google_networkservices1/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 NetworkServices 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_networkservices1 as networkservices1;
49/// use networkservices1::api::AuthzExtension;
50/// use networkservices1::{Result, Error};
51/// # async fn dox() {
52/// use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
53///
54/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
55/// // `client_secret`, among other things.
56/// let secret: yup_oauth2::ApplicationSecret = Default::default();
57/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
58/// // unless you replace `None` with the desired Flow.
59/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
60/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
61/// // retrieve them from storage.
62/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
63/// .with_native_roots()
64/// .unwrap()
65/// .https_only()
66/// .enable_http2()
67/// .build();
68///
69/// let executor = hyper_util::rt::TokioExecutor::new();
70/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
71/// secret,
72/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
73/// yup_oauth2::client::CustomHyperClientBuilder::from(
74/// hyper_util::client::legacy::Client::builder(executor).build(connector),
75/// ),
76/// ).build().await.unwrap();
77///
78/// let client = hyper_util::client::legacy::Client::builder(
79/// hyper_util::rt::TokioExecutor::new()
80/// )
81/// .build(
82/// hyper_rustls::HttpsConnectorBuilder::new()
83/// .with_native_roots()
84/// .unwrap()
85/// .https_or_http()
86/// .enable_http2()
87/// .build()
88/// );
89/// let mut hub = NetworkServices::new(client, auth);
90/// // As the method needs a request, you would usually fill it with the desired information
91/// // into the respective structure. Some of the parts shown here might not be applicable !
92/// // Values shown here are possibly random and not representative !
93/// let mut req = AuthzExtension::default();
94///
95/// // You can configure optional parameters by calling the respective setters at will, and
96/// // execute the final call using `doit()`.
97/// // Values shown here are possibly random and not representative !
98/// let result = hub.projects().locations_authz_extensions_create(req, "parent")
99/// .request_id("sed")
100/// .authz_extension_id("amet.")
101/// .doit().await;
102///
103/// match result {
104/// Err(e) => match e {
105/// // The Error enum provides details about what exactly happened.
106/// // You can also just use its `Debug`, `Display` or `Error` traits
107/// Error::HttpError(_)
108/// |Error::Io(_)
109/// |Error::MissingAPIKey
110/// |Error::MissingToken(_)
111/// |Error::Cancelled
112/// |Error::UploadSizeLimitExceeded(_, _)
113/// |Error::Failure(_)
114/// |Error::BadRequest(_)
115/// |Error::FieldClash(_)
116/// |Error::JsonDecodeError(_, _) => println!("{}", e),
117/// },
118/// Ok(res) => println!("Success: {:?}", res),
119/// }
120/// # }
121/// ```
122#[derive(Clone)]
123pub struct NetworkServices<C> {
124 pub client: common::Client<C>,
125 pub auth: Box<dyn common::GetToken>,
126 _user_agent: String,
127 _base_url: String,
128 _root_url: String,
129}
130
131impl<C> common::Hub for NetworkServices<C> {}
132
133impl<'a, C> NetworkServices<C> {
134 pub fn new<A: 'static + common::GetToken>(
135 client: common::Client<C>,
136 auth: A,
137 ) -> NetworkServices<C> {
138 NetworkServices {
139 client,
140 auth: Box::new(auth),
141 _user_agent: "google-api-rust-client/7.0.0".to_string(),
142 _base_url: "https://networkservices.googleapis.com/".to_string(),
143 _root_url: "https://networkservices.googleapis.com/".to_string(),
144 }
145 }
146
147 pub fn projects(&'a self) -> ProjectMethods<'a, C> {
148 ProjectMethods { hub: self }
149 }
150
151 /// Set the user-agent header field to use in all requests to the server.
152 /// It defaults to `google-api-rust-client/7.0.0`.
153 ///
154 /// Returns the previously set user-agent.
155 pub fn user_agent(&mut self, agent_name: String) -> String {
156 std::mem::replace(&mut self._user_agent, agent_name)
157 }
158
159 /// Set the base url to use in all requests to the server.
160 /// It defaults to `https://networkservices.googleapis.com/`.
161 ///
162 /// Returns the previously set base url.
163 pub fn base_url(&mut self, new_base_url: String) -> String {
164 std::mem::replace(&mut self._base_url, new_base_url)
165 }
166
167 /// Set the root url to use in all requests to the server.
168 /// It defaults to `https://networkservices.googleapis.com/`.
169 ///
170 /// Returns the previously set root url.
171 pub fn root_url(&mut self, new_root_url: String) -> String {
172 std::mem::replace(&mut self._root_url, new_root_url)
173 }
174}
175
176// ############
177// SCHEMAS ###
178// ##########
179/// 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.
180///
181/// This type is not used in any activity, and only used as *part* of another schema.
182///
183#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
184#[serde_with::serde_as]
185#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
186pub struct AuditConfig {
187 /// The configuration for logging of each type of permission.
188 #[serde(rename = "auditLogConfigs")]
189 pub audit_log_configs: Option<Vec<AuditLogConfig>>,
190 /// 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.
191 pub service: Option<String>,
192}
193
194impl common::Part for AuditConfig {}
195
196/// 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.
197///
198/// This type is not used in any activity, and only used as *part* of another schema.
199///
200#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
201#[serde_with::serde_as]
202#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
203pub struct AuditLogConfig {
204 /// Specifies the identities that do not cause logging for this type of permission. Follows the same format of Binding.members.
205 #[serde(rename = "exemptedMembers")]
206 pub exempted_members: Option<Vec<String>>,
207 /// The log type that this config enables.
208 #[serde(rename = "logType")]
209 pub log_type: Option<String>,
210}
211
212impl common::Part for AuditLogConfig {}
213
214/// `AuthzExtension` is a resource that allows traffic forwarding to a callout backend service to make an authorization decision.
215///
216/// # Activities
217///
218/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
219/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
220///
221/// * [locations authz extensions create projects](ProjectLocationAuthzExtensionCreateCall) (request)
222/// * [locations authz extensions get projects](ProjectLocationAuthzExtensionGetCall) (response)
223/// * [locations authz extensions patch projects](ProjectLocationAuthzExtensionPatchCall) (request)
224#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
225#[serde_with::serde_as]
226#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
227pub struct AuthzExtension {
228 /// Required. The `:authority` header in the gRPC request sent from Envoy to the extension service.
229 pub authority: Option<String>,
230 /// Output only. The timestamp when the resource was created.
231 #[serde(rename = "createTime")]
232 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
233 /// Optional. A human-readable description of the resource.
234 pub description: Option<String>,
235 /// Optional. Determines how the proxy behaves if the call to the extension fails or times out. When set to `TRUE`, request or response processing continues without error. Any subsequent extensions in the extension chain are also executed. When set to `FALSE` or the default setting of `FALSE` is used, one of the following happens: * If response headers have not been delivered to the downstream client, a generic 500 error is returned to the client. The error response can be tailored by configuring a custom error response in the load balancer. * If response headers have been delivered, then the HTTP stream to the downstream client is reset.
236 #[serde(rename = "failOpen")]
237 pub fail_open: Option<bool>,
238 /// Optional. List of the HTTP headers to forward to the extension (from the client). If omitted, all headers are sent. Each element is a string indicating the header name.
239 #[serde(rename = "forwardHeaders")]
240 pub forward_headers: Option<Vec<String>>,
241 /// Optional. Set of labels associated with the `AuthzExtension` resource. The format must comply with [the requirements for labels](https://cloud.google.com/compute/docs/labeling-resources#requirements) for Google Cloud resources.
242 pub labels: Option<HashMap<String, String>>,
243 /// Required. All backend services and forwarding rules referenced by this extension must share the same load balancing scheme. Supported values: `INTERNAL_MANAGED`, `EXTERNAL_MANAGED`. For more information, refer to [Backend services overview](https://cloud.google.com/load-balancing/docs/backend-service).
244 #[serde(rename = "loadBalancingScheme")]
245 pub load_balancing_scheme: Option<String>,
246 /// Optional. The metadata provided here is included as part of the `metadata_context` (of type `google.protobuf.Struct`) in the `ProcessingRequest` message sent to the extension server. The metadata is available under the namespace `com.google.authz_extension.`. The following variables are supported in the metadata Struct: `{forwarding_rule_id}` - substituted with the forwarding rule's fully qualified resource name.
247 pub metadata: Option<HashMap<String, serde_json::Value>>,
248 /// Required. Identifier. Name of the `AuthzExtension` resource in the following format: `projects/{project}/locations/{location}/authzExtensions/{authz_extension}`.
249 pub name: Option<String>,
250 /// Required. The reference to the service that runs the extension. To configure a callout extension, `service` must be a fully-qualified reference to a [backend service](https://cloud.google.com/compute/docs/reference/rest/v1/backendServices) in the format: `https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/backendServices/{backendService}` or `https://www.googleapis.com/compute/v1/projects/{project}/global/backendServices/{backendService}`.
251 pub service: Option<String>,
252 /// Required. Specifies the timeout for each individual message on the stream. The timeout must be between 10-10000 milliseconds.
253 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
254 pub timeout: Option<chrono::Duration>,
255 /// Output only. The timestamp when the resource was updated.
256 #[serde(rename = "updateTime")]
257 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
258 /// Optional. The format of communication supported by the callout extension. This field is supported only for regional `AuthzExtension` resources. If not specified, the default value `EXT_PROC_GRPC` is used. Global `AuthzExtension` resources use the `EXT_PROC_GRPC` wire format.
259 #[serde(rename = "wireFormat")]
260 pub wire_format: Option<String>,
261}
262
263impl common::RequestValue for AuthzExtension {}
264impl common::ResponseResult for AuthzExtension {}
265
266/// Associates `members`, or principals, with a `role`.
267///
268/// This type is not used in any activity, and only used as *part* of another schema.
269///
270#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
271#[serde_with::serde_as]
272#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
273pub struct Binding {
274 /// 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).
275 pub condition: Option<Expr>,
276 /// 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`.
277 pub members: Option<Vec<String>>,
278 /// 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).
279 pub role: Option<String>,
280}
281
282impl common::Part for Binding {}
283
284/// The request message for Operations.CancelOperation.
285///
286/// # Activities
287///
288/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
289/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
290///
291/// * [locations operations cancel projects](ProjectLocationOperationCancelCall) (request)
292#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
293#[serde_with::serde_as]
294#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
295pub struct CancelOperationRequest {
296 _never_set: Option<bool>,
297}
298
299impl common::RequestValue for CancelOperationRequest {}
300
301/// 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); }
302///
303/// # Activities
304///
305/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
306/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
307///
308/// * [locations operations cancel projects](ProjectLocationOperationCancelCall) (response)
309/// * [locations operations delete projects](ProjectLocationOperationDeleteCall) (response)
310#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
311#[serde_with::serde_as]
312#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
313pub struct Empty {
314 _never_set: Option<bool>,
315}
316
317impl common::ResponseResult for Empty {}
318
319/// A definition of a matcher that selects endpoints to which the policies should be applied.
320///
321/// This type is not used in any activity, and only used as *part* of another schema.
322///
323#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
324#[serde_with::serde_as]
325#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
326pub struct EndpointMatcher {
327 /// The matcher is based on node metadata presented by xDS clients.
328 #[serde(rename = "metadataLabelMatcher")]
329 pub metadata_label_matcher: Option<EndpointMatcherMetadataLabelMatcher>,
330}
331
332impl common::Part for EndpointMatcher {}
333
334/// The matcher that is based on node metadata presented by xDS clients.
335///
336/// This type is not used in any activity, and only used as *part* of another schema.
337///
338#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
339#[serde_with::serde_as]
340#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
341pub struct EndpointMatcherMetadataLabelMatcher {
342 /// Specifies how matching should be done. Supported values are: MATCH_ANY: At least one of the Labels specified in the matcher should match the metadata presented by xDS client. MATCH_ALL: The metadata presented by the xDS client should contain all of the labels specified here. The selection is determined based on the best match. For example, suppose there are three EndpointPolicy resources P1, P2 and P3 and if P1 has a the matcher as MATCH_ANY , P2 has MATCH_ALL , and P3 has MATCH_ALL . If a client with label connects, the config from P1 will be selected. If a client with label connects, the config from P2 will be selected. If a client with label connects, the config from P3 will be selected. If there is more than one best match, (for example, if a config P4 with selector exists and if a client with label connects), pick up the one with older creation time.
343 #[serde(rename = "metadataLabelMatchCriteria")]
344 pub metadata_label_match_criteria: Option<String>,
345 /// The list of label value pairs that must match labels in the provided metadata based on filterMatchCriteria This list can have at most 64 entries. The list can be empty if the match criteria is MATCH_ANY, to specify a wildcard match (i.e this matches any client).
346 #[serde(rename = "metadataLabels")]
347 pub metadata_labels: Option<Vec<EndpointMatcherMetadataLabelMatcherMetadataLabels>>,
348}
349
350impl common::Part for EndpointMatcherMetadataLabelMatcher {}
351
352/// Defines a name-pair value for a single label.
353///
354/// This type is not used in any activity, and only used as *part* of another schema.
355///
356#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
357#[serde_with::serde_as]
358#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
359pub struct EndpointMatcherMetadataLabelMatcherMetadataLabels {
360 /// Required. Label name presented as key in xDS Node Metadata.
361 #[serde(rename = "labelName")]
362 pub label_name: Option<String>,
363 /// Required. Label value presented as value corresponding to the above key, in xDS Node Metadata.
364 #[serde(rename = "labelValue")]
365 pub label_value: Option<String>,
366}
367
368impl common::Part for EndpointMatcherMetadataLabelMatcherMetadataLabels {}
369
370/// EndpointPolicy is a resource that helps apply desired configuration on the endpoints that match specific criteria. For example, this resource can be used to apply “authentication config” an all endpoints that serve on port 8080.
371///
372/// # Activities
373///
374/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
375/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
376///
377/// * [locations endpoint policies create projects](ProjectLocationEndpointPolicyCreateCall) (request)
378/// * [locations endpoint policies get projects](ProjectLocationEndpointPolicyGetCall) (response)
379/// * [locations endpoint policies patch projects](ProjectLocationEndpointPolicyPatchCall) (request)
380#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
381#[serde_with::serde_as]
382#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
383pub struct EndpointPolicy {
384 /// Optional. This field specifies the URL of AuthorizationPolicy resource that applies authorization policies to the inbound traffic at the matched endpoints. Refer to Authorization. If this field is not specified, authorization is disabled(no authz checks) for this endpoint.
385 #[serde(rename = "authorizationPolicy")]
386 pub authorization_policy: Option<String>,
387 /// Optional. A URL referring to a ClientTlsPolicy resource. ClientTlsPolicy can be set to specify the authentication for traffic from the proxy to the actual endpoints. More specifically, it is applied to the outgoing traffic from the proxy to the endpoint. This is typically used for sidecar model where the proxy identifies itself as endpoint to the control plane, with the connection between sidecar and endpoint requiring authentication. If this field is not set, authentication is disabled(open). Applicable only when EndpointPolicyType is SIDECAR_PROXY.
388 #[serde(rename = "clientTlsPolicy")]
389 pub client_tls_policy: Option<String>,
390 /// Output only. The timestamp when the resource was created.
391 #[serde(rename = "createTime")]
392 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
393 /// Optional. A free-text description of the resource. Max length 1024 characters.
394 pub description: Option<String>,
395 /// Required. A matcher that selects endpoints to which the policies should be applied.
396 #[serde(rename = "endpointMatcher")]
397 pub endpoint_matcher: Option<EndpointMatcher>,
398 /// Optional. Set of label tags associated with the EndpointPolicy resource.
399 pub labels: Option<HashMap<String, String>>,
400 /// Identifier. Name of the EndpointPolicy resource. It matches pattern `projects/{project}/locations/*/endpointPolicies/{endpoint_policy}`.
401 pub name: Option<String>,
402 /// Optional. A URL referring to ServerTlsPolicy resource. ServerTlsPolicy is used to determine the authentication policy to be applied to terminate the inbound traffic at the identified backends. If this field is not set, authentication is disabled(open) for this endpoint.
403 #[serde(rename = "serverTlsPolicy")]
404 pub server_tls_policy: Option<String>,
405 /// Optional. Port selector for the (matched) endpoints. If no port selector is provided, the matched config is applied to all ports.
406 #[serde(rename = "trafficPortSelector")]
407 pub traffic_port_selector: Option<TrafficPortSelector>,
408 /// Required. The type of endpoint policy. This is primarily used to validate the configuration.
409 #[serde(rename = "type")]
410 pub type_: Option<String>,
411 /// Output only. The timestamp when the resource was updated.
412 #[serde(rename = "updateTime")]
413 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
414}
415
416impl common::RequestValue for EndpointPolicy {}
417impl common::ResponseResult for EndpointPolicy {}
418
419/// 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.
420///
421/// This type is not used in any activity, and only used as *part* of another schema.
422///
423#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
424#[serde_with::serde_as]
425#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
426pub struct Expr {
427 /// Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.
428 pub description: Option<String>,
429 /// Textual representation of an expression in Common Expression Language syntax.
430 pub expression: Option<String>,
431 /// Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.
432 pub location: Option<String>,
433 /// 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.
434 pub title: Option<String>,
435}
436
437impl common::Part for Expr {}
438
439/// A single extension chain wrapper that contains the match conditions and extensions to execute.
440///
441/// This type is not used in any activity, and only used as *part* of another schema.
442///
443#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
444#[serde_with::serde_as]
445#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
446pub struct ExtensionChain {
447 /// Required. A set of extensions to execute for the matching request. At least one extension is required. Up to 3 extensions can be defined for each extension chain for `LbTrafficExtension` resource. `LbRouteExtension` and `LbEdgeExtension` chains are limited to 1 extension per extension chain.
448 pub extensions: Option<Vec<ExtensionChainExtension>>,
449 /// Required. Conditions under which this chain is invoked for a request.
450 #[serde(rename = "matchCondition")]
451 pub match_condition: Option<ExtensionChainMatchCondition>,
452 /// Required. The name for this extension chain. The name is logged as part of the HTTP request logs. The name must conform with RFC-1034, is restricted to lower-cased letters, numbers and hyphens, and can have a maximum length of 63 characters. Additionally, the first character must be a letter and the last a letter or a number.
453 pub name: Option<String>,
454}
455
456impl common::Part for ExtensionChain {}
457
458/// A single extension in the chain to execute for the matching request.
459///
460/// This type is not used in any activity, and only used as *part* of another schema.
461///
462#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
463#[serde_with::serde_as]
464#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
465pub struct ExtensionChainExtension {
466 /// Optional. The `:authority` header in the gRPC request sent from Envoy to the extension service. Required for Callout extensions. This field is not supported for plugin extensions. Setting it results in a validation error.
467 pub authority: Option<String>,
468 /// Optional. Determines how the proxy behaves if the call to the extension fails or times out. When set to `TRUE`, request or response processing continues without error. Any subsequent extensions in the extension chain are also executed. When set to `FALSE` or the default setting of `FALSE` is used, one of the following happens: * If response headers have not been delivered to the downstream client, a generic 500 error is returned to the client. The error response can be tailored by configuring a custom error response in the load balancer. * If response headers have been delivered, then the HTTP stream to the downstream client is reset.
469 #[serde(rename = "failOpen")]
470 pub fail_open: Option<bool>,
471 /// Optional. List of the HTTP headers to forward to the extension (from the client or backend). If omitted, all headers are sent. Each element is a string indicating the header name.
472 #[serde(rename = "forwardHeaders")]
473 pub forward_headers: Option<Vec<String>>,
474 /// Optional. The metadata provided here is included as part of the `metadata_context` (of type `google.protobuf.Struct`) in the `ProcessingRequest` message sent to the extension server. For `AuthzExtension` resources, the metadata is available under the namespace `com.google.authz_extension.`. For other types of extensions, the metadata is available under the namespace `com.google....`. For example: `com.google.lb_traffic_extension.lbtrafficextension1.chain1.ext1`. The following variables are supported in the metadata: `{forwarding_rule_id}` - substituted with the forwarding rule's fully qualified resource name. This field must not be set for plugin extensions. Setting it results in a validation error. You can set metadata at either the resource level or the extension level. The extension level metadata is recommended because you can pass a different set of metadata through each extension to the backend. This field is subject to following limitations: * The total size of the metadata must be less than 1KiB. * The total number of keys in the metadata must be less than 16. * The length of each key must be less than 64 characters. * The length of each value must be less than 1024 characters. * All values must be strings.
475 pub metadata: Option<HashMap<String, serde_json::Value>>,
476 /// Optional. The name for this extension. The name is logged as part of the HTTP request logs. The name must conform with RFC-1034, is restricted to lower-cased letters, numbers and hyphens, and can have a maximum length of 63 characters. Additionally, the first character must be a letter and the last a letter or a number. This field is required except for AuthzExtension.
477 pub name: Option<String>,
478 /// Optional. When set to `TRUE`, enables `observability_mode` on the `ext_proc` filter. This makes `ext_proc` calls asynchronous. Envoy doesn't check for the response from `ext_proc` calls. For more information about the filter, see: https://www.envoyproxy.io/docs/envoy/v1.32.3/api-v3/extensions/filters/http/ext_proc/v3/ext_proc.proto#extensions-filters-http-ext-proc-v3-externalprocessor This field is helpful when you want to try out the extension in async log-only mode. Supported by regional `LbTrafficExtension` and `LbRouteExtension` resources. Only `STREAMED` (default) body processing mode is supported.
479 #[serde(rename = "observabilityMode")]
480 pub observability_mode: Option<bool>,
481 /// Optional. Configures the send mode for request body processing. The field can only be set if `supported_events` includes `REQUEST_BODY`. If `supported_events` includes `REQUEST_BODY`, but `request_body_send_mode` is unset, the default value `STREAMED` is used. When this field is set to `FULL_DUPLEX_STREAMED`, `supported_events` must include both `REQUEST_BODY` and `REQUEST_TRAILERS`. This field can be set only for `LbTrafficExtension` and `LbRouteExtension` resources, and only when the `service` field of the extension points to a `BackendService`. Only `FULL_DUPLEX_STREAMED` mode is supported for `LbRouteExtension` resources.
482 #[serde(rename = "requestBodySendMode")]
483 pub request_body_send_mode: Option<String>,
484 /// Optional. Configures the send mode for response processing. If unspecified, the default value `STREAMED` is used. The field can only be set if `supported_events` includes `RESPONSE_BODY`. If `supported_events` includes `RESPONSE_BODY`, but `response_body_send_mode` is unset, the default value `STREAMED` is used. When this field is set to `FULL_DUPLEX_STREAMED`, `supported_events` must include both `RESPONSE_BODY` and `RESPONSE_TRAILERS`. This field can be set only for `LbTrafficExtension` resources, and only when the `service` field of the extension points to a `BackendService`.
485 #[serde(rename = "responseBodySendMode")]
486 pub response_body_send_mode: Option<String>,
487 /// Required. The reference to the service that runs the extension. To configure a callout extension, `service` must be a fully-qualified reference to a [backend service](https://cloud.google.com/compute/docs/reference/rest/v1/backendServices) in the format: `https://www.googleapis.com/compute/v1/projects/{project}/regions/{region}/backendServices/{backendService}` or `https://www.googleapis.com/compute/v1/projects/{project}/global/backendServices/{backendService}`. To configure a plugin extension, `service` must be a reference to a [`WasmPlugin` resource](https://cloud.google.com/service-extensions/docs/reference/rest/v1beta1/projects.locations.wasmPlugins) in the format: `projects/{project}/locations/{location}/wasmPlugins/{plugin}` or `//networkservices.googleapis.com/projects/{project}/locations/{location}/wasmPlugins/{wasmPlugin}`. Plugin extensions are currently supported for the `LbTrafficExtension`, the `LbRouteExtension`, and the `LbEdgeExtension` resources.
488 pub service: Option<String>,
489 /// Optional. A set of events during request or response processing for which this extension is called. For the `LbTrafficExtension` resource, this field is required. For the `LbRouteExtension` resource, this field is optional. If unspecified, `REQUEST_HEADERS` event is assumed as supported. For the `LbEdgeExtension` resource, this field is required and must only contain `REQUEST_HEADERS` event. For the `AuthzExtension` resource, this field is optional. `REQUEST_HEADERS` is the only supported event. If unspecified, `REQUEST_HEADERS` event is assumed as supported.
490 #[serde(rename = "supportedEvents")]
491 pub supported_events: Option<Vec<String>>,
492 /// Optional. Specifies the timeout for each individual message on the stream. The timeout must be between `10`-`10000` milliseconds. Required for callout extensions. This field is not supported for plugin extensions. Setting it results in a validation error.
493 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
494 pub timeout: Option<chrono::Duration>,
495}
496
497impl common::Part for ExtensionChainExtension {}
498
499/// Conditions under which this chain is invoked for a request.
500///
501/// This type is not used in any activity, and only used as *part* of another schema.
502///
503#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
504#[serde_with::serde_as]
505#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
506pub struct ExtensionChainMatchCondition {
507 /// Required. A Common Expression Language (CEL) expression that is used to match requests for which the extension chain is executed. For more information, see [CEL matcher language reference](https://cloud.google.com/service-extensions/docs/cel-matcher-language-reference).
508 #[serde(rename = "celExpression")]
509 pub cel_expression: Option<String>,
510}
511
512impl common::Part for ExtensionChainMatchCondition {}
513
514/// Gateway represents the configuration for a proxy, typically a load balancer. It captures the ip:port over which the services are exposed by the proxy, along with any policy configurations. Routes have reference to to Gateways to dictate how requests should be routed by this Gateway.
515///
516/// # Activities
517///
518/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
519/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
520///
521/// * [locations gateways create projects](ProjectLocationGatewayCreateCall) (request)
522/// * [locations gateways get projects](ProjectLocationGatewayGetCall) (response)
523/// * [locations gateways patch projects](ProjectLocationGatewayPatchCall) (request)
524#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
525#[serde_with::serde_as]
526#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
527pub struct Gateway {
528 /// Optional. Zero or one IPv4 or IPv6 address on which the Gateway will receive the traffic. When no address is provided, an IP from the subnetwork is allocated This field only applies to gateways of type 'SECURE_WEB_GATEWAY'. Gateways of type 'OPEN_MESH' listen on 0.0.0.0 for IPv4 and :: for IPv6.
529 pub addresses: Option<Vec<String>>,
530 /// Optional. A fully-qualified Certificates URL reference. The proxy presents a Certificate (selected based on SNI) when establishing a TLS connection. This feature only applies to gateways of type 'SECURE_WEB_GATEWAY'.
531 #[serde(rename = "certificateUrls")]
532 pub certificate_urls: Option<Vec<String>>,
533 /// Output only. The timestamp when the resource was created.
534 #[serde(rename = "createTime")]
535 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
536 /// Optional. A free-text description of the resource. Max length 1024 characters.
537 pub description: Option<String>,
538 /// Optional. Determines if envoy will insert internal debug headers into upstream requests. Other Envoy headers may still be injected. By default, envoy will not insert any debug headers.
539 #[serde(rename = "envoyHeaders")]
540 pub envoy_headers: Option<String>,
541 /// Optional. A fully-qualified GatewaySecurityPolicy URL reference. Defines how a server should apply security policy to inbound (VM to Proxy) initiated connections. For example: `projects/*/locations/*/gatewaySecurityPolicies/swg-policy`. This policy is specific to gateways of type 'SECURE_WEB_GATEWAY'.
542 #[serde(rename = "gatewaySecurityPolicy")]
543 pub gateway_security_policy: Option<String>,
544 /// Optional. The IP Version that will be used by this gateway. Valid options are IPV4 or IPV6. Default is IPV4.
545 #[serde(rename = "ipVersion")]
546 pub ip_version: Option<String>,
547 /// Optional. Set of label tags associated with the Gateway resource.
548 pub labels: Option<HashMap<String, String>>,
549 /// Identifier. Name of the Gateway resource. It matches pattern `projects/*/locations/*/gateways/`.
550 pub name: Option<String>,
551 /// Optional. The relative resource name identifying the VPC network that is using this configuration. For example: `projects/*/global/networks/network-1`. Currently, this field is specific to gateways of type 'SECURE_WEB_GATEWAY'.
552 pub network: Option<String>,
553 /// Required. One or more port numbers (1-65535), on which the Gateway will receive traffic. The proxy binds to the specified ports. Gateways of type 'SECURE_WEB_GATEWAY' are limited to 5 ports. Gateways of type 'OPEN_MESH' listen on 0.0.0.0 for IPv4 and :: for IPv6 and support multiple ports.
554 pub ports: Option<Vec<i32>>,
555 /// Optional. The routing mode of the Gateway. This field is configurable only for gateways of type SECURE_WEB_GATEWAY. This field is required for gateways of type SECURE_WEB_GATEWAY.
556 #[serde(rename = "routingMode")]
557 pub routing_mode: Option<String>,
558 /// Optional. Scope determines how configuration across multiple Gateway instances are merged. The configuration for multiple Gateway instances with the same scope will be merged as presented as a single configuration to the proxy/load balancer. Max length 64 characters. Scope should start with a letter and can only have letters, numbers, hyphens.
559 pub scope: Option<String>,
560 /// Output only. Server-defined URL of this resource
561 #[serde(rename = "selfLink")]
562 pub self_link: Option<String>,
563 /// Optional. A fully-qualified ServerTLSPolicy URL reference. Specifies how TLS traffic is terminated. If empty, TLS termination is disabled.
564 #[serde(rename = "serverTlsPolicy")]
565 pub server_tls_policy: Option<String>,
566 /// Optional. The relative resource name identifying the subnetwork in which this SWG is allocated. For example: `projects/*/regions/us-central1/subnetworks/network-1` Currently, this field is specific to gateways of type 'SECURE_WEB_GATEWAY".
567 pub subnetwork: Option<String>,
568 /// Immutable. The type of the customer managed gateway. This field is required. If unspecified, an error is returned.
569 #[serde(rename = "type")]
570 pub type_: Option<String>,
571 /// Output only. The timestamp when the resource was updated.
572 #[serde(rename = "updateTime")]
573 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
574}
575
576impl common::RequestValue for Gateway {}
577impl common::ResponseResult for Gateway {}
578
579/// GatewayRouteView defines view-only resource for Routes to a Gateway
580///
581/// # Activities
582///
583/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
584/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
585///
586/// * [locations gateways route views get projects](ProjectLocationGatewayRouteViewGetCall) (response)
587#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
588#[serde_with::serde_as]
589#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
590pub struct GatewayRouteView {
591 /// Output only. Identifier. Full path name of the GatewayRouteView resource. Format: projects/{project_number}/locations/{location}/gateways/{gateway}/routeViews/{route_view}
592 pub name: Option<String>,
593 /// Output only. The resource id for the route.
594 #[serde(rename = "routeId")]
595 pub route_id: Option<String>,
596 /// Output only. Location where the route exists.
597 #[serde(rename = "routeLocation")]
598 pub route_location: Option<String>,
599 /// Output only. Project number where the route exists.
600 #[serde(rename = "routeProjectNumber")]
601 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
602 pub route_project_number: Option<i64>,
603 /// Output only. Type of the route: HttpRoute,GrpcRoute,TcpRoute, or TlsRoute
604 #[serde(rename = "routeType")]
605 pub route_type: Option<String>,
606}
607
608impl common::ResponseResult for GatewayRouteView {}
609
610/// GrpcRoute is the resource defining how gRPC traffic routed by a Mesh or Gateway resource is routed.
611///
612/// # Activities
613///
614/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
615/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
616///
617/// * [locations grpc routes create projects](ProjectLocationGrpcRouteCreateCall) (request)
618/// * [locations grpc routes get projects](ProjectLocationGrpcRouteGetCall) (response)
619/// * [locations grpc routes patch projects](ProjectLocationGrpcRoutePatchCall) (request)
620#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
621#[serde_with::serde_as]
622#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
623pub struct GrpcRoute {
624 /// Output only. The timestamp when the resource was created.
625 #[serde(rename = "createTime")]
626 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
627 /// Optional. A free-text description of the resource. Max length 1024 characters.
628 pub description: Option<String>,
629 /// Optional. Gateways defines a list of gateways this GrpcRoute is attached to, as one of the routing rules to route the requests served by the gateway. Each gateway reference should match the pattern: `projects/*/locations/*/gateways/`
630 pub gateways: Option<Vec<String>>,
631 /// Required. Service hostnames with an optional port for which this route describes traffic. Format: [:] Hostname is the fully qualified domain name of a network host. This matches the RFC 1123 definition of a hostname with 2 notable exceptions: - IPs are not allowed. - A hostname may be prefixed with a wildcard label (`*.`). The wildcard label must appear by itself as the first label. Hostname can be "precise" which is a domain name without the terminating dot of a network host (e.g. `foo.example.com`) or "wildcard", which is a domain name prefixed with a single wildcard label (e.g. `*.example.com`). Note that as per RFC1035 and RFC1123, a label must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character. No other punctuation is allowed. The routes associated with a Mesh or Gateway must have unique hostnames. If you attempt to attach multiple routes with conflicting hostnames, the configuration will be rejected. For example, while it is acceptable for routes for the hostnames `*.foo.bar.com` and `*.bar.com` to be associated with the same route, it is not possible to associate two routes both with `*.bar.com` or both with `bar.com`. If a port is specified, then gRPC clients must use the channel URI with the port to match this rule (i.e. "xds:///service:123"), otherwise they must supply the URI without a port (i.e. "xds:///service").
632 pub hostnames: Option<Vec<String>>,
633 /// Optional. Set of label tags associated with the GrpcRoute resource.
634 pub labels: Option<HashMap<String, String>>,
635 /// Optional. Meshes defines a list of meshes this GrpcRoute is attached to, as one of the routing rules to route the requests served by the mesh. Each mesh reference should match the pattern: `projects/*/locations/*/meshes/`
636 pub meshes: Option<Vec<String>>,
637 /// Identifier. Name of the GrpcRoute resource. It matches pattern `projects/*/locations/*/grpcRoutes/`
638 pub name: Option<String>,
639 /// Required. A list of detailed rules defining how to route traffic. Within a single GrpcRoute, the GrpcRoute.RouteAction associated with the first matching GrpcRoute.RouteRule will be executed. At least one rule must be supplied.
640 pub rules: Option<Vec<GrpcRouteRouteRule>>,
641 /// Output only. Server-defined URL of this resource
642 #[serde(rename = "selfLink")]
643 pub self_link: Option<String>,
644 /// Output only. The timestamp when the resource was updated.
645 #[serde(rename = "updateTime")]
646 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
647}
648
649impl common::RequestValue for GrpcRoute {}
650impl common::ResponseResult for GrpcRoute {}
651
652/// The destination to which traffic will be routed.
653///
654/// This type is not used in any activity, and only used as *part* of another schema.
655///
656#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
657#[serde_with::serde_as]
658#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
659pub struct GrpcRouteDestination {
660 /// Required. The URL of a destination service to which to route traffic. Must refer to either a BackendService or ServiceDirectoryService.
661 #[serde(rename = "serviceName")]
662 pub service_name: Option<String>,
663 /// Optional. Specifies the proportion of requests forwarded to the backend referenced by the serviceName field. This is computed as: - weight/Sum(weights in this destination list). For non-zero values, there may be some epsilon from the exact proportion defined here depending on the precision an implementation supports. If only one serviceName is specified and it has a weight greater than 0, 100% of the traffic is forwarded to that backend. If weights are specified for any one service name, they need to be specified for all of them. If weights are unspecified for all services, then, traffic is distributed in equal proportions to all of them.
664 pub weight: Option<i32>,
665}
666
667impl common::Part for GrpcRouteDestination {}
668
669/// The specification for fault injection introduced into traffic to test the resiliency of clients to destination service failure. As part of fault injection, when clients send requests to a destination, delays can be introduced on a percentage of requests before sending those requests to the destination service. Similarly requests from clients can be aborted by for a percentage of requests.
670///
671/// This type is not used in any activity, and only used as *part* of another schema.
672///
673#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
674#[serde_with::serde_as]
675#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
676pub struct GrpcRouteFaultInjectionPolicy {
677 /// The specification for aborting to client requests.
678 pub abort: Option<GrpcRouteFaultInjectionPolicyAbort>,
679 /// The specification for injecting delay to client requests.
680 pub delay: Option<GrpcRouteFaultInjectionPolicyDelay>,
681}
682
683impl common::Part for GrpcRouteFaultInjectionPolicy {}
684
685/// Specification of how client requests are aborted as part of fault injection before being sent to a destination.
686///
687/// This type is not used in any activity, and only used as *part* of another schema.
688///
689#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
690#[serde_with::serde_as]
691#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
692pub struct GrpcRouteFaultInjectionPolicyAbort {
693 /// The HTTP status code used to abort the request. The value must be between 200 and 599 inclusive.
694 #[serde(rename = "httpStatus")]
695 pub http_status: Option<i32>,
696 /// The percentage of traffic which will be aborted. The value must be between [0, 100]
697 pub percentage: Option<i32>,
698}
699
700impl common::Part for GrpcRouteFaultInjectionPolicyAbort {}
701
702/// Specification of how client requests are delayed as part of fault injection before being sent to a destination.
703///
704/// This type is not used in any activity, and only used as *part* of another schema.
705///
706#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
707#[serde_with::serde_as]
708#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
709pub struct GrpcRouteFaultInjectionPolicyDelay {
710 /// Specify a fixed delay before forwarding the request.
711 #[serde(rename = "fixedDelay")]
712 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
713 pub fixed_delay: Option<chrono::Duration>,
714 /// The percentage of traffic on which delay will be injected. The value must be between [0, 100]
715 pub percentage: Option<i32>,
716}
717
718impl common::Part for GrpcRouteFaultInjectionPolicyDelay {}
719
720/// A match against a collection of headers.
721///
722/// This type is not used in any activity, and only used as *part* of another schema.
723///
724#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
725#[serde_with::serde_as]
726#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
727pub struct GrpcRouteHeaderMatch {
728 /// Required. The key of the header.
729 pub key: Option<String>,
730 /// Optional. Specifies how to match against the value of the header. If not specified, a default value of EXACT is used.
731 #[serde(rename = "type")]
732 pub type_: Option<String>,
733 /// Required. The value of the header.
734 pub value: Option<String>,
735}
736
737impl common::Part for GrpcRouteHeaderMatch {}
738
739/// Specifies a match against a method.
740///
741/// This type is not used in any activity, and only used as *part* of another schema.
742///
743#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
744#[serde_with::serde_as]
745#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
746pub struct GrpcRouteMethodMatch {
747 /// Optional. Specifies that matches are case sensitive. The default value is true. case_sensitive must not be used with a type of REGULAR_EXPRESSION.
748 #[serde(rename = "caseSensitive")]
749 pub case_sensitive: Option<bool>,
750 /// Required. Name of the method to match against. If unspecified, will match all methods.
751 #[serde(rename = "grpcMethod")]
752 pub grpc_method: Option<String>,
753 /// Required. Name of the service to match against. If unspecified, will match all services.
754 #[serde(rename = "grpcService")]
755 pub grpc_service: Option<String>,
756 /// Optional. Specifies how to match against the name. If not specified, a default value of "EXACT" is used.
757 #[serde(rename = "type")]
758 pub type_: Option<String>,
759}
760
761impl common::Part for GrpcRouteMethodMatch {}
762
763/// The specifications for retries. Specifies one or more conditions for which this retry rule applies. Valid values are:
764///
765/// This type is not used in any activity, and only used as *part* of another schema.
766///
767#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
768#[serde_with::serde_as]
769#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
770pub struct GrpcRouteRetryPolicy {
771 /// Specifies the allowed number of retries. This number must be > 0. If not specified, default to 1.
772 #[serde(rename = "numRetries")]
773 pub num_retries: Option<u32>,
774 /// - connect-failure: Router will retry on failures connecting to Backend Services, for example due to connection timeouts. - refused-stream: Router will retry if the backend service resets the stream with a REFUSED_STREAM error code. This reset type indicates that it is safe to retry. - cancelled: Router will retry if the gRPC status code in the response header is set to cancelled - deadline-exceeded: Router will retry if the gRPC status code in the response header is set to deadline-exceeded - resource-exhausted: Router will retry if the gRPC status code in the response header is set to resource-exhausted - unavailable: Router will retry if the gRPC status code in the response header is set to unavailable
775 #[serde(rename = "retryConditions")]
776 pub retry_conditions: Option<Vec<String>>,
777}
778
779impl common::Part for GrpcRouteRetryPolicy {}
780
781/// Specifies how to route matched traffic.
782///
783/// This type is not used in any activity, and only used as *part* of another schema.
784///
785#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
786#[serde_with::serde_as]
787#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
788pub struct GrpcRouteRouteAction {
789 /// Optional. The destination services to which traffic should be forwarded. If multiple destinations are specified, traffic will be split between Backend Service(s) according to the weight field of these destinations.
790 pub destinations: Option<Vec<GrpcRouteDestination>>,
791 /// Optional. The specification for fault injection introduced into traffic to test the resiliency of clients to destination service failure. As part of fault injection, when clients send requests to a destination, delays can be introduced on a percentage of requests before sending those requests to the destination service. Similarly requests from clients can be aborted by for a percentage of requests. timeout and retry_policy will be ignored by clients that are configured with a fault_injection_policy
792 #[serde(rename = "faultInjectionPolicy")]
793 pub fault_injection_policy: Option<GrpcRouteFaultInjectionPolicy>,
794 /// Optional. Specifies the idle timeout for the selected route. The idle timeout is defined as the period in which there are no bytes sent or received on either the upstream or downstream connection. If not set, the default idle timeout is 1 hour. If set to 0s, the timeout will be disabled.
795 #[serde(rename = "idleTimeout")]
796 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
797 pub idle_timeout: Option<chrono::Duration>,
798 /// Optional. Specifies the retry policy associated with this route.
799 #[serde(rename = "retryPolicy")]
800 pub retry_policy: Option<GrpcRouteRetryPolicy>,
801 /// Optional. Specifies cookie-based stateful session affinity.
802 #[serde(rename = "statefulSessionAffinity")]
803 pub stateful_session_affinity: Option<GrpcRouteStatefulSessionAffinityPolicy>,
804 /// Optional. Specifies the timeout for selected route. Timeout is computed from the time the request has been fully processed (i.e. end of stream) up until the response has been completely processed. Timeout includes all retries.
805 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
806 pub timeout: Option<chrono::Duration>,
807}
808
809impl common::Part for GrpcRouteRouteAction {}
810
811/// Criteria for matching traffic. A RouteMatch will be considered to match when all supplied fields match.
812///
813/// This type is not used in any activity, and only used as *part* of another schema.
814///
815#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
816#[serde_with::serde_as]
817#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
818pub struct GrpcRouteRouteMatch {
819 /// Optional. Specifies a collection of headers to match.
820 pub headers: Option<Vec<GrpcRouteHeaderMatch>>,
821 /// Optional. A gRPC method to match against. If this field is empty or omitted, will match all methods.
822 pub method: Option<GrpcRouteMethodMatch>,
823}
824
825impl common::Part for GrpcRouteRouteMatch {}
826
827/// Describes how to route traffic.
828///
829/// This type is not used in any activity, and only used as *part* of another schema.
830///
831#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
832#[serde_with::serde_as]
833#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
834pub struct GrpcRouteRouteRule {
835 /// Required. A detailed rule defining how to route traffic. This field is required.
836 pub action: Option<GrpcRouteRouteAction>,
837 /// Optional. Matches define conditions used for matching the rule against incoming gRPC requests. Each match is independent, i.e. this rule will be matched if ANY one of the matches is satisfied. If no matches field is specified, this rule will unconditionally match traffic.
838 pub matches: Option<Vec<GrpcRouteRouteMatch>>,
839}
840
841impl common::Part for GrpcRouteRouteRule {}
842
843/// The specification for cookie-based stateful session affinity where the date plane supplies a “session cookie” with the name "GSSA" which encodes a specific destination host and each request containing that cookie will be directed to that host as long as the destination host remains up and healthy. The gRPC proxyless mesh library or sidecar proxy will manage the session cookie but the client application code is responsible for copying the cookie from each RPC in the session to the next.
844///
845/// This type is not used in any activity, and only used as *part* of another schema.
846///
847#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
848#[serde_with::serde_as]
849#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
850pub struct GrpcRouteStatefulSessionAffinityPolicy {
851 /// Required. The cookie TTL value for the Set-Cookie header generated by the data plane. The lifetime of the cookie may be set to a value from 0 to 86400 seconds (24 hours) inclusive. Set this to 0s to use a session cookie and disable cookie expiration.
852 #[serde(rename = "cookieTtl")]
853 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
854 pub cookie_ttl: Option<chrono::Duration>,
855}
856
857impl common::Part for GrpcRouteStatefulSessionAffinityPolicy {}
858
859/// HttpRoute is the resource defining how HTTP traffic should be routed by a Mesh or Gateway resource.
860///
861/// # Activities
862///
863/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
864/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
865///
866/// * [locations http routes create projects](ProjectLocationHttpRouteCreateCall) (request)
867/// * [locations http routes get projects](ProjectLocationHttpRouteGetCall) (response)
868/// * [locations http routes patch projects](ProjectLocationHttpRoutePatchCall) (request)
869#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
870#[serde_with::serde_as]
871#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
872pub struct HttpRoute {
873 /// Output only. The timestamp when the resource was created.
874 #[serde(rename = "createTime")]
875 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
876 /// Optional. A free-text description of the resource. Max length 1024 characters.
877 pub description: Option<String>,
878 /// Optional. Gateways defines a list of gateways this HttpRoute is attached to, as one of the routing rules to route the requests served by the gateway. Each gateway reference should match the pattern: `projects/*/locations/*/gateways/`
879 pub gateways: Option<Vec<String>>,
880 /// Required. Hostnames define a set of hosts that should match against the HTTP host header to select a HttpRoute to process the request. Hostname is the fully qualified domain name of a network host, as defined by RFC 1123 with the exception that: - IPs are not allowed. - A hostname may be prefixed with a wildcard label (`*.`). The wildcard label must appear by itself as the first label. Hostname can be "precise" which is a domain name without the terminating dot of a network host (e.g. `foo.example.com`) or "wildcard", which is a domain name prefixed with a single wildcard label (e.g. `*.example.com`). Note that as per RFC1035 and RFC1123, a label must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character. No other punctuation is allowed. The routes associated with a Mesh or Gateways must have unique hostnames. If you attempt to attach multiple routes with conflicting hostnames, the configuration will be rejected. For example, while it is acceptable for routes for the hostnames `*.foo.bar.com` and `*.bar.com` to be associated with the same Mesh (or Gateways under the same scope), it is not possible to associate two routes both with `*.bar.com` or both with `bar.com`.
881 pub hostnames: Option<Vec<String>>,
882 /// Optional. Set of label tags associated with the HttpRoute resource.
883 pub labels: Option<HashMap<String, String>>,
884 /// Optional. Meshes defines a list of meshes this HttpRoute is attached to, as one of the routing rules to route the requests served by the mesh. Each mesh reference should match the pattern: `projects/*/locations/*/meshes/` The attached Mesh should be of a type SIDECAR
885 pub meshes: Option<Vec<String>>,
886 /// Identifier. Name of the HttpRoute resource. It matches pattern `projects/*/locations/*/httpRoutes/http_route_name>`.
887 pub name: Option<String>,
888 /// Required. Rules that define how traffic is routed and handled. Rules will be matched sequentially based on the RouteMatch specified for the rule.
889 pub rules: Option<Vec<HttpRouteRouteRule>>,
890 /// Output only. Server-defined URL of this resource
891 #[serde(rename = "selfLink")]
892 pub self_link: Option<String>,
893 /// Output only. The timestamp when the resource was updated.
894 #[serde(rename = "updateTime")]
895 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
896}
897
898impl common::RequestValue for HttpRoute {}
899impl common::ResponseResult for HttpRoute {}
900
901/// The Specification for allowing client side cross-origin requests.
902///
903/// This type is not used in any activity, and only used as *part* of another schema.
904///
905#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
906#[serde_with::serde_as]
907#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
908pub struct HttpRouteCorsPolicy {
909 /// In response to a preflight request, setting this to true indicates that the actual request can include user credentials. This translates to the Access-Control-Allow-Credentials header. Default value is false.
910 #[serde(rename = "allowCredentials")]
911 pub allow_credentials: Option<bool>,
912 /// Specifies the content for Access-Control-Allow-Headers header.
913 #[serde(rename = "allowHeaders")]
914 pub allow_headers: Option<Vec<String>>,
915 /// Specifies the content for Access-Control-Allow-Methods header.
916 #[serde(rename = "allowMethods")]
917 pub allow_methods: Option<Vec<String>>,
918 /// Specifies the regular expression patterns that match allowed origins. For regular expression grammar, please see https://github.com/google/re2/wiki/Syntax.
919 #[serde(rename = "allowOriginRegexes")]
920 pub allow_origin_regexes: Option<Vec<String>>,
921 /// Specifies the list of origins that will be allowed to do CORS requests. An origin is allowed if it matches either an item in allow_origins or an item in allow_origin_regexes.
922 #[serde(rename = "allowOrigins")]
923 pub allow_origins: Option<Vec<String>>,
924 /// If true, the CORS policy is disabled. The default value is false, which indicates that the CORS policy is in effect.
925 pub disabled: Option<bool>,
926 /// Specifies the content for Access-Control-Expose-Headers header.
927 #[serde(rename = "exposeHeaders")]
928 pub expose_headers: Option<Vec<String>>,
929 /// Specifies how long result of a preflight request can be cached in seconds. This translates to the Access-Control-Max-Age header.
930 #[serde(rename = "maxAge")]
931 pub max_age: Option<String>,
932}
933
934impl common::Part for HttpRouteCorsPolicy {}
935
936/// Specifications of a destination to which the request should be routed to.
937///
938/// This type is not used in any activity, and only used as *part* of another schema.
939///
940#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
941#[serde_with::serde_as]
942#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
943pub struct HttpRouteDestination {
944 /// Optional. The specification for modifying the headers of a matching request prior to delivery of the request to the destination. If HeaderModifiers are set on both the Destination and the RouteAction, they will be merged. Conflicts between the two will not be resolved on the configuration.
945 #[serde(rename = "requestHeaderModifier")]
946 pub request_header_modifier: Option<HttpRouteHeaderModifier>,
947 /// Optional. The specification for modifying the headers of a response prior to sending the response back to the client. If HeaderModifiers are set on both the Destination and the RouteAction, they will be merged. Conflicts between the two will not be resolved on the configuration.
948 #[serde(rename = "responseHeaderModifier")]
949 pub response_header_modifier: Option<HttpRouteHeaderModifier>,
950 /// The URL of a BackendService to route traffic to.
951 #[serde(rename = "serviceName")]
952 pub service_name: Option<String>,
953 /// Specifies the proportion of requests forwarded to the backend referenced by the serviceName field. This is computed as: - weight/Sum(weights in this destination list). For non-zero values, there may be some epsilon from the exact proportion defined here depending on the precision an implementation supports. If only one serviceName is specified and it has a weight greater than 0, 100% of the traffic is forwarded to that backend. If weights are specified for any one service name, they need to be specified for all of them. If weights are unspecified for all services, then, traffic is distributed in equal proportions to all of them.
954 pub weight: Option<i32>,
955}
956
957impl common::Part for HttpRouteDestination {}
958
959/// The specification for fault injection introduced into traffic to test the resiliency of clients to destination service failure. As part of fault injection, when clients send requests to a destination, delays can be introduced by client proxy on a percentage of requests before sending those requests to the destination service. Similarly requests can be aborted by client proxy for a percentage of requests.
960///
961/// This type is not used in any activity, and only used as *part* of another schema.
962///
963#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
964#[serde_with::serde_as]
965#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
966pub struct HttpRouteFaultInjectionPolicy {
967 /// The specification for aborting to client requests.
968 pub abort: Option<HttpRouteFaultInjectionPolicyAbort>,
969 /// The specification for injecting delay to client requests.
970 pub delay: Option<HttpRouteFaultInjectionPolicyDelay>,
971}
972
973impl common::Part for HttpRouteFaultInjectionPolicy {}
974
975/// Specification of how client requests are aborted as part of fault injection before being sent to a destination.
976///
977/// This type is not used in any activity, and only used as *part* of another schema.
978///
979#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
980#[serde_with::serde_as]
981#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
982pub struct HttpRouteFaultInjectionPolicyAbort {
983 /// The HTTP status code used to abort the request. The value must be between 200 and 599 inclusive.
984 #[serde(rename = "httpStatus")]
985 pub http_status: Option<i32>,
986 /// The percentage of traffic which will be aborted. The value must be between [0, 100]
987 pub percentage: Option<i32>,
988}
989
990impl common::Part for HttpRouteFaultInjectionPolicyAbort {}
991
992/// Specification of how client requests are delayed as part of fault injection before being sent to a destination.
993///
994/// This type is not used in any activity, and only used as *part* of another schema.
995///
996#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
997#[serde_with::serde_as]
998#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
999pub struct HttpRouteFaultInjectionPolicyDelay {
1000 /// Specify a fixed delay before forwarding the request.
1001 #[serde(rename = "fixedDelay")]
1002 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
1003 pub fixed_delay: Option<chrono::Duration>,
1004 /// The percentage of traffic on which delay will be injected. The value must be between [0, 100]
1005 pub percentage: Option<i32>,
1006}
1007
1008impl common::Part for HttpRouteFaultInjectionPolicyDelay {}
1009
1010/// Specifies how to select a route rule based on HTTP request headers.
1011///
1012/// This type is not used in any activity, and only used as *part* of another schema.
1013///
1014#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1015#[serde_with::serde_as]
1016#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1017pub struct HttpRouteHeaderMatch {
1018 /// The value of the header should match exactly the content of exact_match.
1019 #[serde(rename = "exactMatch")]
1020 pub exact_match: Option<String>,
1021 /// The name of the HTTP header to match against.
1022 pub header: Option<String>,
1023 /// If specified, the match result will be inverted before checking. Default value is set to false.
1024 #[serde(rename = "invertMatch")]
1025 pub invert_match: Option<bool>,
1026 /// The value of the header must start with the contents of prefix_match.
1027 #[serde(rename = "prefixMatch")]
1028 pub prefix_match: Option<String>,
1029 /// A header with header_name must exist. The match takes place whether or not the header has a value.
1030 #[serde(rename = "presentMatch")]
1031 pub present_match: Option<bool>,
1032 /// If specified, the rule will match if the request header value is within the range.
1033 #[serde(rename = "rangeMatch")]
1034 pub range_match: Option<HttpRouteHeaderMatchIntegerRange>,
1035 /// The value of the header must match the regular expression specified in regex_match. For regular expression grammar, please see: https://github.com/google/re2/wiki/Syntax
1036 #[serde(rename = "regexMatch")]
1037 pub regex_match: Option<String>,
1038 /// The value of the header must end with the contents of suffix_match.
1039 #[serde(rename = "suffixMatch")]
1040 pub suffix_match: Option<String>,
1041}
1042
1043impl common::Part for HttpRouteHeaderMatch {}
1044
1045/// Represents an integer value range.
1046///
1047/// This type is not used in any activity, and only used as *part* of another schema.
1048///
1049#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1050#[serde_with::serde_as]
1051#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1052pub struct HttpRouteHeaderMatchIntegerRange {
1053 /// End of the range (exclusive)
1054 pub end: Option<i32>,
1055 /// Start of the range (inclusive)
1056 pub start: Option<i32>,
1057}
1058
1059impl common::Part for HttpRouteHeaderMatchIntegerRange {}
1060
1061/// The specification for modifying HTTP header in HTTP request and HTTP response.
1062///
1063/// This type is not used in any activity, and only used as *part* of another schema.
1064///
1065#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1066#[serde_with::serde_as]
1067#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1068pub struct HttpRouteHeaderModifier {
1069 /// Add the headers with given map where key is the name of the header, value is the value of the header.
1070 pub add: Option<HashMap<String, String>>,
1071 /// Remove headers (matching by header names) specified in the list.
1072 pub remove: Option<Vec<String>>,
1073 /// Completely overwrite/replace the headers with given map where key is the name of the header, value is the value of the header.
1074 pub set: Option<HashMap<String, String>>,
1075}
1076
1077impl common::Part for HttpRouteHeaderModifier {}
1078
1079/// Static HTTP response object to be returned.
1080///
1081/// This type is not used in any activity, and only used as *part* of another schema.
1082///
1083#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1084#[serde_with::serde_as]
1085#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1086pub struct HttpRouteHttpDirectResponse {
1087 /// Optional. Response body as bytes. Maximum body size is 4096B.
1088 #[serde(rename = "bytesBody")]
1089 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1090 pub bytes_body: Option<Vec<u8>>,
1091 /// Required. Status to return as part of HTTP Response. Must be a positive integer.
1092 pub status: Option<i32>,
1093 /// Optional. Response body as a string. Maximum body length is 1024 characters.
1094 #[serde(rename = "stringBody")]
1095 pub string_body: Option<String>,
1096}
1097
1098impl common::Part for HttpRouteHttpDirectResponse {}
1099
1100/// Specifications to match a query parameter in the request.
1101///
1102/// This type is not used in any activity, and only used as *part* of another schema.
1103///
1104#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1105#[serde_with::serde_as]
1106#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1107pub struct HttpRouteQueryParameterMatch {
1108 /// The value of the query parameter must exactly match the contents of exact_match. Only one of exact_match, regex_match, or present_match must be set.
1109 #[serde(rename = "exactMatch")]
1110 pub exact_match: Option<String>,
1111 /// Specifies that the QueryParameterMatcher matches if request contains query parameter, irrespective of whether the parameter has a value or not. Only one of exact_match, regex_match, or present_match must be set.
1112 #[serde(rename = "presentMatch")]
1113 pub present_match: Option<bool>,
1114 /// The name of the query parameter to match.
1115 #[serde(rename = "queryParameter")]
1116 pub query_parameter: Option<String>,
1117 /// The value of the query parameter must match the regular expression specified by regex_match. For regular expression grammar, please see https://github.com/google/re2/wiki/Syntax Only one of exact_match, regex_match, or present_match must be set.
1118 #[serde(rename = "regexMatch")]
1119 pub regex_match: Option<String>,
1120}
1121
1122impl common::Part for HttpRouteQueryParameterMatch {}
1123
1124/// The specification for redirecting traffic.
1125///
1126/// This type is not used in any activity, and only used as *part* of another schema.
1127///
1128#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1129#[serde_with::serde_as]
1130#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1131pub struct HttpRouteRedirect {
1132 /// The host that will be used in the redirect response instead of the one that was supplied in the request.
1133 #[serde(rename = "hostRedirect")]
1134 pub host_redirect: Option<String>,
1135 /// If set to true, the URL scheme in the redirected request is set to https. If set to false, the URL scheme of the redirected request will remain the same as that of the request. The default is set to false.
1136 #[serde(rename = "httpsRedirect")]
1137 pub https_redirect: Option<bool>,
1138 /// The path that will be used in the redirect response instead of the one that was supplied in the request. path_redirect can not be supplied together with prefix_redirect. Supply one alone or neither. If neither is supplied, the path of the original request will be used for the redirect.
1139 #[serde(rename = "pathRedirect")]
1140 pub path_redirect: Option<String>,
1141 /// The port that will be used in the redirected request instead of the one that was supplied in the request.
1142 #[serde(rename = "portRedirect")]
1143 pub port_redirect: Option<i32>,
1144 /// Indicates that during redirection, the matched prefix (or path) should be swapped with this value. This option allows URLs be dynamically created based on the request.
1145 #[serde(rename = "prefixRewrite")]
1146 pub prefix_rewrite: Option<String>,
1147 /// The HTTP Status code to use for the redirect.
1148 #[serde(rename = "responseCode")]
1149 pub response_code: Option<String>,
1150 /// if set to true, any accompanying query portion of the original URL is removed prior to redirecting the request. If set to false, the query portion of the original URL is retained. The default is set to false.
1151 #[serde(rename = "stripQuery")]
1152 pub strip_query: Option<bool>,
1153}
1154
1155impl common::Part for HttpRouteRedirect {}
1156
1157/// Specifies the policy on how requests are shadowed to a separate mirrored destination service. The proxy does not wait for responses from the shadow service. Prior to sending traffic to the shadow service, the host/authority header is suffixed with -shadow. Mirroring is currently not supported for Cloud Run destinations.
1158///
1159/// This type is not used in any activity, and only used as *part* of another schema.
1160///
1161#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1162#[serde_with::serde_as]
1163#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1164pub struct HttpRouteRequestMirrorPolicy {
1165 /// The destination the requests will be mirrored to. The weight of the destination will be ignored.
1166 pub destination: Option<HttpRouteDestination>,
1167 /// Optional. The percentage of requests to get mirrored to the desired destination.
1168 #[serde(rename = "mirrorPercent")]
1169 pub mirror_percent: Option<f32>,
1170}
1171
1172impl common::Part for HttpRouteRequestMirrorPolicy {}
1173
1174/// The specifications for retries.
1175///
1176/// This type is not used in any activity, and only used as *part* of another schema.
1177///
1178#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1179#[serde_with::serde_as]
1180#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1181pub struct HttpRouteRetryPolicy {
1182 /// Specifies the allowed number of retries. This number must be > 0. If not specified, default to 1.
1183 #[serde(rename = "numRetries")]
1184 pub num_retries: Option<i32>,
1185 /// Specifies a non-zero timeout per retry attempt.
1186 #[serde(rename = "perTryTimeout")]
1187 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
1188 pub per_try_timeout: Option<chrono::Duration>,
1189 /// Specifies one or more conditions when this retry policy applies. Valid values are: 5xx: Proxy will attempt a retry if the destination service responds with any 5xx response code, of if the destination service does not respond at all, example: disconnect, reset, read timeout, connection failure and refused streams. gateway-error: Similar to 5xx, but only applies to response codes 502, 503, 504. reset: Proxy will attempt a retry if the destination service does not respond at all (disconnect/reset/read timeout) connect-failure: Proxy will retry on failures connecting to destination for example due to connection timeouts. retriable-4xx: Proxy will retry fro retriable 4xx response codes. Currently the only retriable error supported is 409. refused-stream: Proxy will retry if the destination resets the stream with a REFUSED_STREAM error code. This reset type indicates that it is safe to retry.
1190 #[serde(rename = "retryConditions")]
1191 pub retry_conditions: Option<Vec<String>>,
1192}
1193
1194impl common::Part for HttpRouteRetryPolicy {}
1195
1196/// The specifications for routing traffic and applying associated policies.
1197///
1198/// This type is not used in any activity, and only used as *part* of another schema.
1199///
1200#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1201#[serde_with::serde_as]
1202#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1203pub struct HttpRouteRouteAction {
1204 /// The specification for allowing client side cross-origin requests.
1205 #[serde(rename = "corsPolicy")]
1206 pub cors_policy: Option<HttpRouteCorsPolicy>,
1207 /// The destination to which traffic should be forwarded.
1208 pub destinations: Option<Vec<HttpRouteDestination>>,
1209 /// Optional. Static HTTP Response object to be returned regardless of the request.
1210 #[serde(rename = "directResponse")]
1211 pub direct_response: Option<HttpRouteHttpDirectResponse>,
1212 /// The specification for fault injection introduced into traffic to test the resiliency of clients to backend service failure. As part of fault injection, when clients send requests to a backend service, delays can be introduced on a percentage of requests before sending those requests to the backend service. Similarly requests from clients can be aborted for a percentage of requests. timeout and retry_policy will be ignored by clients that are configured with a fault_injection_policy
1213 #[serde(rename = "faultInjectionPolicy")]
1214 pub fault_injection_policy: Option<HttpRouteFaultInjectionPolicy>,
1215 /// Optional. Specifies the idle timeout for the selected route. The idle timeout is defined as the period in which there are no bytes sent or received on either the upstream or downstream connection. If not set, the default idle timeout is 1 hour. If set to 0s, the timeout will be disabled.
1216 #[serde(rename = "idleTimeout")]
1217 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
1218 pub idle_timeout: Option<chrono::Duration>,
1219 /// If set, the request is directed as configured by this field.
1220 pub redirect: Option<HttpRouteRedirect>,
1221 /// The specification for modifying the headers of a matching request prior to delivery of the request to the destination. If HeaderModifiers are set on both the Destination and the RouteAction, they will be merged. Conflicts between the two will not be resolved on the configuration.
1222 #[serde(rename = "requestHeaderModifier")]
1223 pub request_header_modifier: Option<HttpRouteHeaderModifier>,
1224 /// Specifies the policy on how requests intended for the routes destination are shadowed to a separate mirrored destination. Proxy will not wait for the shadow destination to respond before returning the response. Prior to sending traffic to the shadow service, the host/authority header is suffixed with -shadow.
1225 #[serde(rename = "requestMirrorPolicy")]
1226 pub request_mirror_policy: Option<HttpRouteRequestMirrorPolicy>,
1227 /// The specification for modifying the headers of a response prior to sending the response back to the client. If HeaderModifiers are set on both the Destination and the RouteAction, they will be merged. Conflicts between the two will not be resolved on the configuration.
1228 #[serde(rename = "responseHeaderModifier")]
1229 pub response_header_modifier: Option<HttpRouteHeaderModifier>,
1230 /// Specifies the retry policy associated with this route.
1231 #[serde(rename = "retryPolicy")]
1232 pub retry_policy: Option<HttpRouteRetryPolicy>,
1233 /// Optional. Specifies cookie-based stateful session affinity.
1234 #[serde(rename = "statefulSessionAffinity")]
1235 pub stateful_session_affinity: Option<HttpRouteStatefulSessionAffinityPolicy>,
1236 /// Specifies the timeout for selected route. Timeout is computed from the time the request has been fully processed (i.e. end of stream) up until the response has been completely processed. Timeout includes all retries.
1237 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
1238 pub timeout: Option<chrono::Duration>,
1239 /// The specification for rewrite URL before forwarding requests to the destination.
1240 #[serde(rename = "urlRewrite")]
1241 pub url_rewrite: Option<HttpRouteURLRewrite>,
1242}
1243
1244impl common::Part for HttpRouteRouteAction {}
1245
1246/// RouteMatch defines specifications used to match requests. If multiple match types are set, this RouteMatch will match if ALL type of matches are matched.
1247///
1248/// This type is not used in any activity, and only used as *part* of another schema.
1249///
1250#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1251#[serde_with::serde_as]
1252#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1253pub struct HttpRouteRouteMatch {
1254 /// The HTTP request path value should exactly match this value. Only one of full_path_match, prefix_match, or regex_match should be used.
1255 #[serde(rename = "fullPathMatch")]
1256 pub full_path_match: Option<String>,
1257 /// Specifies a list of HTTP request headers to match against. ALL of the supplied headers must be matched.
1258 pub headers: Option<Vec<HttpRouteHeaderMatch>>,
1259 /// Specifies if prefix_match and full_path_match matches are case sensitive. The default value is false.
1260 #[serde(rename = "ignoreCase")]
1261 pub ignore_case: Option<bool>,
1262 /// The HTTP request path value must begin with specified prefix_match. prefix_match must begin with a /. Only one of full_path_match, prefix_match, or regex_match should be used.
1263 #[serde(rename = "prefixMatch")]
1264 pub prefix_match: Option<String>,
1265 /// Specifies a list of query parameters to match against. ALL of the query parameters must be matched.
1266 #[serde(rename = "queryParameters")]
1267 pub query_parameters: Option<Vec<HttpRouteQueryParameterMatch>>,
1268 /// The HTTP request path value must satisfy the regular expression specified by regex_match after removing any query parameters and anchor supplied with the original URL. For regular expression grammar, please see https://github.com/google/re2/wiki/Syntax Only one of full_path_match, prefix_match, or regex_match should be used.
1269 #[serde(rename = "regexMatch")]
1270 pub regex_match: Option<String>,
1271}
1272
1273impl common::Part for HttpRouteRouteMatch {}
1274
1275/// Specifies how to match traffic and how to route traffic when traffic is matched.
1276///
1277/// This type is not used in any activity, and only used as *part* of another schema.
1278///
1279#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1280#[serde_with::serde_as]
1281#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1282pub struct HttpRouteRouteRule {
1283 /// The detailed rule defining how to route matched traffic.
1284 pub action: Option<HttpRouteRouteAction>,
1285 /// A list of matches define conditions used for matching the rule against incoming HTTP requests. Each match is independent, i.e. this rule will be matched if ANY one of the matches is satisfied. If no matches field is specified, this rule will unconditionally match traffic. If a default rule is desired to be configured, add a rule with no matches specified to the end of the rules list.
1286 pub matches: Option<Vec<HttpRouteRouteMatch>>,
1287}
1288
1289impl common::Part for HttpRouteRouteRule {}
1290
1291/// The specification for cookie-based stateful session affinity where the date plane supplies a “session cookie” with the name "GSSA" which encodes a specific destination host and each request containing that cookie will be directed to that host as long as the destination host remains up and healthy. The gRPC proxyless mesh library or sidecar proxy will manage the session cookie but the client application code is responsible for copying the cookie from each RPC in the session to the next.
1292///
1293/// This type is not used in any activity, and only used as *part* of another schema.
1294///
1295#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1296#[serde_with::serde_as]
1297#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1298pub struct HttpRouteStatefulSessionAffinityPolicy {
1299 /// Required. The cookie TTL value for the Set-Cookie header generated by the data plane. The lifetime of the cookie may be set to a value from 0 to 86400 seconds (24 hours) inclusive. Set this to 0s to use a session cookie and disable cookie expiration.
1300 #[serde(rename = "cookieTtl")]
1301 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
1302 pub cookie_ttl: Option<chrono::Duration>,
1303}
1304
1305impl common::Part for HttpRouteStatefulSessionAffinityPolicy {}
1306
1307/// The specification for modifying the URL of the request, prior to forwarding the request to the destination.
1308///
1309/// This type is not used in any activity, and only used as *part* of another schema.
1310///
1311#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1312#[serde_with::serde_as]
1313#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1314pub struct HttpRouteURLRewrite {
1315 /// Prior to forwarding the request to the selected destination, the requests host header is replaced by this value.
1316 #[serde(rename = "hostRewrite")]
1317 pub host_rewrite: Option<String>,
1318 /// Prior to forwarding the request to the selected destination, the matching portion of the requests path is replaced by this value.
1319 #[serde(rename = "pathPrefixRewrite")]
1320 pub path_prefix_rewrite: Option<String>,
1321}
1322
1323impl common::Part for HttpRouteURLRewrite {}
1324
1325/// `LbEdgeExtension` is a resource that lets the extension service influence the selection of backend services and Cloud CDN cache keys by modifying request headers.
1326///
1327/// # Activities
1328///
1329/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1330/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1331///
1332/// * [locations lb edge extensions create projects](ProjectLocationLbEdgeExtensionCreateCall) (request)
1333/// * [locations lb edge extensions get projects](ProjectLocationLbEdgeExtensionGetCall) (response)
1334/// * [locations lb edge extensions patch projects](ProjectLocationLbEdgeExtensionPatchCall) (request)
1335#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1336#[serde_with::serde_as]
1337#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1338pub struct LbEdgeExtension {
1339 /// Output only. The timestamp when the resource was created.
1340 #[serde(rename = "createTime")]
1341 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1342 /// Optional. A human-readable description of the resource.
1343 pub description: Option<String>,
1344 /// Required. A set of ordered extension chains that contain the match conditions and extensions to execute. Match conditions for each extension chain are evaluated in sequence for a given request. The first extension chain that has a condition that matches the request is executed. Any subsequent extension chains do not execute. Limited to 5 extension chains per resource.
1345 #[serde(rename = "extensionChains")]
1346 pub extension_chains: Option<Vec<ExtensionChain>>,
1347 /// Required. A list of references to the forwarding rules to which this service extension is attached. At least one forwarding rule is required. Only one `LbEdgeExtension` resource can be associated with a forwarding rule.
1348 #[serde(rename = "forwardingRules")]
1349 pub forwarding_rules: Option<Vec<String>>,
1350 /// Optional. Set of labels associated with the `LbEdgeExtension` resource. The format must comply with [the requirements for labels](https://cloud.google.com/compute/docs/labeling-resources#requirements) for Google Cloud resources.
1351 pub labels: Option<HashMap<String, String>>,
1352 /// Required. All forwarding rules referenced by this extension must share the same load balancing scheme. Supported values: `EXTERNAL_MANAGED`.
1353 #[serde(rename = "loadBalancingScheme")]
1354 pub load_balancing_scheme: Option<String>,
1355 /// Required. Identifier. Name of the `LbEdgeExtension` resource in the following format: `projects/{project}/locations/{location}/lbEdgeExtensions/{lb_edge_extension}`.
1356 pub name: Option<String>,
1357 /// Output only. The timestamp when the resource was updated.
1358 #[serde(rename = "updateTime")]
1359 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1360}
1361
1362impl common::RequestValue for LbEdgeExtension {}
1363impl common::ResponseResult for LbEdgeExtension {}
1364
1365/// `LbRouteExtension` is a resource that lets you control where traffic is routed to for a given request.
1366///
1367/// # Activities
1368///
1369/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1370/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1371///
1372/// * [locations lb route extensions create projects](ProjectLocationLbRouteExtensionCreateCall) (request)
1373/// * [locations lb route extensions get projects](ProjectLocationLbRouteExtensionGetCall) (response)
1374/// * [locations lb route extensions patch projects](ProjectLocationLbRouteExtensionPatchCall) (request)
1375#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1376#[serde_with::serde_as]
1377#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1378pub struct LbRouteExtension {
1379 /// Output only. The timestamp when the resource was created.
1380 #[serde(rename = "createTime")]
1381 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1382 /// Optional. A human-readable description of the resource.
1383 pub description: Option<String>,
1384 /// Required. A set of ordered extension chains that contain the match conditions and extensions to execute. Match conditions for each extension chain are evaluated in sequence for a given request. The first extension chain that has a condition that matches the request is executed. Any subsequent extension chains do not execute. Limited to 5 extension chains per resource.
1385 #[serde(rename = "extensionChains")]
1386 pub extension_chains: Option<Vec<ExtensionChain>>,
1387 /// Required. A list of references to the forwarding rules to which this service extension is attached. At least one forwarding rule is required. Only one `LbRouteExtension` resource can be associated with a forwarding rule.
1388 #[serde(rename = "forwardingRules")]
1389 pub forwarding_rules: Option<Vec<String>>,
1390 /// Optional. Set of labels associated with the `LbRouteExtension` resource. The format must comply with [the requirements for labels](https://cloud.google.com/compute/docs/labeling-resources#requirements) for Google Cloud resources.
1391 pub labels: Option<HashMap<String, String>>,
1392 /// Required. All backend services and forwarding rules referenced by this extension must share the same load balancing scheme. Supported values: `INTERNAL_MANAGED`, `EXTERNAL_MANAGED`. For more information, refer to [Backend services overview](https://cloud.google.com/load-balancing/docs/backend-service).
1393 #[serde(rename = "loadBalancingScheme")]
1394 pub load_balancing_scheme: Option<String>,
1395 /// Optional. The metadata provided here is included as part of the `metadata_context` (of type `google.protobuf.Struct`) in the `ProcessingRequest` message sent to the extension server. The metadata applies to all extensions in all extensions chains in this resource. The metadata is available under the key `com.google.lb_route_extension.`. The following variables are supported in the metadata: `{forwarding_rule_id}` - substituted with the forwarding rule's fully qualified resource name. This field must not be set if at least one of the extension chains contains plugin extensions. Setting it results in a validation error. You can set metadata at either the resource level or the extension level. The extension level metadata is recommended because you can pass a different set of metadata through each extension to the backend.
1396 pub metadata: Option<HashMap<String, serde_json::Value>>,
1397 /// Required. Identifier. Name of the `LbRouteExtension` resource in the following format: `projects/{project}/locations/{location}/lbRouteExtensions/{lb_route_extension}`.
1398 pub name: Option<String>,
1399 /// Output only. The timestamp when the resource was updated.
1400 #[serde(rename = "updateTime")]
1401 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1402}
1403
1404impl common::RequestValue for LbRouteExtension {}
1405impl common::ResponseResult for LbRouteExtension {}
1406
1407/// `LbTrafficExtension` is a resource that lets the extension service modify the headers and payloads of both requests and responses without impacting the choice of backend services or any other security policies associated with the backend service.
1408///
1409/// # Activities
1410///
1411/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1412/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1413///
1414/// * [locations lb traffic extensions create projects](ProjectLocationLbTrafficExtensionCreateCall) (request)
1415/// * [locations lb traffic extensions get projects](ProjectLocationLbTrafficExtensionGetCall) (response)
1416/// * [locations lb traffic extensions patch projects](ProjectLocationLbTrafficExtensionPatchCall) (request)
1417#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1418#[serde_with::serde_as]
1419#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1420pub struct LbTrafficExtension {
1421 /// Output only. The timestamp when the resource was created.
1422 #[serde(rename = "createTime")]
1423 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1424 /// Optional. A human-readable description of the resource.
1425 pub description: Option<String>,
1426 /// Required. A set of ordered extension chains that contain the match conditions and extensions to execute. Match conditions for each extension chain are evaluated in sequence for a given request. The first extension chain that has a condition that matches the request is executed. Any subsequent extension chains do not execute. Limited to 5 extension chains per resource.
1427 #[serde(rename = "extensionChains")]
1428 pub extension_chains: Option<Vec<ExtensionChain>>,
1429 /// Optional. A list of references to the forwarding rules to which this service extension is attached. At least one forwarding rule is required. Only one `LbTrafficExtension` resource can be associated with a forwarding rule.
1430 #[serde(rename = "forwardingRules")]
1431 pub forwarding_rules: Option<Vec<String>>,
1432 /// Optional. Set of labels associated with the `LbTrafficExtension` resource. The format must comply with [the requirements for labels](https://cloud.google.com/compute/docs/labeling-resources#requirements) for Google Cloud resources.
1433 pub labels: Option<HashMap<String, String>>,
1434 /// Required. All backend services and forwarding rules referenced by this extension must share the same load balancing scheme. Supported values: `INTERNAL_MANAGED` and `EXTERNAL_MANAGED`. For more information, refer to [Backend services overview](https://cloud.google.com/load-balancing/docs/backend-service).
1435 #[serde(rename = "loadBalancingScheme")]
1436 pub load_balancing_scheme: Option<String>,
1437 /// Optional. The metadata provided here is included as part of the `metadata_context` (of type `google.protobuf.Struct`) in the `ProcessingRequest` message sent to the extension server. The metadata applies to all extensions in all extensions chains in this resource. The metadata is available under the key `com.google.lb_traffic_extension.`. The following variables are supported in the metadata: `{forwarding_rule_id}` - substituted with the forwarding rule's fully qualified resource name. This field must not be set if at least one of the extension chains contains plugin extensions. Setting it results in a validation error. You can set metadata at either the resource level or the extension level. The extension level metadata is recommended because you can pass a different set of metadata through each extension to the backend.
1438 pub metadata: Option<HashMap<String, serde_json::Value>>,
1439 /// Required. Identifier. Name of the `LbTrafficExtension` resource in the following format: `projects/{project}/locations/{location}/lbTrafficExtensions/{lb_traffic_extension}`.
1440 pub name: Option<String>,
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 LbTrafficExtension {}
1447impl common::ResponseResult for LbTrafficExtension {}
1448
1449/// Message for response to listing `AuthzExtension` resources.
1450///
1451/// # Activities
1452///
1453/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1454/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1455///
1456/// * [locations authz extensions list projects](ProjectLocationAuthzExtensionListCall) (response)
1457#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1458#[serde_with::serde_as]
1459#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1460pub struct ListAuthzExtensionsResponse {
1461 /// The list of `AuthzExtension` resources.
1462 #[serde(rename = "authzExtensions")]
1463 pub authz_extensions: Option<Vec<AuthzExtension>>,
1464 /// A token identifying a page of results that the server returns.
1465 #[serde(rename = "nextPageToken")]
1466 pub next_page_token: Option<String>,
1467 /// Locations that could not be reached.
1468 pub unreachable: Option<Vec<String>>,
1469}
1470
1471impl common::ResponseResult for ListAuthzExtensionsResponse {}
1472
1473/// Response returned by the ListEndpointPolicies method.
1474///
1475/// # Activities
1476///
1477/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1478/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1479///
1480/// * [locations endpoint policies list projects](ProjectLocationEndpointPolicyListCall) (response)
1481#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1482#[serde_with::serde_as]
1483#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1484pub struct ListEndpointPoliciesResponse {
1485 /// List of EndpointPolicy resources.
1486 #[serde(rename = "endpointPolicies")]
1487 pub endpoint_policies: Option<Vec<EndpointPolicy>>,
1488 /// 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`.
1489 #[serde(rename = "nextPageToken")]
1490 pub next_page_token: Option<String>,
1491 /// Unreachable resources. Populated when the request opts into return_partial_success and reading across collections e.g. when attempting to list all resources across all supported locations.
1492 pub unreachable: Option<Vec<String>>,
1493}
1494
1495impl common::ResponseResult for ListEndpointPoliciesResponse {}
1496
1497/// Response returned by the ListGatewayRouteViews method.
1498///
1499/// # Activities
1500///
1501/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1502/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1503///
1504/// * [locations gateways route views list projects](ProjectLocationGatewayRouteViewListCall) (response)
1505#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1506#[serde_with::serde_as]
1507#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1508pub struct ListGatewayRouteViewsResponse {
1509 /// List of GatewayRouteView resources.
1510 #[serde(rename = "gatewayRouteViews")]
1511 pub gateway_route_views: Option<Vec<GatewayRouteView>>,
1512 /// A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
1513 #[serde(rename = "nextPageToken")]
1514 pub next_page_token: Option<String>,
1515 /// Unreachable resources. Populated when the request attempts to list all resources across all supported locations, while some locations are temporarily unavailable.
1516 pub unreachable: Option<Vec<String>>,
1517}
1518
1519impl common::ResponseResult for ListGatewayRouteViewsResponse {}
1520
1521/// Response returned by the ListGateways method.
1522///
1523/// # Activities
1524///
1525/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1526/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1527///
1528/// * [locations gateways list projects](ProjectLocationGatewayListCall) (response)
1529#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1530#[serde_with::serde_as]
1531#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1532pub struct ListGatewaysResponse {
1533 /// List of Gateway resources.
1534 pub gateways: Option<Vec<Gateway>>,
1535 /// 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`.
1536 #[serde(rename = "nextPageToken")]
1537 pub next_page_token: Option<String>,
1538 /// Locations that could not be reached.
1539 pub unreachable: Option<Vec<String>>,
1540}
1541
1542impl common::ResponseResult for ListGatewaysResponse {}
1543
1544/// Response returned by the ListGrpcRoutes method.
1545///
1546/// # Activities
1547///
1548/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1549/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1550///
1551/// * [locations grpc routes list projects](ProjectLocationGrpcRouteListCall) (response)
1552#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1553#[serde_with::serde_as]
1554#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1555pub struct ListGrpcRoutesResponse {
1556 /// List of GrpcRoute resources.
1557 #[serde(rename = "grpcRoutes")]
1558 pub grpc_routes: Option<Vec<GrpcRoute>>,
1559 /// 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`.
1560 #[serde(rename = "nextPageToken")]
1561 pub next_page_token: Option<String>,
1562 /// Unreachable resources. Populated when the request opts into return_partial_success and reading across collections e.g. when attempting to list all resources across all supported locations.
1563 pub unreachable: Option<Vec<String>>,
1564}
1565
1566impl common::ResponseResult for ListGrpcRoutesResponse {}
1567
1568/// Response returned by the ListHttpRoutes method.
1569///
1570/// # Activities
1571///
1572/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1573/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1574///
1575/// * [locations http routes list projects](ProjectLocationHttpRouteListCall) (response)
1576#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1577#[serde_with::serde_as]
1578#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1579pub struct ListHttpRoutesResponse {
1580 /// List of HttpRoute resources.
1581 #[serde(rename = "httpRoutes")]
1582 pub http_routes: Option<Vec<HttpRoute>>,
1583 /// 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`.
1584 #[serde(rename = "nextPageToken")]
1585 pub next_page_token: Option<String>,
1586 /// Unreachable resources. Populated when the request opts into return_partial_success and reading across collections e.g. when attempting to list all resources across all supported locations.
1587 pub unreachable: Option<Vec<String>>,
1588}
1589
1590impl common::ResponseResult for ListHttpRoutesResponse {}
1591
1592/// Message for response to listing `LbEdgeExtension` resources.
1593///
1594/// # Activities
1595///
1596/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1597/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1598///
1599/// * [locations lb edge extensions list projects](ProjectLocationLbEdgeExtensionListCall) (response)
1600#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1601#[serde_with::serde_as]
1602#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1603pub struct ListLbEdgeExtensionsResponse {
1604 /// The list of `LbEdgeExtension` resources.
1605 #[serde(rename = "lbEdgeExtensions")]
1606 pub lb_edge_extensions: Option<Vec<LbEdgeExtension>>,
1607 /// A token identifying a page of results that the server returns.
1608 #[serde(rename = "nextPageToken")]
1609 pub next_page_token: Option<String>,
1610 /// Locations that could not be reached.
1611 pub unreachable: Option<Vec<String>>,
1612}
1613
1614impl common::ResponseResult for ListLbEdgeExtensionsResponse {}
1615
1616/// Message for response to listing `LbRouteExtension` resources.
1617///
1618/// # Activities
1619///
1620/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1621/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1622///
1623/// * [locations lb route extensions list projects](ProjectLocationLbRouteExtensionListCall) (response)
1624#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1625#[serde_with::serde_as]
1626#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1627pub struct ListLbRouteExtensionsResponse {
1628 /// The list of `LbRouteExtension` resources.
1629 #[serde(rename = "lbRouteExtensions")]
1630 pub lb_route_extensions: Option<Vec<LbRouteExtension>>,
1631 /// A token identifying a page of results that the server returns.
1632 #[serde(rename = "nextPageToken")]
1633 pub next_page_token: Option<String>,
1634 /// Locations that could not be reached.
1635 pub unreachable: Option<Vec<String>>,
1636}
1637
1638impl common::ResponseResult for ListLbRouteExtensionsResponse {}
1639
1640/// Message for response to listing `LbTrafficExtension` resources.
1641///
1642/// # Activities
1643///
1644/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1645/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1646///
1647/// * [locations lb traffic extensions list projects](ProjectLocationLbTrafficExtensionListCall) (response)
1648#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1649#[serde_with::serde_as]
1650#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1651pub struct ListLbTrafficExtensionsResponse {
1652 /// The list of `LbTrafficExtension` resources.
1653 #[serde(rename = "lbTrafficExtensions")]
1654 pub lb_traffic_extensions: Option<Vec<LbTrafficExtension>>,
1655 /// A token identifying a page of results that the server returns.
1656 #[serde(rename = "nextPageToken")]
1657 pub next_page_token: Option<String>,
1658 /// Locations that could not be reached.
1659 pub unreachable: Option<Vec<String>>,
1660}
1661
1662impl common::ResponseResult for ListLbTrafficExtensionsResponse {}
1663
1664/// The response message for Locations.ListLocations.
1665///
1666/// # Activities
1667///
1668/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1669/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1670///
1671/// * [locations list projects](ProjectLocationListCall) (response)
1672#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1673#[serde_with::serde_as]
1674#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1675pub struct ListLocationsResponse {
1676 /// A list of locations that matches the specified filter in the request.
1677 pub locations: Option<Vec<Location>>,
1678 /// The standard List next-page token.
1679 #[serde(rename = "nextPageToken")]
1680 pub next_page_token: Option<String>,
1681}
1682
1683impl common::ResponseResult for ListLocationsResponse {}
1684
1685/// Response returned by the ListMeshRouteViews method.
1686///
1687/// # Activities
1688///
1689/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1690/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1691///
1692/// * [locations meshes route views list projects](ProjectLocationMeshRouteViewListCall) (response)
1693#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1694#[serde_with::serde_as]
1695#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1696pub struct ListMeshRouteViewsResponse {
1697 /// List of MeshRouteView resources.
1698 #[serde(rename = "meshRouteViews")]
1699 pub mesh_route_views: Option<Vec<MeshRouteView>>,
1700 /// A token, which can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
1701 #[serde(rename = "nextPageToken")]
1702 pub next_page_token: Option<String>,
1703 /// Unreachable resources. Populated when the request attempts to list all resources across all supported locations, while some locations are temporarily unavailable.
1704 pub unreachable: Option<Vec<String>>,
1705}
1706
1707impl common::ResponseResult for ListMeshRouteViewsResponse {}
1708
1709/// Response returned by the ListMeshes method.
1710///
1711/// # Activities
1712///
1713/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1714/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1715///
1716/// * [locations meshes list projects](ProjectLocationMeshListCall) (response)
1717#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1718#[serde_with::serde_as]
1719#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1720pub struct ListMeshesResponse {
1721 /// List of Mesh resources.
1722 pub meshes: Option<Vec<Mesh>>,
1723 /// 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`.
1724 #[serde(rename = "nextPageToken")]
1725 pub next_page_token: Option<String>,
1726 /// Unreachable resources. Populated when the request opts into `return_partial_success` and reading across collections e.g. when attempting to list all resources across all supported locations.
1727 pub unreachable: Option<Vec<String>>,
1728}
1729
1730impl common::ResponseResult for ListMeshesResponse {}
1731
1732/// The response message for Operations.ListOperations.
1733///
1734/// # Activities
1735///
1736/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1737/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1738///
1739/// * [locations operations list projects](ProjectLocationOperationListCall) (response)
1740#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1741#[serde_with::serde_as]
1742#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1743pub struct ListOperationsResponse {
1744 /// The standard List next-page token.
1745 #[serde(rename = "nextPageToken")]
1746 pub next_page_token: Option<String>,
1747 /// A list of operations that matches the specified filter in the request.
1748 pub operations: Option<Vec<Operation>>,
1749 /// Unordered list. Unreachable resources. Populated when the request sets `ListOperationsRequest.return_partial_success` and reads across collections. For example, when attempting to list all resources across all supported locations.
1750 pub unreachable: Option<Vec<String>>,
1751}
1752
1753impl common::ResponseResult for ListOperationsResponse {}
1754
1755/// Response returned by the ListServiceBindings method.
1756///
1757/// # Activities
1758///
1759/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1760/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1761///
1762/// * [locations service bindings list projects](ProjectLocationServiceBindingListCall) (response)
1763#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1764#[serde_with::serde_as]
1765#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1766pub struct ListServiceBindingsResponse {
1767 /// 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`.
1768 #[serde(rename = "nextPageToken")]
1769 pub next_page_token: Option<String>,
1770 /// List of ServiceBinding resources.
1771 #[serde(rename = "serviceBindings")]
1772 pub service_bindings: Option<Vec<ServiceBinding>>,
1773 /// Unreachable resources. Populated when the request attempts to list all resources across all supported locations, while some locations are temporarily unavailable.
1774 pub unreachable: Option<Vec<String>>,
1775}
1776
1777impl common::ResponseResult for ListServiceBindingsResponse {}
1778
1779/// Response returned by the ListServiceLbPolicies method.
1780///
1781/// # Activities
1782///
1783/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1784/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1785///
1786/// * [locations service lb policies list projects](ProjectLocationServiceLbPolicyListCall) (response)
1787#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1788#[serde_with::serde_as]
1789#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1790pub struct ListServiceLbPoliciesResponse {
1791 /// 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`.
1792 #[serde(rename = "nextPageToken")]
1793 pub next_page_token: Option<String>,
1794 /// List of ServiceLbPolicy resources.
1795 #[serde(rename = "serviceLbPolicies")]
1796 pub service_lb_policies: Option<Vec<ServiceLbPolicy>>,
1797 /// Unreachable resources. Populated when the request attempts to list all resources across all supported locations, while some locations are temporarily unavailable.
1798 pub unreachable: Option<Vec<String>>,
1799}
1800
1801impl common::ResponseResult for ListServiceLbPoliciesResponse {}
1802
1803/// Response returned by the ListTcpRoutes method.
1804///
1805/// # Activities
1806///
1807/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1808/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1809///
1810/// * [locations tcp routes list projects](ProjectLocationTcpRouteListCall) (response)
1811#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1812#[serde_with::serde_as]
1813#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1814pub struct ListTcpRoutesResponse {
1815 /// 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`.
1816 #[serde(rename = "nextPageToken")]
1817 pub next_page_token: Option<String>,
1818 /// List of TcpRoute resources.
1819 #[serde(rename = "tcpRoutes")]
1820 pub tcp_routes: Option<Vec<TcpRoute>>,
1821 /// Unreachable resources. Populated when the request opts into return_partial_success and reading across collections e.g. when attempting to list all resources across all supported locations.
1822 pub unreachable: Option<Vec<String>>,
1823}
1824
1825impl common::ResponseResult for ListTcpRoutesResponse {}
1826
1827/// Response returned by the ListTlsRoutes method.
1828///
1829/// # Activities
1830///
1831/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1832/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1833///
1834/// * [locations tls routes list projects](ProjectLocationTlsRouteListCall) (response)
1835#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1836#[serde_with::serde_as]
1837#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1838pub struct ListTlsRoutesResponse {
1839 /// 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`.
1840 #[serde(rename = "nextPageToken")]
1841 pub next_page_token: Option<String>,
1842 /// List of TlsRoute resources.
1843 #[serde(rename = "tlsRoutes")]
1844 pub tls_routes: Option<Vec<TlsRoute>>,
1845 /// Unreachable resources. Populated when the request opts into return_partial_success and reading across collections e.g. when attempting to list all resources across all supported locations.
1846 pub unreachable: Option<Vec<String>>,
1847}
1848
1849impl common::ResponseResult for ListTlsRoutesResponse {}
1850
1851/// Response returned by the `ListWasmPluginVersions` method.
1852///
1853/// # Activities
1854///
1855/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1856/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1857///
1858/// * [locations wasm plugins versions list projects](ProjectLocationWasmPluginVersionListCall) (response)
1859#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1860#[serde_with::serde_as]
1861#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1862pub struct ListWasmPluginVersionsResponse {
1863 /// 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`.
1864 #[serde(rename = "nextPageToken")]
1865 pub next_page_token: Option<String>,
1866 /// Unreachable resources. Populated when the request attempts to list all resources across all supported locations, while some locations are temporarily unavailable.
1867 pub unreachable: Option<Vec<String>>,
1868 /// List of `WasmPluginVersion` resources.
1869 #[serde(rename = "wasmPluginVersions")]
1870 pub wasm_plugin_versions: Option<Vec<WasmPluginVersion>>,
1871}
1872
1873impl common::ResponseResult for ListWasmPluginVersionsResponse {}
1874
1875/// Response returned by the `ListWasmPlugins` method.
1876///
1877/// # Activities
1878///
1879/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1880/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1881///
1882/// * [locations wasm plugins list projects](ProjectLocationWasmPluginListCall) (response)
1883#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1884#[serde_with::serde_as]
1885#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1886pub struct ListWasmPluginsResponse {
1887 /// 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`.
1888 #[serde(rename = "nextPageToken")]
1889 pub next_page_token: Option<String>,
1890 /// Unreachable resources. Populated when the request attempts to list all resources across all supported locations, while some locations are temporarily unavailable.
1891 pub unreachable: Option<Vec<String>>,
1892 /// List of `WasmPlugin` resources.
1893 #[serde(rename = "wasmPlugins")]
1894 pub wasm_plugins: Option<Vec<WasmPlugin>>,
1895}
1896
1897impl common::ResponseResult for ListWasmPluginsResponse {}
1898
1899/// A resource that represents a Google Cloud location.
1900///
1901/// # Activities
1902///
1903/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1904/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1905///
1906/// * [locations get projects](ProjectLocationGetCall) (response)
1907#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1908#[serde_with::serde_as]
1909#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1910pub struct Location {
1911 /// The friendly name for this location, typically a nearby city name. For example, "Tokyo".
1912 #[serde(rename = "displayName")]
1913 pub display_name: Option<String>,
1914 /// Cross-service attributes for the location. For example {"cloud.googleapis.com/region": "us-east1"}
1915 pub labels: Option<HashMap<String, String>>,
1916 /// The canonical id for this location. For example: `"us-east1"`.
1917 #[serde(rename = "locationId")]
1918 pub location_id: Option<String>,
1919 /// Service-specific metadata. For example the available capacity at the given location.
1920 pub metadata: Option<HashMap<String, serde_json::Value>>,
1921 /// Resource name for the location, which may vary between implementations. For example: `"projects/example-project/locations/us-east1"`
1922 pub name: Option<String>,
1923}
1924
1925impl common::ResponseResult for Location {}
1926
1927/// Mesh represents a logical configuration grouping for workload to workload communication within a service mesh. Routes that point to mesh dictate how requests are routed within this logical mesh boundary.
1928///
1929/// # Activities
1930///
1931/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1932/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1933///
1934/// * [locations meshes create projects](ProjectLocationMeshCreateCall) (request)
1935/// * [locations meshes get projects](ProjectLocationMeshGetCall) (response)
1936/// * [locations meshes patch projects](ProjectLocationMeshPatchCall) (request)
1937#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1938#[serde_with::serde_as]
1939#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1940pub struct Mesh {
1941 /// Output only. The timestamp when the resource was created.
1942 #[serde(rename = "createTime")]
1943 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1944 /// Optional. A free-text description of the resource. Max length 1024 characters.
1945 pub description: Option<String>,
1946 /// Optional. Determines if envoy will insert internal debug headers into upstream requests. Other Envoy headers may still be injected. By default, envoy will not insert any debug headers.
1947 #[serde(rename = "envoyHeaders")]
1948 pub envoy_headers: Option<String>,
1949 /// Optional. If set to a valid TCP port (1-65535), instructs the SIDECAR proxy to listen on the specified port of localhost (127.0.0.1) address. The SIDECAR proxy will expect all traffic to be redirected to this port regardless of its actual ip:port destination. If unset, a port '15001' is used as the interception port. This is applicable only for sidecar proxy deployments.
1950 #[serde(rename = "interceptionPort")]
1951 pub interception_port: Option<i32>,
1952 /// Optional. Set of label tags associated with the Mesh resource.
1953 pub labels: Option<HashMap<String, String>>,
1954 /// Identifier. Name of the Mesh resource. It matches pattern `projects/*/locations/*/meshes/`.
1955 pub name: Option<String>,
1956 /// Output only. Server-defined URL of this resource
1957 #[serde(rename = "selfLink")]
1958 pub self_link: Option<String>,
1959 /// Output only. The timestamp when the resource was updated.
1960 #[serde(rename = "updateTime")]
1961 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1962}
1963
1964impl common::RequestValue for Mesh {}
1965impl common::ResponseResult for Mesh {}
1966
1967/// MeshRouteView defines view-only resource for Routes to a Mesh
1968///
1969/// # Activities
1970///
1971/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1972/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1973///
1974/// * [locations meshes route views get projects](ProjectLocationMeshRouteViewGetCall) (response)
1975#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1976#[serde_with::serde_as]
1977#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1978pub struct MeshRouteView {
1979 /// Output only. Identifier. Full path name of the MeshRouteView resource. Format: projects/{project_number}/locations/{location}/meshes/{mesh}/routeViews/{route_view}
1980 pub name: Option<String>,
1981 /// Output only. The resource id for the route.
1982 #[serde(rename = "routeId")]
1983 pub route_id: Option<String>,
1984 /// Output only. Location where the route exists.
1985 #[serde(rename = "routeLocation")]
1986 pub route_location: Option<String>,
1987 /// Output only. Project number where the route exists.
1988 #[serde(rename = "routeProjectNumber")]
1989 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1990 pub route_project_number: Option<i64>,
1991 /// Output only. Type of the route: HttpRoute,GrpcRoute,TcpRoute, or TlsRoute
1992 #[serde(rename = "routeType")]
1993 pub route_type: Option<String>,
1994}
1995
1996impl common::ResponseResult for MeshRouteView {}
1997
1998/// This resource represents a long-running operation that is the result of a network API call.
1999///
2000/// # Activities
2001///
2002/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2003/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2004///
2005/// * [locations authz extensions create projects](ProjectLocationAuthzExtensionCreateCall) (response)
2006/// * [locations authz extensions delete projects](ProjectLocationAuthzExtensionDeleteCall) (response)
2007/// * [locations authz extensions patch projects](ProjectLocationAuthzExtensionPatchCall) (response)
2008/// * [locations endpoint policies create projects](ProjectLocationEndpointPolicyCreateCall) (response)
2009/// * [locations endpoint policies delete projects](ProjectLocationEndpointPolicyDeleteCall) (response)
2010/// * [locations endpoint policies patch projects](ProjectLocationEndpointPolicyPatchCall) (response)
2011/// * [locations gateways create projects](ProjectLocationGatewayCreateCall) (response)
2012/// * [locations gateways delete projects](ProjectLocationGatewayDeleteCall) (response)
2013/// * [locations gateways patch projects](ProjectLocationGatewayPatchCall) (response)
2014/// * [locations grpc routes create projects](ProjectLocationGrpcRouteCreateCall) (response)
2015/// * [locations grpc routes delete projects](ProjectLocationGrpcRouteDeleteCall) (response)
2016/// * [locations grpc routes patch projects](ProjectLocationGrpcRoutePatchCall) (response)
2017/// * [locations http routes create projects](ProjectLocationHttpRouteCreateCall) (response)
2018/// * [locations http routes delete projects](ProjectLocationHttpRouteDeleteCall) (response)
2019/// * [locations http routes patch projects](ProjectLocationHttpRoutePatchCall) (response)
2020/// * [locations lb edge extensions create projects](ProjectLocationLbEdgeExtensionCreateCall) (response)
2021/// * [locations lb edge extensions delete projects](ProjectLocationLbEdgeExtensionDeleteCall) (response)
2022/// * [locations lb edge extensions patch projects](ProjectLocationLbEdgeExtensionPatchCall) (response)
2023/// * [locations lb route extensions create projects](ProjectLocationLbRouteExtensionCreateCall) (response)
2024/// * [locations lb route extensions delete projects](ProjectLocationLbRouteExtensionDeleteCall) (response)
2025/// * [locations lb route extensions patch projects](ProjectLocationLbRouteExtensionPatchCall) (response)
2026/// * [locations lb traffic extensions create projects](ProjectLocationLbTrafficExtensionCreateCall) (response)
2027/// * [locations lb traffic extensions delete projects](ProjectLocationLbTrafficExtensionDeleteCall) (response)
2028/// * [locations lb traffic extensions patch projects](ProjectLocationLbTrafficExtensionPatchCall) (response)
2029/// * [locations meshes create projects](ProjectLocationMeshCreateCall) (response)
2030/// * [locations meshes delete projects](ProjectLocationMeshDeleteCall) (response)
2031/// * [locations meshes patch projects](ProjectLocationMeshPatchCall) (response)
2032/// * [locations operations get projects](ProjectLocationOperationGetCall) (response)
2033/// * [locations service bindings create projects](ProjectLocationServiceBindingCreateCall) (response)
2034/// * [locations service bindings delete projects](ProjectLocationServiceBindingDeleteCall) (response)
2035/// * [locations service bindings patch projects](ProjectLocationServiceBindingPatchCall) (response)
2036/// * [locations service lb policies create projects](ProjectLocationServiceLbPolicyCreateCall) (response)
2037/// * [locations service lb policies delete projects](ProjectLocationServiceLbPolicyDeleteCall) (response)
2038/// * [locations service lb policies patch projects](ProjectLocationServiceLbPolicyPatchCall) (response)
2039/// * [locations tcp routes create projects](ProjectLocationTcpRouteCreateCall) (response)
2040/// * [locations tcp routes delete projects](ProjectLocationTcpRouteDeleteCall) (response)
2041/// * [locations tcp routes patch projects](ProjectLocationTcpRoutePatchCall) (response)
2042/// * [locations tls routes create projects](ProjectLocationTlsRouteCreateCall) (response)
2043/// * [locations tls routes delete projects](ProjectLocationTlsRouteDeleteCall) (response)
2044/// * [locations tls routes patch projects](ProjectLocationTlsRoutePatchCall) (response)
2045/// * [locations wasm plugins versions create projects](ProjectLocationWasmPluginVersionCreateCall) (response)
2046/// * [locations wasm plugins versions delete projects](ProjectLocationWasmPluginVersionDeleteCall) (response)
2047/// * [locations wasm plugins create projects](ProjectLocationWasmPluginCreateCall) (response)
2048/// * [locations wasm plugins delete projects](ProjectLocationWasmPluginDeleteCall) (response)
2049/// * [locations wasm plugins patch projects](ProjectLocationWasmPluginPatchCall) (response)
2050#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2051#[serde_with::serde_as]
2052#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2053pub struct Operation {
2054 /// 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.
2055 pub done: Option<bool>,
2056 /// The error result of the operation in case of failure or cancellation.
2057 pub error: Option<Status>,
2058 /// 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.
2059 pub metadata: Option<HashMap<String, serde_json::Value>>,
2060 /// 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}`.
2061 pub name: Option<String>,
2062 /// 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`.
2063 pub response: Option<HashMap<String, serde_json::Value>>,
2064}
2065
2066impl common::ResponseResult for Operation {}
2067
2068/// 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/).
2069///
2070/// # Activities
2071///
2072/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2073/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2074///
2075/// * [locations edge cache keysets get iam policy projects](ProjectLocationEdgeCacheKeysetGetIamPolicyCall) (response)
2076/// * [locations edge cache keysets set iam policy projects](ProjectLocationEdgeCacheKeysetSetIamPolicyCall) (response)
2077/// * [locations edge cache origins get iam policy projects](ProjectLocationEdgeCacheOriginGetIamPolicyCall) (response)
2078/// * [locations edge cache origins set iam policy projects](ProjectLocationEdgeCacheOriginSetIamPolicyCall) (response)
2079/// * [locations edge cache services get iam policy projects](ProjectLocationEdgeCacheServiceGetIamPolicyCall) (response)
2080/// * [locations edge cache services set iam policy projects](ProjectLocationEdgeCacheServiceSetIamPolicyCall) (response)
2081#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2082#[serde_with::serde_as]
2083#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2084pub struct Policy {
2085 /// Specifies cloud audit logging configuration for this policy.
2086 #[serde(rename = "auditConfigs")]
2087 pub audit_configs: Option<Vec<AuditConfig>>,
2088 /// 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`.
2089 pub bindings: Option<Vec<Binding>>,
2090 /// `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.
2091 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
2092 pub etag: Option<Vec<u8>>,
2093 /// 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).
2094 pub version: Option<i32>,
2095}
2096
2097impl common::ResponseResult for Policy {}
2098
2099/// ServiceBinding can be used to: - Bind a Service Directory Service to be used in a BackendService resource. This feature will be deprecated soon. - Bind a Private Service Connect producer service to be used in consumer Cloud Service Mesh or Application Load Balancers. - Bind a Cloud Run service to be used in consumer Cloud Service Mesh or Application Load Balancers.
2100///
2101/// # Activities
2102///
2103/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2104/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2105///
2106/// * [locations service bindings create projects](ProjectLocationServiceBindingCreateCall) (request)
2107/// * [locations service bindings get projects](ProjectLocationServiceBindingGetCall) (response)
2108/// * [locations service bindings patch projects](ProjectLocationServiceBindingPatchCall) (request)
2109#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2110#[serde_with::serde_as]
2111#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2112pub struct ServiceBinding {
2113 /// Output only. The timestamp when the resource was created.
2114 #[serde(rename = "createTime")]
2115 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2116 /// Optional. A free-text description of the resource. Max length 1024 characters.
2117 pub description: Option<String>,
2118 /// Optional. Set of label tags associated with the ServiceBinding resource.
2119 pub labels: Option<HashMap<String, String>>,
2120 /// Identifier. Name of the ServiceBinding resource. It matches pattern `projects/*/locations/*/serviceBindings/`.
2121 pub name: Option<String>,
2122 /// Optional. The full Service Directory Service name of the format `projects/*/locations/*/namespaces/*/services/*`. This field is for Service Directory integration which will be deprecated soon.
2123 pub service: Option<String>,
2124 /// Output only. The unique identifier of the Service Directory Service against which the ServiceBinding resource is validated. This is populated when the Service Binding resource is used in another resource (like Backend Service). This is of the UUID4 format. This field is for Service Directory integration which will be deprecated soon.
2125 #[serde(rename = "serviceId")]
2126 pub service_id: Option<String>,
2127 /// Output only. The timestamp when the resource was updated.
2128 #[serde(rename = "updateTime")]
2129 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2130}
2131
2132impl common::RequestValue for ServiceBinding {}
2133impl common::ResponseResult for ServiceBinding {}
2134
2135/// ServiceLbPolicy holds global load balancing and traffic distribution configuration that can be applied to a BackendService.
2136///
2137/// # Activities
2138///
2139/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2140/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2141///
2142/// * [locations service lb policies create projects](ProjectLocationServiceLbPolicyCreateCall) (request)
2143/// * [locations service lb policies get projects](ProjectLocationServiceLbPolicyGetCall) (response)
2144/// * [locations service lb policies patch projects](ProjectLocationServiceLbPolicyPatchCall) (request)
2145#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2146#[serde_with::serde_as]
2147#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2148pub struct ServiceLbPolicy {
2149 /// Optional. Configuration to automatically move traffic away for unhealthy IG/NEG for the associated Backend Service.
2150 #[serde(rename = "autoCapacityDrain")]
2151 pub auto_capacity_drain: Option<ServiceLbPolicyAutoCapacityDrain>,
2152 /// Output only. The timestamp when this resource was created.
2153 #[serde(rename = "createTime")]
2154 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2155 /// Optional. A free-text description of the resource. Max length 1024 characters.
2156 pub description: Option<String>,
2157 /// Optional. Configuration related to health based failover.
2158 #[serde(rename = "failoverConfig")]
2159 pub failover_config: Option<ServiceLbPolicyFailoverConfig>,
2160 /// Optional. Configuration to provide isolation support for the associated Backend Service.
2161 #[serde(rename = "isolationConfig")]
2162 pub isolation_config: Option<ServiceLbPolicyIsolationConfig>,
2163 /// Optional. Set of label tags associated with the ServiceLbPolicy resource.
2164 pub labels: Option<HashMap<String, String>>,
2165 /// Optional. The type of load balancing algorithm to be used. The default behavior is WATERFALL_BY_REGION.
2166 #[serde(rename = "loadBalancingAlgorithm")]
2167 pub load_balancing_algorithm: Option<String>,
2168 /// Identifier. Name of the ServiceLbPolicy resource. It matches pattern `projects/{project}/locations/{location}/serviceLbPolicies/{service_lb_policy_name}`.
2169 pub name: Option<String>,
2170 /// Output only. The timestamp when this resource was last updated.
2171 #[serde(rename = "updateTime")]
2172 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2173}
2174
2175impl common::RequestValue for ServiceLbPolicy {}
2176impl common::ResponseResult for ServiceLbPolicy {}
2177
2178/// Option to specify if an unhealthy IG/NEG should be considered for global load balancing and traffic routing.
2179///
2180/// This type is not used in any activity, and only used as *part* of another schema.
2181///
2182#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2183#[serde_with::serde_as]
2184#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2185pub struct ServiceLbPolicyAutoCapacityDrain {
2186 /// Optional. If set to 'True', an unhealthy IG/NEG will be set as drained. - An IG/NEG is considered unhealthy if less than 25% of the instances/endpoints in the IG/NEG are healthy. - This option will never result in draining more than 50% of the configured IGs/NEGs for the Backend Service.
2187 pub enable: Option<bool>,
2188}
2189
2190impl common::Part for ServiceLbPolicyAutoCapacityDrain {}
2191
2192/// Option to specify health based failover behavior. This is not related to Network load balancer FailoverPolicy.
2193///
2194/// This type is not used in any activity, and only used as *part* of another schema.
2195///
2196#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2197#[serde_with::serde_as]
2198#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2199pub struct ServiceLbPolicyFailoverConfig {
2200 /// Optional. The percentage threshold that a load balancer will begin to send traffic to failover backends. If the percentage of endpoints in a MIG/NEG is smaller than this value, traffic would be sent to failover backends if possible. This field should be set to a value between 1 and 99. The default value is 50 for Global external HTTP(S) load balancer (classic) and Proxyless service mesh, and 70 for others.
2201 #[serde(rename = "failoverHealthThreshold")]
2202 pub failover_health_threshold: Option<i32>,
2203}
2204
2205impl common::Part for ServiceLbPolicyFailoverConfig {}
2206
2207/// Configuration to provide isolation support for the associated Backend Service.
2208///
2209/// This type is not used in any activity, and only used as *part* of another schema.
2210///
2211#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2212#[serde_with::serde_as]
2213#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2214pub struct ServiceLbPolicyIsolationConfig {
2215 /// Optional. The isolation granularity of the load balancer.
2216 #[serde(rename = "isolationGranularity")]
2217 pub isolation_granularity: Option<String>,
2218 /// Optional. The isolation mode of the load balancer.
2219 #[serde(rename = "isolationMode")]
2220 pub isolation_mode: Option<String>,
2221}
2222
2223impl common::Part for ServiceLbPolicyIsolationConfig {}
2224
2225/// Request message for `SetIamPolicy` method.
2226///
2227/// # Activities
2228///
2229/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2230/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2231///
2232/// * [locations edge cache keysets set iam policy projects](ProjectLocationEdgeCacheKeysetSetIamPolicyCall) (request)
2233/// * [locations edge cache origins set iam policy projects](ProjectLocationEdgeCacheOriginSetIamPolicyCall) (request)
2234/// * [locations edge cache services set iam policy projects](ProjectLocationEdgeCacheServiceSetIamPolicyCall) (request)
2235#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2236#[serde_with::serde_as]
2237#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2238pub struct SetIamPolicyRequest {
2239 /// 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.
2240 pub policy: Option<Policy>,
2241 /// 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"`
2242 #[serde(rename = "updateMask")]
2243 pub update_mask: Option<common::FieldMask>,
2244}
2245
2246impl common::RequestValue for SetIamPolicyRequest {}
2247
2248/// 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).
2249///
2250/// This type is not used in any activity, and only used as *part* of another schema.
2251///
2252#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2253#[serde_with::serde_as]
2254#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2255pub struct Status {
2256 /// The status code, which should be an enum value of google.rpc.Code.
2257 pub code: Option<i32>,
2258 /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
2259 pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
2260 /// 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.
2261 pub message: Option<String>,
2262}
2263
2264impl common::Part for Status {}
2265
2266/// TcpRoute is the resource defining how TCP traffic should be routed by a Mesh/Gateway resource.
2267///
2268/// # Activities
2269///
2270/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2271/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2272///
2273/// * [locations tcp routes create projects](ProjectLocationTcpRouteCreateCall) (request)
2274/// * [locations tcp routes get projects](ProjectLocationTcpRouteGetCall) (response)
2275/// * [locations tcp routes patch projects](ProjectLocationTcpRoutePatchCall) (request)
2276#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2277#[serde_with::serde_as]
2278#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2279pub struct TcpRoute {
2280 /// Output only. The timestamp when the resource was created.
2281 #[serde(rename = "createTime")]
2282 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2283 /// Optional. A free-text description of the resource. Max length 1024 characters.
2284 pub description: Option<String>,
2285 /// Optional. Gateways defines a list of gateways this TcpRoute is attached to, as one of the routing rules to route the requests served by the gateway. Each gateway reference should match the pattern: `projects/*/locations/*/gateways/`
2286 pub gateways: Option<Vec<String>>,
2287 /// Optional. Set of label tags associated with the TcpRoute resource.
2288 pub labels: Option<HashMap<String, String>>,
2289 /// Optional. Meshes defines a list of meshes this TcpRoute is attached to, as one of the routing rules to route the requests served by the mesh. Each mesh reference should match the pattern: `projects/*/locations/*/meshes/` The attached Mesh should be of a type SIDECAR
2290 pub meshes: Option<Vec<String>>,
2291 /// Identifier. Name of the TcpRoute resource. It matches pattern `projects/*/locations/*/tcpRoutes/tcp_route_name>`.
2292 pub name: Option<String>,
2293 /// Required. Rules that define how traffic is routed and handled. At least one RouteRule must be supplied. If there are multiple rules then the action taken will be the first rule to match.
2294 pub rules: Option<Vec<TcpRouteRouteRule>>,
2295 /// Output only. Server-defined URL of this resource
2296 #[serde(rename = "selfLink")]
2297 pub self_link: Option<String>,
2298 /// Output only. The timestamp when the resource was updated.
2299 #[serde(rename = "updateTime")]
2300 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2301}
2302
2303impl common::RequestValue for TcpRoute {}
2304impl common::ResponseResult for TcpRoute {}
2305
2306/// The specifications for routing traffic and applying associated policies.
2307///
2308/// This type is not used in any activity, and only used as *part* of another schema.
2309///
2310#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2311#[serde_with::serde_as]
2312#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2313pub struct TcpRouteRouteAction {
2314 /// Optional. The destination services to which traffic should be forwarded. At least one destination service is required. Only one of route destination or original destination can be set.
2315 pub destinations: Option<Vec<TcpRouteRouteDestination>>,
2316 /// Optional. Specifies the idle timeout for the selected route. The idle timeout is defined as the period in which there are no bytes sent or received on either the upstream or downstream connection. If not set, the default idle timeout is 30 seconds. If set to 0s, the timeout will be disabled.
2317 #[serde(rename = "idleTimeout")]
2318 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
2319 pub idle_timeout: Option<chrono::Duration>,
2320 /// Optional. If true, Router will use the destination IP and port of the original connection as the destination of the request. Default is false. Only one of route destinations or original destination can be set.
2321 #[serde(rename = "originalDestination")]
2322 pub original_destination: Option<bool>,
2323}
2324
2325impl common::Part for TcpRouteRouteAction {}
2326
2327/// Describe the destination for traffic to be routed to.
2328///
2329/// This type is not used in any activity, and only used as *part* of another schema.
2330///
2331#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2332#[serde_with::serde_as]
2333#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2334pub struct TcpRouteRouteDestination {
2335 /// Required. The URL of a BackendService to route traffic to.
2336 #[serde(rename = "serviceName")]
2337 pub service_name: Option<String>,
2338 /// Optional. Specifies the proportion of requests forwarded to the backend referenced by the serviceName field. This is computed as: - weight/Sum(weights in this destination list). For non-zero values, there may be some epsilon from the exact proportion defined here depending on the precision an implementation supports. If only one serviceName is specified and it has a weight greater than 0, 100% of the traffic is forwarded to that backend. If weights are specified for any one service name, they need to be specified for all of them. If weights are unspecified for all services, then, traffic is distributed in equal proportions to all of them.
2339 pub weight: Option<i32>,
2340}
2341
2342impl common::Part for TcpRouteRouteDestination {}
2343
2344/// RouteMatch defines the predicate used to match requests to a given action. Multiple match types are "OR"ed for evaluation. If no routeMatch field is specified, this rule will unconditionally match traffic.
2345///
2346/// This type is not used in any activity, and only used as *part* of another schema.
2347///
2348#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2349#[serde_with::serde_as]
2350#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2351pub struct TcpRouteRouteMatch {
2352 /// Required. Must be specified in the CIDR range format. A CIDR range consists of an IP Address and a prefix length to construct the subnet mask. By default, the prefix length is 32 (i.e. matches a single IP address). Only IPV4 addresses are supported. Examples: "10.0.0.1" - matches against this exact IP address. "10.0.0.0/8" - matches against any IP address within the 10.0.0.0 subnet and 255.255.255.0 mask. "0.0.0.0/0" - matches against any IP address'.
2353 pub address: Option<String>,
2354 /// Required. Specifies the destination port to match against.
2355 pub port: Option<String>,
2356}
2357
2358impl common::Part for TcpRouteRouteMatch {}
2359
2360/// Specifies how to match traffic and how to route traffic when traffic is matched.
2361///
2362/// This type is not used in any activity, and only used as *part* of another schema.
2363///
2364#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2365#[serde_with::serde_as]
2366#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2367pub struct TcpRouteRouteRule {
2368 /// Required. The detailed rule defining how to route matched traffic.
2369 pub action: Option<TcpRouteRouteAction>,
2370 /// Optional. RouteMatch defines the predicate used to match requests to a given action. Multiple match types are "OR"ed for evaluation. If no routeMatch field is specified, this rule will unconditionally match traffic.
2371 pub matches: Option<Vec<TcpRouteRouteMatch>>,
2372}
2373
2374impl common::Part for TcpRouteRouteRule {}
2375
2376/// Request message for `TestIamPermissions` method.
2377///
2378/// # Activities
2379///
2380/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2381/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2382///
2383/// * [locations edge cache keysets test iam permissions projects](ProjectLocationEdgeCacheKeysetTestIamPermissionCall) (request)
2384/// * [locations edge cache origins test iam permissions projects](ProjectLocationEdgeCacheOriginTestIamPermissionCall) (request)
2385/// * [locations edge cache services test iam permissions projects](ProjectLocationEdgeCacheServiceTestIamPermissionCall) (request)
2386#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2387#[serde_with::serde_as]
2388#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2389pub struct TestIamPermissionsRequest {
2390 /// 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).
2391 pub permissions: Option<Vec<String>>,
2392}
2393
2394impl common::RequestValue for TestIamPermissionsRequest {}
2395
2396/// Response message for `TestIamPermissions` method.
2397///
2398/// # Activities
2399///
2400/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2401/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2402///
2403/// * [locations edge cache keysets test iam permissions projects](ProjectLocationEdgeCacheKeysetTestIamPermissionCall) (response)
2404/// * [locations edge cache origins test iam permissions projects](ProjectLocationEdgeCacheOriginTestIamPermissionCall) (response)
2405/// * [locations edge cache services test iam permissions projects](ProjectLocationEdgeCacheServiceTestIamPermissionCall) (response)
2406#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2407#[serde_with::serde_as]
2408#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2409pub struct TestIamPermissionsResponse {
2410 /// A subset of `TestPermissionsRequest.permissions` that the caller is allowed.
2411 pub permissions: Option<Vec<String>>,
2412}
2413
2414impl common::ResponseResult for TestIamPermissionsResponse {}
2415
2416/// TlsRoute defines how traffic should be routed based on SNI and other matching L3 attributes.
2417///
2418/// # Activities
2419///
2420/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2421/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2422///
2423/// * [locations tls routes create projects](ProjectLocationTlsRouteCreateCall) (request)
2424/// * [locations tls routes get projects](ProjectLocationTlsRouteGetCall) (response)
2425/// * [locations tls routes patch projects](ProjectLocationTlsRoutePatchCall) (request)
2426#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2427#[serde_with::serde_as]
2428#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2429pub struct TlsRoute {
2430 /// Output only. The timestamp when the resource was created.
2431 #[serde(rename = "createTime")]
2432 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2433 /// Optional. A free-text description of the resource. Max length 1024 characters.
2434 pub description: Option<String>,
2435 /// Optional. Gateways defines a list of gateways this TlsRoute is attached to, as one of the routing rules to route the requests served by the gateway. Each gateway reference should match the pattern: `projects/*/locations/*/gateways/`
2436 pub gateways: Option<Vec<String>>,
2437 /// Optional. Set of label tags associated with the TlsRoute resource.
2438 pub labels: Option<HashMap<String, String>>,
2439 /// Optional. Meshes defines a list of meshes this TlsRoute is attached to, as one of the routing rules to route the requests served by the mesh. Each mesh reference should match the pattern: `projects/*/locations/*/meshes/` The attached Mesh should be of a type SIDECAR
2440 pub meshes: Option<Vec<String>>,
2441 /// Identifier. Name of the TlsRoute resource. It matches pattern `projects/*/locations/*/tlsRoutes/tls_route_name>`.
2442 pub name: Option<String>,
2443 /// Required. Rules that define how traffic is routed and handled. At least one RouteRule must be supplied. If there are multiple rules then the action taken will be the first rule to match.
2444 pub rules: Option<Vec<TlsRouteRouteRule>>,
2445 /// Output only. Server-defined URL of this resource
2446 #[serde(rename = "selfLink")]
2447 pub self_link: Option<String>,
2448 /// Output only. The timestamp when the resource was updated.
2449 #[serde(rename = "updateTime")]
2450 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2451}
2452
2453impl common::RequestValue for TlsRoute {}
2454impl common::ResponseResult for TlsRoute {}
2455
2456/// The specifications for routing traffic and applying associated policies.
2457///
2458/// This type is not used in any activity, and only used as *part* of another schema.
2459///
2460#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2461#[serde_with::serde_as]
2462#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2463pub struct TlsRouteRouteAction {
2464 /// Required. The destination services to which traffic should be forwarded. At least one destination service is required.
2465 pub destinations: Option<Vec<TlsRouteRouteDestination>>,
2466 /// Optional. Specifies the idle timeout for the selected route. The idle timeout is defined as the period in which there are no bytes sent or received on either the upstream or downstream connection. If not set, the default idle timeout is 1 hour. If set to 0s, the timeout will be disabled.
2467 #[serde(rename = "idleTimeout")]
2468 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
2469 pub idle_timeout: Option<chrono::Duration>,
2470}
2471
2472impl common::Part for TlsRouteRouteAction {}
2473
2474/// Describe the destination for traffic to be routed to.
2475///
2476/// This type is not used in any activity, and only used as *part* of another schema.
2477///
2478#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2479#[serde_with::serde_as]
2480#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2481pub struct TlsRouteRouteDestination {
2482 /// Required. The URL of a BackendService to route traffic to.
2483 #[serde(rename = "serviceName")]
2484 pub service_name: Option<String>,
2485 /// Optional. Specifies the proportion of requests forwarded to the backend referenced by the service_name field. This is computed as: - weight/Sum(weights in destinations) Weights in all destinations does not need to sum up to 100.
2486 pub weight: Option<i32>,
2487}
2488
2489impl common::Part for TlsRouteRouteDestination {}
2490
2491/// RouteMatch defines the predicate used to match requests to a given action. Multiple match types are "AND"ed for evaluation.
2492///
2493/// This type is not used in any activity, and only used as *part* of another schema.
2494///
2495#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2496#[serde_with::serde_as]
2497#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2498pub struct TlsRouteRouteMatch {
2499 /// Optional. ALPN (Application-Layer Protocol Negotiation) to match against. Examples: "http/1.1", "h2". At least one of sni_host and alpn is required. Up to 5 alpns across all matches can be set.
2500 pub alpn: Option<Vec<String>>,
2501 /// Optional. SNI (server name indicator) to match against. SNI will be matched against all wildcard domains, i.e. `www.example.com` will be first matched against `www.example.com`, then `*.example.com`, then `*.com.` Partial wildcards are not supported, and values like *w.example.com are invalid. At least one of sni_host and alpn is required. Up to 100 sni hosts across all matches can be set.
2502 #[serde(rename = "sniHost")]
2503 pub sni_host: Option<Vec<String>>,
2504}
2505
2506impl common::Part for TlsRouteRouteMatch {}
2507
2508/// Specifies how to match traffic and how to route traffic when traffic is matched.
2509///
2510/// This type is not used in any activity, and only used as *part* of another schema.
2511///
2512#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2513#[serde_with::serde_as]
2514#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2515pub struct TlsRouteRouteRule {
2516 /// Required. The detailed rule defining how to route matched traffic.
2517 pub action: Option<TlsRouteRouteAction>,
2518 /// Required. RouteMatch defines the predicate used to match requests to a given action. Multiple match types are "OR"ed for evaluation. Atleast one RouteMatch must be supplied.
2519 pub matches: Option<Vec<TlsRouteRouteMatch>>,
2520}
2521
2522impl common::Part for TlsRouteRouteRule {}
2523
2524/// Specification of a port-based selector.
2525///
2526/// This type is not used in any activity, and only used as *part* of another schema.
2527///
2528#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2529#[serde_with::serde_as]
2530#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2531pub struct TrafficPortSelector {
2532 /// Optional. A list of ports. Can be port numbers or port range (example, [80-90] specifies all ports from 80 to 90, including 80 and 90) or named ports or * to specify all ports. If the list is empty, all ports are selected.
2533 pub ports: Option<Vec<String>>,
2534}
2535
2536impl common::Part for TrafficPortSelector {}
2537
2538/// `WasmPlugin` is a resource representing a service executing a customer-provided Wasm module.
2539///
2540/// # Activities
2541///
2542/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2543/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2544///
2545/// * [locations wasm plugins create projects](ProjectLocationWasmPluginCreateCall) (request)
2546/// * [locations wasm plugins get projects](ProjectLocationWasmPluginGetCall) (response)
2547/// * [locations wasm plugins patch projects](ProjectLocationWasmPluginPatchCall) (request)
2548#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2549#[serde_with::serde_as]
2550#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2551pub struct WasmPlugin {
2552 /// Output only. The timestamp when the resource was created.
2553 #[serde(rename = "createTime")]
2554 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2555 /// Optional. A human-readable description of the resource.
2556 pub description: Option<String>,
2557 /// Optional. Set of labels associated with the `WasmPlugin` resource. The format must comply with [the following requirements](https://cloud.google.com/compute/docs/labeling-resources#requirements).
2558 pub labels: Option<HashMap<String, String>>,
2559 /// Optional. Specifies the logging options for the activity performed by this plugin. If logging is enabled, plugin logs are exported to Cloud Logging. Note that the settings relate to the logs generated by using logging statements in your Wasm code.
2560 #[serde(rename = "logConfig")]
2561 pub log_config: Option<WasmPluginLogConfig>,
2562 /// Optional. The ID of the `WasmPluginVersion` resource that is the currently serving one. The version referred to must be a child of this `WasmPlugin` resource.
2563 #[serde(rename = "mainVersionId")]
2564 pub main_version_id: Option<String>,
2565 /// Identifier. Name of the `WasmPlugin` resource in the following format: `projects/{project}/locations/{location}/wasmPlugins/{wasm_plugin}`.
2566 pub name: Option<String>,
2567 /// Output only. The timestamp when the resource was updated.
2568 #[serde(rename = "updateTime")]
2569 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2570 /// Output only. List of all [extensions](https://cloud.google.com/service-extensions/docs/overview) that use this `WasmPlugin` resource.
2571 #[serde(rename = "usedBy")]
2572 pub used_by: Option<Vec<WasmPluginUsedBy>>,
2573 /// Optional. All versions of this `WasmPlugin` resource in the key-value format. The key is the resource ID, and the value is the `VersionDetails` object. Lets you create or update a `WasmPlugin` resource and its versions in a single request. When the `main_version_id` field is not empty, it must point to one of the `VersionDetails` objects in the map. If provided in a `PATCH` request, the new versions replace the previous set. Any version omitted from the `versions` field is removed. Because the `WasmPluginVersion` resource is immutable, if a `WasmPluginVersion` resource with the same name already exists and differs, the request fails. Note: In a `GET` request, this field is populated only if the field `GetWasmPluginRequest.view` is set to `WASM_PLUGIN_VIEW_FULL`.
2574 pub versions: Option<HashMap<String, WasmPluginVersionDetails>>,
2575}
2576
2577impl common::RequestValue for WasmPlugin {}
2578impl common::ResponseResult for WasmPlugin {}
2579
2580/// Specifies the logging options for the activity performed by this plugin. If logging is enabled, plugin logs are exported to Cloud Logging.
2581///
2582/// This type is not used in any activity, and only used as *part* of another schema.
2583///
2584#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2585#[serde_with::serde_as]
2586#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2587pub struct WasmPluginLogConfig {
2588 /// Optional. Specifies whether to enable logging for activity by this plugin. Defaults to `false`.
2589 pub enable: Option<bool>,
2590 /// Non-empty default. Specifies the lowest level of the plugin logs that are exported to Cloud Logging. This setting relates to the logs generated by using logging statements in your Wasm code. This field is can be set only if logging is enabled for the plugin. If the field is not provided when logging is enabled, it is set to `INFO` by default.
2591 #[serde(rename = "minLogLevel")]
2592 pub min_log_level: Option<String>,
2593 /// Non-empty default. Configures the sampling rate of activity logs, where `1.0` means all logged activity is reported and `0.0` means no activity is reported. A floating point value between `0.0` and `1.0` indicates that a percentage of log messages is stored. The default value when logging is enabled is `1.0`. The value of the field must be between `0` and `1` (inclusive). This field can be specified only if logging is enabled for this plugin.
2594 #[serde(rename = "sampleRate")]
2595 pub sample_rate: Option<f32>,
2596}
2597
2598impl common::Part for WasmPluginLogConfig {}
2599
2600/// Defines a resource that uses the `WasmPlugin` resource.
2601///
2602/// This type is not used in any activity, and only used as *part* of another schema.
2603///
2604#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2605#[serde_with::serde_as]
2606#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2607pub struct WasmPluginUsedBy {
2608 /// Output only. Full name of the resource https://google.aip.dev/122#full-resource-names, for example `//networkservices.googleapis.com/projects/{project}/locations/{location}/lbRouteExtensions/{extension}`
2609 pub name: Option<String>,
2610}
2611
2612impl common::Part for WasmPluginUsedBy {}
2613
2614/// A single immutable version of a `WasmPlugin` resource. Defines the Wasm module used and optionally its runtime config.
2615///
2616/// # Activities
2617///
2618/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2619/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2620///
2621/// * [locations wasm plugins versions create projects](ProjectLocationWasmPluginVersionCreateCall) (request)
2622/// * [locations wasm plugins versions get projects](ProjectLocationWasmPluginVersionGetCall) (response)
2623#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2624#[serde_with::serde_as]
2625#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2626pub struct WasmPluginVersion {
2627 /// Output only. The timestamp when the resource was created.
2628 #[serde(rename = "createTime")]
2629 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2630 /// Optional. A human-readable description of the resource.
2631 pub description: Option<String>,
2632 /// Output only. This field holds the digest (usually checksum) value for the plugin image. The value is calculated based on the `image_uri` field. If the `image_uri` field refers to a container image, the digest value is obtained from the container image. If the `image_uri` field refers to a generic artifact, the digest value is calculated based on the contents of the file.
2633 #[serde(rename = "imageDigest")]
2634 pub image_digest: Option<String>,
2635 /// Optional. URI of the image containing the Wasm module, stored in Artifact Registry. The URI can refer to one of the following repository formats: * Container images: the `image_uri` must point to a container that contains a single file with the name `plugin.wasm`. When a new `WasmPluginVersion` resource is created, the digest of the image is saved in the `image_digest` field. When pulling a container image from Artifact Registry, the digest value is used instead of an image tag. * Generic artifacts: the `image_uri` must be in this format: `projects/{project}/locations/{location}/repositories/{repository}/ genericArtifacts/{package}:{version}`. The specified package and version must contain a file with the name `plugin.wasm`. When a new `WasmPluginVersion` resource is created, the checksum of the contents of the file is saved in the `image_digest` field.
2636 #[serde(rename = "imageUri")]
2637 pub image_uri: Option<String>,
2638 /// Optional. Set of labels associated with the `WasmPluginVersion` resource.
2639 pub labels: Option<HashMap<String, String>>,
2640 /// Identifier. Name of the `WasmPluginVersion` resource in the following format: `projects/{project}/locations/{location}/wasmPlugins/{wasm_plugin}/ versions/{wasm_plugin_version}`.
2641 pub name: Option<String>,
2642 /// Configuration for the plugin. The configuration is provided to the plugin at runtime through the `ON_CONFIGURE` callback. When a new `WasmPluginVersion` resource is created, the digest of the contents is saved in the `plugin_config_digest` field.
2643 #[serde(rename = "pluginConfigData")]
2644 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
2645 pub plugin_config_data: Option<Vec<u8>>,
2646 /// Output only. This field holds the digest (usually checksum) value for the plugin configuration. The value is calculated based on the contents of `plugin_config_data` field or the image defined by the `plugin_config_uri` field.
2647 #[serde(rename = "pluginConfigDigest")]
2648 pub plugin_config_digest: Option<String>,
2649 /// URI of the plugin configuration stored in the Artifact Registry. The configuration is provided to the plugin at runtime through the `ON_CONFIGURE` callback. The URI can refer to one of the following repository formats: * Container images: the `plugin_config_uri` must point to a container that contains a single file with the name `plugin.config`. When a new `WasmPluginVersion` resource is created, the digest of the image is saved in the `plugin_config_digest` field. When pulling a container image from Artifact Registry, the digest value is used instead of an image tag. * Generic artifacts: the `plugin_config_uri` must be in this format: `projects/{project}/locations/{location}/repositories/{repository}/ genericArtifacts/{package}:{version}`. The specified package and version must contain a file with the name `plugin.config`. When a new `WasmPluginVersion` resource is created, the checksum of the contents of the file is saved in the `plugin_config_digest` field.
2650 #[serde(rename = "pluginConfigUri")]
2651 pub plugin_config_uri: Option<String>,
2652 /// Output only. The timestamp when the resource was updated.
2653 #[serde(rename = "updateTime")]
2654 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2655}
2656
2657impl common::RequestValue for WasmPluginVersion {}
2658impl common::ResponseResult for WasmPluginVersion {}
2659
2660/// Details of a `WasmPluginVersion` resource to be inlined in the `WasmPlugin` resource.
2661///
2662/// This type is not used in any activity, and only used as *part* of another schema.
2663///
2664#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2665#[serde_with::serde_as]
2666#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2667pub struct WasmPluginVersionDetails {
2668 /// Output only. The timestamp when the resource was created.
2669 #[serde(rename = "createTime")]
2670 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2671 /// Optional. A human-readable description of the resource.
2672 pub description: Option<String>,
2673 /// Output only. This field holds the digest (usually checksum) value for the plugin image. The value is calculated based on the `image_uri` field. If the `image_uri` field refers to a container image, the digest value is obtained from the container image. If the `image_uri` field refers to a generic artifact, the digest value is calculated based on the contents of the file.
2674 #[serde(rename = "imageDigest")]
2675 pub image_digest: Option<String>,
2676 /// Optional. URI of the image containing the Wasm module, stored in Artifact Registry. The URI can refer to one of the following repository formats: * Container images: the `image_uri` must point to a container that contains a single file with the name `plugin.wasm`. When a new `WasmPluginVersion` resource is created, the digest of the image is saved in the `image_digest` field. When pulling a container image from Artifact Registry, the digest value is used instead of an image tag. * Generic artifacts: the `image_uri` must be in this format: `projects/{project}/locations/{location}/repositories/{repository}/ genericArtifacts/{package}:{version}`. The specified package and version must contain a file with the name `plugin.wasm`. When a new `WasmPluginVersion` resource is created, the checksum of the contents of the file is saved in the `image_digest` field.
2677 #[serde(rename = "imageUri")]
2678 pub image_uri: Option<String>,
2679 /// Optional. Set of labels associated with the `WasmPluginVersion` resource.
2680 pub labels: Option<HashMap<String, String>>,
2681 /// Configuration for the plugin. The configuration is provided to the plugin at runtime through the `ON_CONFIGURE` callback. When a new `WasmPluginVersion` version is created, the digest of the contents is saved in the `plugin_config_digest` field.
2682 #[serde(rename = "pluginConfigData")]
2683 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
2684 pub plugin_config_data: Option<Vec<u8>>,
2685 /// Output only. This field holds the digest (usually checksum) value for the plugin configuration. The value is calculated based on the contents of `plugin_config_data` field or the image defined by the `plugin_config_uri` field.
2686 #[serde(rename = "pluginConfigDigest")]
2687 pub plugin_config_digest: Option<String>,
2688 /// URI of the plugin configuration stored in the Artifact Registry. The configuration is provided to the plugin at runtime through the `ON_CONFIGURE` callback. The URI can refer to one of the following repository formats: * Container images: the `plugin_config_uri` must point to a container that contains a single file with the name `plugin.config`. When a new `WasmPluginVersion` resource is created, the digest of the image is saved in the `plugin_config_digest` field. When pulling a container image from Artifact Registry, the digest value is used instead of an image tag. * Generic artifacts: the `plugin_config_uri` must be in this format: `projects/{project}/locations/{location}/repositories/{repository}/ genericArtifacts/{package}:{version}`. The specified package and version must contain a file with the name `plugin.config`. When a new `WasmPluginVersion` resource is created, the checksum of the contents of the file is saved in the `plugin_config_digest` field.
2689 #[serde(rename = "pluginConfigUri")]
2690 pub plugin_config_uri: Option<String>,
2691 /// Output only. The timestamp when the resource was updated.
2692 #[serde(rename = "updateTime")]
2693 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2694}
2695
2696impl common::Part for WasmPluginVersionDetails {}
2697
2698// ###################
2699// MethodBuilders ###
2700// #################
2701
2702/// A builder providing access to all methods supported on *project* resources.
2703/// It is not used directly, but through the [`NetworkServices`] hub.
2704///
2705/// # Example
2706///
2707/// Instantiate a resource builder
2708///
2709/// ```test_harness,no_run
2710/// extern crate hyper;
2711/// extern crate hyper_rustls;
2712/// extern crate google_networkservices1 as networkservices1;
2713///
2714/// # async fn dox() {
2715/// use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2716///
2717/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2718/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2719/// .with_native_roots()
2720/// .unwrap()
2721/// .https_only()
2722/// .enable_http2()
2723/// .build();
2724///
2725/// let executor = hyper_util::rt::TokioExecutor::new();
2726/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2727/// secret,
2728/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2729/// yup_oauth2::client::CustomHyperClientBuilder::from(
2730/// hyper_util::client::legacy::Client::builder(executor).build(connector),
2731/// ),
2732/// ).build().await.unwrap();
2733///
2734/// let client = hyper_util::client::legacy::Client::builder(
2735/// hyper_util::rt::TokioExecutor::new()
2736/// )
2737/// .build(
2738/// hyper_rustls::HttpsConnectorBuilder::new()
2739/// .with_native_roots()
2740/// .unwrap()
2741/// .https_or_http()
2742/// .enable_http2()
2743/// .build()
2744/// );
2745/// let mut hub = NetworkServices::new(client, auth);
2746/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2747/// // like `locations_authz_extensions_create(...)`, `locations_authz_extensions_delete(...)`, `locations_authz_extensions_get(...)`, `locations_authz_extensions_list(...)`, `locations_authz_extensions_patch(...)`, `locations_edge_cache_keysets_get_iam_policy(...)`, `locations_edge_cache_keysets_set_iam_policy(...)`, `locations_edge_cache_keysets_test_iam_permissions(...)`, `locations_edge_cache_origins_get_iam_policy(...)`, `locations_edge_cache_origins_set_iam_policy(...)`, `locations_edge_cache_origins_test_iam_permissions(...)`, `locations_edge_cache_services_get_iam_policy(...)`, `locations_edge_cache_services_set_iam_policy(...)`, `locations_edge_cache_services_test_iam_permissions(...)`, `locations_endpoint_policies_create(...)`, `locations_endpoint_policies_delete(...)`, `locations_endpoint_policies_get(...)`, `locations_endpoint_policies_list(...)`, `locations_endpoint_policies_patch(...)`, `locations_gateways_create(...)`, `locations_gateways_delete(...)`, `locations_gateways_get(...)`, `locations_gateways_list(...)`, `locations_gateways_patch(...)`, `locations_gateways_route_views_get(...)`, `locations_gateways_route_views_list(...)`, `locations_get(...)`, `locations_grpc_routes_create(...)`, `locations_grpc_routes_delete(...)`, `locations_grpc_routes_get(...)`, `locations_grpc_routes_list(...)`, `locations_grpc_routes_patch(...)`, `locations_http_routes_create(...)`, `locations_http_routes_delete(...)`, `locations_http_routes_get(...)`, `locations_http_routes_list(...)`, `locations_http_routes_patch(...)`, `locations_lb_edge_extensions_create(...)`, `locations_lb_edge_extensions_delete(...)`, `locations_lb_edge_extensions_get(...)`, `locations_lb_edge_extensions_list(...)`, `locations_lb_edge_extensions_patch(...)`, `locations_lb_route_extensions_create(...)`, `locations_lb_route_extensions_delete(...)`, `locations_lb_route_extensions_get(...)`, `locations_lb_route_extensions_list(...)`, `locations_lb_route_extensions_patch(...)`, `locations_lb_traffic_extensions_create(...)`, `locations_lb_traffic_extensions_delete(...)`, `locations_lb_traffic_extensions_get(...)`, `locations_lb_traffic_extensions_list(...)`, `locations_lb_traffic_extensions_patch(...)`, `locations_list(...)`, `locations_meshes_create(...)`, `locations_meshes_delete(...)`, `locations_meshes_get(...)`, `locations_meshes_list(...)`, `locations_meshes_patch(...)`, `locations_meshes_route_views_get(...)`, `locations_meshes_route_views_list(...)`, `locations_operations_cancel(...)`, `locations_operations_delete(...)`, `locations_operations_get(...)`, `locations_operations_list(...)`, `locations_service_bindings_create(...)`, `locations_service_bindings_delete(...)`, `locations_service_bindings_get(...)`, `locations_service_bindings_list(...)`, `locations_service_bindings_patch(...)`, `locations_service_lb_policies_create(...)`, `locations_service_lb_policies_delete(...)`, `locations_service_lb_policies_get(...)`, `locations_service_lb_policies_list(...)`, `locations_service_lb_policies_patch(...)`, `locations_tcp_routes_create(...)`, `locations_tcp_routes_delete(...)`, `locations_tcp_routes_get(...)`, `locations_tcp_routes_list(...)`, `locations_tcp_routes_patch(...)`, `locations_tls_routes_create(...)`, `locations_tls_routes_delete(...)`, `locations_tls_routes_get(...)`, `locations_tls_routes_list(...)`, `locations_tls_routes_patch(...)`, `locations_wasm_plugins_create(...)`, `locations_wasm_plugins_delete(...)`, `locations_wasm_plugins_get(...)`, `locations_wasm_plugins_list(...)`, `locations_wasm_plugins_patch(...)`, `locations_wasm_plugins_versions_create(...)`, `locations_wasm_plugins_versions_delete(...)`, `locations_wasm_plugins_versions_get(...)` and `locations_wasm_plugins_versions_list(...)`
2748/// // to build up your call.
2749/// let rb = hub.projects();
2750/// # }
2751/// ```
2752pub struct ProjectMethods<'a, C>
2753where
2754 C: 'a,
2755{
2756 hub: &'a NetworkServices<C>,
2757}
2758
2759impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
2760
2761impl<'a, C> ProjectMethods<'a, C> {
2762 /// Create a builder to help you perform the following task:
2763 ///
2764 /// Creates a new `AuthzExtension` resource in a given project and location.
2765 ///
2766 /// # Arguments
2767 ///
2768 /// * `request` - No description provided.
2769 /// * `parent` - Required. The parent resource of the `AuthzExtension` resource. Must be in the format `projects/{project}/locations/{location}`.
2770 pub fn locations_authz_extensions_create(
2771 &self,
2772 request: AuthzExtension,
2773 parent: &str,
2774 ) -> ProjectLocationAuthzExtensionCreateCall<'a, C> {
2775 ProjectLocationAuthzExtensionCreateCall {
2776 hub: self.hub,
2777 _request: request,
2778 _parent: parent.to_string(),
2779 _request_id: Default::default(),
2780 _authz_extension_id: Default::default(),
2781 _delegate: Default::default(),
2782 _additional_params: Default::default(),
2783 _scopes: Default::default(),
2784 }
2785 }
2786
2787 /// Create a builder to help you perform the following task:
2788 ///
2789 /// Deletes the specified `AuthzExtension` resource.
2790 ///
2791 /// # Arguments
2792 ///
2793 /// * `name` - Required. The name of the `AuthzExtension` resource to delete. Must be in the format `projects/{project}/locations/{location}/authzExtensions/{authz_extension}`.
2794 pub fn locations_authz_extensions_delete(
2795 &self,
2796 name: &str,
2797 ) -> ProjectLocationAuthzExtensionDeleteCall<'a, C> {
2798 ProjectLocationAuthzExtensionDeleteCall {
2799 hub: self.hub,
2800 _name: name.to_string(),
2801 _request_id: Default::default(),
2802 _delegate: Default::default(),
2803 _additional_params: Default::default(),
2804 _scopes: Default::default(),
2805 }
2806 }
2807
2808 /// Create a builder to help you perform the following task:
2809 ///
2810 /// Gets details of the specified `AuthzExtension` resource.
2811 ///
2812 /// # Arguments
2813 ///
2814 /// * `name` - Required. A name of the `AuthzExtension` resource to get. Must be in the format `projects/{project}/locations/{location}/authzExtensions/{authz_extension}`.
2815 pub fn locations_authz_extensions_get(
2816 &self,
2817 name: &str,
2818 ) -> ProjectLocationAuthzExtensionGetCall<'a, C> {
2819 ProjectLocationAuthzExtensionGetCall {
2820 hub: self.hub,
2821 _name: name.to_string(),
2822 _delegate: Default::default(),
2823 _additional_params: Default::default(),
2824 _scopes: Default::default(),
2825 }
2826 }
2827
2828 /// Create a builder to help you perform the following task:
2829 ///
2830 /// Lists `AuthzExtension` resources in a given project and location.
2831 ///
2832 /// # Arguments
2833 ///
2834 /// * `parent` - Required. The project and location from which the `AuthzExtension` resources are listed. These values are specified in the following format: `projects/{project}/locations/{location}`.
2835 pub fn locations_authz_extensions_list(
2836 &self,
2837 parent: &str,
2838 ) -> ProjectLocationAuthzExtensionListCall<'a, C> {
2839 ProjectLocationAuthzExtensionListCall {
2840 hub: self.hub,
2841 _parent: parent.to_string(),
2842 _page_token: Default::default(),
2843 _page_size: Default::default(),
2844 _order_by: Default::default(),
2845 _filter: Default::default(),
2846 _delegate: Default::default(),
2847 _additional_params: Default::default(),
2848 _scopes: Default::default(),
2849 }
2850 }
2851
2852 /// Create a builder to help you perform the following task:
2853 ///
2854 /// Updates the parameters of the specified `AuthzExtension` resource.
2855 ///
2856 /// # Arguments
2857 ///
2858 /// * `request` - No description provided.
2859 /// * `name` - Required. Identifier. Name of the `AuthzExtension` resource in the following format: `projects/{project}/locations/{location}/authzExtensions/{authz_extension}`.
2860 pub fn locations_authz_extensions_patch(
2861 &self,
2862 request: AuthzExtension,
2863 name: &str,
2864 ) -> ProjectLocationAuthzExtensionPatchCall<'a, C> {
2865 ProjectLocationAuthzExtensionPatchCall {
2866 hub: self.hub,
2867 _request: request,
2868 _name: name.to_string(),
2869 _update_mask: Default::default(),
2870 _request_id: Default::default(),
2871 _delegate: Default::default(),
2872 _additional_params: Default::default(),
2873 _scopes: Default::default(),
2874 }
2875 }
2876
2877 /// Create a builder to help you perform the following task:
2878 ///
2879 /// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
2880 ///
2881 /// # Arguments
2882 ///
2883 /// * `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.
2884 pub fn locations_edge_cache_keysets_get_iam_policy(
2885 &self,
2886 resource: &str,
2887 ) -> ProjectLocationEdgeCacheKeysetGetIamPolicyCall<'a, C> {
2888 ProjectLocationEdgeCacheKeysetGetIamPolicyCall {
2889 hub: self.hub,
2890 _resource: resource.to_string(),
2891 _options_requested_policy_version: Default::default(),
2892 _delegate: Default::default(),
2893 _additional_params: Default::default(),
2894 _scopes: Default::default(),
2895 }
2896 }
2897
2898 /// Create a builder to help you perform the following task:
2899 ///
2900 /// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
2901 ///
2902 /// # Arguments
2903 ///
2904 /// * `request` - No description provided.
2905 /// * `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.
2906 pub fn locations_edge_cache_keysets_set_iam_policy(
2907 &self,
2908 request: SetIamPolicyRequest,
2909 resource: &str,
2910 ) -> ProjectLocationEdgeCacheKeysetSetIamPolicyCall<'a, C> {
2911 ProjectLocationEdgeCacheKeysetSetIamPolicyCall {
2912 hub: self.hub,
2913 _request: request,
2914 _resource: resource.to_string(),
2915 _delegate: Default::default(),
2916 _additional_params: Default::default(),
2917 _scopes: Default::default(),
2918 }
2919 }
2920
2921 /// Create a builder to help you perform the following task:
2922 ///
2923 /// 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.
2924 ///
2925 /// # Arguments
2926 ///
2927 /// * `request` - No description provided.
2928 /// * `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.
2929 pub fn locations_edge_cache_keysets_test_iam_permissions(
2930 &self,
2931 request: TestIamPermissionsRequest,
2932 resource: &str,
2933 ) -> ProjectLocationEdgeCacheKeysetTestIamPermissionCall<'a, C> {
2934 ProjectLocationEdgeCacheKeysetTestIamPermissionCall {
2935 hub: self.hub,
2936 _request: request,
2937 _resource: resource.to_string(),
2938 _delegate: Default::default(),
2939 _additional_params: Default::default(),
2940 _scopes: Default::default(),
2941 }
2942 }
2943
2944 /// Create a builder to help you perform the following task:
2945 ///
2946 /// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
2947 ///
2948 /// # Arguments
2949 ///
2950 /// * `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.
2951 pub fn locations_edge_cache_origins_get_iam_policy(
2952 &self,
2953 resource: &str,
2954 ) -> ProjectLocationEdgeCacheOriginGetIamPolicyCall<'a, C> {
2955 ProjectLocationEdgeCacheOriginGetIamPolicyCall {
2956 hub: self.hub,
2957 _resource: resource.to_string(),
2958 _options_requested_policy_version: Default::default(),
2959 _delegate: Default::default(),
2960 _additional_params: Default::default(),
2961 _scopes: Default::default(),
2962 }
2963 }
2964
2965 /// Create a builder to help you perform the following task:
2966 ///
2967 /// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
2968 ///
2969 /// # Arguments
2970 ///
2971 /// * `request` - No description provided.
2972 /// * `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.
2973 pub fn locations_edge_cache_origins_set_iam_policy(
2974 &self,
2975 request: SetIamPolicyRequest,
2976 resource: &str,
2977 ) -> ProjectLocationEdgeCacheOriginSetIamPolicyCall<'a, C> {
2978 ProjectLocationEdgeCacheOriginSetIamPolicyCall {
2979 hub: self.hub,
2980 _request: request,
2981 _resource: resource.to_string(),
2982 _delegate: Default::default(),
2983 _additional_params: Default::default(),
2984 _scopes: Default::default(),
2985 }
2986 }
2987
2988 /// Create a builder to help you perform the following task:
2989 ///
2990 /// 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.
2991 ///
2992 /// # Arguments
2993 ///
2994 /// * `request` - No description provided.
2995 /// * `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.
2996 pub fn locations_edge_cache_origins_test_iam_permissions(
2997 &self,
2998 request: TestIamPermissionsRequest,
2999 resource: &str,
3000 ) -> ProjectLocationEdgeCacheOriginTestIamPermissionCall<'a, C> {
3001 ProjectLocationEdgeCacheOriginTestIamPermissionCall {
3002 hub: self.hub,
3003 _request: request,
3004 _resource: resource.to_string(),
3005 _delegate: Default::default(),
3006 _additional_params: Default::default(),
3007 _scopes: Default::default(),
3008 }
3009 }
3010
3011 /// Create a builder to help you perform the following task:
3012 ///
3013 /// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
3014 ///
3015 /// # Arguments
3016 ///
3017 /// * `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.
3018 pub fn locations_edge_cache_services_get_iam_policy(
3019 &self,
3020 resource: &str,
3021 ) -> ProjectLocationEdgeCacheServiceGetIamPolicyCall<'a, C> {
3022 ProjectLocationEdgeCacheServiceGetIamPolicyCall {
3023 hub: self.hub,
3024 _resource: resource.to_string(),
3025 _options_requested_policy_version: Default::default(),
3026 _delegate: Default::default(),
3027 _additional_params: Default::default(),
3028 _scopes: Default::default(),
3029 }
3030 }
3031
3032 /// Create a builder to help you perform the following task:
3033 ///
3034 /// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
3035 ///
3036 /// # Arguments
3037 ///
3038 /// * `request` - No description provided.
3039 /// * `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.
3040 pub fn locations_edge_cache_services_set_iam_policy(
3041 &self,
3042 request: SetIamPolicyRequest,
3043 resource: &str,
3044 ) -> ProjectLocationEdgeCacheServiceSetIamPolicyCall<'a, C> {
3045 ProjectLocationEdgeCacheServiceSetIamPolicyCall {
3046 hub: self.hub,
3047 _request: request,
3048 _resource: resource.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 /// 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.
3058 ///
3059 /// # Arguments
3060 ///
3061 /// * `request` - No description provided.
3062 /// * `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.
3063 pub fn locations_edge_cache_services_test_iam_permissions(
3064 &self,
3065 request: TestIamPermissionsRequest,
3066 resource: &str,
3067 ) -> ProjectLocationEdgeCacheServiceTestIamPermissionCall<'a, C> {
3068 ProjectLocationEdgeCacheServiceTestIamPermissionCall {
3069 hub: self.hub,
3070 _request: request,
3071 _resource: resource.to_string(),
3072 _delegate: Default::default(),
3073 _additional_params: Default::default(),
3074 _scopes: Default::default(),
3075 }
3076 }
3077
3078 /// Create a builder to help you perform the following task:
3079 ///
3080 /// Creates a new EndpointPolicy in a given project and location.
3081 ///
3082 /// # Arguments
3083 ///
3084 /// * `request` - No description provided.
3085 /// * `parent` - Required. The parent resource of the EndpointPolicy. Must be in the format `projects/*/locations/*`.
3086 pub fn locations_endpoint_policies_create(
3087 &self,
3088 request: EndpointPolicy,
3089 parent: &str,
3090 ) -> ProjectLocationEndpointPolicyCreateCall<'a, C> {
3091 ProjectLocationEndpointPolicyCreateCall {
3092 hub: self.hub,
3093 _request: request,
3094 _parent: parent.to_string(),
3095 _endpoint_policy_id: Default::default(),
3096 _delegate: Default::default(),
3097 _additional_params: Default::default(),
3098 _scopes: Default::default(),
3099 }
3100 }
3101
3102 /// Create a builder to help you perform the following task:
3103 ///
3104 /// Deletes a single EndpointPolicy.
3105 ///
3106 /// # Arguments
3107 ///
3108 /// * `name` - Required. A name of the EndpointPolicy to delete. Must be in the format `projects/*/locations/*/endpointPolicies/*`.
3109 pub fn locations_endpoint_policies_delete(
3110 &self,
3111 name: &str,
3112 ) -> ProjectLocationEndpointPolicyDeleteCall<'a, C> {
3113 ProjectLocationEndpointPolicyDeleteCall {
3114 hub: self.hub,
3115 _name: name.to_string(),
3116 _delegate: Default::default(),
3117 _additional_params: Default::default(),
3118 _scopes: Default::default(),
3119 }
3120 }
3121
3122 /// Create a builder to help you perform the following task:
3123 ///
3124 /// Gets details of a single EndpointPolicy.
3125 ///
3126 /// # Arguments
3127 ///
3128 /// * `name` - Required. A name of the EndpointPolicy to get. Must be in the format `projects/*/locations/*/endpointPolicies/*`.
3129 pub fn locations_endpoint_policies_get(
3130 &self,
3131 name: &str,
3132 ) -> ProjectLocationEndpointPolicyGetCall<'a, C> {
3133 ProjectLocationEndpointPolicyGetCall {
3134 hub: self.hub,
3135 _name: name.to_string(),
3136 _delegate: Default::default(),
3137 _additional_params: Default::default(),
3138 _scopes: Default::default(),
3139 }
3140 }
3141
3142 /// Create a builder to help you perform the following task:
3143 ///
3144 /// Lists EndpointPolicies in a given project and location.
3145 ///
3146 /// # Arguments
3147 ///
3148 /// * `parent` - Required. The project and location from which the EndpointPolicies should be listed, specified in the format `projects/*/locations/*`.
3149 pub fn locations_endpoint_policies_list(
3150 &self,
3151 parent: &str,
3152 ) -> ProjectLocationEndpointPolicyListCall<'a, C> {
3153 ProjectLocationEndpointPolicyListCall {
3154 hub: self.hub,
3155 _parent: parent.to_string(),
3156 _return_partial_success: Default::default(),
3157 _page_token: Default::default(),
3158 _page_size: Default::default(),
3159 _delegate: Default::default(),
3160 _additional_params: Default::default(),
3161 _scopes: Default::default(),
3162 }
3163 }
3164
3165 /// Create a builder to help you perform the following task:
3166 ///
3167 /// Updates the parameters of a single EndpointPolicy.
3168 ///
3169 /// # Arguments
3170 ///
3171 /// * `request` - No description provided.
3172 /// * `name` - Identifier. Name of the EndpointPolicy resource. It matches pattern `projects/{project}/locations/*/endpointPolicies/{endpoint_policy}`.
3173 pub fn locations_endpoint_policies_patch(
3174 &self,
3175 request: EndpointPolicy,
3176 name: &str,
3177 ) -> ProjectLocationEndpointPolicyPatchCall<'a, C> {
3178 ProjectLocationEndpointPolicyPatchCall {
3179 hub: self.hub,
3180 _request: request,
3181 _name: name.to_string(),
3182 _update_mask: Default::default(),
3183 _delegate: Default::default(),
3184 _additional_params: Default::default(),
3185 _scopes: Default::default(),
3186 }
3187 }
3188
3189 /// Create a builder to help you perform the following task:
3190 ///
3191 /// Get a single RouteView of a Gateway.
3192 ///
3193 /// # Arguments
3194 ///
3195 /// * `name` - Required. Name of the GatewayRouteView resource. Formats: projects/{project_number}/locations/{location}/gateways/{gateway}/routeViews/{route_view}
3196 pub fn locations_gateways_route_views_get(
3197 &self,
3198 name: &str,
3199 ) -> ProjectLocationGatewayRouteViewGetCall<'a, C> {
3200 ProjectLocationGatewayRouteViewGetCall {
3201 hub: self.hub,
3202 _name: name.to_string(),
3203 _delegate: Default::default(),
3204 _additional_params: Default::default(),
3205 _scopes: Default::default(),
3206 }
3207 }
3208
3209 /// Create a builder to help you perform the following task:
3210 ///
3211 /// Lists RouteViews
3212 ///
3213 /// # Arguments
3214 ///
3215 /// * `parent` - Required. The Gateway to which a Route is associated. Formats: projects/{project_number}/locations/{location}/gateways/{gateway}
3216 pub fn locations_gateways_route_views_list(
3217 &self,
3218 parent: &str,
3219 ) -> ProjectLocationGatewayRouteViewListCall<'a, C> {
3220 ProjectLocationGatewayRouteViewListCall {
3221 hub: self.hub,
3222 _parent: parent.to_string(),
3223 _page_token: Default::default(),
3224 _page_size: Default::default(),
3225 _delegate: Default::default(),
3226 _additional_params: Default::default(),
3227 _scopes: Default::default(),
3228 }
3229 }
3230
3231 /// Create a builder to help you perform the following task:
3232 ///
3233 /// Creates a new Gateway in a given project and location.
3234 ///
3235 /// # Arguments
3236 ///
3237 /// * `request` - No description provided.
3238 /// * `parent` - Required. The parent resource of the Gateway. Must be in the format `projects/*/locations/*`.
3239 pub fn locations_gateways_create(
3240 &self,
3241 request: Gateway,
3242 parent: &str,
3243 ) -> ProjectLocationGatewayCreateCall<'a, C> {
3244 ProjectLocationGatewayCreateCall {
3245 hub: self.hub,
3246 _request: request,
3247 _parent: parent.to_string(),
3248 _gateway_id: Default::default(),
3249 _delegate: Default::default(),
3250 _additional_params: Default::default(),
3251 _scopes: Default::default(),
3252 }
3253 }
3254
3255 /// Create a builder to help you perform the following task:
3256 ///
3257 /// Deletes a single Gateway.
3258 ///
3259 /// # Arguments
3260 ///
3261 /// * `name` - Required. A name of the Gateway to delete. Must be in the format `projects/*/locations/*/gateways/*`.
3262 pub fn locations_gateways_delete(&self, name: &str) -> ProjectLocationGatewayDeleteCall<'a, C> {
3263 ProjectLocationGatewayDeleteCall {
3264 hub: self.hub,
3265 _name: name.to_string(),
3266 _delegate: Default::default(),
3267 _additional_params: Default::default(),
3268 _scopes: Default::default(),
3269 }
3270 }
3271
3272 /// Create a builder to help you perform the following task:
3273 ///
3274 /// Gets details of a single Gateway.
3275 ///
3276 /// # Arguments
3277 ///
3278 /// * `name` - Required. A name of the Gateway to get. Must be in the format `projects/*/locations/*/gateways/*`.
3279 pub fn locations_gateways_get(&self, name: &str) -> ProjectLocationGatewayGetCall<'a, C> {
3280 ProjectLocationGatewayGetCall {
3281 hub: self.hub,
3282 _name: name.to_string(),
3283 _delegate: Default::default(),
3284 _additional_params: Default::default(),
3285 _scopes: Default::default(),
3286 }
3287 }
3288
3289 /// Create a builder to help you perform the following task:
3290 ///
3291 /// Lists Gateways in a given project and location.
3292 ///
3293 /// # Arguments
3294 ///
3295 /// * `parent` - Required. The project and location from which the Gateways should be listed, specified in the format `projects/*/locations/*`.
3296 pub fn locations_gateways_list(&self, parent: &str) -> ProjectLocationGatewayListCall<'a, C> {
3297 ProjectLocationGatewayListCall {
3298 hub: self.hub,
3299 _parent: parent.to_string(),
3300 _page_token: Default::default(),
3301 _page_size: Default::default(),
3302 _delegate: Default::default(),
3303 _additional_params: Default::default(),
3304 _scopes: Default::default(),
3305 }
3306 }
3307
3308 /// Create a builder to help you perform the following task:
3309 ///
3310 /// Updates the parameters of a single Gateway.
3311 ///
3312 /// # Arguments
3313 ///
3314 /// * `request` - No description provided.
3315 /// * `name` - Identifier. Name of the Gateway resource. It matches pattern `projects/*/locations/*/gateways/`.
3316 pub fn locations_gateways_patch(
3317 &self,
3318 request: Gateway,
3319 name: &str,
3320 ) -> ProjectLocationGatewayPatchCall<'a, C> {
3321 ProjectLocationGatewayPatchCall {
3322 hub: self.hub,
3323 _request: request,
3324 _name: name.to_string(),
3325 _update_mask: Default::default(),
3326 _delegate: Default::default(),
3327 _additional_params: Default::default(),
3328 _scopes: Default::default(),
3329 }
3330 }
3331
3332 /// Create a builder to help you perform the following task:
3333 ///
3334 /// Creates a new GrpcRoute in a given project and location.
3335 ///
3336 /// # Arguments
3337 ///
3338 /// * `request` - No description provided.
3339 /// * `parent` - Required. The parent resource of the GrpcRoute. Must be in the format `projects/*/locations/*`.
3340 pub fn locations_grpc_routes_create(
3341 &self,
3342 request: GrpcRoute,
3343 parent: &str,
3344 ) -> ProjectLocationGrpcRouteCreateCall<'a, C> {
3345 ProjectLocationGrpcRouteCreateCall {
3346 hub: self.hub,
3347 _request: request,
3348 _parent: parent.to_string(),
3349 _grpc_route_id: Default::default(),
3350 _delegate: Default::default(),
3351 _additional_params: Default::default(),
3352 _scopes: Default::default(),
3353 }
3354 }
3355
3356 /// Create a builder to help you perform the following task:
3357 ///
3358 /// Deletes a single GrpcRoute.
3359 ///
3360 /// # Arguments
3361 ///
3362 /// * `name` - Required. A name of the GrpcRoute to delete. Must be in the format `projects/*/locations/*/grpcRoutes/*`.
3363 pub fn locations_grpc_routes_delete(
3364 &self,
3365 name: &str,
3366 ) -> ProjectLocationGrpcRouteDeleteCall<'a, C> {
3367 ProjectLocationGrpcRouteDeleteCall {
3368 hub: self.hub,
3369 _name: name.to_string(),
3370 _delegate: Default::default(),
3371 _additional_params: Default::default(),
3372 _scopes: Default::default(),
3373 }
3374 }
3375
3376 /// Create a builder to help you perform the following task:
3377 ///
3378 /// Gets details of a single GrpcRoute.
3379 ///
3380 /// # Arguments
3381 ///
3382 /// * `name` - Required. A name of the GrpcRoute to get. Must be in the format `projects/*/locations/*/grpcRoutes/*`.
3383 pub fn locations_grpc_routes_get(&self, name: &str) -> ProjectLocationGrpcRouteGetCall<'a, C> {
3384 ProjectLocationGrpcRouteGetCall {
3385 hub: self.hub,
3386 _name: name.to_string(),
3387 _delegate: Default::default(),
3388 _additional_params: Default::default(),
3389 _scopes: Default::default(),
3390 }
3391 }
3392
3393 /// Create a builder to help you perform the following task:
3394 ///
3395 /// Lists GrpcRoutes in a given project and location.
3396 ///
3397 /// # Arguments
3398 ///
3399 /// * `parent` - Required. The project and location from which the GrpcRoutes should be listed, specified in the format `projects/*/locations/*`.
3400 pub fn locations_grpc_routes_list(
3401 &self,
3402 parent: &str,
3403 ) -> ProjectLocationGrpcRouteListCall<'a, C> {
3404 ProjectLocationGrpcRouteListCall {
3405 hub: self.hub,
3406 _parent: parent.to_string(),
3407 _return_partial_success: Default::default(),
3408 _page_token: Default::default(),
3409 _page_size: Default::default(),
3410 _delegate: Default::default(),
3411 _additional_params: Default::default(),
3412 _scopes: Default::default(),
3413 }
3414 }
3415
3416 /// Create a builder to help you perform the following task:
3417 ///
3418 /// Updates the parameters of a single GrpcRoute.
3419 ///
3420 /// # Arguments
3421 ///
3422 /// * `request` - No description provided.
3423 /// * `name` - Identifier. Name of the GrpcRoute resource. It matches pattern `projects/*/locations/*/grpcRoutes/`
3424 pub fn locations_grpc_routes_patch(
3425 &self,
3426 request: GrpcRoute,
3427 name: &str,
3428 ) -> ProjectLocationGrpcRoutePatchCall<'a, C> {
3429 ProjectLocationGrpcRoutePatchCall {
3430 hub: self.hub,
3431 _request: request,
3432 _name: name.to_string(),
3433 _update_mask: Default::default(),
3434 _delegate: Default::default(),
3435 _additional_params: Default::default(),
3436 _scopes: Default::default(),
3437 }
3438 }
3439
3440 /// Create a builder to help you perform the following task:
3441 ///
3442 /// Creates a new HttpRoute in a given project and location.
3443 ///
3444 /// # Arguments
3445 ///
3446 /// * `request` - No description provided.
3447 /// * `parent` - Required. The parent resource of the HttpRoute. Must be in the format `projects/*/locations/*`.
3448 pub fn locations_http_routes_create(
3449 &self,
3450 request: HttpRoute,
3451 parent: &str,
3452 ) -> ProjectLocationHttpRouteCreateCall<'a, C> {
3453 ProjectLocationHttpRouteCreateCall {
3454 hub: self.hub,
3455 _request: request,
3456 _parent: parent.to_string(),
3457 _http_route_id: Default::default(),
3458 _delegate: Default::default(),
3459 _additional_params: Default::default(),
3460 _scopes: Default::default(),
3461 }
3462 }
3463
3464 /// Create a builder to help you perform the following task:
3465 ///
3466 /// Deletes a single HttpRoute.
3467 ///
3468 /// # Arguments
3469 ///
3470 /// * `name` - Required. A name of the HttpRoute to delete. Must be in the format `projects/*/locations/*/httpRoutes/*`.
3471 pub fn locations_http_routes_delete(
3472 &self,
3473 name: &str,
3474 ) -> ProjectLocationHttpRouteDeleteCall<'a, C> {
3475 ProjectLocationHttpRouteDeleteCall {
3476 hub: self.hub,
3477 _name: name.to_string(),
3478 _delegate: Default::default(),
3479 _additional_params: Default::default(),
3480 _scopes: Default::default(),
3481 }
3482 }
3483
3484 /// Create a builder to help you perform the following task:
3485 ///
3486 /// Gets details of a single HttpRoute.
3487 ///
3488 /// # Arguments
3489 ///
3490 /// * `name` - Required. A name of the HttpRoute to get. Must be in the format `projects/*/locations/*/httpRoutes/*`.
3491 pub fn locations_http_routes_get(&self, name: &str) -> ProjectLocationHttpRouteGetCall<'a, C> {
3492 ProjectLocationHttpRouteGetCall {
3493 hub: self.hub,
3494 _name: name.to_string(),
3495 _delegate: Default::default(),
3496 _additional_params: Default::default(),
3497 _scopes: Default::default(),
3498 }
3499 }
3500
3501 /// Create a builder to help you perform the following task:
3502 ///
3503 /// Lists HttpRoute in a given project and location.
3504 ///
3505 /// # Arguments
3506 ///
3507 /// * `parent` - Required. The project and location from which the HttpRoutes should be listed, specified in the format `projects/*/locations/*`.
3508 pub fn locations_http_routes_list(
3509 &self,
3510 parent: &str,
3511 ) -> ProjectLocationHttpRouteListCall<'a, C> {
3512 ProjectLocationHttpRouteListCall {
3513 hub: self.hub,
3514 _parent: parent.to_string(),
3515 _return_partial_success: Default::default(),
3516 _page_token: Default::default(),
3517 _page_size: Default::default(),
3518 _delegate: Default::default(),
3519 _additional_params: Default::default(),
3520 _scopes: Default::default(),
3521 }
3522 }
3523
3524 /// Create a builder to help you perform the following task:
3525 ///
3526 /// Updates the parameters of a single HttpRoute.
3527 ///
3528 /// # Arguments
3529 ///
3530 /// * `request` - No description provided.
3531 /// * `name` - Identifier. Name of the HttpRoute resource. It matches pattern `projects/*/locations/*/httpRoutes/http_route_name>`.
3532 pub fn locations_http_routes_patch(
3533 &self,
3534 request: HttpRoute,
3535 name: &str,
3536 ) -> ProjectLocationHttpRoutePatchCall<'a, C> {
3537 ProjectLocationHttpRoutePatchCall {
3538 hub: self.hub,
3539 _request: request,
3540 _name: name.to_string(),
3541 _update_mask: Default::default(),
3542 _delegate: Default::default(),
3543 _additional_params: Default::default(),
3544 _scopes: Default::default(),
3545 }
3546 }
3547
3548 /// Create a builder to help you perform the following task:
3549 ///
3550 /// Creates a new `LbEdgeExtension` resource in a given project and location.
3551 ///
3552 /// # Arguments
3553 ///
3554 /// * `request` - No description provided.
3555 /// * `parent` - Required. The parent resource of the `LbEdgeExtension` resource. Must be in the format `projects/{project}/locations/{location}`.
3556 pub fn locations_lb_edge_extensions_create(
3557 &self,
3558 request: LbEdgeExtension,
3559 parent: &str,
3560 ) -> ProjectLocationLbEdgeExtensionCreateCall<'a, C> {
3561 ProjectLocationLbEdgeExtensionCreateCall {
3562 hub: self.hub,
3563 _request: request,
3564 _parent: parent.to_string(),
3565 _request_id: Default::default(),
3566 _lb_edge_extension_id: Default::default(),
3567 _delegate: Default::default(),
3568 _additional_params: Default::default(),
3569 _scopes: Default::default(),
3570 }
3571 }
3572
3573 /// Create a builder to help you perform the following task:
3574 ///
3575 /// Deletes the specified `LbEdgeExtension` resource.
3576 ///
3577 /// # Arguments
3578 ///
3579 /// * `name` - Required. The name of the `LbEdgeExtension` resource to delete. Must be in the format `projects/{project}/locations/{location}/lbEdgeExtensions/{lb_edge_extension}`.
3580 pub fn locations_lb_edge_extensions_delete(
3581 &self,
3582 name: &str,
3583 ) -> ProjectLocationLbEdgeExtensionDeleteCall<'a, C> {
3584 ProjectLocationLbEdgeExtensionDeleteCall {
3585 hub: self.hub,
3586 _name: name.to_string(),
3587 _request_id: Default::default(),
3588 _delegate: Default::default(),
3589 _additional_params: Default::default(),
3590 _scopes: Default::default(),
3591 }
3592 }
3593
3594 /// Create a builder to help you perform the following task:
3595 ///
3596 /// Gets details of the specified `LbEdgeExtension` resource.
3597 ///
3598 /// # Arguments
3599 ///
3600 /// * `name` - Required. A name of the `LbEdgeExtension` resource to get. Must be in the format `projects/{project}/locations/{location}/lbEdgeExtensions/{lb_edge_extension}`.
3601 pub fn locations_lb_edge_extensions_get(
3602 &self,
3603 name: &str,
3604 ) -> ProjectLocationLbEdgeExtensionGetCall<'a, C> {
3605 ProjectLocationLbEdgeExtensionGetCall {
3606 hub: self.hub,
3607 _name: name.to_string(),
3608 _delegate: Default::default(),
3609 _additional_params: Default::default(),
3610 _scopes: Default::default(),
3611 }
3612 }
3613
3614 /// Create a builder to help you perform the following task:
3615 ///
3616 /// Lists `LbEdgeExtension` resources in a given project and location.
3617 ///
3618 /// # Arguments
3619 ///
3620 /// * `parent` - Required. The project and location from which the `LbEdgeExtension` resources are listed. These values are specified in the following format: `projects/{project}/locations/{location}`.
3621 pub fn locations_lb_edge_extensions_list(
3622 &self,
3623 parent: &str,
3624 ) -> ProjectLocationLbEdgeExtensionListCall<'a, C> {
3625 ProjectLocationLbEdgeExtensionListCall {
3626 hub: self.hub,
3627 _parent: parent.to_string(),
3628 _page_token: Default::default(),
3629 _page_size: Default::default(),
3630 _order_by: Default::default(),
3631 _filter: Default::default(),
3632 _delegate: Default::default(),
3633 _additional_params: Default::default(),
3634 _scopes: Default::default(),
3635 }
3636 }
3637
3638 /// Create a builder to help you perform the following task:
3639 ///
3640 /// Updates the parameters of the specified `LbEdgeExtension` resource.
3641 ///
3642 /// # Arguments
3643 ///
3644 /// * `request` - No description provided.
3645 /// * `name` - Required. Identifier. Name of the `LbEdgeExtension` resource in the following format: `projects/{project}/locations/{location}/lbEdgeExtensions/{lb_edge_extension}`.
3646 pub fn locations_lb_edge_extensions_patch(
3647 &self,
3648 request: LbEdgeExtension,
3649 name: &str,
3650 ) -> ProjectLocationLbEdgeExtensionPatchCall<'a, C> {
3651 ProjectLocationLbEdgeExtensionPatchCall {
3652 hub: self.hub,
3653 _request: request,
3654 _name: name.to_string(),
3655 _update_mask: Default::default(),
3656 _request_id: Default::default(),
3657 _delegate: Default::default(),
3658 _additional_params: Default::default(),
3659 _scopes: Default::default(),
3660 }
3661 }
3662
3663 /// Create a builder to help you perform the following task:
3664 ///
3665 /// Creates a new `LbRouteExtension` resource in a given project and location.
3666 ///
3667 /// # Arguments
3668 ///
3669 /// * `request` - No description provided.
3670 /// * `parent` - Required. The parent resource of the `LbRouteExtension` resource. Must be in the format `projects/{project}/locations/{location}`.
3671 pub fn locations_lb_route_extensions_create(
3672 &self,
3673 request: LbRouteExtension,
3674 parent: &str,
3675 ) -> ProjectLocationLbRouteExtensionCreateCall<'a, C> {
3676 ProjectLocationLbRouteExtensionCreateCall {
3677 hub: self.hub,
3678 _request: request,
3679 _parent: parent.to_string(),
3680 _request_id: Default::default(),
3681 _lb_route_extension_id: Default::default(),
3682 _delegate: Default::default(),
3683 _additional_params: Default::default(),
3684 _scopes: Default::default(),
3685 }
3686 }
3687
3688 /// Create a builder to help you perform the following task:
3689 ///
3690 /// Deletes the specified `LbRouteExtension` resource.
3691 ///
3692 /// # Arguments
3693 ///
3694 /// * `name` - Required. The name of the `LbRouteExtension` resource to delete. Must be in the format `projects/{project}/locations/{location}/lbRouteExtensions/{lb_route_extension}`.
3695 pub fn locations_lb_route_extensions_delete(
3696 &self,
3697 name: &str,
3698 ) -> ProjectLocationLbRouteExtensionDeleteCall<'a, C> {
3699 ProjectLocationLbRouteExtensionDeleteCall {
3700 hub: self.hub,
3701 _name: name.to_string(),
3702 _request_id: Default::default(),
3703 _delegate: Default::default(),
3704 _additional_params: Default::default(),
3705 _scopes: Default::default(),
3706 }
3707 }
3708
3709 /// Create a builder to help you perform the following task:
3710 ///
3711 /// Gets details of the specified `LbRouteExtension` resource.
3712 ///
3713 /// # Arguments
3714 ///
3715 /// * `name` - Required. A name of the `LbRouteExtension` resource to get. Must be in the format `projects/{project}/locations/{location}/lbRouteExtensions/{lb_route_extension}`.
3716 pub fn locations_lb_route_extensions_get(
3717 &self,
3718 name: &str,
3719 ) -> ProjectLocationLbRouteExtensionGetCall<'a, C> {
3720 ProjectLocationLbRouteExtensionGetCall {
3721 hub: self.hub,
3722 _name: name.to_string(),
3723 _delegate: Default::default(),
3724 _additional_params: Default::default(),
3725 _scopes: Default::default(),
3726 }
3727 }
3728
3729 /// Create a builder to help you perform the following task:
3730 ///
3731 /// Lists `LbRouteExtension` resources in a given project and location.
3732 ///
3733 /// # Arguments
3734 ///
3735 /// * `parent` - Required. The project and location from which the `LbRouteExtension` resources are listed. These values are specified in the following format: `projects/{project}/locations/{location}`.
3736 pub fn locations_lb_route_extensions_list(
3737 &self,
3738 parent: &str,
3739 ) -> ProjectLocationLbRouteExtensionListCall<'a, C> {
3740 ProjectLocationLbRouteExtensionListCall {
3741 hub: self.hub,
3742 _parent: parent.to_string(),
3743 _page_token: Default::default(),
3744 _page_size: Default::default(),
3745 _order_by: Default::default(),
3746 _filter: Default::default(),
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 /// Updates the parameters of the specified `LbRouteExtension` resource.
3756 ///
3757 /// # Arguments
3758 ///
3759 /// * `request` - No description provided.
3760 /// * `name` - Required. Identifier. Name of the `LbRouteExtension` resource in the following format: `projects/{project}/locations/{location}/lbRouteExtensions/{lb_route_extension}`.
3761 pub fn locations_lb_route_extensions_patch(
3762 &self,
3763 request: LbRouteExtension,
3764 name: &str,
3765 ) -> ProjectLocationLbRouteExtensionPatchCall<'a, C> {
3766 ProjectLocationLbRouteExtensionPatchCall {
3767 hub: self.hub,
3768 _request: request,
3769 _name: name.to_string(),
3770 _update_mask: Default::default(),
3771 _request_id: Default::default(),
3772 _delegate: Default::default(),
3773 _additional_params: Default::default(),
3774 _scopes: Default::default(),
3775 }
3776 }
3777
3778 /// Create a builder to help you perform the following task:
3779 ///
3780 /// Creates a new `LbTrafficExtension` resource in a given project and location.
3781 ///
3782 /// # Arguments
3783 ///
3784 /// * `request` - No description provided.
3785 /// * `parent` - Required. The parent resource of the `LbTrafficExtension` resource. Must be in the format `projects/{project}/locations/{location}`.
3786 pub fn locations_lb_traffic_extensions_create(
3787 &self,
3788 request: LbTrafficExtension,
3789 parent: &str,
3790 ) -> ProjectLocationLbTrafficExtensionCreateCall<'a, C> {
3791 ProjectLocationLbTrafficExtensionCreateCall {
3792 hub: self.hub,
3793 _request: request,
3794 _parent: parent.to_string(),
3795 _request_id: Default::default(),
3796 _lb_traffic_extension_id: Default::default(),
3797 _delegate: Default::default(),
3798 _additional_params: Default::default(),
3799 _scopes: Default::default(),
3800 }
3801 }
3802
3803 /// Create a builder to help you perform the following task:
3804 ///
3805 /// Deletes the specified `LbTrafficExtension` resource.
3806 ///
3807 /// # Arguments
3808 ///
3809 /// * `name` - Required. The name of the `LbTrafficExtension` resource to delete. Must be in the format `projects/{project}/locations/{location}/lbTrafficExtensions/{lb_traffic_extension}`.
3810 pub fn locations_lb_traffic_extensions_delete(
3811 &self,
3812 name: &str,
3813 ) -> ProjectLocationLbTrafficExtensionDeleteCall<'a, C> {
3814 ProjectLocationLbTrafficExtensionDeleteCall {
3815 hub: self.hub,
3816 _name: name.to_string(),
3817 _request_id: Default::default(),
3818 _delegate: Default::default(),
3819 _additional_params: Default::default(),
3820 _scopes: Default::default(),
3821 }
3822 }
3823
3824 /// Create a builder to help you perform the following task:
3825 ///
3826 /// Gets details of the specified `LbTrafficExtension` resource.
3827 ///
3828 /// # Arguments
3829 ///
3830 /// * `name` - Required. A name of the `LbTrafficExtension` resource to get. Must be in the format `projects/{project}/locations/{location}/lbTrafficExtensions/{lb_traffic_extension}`.
3831 pub fn locations_lb_traffic_extensions_get(
3832 &self,
3833 name: &str,
3834 ) -> ProjectLocationLbTrafficExtensionGetCall<'a, C> {
3835 ProjectLocationLbTrafficExtensionGetCall {
3836 hub: self.hub,
3837 _name: name.to_string(),
3838 _delegate: Default::default(),
3839 _additional_params: Default::default(),
3840 _scopes: Default::default(),
3841 }
3842 }
3843
3844 /// Create a builder to help you perform the following task:
3845 ///
3846 /// Lists `LbTrafficExtension` resources in a given project and location.
3847 ///
3848 /// # Arguments
3849 ///
3850 /// * `parent` - Required. The project and location from which the `LbTrafficExtension` resources are listed. These values are specified in the following format: `projects/{project}/locations/{location}`.
3851 pub fn locations_lb_traffic_extensions_list(
3852 &self,
3853 parent: &str,
3854 ) -> ProjectLocationLbTrafficExtensionListCall<'a, C> {
3855 ProjectLocationLbTrafficExtensionListCall {
3856 hub: self.hub,
3857 _parent: parent.to_string(),
3858 _page_token: Default::default(),
3859 _page_size: Default::default(),
3860 _order_by: Default::default(),
3861 _filter: Default::default(),
3862 _delegate: Default::default(),
3863 _additional_params: Default::default(),
3864 _scopes: Default::default(),
3865 }
3866 }
3867
3868 /// Create a builder to help you perform the following task:
3869 ///
3870 /// Updates the parameters of the specified `LbTrafficExtension` resource.
3871 ///
3872 /// # Arguments
3873 ///
3874 /// * `request` - No description provided.
3875 /// * `name` - Required. Identifier. Name of the `LbTrafficExtension` resource in the following format: `projects/{project}/locations/{location}/lbTrafficExtensions/{lb_traffic_extension}`.
3876 pub fn locations_lb_traffic_extensions_patch(
3877 &self,
3878 request: LbTrafficExtension,
3879 name: &str,
3880 ) -> ProjectLocationLbTrafficExtensionPatchCall<'a, C> {
3881 ProjectLocationLbTrafficExtensionPatchCall {
3882 hub: self.hub,
3883 _request: request,
3884 _name: name.to_string(),
3885 _update_mask: Default::default(),
3886 _request_id: Default::default(),
3887 _delegate: Default::default(),
3888 _additional_params: Default::default(),
3889 _scopes: Default::default(),
3890 }
3891 }
3892
3893 /// Create a builder to help you perform the following task:
3894 ///
3895 /// Get a single RouteView of a Mesh.
3896 ///
3897 /// # Arguments
3898 ///
3899 /// * `name` - Required. Name of the MeshRouteView resource. Format: projects/{project_number}/locations/{location}/meshes/{mesh}/routeViews/{route_view}
3900 pub fn locations_meshes_route_views_get(
3901 &self,
3902 name: &str,
3903 ) -> ProjectLocationMeshRouteViewGetCall<'a, C> {
3904 ProjectLocationMeshRouteViewGetCall {
3905 hub: self.hub,
3906 _name: name.to_string(),
3907 _delegate: Default::default(),
3908 _additional_params: Default::default(),
3909 _scopes: Default::default(),
3910 }
3911 }
3912
3913 /// Create a builder to help you perform the following task:
3914 ///
3915 /// Lists RouteViews
3916 ///
3917 /// # Arguments
3918 ///
3919 /// * `parent` - Required. The Mesh to which a Route is associated. Format: projects/{project_number}/locations/{location}/meshes/{mesh}
3920 pub fn locations_meshes_route_views_list(
3921 &self,
3922 parent: &str,
3923 ) -> ProjectLocationMeshRouteViewListCall<'a, C> {
3924 ProjectLocationMeshRouteViewListCall {
3925 hub: self.hub,
3926 _parent: parent.to_string(),
3927 _page_token: Default::default(),
3928 _page_size: Default::default(),
3929 _delegate: Default::default(),
3930 _additional_params: Default::default(),
3931 _scopes: Default::default(),
3932 }
3933 }
3934
3935 /// Create a builder to help you perform the following task:
3936 ///
3937 /// Creates a new Mesh in a given project and location.
3938 ///
3939 /// # Arguments
3940 ///
3941 /// * `request` - No description provided.
3942 /// * `parent` - Required. The parent resource of the Mesh. Must be in the format `projects/*/locations/*`.
3943 pub fn locations_meshes_create(
3944 &self,
3945 request: Mesh,
3946 parent: &str,
3947 ) -> ProjectLocationMeshCreateCall<'a, C> {
3948 ProjectLocationMeshCreateCall {
3949 hub: self.hub,
3950 _request: request,
3951 _parent: parent.to_string(),
3952 _mesh_id: Default::default(),
3953 _delegate: Default::default(),
3954 _additional_params: Default::default(),
3955 _scopes: Default::default(),
3956 }
3957 }
3958
3959 /// Create a builder to help you perform the following task:
3960 ///
3961 /// Deletes a single Mesh.
3962 ///
3963 /// # Arguments
3964 ///
3965 /// * `name` - Required. A name of the Mesh to delete. Must be in the format `projects/*/locations/*/meshes/*`.
3966 pub fn locations_meshes_delete(&self, name: &str) -> ProjectLocationMeshDeleteCall<'a, C> {
3967 ProjectLocationMeshDeleteCall {
3968 hub: self.hub,
3969 _name: name.to_string(),
3970 _delegate: Default::default(),
3971 _additional_params: Default::default(),
3972 _scopes: Default::default(),
3973 }
3974 }
3975
3976 /// Create a builder to help you perform the following task:
3977 ///
3978 /// Gets details of a single Mesh.
3979 ///
3980 /// # Arguments
3981 ///
3982 /// * `name` - Required. A name of the Mesh to get. Must be in the format `projects/*/locations/*/meshes/*`.
3983 pub fn locations_meshes_get(&self, name: &str) -> ProjectLocationMeshGetCall<'a, C> {
3984 ProjectLocationMeshGetCall {
3985 hub: self.hub,
3986 _name: name.to_string(),
3987 _delegate: Default::default(),
3988 _additional_params: Default::default(),
3989 _scopes: Default::default(),
3990 }
3991 }
3992
3993 /// Create a builder to help you perform the following task:
3994 ///
3995 /// Lists Meshes in a given project and location.
3996 ///
3997 /// # Arguments
3998 ///
3999 /// * `parent` - Required. The project and location from which the Meshes should be listed, specified in the format `projects/*/locations/*`.
4000 pub fn locations_meshes_list(&self, parent: &str) -> ProjectLocationMeshListCall<'a, C> {
4001 ProjectLocationMeshListCall {
4002 hub: self.hub,
4003 _parent: parent.to_string(),
4004 _return_partial_success: Default::default(),
4005 _page_token: Default::default(),
4006 _page_size: Default::default(),
4007 _delegate: Default::default(),
4008 _additional_params: Default::default(),
4009 _scopes: Default::default(),
4010 }
4011 }
4012
4013 /// Create a builder to help you perform the following task:
4014 ///
4015 /// Updates the parameters of a single Mesh.
4016 ///
4017 /// # Arguments
4018 ///
4019 /// * `request` - No description provided.
4020 /// * `name` - Identifier. Name of the Mesh resource. It matches pattern `projects/*/locations/*/meshes/`.
4021 pub fn locations_meshes_patch(
4022 &self,
4023 request: Mesh,
4024 name: &str,
4025 ) -> ProjectLocationMeshPatchCall<'a, C> {
4026 ProjectLocationMeshPatchCall {
4027 hub: self.hub,
4028 _request: request,
4029 _name: name.to_string(),
4030 _update_mask: Default::default(),
4031 _delegate: Default::default(),
4032 _additional_params: Default::default(),
4033 _scopes: Default::default(),
4034 }
4035 }
4036
4037 /// Create a builder to help you perform the following task:
4038 ///
4039 /// 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`.
4040 ///
4041 /// # Arguments
4042 ///
4043 /// * `request` - No description provided.
4044 /// * `name` - The name of the operation resource to be cancelled.
4045 pub fn locations_operations_cancel(
4046 &self,
4047 request: CancelOperationRequest,
4048 name: &str,
4049 ) -> ProjectLocationOperationCancelCall<'a, C> {
4050 ProjectLocationOperationCancelCall {
4051 hub: self.hub,
4052 _request: request,
4053 _name: name.to_string(),
4054 _delegate: Default::default(),
4055 _additional_params: Default::default(),
4056 _scopes: Default::default(),
4057 }
4058 }
4059
4060 /// Create a builder to help you perform the following task:
4061 ///
4062 /// 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`.
4063 ///
4064 /// # Arguments
4065 ///
4066 /// * `name` - The name of the operation resource to be deleted.
4067 pub fn locations_operations_delete(
4068 &self,
4069 name: &str,
4070 ) -> ProjectLocationOperationDeleteCall<'a, C> {
4071 ProjectLocationOperationDeleteCall {
4072 hub: self.hub,
4073 _name: name.to_string(),
4074 _delegate: Default::default(),
4075 _additional_params: Default::default(),
4076 _scopes: Default::default(),
4077 }
4078 }
4079
4080 /// Create a builder to help you perform the following task:
4081 ///
4082 /// 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.
4083 ///
4084 /// # Arguments
4085 ///
4086 /// * `name` - The name of the operation resource.
4087 pub fn locations_operations_get(&self, name: &str) -> ProjectLocationOperationGetCall<'a, C> {
4088 ProjectLocationOperationGetCall {
4089 hub: self.hub,
4090 _name: name.to_string(),
4091 _delegate: Default::default(),
4092 _additional_params: Default::default(),
4093 _scopes: Default::default(),
4094 }
4095 }
4096
4097 /// Create a builder to help you perform the following task:
4098 ///
4099 /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
4100 ///
4101 /// # Arguments
4102 ///
4103 /// * `name` - The name of the operation's parent resource.
4104 pub fn locations_operations_list(&self, name: &str) -> ProjectLocationOperationListCall<'a, C> {
4105 ProjectLocationOperationListCall {
4106 hub: self.hub,
4107 _name: name.to_string(),
4108 _return_partial_success: Default::default(),
4109 _page_token: Default::default(),
4110 _page_size: Default::default(),
4111 _filter: Default::default(),
4112 _delegate: Default::default(),
4113 _additional_params: Default::default(),
4114 _scopes: Default::default(),
4115 }
4116 }
4117
4118 /// Create a builder to help you perform the following task:
4119 ///
4120 /// Creates a new ServiceBinding in a given project and location.
4121 ///
4122 /// # Arguments
4123 ///
4124 /// * `request` - No description provided.
4125 /// * `parent` - Required. The parent resource of the ServiceBinding. Must be in the format `projects/*/locations/*`.
4126 pub fn locations_service_bindings_create(
4127 &self,
4128 request: ServiceBinding,
4129 parent: &str,
4130 ) -> ProjectLocationServiceBindingCreateCall<'a, C> {
4131 ProjectLocationServiceBindingCreateCall {
4132 hub: self.hub,
4133 _request: request,
4134 _parent: parent.to_string(),
4135 _service_binding_id: Default::default(),
4136 _delegate: Default::default(),
4137 _additional_params: Default::default(),
4138 _scopes: Default::default(),
4139 }
4140 }
4141
4142 /// Create a builder to help you perform the following task:
4143 ///
4144 /// Deletes a single ServiceBinding.
4145 ///
4146 /// # Arguments
4147 ///
4148 /// * `name` - Required. A name of the ServiceBinding to delete. Must be in the format `projects/*/locations/*/serviceBindings/*`.
4149 pub fn locations_service_bindings_delete(
4150 &self,
4151 name: &str,
4152 ) -> ProjectLocationServiceBindingDeleteCall<'a, C> {
4153 ProjectLocationServiceBindingDeleteCall {
4154 hub: self.hub,
4155 _name: name.to_string(),
4156 _delegate: Default::default(),
4157 _additional_params: Default::default(),
4158 _scopes: Default::default(),
4159 }
4160 }
4161
4162 /// Create a builder to help you perform the following task:
4163 ///
4164 /// Gets details of a single ServiceBinding.
4165 ///
4166 /// # Arguments
4167 ///
4168 /// * `name` - Required. A name of the ServiceBinding to get. Must be in the format `projects/*/locations/*/serviceBindings/*`.
4169 pub fn locations_service_bindings_get(
4170 &self,
4171 name: &str,
4172 ) -> ProjectLocationServiceBindingGetCall<'a, C> {
4173 ProjectLocationServiceBindingGetCall {
4174 hub: self.hub,
4175 _name: name.to_string(),
4176 _delegate: Default::default(),
4177 _additional_params: Default::default(),
4178 _scopes: Default::default(),
4179 }
4180 }
4181
4182 /// Create a builder to help you perform the following task:
4183 ///
4184 /// Lists ServiceBinding in a given project and location.
4185 ///
4186 /// # Arguments
4187 ///
4188 /// * `parent` - Required. The project and location from which the ServiceBindings should be listed, specified in the format `projects/*/locations/*`.
4189 pub fn locations_service_bindings_list(
4190 &self,
4191 parent: &str,
4192 ) -> ProjectLocationServiceBindingListCall<'a, C> {
4193 ProjectLocationServiceBindingListCall {
4194 hub: self.hub,
4195 _parent: parent.to_string(),
4196 _page_token: Default::default(),
4197 _page_size: Default::default(),
4198 _delegate: Default::default(),
4199 _additional_params: Default::default(),
4200 _scopes: Default::default(),
4201 }
4202 }
4203
4204 /// Create a builder to help you perform the following task:
4205 ///
4206 /// Updates the parameters of a single ServiceBinding.
4207 ///
4208 /// # Arguments
4209 ///
4210 /// * `request` - No description provided.
4211 /// * `name` - Identifier. Name of the ServiceBinding resource. It matches pattern `projects/*/locations/*/serviceBindings/`.
4212 pub fn locations_service_bindings_patch(
4213 &self,
4214 request: ServiceBinding,
4215 name: &str,
4216 ) -> ProjectLocationServiceBindingPatchCall<'a, C> {
4217 ProjectLocationServiceBindingPatchCall {
4218 hub: self.hub,
4219 _request: request,
4220 _name: name.to_string(),
4221 _update_mask: Default::default(),
4222 _delegate: Default::default(),
4223 _additional_params: Default::default(),
4224 _scopes: Default::default(),
4225 }
4226 }
4227
4228 /// Create a builder to help you perform the following task:
4229 ///
4230 /// Creates a new ServiceLbPolicy in a given project and location.
4231 ///
4232 /// # Arguments
4233 ///
4234 /// * `request` - No description provided.
4235 /// * `parent` - Required. The parent resource of the ServiceLbPolicy. Must be in the format `projects/{project}/locations/{location}`.
4236 pub fn locations_service_lb_policies_create(
4237 &self,
4238 request: ServiceLbPolicy,
4239 parent: &str,
4240 ) -> ProjectLocationServiceLbPolicyCreateCall<'a, C> {
4241 ProjectLocationServiceLbPolicyCreateCall {
4242 hub: self.hub,
4243 _request: request,
4244 _parent: parent.to_string(),
4245 _service_lb_policy_id: Default::default(),
4246 _delegate: Default::default(),
4247 _additional_params: Default::default(),
4248 _scopes: Default::default(),
4249 }
4250 }
4251
4252 /// Create a builder to help you perform the following task:
4253 ///
4254 /// Deletes a single ServiceLbPolicy.
4255 ///
4256 /// # Arguments
4257 ///
4258 /// * `name` - Required. A name of the ServiceLbPolicy to delete. Must be in the format `projects/{project}/locations/{location}/serviceLbPolicies/*`.
4259 pub fn locations_service_lb_policies_delete(
4260 &self,
4261 name: &str,
4262 ) -> ProjectLocationServiceLbPolicyDeleteCall<'a, C> {
4263 ProjectLocationServiceLbPolicyDeleteCall {
4264 hub: self.hub,
4265 _name: name.to_string(),
4266 _delegate: Default::default(),
4267 _additional_params: Default::default(),
4268 _scopes: Default::default(),
4269 }
4270 }
4271
4272 /// Create a builder to help you perform the following task:
4273 ///
4274 /// Gets details of a single ServiceLbPolicy.
4275 ///
4276 /// # Arguments
4277 ///
4278 /// * `name` - Required. A name of the ServiceLbPolicy to get. Must be in the format `projects/{project}/locations/{location}/serviceLbPolicies/*`.
4279 pub fn locations_service_lb_policies_get(
4280 &self,
4281 name: &str,
4282 ) -> ProjectLocationServiceLbPolicyGetCall<'a, C> {
4283 ProjectLocationServiceLbPolicyGetCall {
4284 hub: self.hub,
4285 _name: name.to_string(),
4286 _delegate: Default::default(),
4287 _additional_params: Default::default(),
4288 _scopes: Default::default(),
4289 }
4290 }
4291
4292 /// Create a builder to help you perform the following task:
4293 ///
4294 /// Lists ServiceLbPolicies in a given project and location.
4295 ///
4296 /// # Arguments
4297 ///
4298 /// * `parent` - Required. The project and location from which the ServiceLbPolicies should be listed, specified in the format `projects/{project}/locations/{location}`.
4299 pub fn locations_service_lb_policies_list(
4300 &self,
4301 parent: &str,
4302 ) -> ProjectLocationServiceLbPolicyListCall<'a, C> {
4303 ProjectLocationServiceLbPolicyListCall {
4304 hub: self.hub,
4305 _parent: parent.to_string(),
4306 _page_token: Default::default(),
4307 _page_size: Default::default(),
4308 _delegate: Default::default(),
4309 _additional_params: Default::default(),
4310 _scopes: Default::default(),
4311 }
4312 }
4313
4314 /// Create a builder to help you perform the following task:
4315 ///
4316 /// Updates the parameters of a single ServiceLbPolicy.
4317 ///
4318 /// # Arguments
4319 ///
4320 /// * `request` - No description provided.
4321 /// * `name` - Identifier. Name of the ServiceLbPolicy resource. It matches pattern `projects/{project}/locations/{location}/serviceLbPolicies/{service_lb_policy_name}`.
4322 pub fn locations_service_lb_policies_patch(
4323 &self,
4324 request: ServiceLbPolicy,
4325 name: &str,
4326 ) -> ProjectLocationServiceLbPolicyPatchCall<'a, C> {
4327 ProjectLocationServiceLbPolicyPatchCall {
4328 hub: self.hub,
4329 _request: request,
4330 _name: name.to_string(),
4331 _update_mask: Default::default(),
4332 _delegate: Default::default(),
4333 _additional_params: Default::default(),
4334 _scopes: Default::default(),
4335 }
4336 }
4337
4338 /// Create a builder to help you perform the following task:
4339 ///
4340 /// Creates a new TcpRoute in a given project and location.
4341 ///
4342 /// # Arguments
4343 ///
4344 /// * `request` - No description provided.
4345 /// * `parent` - Required. The parent resource of the TcpRoute. Must be in the format `projects/*/locations/*`.
4346 pub fn locations_tcp_routes_create(
4347 &self,
4348 request: TcpRoute,
4349 parent: &str,
4350 ) -> ProjectLocationTcpRouteCreateCall<'a, C> {
4351 ProjectLocationTcpRouteCreateCall {
4352 hub: self.hub,
4353 _request: request,
4354 _parent: parent.to_string(),
4355 _tcp_route_id: Default::default(),
4356 _delegate: Default::default(),
4357 _additional_params: Default::default(),
4358 _scopes: Default::default(),
4359 }
4360 }
4361
4362 /// Create a builder to help you perform the following task:
4363 ///
4364 /// Deletes a single TcpRoute.
4365 ///
4366 /// # Arguments
4367 ///
4368 /// * `name` - Required. A name of the TcpRoute to delete. Must be in the format `projects/*/locations/*/tcpRoutes/*`.
4369 pub fn locations_tcp_routes_delete(
4370 &self,
4371 name: &str,
4372 ) -> ProjectLocationTcpRouteDeleteCall<'a, C> {
4373 ProjectLocationTcpRouteDeleteCall {
4374 hub: self.hub,
4375 _name: name.to_string(),
4376 _delegate: Default::default(),
4377 _additional_params: Default::default(),
4378 _scopes: Default::default(),
4379 }
4380 }
4381
4382 /// Create a builder to help you perform the following task:
4383 ///
4384 /// Gets details of a single TcpRoute.
4385 ///
4386 /// # Arguments
4387 ///
4388 /// * `name` - Required. A name of the TcpRoute to get. Must be in the format `projects/*/locations/*/tcpRoutes/*`.
4389 pub fn locations_tcp_routes_get(&self, name: &str) -> ProjectLocationTcpRouteGetCall<'a, C> {
4390 ProjectLocationTcpRouteGetCall {
4391 hub: self.hub,
4392 _name: name.to_string(),
4393 _delegate: Default::default(),
4394 _additional_params: Default::default(),
4395 _scopes: Default::default(),
4396 }
4397 }
4398
4399 /// Create a builder to help you perform the following task:
4400 ///
4401 /// Lists TcpRoute in a given project and location.
4402 ///
4403 /// # Arguments
4404 ///
4405 /// * `parent` - Required. The project and location from which the TcpRoutes should be listed, specified in the format `projects/*/locations/*`.
4406 pub fn locations_tcp_routes_list(
4407 &self,
4408 parent: &str,
4409 ) -> ProjectLocationTcpRouteListCall<'a, C> {
4410 ProjectLocationTcpRouteListCall {
4411 hub: self.hub,
4412 _parent: parent.to_string(),
4413 _return_partial_success: Default::default(),
4414 _page_token: Default::default(),
4415 _page_size: Default::default(),
4416 _delegate: Default::default(),
4417 _additional_params: Default::default(),
4418 _scopes: Default::default(),
4419 }
4420 }
4421
4422 /// Create a builder to help you perform the following task:
4423 ///
4424 /// Updates the parameters of a single TcpRoute.
4425 ///
4426 /// # Arguments
4427 ///
4428 /// * `request` - No description provided.
4429 /// * `name` - Identifier. Name of the TcpRoute resource. It matches pattern `projects/*/locations/*/tcpRoutes/tcp_route_name>`.
4430 pub fn locations_tcp_routes_patch(
4431 &self,
4432 request: TcpRoute,
4433 name: &str,
4434 ) -> ProjectLocationTcpRoutePatchCall<'a, C> {
4435 ProjectLocationTcpRoutePatchCall {
4436 hub: self.hub,
4437 _request: request,
4438 _name: name.to_string(),
4439 _update_mask: Default::default(),
4440 _delegate: Default::default(),
4441 _additional_params: Default::default(),
4442 _scopes: Default::default(),
4443 }
4444 }
4445
4446 /// Create a builder to help you perform the following task:
4447 ///
4448 /// Creates a new TlsRoute in a given project and location.
4449 ///
4450 /// # Arguments
4451 ///
4452 /// * `request` - No description provided.
4453 /// * `parent` - Required. The parent resource of the TlsRoute. Must be in the format `projects/*/locations/*`.
4454 pub fn locations_tls_routes_create(
4455 &self,
4456 request: TlsRoute,
4457 parent: &str,
4458 ) -> ProjectLocationTlsRouteCreateCall<'a, C> {
4459 ProjectLocationTlsRouteCreateCall {
4460 hub: self.hub,
4461 _request: request,
4462 _parent: parent.to_string(),
4463 _tls_route_id: Default::default(),
4464 _delegate: Default::default(),
4465 _additional_params: Default::default(),
4466 _scopes: Default::default(),
4467 }
4468 }
4469
4470 /// Create a builder to help you perform the following task:
4471 ///
4472 /// Deletes a single TlsRoute.
4473 ///
4474 /// # Arguments
4475 ///
4476 /// * `name` - Required. A name of the TlsRoute to delete. Must be in the format `projects/*/locations/*/tlsRoutes/*`.
4477 pub fn locations_tls_routes_delete(
4478 &self,
4479 name: &str,
4480 ) -> ProjectLocationTlsRouteDeleteCall<'a, C> {
4481 ProjectLocationTlsRouteDeleteCall {
4482 hub: self.hub,
4483 _name: name.to_string(),
4484 _delegate: Default::default(),
4485 _additional_params: Default::default(),
4486 _scopes: Default::default(),
4487 }
4488 }
4489
4490 /// Create a builder to help you perform the following task:
4491 ///
4492 /// Gets details of a single TlsRoute.
4493 ///
4494 /// # Arguments
4495 ///
4496 /// * `name` - Required. A name of the TlsRoute to get. Must be in the format `projects/*/locations/*/tlsRoutes/*`.
4497 pub fn locations_tls_routes_get(&self, name: &str) -> ProjectLocationTlsRouteGetCall<'a, C> {
4498 ProjectLocationTlsRouteGetCall {
4499 hub: self.hub,
4500 _name: name.to_string(),
4501 _delegate: Default::default(),
4502 _additional_params: Default::default(),
4503 _scopes: Default::default(),
4504 }
4505 }
4506
4507 /// Create a builder to help you perform the following task:
4508 ///
4509 /// Lists TlsRoute in a given project and location.
4510 ///
4511 /// # Arguments
4512 ///
4513 /// * `parent` - Required. The project and location from which the TlsRoutes should be listed, specified in the format `projects/*/locations/*`.
4514 pub fn locations_tls_routes_list(
4515 &self,
4516 parent: &str,
4517 ) -> ProjectLocationTlsRouteListCall<'a, C> {
4518 ProjectLocationTlsRouteListCall {
4519 hub: self.hub,
4520 _parent: parent.to_string(),
4521 _return_partial_success: Default::default(),
4522 _page_token: Default::default(),
4523 _page_size: Default::default(),
4524 _delegate: Default::default(),
4525 _additional_params: Default::default(),
4526 _scopes: Default::default(),
4527 }
4528 }
4529
4530 /// Create a builder to help you perform the following task:
4531 ///
4532 /// Updates the parameters of a single TlsRoute.
4533 ///
4534 /// # Arguments
4535 ///
4536 /// * `request` - No description provided.
4537 /// * `name` - Identifier. Name of the TlsRoute resource. It matches pattern `projects/*/locations/*/tlsRoutes/tls_route_name>`.
4538 pub fn locations_tls_routes_patch(
4539 &self,
4540 request: TlsRoute,
4541 name: &str,
4542 ) -> ProjectLocationTlsRoutePatchCall<'a, C> {
4543 ProjectLocationTlsRoutePatchCall {
4544 hub: self.hub,
4545 _request: request,
4546 _name: name.to_string(),
4547 _update_mask: Default::default(),
4548 _delegate: Default::default(),
4549 _additional_params: Default::default(),
4550 _scopes: Default::default(),
4551 }
4552 }
4553
4554 /// Create a builder to help you perform the following task:
4555 ///
4556 /// Creates a new `WasmPluginVersion` resource in a given project and location.
4557 ///
4558 /// # Arguments
4559 ///
4560 /// * `request` - No description provided.
4561 /// * `parent` - Required. The parent resource of the `WasmPluginVersion` resource. Must be in the format `projects/{project}/locations/global/wasmPlugins/{wasm_plugin}`.
4562 pub fn locations_wasm_plugins_versions_create(
4563 &self,
4564 request: WasmPluginVersion,
4565 parent: &str,
4566 ) -> ProjectLocationWasmPluginVersionCreateCall<'a, C> {
4567 ProjectLocationWasmPluginVersionCreateCall {
4568 hub: self.hub,
4569 _request: request,
4570 _parent: parent.to_string(),
4571 _wasm_plugin_version_id: Default::default(),
4572 _delegate: Default::default(),
4573 _additional_params: Default::default(),
4574 _scopes: Default::default(),
4575 }
4576 }
4577
4578 /// Create a builder to help you perform the following task:
4579 ///
4580 /// Deletes the specified `WasmPluginVersion` resource.
4581 ///
4582 /// # Arguments
4583 ///
4584 /// * `name` - Required. A name of the `WasmPluginVersion` resource to delete. Must be in the format `projects/{project}/locations/global/wasmPlugins/{wasm_plugin}/versions/{wasm_plugin_version}`.
4585 pub fn locations_wasm_plugins_versions_delete(
4586 &self,
4587 name: &str,
4588 ) -> ProjectLocationWasmPluginVersionDeleteCall<'a, C> {
4589 ProjectLocationWasmPluginVersionDeleteCall {
4590 hub: self.hub,
4591 _name: name.to_string(),
4592 _delegate: Default::default(),
4593 _additional_params: Default::default(),
4594 _scopes: Default::default(),
4595 }
4596 }
4597
4598 /// Create a builder to help you perform the following task:
4599 ///
4600 /// Gets details of the specified `WasmPluginVersion` resource.
4601 ///
4602 /// # Arguments
4603 ///
4604 /// * `name` - Required. A name of the `WasmPluginVersion` resource to get. Must be in the format `projects/{project}/locations/global/wasmPlugins/{wasm_plugin}/versions/{wasm_plugin_version}`.
4605 pub fn locations_wasm_plugins_versions_get(
4606 &self,
4607 name: &str,
4608 ) -> ProjectLocationWasmPluginVersionGetCall<'a, C> {
4609 ProjectLocationWasmPluginVersionGetCall {
4610 hub: self.hub,
4611 _name: name.to_string(),
4612 _delegate: Default::default(),
4613 _additional_params: Default::default(),
4614 _scopes: Default::default(),
4615 }
4616 }
4617
4618 /// Create a builder to help you perform the following task:
4619 ///
4620 /// Lists `WasmPluginVersion` resources in a given project and location.
4621 ///
4622 /// # Arguments
4623 ///
4624 /// * `parent` - Required. The `WasmPlugin` resource whose `WasmPluginVersion`s are listed, specified in the following format: `projects/{project}/locations/global/wasmPlugins/{wasm_plugin}`.
4625 pub fn locations_wasm_plugins_versions_list(
4626 &self,
4627 parent: &str,
4628 ) -> ProjectLocationWasmPluginVersionListCall<'a, C> {
4629 ProjectLocationWasmPluginVersionListCall {
4630 hub: self.hub,
4631 _parent: parent.to_string(),
4632 _page_token: Default::default(),
4633 _page_size: Default::default(),
4634 _delegate: Default::default(),
4635 _additional_params: Default::default(),
4636 _scopes: Default::default(),
4637 }
4638 }
4639
4640 /// Create a builder to help you perform the following task:
4641 ///
4642 /// Creates a new `WasmPlugin` resource in a given project and location.
4643 ///
4644 /// # Arguments
4645 ///
4646 /// * `request` - No description provided.
4647 /// * `parent` - Required. The parent resource of the `WasmPlugin` resource. Must be in the format `projects/{project}/locations/global`.
4648 pub fn locations_wasm_plugins_create(
4649 &self,
4650 request: WasmPlugin,
4651 parent: &str,
4652 ) -> ProjectLocationWasmPluginCreateCall<'a, C> {
4653 ProjectLocationWasmPluginCreateCall {
4654 hub: self.hub,
4655 _request: request,
4656 _parent: parent.to_string(),
4657 _wasm_plugin_id: Default::default(),
4658 _delegate: Default::default(),
4659 _additional_params: Default::default(),
4660 _scopes: Default::default(),
4661 }
4662 }
4663
4664 /// Create a builder to help you perform the following task:
4665 ///
4666 /// Deletes the specified `WasmPlugin` resource.
4667 ///
4668 /// # Arguments
4669 ///
4670 /// * `name` - Required. A name of the `WasmPlugin` resource to delete. Must be in the format `projects/{project}/locations/global/wasmPlugins/{wasm_plugin}`.
4671 pub fn locations_wasm_plugins_delete(
4672 &self,
4673 name: &str,
4674 ) -> ProjectLocationWasmPluginDeleteCall<'a, C> {
4675 ProjectLocationWasmPluginDeleteCall {
4676 hub: self.hub,
4677 _name: name.to_string(),
4678 _delegate: Default::default(),
4679 _additional_params: Default::default(),
4680 _scopes: Default::default(),
4681 }
4682 }
4683
4684 /// Create a builder to help you perform the following task:
4685 ///
4686 /// Gets details of the specified `WasmPlugin` resource.
4687 ///
4688 /// # Arguments
4689 ///
4690 /// * `name` - Required. A name of the `WasmPlugin` resource to get. Must be in the format `projects/{project}/locations/global/wasmPlugins/{wasm_plugin}`.
4691 pub fn locations_wasm_plugins_get(
4692 &self,
4693 name: &str,
4694 ) -> ProjectLocationWasmPluginGetCall<'a, C> {
4695 ProjectLocationWasmPluginGetCall {
4696 hub: self.hub,
4697 _name: name.to_string(),
4698 _view: Default::default(),
4699 _delegate: Default::default(),
4700 _additional_params: Default::default(),
4701 _scopes: Default::default(),
4702 }
4703 }
4704
4705 /// Create a builder to help you perform the following task:
4706 ///
4707 /// Lists `WasmPlugin` resources in a given project and location.
4708 ///
4709 /// # Arguments
4710 ///
4711 /// * `parent` - Required. The project and location from which the `WasmPlugin` resources are listed, specified in the following format: `projects/{project}/locations/global`.
4712 pub fn locations_wasm_plugins_list(
4713 &self,
4714 parent: &str,
4715 ) -> ProjectLocationWasmPluginListCall<'a, C> {
4716 ProjectLocationWasmPluginListCall {
4717 hub: self.hub,
4718 _parent: parent.to_string(),
4719 _page_token: Default::default(),
4720 _page_size: Default::default(),
4721 _delegate: Default::default(),
4722 _additional_params: Default::default(),
4723 _scopes: Default::default(),
4724 }
4725 }
4726
4727 /// Create a builder to help you perform the following task:
4728 ///
4729 /// Updates the parameters of the specified `WasmPlugin` resource.
4730 ///
4731 /// # Arguments
4732 ///
4733 /// * `request` - No description provided.
4734 /// * `name` - Identifier. Name of the `WasmPlugin` resource in the following format: `projects/{project}/locations/{location}/wasmPlugins/{wasm_plugin}`.
4735 pub fn locations_wasm_plugins_patch(
4736 &self,
4737 request: WasmPlugin,
4738 name: &str,
4739 ) -> ProjectLocationWasmPluginPatchCall<'a, C> {
4740 ProjectLocationWasmPluginPatchCall {
4741 hub: self.hub,
4742 _request: request,
4743 _name: name.to_string(),
4744 _update_mask: Default::default(),
4745 _delegate: Default::default(),
4746 _additional_params: Default::default(),
4747 _scopes: Default::default(),
4748 }
4749 }
4750
4751 /// Create a builder to help you perform the following task:
4752 ///
4753 /// Gets information about a location.
4754 ///
4755 /// # Arguments
4756 ///
4757 /// * `name` - Resource name for the location.
4758 pub fn locations_get(&self, name: &str) -> ProjectLocationGetCall<'a, C> {
4759 ProjectLocationGetCall {
4760 hub: self.hub,
4761 _name: name.to_string(),
4762 _delegate: Default::default(),
4763 _additional_params: Default::default(),
4764 _scopes: Default::default(),
4765 }
4766 }
4767
4768 /// Create a builder to help you perform the following task:
4769 ///
4770 /// Lists information about the supported locations for this service.
4771 ///
4772 /// # Arguments
4773 ///
4774 /// * `name` - The resource that owns the locations collection, if applicable.
4775 pub fn locations_list(&self, name: &str) -> ProjectLocationListCall<'a, C> {
4776 ProjectLocationListCall {
4777 hub: self.hub,
4778 _name: name.to_string(),
4779 _page_token: Default::default(),
4780 _page_size: Default::default(),
4781 _filter: Default::default(),
4782 _extra_location_types: Default::default(),
4783 _delegate: Default::default(),
4784 _additional_params: Default::default(),
4785 _scopes: Default::default(),
4786 }
4787 }
4788}
4789
4790// ###################
4791// CallBuilders ###
4792// #################
4793
4794/// Creates a new `AuthzExtension` resource in a given project and location.
4795///
4796/// A builder for the *locations.authzExtensions.create* method supported by a *project* resource.
4797/// It is not used directly, but through a [`ProjectMethods`] instance.
4798///
4799/// # Example
4800///
4801/// Instantiate a resource method builder
4802///
4803/// ```test_harness,no_run
4804/// # extern crate hyper;
4805/// # extern crate hyper_rustls;
4806/// # extern crate google_networkservices1 as networkservices1;
4807/// use networkservices1::api::AuthzExtension;
4808/// # async fn dox() {
4809/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4810///
4811/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4812/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4813/// # .with_native_roots()
4814/// # .unwrap()
4815/// # .https_only()
4816/// # .enable_http2()
4817/// # .build();
4818///
4819/// # let executor = hyper_util::rt::TokioExecutor::new();
4820/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4821/// # secret,
4822/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4823/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4824/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4825/// # ),
4826/// # ).build().await.unwrap();
4827///
4828/// # let client = hyper_util::client::legacy::Client::builder(
4829/// # hyper_util::rt::TokioExecutor::new()
4830/// # )
4831/// # .build(
4832/// # hyper_rustls::HttpsConnectorBuilder::new()
4833/// # .with_native_roots()
4834/// # .unwrap()
4835/// # .https_or_http()
4836/// # .enable_http2()
4837/// # .build()
4838/// # );
4839/// # let mut hub = NetworkServices::new(client, auth);
4840/// // As the method needs a request, you would usually fill it with the desired information
4841/// // into the respective structure. Some of the parts shown here might not be applicable !
4842/// // Values shown here are possibly random and not representative !
4843/// let mut req = AuthzExtension::default();
4844///
4845/// // You can configure optional parameters by calling the respective setters at will, and
4846/// // execute the final call using `doit()`.
4847/// // Values shown here are possibly random and not representative !
4848/// let result = hub.projects().locations_authz_extensions_create(req, "parent")
4849/// .request_id("amet.")
4850/// .authz_extension_id("duo")
4851/// .doit().await;
4852/// # }
4853/// ```
4854pub struct ProjectLocationAuthzExtensionCreateCall<'a, C>
4855where
4856 C: 'a,
4857{
4858 hub: &'a NetworkServices<C>,
4859 _request: AuthzExtension,
4860 _parent: String,
4861 _request_id: Option<String>,
4862 _authz_extension_id: Option<String>,
4863 _delegate: Option<&'a mut dyn common::Delegate>,
4864 _additional_params: HashMap<String, String>,
4865 _scopes: BTreeSet<String>,
4866}
4867
4868impl<'a, C> common::CallBuilder for ProjectLocationAuthzExtensionCreateCall<'a, C> {}
4869
4870impl<'a, C> ProjectLocationAuthzExtensionCreateCall<'a, C>
4871where
4872 C: common::Connector,
4873{
4874 /// Perform the operation you have build so far.
4875 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
4876 use std::borrow::Cow;
4877 use std::io::{Read, Seek};
4878
4879 use common::{url::Params, ToParts};
4880 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4881
4882 let mut dd = common::DefaultDelegate;
4883 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4884 dlg.begin(common::MethodInfo {
4885 id: "networkservices.projects.locations.authzExtensions.create",
4886 http_method: hyper::Method::POST,
4887 });
4888
4889 for &field in ["alt", "parent", "requestId", "authzExtensionId"].iter() {
4890 if self._additional_params.contains_key(field) {
4891 dlg.finished(false);
4892 return Err(common::Error::FieldClash(field));
4893 }
4894 }
4895
4896 let mut params = Params::with_capacity(6 + self._additional_params.len());
4897 params.push("parent", self._parent);
4898 if let Some(value) = self._request_id.as_ref() {
4899 params.push("requestId", value);
4900 }
4901 if let Some(value) = self._authz_extension_id.as_ref() {
4902 params.push("authzExtensionId", value);
4903 }
4904
4905 params.extend(self._additional_params.iter());
4906
4907 params.push("alt", "json");
4908 let mut url = self.hub._base_url.clone() + "v1/{+parent}/authzExtensions";
4909 if self._scopes.is_empty() {
4910 self._scopes
4911 .insert(Scope::CloudPlatform.as_ref().to_string());
4912 }
4913
4914 #[allow(clippy::single_element_loop)]
4915 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4916 url = params.uri_replacement(url, param_name, find_this, true);
4917 }
4918 {
4919 let to_remove = ["parent"];
4920 params.remove_params(&to_remove);
4921 }
4922
4923 let url = params.parse_with_url(&url);
4924
4925 let mut json_mime_type = mime::APPLICATION_JSON;
4926 let mut request_value_reader = {
4927 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4928 common::remove_json_null_values(&mut value);
4929 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4930 serde_json::to_writer(&mut dst, &value).unwrap();
4931 dst
4932 };
4933 let request_size = request_value_reader
4934 .seek(std::io::SeekFrom::End(0))
4935 .unwrap();
4936 request_value_reader
4937 .seek(std::io::SeekFrom::Start(0))
4938 .unwrap();
4939
4940 loop {
4941 let token = match self
4942 .hub
4943 .auth
4944 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4945 .await
4946 {
4947 Ok(token) => token,
4948 Err(e) => match dlg.token(e) {
4949 Ok(token) => token,
4950 Err(e) => {
4951 dlg.finished(false);
4952 return Err(common::Error::MissingToken(e));
4953 }
4954 },
4955 };
4956 request_value_reader
4957 .seek(std::io::SeekFrom::Start(0))
4958 .unwrap();
4959 let mut req_result = {
4960 let client = &self.hub.client;
4961 dlg.pre_request();
4962 let mut req_builder = hyper::Request::builder()
4963 .method(hyper::Method::POST)
4964 .uri(url.as_str())
4965 .header(USER_AGENT, self.hub._user_agent.clone());
4966
4967 if let Some(token) = token.as_ref() {
4968 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4969 }
4970
4971 let request = req_builder
4972 .header(CONTENT_TYPE, json_mime_type.to_string())
4973 .header(CONTENT_LENGTH, request_size as u64)
4974 .body(common::to_body(
4975 request_value_reader.get_ref().clone().into(),
4976 ));
4977
4978 client.request(request.unwrap()).await
4979 };
4980
4981 match req_result {
4982 Err(err) => {
4983 if let common::Retry::After(d) = dlg.http_error(&err) {
4984 sleep(d).await;
4985 continue;
4986 }
4987 dlg.finished(false);
4988 return Err(common::Error::HttpError(err));
4989 }
4990 Ok(res) => {
4991 let (mut parts, body) = res.into_parts();
4992 let mut body = common::Body::new(body);
4993 if !parts.status.is_success() {
4994 let bytes = common::to_bytes(body).await.unwrap_or_default();
4995 let error = serde_json::from_str(&common::to_string(&bytes));
4996 let response = common::to_response(parts, bytes.into());
4997
4998 if let common::Retry::After(d) =
4999 dlg.http_failure(&response, error.as_ref().ok())
5000 {
5001 sleep(d).await;
5002 continue;
5003 }
5004
5005 dlg.finished(false);
5006
5007 return Err(match error {
5008 Ok(value) => common::Error::BadRequest(value),
5009 _ => common::Error::Failure(response),
5010 });
5011 }
5012 let response = {
5013 let bytes = common::to_bytes(body).await.unwrap_or_default();
5014 let encoded = common::to_string(&bytes);
5015 match serde_json::from_str(&encoded) {
5016 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5017 Err(error) => {
5018 dlg.response_json_decode_error(&encoded, &error);
5019 return Err(common::Error::JsonDecodeError(
5020 encoded.to_string(),
5021 error,
5022 ));
5023 }
5024 }
5025 };
5026
5027 dlg.finished(true);
5028 return Ok(response);
5029 }
5030 }
5031 }
5032 }
5033
5034 ///
5035 /// Sets the *request* property to the given value.
5036 ///
5037 /// Even though the property as already been set when instantiating this call,
5038 /// we provide this method for API completeness.
5039 pub fn request(
5040 mut self,
5041 new_value: AuthzExtension,
5042 ) -> ProjectLocationAuthzExtensionCreateCall<'a, C> {
5043 self._request = new_value;
5044 self
5045 }
5046 /// Required. The parent resource of the `AuthzExtension` resource. Must be in the format `projects/{project}/locations/{location}`.
5047 ///
5048 /// Sets the *parent* path property to the given value.
5049 ///
5050 /// Even though the property as already been set when instantiating this call,
5051 /// we provide this method for API completeness.
5052 pub fn parent(mut self, new_value: &str) -> ProjectLocationAuthzExtensionCreateCall<'a, C> {
5053 self._parent = new_value.to_string();
5054 self
5055 }
5056 /// Optional. An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server can ignore the request if it has already been completed. The server guarantees that for 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 ignores 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).
5057 ///
5058 /// Sets the *request id* query property to the given value.
5059 pub fn request_id(mut self, new_value: &str) -> ProjectLocationAuthzExtensionCreateCall<'a, C> {
5060 self._request_id = Some(new_value.to_string());
5061 self
5062 }
5063 /// Required. User-provided ID of the `AuthzExtension` resource to be created.
5064 ///
5065 /// Sets the *authz extension id* query property to the given value.
5066 pub fn authz_extension_id(
5067 mut self,
5068 new_value: &str,
5069 ) -> ProjectLocationAuthzExtensionCreateCall<'a, C> {
5070 self._authz_extension_id = Some(new_value.to_string());
5071 self
5072 }
5073 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5074 /// while executing the actual API request.
5075 ///
5076 /// ````text
5077 /// It should be used to handle progress information, and to implement a certain level of resilience.
5078 /// ````
5079 ///
5080 /// Sets the *delegate* property to the given value.
5081 pub fn delegate(
5082 mut self,
5083 new_value: &'a mut dyn common::Delegate,
5084 ) -> ProjectLocationAuthzExtensionCreateCall<'a, C> {
5085 self._delegate = Some(new_value);
5086 self
5087 }
5088
5089 /// Set any additional parameter of the query string used in the request.
5090 /// It should be used to set parameters which are not yet available through their own
5091 /// setters.
5092 ///
5093 /// Please note that this method must not be used to set any of the known parameters
5094 /// which have their own setter method. If done anyway, the request will fail.
5095 ///
5096 /// # Additional Parameters
5097 ///
5098 /// * *$.xgafv* (query-string) - V1 error format.
5099 /// * *access_token* (query-string) - OAuth access token.
5100 /// * *alt* (query-string) - Data format for response.
5101 /// * *callback* (query-string) - JSONP
5102 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5103 /// * *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.
5104 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5105 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5106 /// * *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.
5107 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5108 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5109 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationAuthzExtensionCreateCall<'a, C>
5110 where
5111 T: AsRef<str>,
5112 {
5113 self._additional_params
5114 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5115 self
5116 }
5117
5118 /// Identifies the authorization scope for the method you are building.
5119 ///
5120 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5121 /// [`Scope::CloudPlatform`].
5122 ///
5123 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5124 /// tokens for more than one scope.
5125 ///
5126 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5127 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5128 /// sufficient, a read-write scope will do as well.
5129 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationAuthzExtensionCreateCall<'a, C>
5130 where
5131 St: AsRef<str>,
5132 {
5133 self._scopes.insert(String::from(scope.as_ref()));
5134 self
5135 }
5136 /// Identifies the authorization scope(s) for the method you are building.
5137 ///
5138 /// See [`Self::add_scope()`] for details.
5139 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationAuthzExtensionCreateCall<'a, C>
5140 where
5141 I: IntoIterator<Item = St>,
5142 St: AsRef<str>,
5143 {
5144 self._scopes
5145 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5146 self
5147 }
5148
5149 /// Removes all scopes, and no default scope will be used either.
5150 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5151 /// for details).
5152 pub fn clear_scopes(mut self) -> ProjectLocationAuthzExtensionCreateCall<'a, C> {
5153 self._scopes.clear();
5154 self
5155 }
5156}
5157
5158/// Deletes the specified `AuthzExtension` resource.
5159///
5160/// A builder for the *locations.authzExtensions.delete* method supported by a *project* resource.
5161/// It is not used directly, but through a [`ProjectMethods`] instance.
5162///
5163/// # Example
5164///
5165/// Instantiate a resource method builder
5166///
5167/// ```test_harness,no_run
5168/// # extern crate hyper;
5169/// # extern crate hyper_rustls;
5170/// # extern crate google_networkservices1 as networkservices1;
5171/// # async fn dox() {
5172/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5173///
5174/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5175/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5176/// # .with_native_roots()
5177/// # .unwrap()
5178/// # .https_only()
5179/// # .enable_http2()
5180/// # .build();
5181///
5182/// # let executor = hyper_util::rt::TokioExecutor::new();
5183/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5184/// # secret,
5185/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5186/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5187/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5188/// # ),
5189/// # ).build().await.unwrap();
5190///
5191/// # let client = hyper_util::client::legacy::Client::builder(
5192/// # hyper_util::rt::TokioExecutor::new()
5193/// # )
5194/// # .build(
5195/// # hyper_rustls::HttpsConnectorBuilder::new()
5196/// # .with_native_roots()
5197/// # .unwrap()
5198/// # .https_or_http()
5199/// # .enable_http2()
5200/// # .build()
5201/// # );
5202/// # let mut hub = NetworkServices::new(client, auth);
5203/// // You can configure optional parameters by calling the respective setters at will, and
5204/// // execute the final call using `doit()`.
5205/// // Values shown here are possibly random and not representative !
5206/// let result = hub.projects().locations_authz_extensions_delete("name")
5207/// .request_id("gubergren")
5208/// .doit().await;
5209/// # }
5210/// ```
5211pub struct ProjectLocationAuthzExtensionDeleteCall<'a, C>
5212where
5213 C: 'a,
5214{
5215 hub: &'a NetworkServices<C>,
5216 _name: String,
5217 _request_id: Option<String>,
5218 _delegate: Option<&'a mut dyn common::Delegate>,
5219 _additional_params: HashMap<String, String>,
5220 _scopes: BTreeSet<String>,
5221}
5222
5223impl<'a, C> common::CallBuilder for ProjectLocationAuthzExtensionDeleteCall<'a, C> {}
5224
5225impl<'a, C> ProjectLocationAuthzExtensionDeleteCall<'a, C>
5226where
5227 C: common::Connector,
5228{
5229 /// Perform the operation you have build so far.
5230 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
5231 use std::borrow::Cow;
5232 use std::io::{Read, Seek};
5233
5234 use common::{url::Params, ToParts};
5235 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5236
5237 let mut dd = common::DefaultDelegate;
5238 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5239 dlg.begin(common::MethodInfo {
5240 id: "networkservices.projects.locations.authzExtensions.delete",
5241 http_method: hyper::Method::DELETE,
5242 });
5243
5244 for &field in ["alt", "name", "requestId"].iter() {
5245 if self._additional_params.contains_key(field) {
5246 dlg.finished(false);
5247 return Err(common::Error::FieldClash(field));
5248 }
5249 }
5250
5251 let mut params = Params::with_capacity(4 + self._additional_params.len());
5252 params.push("name", self._name);
5253 if let Some(value) = self._request_id.as_ref() {
5254 params.push("requestId", value);
5255 }
5256
5257 params.extend(self._additional_params.iter());
5258
5259 params.push("alt", "json");
5260 let mut url = self.hub._base_url.clone() + "v1/{+name}";
5261 if self._scopes.is_empty() {
5262 self._scopes
5263 .insert(Scope::CloudPlatform.as_ref().to_string());
5264 }
5265
5266 #[allow(clippy::single_element_loop)]
5267 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5268 url = params.uri_replacement(url, param_name, find_this, true);
5269 }
5270 {
5271 let to_remove = ["name"];
5272 params.remove_params(&to_remove);
5273 }
5274
5275 let url = params.parse_with_url(&url);
5276
5277 loop {
5278 let token = match self
5279 .hub
5280 .auth
5281 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5282 .await
5283 {
5284 Ok(token) => token,
5285 Err(e) => match dlg.token(e) {
5286 Ok(token) => token,
5287 Err(e) => {
5288 dlg.finished(false);
5289 return Err(common::Error::MissingToken(e));
5290 }
5291 },
5292 };
5293 let mut req_result = {
5294 let client = &self.hub.client;
5295 dlg.pre_request();
5296 let mut req_builder = hyper::Request::builder()
5297 .method(hyper::Method::DELETE)
5298 .uri(url.as_str())
5299 .header(USER_AGENT, self.hub._user_agent.clone());
5300
5301 if let Some(token) = token.as_ref() {
5302 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5303 }
5304
5305 let request = req_builder
5306 .header(CONTENT_LENGTH, 0_u64)
5307 .body(common::to_body::<String>(None));
5308
5309 client.request(request.unwrap()).await
5310 };
5311
5312 match req_result {
5313 Err(err) => {
5314 if let common::Retry::After(d) = dlg.http_error(&err) {
5315 sleep(d).await;
5316 continue;
5317 }
5318 dlg.finished(false);
5319 return Err(common::Error::HttpError(err));
5320 }
5321 Ok(res) => {
5322 let (mut parts, body) = res.into_parts();
5323 let mut body = common::Body::new(body);
5324 if !parts.status.is_success() {
5325 let bytes = common::to_bytes(body).await.unwrap_or_default();
5326 let error = serde_json::from_str(&common::to_string(&bytes));
5327 let response = common::to_response(parts, bytes.into());
5328
5329 if let common::Retry::After(d) =
5330 dlg.http_failure(&response, error.as_ref().ok())
5331 {
5332 sleep(d).await;
5333 continue;
5334 }
5335
5336 dlg.finished(false);
5337
5338 return Err(match error {
5339 Ok(value) => common::Error::BadRequest(value),
5340 _ => common::Error::Failure(response),
5341 });
5342 }
5343 let response = {
5344 let bytes = common::to_bytes(body).await.unwrap_or_default();
5345 let encoded = common::to_string(&bytes);
5346 match serde_json::from_str(&encoded) {
5347 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5348 Err(error) => {
5349 dlg.response_json_decode_error(&encoded, &error);
5350 return Err(common::Error::JsonDecodeError(
5351 encoded.to_string(),
5352 error,
5353 ));
5354 }
5355 }
5356 };
5357
5358 dlg.finished(true);
5359 return Ok(response);
5360 }
5361 }
5362 }
5363 }
5364
5365 /// Required. The name of the `AuthzExtension` resource to delete. Must be in the format `projects/{project}/locations/{location}/authzExtensions/{authz_extension}`.
5366 ///
5367 /// Sets the *name* path property to the given value.
5368 ///
5369 /// Even though the property as already been set when instantiating this call,
5370 /// we provide this method for API completeness.
5371 pub fn name(mut self, new_value: &str) -> ProjectLocationAuthzExtensionDeleteCall<'a, C> {
5372 self._name = new_value.to_string();
5373 self
5374 }
5375 /// Optional. An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server can ignore the request if it has already been completed. The server guarantees that for 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 ignores 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).
5376 ///
5377 /// Sets the *request id* query property to the given value.
5378 pub fn request_id(mut self, new_value: &str) -> ProjectLocationAuthzExtensionDeleteCall<'a, C> {
5379 self._request_id = Some(new_value.to_string());
5380 self
5381 }
5382 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5383 /// while executing the actual API request.
5384 ///
5385 /// ````text
5386 /// It should be used to handle progress information, and to implement a certain level of resilience.
5387 /// ````
5388 ///
5389 /// Sets the *delegate* property to the given value.
5390 pub fn delegate(
5391 mut self,
5392 new_value: &'a mut dyn common::Delegate,
5393 ) -> ProjectLocationAuthzExtensionDeleteCall<'a, C> {
5394 self._delegate = Some(new_value);
5395 self
5396 }
5397
5398 /// Set any additional parameter of the query string used in the request.
5399 /// It should be used to set parameters which are not yet available through their own
5400 /// setters.
5401 ///
5402 /// Please note that this method must not be used to set any of the known parameters
5403 /// which have their own setter method. If done anyway, the request will fail.
5404 ///
5405 /// # Additional Parameters
5406 ///
5407 /// * *$.xgafv* (query-string) - V1 error format.
5408 /// * *access_token* (query-string) - OAuth access token.
5409 /// * *alt* (query-string) - Data format for response.
5410 /// * *callback* (query-string) - JSONP
5411 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5412 /// * *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.
5413 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5414 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5415 /// * *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.
5416 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5417 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5418 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationAuthzExtensionDeleteCall<'a, C>
5419 where
5420 T: AsRef<str>,
5421 {
5422 self._additional_params
5423 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5424 self
5425 }
5426
5427 /// Identifies the authorization scope for the method you are building.
5428 ///
5429 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5430 /// [`Scope::CloudPlatform`].
5431 ///
5432 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5433 /// tokens for more than one scope.
5434 ///
5435 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5436 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5437 /// sufficient, a read-write scope will do as well.
5438 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationAuthzExtensionDeleteCall<'a, C>
5439 where
5440 St: AsRef<str>,
5441 {
5442 self._scopes.insert(String::from(scope.as_ref()));
5443 self
5444 }
5445 /// Identifies the authorization scope(s) for the method you are building.
5446 ///
5447 /// See [`Self::add_scope()`] for details.
5448 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationAuthzExtensionDeleteCall<'a, C>
5449 where
5450 I: IntoIterator<Item = St>,
5451 St: AsRef<str>,
5452 {
5453 self._scopes
5454 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5455 self
5456 }
5457
5458 /// Removes all scopes, and no default scope will be used either.
5459 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5460 /// for details).
5461 pub fn clear_scopes(mut self) -> ProjectLocationAuthzExtensionDeleteCall<'a, C> {
5462 self._scopes.clear();
5463 self
5464 }
5465}
5466
5467/// Gets details of the specified `AuthzExtension` resource.
5468///
5469/// A builder for the *locations.authzExtensions.get* method supported by a *project* resource.
5470/// It is not used directly, but through a [`ProjectMethods`] instance.
5471///
5472/// # Example
5473///
5474/// Instantiate a resource method builder
5475///
5476/// ```test_harness,no_run
5477/// # extern crate hyper;
5478/// # extern crate hyper_rustls;
5479/// # extern crate google_networkservices1 as networkservices1;
5480/// # async fn dox() {
5481/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5482///
5483/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5484/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5485/// # .with_native_roots()
5486/// # .unwrap()
5487/// # .https_only()
5488/// # .enable_http2()
5489/// # .build();
5490///
5491/// # let executor = hyper_util::rt::TokioExecutor::new();
5492/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5493/// # secret,
5494/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5495/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5496/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5497/// # ),
5498/// # ).build().await.unwrap();
5499///
5500/// # let client = hyper_util::client::legacy::Client::builder(
5501/// # hyper_util::rt::TokioExecutor::new()
5502/// # )
5503/// # .build(
5504/// # hyper_rustls::HttpsConnectorBuilder::new()
5505/// # .with_native_roots()
5506/// # .unwrap()
5507/// # .https_or_http()
5508/// # .enable_http2()
5509/// # .build()
5510/// # );
5511/// # let mut hub = NetworkServices::new(client, auth);
5512/// // You can configure optional parameters by calling the respective setters at will, and
5513/// // execute the final call using `doit()`.
5514/// // Values shown here are possibly random and not representative !
5515/// let result = hub.projects().locations_authz_extensions_get("name")
5516/// .doit().await;
5517/// # }
5518/// ```
5519pub struct ProjectLocationAuthzExtensionGetCall<'a, C>
5520where
5521 C: 'a,
5522{
5523 hub: &'a NetworkServices<C>,
5524 _name: String,
5525 _delegate: Option<&'a mut dyn common::Delegate>,
5526 _additional_params: HashMap<String, String>,
5527 _scopes: BTreeSet<String>,
5528}
5529
5530impl<'a, C> common::CallBuilder for ProjectLocationAuthzExtensionGetCall<'a, C> {}
5531
5532impl<'a, C> ProjectLocationAuthzExtensionGetCall<'a, C>
5533where
5534 C: common::Connector,
5535{
5536 /// Perform the operation you have build so far.
5537 pub async fn doit(mut self) -> common::Result<(common::Response, AuthzExtension)> {
5538 use std::borrow::Cow;
5539 use std::io::{Read, Seek};
5540
5541 use common::{url::Params, ToParts};
5542 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5543
5544 let mut dd = common::DefaultDelegate;
5545 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5546 dlg.begin(common::MethodInfo {
5547 id: "networkservices.projects.locations.authzExtensions.get",
5548 http_method: hyper::Method::GET,
5549 });
5550
5551 for &field in ["alt", "name"].iter() {
5552 if self._additional_params.contains_key(field) {
5553 dlg.finished(false);
5554 return Err(common::Error::FieldClash(field));
5555 }
5556 }
5557
5558 let mut params = Params::with_capacity(3 + self._additional_params.len());
5559 params.push("name", self._name);
5560
5561 params.extend(self._additional_params.iter());
5562
5563 params.push("alt", "json");
5564 let mut url = self.hub._base_url.clone() + "v1/{+name}";
5565 if self._scopes.is_empty() {
5566 self._scopes
5567 .insert(Scope::CloudPlatform.as_ref().to_string());
5568 }
5569
5570 #[allow(clippy::single_element_loop)]
5571 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5572 url = params.uri_replacement(url, param_name, find_this, true);
5573 }
5574 {
5575 let to_remove = ["name"];
5576 params.remove_params(&to_remove);
5577 }
5578
5579 let url = params.parse_with_url(&url);
5580
5581 loop {
5582 let token = match self
5583 .hub
5584 .auth
5585 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5586 .await
5587 {
5588 Ok(token) => token,
5589 Err(e) => match dlg.token(e) {
5590 Ok(token) => token,
5591 Err(e) => {
5592 dlg.finished(false);
5593 return Err(common::Error::MissingToken(e));
5594 }
5595 },
5596 };
5597 let mut req_result = {
5598 let client = &self.hub.client;
5599 dlg.pre_request();
5600 let mut req_builder = hyper::Request::builder()
5601 .method(hyper::Method::GET)
5602 .uri(url.as_str())
5603 .header(USER_AGENT, self.hub._user_agent.clone());
5604
5605 if let Some(token) = token.as_ref() {
5606 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5607 }
5608
5609 let request = req_builder
5610 .header(CONTENT_LENGTH, 0_u64)
5611 .body(common::to_body::<String>(None));
5612
5613 client.request(request.unwrap()).await
5614 };
5615
5616 match req_result {
5617 Err(err) => {
5618 if let common::Retry::After(d) = dlg.http_error(&err) {
5619 sleep(d).await;
5620 continue;
5621 }
5622 dlg.finished(false);
5623 return Err(common::Error::HttpError(err));
5624 }
5625 Ok(res) => {
5626 let (mut parts, body) = res.into_parts();
5627 let mut body = common::Body::new(body);
5628 if !parts.status.is_success() {
5629 let bytes = common::to_bytes(body).await.unwrap_or_default();
5630 let error = serde_json::from_str(&common::to_string(&bytes));
5631 let response = common::to_response(parts, bytes.into());
5632
5633 if let common::Retry::After(d) =
5634 dlg.http_failure(&response, error.as_ref().ok())
5635 {
5636 sleep(d).await;
5637 continue;
5638 }
5639
5640 dlg.finished(false);
5641
5642 return Err(match error {
5643 Ok(value) => common::Error::BadRequest(value),
5644 _ => common::Error::Failure(response),
5645 });
5646 }
5647 let response = {
5648 let bytes = common::to_bytes(body).await.unwrap_or_default();
5649 let encoded = common::to_string(&bytes);
5650 match serde_json::from_str(&encoded) {
5651 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5652 Err(error) => {
5653 dlg.response_json_decode_error(&encoded, &error);
5654 return Err(common::Error::JsonDecodeError(
5655 encoded.to_string(),
5656 error,
5657 ));
5658 }
5659 }
5660 };
5661
5662 dlg.finished(true);
5663 return Ok(response);
5664 }
5665 }
5666 }
5667 }
5668
5669 /// Required. A name of the `AuthzExtension` resource to get. Must be in the format `projects/{project}/locations/{location}/authzExtensions/{authz_extension}`.
5670 ///
5671 /// Sets the *name* path property to the given value.
5672 ///
5673 /// Even though the property as already been set when instantiating this call,
5674 /// we provide this method for API completeness.
5675 pub fn name(mut self, new_value: &str) -> ProjectLocationAuthzExtensionGetCall<'a, C> {
5676 self._name = new_value.to_string();
5677 self
5678 }
5679 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5680 /// while executing the actual API request.
5681 ///
5682 /// ````text
5683 /// It should be used to handle progress information, and to implement a certain level of resilience.
5684 /// ````
5685 ///
5686 /// Sets the *delegate* property to the given value.
5687 pub fn delegate(
5688 mut self,
5689 new_value: &'a mut dyn common::Delegate,
5690 ) -> ProjectLocationAuthzExtensionGetCall<'a, C> {
5691 self._delegate = Some(new_value);
5692 self
5693 }
5694
5695 /// Set any additional parameter of the query string used in the request.
5696 /// It should be used to set parameters which are not yet available through their own
5697 /// setters.
5698 ///
5699 /// Please note that this method must not be used to set any of the known parameters
5700 /// which have their own setter method. If done anyway, the request will fail.
5701 ///
5702 /// # Additional Parameters
5703 ///
5704 /// * *$.xgafv* (query-string) - V1 error format.
5705 /// * *access_token* (query-string) - OAuth access token.
5706 /// * *alt* (query-string) - Data format for response.
5707 /// * *callback* (query-string) - JSONP
5708 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5709 /// * *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.
5710 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5711 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5712 /// * *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.
5713 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5714 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5715 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationAuthzExtensionGetCall<'a, C>
5716 where
5717 T: AsRef<str>,
5718 {
5719 self._additional_params
5720 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5721 self
5722 }
5723
5724 /// Identifies the authorization scope for the method you are building.
5725 ///
5726 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5727 /// [`Scope::CloudPlatform`].
5728 ///
5729 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5730 /// tokens for more than one scope.
5731 ///
5732 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5733 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5734 /// sufficient, a read-write scope will do as well.
5735 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationAuthzExtensionGetCall<'a, C>
5736 where
5737 St: AsRef<str>,
5738 {
5739 self._scopes.insert(String::from(scope.as_ref()));
5740 self
5741 }
5742 /// Identifies the authorization scope(s) for the method you are building.
5743 ///
5744 /// See [`Self::add_scope()`] for details.
5745 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationAuthzExtensionGetCall<'a, C>
5746 where
5747 I: IntoIterator<Item = St>,
5748 St: AsRef<str>,
5749 {
5750 self._scopes
5751 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5752 self
5753 }
5754
5755 /// Removes all scopes, and no default scope will be used either.
5756 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5757 /// for details).
5758 pub fn clear_scopes(mut self) -> ProjectLocationAuthzExtensionGetCall<'a, C> {
5759 self._scopes.clear();
5760 self
5761 }
5762}
5763
5764/// Lists `AuthzExtension` resources in a given project and location.
5765///
5766/// A builder for the *locations.authzExtensions.list* method supported by a *project* resource.
5767/// It is not used directly, but through a [`ProjectMethods`] instance.
5768///
5769/// # Example
5770///
5771/// Instantiate a resource method builder
5772///
5773/// ```test_harness,no_run
5774/// # extern crate hyper;
5775/// # extern crate hyper_rustls;
5776/// # extern crate google_networkservices1 as networkservices1;
5777/// # async fn dox() {
5778/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5779///
5780/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5781/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5782/// # .with_native_roots()
5783/// # .unwrap()
5784/// # .https_only()
5785/// # .enable_http2()
5786/// # .build();
5787///
5788/// # let executor = hyper_util::rt::TokioExecutor::new();
5789/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5790/// # secret,
5791/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5792/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5793/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5794/// # ),
5795/// # ).build().await.unwrap();
5796///
5797/// # let client = hyper_util::client::legacy::Client::builder(
5798/// # hyper_util::rt::TokioExecutor::new()
5799/// # )
5800/// # .build(
5801/// # hyper_rustls::HttpsConnectorBuilder::new()
5802/// # .with_native_roots()
5803/// # .unwrap()
5804/// # .https_or_http()
5805/// # .enable_http2()
5806/// # .build()
5807/// # );
5808/// # let mut hub = NetworkServices::new(client, auth);
5809/// // You can configure optional parameters by calling the respective setters at will, and
5810/// // execute the final call using `doit()`.
5811/// // Values shown here are possibly random and not representative !
5812/// let result = hub.projects().locations_authz_extensions_list("parent")
5813/// .page_token("eos")
5814/// .page_size(-4)
5815/// .order_by("ea")
5816/// .filter("ipsum")
5817/// .doit().await;
5818/// # }
5819/// ```
5820pub struct ProjectLocationAuthzExtensionListCall<'a, C>
5821where
5822 C: 'a,
5823{
5824 hub: &'a NetworkServices<C>,
5825 _parent: String,
5826 _page_token: Option<String>,
5827 _page_size: Option<i32>,
5828 _order_by: Option<String>,
5829 _filter: Option<String>,
5830 _delegate: Option<&'a mut dyn common::Delegate>,
5831 _additional_params: HashMap<String, String>,
5832 _scopes: BTreeSet<String>,
5833}
5834
5835impl<'a, C> common::CallBuilder for ProjectLocationAuthzExtensionListCall<'a, C> {}
5836
5837impl<'a, C> ProjectLocationAuthzExtensionListCall<'a, C>
5838where
5839 C: common::Connector,
5840{
5841 /// Perform the operation you have build so far.
5842 pub async fn doit(mut self) -> common::Result<(common::Response, ListAuthzExtensionsResponse)> {
5843 use std::borrow::Cow;
5844 use std::io::{Read, Seek};
5845
5846 use common::{url::Params, ToParts};
5847 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5848
5849 let mut dd = common::DefaultDelegate;
5850 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5851 dlg.begin(common::MethodInfo {
5852 id: "networkservices.projects.locations.authzExtensions.list",
5853 http_method: hyper::Method::GET,
5854 });
5855
5856 for &field in [
5857 "alt",
5858 "parent",
5859 "pageToken",
5860 "pageSize",
5861 "orderBy",
5862 "filter",
5863 ]
5864 .iter()
5865 {
5866 if self._additional_params.contains_key(field) {
5867 dlg.finished(false);
5868 return Err(common::Error::FieldClash(field));
5869 }
5870 }
5871
5872 let mut params = Params::with_capacity(7 + self._additional_params.len());
5873 params.push("parent", self._parent);
5874 if let Some(value) = self._page_token.as_ref() {
5875 params.push("pageToken", value);
5876 }
5877 if let Some(value) = self._page_size.as_ref() {
5878 params.push("pageSize", value.to_string());
5879 }
5880 if let Some(value) = self._order_by.as_ref() {
5881 params.push("orderBy", value);
5882 }
5883 if let Some(value) = self._filter.as_ref() {
5884 params.push("filter", value);
5885 }
5886
5887 params.extend(self._additional_params.iter());
5888
5889 params.push("alt", "json");
5890 let mut url = self.hub._base_url.clone() + "v1/{+parent}/authzExtensions";
5891 if self._scopes.is_empty() {
5892 self._scopes
5893 .insert(Scope::CloudPlatform.as_ref().to_string());
5894 }
5895
5896 #[allow(clippy::single_element_loop)]
5897 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
5898 url = params.uri_replacement(url, param_name, find_this, true);
5899 }
5900 {
5901 let to_remove = ["parent"];
5902 params.remove_params(&to_remove);
5903 }
5904
5905 let url = params.parse_with_url(&url);
5906
5907 loop {
5908 let token = match self
5909 .hub
5910 .auth
5911 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5912 .await
5913 {
5914 Ok(token) => token,
5915 Err(e) => match dlg.token(e) {
5916 Ok(token) => token,
5917 Err(e) => {
5918 dlg.finished(false);
5919 return Err(common::Error::MissingToken(e));
5920 }
5921 },
5922 };
5923 let mut req_result = {
5924 let client = &self.hub.client;
5925 dlg.pre_request();
5926 let mut req_builder = hyper::Request::builder()
5927 .method(hyper::Method::GET)
5928 .uri(url.as_str())
5929 .header(USER_AGENT, self.hub._user_agent.clone());
5930
5931 if let Some(token) = token.as_ref() {
5932 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5933 }
5934
5935 let request = req_builder
5936 .header(CONTENT_LENGTH, 0_u64)
5937 .body(common::to_body::<String>(None));
5938
5939 client.request(request.unwrap()).await
5940 };
5941
5942 match req_result {
5943 Err(err) => {
5944 if let common::Retry::After(d) = dlg.http_error(&err) {
5945 sleep(d).await;
5946 continue;
5947 }
5948 dlg.finished(false);
5949 return Err(common::Error::HttpError(err));
5950 }
5951 Ok(res) => {
5952 let (mut parts, body) = res.into_parts();
5953 let mut body = common::Body::new(body);
5954 if !parts.status.is_success() {
5955 let bytes = common::to_bytes(body).await.unwrap_or_default();
5956 let error = serde_json::from_str(&common::to_string(&bytes));
5957 let response = common::to_response(parts, bytes.into());
5958
5959 if let common::Retry::After(d) =
5960 dlg.http_failure(&response, error.as_ref().ok())
5961 {
5962 sleep(d).await;
5963 continue;
5964 }
5965
5966 dlg.finished(false);
5967
5968 return Err(match error {
5969 Ok(value) => common::Error::BadRequest(value),
5970 _ => common::Error::Failure(response),
5971 });
5972 }
5973 let response = {
5974 let bytes = common::to_bytes(body).await.unwrap_or_default();
5975 let encoded = common::to_string(&bytes);
5976 match serde_json::from_str(&encoded) {
5977 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5978 Err(error) => {
5979 dlg.response_json_decode_error(&encoded, &error);
5980 return Err(common::Error::JsonDecodeError(
5981 encoded.to_string(),
5982 error,
5983 ));
5984 }
5985 }
5986 };
5987
5988 dlg.finished(true);
5989 return Ok(response);
5990 }
5991 }
5992 }
5993 }
5994
5995 /// Required. The project and location from which the `AuthzExtension` resources are listed. These values are specified in the following format: `projects/{project}/locations/{location}`.
5996 ///
5997 /// Sets the *parent* path property to the given value.
5998 ///
5999 /// Even though the property as already been set when instantiating this call,
6000 /// we provide this method for API completeness.
6001 pub fn parent(mut self, new_value: &str) -> ProjectLocationAuthzExtensionListCall<'a, C> {
6002 self._parent = new_value.to_string();
6003 self
6004 }
6005 /// Optional. A token identifying a page of results that the server returns.
6006 ///
6007 /// Sets the *page token* query property to the given value.
6008 pub fn page_token(mut self, new_value: &str) -> ProjectLocationAuthzExtensionListCall<'a, C> {
6009 self._page_token = Some(new_value.to_string());
6010 self
6011 }
6012 /// Optional. Requested page size. The server might return fewer items than requested. If unspecified, the server picks an appropriate default.
6013 ///
6014 /// Sets the *page size* query property to the given value.
6015 pub fn page_size(mut self, new_value: i32) -> ProjectLocationAuthzExtensionListCall<'a, C> {
6016 self._page_size = Some(new_value);
6017 self
6018 }
6019 /// Optional. Hint about how to order the results.
6020 ///
6021 /// Sets the *order by* query property to the given value.
6022 pub fn order_by(mut self, new_value: &str) -> ProjectLocationAuthzExtensionListCall<'a, C> {
6023 self._order_by = Some(new_value.to_string());
6024 self
6025 }
6026 /// Optional. Filtering results.
6027 ///
6028 /// Sets the *filter* query property to the given value.
6029 pub fn filter(mut self, new_value: &str) -> ProjectLocationAuthzExtensionListCall<'a, C> {
6030 self._filter = Some(new_value.to_string());
6031 self
6032 }
6033 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6034 /// while executing the actual API request.
6035 ///
6036 /// ````text
6037 /// It should be used to handle progress information, and to implement a certain level of resilience.
6038 /// ````
6039 ///
6040 /// Sets the *delegate* property to the given value.
6041 pub fn delegate(
6042 mut self,
6043 new_value: &'a mut dyn common::Delegate,
6044 ) -> ProjectLocationAuthzExtensionListCall<'a, C> {
6045 self._delegate = Some(new_value);
6046 self
6047 }
6048
6049 /// Set any additional parameter of the query string used in the request.
6050 /// It should be used to set parameters which are not yet available through their own
6051 /// setters.
6052 ///
6053 /// Please note that this method must not be used to set any of the known parameters
6054 /// which have their own setter method. If done anyway, the request will fail.
6055 ///
6056 /// # Additional Parameters
6057 ///
6058 /// * *$.xgafv* (query-string) - V1 error format.
6059 /// * *access_token* (query-string) - OAuth access token.
6060 /// * *alt* (query-string) - Data format for response.
6061 /// * *callback* (query-string) - JSONP
6062 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6063 /// * *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.
6064 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6065 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6066 /// * *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.
6067 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6068 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6069 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationAuthzExtensionListCall<'a, C>
6070 where
6071 T: AsRef<str>,
6072 {
6073 self._additional_params
6074 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6075 self
6076 }
6077
6078 /// Identifies the authorization scope for the method you are building.
6079 ///
6080 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6081 /// [`Scope::CloudPlatform`].
6082 ///
6083 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6084 /// tokens for more than one scope.
6085 ///
6086 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6087 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6088 /// sufficient, a read-write scope will do as well.
6089 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationAuthzExtensionListCall<'a, C>
6090 where
6091 St: AsRef<str>,
6092 {
6093 self._scopes.insert(String::from(scope.as_ref()));
6094 self
6095 }
6096 /// Identifies the authorization scope(s) for the method you are building.
6097 ///
6098 /// See [`Self::add_scope()`] for details.
6099 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationAuthzExtensionListCall<'a, C>
6100 where
6101 I: IntoIterator<Item = St>,
6102 St: AsRef<str>,
6103 {
6104 self._scopes
6105 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6106 self
6107 }
6108
6109 /// Removes all scopes, and no default scope will be used either.
6110 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6111 /// for details).
6112 pub fn clear_scopes(mut self) -> ProjectLocationAuthzExtensionListCall<'a, C> {
6113 self._scopes.clear();
6114 self
6115 }
6116}
6117
6118/// Updates the parameters of the specified `AuthzExtension` resource.
6119///
6120/// A builder for the *locations.authzExtensions.patch* method supported by a *project* resource.
6121/// It is not used directly, but through a [`ProjectMethods`] instance.
6122///
6123/// # Example
6124///
6125/// Instantiate a resource method builder
6126///
6127/// ```test_harness,no_run
6128/// # extern crate hyper;
6129/// # extern crate hyper_rustls;
6130/// # extern crate google_networkservices1 as networkservices1;
6131/// use networkservices1::api::AuthzExtension;
6132/// # async fn dox() {
6133/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6134///
6135/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6136/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6137/// # .with_native_roots()
6138/// # .unwrap()
6139/// # .https_only()
6140/// # .enable_http2()
6141/// # .build();
6142///
6143/// # let executor = hyper_util::rt::TokioExecutor::new();
6144/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6145/// # secret,
6146/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6147/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6148/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6149/// # ),
6150/// # ).build().await.unwrap();
6151///
6152/// # let client = hyper_util::client::legacy::Client::builder(
6153/// # hyper_util::rt::TokioExecutor::new()
6154/// # )
6155/// # .build(
6156/// # hyper_rustls::HttpsConnectorBuilder::new()
6157/// # .with_native_roots()
6158/// # .unwrap()
6159/// # .https_or_http()
6160/// # .enable_http2()
6161/// # .build()
6162/// # );
6163/// # let mut hub = NetworkServices::new(client, auth);
6164/// // As the method needs a request, you would usually fill it with the desired information
6165/// // into the respective structure. Some of the parts shown here might not be applicable !
6166/// // Values shown here are possibly random and not representative !
6167/// let mut req = AuthzExtension::default();
6168///
6169/// // You can configure optional parameters by calling the respective setters at will, and
6170/// // execute the final call using `doit()`.
6171/// // Values shown here are possibly random and not representative !
6172/// let result = hub.projects().locations_authz_extensions_patch(req, "name")
6173/// .update_mask(FieldMask::new::<&str>(&[]))
6174/// .request_id("amet")
6175/// .doit().await;
6176/// # }
6177/// ```
6178pub struct ProjectLocationAuthzExtensionPatchCall<'a, C>
6179where
6180 C: 'a,
6181{
6182 hub: &'a NetworkServices<C>,
6183 _request: AuthzExtension,
6184 _name: String,
6185 _update_mask: Option<common::FieldMask>,
6186 _request_id: Option<String>,
6187 _delegate: Option<&'a mut dyn common::Delegate>,
6188 _additional_params: HashMap<String, String>,
6189 _scopes: BTreeSet<String>,
6190}
6191
6192impl<'a, C> common::CallBuilder for ProjectLocationAuthzExtensionPatchCall<'a, C> {}
6193
6194impl<'a, C> ProjectLocationAuthzExtensionPatchCall<'a, C>
6195where
6196 C: common::Connector,
6197{
6198 /// Perform the operation you have build so far.
6199 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
6200 use std::borrow::Cow;
6201 use std::io::{Read, Seek};
6202
6203 use common::{url::Params, ToParts};
6204 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6205
6206 let mut dd = common::DefaultDelegate;
6207 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6208 dlg.begin(common::MethodInfo {
6209 id: "networkservices.projects.locations.authzExtensions.patch",
6210 http_method: hyper::Method::PATCH,
6211 });
6212
6213 for &field in ["alt", "name", "updateMask", "requestId"].iter() {
6214 if self._additional_params.contains_key(field) {
6215 dlg.finished(false);
6216 return Err(common::Error::FieldClash(field));
6217 }
6218 }
6219
6220 let mut params = Params::with_capacity(6 + self._additional_params.len());
6221 params.push("name", self._name);
6222 if let Some(value) = self._update_mask.as_ref() {
6223 params.push("updateMask", value.to_string());
6224 }
6225 if let Some(value) = self._request_id.as_ref() {
6226 params.push("requestId", value);
6227 }
6228
6229 params.extend(self._additional_params.iter());
6230
6231 params.push("alt", "json");
6232 let mut url = self.hub._base_url.clone() + "v1/{+name}";
6233 if self._scopes.is_empty() {
6234 self._scopes
6235 .insert(Scope::CloudPlatform.as_ref().to_string());
6236 }
6237
6238 #[allow(clippy::single_element_loop)]
6239 for &(find_this, param_name) in [("{+name}", "name")].iter() {
6240 url = params.uri_replacement(url, param_name, find_this, true);
6241 }
6242 {
6243 let to_remove = ["name"];
6244 params.remove_params(&to_remove);
6245 }
6246
6247 let url = params.parse_with_url(&url);
6248
6249 let mut json_mime_type = mime::APPLICATION_JSON;
6250 let mut request_value_reader = {
6251 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6252 common::remove_json_null_values(&mut value);
6253 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6254 serde_json::to_writer(&mut dst, &value).unwrap();
6255 dst
6256 };
6257 let request_size = request_value_reader
6258 .seek(std::io::SeekFrom::End(0))
6259 .unwrap();
6260 request_value_reader
6261 .seek(std::io::SeekFrom::Start(0))
6262 .unwrap();
6263
6264 loop {
6265 let token = match self
6266 .hub
6267 .auth
6268 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6269 .await
6270 {
6271 Ok(token) => token,
6272 Err(e) => match dlg.token(e) {
6273 Ok(token) => token,
6274 Err(e) => {
6275 dlg.finished(false);
6276 return Err(common::Error::MissingToken(e));
6277 }
6278 },
6279 };
6280 request_value_reader
6281 .seek(std::io::SeekFrom::Start(0))
6282 .unwrap();
6283 let mut req_result = {
6284 let client = &self.hub.client;
6285 dlg.pre_request();
6286 let mut req_builder = hyper::Request::builder()
6287 .method(hyper::Method::PATCH)
6288 .uri(url.as_str())
6289 .header(USER_AGENT, self.hub._user_agent.clone());
6290
6291 if let Some(token) = token.as_ref() {
6292 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6293 }
6294
6295 let request = req_builder
6296 .header(CONTENT_TYPE, json_mime_type.to_string())
6297 .header(CONTENT_LENGTH, request_size as u64)
6298 .body(common::to_body(
6299 request_value_reader.get_ref().clone().into(),
6300 ));
6301
6302 client.request(request.unwrap()).await
6303 };
6304
6305 match req_result {
6306 Err(err) => {
6307 if let common::Retry::After(d) = dlg.http_error(&err) {
6308 sleep(d).await;
6309 continue;
6310 }
6311 dlg.finished(false);
6312 return Err(common::Error::HttpError(err));
6313 }
6314 Ok(res) => {
6315 let (mut parts, body) = res.into_parts();
6316 let mut body = common::Body::new(body);
6317 if !parts.status.is_success() {
6318 let bytes = common::to_bytes(body).await.unwrap_or_default();
6319 let error = serde_json::from_str(&common::to_string(&bytes));
6320 let response = common::to_response(parts, bytes.into());
6321
6322 if let common::Retry::After(d) =
6323 dlg.http_failure(&response, error.as_ref().ok())
6324 {
6325 sleep(d).await;
6326 continue;
6327 }
6328
6329 dlg.finished(false);
6330
6331 return Err(match error {
6332 Ok(value) => common::Error::BadRequest(value),
6333 _ => common::Error::Failure(response),
6334 });
6335 }
6336 let response = {
6337 let bytes = common::to_bytes(body).await.unwrap_or_default();
6338 let encoded = common::to_string(&bytes);
6339 match serde_json::from_str(&encoded) {
6340 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6341 Err(error) => {
6342 dlg.response_json_decode_error(&encoded, &error);
6343 return Err(common::Error::JsonDecodeError(
6344 encoded.to_string(),
6345 error,
6346 ));
6347 }
6348 }
6349 };
6350
6351 dlg.finished(true);
6352 return Ok(response);
6353 }
6354 }
6355 }
6356 }
6357
6358 ///
6359 /// Sets the *request* property to the given value.
6360 ///
6361 /// Even though the property as already been set when instantiating this call,
6362 /// we provide this method for API completeness.
6363 pub fn request(
6364 mut self,
6365 new_value: AuthzExtension,
6366 ) -> ProjectLocationAuthzExtensionPatchCall<'a, C> {
6367 self._request = new_value;
6368 self
6369 }
6370 /// Required. Identifier. Name of the `AuthzExtension` resource in the following format: `projects/{project}/locations/{location}/authzExtensions/{authz_extension}`.
6371 ///
6372 /// Sets the *name* path property to the given value.
6373 ///
6374 /// Even though the property as already been set when instantiating this call,
6375 /// we provide this method for API completeness.
6376 pub fn name(mut self, new_value: &str) -> ProjectLocationAuthzExtensionPatchCall<'a, C> {
6377 self._name = new_value.to_string();
6378 self
6379 }
6380 /// Required. Used to specify the fields to be overwritten in the `AuthzExtension` resource by the update. The fields specified in the `update_mask` are relative to the resource, not the full request. A field is overwritten if it is in the mask. If the user does not specify a mask, then all fields are overwritten.
6381 ///
6382 /// Sets the *update mask* query property to the given value.
6383 pub fn update_mask(
6384 mut self,
6385 new_value: common::FieldMask,
6386 ) -> ProjectLocationAuthzExtensionPatchCall<'a, C> {
6387 self._update_mask = Some(new_value);
6388 self
6389 }
6390 /// Optional. An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server can ignore the request if it has already been completed. The server guarantees that for 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 ignores 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).
6391 ///
6392 /// Sets the *request id* query property to the given value.
6393 pub fn request_id(mut self, new_value: &str) -> ProjectLocationAuthzExtensionPatchCall<'a, C> {
6394 self._request_id = Some(new_value.to_string());
6395 self
6396 }
6397 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6398 /// while executing the actual API request.
6399 ///
6400 /// ````text
6401 /// It should be used to handle progress information, and to implement a certain level of resilience.
6402 /// ````
6403 ///
6404 /// Sets the *delegate* property to the given value.
6405 pub fn delegate(
6406 mut self,
6407 new_value: &'a mut dyn common::Delegate,
6408 ) -> ProjectLocationAuthzExtensionPatchCall<'a, C> {
6409 self._delegate = Some(new_value);
6410 self
6411 }
6412
6413 /// Set any additional parameter of the query string used in the request.
6414 /// It should be used to set parameters which are not yet available through their own
6415 /// setters.
6416 ///
6417 /// Please note that this method must not be used to set any of the known parameters
6418 /// which have their own setter method. If done anyway, the request will fail.
6419 ///
6420 /// # Additional Parameters
6421 ///
6422 /// * *$.xgafv* (query-string) - V1 error format.
6423 /// * *access_token* (query-string) - OAuth access token.
6424 /// * *alt* (query-string) - Data format for response.
6425 /// * *callback* (query-string) - JSONP
6426 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6427 /// * *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.
6428 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6429 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6430 /// * *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.
6431 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6432 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6433 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationAuthzExtensionPatchCall<'a, C>
6434 where
6435 T: AsRef<str>,
6436 {
6437 self._additional_params
6438 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6439 self
6440 }
6441
6442 /// Identifies the authorization scope for the method you are building.
6443 ///
6444 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6445 /// [`Scope::CloudPlatform`].
6446 ///
6447 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6448 /// tokens for more than one scope.
6449 ///
6450 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6451 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6452 /// sufficient, a read-write scope will do as well.
6453 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationAuthzExtensionPatchCall<'a, C>
6454 where
6455 St: AsRef<str>,
6456 {
6457 self._scopes.insert(String::from(scope.as_ref()));
6458 self
6459 }
6460 /// Identifies the authorization scope(s) for the method you are building.
6461 ///
6462 /// See [`Self::add_scope()`] for details.
6463 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationAuthzExtensionPatchCall<'a, C>
6464 where
6465 I: IntoIterator<Item = St>,
6466 St: AsRef<str>,
6467 {
6468 self._scopes
6469 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6470 self
6471 }
6472
6473 /// Removes all scopes, and no default scope will be used either.
6474 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6475 /// for details).
6476 pub fn clear_scopes(mut self) -> ProjectLocationAuthzExtensionPatchCall<'a, C> {
6477 self._scopes.clear();
6478 self
6479 }
6480}
6481
6482/// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
6483///
6484/// A builder for the *locations.edgeCacheKeysets.getIamPolicy* method supported by a *project* resource.
6485/// It is not used directly, but through a [`ProjectMethods`] instance.
6486///
6487/// # Example
6488///
6489/// Instantiate a resource method builder
6490///
6491/// ```test_harness,no_run
6492/// # extern crate hyper;
6493/// # extern crate hyper_rustls;
6494/// # extern crate google_networkservices1 as networkservices1;
6495/// # async fn dox() {
6496/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6497///
6498/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6499/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6500/// # .with_native_roots()
6501/// # .unwrap()
6502/// # .https_only()
6503/// # .enable_http2()
6504/// # .build();
6505///
6506/// # let executor = hyper_util::rt::TokioExecutor::new();
6507/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6508/// # secret,
6509/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6510/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6511/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6512/// # ),
6513/// # ).build().await.unwrap();
6514///
6515/// # let client = hyper_util::client::legacy::Client::builder(
6516/// # hyper_util::rt::TokioExecutor::new()
6517/// # )
6518/// # .build(
6519/// # hyper_rustls::HttpsConnectorBuilder::new()
6520/// # .with_native_roots()
6521/// # .unwrap()
6522/// # .https_or_http()
6523/// # .enable_http2()
6524/// # .build()
6525/// # );
6526/// # let mut hub = NetworkServices::new(client, auth);
6527/// // You can configure optional parameters by calling the respective setters at will, and
6528/// // execute the final call using `doit()`.
6529/// // Values shown here are possibly random and not representative !
6530/// let result = hub.projects().locations_edge_cache_keysets_get_iam_policy("resource")
6531/// .options_requested_policy_version(-50)
6532/// .doit().await;
6533/// # }
6534/// ```
6535pub struct ProjectLocationEdgeCacheKeysetGetIamPolicyCall<'a, C>
6536where
6537 C: 'a,
6538{
6539 hub: &'a NetworkServices<C>,
6540 _resource: String,
6541 _options_requested_policy_version: Option<i32>,
6542 _delegate: Option<&'a mut dyn common::Delegate>,
6543 _additional_params: HashMap<String, String>,
6544 _scopes: BTreeSet<String>,
6545}
6546
6547impl<'a, C> common::CallBuilder for ProjectLocationEdgeCacheKeysetGetIamPolicyCall<'a, C> {}
6548
6549impl<'a, C> ProjectLocationEdgeCacheKeysetGetIamPolicyCall<'a, C>
6550where
6551 C: common::Connector,
6552{
6553 /// Perform the operation you have build so far.
6554 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
6555 use std::borrow::Cow;
6556 use std::io::{Read, Seek};
6557
6558 use common::{url::Params, ToParts};
6559 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6560
6561 let mut dd = common::DefaultDelegate;
6562 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6563 dlg.begin(common::MethodInfo {
6564 id: "networkservices.projects.locations.edgeCacheKeysets.getIamPolicy",
6565 http_method: hyper::Method::GET,
6566 });
6567
6568 for &field in ["alt", "resource", "options.requestedPolicyVersion"].iter() {
6569 if self._additional_params.contains_key(field) {
6570 dlg.finished(false);
6571 return Err(common::Error::FieldClash(field));
6572 }
6573 }
6574
6575 let mut params = Params::with_capacity(4 + self._additional_params.len());
6576 params.push("resource", self._resource);
6577 if let Some(value) = self._options_requested_policy_version.as_ref() {
6578 params.push("options.requestedPolicyVersion", value.to_string());
6579 }
6580
6581 params.extend(self._additional_params.iter());
6582
6583 params.push("alt", "json");
6584 let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
6585 if self._scopes.is_empty() {
6586 self._scopes
6587 .insert(Scope::CloudPlatform.as_ref().to_string());
6588 }
6589
6590 #[allow(clippy::single_element_loop)]
6591 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
6592 url = params.uri_replacement(url, param_name, find_this, true);
6593 }
6594 {
6595 let to_remove = ["resource"];
6596 params.remove_params(&to_remove);
6597 }
6598
6599 let url = params.parse_with_url(&url);
6600
6601 loop {
6602 let token = match self
6603 .hub
6604 .auth
6605 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6606 .await
6607 {
6608 Ok(token) => token,
6609 Err(e) => match dlg.token(e) {
6610 Ok(token) => token,
6611 Err(e) => {
6612 dlg.finished(false);
6613 return Err(common::Error::MissingToken(e));
6614 }
6615 },
6616 };
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::GET)
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_LENGTH, 0_u64)
6631 .body(common::to_body::<String>(None));
6632
6633 client.request(request.unwrap()).await
6634 };
6635
6636 match req_result {
6637 Err(err) => {
6638 if let common::Retry::After(d) = dlg.http_error(&err) {
6639 sleep(d).await;
6640 continue;
6641 }
6642 dlg.finished(false);
6643 return Err(common::Error::HttpError(err));
6644 }
6645 Ok(res) => {
6646 let (mut parts, body) = res.into_parts();
6647 let mut body = common::Body::new(body);
6648 if !parts.status.is_success() {
6649 let bytes = common::to_bytes(body).await.unwrap_or_default();
6650 let error = serde_json::from_str(&common::to_string(&bytes));
6651 let response = common::to_response(parts, bytes.into());
6652
6653 if let common::Retry::After(d) =
6654 dlg.http_failure(&response, error.as_ref().ok())
6655 {
6656 sleep(d).await;
6657 continue;
6658 }
6659
6660 dlg.finished(false);
6661
6662 return Err(match error {
6663 Ok(value) => common::Error::BadRequest(value),
6664 _ => common::Error::Failure(response),
6665 });
6666 }
6667 let response = {
6668 let bytes = common::to_bytes(body).await.unwrap_or_default();
6669 let encoded = common::to_string(&bytes);
6670 match serde_json::from_str(&encoded) {
6671 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6672 Err(error) => {
6673 dlg.response_json_decode_error(&encoded, &error);
6674 return Err(common::Error::JsonDecodeError(
6675 encoded.to_string(),
6676 error,
6677 ));
6678 }
6679 }
6680 };
6681
6682 dlg.finished(true);
6683 return Ok(response);
6684 }
6685 }
6686 }
6687 }
6688
6689 /// 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.
6690 ///
6691 /// Sets the *resource* path property to the given value.
6692 ///
6693 /// Even though the property as already been set when instantiating this call,
6694 /// we provide this method for API completeness.
6695 pub fn resource(
6696 mut self,
6697 new_value: &str,
6698 ) -> ProjectLocationEdgeCacheKeysetGetIamPolicyCall<'a, C> {
6699 self._resource = new_value.to_string();
6700 self
6701 }
6702 /// 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).
6703 ///
6704 /// Sets the *options.requested policy version* query property to the given value.
6705 pub fn options_requested_policy_version(
6706 mut self,
6707 new_value: i32,
6708 ) -> ProjectLocationEdgeCacheKeysetGetIamPolicyCall<'a, C> {
6709 self._options_requested_policy_version = Some(new_value);
6710 self
6711 }
6712 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6713 /// while executing the actual API request.
6714 ///
6715 /// ````text
6716 /// It should be used to handle progress information, and to implement a certain level of resilience.
6717 /// ````
6718 ///
6719 /// Sets the *delegate* property to the given value.
6720 pub fn delegate(
6721 mut self,
6722 new_value: &'a mut dyn common::Delegate,
6723 ) -> ProjectLocationEdgeCacheKeysetGetIamPolicyCall<'a, C> {
6724 self._delegate = Some(new_value);
6725 self
6726 }
6727
6728 /// Set any additional parameter of the query string used in the request.
6729 /// It should be used to set parameters which are not yet available through their own
6730 /// setters.
6731 ///
6732 /// Please note that this method must not be used to set any of the known parameters
6733 /// which have their own setter method. If done anyway, the request will fail.
6734 ///
6735 /// # Additional Parameters
6736 ///
6737 /// * *$.xgafv* (query-string) - V1 error format.
6738 /// * *access_token* (query-string) - OAuth access token.
6739 /// * *alt* (query-string) - Data format for response.
6740 /// * *callback* (query-string) - JSONP
6741 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6742 /// * *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.
6743 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6744 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6745 /// * *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.
6746 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6747 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6748 pub fn param<T>(
6749 mut self,
6750 name: T,
6751 value: T,
6752 ) -> ProjectLocationEdgeCacheKeysetGetIamPolicyCall<'a, C>
6753 where
6754 T: AsRef<str>,
6755 {
6756 self._additional_params
6757 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6758 self
6759 }
6760
6761 /// Identifies the authorization scope for the method you are building.
6762 ///
6763 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6764 /// [`Scope::CloudPlatform`].
6765 ///
6766 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6767 /// tokens for more than one scope.
6768 ///
6769 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6770 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6771 /// sufficient, a read-write scope will do as well.
6772 pub fn add_scope<St>(
6773 mut self,
6774 scope: St,
6775 ) -> ProjectLocationEdgeCacheKeysetGetIamPolicyCall<'a, C>
6776 where
6777 St: AsRef<str>,
6778 {
6779 self._scopes.insert(String::from(scope.as_ref()));
6780 self
6781 }
6782 /// Identifies the authorization scope(s) for the method you are building.
6783 ///
6784 /// See [`Self::add_scope()`] for details.
6785 pub fn add_scopes<I, St>(
6786 mut self,
6787 scopes: I,
6788 ) -> ProjectLocationEdgeCacheKeysetGetIamPolicyCall<'a, C>
6789 where
6790 I: IntoIterator<Item = St>,
6791 St: AsRef<str>,
6792 {
6793 self._scopes
6794 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6795 self
6796 }
6797
6798 /// Removes all scopes, and no default scope will be used either.
6799 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6800 /// for details).
6801 pub fn clear_scopes(mut self) -> ProjectLocationEdgeCacheKeysetGetIamPolicyCall<'a, C> {
6802 self._scopes.clear();
6803 self
6804 }
6805}
6806
6807/// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
6808///
6809/// A builder for the *locations.edgeCacheKeysets.setIamPolicy* method supported by a *project* resource.
6810/// It is not used directly, but through a [`ProjectMethods`] instance.
6811///
6812/// # Example
6813///
6814/// Instantiate a resource method builder
6815///
6816/// ```test_harness,no_run
6817/// # extern crate hyper;
6818/// # extern crate hyper_rustls;
6819/// # extern crate google_networkservices1 as networkservices1;
6820/// use networkservices1::api::SetIamPolicyRequest;
6821/// # async fn dox() {
6822/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6823///
6824/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6825/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6826/// # .with_native_roots()
6827/// # .unwrap()
6828/// # .https_only()
6829/// # .enable_http2()
6830/// # .build();
6831///
6832/// # let executor = hyper_util::rt::TokioExecutor::new();
6833/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6834/// # secret,
6835/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6836/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6837/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6838/// # ),
6839/// # ).build().await.unwrap();
6840///
6841/// # let client = hyper_util::client::legacy::Client::builder(
6842/// # hyper_util::rt::TokioExecutor::new()
6843/// # )
6844/// # .build(
6845/// # hyper_rustls::HttpsConnectorBuilder::new()
6846/// # .with_native_roots()
6847/// # .unwrap()
6848/// # .https_or_http()
6849/// # .enable_http2()
6850/// # .build()
6851/// # );
6852/// # let mut hub = NetworkServices::new(client, auth);
6853/// // As the method needs a request, you would usually fill it with the desired information
6854/// // into the respective structure. Some of the parts shown here might not be applicable !
6855/// // Values shown here are possibly random and not representative !
6856/// let mut req = SetIamPolicyRequest::default();
6857///
6858/// // You can configure optional parameters by calling the respective setters at will, and
6859/// // execute the final call using `doit()`.
6860/// // Values shown here are possibly random and not representative !
6861/// let result = hub.projects().locations_edge_cache_keysets_set_iam_policy(req, "resource")
6862/// .doit().await;
6863/// # }
6864/// ```
6865pub struct ProjectLocationEdgeCacheKeysetSetIamPolicyCall<'a, C>
6866where
6867 C: 'a,
6868{
6869 hub: &'a NetworkServices<C>,
6870 _request: SetIamPolicyRequest,
6871 _resource: String,
6872 _delegate: Option<&'a mut dyn common::Delegate>,
6873 _additional_params: HashMap<String, String>,
6874 _scopes: BTreeSet<String>,
6875}
6876
6877impl<'a, C> common::CallBuilder for ProjectLocationEdgeCacheKeysetSetIamPolicyCall<'a, C> {}
6878
6879impl<'a, C> ProjectLocationEdgeCacheKeysetSetIamPolicyCall<'a, C>
6880where
6881 C: common::Connector,
6882{
6883 /// Perform the operation you have build so far.
6884 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
6885 use std::borrow::Cow;
6886 use std::io::{Read, Seek};
6887
6888 use common::{url::Params, ToParts};
6889 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6890
6891 let mut dd = common::DefaultDelegate;
6892 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6893 dlg.begin(common::MethodInfo {
6894 id: "networkservices.projects.locations.edgeCacheKeysets.setIamPolicy",
6895 http_method: hyper::Method::POST,
6896 });
6897
6898 for &field in ["alt", "resource"].iter() {
6899 if self._additional_params.contains_key(field) {
6900 dlg.finished(false);
6901 return Err(common::Error::FieldClash(field));
6902 }
6903 }
6904
6905 let mut params = Params::with_capacity(4 + self._additional_params.len());
6906 params.push("resource", self._resource);
6907
6908 params.extend(self._additional_params.iter());
6909
6910 params.push("alt", "json");
6911 let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
6912 if self._scopes.is_empty() {
6913 self._scopes
6914 .insert(Scope::CloudPlatform.as_ref().to_string());
6915 }
6916
6917 #[allow(clippy::single_element_loop)]
6918 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
6919 url = params.uri_replacement(url, param_name, find_this, true);
6920 }
6921 {
6922 let to_remove = ["resource"];
6923 params.remove_params(&to_remove);
6924 }
6925
6926 let url = params.parse_with_url(&url);
6927
6928 let mut json_mime_type = mime::APPLICATION_JSON;
6929 let mut request_value_reader = {
6930 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6931 common::remove_json_null_values(&mut value);
6932 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6933 serde_json::to_writer(&mut dst, &value).unwrap();
6934 dst
6935 };
6936 let request_size = request_value_reader
6937 .seek(std::io::SeekFrom::End(0))
6938 .unwrap();
6939 request_value_reader
6940 .seek(std::io::SeekFrom::Start(0))
6941 .unwrap();
6942
6943 loop {
6944 let token = match self
6945 .hub
6946 .auth
6947 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6948 .await
6949 {
6950 Ok(token) => token,
6951 Err(e) => match dlg.token(e) {
6952 Ok(token) => token,
6953 Err(e) => {
6954 dlg.finished(false);
6955 return Err(common::Error::MissingToken(e));
6956 }
6957 },
6958 };
6959 request_value_reader
6960 .seek(std::io::SeekFrom::Start(0))
6961 .unwrap();
6962 let mut req_result = {
6963 let client = &self.hub.client;
6964 dlg.pre_request();
6965 let mut req_builder = hyper::Request::builder()
6966 .method(hyper::Method::POST)
6967 .uri(url.as_str())
6968 .header(USER_AGENT, self.hub._user_agent.clone());
6969
6970 if let Some(token) = token.as_ref() {
6971 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6972 }
6973
6974 let request = req_builder
6975 .header(CONTENT_TYPE, json_mime_type.to_string())
6976 .header(CONTENT_LENGTH, request_size as u64)
6977 .body(common::to_body(
6978 request_value_reader.get_ref().clone().into(),
6979 ));
6980
6981 client.request(request.unwrap()).await
6982 };
6983
6984 match req_result {
6985 Err(err) => {
6986 if let common::Retry::After(d) = dlg.http_error(&err) {
6987 sleep(d).await;
6988 continue;
6989 }
6990 dlg.finished(false);
6991 return Err(common::Error::HttpError(err));
6992 }
6993 Ok(res) => {
6994 let (mut parts, body) = res.into_parts();
6995 let mut body = common::Body::new(body);
6996 if !parts.status.is_success() {
6997 let bytes = common::to_bytes(body).await.unwrap_or_default();
6998 let error = serde_json::from_str(&common::to_string(&bytes));
6999 let response = common::to_response(parts, bytes.into());
7000
7001 if let common::Retry::After(d) =
7002 dlg.http_failure(&response, error.as_ref().ok())
7003 {
7004 sleep(d).await;
7005 continue;
7006 }
7007
7008 dlg.finished(false);
7009
7010 return Err(match error {
7011 Ok(value) => common::Error::BadRequest(value),
7012 _ => common::Error::Failure(response),
7013 });
7014 }
7015 let response = {
7016 let bytes = common::to_bytes(body).await.unwrap_or_default();
7017 let encoded = common::to_string(&bytes);
7018 match serde_json::from_str(&encoded) {
7019 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7020 Err(error) => {
7021 dlg.response_json_decode_error(&encoded, &error);
7022 return Err(common::Error::JsonDecodeError(
7023 encoded.to_string(),
7024 error,
7025 ));
7026 }
7027 }
7028 };
7029
7030 dlg.finished(true);
7031 return Ok(response);
7032 }
7033 }
7034 }
7035 }
7036
7037 ///
7038 /// Sets the *request* property to the given value.
7039 ///
7040 /// Even though the property as already been set when instantiating this call,
7041 /// we provide this method for API completeness.
7042 pub fn request(
7043 mut self,
7044 new_value: SetIamPolicyRequest,
7045 ) -> ProjectLocationEdgeCacheKeysetSetIamPolicyCall<'a, C> {
7046 self._request = new_value;
7047 self
7048 }
7049 /// 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.
7050 ///
7051 /// Sets the *resource* path property to the given value.
7052 ///
7053 /// Even though the property as already been set when instantiating this call,
7054 /// we provide this method for API completeness.
7055 pub fn resource(
7056 mut self,
7057 new_value: &str,
7058 ) -> ProjectLocationEdgeCacheKeysetSetIamPolicyCall<'a, C> {
7059 self._resource = new_value.to_string();
7060 self
7061 }
7062 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7063 /// while executing the actual API request.
7064 ///
7065 /// ````text
7066 /// It should be used to handle progress information, and to implement a certain level of resilience.
7067 /// ````
7068 ///
7069 /// Sets the *delegate* property to the given value.
7070 pub fn delegate(
7071 mut self,
7072 new_value: &'a mut dyn common::Delegate,
7073 ) -> ProjectLocationEdgeCacheKeysetSetIamPolicyCall<'a, C> {
7074 self._delegate = Some(new_value);
7075 self
7076 }
7077
7078 /// Set any additional parameter of the query string used in the request.
7079 /// It should be used to set parameters which are not yet available through their own
7080 /// setters.
7081 ///
7082 /// Please note that this method must not be used to set any of the known parameters
7083 /// which have their own setter method. If done anyway, the request will fail.
7084 ///
7085 /// # Additional Parameters
7086 ///
7087 /// * *$.xgafv* (query-string) - V1 error format.
7088 /// * *access_token* (query-string) - OAuth access token.
7089 /// * *alt* (query-string) - Data format for response.
7090 /// * *callback* (query-string) - JSONP
7091 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7092 /// * *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.
7093 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7094 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7095 /// * *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.
7096 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7097 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7098 pub fn param<T>(
7099 mut self,
7100 name: T,
7101 value: T,
7102 ) -> ProjectLocationEdgeCacheKeysetSetIamPolicyCall<'a, C>
7103 where
7104 T: AsRef<str>,
7105 {
7106 self._additional_params
7107 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7108 self
7109 }
7110
7111 /// Identifies the authorization scope for the method you are building.
7112 ///
7113 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7114 /// [`Scope::CloudPlatform`].
7115 ///
7116 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7117 /// tokens for more than one scope.
7118 ///
7119 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7120 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7121 /// sufficient, a read-write scope will do as well.
7122 pub fn add_scope<St>(
7123 mut self,
7124 scope: St,
7125 ) -> ProjectLocationEdgeCacheKeysetSetIamPolicyCall<'a, C>
7126 where
7127 St: AsRef<str>,
7128 {
7129 self._scopes.insert(String::from(scope.as_ref()));
7130 self
7131 }
7132 /// Identifies the authorization scope(s) for the method you are building.
7133 ///
7134 /// See [`Self::add_scope()`] for details.
7135 pub fn add_scopes<I, St>(
7136 mut self,
7137 scopes: I,
7138 ) -> ProjectLocationEdgeCacheKeysetSetIamPolicyCall<'a, C>
7139 where
7140 I: IntoIterator<Item = St>,
7141 St: AsRef<str>,
7142 {
7143 self._scopes
7144 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7145 self
7146 }
7147
7148 /// Removes all scopes, and no default scope will be used either.
7149 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7150 /// for details).
7151 pub fn clear_scopes(mut self) -> ProjectLocationEdgeCacheKeysetSetIamPolicyCall<'a, C> {
7152 self._scopes.clear();
7153 self
7154 }
7155}
7156
7157/// 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.
7158///
7159/// A builder for the *locations.edgeCacheKeysets.testIamPermissions* method supported by a *project* resource.
7160/// It is not used directly, but through a [`ProjectMethods`] instance.
7161///
7162/// # Example
7163///
7164/// Instantiate a resource method builder
7165///
7166/// ```test_harness,no_run
7167/// # extern crate hyper;
7168/// # extern crate hyper_rustls;
7169/// # extern crate google_networkservices1 as networkservices1;
7170/// use networkservices1::api::TestIamPermissionsRequest;
7171/// # async fn dox() {
7172/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7173///
7174/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7175/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7176/// # .with_native_roots()
7177/// # .unwrap()
7178/// # .https_only()
7179/// # .enable_http2()
7180/// # .build();
7181///
7182/// # let executor = hyper_util::rt::TokioExecutor::new();
7183/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7184/// # secret,
7185/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7186/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7187/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7188/// # ),
7189/// # ).build().await.unwrap();
7190///
7191/// # let client = hyper_util::client::legacy::Client::builder(
7192/// # hyper_util::rt::TokioExecutor::new()
7193/// # )
7194/// # .build(
7195/// # hyper_rustls::HttpsConnectorBuilder::new()
7196/// # .with_native_roots()
7197/// # .unwrap()
7198/// # .https_or_http()
7199/// # .enable_http2()
7200/// # .build()
7201/// # );
7202/// # let mut hub = NetworkServices::new(client, auth);
7203/// // As the method needs a request, you would usually fill it with the desired information
7204/// // into the respective structure. Some of the parts shown here might not be applicable !
7205/// // Values shown here are possibly random and not representative !
7206/// let mut req = TestIamPermissionsRequest::default();
7207///
7208/// // You can configure optional parameters by calling the respective setters at will, and
7209/// // execute the final call using `doit()`.
7210/// // Values shown here are possibly random and not representative !
7211/// let result = hub.projects().locations_edge_cache_keysets_test_iam_permissions(req, "resource")
7212/// .doit().await;
7213/// # }
7214/// ```
7215pub struct ProjectLocationEdgeCacheKeysetTestIamPermissionCall<'a, C>
7216where
7217 C: 'a,
7218{
7219 hub: &'a NetworkServices<C>,
7220 _request: TestIamPermissionsRequest,
7221 _resource: String,
7222 _delegate: Option<&'a mut dyn common::Delegate>,
7223 _additional_params: HashMap<String, String>,
7224 _scopes: BTreeSet<String>,
7225}
7226
7227impl<'a, C> common::CallBuilder for ProjectLocationEdgeCacheKeysetTestIamPermissionCall<'a, C> {}
7228
7229impl<'a, C> ProjectLocationEdgeCacheKeysetTestIamPermissionCall<'a, C>
7230where
7231 C: common::Connector,
7232{
7233 /// Perform the operation you have build so far.
7234 pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
7235 use std::borrow::Cow;
7236 use std::io::{Read, Seek};
7237
7238 use common::{url::Params, ToParts};
7239 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7240
7241 let mut dd = common::DefaultDelegate;
7242 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7243 dlg.begin(common::MethodInfo {
7244 id: "networkservices.projects.locations.edgeCacheKeysets.testIamPermissions",
7245 http_method: hyper::Method::POST,
7246 });
7247
7248 for &field in ["alt", "resource"].iter() {
7249 if self._additional_params.contains_key(field) {
7250 dlg.finished(false);
7251 return Err(common::Error::FieldClash(field));
7252 }
7253 }
7254
7255 let mut params = Params::with_capacity(4 + self._additional_params.len());
7256 params.push("resource", self._resource);
7257
7258 params.extend(self._additional_params.iter());
7259
7260 params.push("alt", "json");
7261 let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
7262 if self._scopes.is_empty() {
7263 self._scopes
7264 .insert(Scope::CloudPlatform.as_ref().to_string());
7265 }
7266
7267 #[allow(clippy::single_element_loop)]
7268 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
7269 url = params.uri_replacement(url, param_name, find_this, true);
7270 }
7271 {
7272 let to_remove = ["resource"];
7273 params.remove_params(&to_remove);
7274 }
7275
7276 let url = params.parse_with_url(&url);
7277
7278 let mut json_mime_type = mime::APPLICATION_JSON;
7279 let mut request_value_reader = {
7280 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7281 common::remove_json_null_values(&mut value);
7282 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7283 serde_json::to_writer(&mut dst, &value).unwrap();
7284 dst
7285 };
7286 let request_size = request_value_reader
7287 .seek(std::io::SeekFrom::End(0))
7288 .unwrap();
7289 request_value_reader
7290 .seek(std::io::SeekFrom::Start(0))
7291 .unwrap();
7292
7293 loop {
7294 let token = match self
7295 .hub
7296 .auth
7297 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7298 .await
7299 {
7300 Ok(token) => token,
7301 Err(e) => match dlg.token(e) {
7302 Ok(token) => token,
7303 Err(e) => {
7304 dlg.finished(false);
7305 return Err(common::Error::MissingToken(e));
7306 }
7307 },
7308 };
7309 request_value_reader
7310 .seek(std::io::SeekFrom::Start(0))
7311 .unwrap();
7312 let mut req_result = {
7313 let client = &self.hub.client;
7314 dlg.pre_request();
7315 let mut req_builder = hyper::Request::builder()
7316 .method(hyper::Method::POST)
7317 .uri(url.as_str())
7318 .header(USER_AGENT, self.hub._user_agent.clone());
7319
7320 if let Some(token) = token.as_ref() {
7321 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7322 }
7323
7324 let request = req_builder
7325 .header(CONTENT_TYPE, json_mime_type.to_string())
7326 .header(CONTENT_LENGTH, request_size as u64)
7327 .body(common::to_body(
7328 request_value_reader.get_ref().clone().into(),
7329 ));
7330
7331 client.request(request.unwrap()).await
7332 };
7333
7334 match req_result {
7335 Err(err) => {
7336 if let common::Retry::After(d) = dlg.http_error(&err) {
7337 sleep(d).await;
7338 continue;
7339 }
7340 dlg.finished(false);
7341 return Err(common::Error::HttpError(err));
7342 }
7343 Ok(res) => {
7344 let (mut parts, body) = res.into_parts();
7345 let mut body = common::Body::new(body);
7346 if !parts.status.is_success() {
7347 let bytes = common::to_bytes(body).await.unwrap_or_default();
7348 let error = serde_json::from_str(&common::to_string(&bytes));
7349 let response = common::to_response(parts, bytes.into());
7350
7351 if let common::Retry::After(d) =
7352 dlg.http_failure(&response, error.as_ref().ok())
7353 {
7354 sleep(d).await;
7355 continue;
7356 }
7357
7358 dlg.finished(false);
7359
7360 return Err(match error {
7361 Ok(value) => common::Error::BadRequest(value),
7362 _ => common::Error::Failure(response),
7363 });
7364 }
7365 let response = {
7366 let bytes = common::to_bytes(body).await.unwrap_or_default();
7367 let encoded = common::to_string(&bytes);
7368 match serde_json::from_str(&encoded) {
7369 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7370 Err(error) => {
7371 dlg.response_json_decode_error(&encoded, &error);
7372 return Err(common::Error::JsonDecodeError(
7373 encoded.to_string(),
7374 error,
7375 ));
7376 }
7377 }
7378 };
7379
7380 dlg.finished(true);
7381 return Ok(response);
7382 }
7383 }
7384 }
7385 }
7386
7387 ///
7388 /// Sets the *request* property to the given value.
7389 ///
7390 /// Even though the property as already been set when instantiating this call,
7391 /// we provide this method for API completeness.
7392 pub fn request(
7393 mut self,
7394 new_value: TestIamPermissionsRequest,
7395 ) -> ProjectLocationEdgeCacheKeysetTestIamPermissionCall<'a, C> {
7396 self._request = new_value;
7397 self
7398 }
7399 /// 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.
7400 ///
7401 /// Sets the *resource* path property to the given value.
7402 ///
7403 /// Even though the property as already been set when instantiating this call,
7404 /// we provide this method for API completeness.
7405 pub fn resource(
7406 mut self,
7407 new_value: &str,
7408 ) -> ProjectLocationEdgeCacheKeysetTestIamPermissionCall<'a, C> {
7409 self._resource = new_value.to_string();
7410 self
7411 }
7412 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7413 /// while executing the actual API request.
7414 ///
7415 /// ````text
7416 /// It should be used to handle progress information, and to implement a certain level of resilience.
7417 /// ````
7418 ///
7419 /// Sets the *delegate* property to the given value.
7420 pub fn delegate(
7421 mut self,
7422 new_value: &'a mut dyn common::Delegate,
7423 ) -> ProjectLocationEdgeCacheKeysetTestIamPermissionCall<'a, C> {
7424 self._delegate = Some(new_value);
7425 self
7426 }
7427
7428 /// Set any additional parameter of the query string used in the request.
7429 /// It should be used to set parameters which are not yet available through their own
7430 /// setters.
7431 ///
7432 /// Please note that this method must not be used to set any of the known parameters
7433 /// which have their own setter method. If done anyway, the request will fail.
7434 ///
7435 /// # Additional Parameters
7436 ///
7437 /// * *$.xgafv* (query-string) - V1 error format.
7438 /// * *access_token* (query-string) - OAuth access token.
7439 /// * *alt* (query-string) - Data format for response.
7440 /// * *callback* (query-string) - JSONP
7441 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7442 /// * *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.
7443 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7444 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7445 /// * *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.
7446 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7447 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7448 pub fn param<T>(
7449 mut self,
7450 name: T,
7451 value: T,
7452 ) -> ProjectLocationEdgeCacheKeysetTestIamPermissionCall<'a, C>
7453 where
7454 T: AsRef<str>,
7455 {
7456 self._additional_params
7457 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7458 self
7459 }
7460
7461 /// Identifies the authorization scope for the method you are building.
7462 ///
7463 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7464 /// [`Scope::CloudPlatform`].
7465 ///
7466 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7467 /// tokens for more than one scope.
7468 ///
7469 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7470 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7471 /// sufficient, a read-write scope will do as well.
7472 pub fn add_scope<St>(
7473 mut self,
7474 scope: St,
7475 ) -> ProjectLocationEdgeCacheKeysetTestIamPermissionCall<'a, C>
7476 where
7477 St: AsRef<str>,
7478 {
7479 self._scopes.insert(String::from(scope.as_ref()));
7480 self
7481 }
7482 /// Identifies the authorization scope(s) for the method you are building.
7483 ///
7484 /// See [`Self::add_scope()`] for details.
7485 pub fn add_scopes<I, St>(
7486 mut self,
7487 scopes: I,
7488 ) -> ProjectLocationEdgeCacheKeysetTestIamPermissionCall<'a, C>
7489 where
7490 I: IntoIterator<Item = St>,
7491 St: AsRef<str>,
7492 {
7493 self._scopes
7494 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7495 self
7496 }
7497
7498 /// Removes all scopes, and no default scope will be used either.
7499 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7500 /// for details).
7501 pub fn clear_scopes(mut self) -> ProjectLocationEdgeCacheKeysetTestIamPermissionCall<'a, C> {
7502 self._scopes.clear();
7503 self
7504 }
7505}
7506
7507/// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
7508///
7509/// A builder for the *locations.edgeCacheOrigins.getIamPolicy* method supported by a *project* resource.
7510/// It is not used directly, but through a [`ProjectMethods`] instance.
7511///
7512/// # Example
7513///
7514/// Instantiate a resource method builder
7515///
7516/// ```test_harness,no_run
7517/// # extern crate hyper;
7518/// # extern crate hyper_rustls;
7519/// # extern crate google_networkservices1 as networkservices1;
7520/// # async fn dox() {
7521/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7522///
7523/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7524/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7525/// # .with_native_roots()
7526/// # .unwrap()
7527/// # .https_only()
7528/// # .enable_http2()
7529/// # .build();
7530///
7531/// # let executor = hyper_util::rt::TokioExecutor::new();
7532/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7533/// # secret,
7534/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7535/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7536/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7537/// # ),
7538/// # ).build().await.unwrap();
7539///
7540/// # let client = hyper_util::client::legacy::Client::builder(
7541/// # hyper_util::rt::TokioExecutor::new()
7542/// # )
7543/// # .build(
7544/// # hyper_rustls::HttpsConnectorBuilder::new()
7545/// # .with_native_roots()
7546/// # .unwrap()
7547/// # .https_or_http()
7548/// # .enable_http2()
7549/// # .build()
7550/// # );
7551/// # let mut hub = NetworkServices::new(client, auth);
7552/// // You can configure optional parameters by calling the respective setters at will, and
7553/// // execute the final call using `doit()`.
7554/// // Values shown here are possibly random and not representative !
7555/// let result = hub.projects().locations_edge_cache_origins_get_iam_policy("resource")
7556/// .options_requested_policy_version(-16)
7557/// .doit().await;
7558/// # }
7559/// ```
7560pub struct ProjectLocationEdgeCacheOriginGetIamPolicyCall<'a, C>
7561where
7562 C: 'a,
7563{
7564 hub: &'a NetworkServices<C>,
7565 _resource: String,
7566 _options_requested_policy_version: Option<i32>,
7567 _delegate: Option<&'a mut dyn common::Delegate>,
7568 _additional_params: HashMap<String, String>,
7569 _scopes: BTreeSet<String>,
7570}
7571
7572impl<'a, C> common::CallBuilder for ProjectLocationEdgeCacheOriginGetIamPolicyCall<'a, C> {}
7573
7574impl<'a, C> ProjectLocationEdgeCacheOriginGetIamPolicyCall<'a, C>
7575where
7576 C: common::Connector,
7577{
7578 /// Perform the operation you have build so far.
7579 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
7580 use std::borrow::Cow;
7581 use std::io::{Read, Seek};
7582
7583 use common::{url::Params, ToParts};
7584 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7585
7586 let mut dd = common::DefaultDelegate;
7587 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7588 dlg.begin(common::MethodInfo {
7589 id: "networkservices.projects.locations.edgeCacheOrigins.getIamPolicy",
7590 http_method: hyper::Method::GET,
7591 });
7592
7593 for &field in ["alt", "resource", "options.requestedPolicyVersion"].iter() {
7594 if self._additional_params.contains_key(field) {
7595 dlg.finished(false);
7596 return Err(common::Error::FieldClash(field));
7597 }
7598 }
7599
7600 let mut params = Params::with_capacity(4 + self._additional_params.len());
7601 params.push("resource", self._resource);
7602 if let Some(value) = self._options_requested_policy_version.as_ref() {
7603 params.push("options.requestedPolicyVersion", value.to_string());
7604 }
7605
7606 params.extend(self._additional_params.iter());
7607
7608 params.push("alt", "json");
7609 let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
7610 if self._scopes.is_empty() {
7611 self._scopes
7612 .insert(Scope::CloudPlatform.as_ref().to_string());
7613 }
7614
7615 #[allow(clippy::single_element_loop)]
7616 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
7617 url = params.uri_replacement(url, param_name, find_this, true);
7618 }
7619 {
7620 let to_remove = ["resource"];
7621 params.remove_params(&to_remove);
7622 }
7623
7624 let url = params.parse_with_url(&url);
7625
7626 loop {
7627 let token = match self
7628 .hub
7629 .auth
7630 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7631 .await
7632 {
7633 Ok(token) => token,
7634 Err(e) => match dlg.token(e) {
7635 Ok(token) => token,
7636 Err(e) => {
7637 dlg.finished(false);
7638 return Err(common::Error::MissingToken(e));
7639 }
7640 },
7641 };
7642 let mut req_result = {
7643 let client = &self.hub.client;
7644 dlg.pre_request();
7645 let mut req_builder = hyper::Request::builder()
7646 .method(hyper::Method::GET)
7647 .uri(url.as_str())
7648 .header(USER_AGENT, self.hub._user_agent.clone());
7649
7650 if let Some(token) = token.as_ref() {
7651 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7652 }
7653
7654 let request = req_builder
7655 .header(CONTENT_LENGTH, 0_u64)
7656 .body(common::to_body::<String>(None));
7657
7658 client.request(request.unwrap()).await
7659 };
7660
7661 match req_result {
7662 Err(err) => {
7663 if let common::Retry::After(d) = dlg.http_error(&err) {
7664 sleep(d).await;
7665 continue;
7666 }
7667 dlg.finished(false);
7668 return Err(common::Error::HttpError(err));
7669 }
7670 Ok(res) => {
7671 let (mut parts, body) = res.into_parts();
7672 let mut body = common::Body::new(body);
7673 if !parts.status.is_success() {
7674 let bytes = common::to_bytes(body).await.unwrap_or_default();
7675 let error = serde_json::from_str(&common::to_string(&bytes));
7676 let response = common::to_response(parts, bytes.into());
7677
7678 if let common::Retry::After(d) =
7679 dlg.http_failure(&response, error.as_ref().ok())
7680 {
7681 sleep(d).await;
7682 continue;
7683 }
7684
7685 dlg.finished(false);
7686
7687 return Err(match error {
7688 Ok(value) => common::Error::BadRequest(value),
7689 _ => common::Error::Failure(response),
7690 });
7691 }
7692 let response = {
7693 let bytes = common::to_bytes(body).await.unwrap_or_default();
7694 let encoded = common::to_string(&bytes);
7695 match serde_json::from_str(&encoded) {
7696 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7697 Err(error) => {
7698 dlg.response_json_decode_error(&encoded, &error);
7699 return Err(common::Error::JsonDecodeError(
7700 encoded.to_string(),
7701 error,
7702 ));
7703 }
7704 }
7705 };
7706
7707 dlg.finished(true);
7708 return Ok(response);
7709 }
7710 }
7711 }
7712 }
7713
7714 /// 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.
7715 ///
7716 /// Sets the *resource* path property to the given value.
7717 ///
7718 /// Even though the property as already been set when instantiating this call,
7719 /// we provide this method for API completeness.
7720 pub fn resource(
7721 mut self,
7722 new_value: &str,
7723 ) -> ProjectLocationEdgeCacheOriginGetIamPolicyCall<'a, C> {
7724 self._resource = new_value.to_string();
7725 self
7726 }
7727 /// 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).
7728 ///
7729 /// Sets the *options.requested policy version* query property to the given value.
7730 pub fn options_requested_policy_version(
7731 mut self,
7732 new_value: i32,
7733 ) -> ProjectLocationEdgeCacheOriginGetIamPolicyCall<'a, C> {
7734 self._options_requested_policy_version = Some(new_value);
7735 self
7736 }
7737 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7738 /// while executing the actual API request.
7739 ///
7740 /// ````text
7741 /// It should be used to handle progress information, and to implement a certain level of resilience.
7742 /// ````
7743 ///
7744 /// Sets the *delegate* property to the given value.
7745 pub fn delegate(
7746 mut self,
7747 new_value: &'a mut dyn common::Delegate,
7748 ) -> ProjectLocationEdgeCacheOriginGetIamPolicyCall<'a, C> {
7749 self._delegate = Some(new_value);
7750 self
7751 }
7752
7753 /// Set any additional parameter of the query string used in the request.
7754 /// It should be used to set parameters which are not yet available through their own
7755 /// setters.
7756 ///
7757 /// Please note that this method must not be used to set any of the known parameters
7758 /// which have their own setter method. If done anyway, the request will fail.
7759 ///
7760 /// # Additional Parameters
7761 ///
7762 /// * *$.xgafv* (query-string) - V1 error format.
7763 /// * *access_token* (query-string) - OAuth access token.
7764 /// * *alt* (query-string) - Data format for response.
7765 /// * *callback* (query-string) - JSONP
7766 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7767 /// * *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.
7768 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7769 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7770 /// * *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.
7771 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7772 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7773 pub fn param<T>(
7774 mut self,
7775 name: T,
7776 value: T,
7777 ) -> ProjectLocationEdgeCacheOriginGetIamPolicyCall<'a, C>
7778 where
7779 T: AsRef<str>,
7780 {
7781 self._additional_params
7782 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7783 self
7784 }
7785
7786 /// Identifies the authorization scope for the method you are building.
7787 ///
7788 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7789 /// [`Scope::CloudPlatform`].
7790 ///
7791 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7792 /// tokens for more than one scope.
7793 ///
7794 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7795 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7796 /// sufficient, a read-write scope will do as well.
7797 pub fn add_scope<St>(
7798 mut self,
7799 scope: St,
7800 ) -> ProjectLocationEdgeCacheOriginGetIamPolicyCall<'a, C>
7801 where
7802 St: AsRef<str>,
7803 {
7804 self._scopes.insert(String::from(scope.as_ref()));
7805 self
7806 }
7807 /// Identifies the authorization scope(s) for the method you are building.
7808 ///
7809 /// See [`Self::add_scope()`] for details.
7810 pub fn add_scopes<I, St>(
7811 mut self,
7812 scopes: I,
7813 ) -> ProjectLocationEdgeCacheOriginGetIamPolicyCall<'a, C>
7814 where
7815 I: IntoIterator<Item = St>,
7816 St: AsRef<str>,
7817 {
7818 self._scopes
7819 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7820 self
7821 }
7822
7823 /// Removes all scopes, and no default scope will be used either.
7824 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7825 /// for details).
7826 pub fn clear_scopes(mut self) -> ProjectLocationEdgeCacheOriginGetIamPolicyCall<'a, C> {
7827 self._scopes.clear();
7828 self
7829 }
7830}
7831
7832/// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
7833///
7834/// A builder for the *locations.edgeCacheOrigins.setIamPolicy* method supported by a *project* resource.
7835/// It is not used directly, but through a [`ProjectMethods`] instance.
7836///
7837/// # Example
7838///
7839/// Instantiate a resource method builder
7840///
7841/// ```test_harness,no_run
7842/// # extern crate hyper;
7843/// # extern crate hyper_rustls;
7844/// # extern crate google_networkservices1 as networkservices1;
7845/// use networkservices1::api::SetIamPolicyRequest;
7846/// # async fn dox() {
7847/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7848///
7849/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7850/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7851/// # .with_native_roots()
7852/// # .unwrap()
7853/// # .https_only()
7854/// # .enable_http2()
7855/// # .build();
7856///
7857/// # let executor = hyper_util::rt::TokioExecutor::new();
7858/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7859/// # secret,
7860/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7861/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7862/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7863/// # ),
7864/// # ).build().await.unwrap();
7865///
7866/// # let client = hyper_util::client::legacy::Client::builder(
7867/// # hyper_util::rt::TokioExecutor::new()
7868/// # )
7869/// # .build(
7870/// # hyper_rustls::HttpsConnectorBuilder::new()
7871/// # .with_native_roots()
7872/// # .unwrap()
7873/// # .https_or_http()
7874/// # .enable_http2()
7875/// # .build()
7876/// # );
7877/// # let mut hub = NetworkServices::new(client, auth);
7878/// // As the method needs a request, you would usually fill it with the desired information
7879/// // into the respective structure. Some of the parts shown here might not be applicable !
7880/// // Values shown here are possibly random and not representative !
7881/// let mut req = SetIamPolicyRequest::default();
7882///
7883/// // You can configure optional parameters by calling the respective setters at will, and
7884/// // execute the final call using `doit()`.
7885/// // Values shown here are possibly random and not representative !
7886/// let result = hub.projects().locations_edge_cache_origins_set_iam_policy(req, "resource")
7887/// .doit().await;
7888/// # }
7889/// ```
7890pub struct ProjectLocationEdgeCacheOriginSetIamPolicyCall<'a, C>
7891where
7892 C: 'a,
7893{
7894 hub: &'a NetworkServices<C>,
7895 _request: SetIamPolicyRequest,
7896 _resource: String,
7897 _delegate: Option<&'a mut dyn common::Delegate>,
7898 _additional_params: HashMap<String, String>,
7899 _scopes: BTreeSet<String>,
7900}
7901
7902impl<'a, C> common::CallBuilder for ProjectLocationEdgeCacheOriginSetIamPolicyCall<'a, C> {}
7903
7904impl<'a, C> ProjectLocationEdgeCacheOriginSetIamPolicyCall<'a, C>
7905where
7906 C: common::Connector,
7907{
7908 /// Perform the operation you have build so far.
7909 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
7910 use std::borrow::Cow;
7911 use std::io::{Read, Seek};
7912
7913 use common::{url::Params, ToParts};
7914 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7915
7916 let mut dd = common::DefaultDelegate;
7917 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7918 dlg.begin(common::MethodInfo {
7919 id: "networkservices.projects.locations.edgeCacheOrigins.setIamPolicy",
7920 http_method: hyper::Method::POST,
7921 });
7922
7923 for &field in ["alt", "resource"].iter() {
7924 if self._additional_params.contains_key(field) {
7925 dlg.finished(false);
7926 return Err(common::Error::FieldClash(field));
7927 }
7928 }
7929
7930 let mut params = Params::with_capacity(4 + self._additional_params.len());
7931 params.push("resource", self._resource);
7932
7933 params.extend(self._additional_params.iter());
7934
7935 params.push("alt", "json");
7936 let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
7937 if self._scopes.is_empty() {
7938 self._scopes
7939 .insert(Scope::CloudPlatform.as_ref().to_string());
7940 }
7941
7942 #[allow(clippy::single_element_loop)]
7943 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
7944 url = params.uri_replacement(url, param_name, find_this, true);
7945 }
7946 {
7947 let to_remove = ["resource"];
7948 params.remove_params(&to_remove);
7949 }
7950
7951 let url = params.parse_with_url(&url);
7952
7953 let mut json_mime_type = mime::APPLICATION_JSON;
7954 let mut request_value_reader = {
7955 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7956 common::remove_json_null_values(&mut value);
7957 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7958 serde_json::to_writer(&mut dst, &value).unwrap();
7959 dst
7960 };
7961 let request_size = request_value_reader
7962 .seek(std::io::SeekFrom::End(0))
7963 .unwrap();
7964 request_value_reader
7965 .seek(std::io::SeekFrom::Start(0))
7966 .unwrap();
7967
7968 loop {
7969 let token = match self
7970 .hub
7971 .auth
7972 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7973 .await
7974 {
7975 Ok(token) => token,
7976 Err(e) => match dlg.token(e) {
7977 Ok(token) => token,
7978 Err(e) => {
7979 dlg.finished(false);
7980 return Err(common::Error::MissingToken(e));
7981 }
7982 },
7983 };
7984 request_value_reader
7985 .seek(std::io::SeekFrom::Start(0))
7986 .unwrap();
7987 let mut req_result = {
7988 let client = &self.hub.client;
7989 dlg.pre_request();
7990 let mut req_builder = hyper::Request::builder()
7991 .method(hyper::Method::POST)
7992 .uri(url.as_str())
7993 .header(USER_AGENT, self.hub._user_agent.clone());
7994
7995 if let Some(token) = token.as_ref() {
7996 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7997 }
7998
7999 let request = req_builder
8000 .header(CONTENT_TYPE, json_mime_type.to_string())
8001 .header(CONTENT_LENGTH, request_size as u64)
8002 .body(common::to_body(
8003 request_value_reader.get_ref().clone().into(),
8004 ));
8005
8006 client.request(request.unwrap()).await
8007 };
8008
8009 match req_result {
8010 Err(err) => {
8011 if let common::Retry::After(d) = dlg.http_error(&err) {
8012 sleep(d).await;
8013 continue;
8014 }
8015 dlg.finished(false);
8016 return Err(common::Error::HttpError(err));
8017 }
8018 Ok(res) => {
8019 let (mut parts, body) = res.into_parts();
8020 let mut body = common::Body::new(body);
8021 if !parts.status.is_success() {
8022 let bytes = common::to_bytes(body).await.unwrap_or_default();
8023 let error = serde_json::from_str(&common::to_string(&bytes));
8024 let response = common::to_response(parts, bytes.into());
8025
8026 if let common::Retry::After(d) =
8027 dlg.http_failure(&response, error.as_ref().ok())
8028 {
8029 sleep(d).await;
8030 continue;
8031 }
8032
8033 dlg.finished(false);
8034
8035 return Err(match error {
8036 Ok(value) => common::Error::BadRequest(value),
8037 _ => common::Error::Failure(response),
8038 });
8039 }
8040 let response = {
8041 let bytes = common::to_bytes(body).await.unwrap_or_default();
8042 let encoded = common::to_string(&bytes);
8043 match serde_json::from_str(&encoded) {
8044 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8045 Err(error) => {
8046 dlg.response_json_decode_error(&encoded, &error);
8047 return Err(common::Error::JsonDecodeError(
8048 encoded.to_string(),
8049 error,
8050 ));
8051 }
8052 }
8053 };
8054
8055 dlg.finished(true);
8056 return Ok(response);
8057 }
8058 }
8059 }
8060 }
8061
8062 ///
8063 /// Sets the *request* property to the given value.
8064 ///
8065 /// Even though the property as already been set when instantiating this call,
8066 /// we provide this method for API completeness.
8067 pub fn request(
8068 mut self,
8069 new_value: SetIamPolicyRequest,
8070 ) -> ProjectLocationEdgeCacheOriginSetIamPolicyCall<'a, C> {
8071 self._request = new_value;
8072 self
8073 }
8074 /// 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.
8075 ///
8076 /// Sets the *resource* path property to the given value.
8077 ///
8078 /// Even though the property as already been set when instantiating this call,
8079 /// we provide this method for API completeness.
8080 pub fn resource(
8081 mut self,
8082 new_value: &str,
8083 ) -> ProjectLocationEdgeCacheOriginSetIamPolicyCall<'a, C> {
8084 self._resource = new_value.to_string();
8085 self
8086 }
8087 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8088 /// while executing the actual API request.
8089 ///
8090 /// ````text
8091 /// It should be used to handle progress information, and to implement a certain level of resilience.
8092 /// ````
8093 ///
8094 /// Sets the *delegate* property to the given value.
8095 pub fn delegate(
8096 mut self,
8097 new_value: &'a mut dyn common::Delegate,
8098 ) -> ProjectLocationEdgeCacheOriginSetIamPolicyCall<'a, C> {
8099 self._delegate = Some(new_value);
8100 self
8101 }
8102
8103 /// Set any additional parameter of the query string used in the request.
8104 /// It should be used to set parameters which are not yet available through their own
8105 /// setters.
8106 ///
8107 /// Please note that this method must not be used to set any of the known parameters
8108 /// which have their own setter method. If done anyway, the request will fail.
8109 ///
8110 /// # Additional Parameters
8111 ///
8112 /// * *$.xgafv* (query-string) - V1 error format.
8113 /// * *access_token* (query-string) - OAuth access token.
8114 /// * *alt* (query-string) - Data format for response.
8115 /// * *callback* (query-string) - JSONP
8116 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8117 /// * *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.
8118 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8119 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8120 /// * *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.
8121 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8122 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8123 pub fn param<T>(
8124 mut self,
8125 name: T,
8126 value: T,
8127 ) -> ProjectLocationEdgeCacheOriginSetIamPolicyCall<'a, C>
8128 where
8129 T: AsRef<str>,
8130 {
8131 self._additional_params
8132 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8133 self
8134 }
8135
8136 /// Identifies the authorization scope for the method you are building.
8137 ///
8138 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8139 /// [`Scope::CloudPlatform`].
8140 ///
8141 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8142 /// tokens for more than one scope.
8143 ///
8144 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8145 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8146 /// sufficient, a read-write scope will do as well.
8147 pub fn add_scope<St>(
8148 mut self,
8149 scope: St,
8150 ) -> ProjectLocationEdgeCacheOriginSetIamPolicyCall<'a, C>
8151 where
8152 St: AsRef<str>,
8153 {
8154 self._scopes.insert(String::from(scope.as_ref()));
8155 self
8156 }
8157 /// Identifies the authorization scope(s) for the method you are building.
8158 ///
8159 /// See [`Self::add_scope()`] for details.
8160 pub fn add_scopes<I, St>(
8161 mut self,
8162 scopes: I,
8163 ) -> ProjectLocationEdgeCacheOriginSetIamPolicyCall<'a, C>
8164 where
8165 I: IntoIterator<Item = St>,
8166 St: AsRef<str>,
8167 {
8168 self._scopes
8169 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8170 self
8171 }
8172
8173 /// Removes all scopes, and no default scope will be used either.
8174 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8175 /// for details).
8176 pub fn clear_scopes(mut self) -> ProjectLocationEdgeCacheOriginSetIamPolicyCall<'a, C> {
8177 self._scopes.clear();
8178 self
8179 }
8180}
8181
8182/// 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.
8183///
8184/// A builder for the *locations.edgeCacheOrigins.testIamPermissions* method supported by a *project* resource.
8185/// It is not used directly, but through a [`ProjectMethods`] instance.
8186///
8187/// # Example
8188///
8189/// Instantiate a resource method builder
8190///
8191/// ```test_harness,no_run
8192/// # extern crate hyper;
8193/// # extern crate hyper_rustls;
8194/// # extern crate google_networkservices1 as networkservices1;
8195/// use networkservices1::api::TestIamPermissionsRequest;
8196/// # async fn dox() {
8197/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8198///
8199/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8200/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8201/// # .with_native_roots()
8202/// # .unwrap()
8203/// # .https_only()
8204/// # .enable_http2()
8205/// # .build();
8206///
8207/// # let executor = hyper_util::rt::TokioExecutor::new();
8208/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8209/// # secret,
8210/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8211/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8212/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8213/// # ),
8214/// # ).build().await.unwrap();
8215///
8216/// # let client = hyper_util::client::legacy::Client::builder(
8217/// # hyper_util::rt::TokioExecutor::new()
8218/// # )
8219/// # .build(
8220/// # hyper_rustls::HttpsConnectorBuilder::new()
8221/// # .with_native_roots()
8222/// # .unwrap()
8223/// # .https_or_http()
8224/// # .enable_http2()
8225/// # .build()
8226/// # );
8227/// # let mut hub = NetworkServices::new(client, auth);
8228/// // As the method needs a request, you would usually fill it with the desired information
8229/// // into the respective structure. Some of the parts shown here might not be applicable !
8230/// // Values shown here are possibly random and not representative !
8231/// let mut req = TestIamPermissionsRequest::default();
8232///
8233/// // You can configure optional parameters by calling the respective setters at will, and
8234/// // execute the final call using `doit()`.
8235/// // Values shown here are possibly random and not representative !
8236/// let result = hub.projects().locations_edge_cache_origins_test_iam_permissions(req, "resource")
8237/// .doit().await;
8238/// # }
8239/// ```
8240pub struct ProjectLocationEdgeCacheOriginTestIamPermissionCall<'a, C>
8241where
8242 C: 'a,
8243{
8244 hub: &'a NetworkServices<C>,
8245 _request: TestIamPermissionsRequest,
8246 _resource: String,
8247 _delegate: Option<&'a mut dyn common::Delegate>,
8248 _additional_params: HashMap<String, String>,
8249 _scopes: BTreeSet<String>,
8250}
8251
8252impl<'a, C> common::CallBuilder for ProjectLocationEdgeCacheOriginTestIamPermissionCall<'a, C> {}
8253
8254impl<'a, C> ProjectLocationEdgeCacheOriginTestIamPermissionCall<'a, C>
8255where
8256 C: common::Connector,
8257{
8258 /// Perform the operation you have build so far.
8259 pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
8260 use std::borrow::Cow;
8261 use std::io::{Read, Seek};
8262
8263 use common::{url::Params, ToParts};
8264 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8265
8266 let mut dd = common::DefaultDelegate;
8267 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8268 dlg.begin(common::MethodInfo {
8269 id: "networkservices.projects.locations.edgeCacheOrigins.testIamPermissions",
8270 http_method: hyper::Method::POST,
8271 });
8272
8273 for &field in ["alt", "resource"].iter() {
8274 if self._additional_params.contains_key(field) {
8275 dlg.finished(false);
8276 return Err(common::Error::FieldClash(field));
8277 }
8278 }
8279
8280 let mut params = Params::with_capacity(4 + self._additional_params.len());
8281 params.push("resource", self._resource);
8282
8283 params.extend(self._additional_params.iter());
8284
8285 params.push("alt", "json");
8286 let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
8287 if self._scopes.is_empty() {
8288 self._scopes
8289 .insert(Scope::CloudPlatform.as_ref().to_string());
8290 }
8291
8292 #[allow(clippy::single_element_loop)]
8293 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
8294 url = params.uri_replacement(url, param_name, find_this, true);
8295 }
8296 {
8297 let to_remove = ["resource"];
8298 params.remove_params(&to_remove);
8299 }
8300
8301 let url = params.parse_with_url(&url);
8302
8303 let mut json_mime_type = mime::APPLICATION_JSON;
8304 let mut request_value_reader = {
8305 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8306 common::remove_json_null_values(&mut value);
8307 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8308 serde_json::to_writer(&mut dst, &value).unwrap();
8309 dst
8310 };
8311 let request_size = request_value_reader
8312 .seek(std::io::SeekFrom::End(0))
8313 .unwrap();
8314 request_value_reader
8315 .seek(std::io::SeekFrom::Start(0))
8316 .unwrap();
8317
8318 loop {
8319 let token = match self
8320 .hub
8321 .auth
8322 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8323 .await
8324 {
8325 Ok(token) => token,
8326 Err(e) => match dlg.token(e) {
8327 Ok(token) => token,
8328 Err(e) => {
8329 dlg.finished(false);
8330 return Err(common::Error::MissingToken(e));
8331 }
8332 },
8333 };
8334 request_value_reader
8335 .seek(std::io::SeekFrom::Start(0))
8336 .unwrap();
8337 let mut req_result = {
8338 let client = &self.hub.client;
8339 dlg.pre_request();
8340 let mut req_builder = hyper::Request::builder()
8341 .method(hyper::Method::POST)
8342 .uri(url.as_str())
8343 .header(USER_AGENT, self.hub._user_agent.clone());
8344
8345 if let Some(token) = token.as_ref() {
8346 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8347 }
8348
8349 let request = req_builder
8350 .header(CONTENT_TYPE, json_mime_type.to_string())
8351 .header(CONTENT_LENGTH, request_size as u64)
8352 .body(common::to_body(
8353 request_value_reader.get_ref().clone().into(),
8354 ));
8355
8356 client.request(request.unwrap()).await
8357 };
8358
8359 match req_result {
8360 Err(err) => {
8361 if let common::Retry::After(d) = dlg.http_error(&err) {
8362 sleep(d).await;
8363 continue;
8364 }
8365 dlg.finished(false);
8366 return Err(common::Error::HttpError(err));
8367 }
8368 Ok(res) => {
8369 let (mut parts, body) = res.into_parts();
8370 let mut body = common::Body::new(body);
8371 if !parts.status.is_success() {
8372 let bytes = common::to_bytes(body).await.unwrap_or_default();
8373 let error = serde_json::from_str(&common::to_string(&bytes));
8374 let response = common::to_response(parts, bytes.into());
8375
8376 if let common::Retry::After(d) =
8377 dlg.http_failure(&response, error.as_ref().ok())
8378 {
8379 sleep(d).await;
8380 continue;
8381 }
8382
8383 dlg.finished(false);
8384
8385 return Err(match error {
8386 Ok(value) => common::Error::BadRequest(value),
8387 _ => common::Error::Failure(response),
8388 });
8389 }
8390 let response = {
8391 let bytes = common::to_bytes(body).await.unwrap_or_default();
8392 let encoded = common::to_string(&bytes);
8393 match serde_json::from_str(&encoded) {
8394 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8395 Err(error) => {
8396 dlg.response_json_decode_error(&encoded, &error);
8397 return Err(common::Error::JsonDecodeError(
8398 encoded.to_string(),
8399 error,
8400 ));
8401 }
8402 }
8403 };
8404
8405 dlg.finished(true);
8406 return Ok(response);
8407 }
8408 }
8409 }
8410 }
8411
8412 ///
8413 /// Sets the *request* property to the given value.
8414 ///
8415 /// Even though the property as already been set when instantiating this call,
8416 /// we provide this method for API completeness.
8417 pub fn request(
8418 mut self,
8419 new_value: TestIamPermissionsRequest,
8420 ) -> ProjectLocationEdgeCacheOriginTestIamPermissionCall<'a, C> {
8421 self._request = new_value;
8422 self
8423 }
8424 /// 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.
8425 ///
8426 /// Sets the *resource* path property to the given value.
8427 ///
8428 /// Even though the property as already been set when instantiating this call,
8429 /// we provide this method for API completeness.
8430 pub fn resource(
8431 mut self,
8432 new_value: &str,
8433 ) -> ProjectLocationEdgeCacheOriginTestIamPermissionCall<'a, C> {
8434 self._resource = new_value.to_string();
8435 self
8436 }
8437 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8438 /// while executing the actual API request.
8439 ///
8440 /// ````text
8441 /// It should be used to handle progress information, and to implement a certain level of resilience.
8442 /// ````
8443 ///
8444 /// Sets the *delegate* property to the given value.
8445 pub fn delegate(
8446 mut self,
8447 new_value: &'a mut dyn common::Delegate,
8448 ) -> ProjectLocationEdgeCacheOriginTestIamPermissionCall<'a, C> {
8449 self._delegate = Some(new_value);
8450 self
8451 }
8452
8453 /// Set any additional parameter of the query string used in the request.
8454 /// It should be used to set parameters which are not yet available through their own
8455 /// setters.
8456 ///
8457 /// Please note that this method must not be used to set any of the known parameters
8458 /// which have their own setter method. If done anyway, the request will fail.
8459 ///
8460 /// # Additional Parameters
8461 ///
8462 /// * *$.xgafv* (query-string) - V1 error format.
8463 /// * *access_token* (query-string) - OAuth access token.
8464 /// * *alt* (query-string) - Data format for response.
8465 /// * *callback* (query-string) - JSONP
8466 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8467 /// * *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.
8468 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8469 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8470 /// * *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.
8471 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8472 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8473 pub fn param<T>(
8474 mut self,
8475 name: T,
8476 value: T,
8477 ) -> ProjectLocationEdgeCacheOriginTestIamPermissionCall<'a, C>
8478 where
8479 T: AsRef<str>,
8480 {
8481 self._additional_params
8482 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8483 self
8484 }
8485
8486 /// Identifies the authorization scope for the method you are building.
8487 ///
8488 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8489 /// [`Scope::CloudPlatform`].
8490 ///
8491 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8492 /// tokens for more than one scope.
8493 ///
8494 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8495 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8496 /// sufficient, a read-write scope will do as well.
8497 pub fn add_scope<St>(
8498 mut self,
8499 scope: St,
8500 ) -> ProjectLocationEdgeCacheOriginTestIamPermissionCall<'a, C>
8501 where
8502 St: AsRef<str>,
8503 {
8504 self._scopes.insert(String::from(scope.as_ref()));
8505 self
8506 }
8507 /// Identifies the authorization scope(s) for the method you are building.
8508 ///
8509 /// See [`Self::add_scope()`] for details.
8510 pub fn add_scopes<I, St>(
8511 mut self,
8512 scopes: I,
8513 ) -> ProjectLocationEdgeCacheOriginTestIamPermissionCall<'a, C>
8514 where
8515 I: IntoIterator<Item = St>,
8516 St: AsRef<str>,
8517 {
8518 self._scopes
8519 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8520 self
8521 }
8522
8523 /// Removes all scopes, and no default scope will be used either.
8524 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8525 /// for details).
8526 pub fn clear_scopes(mut self) -> ProjectLocationEdgeCacheOriginTestIamPermissionCall<'a, C> {
8527 self._scopes.clear();
8528 self
8529 }
8530}
8531
8532/// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
8533///
8534/// A builder for the *locations.edgeCacheServices.getIamPolicy* method supported by a *project* resource.
8535/// It is not used directly, but through a [`ProjectMethods`] instance.
8536///
8537/// # Example
8538///
8539/// Instantiate a resource method builder
8540///
8541/// ```test_harness,no_run
8542/// # extern crate hyper;
8543/// # extern crate hyper_rustls;
8544/// # extern crate google_networkservices1 as networkservices1;
8545/// # async fn dox() {
8546/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8547///
8548/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8549/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8550/// # .with_native_roots()
8551/// # .unwrap()
8552/// # .https_only()
8553/// # .enable_http2()
8554/// # .build();
8555///
8556/// # let executor = hyper_util::rt::TokioExecutor::new();
8557/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8558/// # secret,
8559/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8560/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8561/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8562/// # ),
8563/// # ).build().await.unwrap();
8564///
8565/// # let client = hyper_util::client::legacy::Client::builder(
8566/// # hyper_util::rt::TokioExecutor::new()
8567/// # )
8568/// # .build(
8569/// # hyper_rustls::HttpsConnectorBuilder::new()
8570/// # .with_native_roots()
8571/// # .unwrap()
8572/// # .https_or_http()
8573/// # .enable_http2()
8574/// # .build()
8575/// # );
8576/// # let mut hub = NetworkServices::new(client, auth);
8577/// // You can configure optional parameters by calling the respective setters at will, and
8578/// // execute the final call using `doit()`.
8579/// // Values shown here are possibly random and not representative !
8580/// let result = hub.projects().locations_edge_cache_services_get_iam_policy("resource")
8581/// .options_requested_policy_version(-7)
8582/// .doit().await;
8583/// # }
8584/// ```
8585pub struct ProjectLocationEdgeCacheServiceGetIamPolicyCall<'a, C>
8586where
8587 C: 'a,
8588{
8589 hub: &'a NetworkServices<C>,
8590 _resource: String,
8591 _options_requested_policy_version: Option<i32>,
8592 _delegate: Option<&'a mut dyn common::Delegate>,
8593 _additional_params: HashMap<String, String>,
8594 _scopes: BTreeSet<String>,
8595}
8596
8597impl<'a, C> common::CallBuilder for ProjectLocationEdgeCacheServiceGetIamPolicyCall<'a, C> {}
8598
8599impl<'a, C> ProjectLocationEdgeCacheServiceGetIamPolicyCall<'a, C>
8600where
8601 C: common::Connector,
8602{
8603 /// Perform the operation you have build so far.
8604 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
8605 use std::borrow::Cow;
8606 use std::io::{Read, Seek};
8607
8608 use common::{url::Params, ToParts};
8609 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8610
8611 let mut dd = common::DefaultDelegate;
8612 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8613 dlg.begin(common::MethodInfo {
8614 id: "networkservices.projects.locations.edgeCacheServices.getIamPolicy",
8615 http_method: hyper::Method::GET,
8616 });
8617
8618 for &field in ["alt", "resource", "options.requestedPolicyVersion"].iter() {
8619 if self._additional_params.contains_key(field) {
8620 dlg.finished(false);
8621 return Err(common::Error::FieldClash(field));
8622 }
8623 }
8624
8625 let mut params = Params::with_capacity(4 + self._additional_params.len());
8626 params.push("resource", self._resource);
8627 if let Some(value) = self._options_requested_policy_version.as_ref() {
8628 params.push("options.requestedPolicyVersion", value.to_string());
8629 }
8630
8631 params.extend(self._additional_params.iter());
8632
8633 params.push("alt", "json");
8634 let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
8635 if self._scopes.is_empty() {
8636 self._scopes
8637 .insert(Scope::CloudPlatform.as_ref().to_string());
8638 }
8639
8640 #[allow(clippy::single_element_loop)]
8641 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
8642 url = params.uri_replacement(url, param_name, find_this, true);
8643 }
8644 {
8645 let to_remove = ["resource"];
8646 params.remove_params(&to_remove);
8647 }
8648
8649 let url = params.parse_with_url(&url);
8650
8651 loop {
8652 let token = match self
8653 .hub
8654 .auth
8655 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8656 .await
8657 {
8658 Ok(token) => token,
8659 Err(e) => match dlg.token(e) {
8660 Ok(token) => token,
8661 Err(e) => {
8662 dlg.finished(false);
8663 return Err(common::Error::MissingToken(e));
8664 }
8665 },
8666 };
8667 let mut req_result = {
8668 let client = &self.hub.client;
8669 dlg.pre_request();
8670 let mut req_builder = hyper::Request::builder()
8671 .method(hyper::Method::GET)
8672 .uri(url.as_str())
8673 .header(USER_AGENT, self.hub._user_agent.clone());
8674
8675 if let Some(token) = token.as_ref() {
8676 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8677 }
8678
8679 let request = req_builder
8680 .header(CONTENT_LENGTH, 0_u64)
8681 .body(common::to_body::<String>(None));
8682
8683 client.request(request.unwrap()).await
8684 };
8685
8686 match req_result {
8687 Err(err) => {
8688 if let common::Retry::After(d) = dlg.http_error(&err) {
8689 sleep(d).await;
8690 continue;
8691 }
8692 dlg.finished(false);
8693 return Err(common::Error::HttpError(err));
8694 }
8695 Ok(res) => {
8696 let (mut parts, body) = res.into_parts();
8697 let mut body = common::Body::new(body);
8698 if !parts.status.is_success() {
8699 let bytes = common::to_bytes(body).await.unwrap_or_default();
8700 let error = serde_json::from_str(&common::to_string(&bytes));
8701 let response = common::to_response(parts, bytes.into());
8702
8703 if let common::Retry::After(d) =
8704 dlg.http_failure(&response, error.as_ref().ok())
8705 {
8706 sleep(d).await;
8707 continue;
8708 }
8709
8710 dlg.finished(false);
8711
8712 return Err(match error {
8713 Ok(value) => common::Error::BadRequest(value),
8714 _ => common::Error::Failure(response),
8715 });
8716 }
8717 let response = {
8718 let bytes = common::to_bytes(body).await.unwrap_or_default();
8719 let encoded = common::to_string(&bytes);
8720 match serde_json::from_str(&encoded) {
8721 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8722 Err(error) => {
8723 dlg.response_json_decode_error(&encoded, &error);
8724 return Err(common::Error::JsonDecodeError(
8725 encoded.to_string(),
8726 error,
8727 ));
8728 }
8729 }
8730 };
8731
8732 dlg.finished(true);
8733 return Ok(response);
8734 }
8735 }
8736 }
8737 }
8738
8739 /// 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.
8740 ///
8741 /// Sets the *resource* path 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 resource(
8746 mut self,
8747 new_value: &str,
8748 ) -> ProjectLocationEdgeCacheServiceGetIamPolicyCall<'a, C> {
8749 self._resource = new_value.to_string();
8750 self
8751 }
8752 /// 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).
8753 ///
8754 /// Sets the *options.requested policy version* query property to the given value.
8755 pub fn options_requested_policy_version(
8756 mut self,
8757 new_value: i32,
8758 ) -> ProjectLocationEdgeCacheServiceGetIamPolicyCall<'a, C> {
8759 self._options_requested_policy_version = Some(new_value);
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 ) -> ProjectLocationEdgeCacheServiceGetIamPolicyCall<'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>(
8799 mut self,
8800 name: T,
8801 value: T,
8802 ) -> ProjectLocationEdgeCacheServiceGetIamPolicyCall<'a, C>
8803 where
8804 T: AsRef<str>,
8805 {
8806 self._additional_params
8807 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8808 self
8809 }
8810
8811 /// Identifies the authorization scope for the method you are building.
8812 ///
8813 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8814 /// [`Scope::CloudPlatform`].
8815 ///
8816 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8817 /// tokens for more than one scope.
8818 ///
8819 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8820 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8821 /// sufficient, a read-write scope will do as well.
8822 pub fn add_scope<St>(
8823 mut self,
8824 scope: St,
8825 ) -> ProjectLocationEdgeCacheServiceGetIamPolicyCall<'a, C>
8826 where
8827 St: AsRef<str>,
8828 {
8829 self._scopes.insert(String::from(scope.as_ref()));
8830 self
8831 }
8832 /// Identifies the authorization scope(s) for the method you are building.
8833 ///
8834 /// See [`Self::add_scope()`] for details.
8835 pub fn add_scopes<I, St>(
8836 mut self,
8837 scopes: I,
8838 ) -> ProjectLocationEdgeCacheServiceGetIamPolicyCall<'a, C>
8839 where
8840 I: IntoIterator<Item = St>,
8841 St: AsRef<str>,
8842 {
8843 self._scopes
8844 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8845 self
8846 }
8847
8848 /// Removes all scopes, and no default scope will be used either.
8849 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8850 /// for details).
8851 pub fn clear_scopes(mut self) -> ProjectLocationEdgeCacheServiceGetIamPolicyCall<'a, C> {
8852 self._scopes.clear();
8853 self
8854 }
8855}
8856
8857/// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
8858///
8859/// A builder for the *locations.edgeCacheServices.setIamPolicy* method supported by a *project* resource.
8860/// It is not used directly, but through a [`ProjectMethods`] instance.
8861///
8862/// # Example
8863///
8864/// Instantiate a resource method builder
8865///
8866/// ```test_harness,no_run
8867/// # extern crate hyper;
8868/// # extern crate hyper_rustls;
8869/// # extern crate google_networkservices1 as networkservices1;
8870/// use networkservices1::api::SetIamPolicyRequest;
8871/// # async fn dox() {
8872/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8873///
8874/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8875/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8876/// # .with_native_roots()
8877/// # .unwrap()
8878/// # .https_only()
8879/// # .enable_http2()
8880/// # .build();
8881///
8882/// # let executor = hyper_util::rt::TokioExecutor::new();
8883/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8884/// # secret,
8885/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8886/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8887/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8888/// # ),
8889/// # ).build().await.unwrap();
8890///
8891/// # let client = hyper_util::client::legacy::Client::builder(
8892/// # hyper_util::rt::TokioExecutor::new()
8893/// # )
8894/// # .build(
8895/// # hyper_rustls::HttpsConnectorBuilder::new()
8896/// # .with_native_roots()
8897/// # .unwrap()
8898/// # .https_or_http()
8899/// # .enable_http2()
8900/// # .build()
8901/// # );
8902/// # let mut hub = NetworkServices::new(client, auth);
8903/// // As the method needs a request, you would usually fill it with the desired information
8904/// // into the respective structure. Some of the parts shown here might not be applicable !
8905/// // Values shown here are possibly random and not representative !
8906/// let mut req = SetIamPolicyRequest::default();
8907///
8908/// // You can configure optional parameters by calling the respective setters at will, and
8909/// // execute the final call using `doit()`.
8910/// // Values shown here are possibly random and not representative !
8911/// let result = hub.projects().locations_edge_cache_services_set_iam_policy(req, "resource")
8912/// .doit().await;
8913/// # }
8914/// ```
8915pub struct ProjectLocationEdgeCacheServiceSetIamPolicyCall<'a, C>
8916where
8917 C: 'a,
8918{
8919 hub: &'a NetworkServices<C>,
8920 _request: SetIamPolicyRequest,
8921 _resource: String,
8922 _delegate: Option<&'a mut dyn common::Delegate>,
8923 _additional_params: HashMap<String, String>,
8924 _scopes: BTreeSet<String>,
8925}
8926
8927impl<'a, C> common::CallBuilder for ProjectLocationEdgeCacheServiceSetIamPolicyCall<'a, C> {}
8928
8929impl<'a, C> ProjectLocationEdgeCacheServiceSetIamPolicyCall<'a, C>
8930where
8931 C: common::Connector,
8932{
8933 /// Perform the operation you have build so far.
8934 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
8935 use std::borrow::Cow;
8936 use std::io::{Read, Seek};
8937
8938 use common::{url::Params, ToParts};
8939 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8940
8941 let mut dd = common::DefaultDelegate;
8942 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8943 dlg.begin(common::MethodInfo {
8944 id: "networkservices.projects.locations.edgeCacheServices.setIamPolicy",
8945 http_method: hyper::Method::POST,
8946 });
8947
8948 for &field in ["alt", "resource"].iter() {
8949 if self._additional_params.contains_key(field) {
8950 dlg.finished(false);
8951 return Err(common::Error::FieldClash(field));
8952 }
8953 }
8954
8955 let mut params = Params::with_capacity(4 + self._additional_params.len());
8956 params.push("resource", self._resource);
8957
8958 params.extend(self._additional_params.iter());
8959
8960 params.push("alt", "json");
8961 let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
8962 if self._scopes.is_empty() {
8963 self._scopes
8964 .insert(Scope::CloudPlatform.as_ref().to_string());
8965 }
8966
8967 #[allow(clippy::single_element_loop)]
8968 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
8969 url = params.uri_replacement(url, param_name, find_this, true);
8970 }
8971 {
8972 let to_remove = ["resource"];
8973 params.remove_params(&to_remove);
8974 }
8975
8976 let url = params.parse_with_url(&url);
8977
8978 let mut json_mime_type = mime::APPLICATION_JSON;
8979 let mut request_value_reader = {
8980 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8981 common::remove_json_null_values(&mut value);
8982 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8983 serde_json::to_writer(&mut dst, &value).unwrap();
8984 dst
8985 };
8986 let request_size = request_value_reader
8987 .seek(std::io::SeekFrom::End(0))
8988 .unwrap();
8989 request_value_reader
8990 .seek(std::io::SeekFrom::Start(0))
8991 .unwrap();
8992
8993 loop {
8994 let token = match self
8995 .hub
8996 .auth
8997 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8998 .await
8999 {
9000 Ok(token) => token,
9001 Err(e) => match dlg.token(e) {
9002 Ok(token) => token,
9003 Err(e) => {
9004 dlg.finished(false);
9005 return Err(common::Error::MissingToken(e));
9006 }
9007 },
9008 };
9009 request_value_reader
9010 .seek(std::io::SeekFrom::Start(0))
9011 .unwrap();
9012 let mut req_result = {
9013 let client = &self.hub.client;
9014 dlg.pre_request();
9015 let mut req_builder = hyper::Request::builder()
9016 .method(hyper::Method::POST)
9017 .uri(url.as_str())
9018 .header(USER_AGENT, self.hub._user_agent.clone());
9019
9020 if let Some(token) = token.as_ref() {
9021 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9022 }
9023
9024 let request = req_builder
9025 .header(CONTENT_TYPE, json_mime_type.to_string())
9026 .header(CONTENT_LENGTH, request_size as u64)
9027 .body(common::to_body(
9028 request_value_reader.get_ref().clone().into(),
9029 ));
9030
9031 client.request(request.unwrap()).await
9032 };
9033
9034 match req_result {
9035 Err(err) => {
9036 if let common::Retry::After(d) = dlg.http_error(&err) {
9037 sleep(d).await;
9038 continue;
9039 }
9040 dlg.finished(false);
9041 return Err(common::Error::HttpError(err));
9042 }
9043 Ok(res) => {
9044 let (mut parts, body) = res.into_parts();
9045 let mut body = common::Body::new(body);
9046 if !parts.status.is_success() {
9047 let bytes = common::to_bytes(body).await.unwrap_or_default();
9048 let error = serde_json::from_str(&common::to_string(&bytes));
9049 let response = common::to_response(parts, bytes.into());
9050
9051 if let common::Retry::After(d) =
9052 dlg.http_failure(&response, error.as_ref().ok())
9053 {
9054 sleep(d).await;
9055 continue;
9056 }
9057
9058 dlg.finished(false);
9059
9060 return Err(match error {
9061 Ok(value) => common::Error::BadRequest(value),
9062 _ => common::Error::Failure(response),
9063 });
9064 }
9065 let response = {
9066 let bytes = common::to_bytes(body).await.unwrap_or_default();
9067 let encoded = common::to_string(&bytes);
9068 match serde_json::from_str(&encoded) {
9069 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9070 Err(error) => {
9071 dlg.response_json_decode_error(&encoded, &error);
9072 return Err(common::Error::JsonDecodeError(
9073 encoded.to_string(),
9074 error,
9075 ));
9076 }
9077 }
9078 };
9079
9080 dlg.finished(true);
9081 return Ok(response);
9082 }
9083 }
9084 }
9085 }
9086
9087 ///
9088 /// Sets the *request* property to the given value.
9089 ///
9090 /// Even though the property as already been set when instantiating this call,
9091 /// we provide this method for API completeness.
9092 pub fn request(
9093 mut self,
9094 new_value: SetIamPolicyRequest,
9095 ) -> ProjectLocationEdgeCacheServiceSetIamPolicyCall<'a, C> {
9096 self._request = new_value;
9097 self
9098 }
9099 /// 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.
9100 ///
9101 /// Sets the *resource* path property to the given value.
9102 ///
9103 /// Even though the property as already been set when instantiating this call,
9104 /// we provide this method for API completeness.
9105 pub fn resource(
9106 mut self,
9107 new_value: &str,
9108 ) -> ProjectLocationEdgeCacheServiceSetIamPolicyCall<'a, C> {
9109 self._resource = new_value.to_string();
9110 self
9111 }
9112 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9113 /// while executing the actual API request.
9114 ///
9115 /// ````text
9116 /// It should be used to handle progress information, and to implement a certain level of resilience.
9117 /// ````
9118 ///
9119 /// Sets the *delegate* property to the given value.
9120 pub fn delegate(
9121 mut self,
9122 new_value: &'a mut dyn common::Delegate,
9123 ) -> ProjectLocationEdgeCacheServiceSetIamPolicyCall<'a, C> {
9124 self._delegate = Some(new_value);
9125 self
9126 }
9127
9128 /// Set any additional parameter of the query string used in the request.
9129 /// It should be used to set parameters which are not yet available through their own
9130 /// setters.
9131 ///
9132 /// Please note that this method must not be used to set any of the known parameters
9133 /// which have their own setter method. If done anyway, the request will fail.
9134 ///
9135 /// # Additional Parameters
9136 ///
9137 /// * *$.xgafv* (query-string) - V1 error format.
9138 /// * *access_token* (query-string) - OAuth access token.
9139 /// * *alt* (query-string) - Data format for response.
9140 /// * *callback* (query-string) - JSONP
9141 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9142 /// * *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.
9143 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9144 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9145 /// * *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.
9146 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9147 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9148 pub fn param<T>(
9149 mut self,
9150 name: T,
9151 value: T,
9152 ) -> ProjectLocationEdgeCacheServiceSetIamPolicyCall<'a, C>
9153 where
9154 T: AsRef<str>,
9155 {
9156 self._additional_params
9157 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9158 self
9159 }
9160
9161 /// Identifies the authorization scope for the method you are building.
9162 ///
9163 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9164 /// [`Scope::CloudPlatform`].
9165 ///
9166 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9167 /// tokens for more than one scope.
9168 ///
9169 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9170 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9171 /// sufficient, a read-write scope will do as well.
9172 pub fn add_scope<St>(
9173 mut self,
9174 scope: St,
9175 ) -> ProjectLocationEdgeCacheServiceSetIamPolicyCall<'a, C>
9176 where
9177 St: AsRef<str>,
9178 {
9179 self._scopes.insert(String::from(scope.as_ref()));
9180 self
9181 }
9182 /// Identifies the authorization scope(s) for the method you are building.
9183 ///
9184 /// See [`Self::add_scope()`] for details.
9185 pub fn add_scopes<I, St>(
9186 mut self,
9187 scopes: I,
9188 ) -> ProjectLocationEdgeCacheServiceSetIamPolicyCall<'a, C>
9189 where
9190 I: IntoIterator<Item = St>,
9191 St: AsRef<str>,
9192 {
9193 self._scopes
9194 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9195 self
9196 }
9197
9198 /// Removes all scopes, and no default scope will be used either.
9199 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9200 /// for details).
9201 pub fn clear_scopes(mut self) -> ProjectLocationEdgeCacheServiceSetIamPolicyCall<'a, C> {
9202 self._scopes.clear();
9203 self
9204 }
9205}
9206
9207/// 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.
9208///
9209/// A builder for the *locations.edgeCacheServices.testIamPermissions* method supported by a *project* resource.
9210/// It is not used directly, but through a [`ProjectMethods`] instance.
9211///
9212/// # Example
9213///
9214/// Instantiate a resource method builder
9215///
9216/// ```test_harness,no_run
9217/// # extern crate hyper;
9218/// # extern crate hyper_rustls;
9219/// # extern crate google_networkservices1 as networkservices1;
9220/// use networkservices1::api::TestIamPermissionsRequest;
9221/// # async fn dox() {
9222/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9223///
9224/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9225/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9226/// # .with_native_roots()
9227/// # .unwrap()
9228/// # .https_only()
9229/// # .enable_http2()
9230/// # .build();
9231///
9232/// # let executor = hyper_util::rt::TokioExecutor::new();
9233/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9234/// # secret,
9235/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9236/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9237/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9238/// # ),
9239/// # ).build().await.unwrap();
9240///
9241/// # let client = hyper_util::client::legacy::Client::builder(
9242/// # hyper_util::rt::TokioExecutor::new()
9243/// # )
9244/// # .build(
9245/// # hyper_rustls::HttpsConnectorBuilder::new()
9246/// # .with_native_roots()
9247/// # .unwrap()
9248/// # .https_or_http()
9249/// # .enable_http2()
9250/// # .build()
9251/// # );
9252/// # let mut hub = NetworkServices::new(client, auth);
9253/// // As the method needs a request, you would usually fill it with the desired information
9254/// // into the respective structure. Some of the parts shown here might not be applicable !
9255/// // Values shown here are possibly random and not representative !
9256/// let mut req = TestIamPermissionsRequest::default();
9257///
9258/// // You can configure optional parameters by calling the respective setters at will, and
9259/// // execute the final call using `doit()`.
9260/// // Values shown here are possibly random and not representative !
9261/// let result = hub.projects().locations_edge_cache_services_test_iam_permissions(req, "resource")
9262/// .doit().await;
9263/// # }
9264/// ```
9265pub struct ProjectLocationEdgeCacheServiceTestIamPermissionCall<'a, C>
9266where
9267 C: 'a,
9268{
9269 hub: &'a NetworkServices<C>,
9270 _request: TestIamPermissionsRequest,
9271 _resource: String,
9272 _delegate: Option<&'a mut dyn common::Delegate>,
9273 _additional_params: HashMap<String, String>,
9274 _scopes: BTreeSet<String>,
9275}
9276
9277impl<'a, C> common::CallBuilder for ProjectLocationEdgeCacheServiceTestIamPermissionCall<'a, C> {}
9278
9279impl<'a, C> ProjectLocationEdgeCacheServiceTestIamPermissionCall<'a, C>
9280where
9281 C: common::Connector,
9282{
9283 /// Perform the operation you have build so far.
9284 pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
9285 use std::borrow::Cow;
9286 use std::io::{Read, Seek};
9287
9288 use common::{url::Params, ToParts};
9289 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9290
9291 let mut dd = common::DefaultDelegate;
9292 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9293 dlg.begin(common::MethodInfo {
9294 id: "networkservices.projects.locations.edgeCacheServices.testIamPermissions",
9295 http_method: hyper::Method::POST,
9296 });
9297
9298 for &field in ["alt", "resource"].iter() {
9299 if self._additional_params.contains_key(field) {
9300 dlg.finished(false);
9301 return Err(common::Error::FieldClash(field));
9302 }
9303 }
9304
9305 let mut params = Params::with_capacity(4 + self._additional_params.len());
9306 params.push("resource", self._resource);
9307
9308 params.extend(self._additional_params.iter());
9309
9310 params.push("alt", "json");
9311 let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
9312 if self._scopes.is_empty() {
9313 self._scopes
9314 .insert(Scope::CloudPlatform.as_ref().to_string());
9315 }
9316
9317 #[allow(clippy::single_element_loop)]
9318 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
9319 url = params.uri_replacement(url, param_name, find_this, true);
9320 }
9321 {
9322 let to_remove = ["resource"];
9323 params.remove_params(&to_remove);
9324 }
9325
9326 let url = params.parse_with_url(&url);
9327
9328 let mut json_mime_type = mime::APPLICATION_JSON;
9329 let mut request_value_reader = {
9330 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9331 common::remove_json_null_values(&mut value);
9332 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9333 serde_json::to_writer(&mut dst, &value).unwrap();
9334 dst
9335 };
9336 let request_size = request_value_reader
9337 .seek(std::io::SeekFrom::End(0))
9338 .unwrap();
9339 request_value_reader
9340 .seek(std::io::SeekFrom::Start(0))
9341 .unwrap();
9342
9343 loop {
9344 let token = match self
9345 .hub
9346 .auth
9347 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9348 .await
9349 {
9350 Ok(token) => token,
9351 Err(e) => match dlg.token(e) {
9352 Ok(token) => token,
9353 Err(e) => {
9354 dlg.finished(false);
9355 return Err(common::Error::MissingToken(e));
9356 }
9357 },
9358 };
9359 request_value_reader
9360 .seek(std::io::SeekFrom::Start(0))
9361 .unwrap();
9362 let mut req_result = {
9363 let client = &self.hub.client;
9364 dlg.pre_request();
9365 let mut req_builder = hyper::Request::builder()
9366 .method(hyper::Method::POST)
9367 .uri(url.as_str())
9368 .header(USER_AGENT, self.hub._user_agent.clone());
9369
9370 if let Some(token) = token.as_ref() {
9371 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9372 }
9373
9374 let request = req_builder
9375 .header(CONTENT_TYPE, json_mime_type.to_string())
9376 .header(CONTENT_LENGTH, request_size as u64)
9377 .body(common::to_body(
9378 request_value_reader.get_ref().clone().into(),
9379 ));
9380
9381 client.request(request.unwrap()).await
9382 };
9383
9384 match req_result {
9385 Err(err) => {
9386 if let common::Retry::After(d) = dlg.http_error(&err) {
9387 sleep(d).await;
9388 continue;
9389 }
9390 dlg.finished(false);
9391 return Err(common::Error::HttpError(err));
9392 }
9393 Ok(res) => {
9394 let (mut parts, body) = res.into_parts();
9395 let mut body = common::Body::new(body);
9396 if !parts.status.is_success() {
9397 let bytes = common::to_bytes(body).await.unwrap_or_default();
9398 let error = serde_json::from_str(&common::to_string(&bytes));
9399 let response = common::to_response(parts, bytes.into());
9400
9401 if let common::Retry::After(d) =
9402 dlg.http_failure(&response, error.as_ref().ok())
9403 {
9404 sleep(d).await;
9405 continue;
9406 }
9407
9408 dlg.finished(false);
9409
9410 return Err(match error {
9411 Ok(value) => common::Error::BadRequest(value),
9412 _ => common::Error::Failure(response),
9413 });
9414 }
9415 let response = {
9416 let bytes = common::to_bytes(body).await.unwrap_or_default();
9417 let encoded = common::to_string(&bytes);
9418 match serde_json::from_str(&encoded) {
9419 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9420 Err(error) => {
9421 dlg.response_json_decode_error(&encoded, &error);
9422 return Err(common::Error::JsonDecodeError(
9423 encoded.to_string(),
9424 error,
9425 ));
9426 }
9427 }
9428 };
9429
9430 dlg.finished(true);
9431 return Ok(response);
9432 }
9433 }
9434 }
9435 }
9436
9437 ///
9438 /// Sets the *request* property to the given value.
9439 ///
9440 /// Even though the property as already been set when instantiating this call,
9441 /// we provide this method for API completeness.
9442 pub fn request(
9443 mut self,
9444 new_value: TestIamPermissionsRequest,
9445 ) -> ProjectLocationEdgeCacheServiceTestIamPermissionCall<'a, C> {
9446 self._request = new_value;
9447 self
9448 }
9449 /// 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.
9450 ///
9451 /// Sets the *resource* path property to the given value.
9452 ///
9453 /// Even though the property as already been set when instantiating this call,
9454 /// we provide this method for API completeness.
9455 pub fn resource(
9456 mut self,
9457 new_value: &str,
9458 ) -> ProjectLocationEdgeCacheServiceTestIamPermissionCall<'a, C> {
9459 self._resource = new_value.to_string();
9460 self
9461 }
9462 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9463 /// while executing the actual API request.
9464 ///
9465 /// ````text
9466 /// It should be used to handle progress information, and to implement a certain level of resilience.
9467 /// ````
9468 ///
9469 /// Sets the *delegate* property to the given value.
9470 pub fn delegate(
9471 mut self,
9472 new_value: &'a mut dyn common::Delegate,
9473 ) -> ProjectLocationEdgeCacheServiceTestIamPermissionCall<'a, C> {
9474 self._delegate = Some(new_value);
9475 self
9476 }
9477
9478 /// Set any additional parameter of the query string used in the request.
9479 /// It should be used to set parameters which are not yet available through their own
9480 /// setters.
9481 ///
9482 /// Please note that this method must not be used to set any of the known parameters
9483 /// which have their own setter method. If done anyway, the request will fail.
9484 ///
9485 /// # Additional Parameters
9486 ///
9487 /// * *$.xgafv* (query-string) - V1 error format.
9488 /// * *access_token* (query-string) - OAuth access token.
9489 /// * *alt* (query-string) - Data format for response.
9490 /// * *callback* (query-string) - JSONP
9491 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9492 /// * *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.
9493 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9494 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9495 /// * *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.
9496 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9497 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9498 pub fn param<T>(
9499 mut self,
9500 name: T,
9501 value: T,
9502 ) -> ProjectLocationEdgeCacheServiceTestIamPermissionCall<'a, C>
9503 where
9504 T: AsRef<str>,
9505 {
9506 self._additional_params
9507 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9508 self
9509 }
9510
9511 /// Identifies the authorization scope for the method you are building.
9512 ///
9513 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9514 /// [`Scope::CloudPlatform`].
9515 ///
9516 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9517 /// tokens for more than one scope.
9518 ///
9519 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9520 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9521 /// sufficient, a read-write scope will do as well.
9522 pub fn add_scope<St>(
9523 mut self,
9524 scope: St,
9525 ) -> ProjectLocationEdgeCacheServiceTestIamPermissionCall<'a, C>
9526 where
9527 St: AsRef<str>,
9528 {
9529 self._scopes.insert(String::from(scope.as_ref()));
9530 self
9531 }
9532 /// Identifies the authorization scope(s) for the method you are building.
9533 ///
9534 /// See [`Self::add_scope()`] for details.
9535 pub fn add_scopes<I, St>(
9536 mut self,
9537 scopes: I,
9538 ) -> ProjectLocationEdgeCacheServiceTestIamPermissionCall<'a, C>
9539 where
9540 I: IntoIterator<Item = St>,
9541 St: AsRef<str>,
9542 {
9543 self._scopes
9544 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9545 self
9546 }
9547
9548 /// Removes all scopes, and no default scope will be used either.
9549 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9550 /// for details).
9551 pub fn clear_scopes(mut self) -> ProjectLocationEdgeCacheServiceTestIamPermissionCall<'a, C> {
9552 self._scopes.clear();
9553 self
9554 }
9555}
9556
9557/// Creates a new EndpointPolicy in a given project and location.
9558///
9559/// A builder for the *locations.endpointPolicies.create* method supported by a *project* resource.
9560/// It is not used directly, but through a [`ProjectMethods`] instance.
9561///
9562/// # Example
9563///
9564/// Instantiate a resource method builder
9565///
9566/// ```test_harness,no_run
9567/// # extern crate hyper;
9568/// # extern crate hyper_rustls;
9569/// # extern crate google_networkservices1 as networkservices1;
9570/// use networkservices1::api::EndpointPolicy;
9571/// # async fn dox() {
9572/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9573///
9574/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9575/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9576/// # .with_native_roots()
9577/// # .unwrap()
9578/// # .https_only()
9579/// # .enable_http2()
9580/// # .build();
9581///
9582/// # let executor = hyper_util::rt::TokioExecutor::new();
9583/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9584/// # secret,
9585/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9586/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9587/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9588/// # ),
9589/// # ).build().await.unwrap();
9590///
9591/// # let client = hyper_util::client::legacy::Client::builder(
9592/// # hyper_util::rt::TokioExecutor::new()
9593/// # )
9594/// # .build(
9595/// # hyper_rustls::HttpsConnectorBuilder::new()
9596/// # .with_native_roots()
9597/// # .unwrap()
9598/// # .https_or_http()
9599/// # .enable_http2()
9600/// # .build()
9601/// # );
9602/// # let mut hub = NetworkServices::new(client, auth);
9603/// // As the method needs a request, you would usually fill it with the desired information
9604/// // into the respective structure. Some of the parts shown here might not be applicable !
9605/// // Values shown here are possibly random and not representative !
9606/// let mut req = EndpointPolicy::default();
9607///
9608/// // You can configure optional parameters by calling the respective setters at will, and
9609/// // execute the final call using `doit()`.
9610/// // Values shown here are possibly random and not representative !
9611/// let result = hub.projects().locations_endpoint_policies_create(req, "parent")
9612/// .endpoint_policy_id("Lorem")
9613/// .doit().await;
9614/// # }
9615/// ```
9616pub struct ProjectLocationEndpointPolicyCreateCall<'a, C>
9617where
9618 C: 'a,
9619{
9620 hub: &'a NetworkServices<C>,
9621 _request: EndpointPolicy,
9622 _parent: String,
9623 _endpoint_policy_id: Option<String>,
9624 _delegate: Option<&'a mut dyn common::Delegate>,
9625 _additional_params: HashMap<String, String>,
9626 _scopes: BTreeSet<String>,
9627}
9628
9629impl<'a, C> common::CallBuilder for ProjectLocationEndpointPolicyCreateCall<'a, C> {}
9630
9631impl<'a, C> ProjectLocationEndpointPolicyCreateCall<'a, C>
9632where
9633 C: common::Connector,
9634{
9635 /// Perform the operation you have build so far.
9636 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
9637 use std::borrow::Cow;
9638 use std::io::{Read, Seek};
9639
9640 use common::{url::Params, ToParts};
9641 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9642
9643 let mut dd = common::DefaultDelegate;
9644 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9645 dlg.begin(common::MethodInfo {
9646 id: "networkservices.projects.locations.endpointPolicies.create",
9647 http_method: hyper::Method::POST,
9648 });
9649
9650 for &field in ["alt", "parent", "endpointPolicyId"].iter() {
9651 if self._additional_params.contains_key(field) {
9652 dlg.finished(false);
9653 return Err(common::Error::FieldClash(field));
9654 }
9655 }
9656
9657 let mut params = Params::with_capacity(5 + self._additional_params.len());
9658 params.push("parent", self._parent);
9659 if let Some(value) = self._endpoint_policy_id.as_ref() {
9660 params.push("endpointPolicyId", value);
9661 }
9662
9663 params.extend(self._additional_params.iter());
9664
9665 params.push("alt", "json");
9666 let mut url = self.hub._base_url.clone() + "v1/{+parent}/endpointPolicies";
9667 if self._scopes.is_empty() {
9668 self._scopes
9669 .insert(Scope::CloudPlatform.as_ref().to_string());
9670 }
9671
9672 #[allow(clippy::single_element_loop)]
9673 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
9674 url = params.uri_replacement(url, param_name, find_this, true);
9675 }
9676 {
9677 let to_remove = ["parent"];
9678 params.remove_params(&to_remove);
9679 }
9680
9681 let url = params.parse_with_url(&url);
9682
9683 let mut json_mime_type = mime::APPLICATION_JSON;
9684 let mut request_value_reader = {
9685 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9686 common::remove_json_null_values(&mut value);
9687 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9688 serde_json::to_writer(&mut dst, &value).unwrap();
9689 dst
9690 };
9691 let request_size = request_value_reader
9692 .seek(std::io::SeekFrom::End(0))
9693 .unwrap();
9694 request_value_reader
9695 .seek(std::io::SeekFrom::Start(0))
9696 .unwrap();
9697
9698 loop {
9699 let token = match self
9700 .hub
9701 .auth
9702 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9703 .await
9704 {
9705 Ok(token) => token,
9706 Err(e) => match dlg.token(e) {
9707 Ok(token) => token,
9708 Err(e) => {
9709 dlg.finished(false);
9710 return Err(common::Error::MissingToken(e));
9711 }
9712 },
9713 };
9714 request_value_reader
9715 .seek(std::io::SeekFrom::Start(0))
9716 .unwrap();
9717 let mut req_result = {
9718 let client = &self.hub.client;
9719 dlg.pre_request();
9720 let mut req_builder = hyper::Request::builder()
9721 .method(hyper::Method::POST)
9722 .uri(url.as_str())
9723 .header(USER_AGENT, self.hub._user_agent.clone());
9724
9725 if let Some(token) = token.as_ref() {
9726 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9727 }
9728
9729 let request = req_builder
9730 .header(CONTENT_TYPE, json_mime_type.to_string())
9731 .header(CONTENT_LENGTH, request_size as u64)
9732 .body(common::to_body(
9733 request_value_reader.get_ref().clone().into(),
9734 ));
9735
9736 client.request(request.unwrap()).await
9737 };
9738
9739 match req_result {
9740 Err(err) => {
9741 if let common::Retry::After(d) = dlg.http_error(&err) {
9742 sleep(d).await;
9743 continue;
9744 }
9745 dlg.finished(false);
9746 return Err(common::Error::HttpError(err));
9747 }
9748 Ok(res) => {
9749 let (mut parts, body) = res.into_parts();
9750 let mut body = common::Body::new(body);
9751 if !parts.status.is_success() {
9752 let bytes = common::to_bytes(body).await.unwrap_or_default();
9753 let error = serde_json::from_str(&common::to_string(&bytes));
9754 let response = common::to_response(parts, bytes.into());
9755
9756 if let common::Retry::After(d) =
9757 dlg.http_failure(&response, error.as_ref().ok())
9758 {
9759 sleep(d).await;
9760 continue;
9761 }
9762
9763 dlg.finished(false);
9764
9765 return Err(match error {
9766 Ok(value) => common::Error::BadRequest(value),
9767 _ => common::Error::Failure(response),
9768 });
9769 }
9770 let response = {
9771 let bytes = common::to_bytes(body).await.unwrap_or_default();
9772 let encoded = common::to_string(&bytes);
9773 match serde_json::from_str(&encoded) {
9774 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9775 Err(error) => {
9776 dlg.response_json_decode_error(&encoded, &error);
9777 return Err(common::Error::JsonDecodeError(
9778 encoded.to_string(),
9779 error,
9780 ));
9781 }
9782 }
9783 };
9784
9785 dlg.finished(true);
9786 return Ok(response);
9787 }
9788 }
9789 }
9790 }
9791
9792 ///
9793 /// Sets the *request* property to the given value.
9794 ///
9795 /// Even though the property as already been set when instantiating this call,
9796 /// we provide this method for API completeness.
9797 pub fn request(
9798 mut self,
9799 new_value: EndpointPolicy,
9800 ) -> ProjectLocationEndpointPolicyCreateCall<'a, C> {
9801 self._request = new_value;
9802 self
9803 }
9804 /// Required. The parent resource of the EndpointPolicy. Must be in the format `projects/*/locations/*`.
9805 ///
9806 /// Sets the *parent* path property to the given value.
9807 ///
9808 /// Even though the property as already been set when instantiating this call,
9809 /// we provide this method for API completeness.
9810 pub fn parent(mut self, new_value: &str) -> ProjectLocationEndpointPolicyCreateCall<'a, C> {
9811 self._parent = new_value.to_string();
9812 self
9813 }
9814 /// Required. Short name of the EndpointPolicy resource to be created. E.g. "CustomECS".
9815 ///
9816 /// Sets the *endpoint policy id* query property to the given value.
9817 pub fn endpoint_policy_id(
9818 mut self,
9819 new_value: &str,
9820 ) -> ProjectLocationEndpointPolicyCreateCall<'a, C> {
9821 self._endpoint_policy_id = Some(new_value.to_string());
9822 self
9823 }
9824 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9825 /// while executing the actual API request.
9826 ///
9827 /// ````text
9828 /// It should be used to handle progress information, and to implement a certain level of resilience.
9829 /// ````
9830 ///
9831 /// Sets the *delegate* property to the given value.
9832 pub fn delegate(
9833 mut self,
9834 new_value: &'a mut dyn common::Delegate,
9835 ) -> ProjectLocationEndpointPolicyCreateCall<'a, C> {
9836 self._delegate = Some(new_value);
9837 self
9838 }
9839
9840 /// Set any additional parameter of the query string used in the request.
9841 /// It should be used to set parameters which are not yet available through their own
9842 /// setters.
9843 ///
9844 /// Please note that this method must not be used to set any of the known parameters
9845 /// which have their own setter method. If done anyway, the request will fail.
9846 ///
9847 /// # Additional Parameters
9848 ///
9849 /// * *$.xgafv* (query-string) - V1 error format.
9850 /// * *access_token* (query-string) - OAuth access token.
9851 /// * *alt* (query-string) - Data format for response.
9852 /// * *callback* (query-string) - JSONP
9853 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9854 /// * *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.
9855 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9856 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9857 /// * *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.
9858 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9859 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9860 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationEndpointPolicyCreateCall<'a, C>
9861 where
9862 T: AsRef<str>,
9863 {
9864 self._additional_params
9865 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9866 self
9867 }
9868
9869 /// Identifies the authorization scope for the method you are building.
9870 ///
9871 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9872 /// [`Scope::CloudPlatform`].
9873 ///
9874 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9875 /// tokens for more than one scope.
9876 ///
9877 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9878 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9879 /// sufficient, a read-write scope will do as well.
9880 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationEndpointPolicyCreateCall<'a, C>
9881 where
9882 St: AsRef<str>,
9883 {
9884 self._scopes.insert(String::from(scope.as_ref()));
9885 self
9886 }
9887 /// Identifies the authorization scope(s) for the method you are building.
9888 ///
9889 /// See [`Self::add_scope()`] for details.
9890 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationEndpointPolicyCreateCall<'a, C>
9891 where
9892 I: IntoIterator<Item = St>,
9893 St: AsRef<str>,
9894 {
9895 self._scopes
9896 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9897 self
9898 }
9899
9900 /// Removes all scopes, and no default scope will be used either.
9901 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9902 /// for details).
9903 pub fn clear_scopes(mut self) -> ProjectLocationEndpointPolicyCreateCall<'a, C> {
9904 self._scopes.clear();
9905 self
9906 }
9907}
9908
9909/// Deletes a single EndpointPolicy.
9910///
9911/// A builder for the *locations.endpointPolicies.delete* method supported by a *project* resource.
9912/// It is not used directly, but through a [`ProjectMethods`] instance.
9913///
9914/// # Example
9915///
9916/// Instantiate a resource method builder
9917///
9918/// ```test_harness,no_run
9919/// # extern crate hyper;
9920/// # extern crate hyper_rustls;
9921/// # extern crate google_networkservices1 as networkservices1;
9922/// # async fn dox() {
9923/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9924///
9925/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9926/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9927/// # .with_native_roots()
9928/// # .unwrap()
9929/// # .https_only()
9930/// # .enable_http2()
9931/// # .build();
9932///
9933/// # let executor = hyper_util::rt::TokioExecutor::new();
9934/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9935/// # secret,
9936/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9937/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9938/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9939/// # ),
9940/// # ).build().await.unwrap();
9941///
9942/// # let client = hyper_util::client::legacy::Client::builder(
9943/// # hyper_util::rt::TokioExecutor::new()
9944/// # )
9945/// # .build(
9946/// # hyper_rustls::HttpsConnectorBuilder::new()
9947/// # .with_native_roots()
9948/// # .unwrap()
9949/// # .https_or_http()
9950/// # .enable_http2()
9951/// # .build()
9952/// # );
9953/// # let mut hub = NetworkServices::new(client, auth);
9954/// // You can configure optional parameters by calling the respective setters at will, and
9955/// // execute the final call using `doit()`.
9956/// // Values shown here are possibly random and not representative !
9957/// let result = hub.projects().locations_endpoint_policies_delete("name")
9958/// .doit().await;
9959/// # }
9960/// ```
9961pub struct ProjectLocationEndpointPolicyDeleteCall<'a, C>
9962where
9963 C: 'a,
9964{
9965 hub: &'a NetworkServices<C>,
9966 _name: String,
9967 _delegate: Option<&'a mut dyn common::Delegate>,
9968 _additional_params: HashMap<String, String>,
9969 _scopes: BTreeSet<String>,
9970}
9971
9972impl<'a, C> common::CallBuilder for ProjectLocationEndpointPolicyDeleteCall<'a, C> {}
9973
9974impl<'a, C> ProjectLocationEndpointPolicyDeleteCall<'a, C>
9975where
9976 C: common::Connector,
9977{
9978 /// Perform the operation you have build so far.
9979 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
9980 use std::borrow::Cow;
9981 use std::io::{Read, Seek};
9982
9983 use common::{url::Params, ToParts};
9984 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9985
9986 let mut dd = common::DefaultDelegate;
9987 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9988 dlg.begin(common::MethodInfo {
9989 id: "networkservices.projects.locations.endpointPolicies.delete",
9990 http_method: hyper::Method::DELETE,
9991 });
9992
9993 for &field in ["alt", "name"].iter() {
9994 if self._additional_params.contains_key(field) {
9995 dlg.finished(false);
9996 return Err(common::Error::FieldClash(field));
9997 }
9998 }
9999
10000 let mut params = Params::with_capacity(3 + self._additional_params.len());
10001 params.push("name", self._name);
10002
10003 params.extend(self._additional_params.iter());
10004
10005 params.push("alt", "json");
10006 let mut url = self.hub._base_url.clone() + "v1/{+name}";
10007 if self._scopes.is_empty() {
10008 self._scopes
10009 .insert(Scope::CloudPlatform.as_ref().to_string());
10010 }
10011
10012 #[allow(clippy::single_element_loop)]
10013 for &(find_this, param_name) in [("{+name}", "name")].iter() {
10014 url = params.uri_replacement(url, param_name, find_this, true);
10015 }
10016 {
10017 let to_remove = ["name"];
10018 params.remove_params(&to_remove);
10019 }
10020
10021 let url = params.parse_with_url(&url);
10022
10023 loop {
10024 let token = match self
10025 .hub
10026 .auth
10027 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10028 .await
10029 {
10030 Ok(token) => token,
10031 Err(e) => match dlg.token(e) {
10032 Ok(token) => token,
10033 Err(e) => {
10034 dlg.finished(false);
10035 return Err(common::Error::MissingToken(e));
10036 }
10037 },
10038 };
10039 let mut req_result = {
10040 let client = &self.hub.client;
10041 dlg.pre_request();
10042 let mut req_builder = hyper::Request::builder()
10043 .method(hyper::Method::DELETE)
10044 .uri(url.as_str())
10045 .header(USER_AGENT, self.hub._user_agent.clone());
10046
10047 if let Some(token) = token.as_ref() {
10048 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10049 }
10050
10051 let request = req_builder
10052 .header(CONTENT_LENGTH, 0_u64)
10053 .body(common::to_body::<String>(None));
10054
10055 client.request(request.unwrap()).await
10056 };
10057
10058 match req_result {
10059 Err(err) => {
10060 if let common::Retry::After(d) = dlg.http_error(&err) {
10061 sleep(d).await;
10062 continue;
10063 }
10064 dlg.finished(false);
10065 return Err(common::Error::HttpError(err));
10066 }
10067 Ok(res) => {
10068 let (mut parts, body) = res.into_parts();
10069 let mut body = common::Body::new(body);
10070 if !parts.status.is_success() {
10071 let bytes = common::to_bytes(body).await.unwrap_or_default();
10072 let error = serde_json::from_str(&common::to_string(&bytes));
10073 let response = common::to_response(parts, bytes.into());
10074
10075 if let common::Retry::After(d) =
10076 dlg.http_failure(&response, error.as_ref().ok())
10077 {
10078 sleep(d).await;
10079 continue;
10080 }
10081
10082 dlg.finished(false);
10083
10084 return Err(match error {
10085 Ok(value) => common::Error::BadRequest(value),
10086 _ => common::Error::Failure(response),
10087 });
10088 }
10089 let response = {
10090 let bytes = common::to_bytes(body).await.unwrap_or_default();
10091 let encoded = common::to_string(&bytes);
10092 match serde_json::from_str(&encoded) {
10093 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10094 Err(error) => {
10095 dlg.response_json_decode_error(&encoded, &error);
10096 return Err(common::Error::JsonDecodeError(
10097 encoded.to_string(),
10098 error,
10099 ));
10100 }
10101 }
10102 };
10103
10104 dlg.finished(true);
10105 return Ok(response);
10106 }
10107 }
10108 }
10109 }
10110
10111 /// Required. A name of the EndpointPolicy to delete. Must be in the format `projects/*/locations/*/endpointPolicies/*`.
10112 ///
10113 /// Sets the *name* path property to the given value.
10114 ///
10115 /// Even though the property as already been set when instantiating this call,
10116 /// we provide this method for API completeness.
10117 pub fn name(mut self, new_value: &str) -> ProjectLocationEndpointPolicyDeleteCall<'a, C> {
10118 self._name = new_value.to_string();
10119 self
10120 }
10121 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10122 /// while executing the actual API request.
10123 ///
10124 /// ````text
10125 /// It should be used to handle progress information, and to implement a certain level of resilience.
10126 /// ````
10127 ///
10128 /// Sets the *delegate* property to the given value.
10129 pub fn delegate(
10130 mut self,
10131 new_value: &'a mut dyn common::Delegate,
10132 ) -> ProjectLocationEndpointPolicyDeleteCall<'a, C> {
10133 self._delegate = Some(new_value);
10134 self
10135 }
10136
10137 /// Set any additional parameter of the query string used in the request.
10138 /// It should be used to set parameters which are not yet available through their own
10139 /// setters.
10140 ///
10141 /// Please note that this method must not be used to set any of the known parameters
10142 /// which have their own setter method. If done anyway, the request will fail.
10143 ///
10144 /// # Additional Parameters
10145 ///
10146 /// * *$.xgafv* (query-string) - V1 error format.
10147 /// * *access_token* (query-string) - OAuth access token.
10148 /// * *alt* (query-string) - Data format for response.
10149 /// * *callback* (query-string) - JSONP
10150 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10151 /// * *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.
10152 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10153 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10154 /// * *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.
10155 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10156 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10157 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationEndpointPolicyDeleteCall<'a, C>
10158 where
10159 T: AsRef<str>,
10160 {
10161 self._additional_params
10162 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10163 self
10164 }
10165
10166 /// Identifies the authorization scope for the method you are building.
10167 ///
10168 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10169 /// [`Scope::CloudPlatform`].
10170 ///
10171 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10172 /// tokens for more than one scope.
10173 ///
10174 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10175 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10176 /// sufficient, a read-write scope will do as well.
10177 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationEndpointPolicyDeleteCall<'a, C>
10178 where
10179 St: AsRef<str>,
10180 {
10181 self._scopes.insert(String::from(scope.as_ref()));
10182 self
10183 }
10184 /// Identifies the authorization scope(s) for the method you are building.
10185 ///
10186 /// See [`Self::add_scope()`] for details.
10187 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationEndpointPolicyDeleteCall<'a, C>
10188 where
10189 I: IntoIterator<Item = St>,
10190 St: AsRef<str>,
10191 {
10192 self._scopes
10193 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10194 self
10195 }
10196
10197 /// Removes all scopes, and no default scope will be used either.
10198 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10199 /// for details).
10200 pub fn clear_scopes(mut self) -> ProjectLocationEndpointPolicyDeleteCall<'a, C> {
10201 self._scopes.clear();
10202 self
10203 }
10204}
10205
10206/// Gets details of a single EndpointPolicy.
10207///
10208/// A builder for the *locations.endpointPolicies.get* method supported by a *project* resource.
10209/// It is not used directly, but through a [`ProjectMethods`] instance.
10210///
10211/// # Example
10212///
10213/// Instantiate a resource method builder
10214///
10215/// ```test_harness,no_run
10216/// # extern crate hyper;
10217/// # extern crate hyper_rustls;
10218/// # extern crate google_networkservices1 as networkservices1;
10219/// # async fn dox() {
10220/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10221///
10222/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10223/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10224/// # .with_native_roots()
10225/// # .unwrap()
10226/// # .https_only()
10227/// # .enable_http2()
10228/// # .build();
10229///
10230/// # let executor = hyper_util::rt::TokioExecutor::new();
10231/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10232/// # secret,
10233/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10234/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10235/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10236/// # ),
10237/// # ).build().await.unwrap();
10238///
10239/// # let client = hyper_util::client::legacy::Client::builder(
10240/// # hyper_util::rt::TokioExecutor::new()
10241/// # )
10242/// # .build(
10243/// # hyper_rustls::HttpsConnectorBuilder::new()
10244/// # .with_native_roots()
10245/// # .unwrap()
10246/// # .https_or_http()
10247/// # .enable_http2()
10248/// # .build()
10249/// # );
10250/// # let mut hub = NetworkServices::new(client, auth);
10251/// // You can configure optional parameters by calling the respective setters at will, and
10252/// // execute the final call using `doit()`.
10253/// // Values shown here are possibly random and not representative !
10254/// let result = hub.projects().locations_endpoint_policies_get("name")
10255/// .doit().await;
10256/// # }
10257/// ```
10258pub struct ProjectLocationEndpointPolicyGetCall<'a, C>
10259where
10260 C: 'a,
10261{
10262 hub: &'a NetworkServices<C>,
10263 _name: String,
10264 _delegate: Option<&'a mut dyn common::Delegate>,
10265 _additional_params: HashMap<String, String>,
10266 _scopes: BTreeSet<String>,
10267}
10268
10269impl<'a, C> common::CallBuilder for ProjectLocationEndpointPolicyGetCall<'a, C> {}
10270
10271impl<'a, C> ProjectLocationEndpointPolicyGetCall<'a, C>
10272where
10273 C: common::Connector,
10274{
10275 /// Perform the operation you have build so far.
10276 pub async fn doit(mut self) -> common::Result<(common::Response, EndpointPolicy)> {
10277 use std::borrow::Cow;
10278 use std::io::{Read, Seek};
10279
10280 use common::{url::Params, ToParts};
10281 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10282
10283 let mut dd = common::DefaultDelegate;
10284 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10285 dlg.begin(common::MethodInfo {
10286 id: "networkservices.projects.locations.endpointPolicies.get",
10287 http_method: hyper::Method::GET,
10288 });
10289
10290 for &field in ["alt", "name"].iter() {
10291 if self._additional_params.contains_key(field) {
10292 dlg.finished(false);
10293 return Err(common::Error::FieldClash(field));
10294 }
10295 }
10296
10297 let mut params = Params::with_capacity(3 + self._additional_params.len());
10298 params.push("name", self._name);
10299
10300 params.extend(self._additional_params.iter());
10301
10302 params.push("alt", "json");
10303 let mut url = self.hub._base_url.clone() + "v1/{+name}";
10304 if self._scopes.is_empty() {
10305 self._scopes
10306 .insert(Scope::CloudPlatform.as_ref().to_string());
10307 }
10308
10309 #[allow(clippy::single_element_loop)]
10310 for &(find_this, param_name) in [("{+name}", "name")].iter() {
10311 url = params.uri_replacement(url, param_name, find_this, true);
10312 }
10313 {
10314 let to_remove = ["name"];
10315 params.remove_params(&to_remove);
10316 }
10317
10318 let url = params.parse_with_url(&url);
10319
10320 loop {
10321 let token = match self
10322 .hub
10323 .auth
10324 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10325 .await
10326 {
10327 Ok(token) => token,
10328 Err(e) => match dlg.token(e) {
10329 Ok(token) => token,
10330 Err(e) => {
10331 dlg.finished(false);
10332 return Err(common::Error::MissingToken(e));
10333 }
10334 },
10335 };
10336 let mut req_result = {
10337 let client = &self.hub.client;
10338 dlg.pre_request();
10339 let mut req_builder = hyper::Request::builder()
10340 .method(hyper::Method::GET)
10341 .uri(url.as_str())
10342 .header(USER_AGENT, self.hub._user_agent.clone());
10343
10344 if let Some(token) = token.as_ref() {
10345 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10346 }
10347
10348 let request = req_builder
10349 .header(CONTENT_LENGTH, 0_u64)
10350 .body(common::to_body::<String>(None));
10351
10352 client.request(request.unwrap()).await
10353 };
10354
10355 match req_result {
10356 Err(err) => {
10357 if let common::Retry::After(d) = dlg.http_error(&err) {
10358 sleep(d).await;
10359 continue;
10360 }
10361 dlg.finished(false);
10362 return Err(common::Error::HttpError(err));
10363 }
10364 Ok(res) => {
10365 let (mut parts, body) = res.into_parts();
10366 let mut body = common::Body::new(body);
10367 if !parts.status.is_success() {
10368 let bytes = common::to_bytes(body).await.unwrap_or_default();
10369 let error = serde_json::from_str(&common::to_string(&bytes));
10370 let response = common::to_response(parts, bytes.into());
10371
10372 if let common::Retry::After(d) =
10373 dlg.http_failure(&response, error.as_ref().ok())
10374 {
10375 sleep(d).await;
10376 continue;
10377 }
10378
10379 dlg.finished(false);
10380
10381 return Err(match error {
10382 Ok(value) => common::Error::BadRequest(value),
10383 _ => common::Error::Failure(response),
10384 });
10385 }
10386 let response = {
10387 let bytes = common::to_bytes(body).await.unwrap_or_default();
10388 let encoded = common::to_string(&bytes);
10389 match serde_json::from_str(&encoded) {
10390 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10391 Err(error) => {
10392 dlg.response_json_decode_error(&encoded, &error);
10393 return Err(common::Error::JsonDecodeError(
10394 encoded.to_string(),
10395 error,
10396 ));
10397 }
10398 }
10399 };
10400
10401 dlg.finished(true);
10402 return Ok(response);
10403 }
10404 }
10405 }
10406 }
10407
10408 /// Required. A name of the EndpointPolicy to get. Must be in the format `projects/*/locations/*/endpointPolicies/*`.
10409 ///
10410 /// Sets the *name* path property to the given value.
10411 ///
10412 /// Even though the property as already been set when instantiating this call,
10413 /// we provide this method for API completeness.
10414 pub fn name(mut self, new_value: &str) -> ProjectLocationEndpointPolicyGetCall<'a, C> {
10415 self._name = new_value.to_string();
10416 self
10417 }
10418 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10419 /// while executing the actual API request.
10420 ///
10421 /// ````text
10422 /// It should be used to handle progress information, and to implement a certain level of resilience.
10423 /// ````
10424 ///
10425 /// Sets the *delegate* property to the given value.
10426 pub fn delegate(
10427 mut self,
10428 new_value: &'a mut dyn common::Delegate,
10429 ) -> ProjectLocationEndpointPolicyGetCall<'a, C> {
10430 self._delegate = Some(new_value);
10431 self
10432 }
10433
10434 /// Set any additional parameter of the query string used in the request.
10435 /// It should be used to set parameters which are not yet available through their own
10436 /// setters.
10437 ///
10438 /// Please note that this method must not be used to set any of the known parameters
10439 /// which have their own setter method. If done anyway, the request will fail.
10440 ///
10441 /// # Additional Parameters
10442 ///
10443 /// * *$.xgafv* (query-string) - V1 error format.
10444 /// * *access_token* (query-string) - OAuth access token.
10445 /// * *alt* (query-string) - Data format for response.
10446 /// * *callback* (query-string) - JSONP
10447 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10448 /// * *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.
10449 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10450 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10451 /// * *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.
10452 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10453 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10454 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationEndpointPolicyGetCall<'a, C>
10455 where
10456 T: AsRef<str>,
10457 {
10458 self._additional_params
10459 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10460 self
10461 }
10462
10463 /// Identifies the authorization scope for the method you are building.
10464 ///
10465 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10466 /// [`Scope::CloudPlatform`].
10467 ///
10468 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10469 /// tokens for more than one scope.
10470 ///
10471 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10472 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10473 /// sufficient, a read-write scope will do as well.
10474 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationEndpointPolicyGetCall<'a, C>
10475 where
10476 St: AsRef<str>,
10477 {
10478 self._scopes.insert(String::from(scope.as_ref()));
10479 self
10480 }
10481 /// Identifies the authorization scope(s) for the method you are building.
10482 ///
10483 /// See [`Self::add_scope()`] for details.
10484 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationEndpointPolicyGetCall<'a, C>
10485 where
10486 I: IntoIterator<Item = St>,
10487 St: AsRef<str>,
10488 {
10489 self._scopes
10490 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10491 self
10492 }
10493
10494 /// Removes all scopes, and no default scope will be used either.
10495 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10496 /// for details).
10497 pub fn clear_scopes(mut self) -> ProjectLocationEndpointPolicyGetCall<'a, C> {
10498 self._scopes.clear();
10499 self
10500 }
10501}
10502
10503/// Lists EndpointPolicies in a given project and location.
10504///
10505/// A builder for the *locations.endpointPolicies.list* method supported by a *project* resource.
10506/// It is not used directly, but through a [`ProjectMethods`] instance.
10507///
10508/// # Example
10509///
10510/// Instantiate a resource method builder
10511///
10512/// ```test_harness,no_run
10513/// # extern crate hyper;
10514/// # extern crate hyper_rustls;
10515/// # extern crate google_networkservices1 as networkservices1;
10516/// # async fn dox() {
10517/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10518///
10519/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10520/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10521/// # .with_native_roots()
10522/// # .unwrap()
10523/// # .https_only()
10524/// # .enable_http2()
10525/// # .build();
10526///
10527/// # let executor = hyper_util::rt::TokioExecutor::new();
10528/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10529/// # secret,
10530/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10531/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10532/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10533/// # ),
10534/// # ).build().await.unwrap();
10535///
10536/// # let client = hyper_util::client::legacy::Client::builder(
10537/// # hyper_util::rt::TokioExecutor::new()
10538/// # )
10539/// # .build(
10540/// # hyper_rustls::HttpsConnectorBuilder::new()
10541/// # .with_native_roots()
10542/// # .unwrap()
10543/// # .https_or_http()
10544/// # .enable_http2()
10545/// # .build()
10546/// # );
10547/// # let mut hub = NetworkServices::new(client, auth);
10548/// // You can configure optional parameters by calling the respective setters at will, and
10549/// // execute the final call using `doit()`.
10550/// // Values shown here are possibly random and not representative !
10551/// let result = hub.projects().locations_endpoint_policies_list("parent")
10552/// .return_partial_success(false)
10553/// .page_token("sed")
10554/// .page_size(-61)
10555/// .doit().await;
10556/// # }
10557/// ```
10558pub struct ProjectLocationEndpointPolicyListCall<'a, C>
10559where
10560 C: 'a,
10561{
10562 hub: &'a NetworkServices<C>,
10563 _parent: String,
10564 _return_partial_success: Option<bool>,
10565 _page_token: Option<String>,
10566 _page_size: Option<i32>,
10567 _delegate: Option<&'a mut dyn common::Delegate>,
10568 _additional_params: HashMap<String, String>,
10569 _scopes: BTreeSet<String>,
10570}
10571
10572impl<'a, C> common::CallBuilder for ProjectLocationEndpointPolicyListCall<'a, C> {}
10573
10574impl<'a, C> ProjectLocationEndpointPolicyListCall<'a, C>
10575where
10576 C: common::Connector,
10577{
10578 /// Perform the operation you have build so far.
10579 pub async fn doit(
10580 mut self,
10581 ) -> common::Result<(common::Response, ListEndpointPoliciesResponse)> {
10582 use std::borrow::Cow;
10583 use std::io::{Read, Seek};
10584
10585 use common::{url::Params, ToParts};
10586 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10587
10588 let mut dd = common::DefaultDelegate;
10589 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10590 dlg.begin(common::MethodInfo {
10591 id: "networkservices.projects.locations.endpointPolicies.list",
10592 http_method: hyper::Method::GET,
10593 });
10594
10595 for &field in [
10596 "alt",
10597 "parent",
10598 "returnPartialSuccess",
10599 "pageToken",
10600 "pageSize",
10601 ]
10602 .iter()
10603 {
10604 if self._additional_params.contains_key(field) {
10605 dlg.finished(false);
10606 return Err(common::Error::FieldClash(field));
10607 }
10608 }
10609
10610 let mut params = Params::with_capacity(6 + self._additional_params.len());
10611 params.push("parent", self._parent);
10612 if let Some(value) = self._return_partial_success.as_ref() {
10613 params.push("returnPartialSuccess", value.to_string());
10614 }
10615 if let Some(value) = self._page_token.as_ref() {
10616 params.push("pageToken", value);
10617 }
10618 if let Some(value) = self._page_size.as_ref() {
10619 params.push("pageSize", value.to_string());
10620 }
10621
10622 params.extend(self._additional_params.iter());
10623
10624 params.push("alt", "json");
10625 let mut url = self.hub._base_url.clone() + "v1/{+parent}/endpointPolicies";
10626 if self._scopes.is_empty() {
10627 self._scopes
10628 .insert(Scope::CloudPlatform.as_ref().to_string());
10629 }
10630
10631 #[allow(clippy::single_element_loop)]
10632 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
10633 url = params.uri_replacement(url, param_name, find_this, true);
10634 }
10635 {
10636 let to_remove = ["parent"];
10637 params.remove_params(&to_remove);
10638 }
10639
10640 let url = params.parse_with_url(&url);
10641
10642 loop {
10643 let token = match self
10644 .hub
10645 .auth
10646 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10647 .await
10648 {
10649 Ok(token) => token,
10650 Err(e) => match dlg.token(e) {
10651 Ok(token) => token,
10652 Err(e) => {
10653 dlg.finished(false);
10654 return Err(common::Error::MissingToken(e));
10655 }
10656 },
10657 };
10658 let mut req_result = {
10659 let client = &self.hub.client;
10660 dlg.pre_request();
10661 let mut req_builder = hyper::Request::builder()
10662 .method(hyper::Method::GET)
10663 .uri(url.as_str())
10664 .header(USER_AGENT, self.hub._user_agent.clone());
10665
10666 if let Some(token) = token.as_ref() {
10667 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10668 }
10669
10670 let request = req_builder
10671 .header(CONTENT_LENGTH, 0_u64)
10672 .body(common::to_body::<String>(None));
10673
10674 client.request(request.unwrap()).await
10675 };
10676
10677 match req_result {
10678 Err(err) => {
10679 if let common::Retry::After(d) = dlg.http_error(&err) {
10680 sleep(d).await;
10681 continue;
10682 }
10683 dlg.finished(false);
10684 return Err(common::Error::HttpError(err));
10685 }
10686 Ok(res) => {
10687 let (mut parts, body) = res.into_parts();
10688 let mut body = common::Body::new(body);
10689 if !parts.status.is_success() {
10690 let bytes = common::to_bytes(body).await.unwrap_or_default();
10691 let error = serde_json::from_str(&common::to_string(&bytes));
10692 let response = common::to_response(parts, bytes.into());
10693
10694 if let common::Retry::After(d) =
10695 dlg.http_failure(&response, error.as_ref().ok())
10696 {
10697 sleep(d).await;
10698 continue;
10699 }
10700
10701 dlg.finished(false);
10702
10703 return Err(match error {
10704 Ok(value) => common::Error::BadRequest(value),
10705 _ => common::Error::Failure(response),
10706 });
10707 }
10708 let response = {
10709 let bytes = common::to_bytes(body).await.unwrap_or_default();
10710 let encoded = common::to_string(&bytes);
10711 match serde_json::from_str(&encoded) {
10712 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10713 Err(error) => {
10714 dlg.response_json_decode_error(&encoded, &error);
10715 return Err(common::Error::JsonDecodeError(
10716 encoded.to_string(),
10717 error,
10718 ));
10719 }
10720 }
10721 };
10722
10723 dlg.finished(true);
10724 return Ok(response);
10725 }
10726 }
10727 }
10728 }
10729
10730 /// Required. The project and location from which the EndpointPolicies should be listed, specified in the format `projects/*/locations/*`.
10731 ///
10732 /// Sets the *parent* path property to the given value.
10733 ///
10734 /// Even though the property as already been set when instantiating this call,
10735 /// we provide this method for API completeness.
10736 pub fn parent(mut self, new_value: &str) -> ProjectLocationEndpointPolicyListCall<'a, C> {
10737 self._parent = new_value.to_string();
10738 self
10739 }
10740 /// Optional. If true, allow partial responses for multi-regional Aggregated List requests. Otherwise if one of the locations is down or unreachable, the Aggregated List request will fail.
10741 ///
10742 /// Sets the *return partial success* query property to the given value.
10743 pub fn return_partial_success(
10744 mut self,
10745 new_value: bool,
10746 ) -> ProjectLocationEndpointPolicyListCall<'a, C> {
10747 self._return_partial_success = Some(new_value);
10748 self
10749 }
10750 /// The value returned by the last `ListEndpointPoliciesResponse` Indicates that this is a continuation of a prior `ListEndpointPolicies` call, and that the system should return the next page of data.
10751 ///
10752 /// Sets the *page token* query property to the given value.
10753 pub fn page_token(mut self, new_value: &str) -> ProjectLocationEndpointPolicyListCall<'a, C> {
10754 self._page_token = Some(new_value.to_string());
10755 self
10756 }
10757 /// Maximum number of EndpointPolicies to return per call.
10758 ///
10759 /// Sets the *page size* query property to the given value.
10760 pub fn page_size(mut self, new_value: i32) -> ProjectLocationEndpointPolicyListCall<'a, C> {
10761 self._page_size = Some(new_value);
10762 self
10763 }
10764 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10765 /// while executing the actual API request.
10766 ///
10767 /// ````text
10768 /// It should be used to handle progress information, and to implement a certain level of resilience.
10769 /// ````
10770 ///
10771 /// Sets the *delegate* property to the given value.
10772 pub fn delegate(
10773 mut self,
10774 new_value: &'a mut dyn common::Delegate,
10775 ) -> ProjectLocationEndpointPolicyListCall<'a, C> {
10776 self._delegate = Some(new_value);
10777 self
10778 }
10779
10780 /// Set any additional parameter of the query string used in the request.
10781 /// It should be used to set parameters which are not yet available through their own
10782 /// setters.
10783 ///
10784 /// Please note that this method must not be used to set any of the known parameters
10785 /// which have their own setter method. If done anyway, the request will fail.
10786 ///
10787 /// # Additional Parameters
10788 ///
10789 /// * *$.xgafv* (query-string) - V1 error format.
10790 /// * *access_token* (query-string) - OAuth access token.
10791 /// * *alt* (query-string) - Data format for response.
10792 /// * *callback* (query-string) - JSONP
10793 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10794 /// * *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.
10795 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10796 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10797 /// * *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.
10798 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10799 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10800 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationEndpointPolicyListCall<'a, C>
10801 where
10802 T: AsRef<str>,
10803 {
10804 self._additional_params
10805 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10806 self
10807 }
10808
10809 /// Identifies the authorization scope for the method you are building.
10810 ///
10811 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10812 /// [`Scope::CloudPlatform`].
10813 ///
10814 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10815 /// tokens for more than one scope.
10816 ///
10817 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10818 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10819 /// sufficient, a read-write scope will do as well.
10820 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationEndpointPolicyListCall<'a, C>
10821 where
10822 St: AsRef<str>,
10823 {
10824 self._scopes.insert(String::from(scope.as_ref()));
10825 self
10826 }
10827 /// Identifies the authorization scope(s) for the method you are building.
10828 ///
10829 /// See [`Self::add_scope()`] for details.
10830 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationEndpointPolicyListCall<'a, C>
10831 where
10832 I: IntoIterator<Item = St>,
10833 St: AsRef<str>,
10834 {
10835 self._scopes
10836 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10837 self
10838 }
10839
10840 /// Removes all scopes, and no default scope will be used either.
10841 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10842 /// for details).
10843 pub fn clear_scopes(mut self) -> ProjectLocationEndpointPolicyListCall<'a, C> {
10844 self._scopes.clear();
10845 self
10846 }
10847}
10848
10849/// Updates the parameters of a single EndpointPolicy.
10850///
10851/// A builder for the *locations.endpointPolicies.patch* method supported by a *project* resource.
10852/// It is not used directly, but through a [`ProjectMethods`] instance.
10853///
10854/// # Example
10855///
10856/// Instantiate a resource method builder
10857///
10858/// ```test_harness,no_run
10859/// # extern crate hyper;
10860/// # extern crate hyper_rustls;
10861/// # extern crate google_networkservices1 as networkservices1;
10862/// use networkservices1::api::EndpointPolicy;
10863/// # async fn dox() {
10864/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10865///
10866/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10867/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10868/// # .with_native_roots()
10869/// # .unwrap()
10870/// # .https_only()
10871/// # .enable_http2()
10872/// # .build();
10873///
10874/// # let executor = hyper_util::rt::TokioExecutor::new();
10875/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10876/// # secret,
10877/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10878/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10879/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10880/// # ),
10881/// # ).build().await.unwrap();
10882///
10883/// # let client = hyper_util::client::legacy::Client::builder(
10884/// # hyper_util::rt::TokioExecutor::new()
10885/// # )
10886/// # .build(
10887/// # hyper_rustls::HttpsConnectorBuilder::new()
10888/// # .with_native_roots()
10889/// # .unwrap()
10890/// # .https_or_http()
10891/// # .enable_http2()
10892/// # .build()
10893/// # );
10894/// # let mut hub = NetworkServices::new(client, auth);
10895/// // As the method needs a request, you would usually fill it with the desired information
10896/// // into the respective structure. Some of the parts shown here might not be applicable !
10897/// // Values shown here are possibly random and not representative !
10898/// let mut req = EndpointPolicy::default();
10899///
10900/// // You can configure optional parameters by calling the respective setters at will, and
10901/// // execute the final call using `doit()`.
10902/// // Values shown here are possibly random and not representative !
10903/// let result = hub.projects().locations_endpoint_policies_patch(req, "name")
10904/// .update_mask(FieldMask::new::<&str>(&[]))
10905/// .doit().await;
10906/// # }
10907/// ```
10908pub struct ProjectLocationEndpointPolicyPatchCall<'a, C>
10909where
10910 C: 'a,
10911{
10912 hub: &'a NetworkServices<C>,
10913 _request: EndpointPolicy,
10914 _name: String,
10915 _update_mask: Option<common::FieldMask>,
10916 _delegate: Option<&'a mut dyn common::Delegate>,
10917 _additional_params: HashMap<String, String>,
10918 _scopes: BTreeSet<String>,
10919}
10920
10921impl<'a, C> common::CallBuilder for ProjectLocationEndpointPolicyPatchCall<'a, C> {}
10922
10923impl<'a, C> ProjectLocationEndpointPolicyPatchCall<'a, C>
10924where
10925 C: common::Connector,
10926{
10927 /// Perform the operation you have build so far.
10928 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
10929 use std::borrow::Cow;
10930 use std::io::{Read, Seek};
10931
10932 use common::{url::Params, ToParts};
10933 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10934
10935 let mut dd = common::DefaultDelegate;
10936 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10937 dlg.begin(common::MethodInfo {
10938 id: "networkservices.projects.locations.endpointPolicies.patch",
10939 http_method: hyper::Method::PATCH,
10940 });
10941
10942 for &field in ["alt", "name", "updateMask"].iter() {
10943 if self._additional_params.contains_key(field) {
10944 dlg.finished(false);
10945 return Err(common::Error::FieldClash(field));
10946 }
10947 }
10948
10949 let mut params = Params::with_capacity(5 + self._additional_params.len());
10950 params.push("name", self._name);
10951 if let Some(value) = self._update_mask.as_ref() {
10952 params.push("updateMask", value.to_string());
10953 }
10954
10955 params.extend(self._additional_params.iter());
10956
10957 params.push("alt", "json");
10958 let mut url = self.hub._base_url.clone() + "v1/{+name}";
10959 if self._scopes.is_empty() {
10960 self._scopes
10961 .insert(Scope::CloudPlatform.as_ref().to_string());
10962 }
10963
10964 #[allow(clippy::single_element_loop)]
10965 for &(find_this, param_name) in [("{+name}", "name")].iter() {
10966 url = params.uri_replacement(url, param_name, find_this, true);
10967 }
10968 {
10969 let to_remove = ["name"];
10970 params.remove_params(&to_remove);
10971 }
10972
10973 let url = params.parse_with_url(&url);
10974
10975 let mut json_mime_type = mime::APPLICATION_JSON;
10976 let mut request_value_reader = {
10977 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10978 common::remove_json_null_values(&mut value);
10979 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10980 serde_json::to_writer(&mut dst, &value).unwrap();
10981 dst
10982 };
10983 let request_size = request_value_reader
10984 .seek(std::io::SeekFrom::End(0))
10985 .unwrap();
10986 request_value_reader
10987 .seek(std::io::SeekFrom::Start(0))
10988 .unwrap();
10989
10990 loop {
10991 let token = match self
10992 .hub
10993 .auth
10994 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10995 .await
10996 {
10997 Ok(token) => token,
10998 Err(e) => match dlg.token(e) {
10999 Ok(token) => token,
11000 Err(e) => {
11001 dlg.finished(false);
11002 return Err(common::Error::MissingToken(e));
11003 }
11004 },
11005 };
11006 request_value_reader
11007 .seek(std::io::SeekFrom::Start(0))
11008 .unwrap();
11009 let mut req_result = {
11010 let client = &self.hub.client;
11011 dlg.pre_request();
11012 let mut req_builder = hyper::Request::builder()
11013 .method(hyper::Method::PATCH)
11014 .uri(url.as_str())
11015 .header(USER_AGENT, self.hub._user_agent.clone());
11016
11017 if let Some(token) = token.as_ref() {
11018 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11019 }
11020
11021 let request = req_builder
11022 .header(CONTENT_TYPE, json_mime_type.to_string())
11023 .header(CONTENT_LENGTH, request_size as u64)
11024 .body(common::to_body(
11025 request_value_reader.get_ref().clone().into(),
11026 ));
11027
11028 client.request(request.unwrap()).await
11029 };
11030
11031 match req_result {
11032 Err(err) => {
11033 if let common::Retry::After(d) = dlg.http_error(&err) {
11034 sleep(d).await;
11035 continue;
11036 }
11037 dlg.finished(false);
11038 return Err(common::Error::HttpError(err));
11039 }
11040 Ok(res) => {
11041 let (mut parts, body) = res.into_parts();
11042 let mut body = common::Body::new(body);
11043 if !parts.status.is_success() {
11044 let bytes = common::to_bytes(body).await.unwrap_or_default();
11045 let error = serde_json::from_str(&common::to_string(&bytes));
11046 let response = common::to_response(parts, bytes.into());
11047
11048 if let common::Retry::After(d) =
11049 dlg.http_failure(&response, error.as_ref().ok())
11050 {
11051 sleep(d).await;
11052 continue;
11053 }
11054
11055 dlg.finished(false);
11056
11057 return Err(match error {
11058 Ok(value) => common::Error::BadRequest(value),
11059 _ => common::Error::Failure(response),
11060 });
11061 }
11062 let response = {
11063 let bytes = common::to_bytes(body).await.unwrap_or_default();
11064 let encoded = common::to_string(&bytes);
11065 match serde_json::from_str(&encoded) {
11066 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11067 Err(error) => {
11068 dlg.response_json_decode_error(&encoded, &error);
11069 return Err(common::Error::JsonDecodeError(
11070 encoded.to_string(),
11071 error,
11072 ));
11073 }
11074 }
11075 };
11076
11077 dlg.finished(true);
11078 return Ok(response);
11079 }
11080 }
11081 }
11082 }
11083
11084 ///
11085 /// Sets the *request* property to the given value.
11086 ///
11087 /// Even though the property as already been set when instantiating this call,
11088 /// we provide this method for API completeness.
11089 pub fn request(
11090 mut self,
11091 new_value: EndpointPolicy,
11092 ) -> ProjectLocationEndpointPolicyPatchCall<'a, C> {
11093 self._request = new_value;
11094 self
11095 }
11096 /// Identifier. Name of the EndpointPolicy resource. It matches pattern `projects/{project}/locations/*/endpointPolicies/{endpoint_policy}`.
11097 ///
11098 /// Sets the *name* path property to the given value.
11099 ///
11100 /// Even though the property as already been set when instantiating this call,
11101 /// we provide this method for API completeness.
11102 pub fn name(mut self, new_value: &str) -> ProjectLocationEndpointPolicyPatchCall<'a, C> {
11103 self._name = new_value.to_string();
11104 self
11105 }
11106 /// Optional. Field mask is used to specify the fields to be overwritten in the EndpointPolicy 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.
11107 ///
11108 /// Sets the *update mask* query property to the given value.
11109 pub fn update_mask(
11110 mut self,
11111 new_value: common::FieldMask,
11112 ) -> ProjectLocationEndpointPolicyPatchCall<'a, C> {
11113 self._update_mask = Some(new_value);
11114 self
11115 }
11116 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11117 /// while executing the actual API request.
11118 ///
11119 /// ````text
11120 /// It should be used to handle progress information, and to implement a certain level of resilience.
11121 /// ````
11122 ///
11123 /// Sets the *delegate* property to the given value.
11124 pub fn delegate(
11125 mut self,
11126 new_value: &'a mut dyn common::Delegate,
11127 ) -> ProjectLocationEndpointPolicyPatchCall<'a, C> {
11128 self._delegate = Some(new_value);
11129 self
11130 }
11131
11132 /// Set any additional parameter of the query string used in the request.
11133 /// It should be used to set parameters which are not yet available through their own
11134 /// setters.
11135 ///
11136 /// Please note that this method must not be used to set any of the known parameters
11137 /// which have their own setter method. If done anyway, the request will fail.
11138 ///
11139 /// # Additional Parameters
11140 ///
11141 /// * *$.xgafv* (query-string) - V1 error format.
11142 /// * *access_token* (query-string) - OAuth access token.
11143 /// * *alt* (query-string) - Data format for response.
11144 /// * *callback* (query-string) - JSONP
11145 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11146 /// * *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.
11147 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11148 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11149 /// * *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.
11150 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11151 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11152 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationEndpointPolicyPatchCall<'a, C>
11153 where
11154 T: AsRef<str>,
11155 {
11156 self._additional_params
11157 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11158 self
11159 }
11160
11161 /// Identifies the authorization scope for the method you are building.
11162 ///
11163 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11164 /// [`Scope::CloudPlatform`].
11165 ///
11166 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11167 /// tokens for more than one scope.
11168 ///
11169 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11170 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11171 /// sufficient, a read-write scope will do as well.
11172 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationEndpointPolicyPatchCall<'a, C>
11173 where
11174 St: AsRef<str>,
11175 {
11176 self._scopes.insert(String::from(scope.as_ref()));
11177 self
11178 }
11179 /// Identifies the authorization scope(s) for the method you are building.
11180 ///
11181 /// See [`Self::add_scope()`] for details.
11182 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationEndpointPolicyPatchCall<'a, C>
11183 where
11184 I: IntoIterator<Item = St>,
11185 St: AsRef<str>,
11186 {
11187 self._scopes
11188 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11189 self
11190 }
11191
11192 /// Removes all scopes, and no default scope will be used either.
11193 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11194 /// for details).
11195 pub fn clear_scopes(mut self) -> ProjectLocationEndpointPolicyPatchCall<'a, C> {
11196 self._scopes.clear();
11197 self
11198 }
11199}
11200
11201/// Get a single RouteView of a Gateway.
11202///
11203/// A builder for the *locations.gateways.routeViews.get* method supported by a *project* resource.
11204/// It is not used directly, but through a [`ProjectMethods`] instance.
11205///
11206/// # Example
11207///
11208/// Instantiate a resource method builder
11209///
11210/// ```test_harness,no_run
11211/// # extern crate hyper;
11212/// # extern crate hyper_rustls;
11213/// # extern crate google_networkservices1 as networkservices1;
11214/// # async fn dox() {
11215/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11216///
11217/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11218/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11219/// # .with_native_roots()
11220/// # .unwrap()
11221/// # .https_only()
11222/// # .enable_http2()
11223/// # .build();
11224///
11225/// # let executor = hyper_util::rt::TokioExecutor::new();
11226/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11227/// # secret,
11228/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11229/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11230/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11231/// # ),
11232/// # ).build().await.unwrap();
11233///
11234/// # let client = hyper_util::client::legacy::Client::builder(
11235/// # hyper_util::rt::TokioExecutor::new()
11236/// # )
11237/// # .build(
11238/// # hyper_rustls::HttpsConnectorBuilder::new()
11239/// # .with_native_roots()
11240/// # .unwrap()
11241/// # .https_or_http()
11242/// # .enable_http2()
11243/// # .build()
11244/// # );
11245/// # let mut hub = NetworkServices::new(client, auth);
11246/// // You can configure optional parameters by calling the respective setters at will, and
11247/// // execute the final call using `doit()`.
11248/// // Values shown here are possibly random and not representative !
11249/// let result = hub.projects().locations_gateways_route_views_get("name")
11250/// .doit().await;
11251/// # }
11252/// ```
11253pub struct ProjectLocationGatewayRouteViewGetCall<'a, C>
11254where
11255 C: 'a,
11256{
11257 hub: &'a NetworkServices<C>,
11258 _name: String,
11259 _delegate: Option<&'a mut dyn common::Delegate>,
11260 _additional_params: HashMap<String, String>,
11261 _scopes: BTreeSet<String>,
11262}
11263
11264impl<'a, C> common::CallBuilder for ProjectLocationGatewayRouteViewGetCall<'a, C> {}
11265
11266impl<'a, C> ProjectLocationGatewayRouteViewGetCall<'a, C>
11267where
11268 C: common::Connector,
11269{
11270 /// Perform the operation you have build so far.
11271 pub async fn doit(mut self) -> common::Result<(common::Response, GatewayRouteView)> {
11272 use std::borrow::Cow;
11273 use std::io::{Read, Seek};
11274
11275 use common::{url::Params, ToParts};
11276 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11277
11278 let mut dd = common::DefaultDelegate;
11279 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11280 dlg.begin(common::MethodInfo {
11281 id: "networkservices.projects.locations.gateways.routeViews.get",
11282 http_method: hyper::Method::GET,
11283 });
11284
11285 for &field in ["alt", "name"].iter() {
11286 if self._additional_params.contains_key(field) {
11287 dlg.finished(false);
11288 return Err(common::Error::FieldClash(field));
11289 }
11290 }
11291
11292 let mut params = Params::with_capacity(3 + self._additional_params.len());
11293 params.push("name", self._name);
11294
11295 params.extend(self._additional_params.iter());
11296
11297 params.push("alt", "json");
11298 let mut url = self.hub._base_url.clone() + "v1/{+name}";
11299 if self._scopes.is_empty() {
11300 self._scopes
11301 .insert(Scope::CloudPlatform.as_ref().to_string());
11302 }
11303
11304 #[allow(clippy::single_element_loop)]
11305 for &(find_this, param_name) in [("{+name}", "name")].iter() {
11306 url = params.uri_replacement(url, param_name, find_this, true);
11307 }
11308 {
11309 let to_remove = ["name"];
11310 params.remove_params(&to_remove);
11311 }
11312
11313 let url = params.parse_with_url(&url);
11314
11315 loop {
11316 let token = match self
11317 .hub
11318 .auth
11319 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11320 .await
11321 {
11322 Ok(token) => token,
11323 Err(e) => match dlg.token(e) {
11324 Ok(token) => token,
11325 Err(e) => {
11326 dlg.finished(false);
11327 return Err(common::Error::MissingToken(e));
11328 }
11329 },
11330 };
11331 let mut req_result = {
11332 let client = &self.hub.client;
11333 dlg.pre_request();
11334 let mut req_builder = hyper::Request::builder()
11335 .method(hyper::Method::GET)
11336 .uri(url.as_str())
11337 .header(USER_AGENT, self.hub._user_agent.clone());
11338
11339 if let Some(token) = token.as_ref() {
11340 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11341 }
11342
11343 let request = req_builder
11344 .header(CONTENT_LENGTH, 0_u64)
11345 .body(common::to_body::<String>(None));
11346
11347 client.request(request.unwrap()).await
11348 };
11349
11350 match req_result {
11351 Err(err) => {
11352 if let common::Retry::After(d) = dlg.http_error(&err) {
11353 sleep(d).await;
11354 continue;
11355 }
11356 dlg.finished(false);
11357 return Err(common::Error::HttpError(err));
11358 }
11359 Ok(res) => {
11360 let (mut parts, body) = res.into_parts();
11361 let mut body = common::Body::new(body);
11362 if !parts.status.is_success() {
11363 let bytes = common::to_bytes(body).await.unwrap_or_default();
11364 let error = serde_json::from_str(&common::to_string(&bytes));
11365 let response = common::to_response(parts, bytes.into());
11366
11367 if let common::Retry::After(d) =
11368 dlg.http_failure(&response, error.as_ref().ok())
11369 {
11370 sleep(d).await;
11371 continue;
11372 }
11373
11374 dlg.finished(false);
11375
11376 return Err(match error {
11377 Ok(value) => common::Error::BadRequest(value),
11378 _ => common::Error::Failure(response),
11379 });
11380 }
11381 let response = {
11382 let bytes = common::to_bytes(body).await.unwrap_or_default();
11383 let encoded = common::to_string(&bytes);
11384 match serde_json::from_str(&encoded) {
11385 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11386 Err(error) => {
11387 dlg.response_json_decode_error(&encoded, &error);
11388 return Err(common::Error::JsonDecodeError(
11389 encoded.to_string(),
11390 error,
11391 ));
11392 }
11393 }
11394 };
11395
11396 dlg.finished(true);
11397 return Ok(response);
11398 }
11399 }
11400 }
11401 }
11402
11403 /// Required. Name of the GatewayRouteView resource. Formats: projects/{project_number}/locations/{location}/gateways/{gateway}/routeViews/{route_view}
11404 ///
11405 /// Sets the *name* path property to the given value.
11406 ///
11407 /// Even though the property as already been set when instantiating this call,
11408 /// we provide this method for API completeness.
11409 pub fn name(mut self, new_value: &str) -> ProjectLocationGatewayRouteViewGetCall<'a, C> {
11410 self._name = new_value.to_string();
11411 self
11412 }
11413 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11414 /// while executing the actual API request.
11415 ///
11416 /// ````text
11417 /// It should be used to handle progress information, and to implement a certain level of resilience.
11418 /// ````
11419 ///
11420 /// Sets the *delegate* property to the given value.
11421 pub fn delegate(
11422 mut self,
11423 new_value: &'a mut dyn common::Delegate,
11424 ) -> ProjectLocationGatewayRouteViewGetCall<'a, C> {
11425 self._delegate = Some(new_value);
11426 self
11427 }
11428
11429 /// Set any additional parameter of the query string used in the request.
11430 /// It should be used to set parameters which are not yet available through their own
11431 /// setters.
11432 ///
11433 /// Please note that this method must not be used to set any of the known parameters
11434 /// which have their own setter method. If done anyway, the request will fail.
11435 ///
11436 /// # Additional Parameters
11437 ///
11438 /// * *$.xgafv* (query-string) - V1 error format.
11439 /// * *access_token* (query-string) - OAuth access token.
11440 /// * *alt* (query-string) - Data format for response.
11441 /// * *callback* (query-string) - JSONP
11442 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11443 /// * *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.
11444 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11445 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11446 /// * *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.
11447 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11448 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11449 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGatewayRouteViewGetCall<'a, C>
11450 where
11451 T: AsRef<str>,
11452 {
11453 self._additional_params
11454 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11455 self
11456 }
11457
11458 /// Identifies the authorization scope for the method you are building.
11459 ///
11460 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11461 /// [`Scope::CloudPlatform`].
11462 ///
11463 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11464 /// tokens for more than one scope.
11465 ///
11466 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11467 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11468 /// sufficient, a read-write scope will do as well.
11469 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGatewayRouteViewGetCall<'a, C>
11470 where
11471 St: AsRef<str>,
11472 {
11473 self._scopes.insert(String::from(scope.as_ref()));
11474 self
11475 }
11476 /// Identifies the authorization scope(s) for the method you are building.
11477 ///
11478 /// See [`Self::add_scope()`] for details.
11479 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGatewayRouteViewGetCall<'a, C>
11480 where
11481 I: IntoIterator<Item = St>,
11482 St: AsRef<str>,
11483 {
11484 self._scopes
11485 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11486 self
11487 }
11488
11489 /// Removes all scopes, and no default scope will be used either.
11490 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11491 /// for details).
11492 pub fn clear_scopes(mut self) -> ProjectLocationGatewayRouteViewGetCall<'a, C> {
11493 self._scopes.clear();
11494 self
11495 }
11496}
11497
11498/// Lists RouteViews
11499///
11500/// A builder for the *locations.gateways.routeViews.list* method supported by a *project* resource.
11501/// It is not used directly, but through a [`ProjectMethods`] instance.
11502///
11503/// # Example
11504///
11505/// Instantiate a resource method builder
11506///
11507/// ```test_harness,no_run
11508/// # extern crate hyper;
11509/// # extern crate hyper_rustls;
11510/// # extern crate google_networkservices1 as networkservices1;
11511/// # async fn dox() {
11512/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11513///
11514/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11515/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11516/// # .with_native_roots()
11517/// # .unwrap()
11518/// # .https_only()
11519/// # .enable_http2()
11520/// # .build();
11521///
11522/// # let executor = hyper_util::rt::TokioExecutor::new();
11523/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11524/// # secret,
11525/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11526/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11527/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11528/// # ),
11529/// # ).build().await.unwrap();
11530///
11531/// # let client = hyper_util::client::legacy::Client::builder(
11532/// # hyper_util::rt::TokioExecutor::new()
11533/// # )
11534/// # .build(
11535/// # hyper_rustls::HttpsConnectorBuilder::new()
11536/// # .with_native_roots()
11537/// # .unwrap()
11538/// # .https_or_http()
11539/// # .enable_http2()
11540/// # .build()
11541/// # );
11542/// # let mut hub = NetworkServices::new(client, auth);
11543/// // You can configure optional parameters by calling the respective setters at will, and
11544/// // execute the final call using `doit()`.
11545/// // Values shown here are possibly random and not representative !
11546/// let result = hub.projects().locations_gateways_route_views_list("parent")
11547/// .page_token("sed")
11548/// .page_size(-24)
11549/// .doit().await;
11550/// # }
11551/// ```
11552pub struct ProjectLocationGatewayRouteViewListCall<'a, C>
11553where
11554 C: 'a,
11555{
11556 hub: &'a NetworkServices<C>,
11557 _parent: String,
11558 _page_token: Option<String>,
11559 _page_size: Option<i32>,
11560 _delegate: Option<&'a mut dyn common::Delegate>,
11561 _additional_params: HashMap<String, String>,
11562 _scopes: BTreeSet<String>,
11563}
11564
11565impl<'a, C> common::CallBuilder for ProjectLocationGatewayRouteViewListCall<'a, C> {}
11566
11567impl<'a, C> ProjectLocationGatewayRouteViewListCall<'a, C>
11568where
11569 C: common::Connector,
11570{
11571 /// Perform the operation you have build so far.
11572 pub async fn doit(
11573 mut self,
11574 ) -> common::Result<(common::Response, ListGatewayRouteViewsResponse)> {
11575 use std::borrow::Cow;
11576 use std::io::{Read, Seek};
11577
11578 use common::{url::Params, ToParts};
11579 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11580
11581 let mut dd = common::DefaultDelegate;
11582 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11583 dlg.begin(common::MethodInfo {
11584 id: "networkservices.projects.locations.gateways.routeViews.list",
11585 http_method: hyper::Method::GET,
11586 });
11587
11588 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
11589 if self._additional_params.contains_key(field) {
11590 dlg.finished(false);
11591 return Err(common::Error::FieldClash(field));
11592 }
11593 }
11594
11595 let mut params = Params::with_capacity(5 + self._additional_params.len());
11596 params.push("parent", self._parent);
11597 if let Some(value) = self._page_token.as_ref() {
11598 params.push("pageToken", value);
11599 }
11600 if let Some(value) = self._page_size.as_ref() {
11601 params.push("pageSize", value.to_string());
11602 }
11603
11604 params.extend(self._additional_params.iter());
11605
11606 params.push("alt", "json");
11607 let mut url = self.hub._base_url.clone() + "v1/{+parent}/routeViews";
11608 if self._scopes.is_empty() {
11609 self._scopes
11610 .insert(Scope::CloudPlatform.as_ref().to_string());
11611 }
11612
11613 #[allow(clippy::single_element_loop)]
11614 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
11615 url = params.uri_replacement(url, param_name, find_this, true);
11616 }
11617 {
11618 let to_remove = ["parent"];
11619 params.remove_params(&to_remove);
11620 }
11621
11622 let url = params.parse_with_url(&url);
11623
11624 loop {
11625 let token = match self
11626 .hub
11627 .auth
11628 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11629 .await
11630 {
11631 Ok(token) => token,
11632 Err(e) => match dlg.token(e) {
11633 Ok(token) => token,
11634 Err(e) => {
11635 dlg.finished(false);
11636 return Err(common::Error::MissingToken(e));
11637 }
11638 },
11639 };
11640 let mut req_result = {
11641 let client = &self.hub.client;
11642 dlg.pre_request();
11643 let mut req_builder = hyper::Request::builder()
11644 .method(hyper::Method::GET)
11645 .uri(url.as_str())
11646 .header(USER_AGENT, self.hub._user_agent.clone());
11647
11648 if let Some(token) = token.as_ref() {
11649 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11650 }
11651
11652 let request = req_builder
11653 .header(CONTENT_LENGTH, 0_u64)
11654 .body(common::to_body::<String>(None));
11655
11656 client.request(request.unwrap()).await
11657 };
11658
11659 match req_result {
11660 Err(err) => {
11661 if let common::Retry::After(d) = dlg.http_error(&err) {
11662 sleep(d).await;
11663 continue;
11664 }
11665 dlg.finished(false);
11666 return Err(common::Error::HttpError(err));
11667 }
11668 Ok(res) => {
11669 let (mut parts, body) = res.into_parts();
11670 let mut body = common::Body::new(body);
11671 if !parts.status.is_success() {
11672 let bytes = common::to_bytes(body).await.unwrap_or_default();
11673 let error = serde_json::from_str(&common::to_string(&bytes));
11674 let response = common::to_response(parts, bytes.into());
11675
11676 if let common::Retry::After(d) =
11677 dlg.http_failure(&response, error.as_ref().ok())
11678 {
11679 sleep(d).await;
11680 continue;
11681 }
11682
11683 dlg.finished(false);
11684
11685 return Err(match error {
11686 Ok(value) => common::Error::BadRequest(value),
11687 _ => common::Error::Failure(response),
11688 });
11689 }
11690 let response = {
11691 let bytes = common::to_bytes(body).await.unwrap_or_default();
11692 let encoded = common::to_string(&bytes);
11693 match serde_json::from_str(&encoded) {
11694 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11695 Err(error) => {
11696 dlg.response_json_decode_error(&encoded, &error);
11697 return Err(common::Error::JsonDecodeError(
11698 encoded.to_string(),
11699 error,
11700 ));
11701 }
11702 }
11703 };
11704
11705 dlg.finished(true);
11706 return Ok(response);
11707 }
11708 }
11709 }
11710 }
11711
11712 /// Required. The Gateway to which a Route is associated. Formats: projects/{project_number}/locations/{location}/gateways/{gateway}
11713 ///
11714 /// Sets the *parent* path property to the given value.
11715 ///
11716 /// Even though the property as already been set when instantiating this call,
11717 /// we provide this method for API completeness.
11718 pub fn parent(mut self, new_value: &str) -> ProjectLocationGatewayRouteViewListCall<'a, C> {
11719 self._parent = new_value.to_string();
11720 self
11721 }
11722 /// The value returned by the last `ListGatewayRouteViewsResponse` Indicates that this is a continuation of a prior `ListGatewayRouteViews` call, and that the system should return the next page of data.
11723 ///
11724 /// Sets the *page token* query property to the given value.
11725 pub fn page_token(mut self, new_value: &str) -> ProjectLocationGatewayRouteViewListCall<'a, C> {
11726 self._page_token = Some(new_value.to_string());
11727 self
11728 }
11729 /// Maximum number of GatewayRouteViews to return per call.
11730 ///
11731 /// Sets the *page size* query property to the given value.
11732 pub fn page_size(mut self, new_value: i32) -> ProjectLocationGatewayRouteViewListCall<'a, C> {
11733 self._page_size = Some(new_value);
11734 self
11735 }
11736 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11737 /// while executing the actual API request.
11738 ///
11739 /// ````text
11740 /// It should be used to handle progress information, and to implement a certain level of resilience.
11741 /// ````
11742 ///
11743 /// Sets the *delegate* property to the given value.
11744 pub fn delegate(
11745 mut self,
11746 new_value: &'a mut dyn common::Delegate,
11747 ) -> ProjectLocationGatewayRouteViewListCall<'a, C> {
11748 self._delegate = Some(new_value);
11749 self
11750 }
11751
11752 /// Set any additional parameter of the query string used in the request.
11753 /// It should be used to set parameters which are not yet available through their own
11754 /// setters.
11755 ///
11756 /// Please note that this method must not be used to set any of the known parameters
11757 /// which have their own setter method. If done anyway, the request will fail.
11758 ///
11759 /// # Additional Parameters
11760 ///
11761 /// * *$.xgafv* (query-string) - V1 error format.
11762 /// * *access_token* (query-string) - OAuth access token.
11763 /// * *alt* (query-string) - Data format for response.
11764 /// * *callback* (query-string) - JSONP
11765 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11766 /// * *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.
11767 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11768 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11769 /// * *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.
11770 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11771 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11772 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGatewayRouteViewListCall<'a, C>
11773 where
11774 T: AsRef<str>,
11775 {
11776 self._additional_params
11777 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11778 self
11779 }
11780
11781 /// Identifies the authorization scope for the method you are building.
11782 ///
11783 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11784 /// [`Scope::CloudPlatform`].
11785 ///
11786 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11787 /// tokens for more than one scope.
11788 ///
11789 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11790 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11791 /// sufficient, a read-write scope will do as well.
11792 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGatewayRouteViewListCall<'a, C>
11793 where
11794 St: AsRef<str>,
11795 {
11796 self._scopes.insert(String::from(scope.as_ref()));
11797 self
11798 }
11799 /// Identifies the authorization scope(s) for the method you are building.
11800 ///
11801 /// See [`Self::add_scope()`] for details.
11802 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGatewayRouteViewListCall<'a, C>
11803 where
11804 I: IntoIterator<Item = St>,
11805 St: AsRef<str>,
11806 {
11807 self._scopes
11808 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11809 self
11810 }
11811
11812 /// Removes all scopes, and no default scope will be used either.
11813 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11814 /// for details).
11815 pub fn clear_scopes(mut self) -> ProjectLocationGatewayRouteViewListCall<'a, C> {
11816 self._scopes.clear();
11817 self
11818 }
11819}
11820
11821/// Creates a new Gateway in a given project and location.
11822///
11823/// A builder for the *locations.gateways.create* method supported by a *project* resource.
11824/// It is not used directly, but through a [`ProjectMethods`] instance.
11825///
11826/// # Example
11827///
11828/// Instantiate a resource method builder
11829///
11830/// ```test_harness,no_run
11831/// # extern crate hyper;
11832/// # extern crate hyper_rustls;
11833/// # extern crate google_networkservices1 as networkservices1;
11834/// use networkservices1::api::Gateway;
11835/// # async fn dox() {
11836/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11837///
11838/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11839/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11840/// # .with_native_roots()
11841/// # .unwrap()
11842/// # .https_only()
11843/// # .enable_http2()
11844/// # .build();
11845///
11846/// # let executor = hyper_util::rt::TokioExecutor::new();
11847/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11848/// # secret,
11849/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11850/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11851/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11852/// # ),
11853/// # ).build().await.unwrap();
11854///
11855/// # let client = hyper_util::client::legacy::Client::builder(
11856/// # hyper_util::rt::TokioExecutor::new()
11857/// # )
11858/// # .build(
11859/// # hyper_rustls::HttpsConnectorBuilder::new()
11860/// # .with_native_roots()
11861/// # .unwrap()
11862/// # .https_or_http()
11863/// # .enable_http2()
11864/// # .build()
11865/// # );
11866/// # let mut hub = NetworkServices::new(client, auth);
11867/// // As the method needs a request, you would usually fill it with the desired information
11868/// // into the respective structure. Some of the parts shown here might not be applicable !
11869/// // Values shown here are possibly random and not representative !
11870/// let mut req = Gateway::default();
11871///
11872/// // You can configure optional parameters by calling the respective setters at will, and
11873/// // execute the final call using `doit()`.
11874/// // Values shown here are possibly random and not representative !
11875/// let result = hub.projects().locations_gateways_create(req, "parent")
11876/// .gateway_id("vero")
11877/// .doit().await;
11878/// # }
11879/// ```
11880pub struct ProjectLocationGatewayCreateCall<'a, C>
11881where
11882 C: 'a,
11883{
11884 hub: &'a NetworkServices<C>,
11885 _request: Gateway,
11886 _parent: String,
11887 _gateway_id: Option<String>,
11888 _delegate: Option<&'a mut dyn common::Delegate>,
11889 _additional_params: HashMap<String, String>,
11890 _scopes: BTreeSet<String>,
11891}
11892
11893impl<'a, C> common::CallBuilder for ProjectLocationGatewayCreateCall<'a, C> {}
11894
11895impl<'a, C> ProjectLocationGatewayCreateCall<'a, C>
11896where
11897 C: common::Connector,
11898{
11899 /// Perform the operation you have build so far.
11900 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
11901 use std::borrow::Cow;
11902 use std::io::{Read, Seek};
11903
11904 use common::{url::Params, ToParts};
11905 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11906
11907 let mut dd = common::DefaultDelegate;
11908 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11909 dlg.begin(common::MethodInfo {
11910 id: "networkservices.projects.locations.gateways.create",
11911 http_method: hyper::Method::POST,
11912 });
11913
11914 for &field in ["alt", "parent", "gatewayId"].iter() {
11915 if self._additional_params.contains_key(field) {
11916 dlg.finished(false);
11917 return Err(common::Error::FieldClash(field));
11918 }
11919 }
11920
11921 let mut params = Params::with_capacity(5 + self._additional_params.len());
11922 params.push("parent", self._parent);
11923 if let Some(value) = self._gateway_id.as_ref() {
11924 params.push("gatewayId", value);
11925 }
11926
11927 params.extend(self._additional_params.iter());
11928
11929 params.push("alt", "json");
11930 let mut url = self.hub._base_url.clone() + "v1/{+parent}/gateways";
11931 if self._scopes.is_empty() {
11932 self._scopes
11933 .insert(Scope::CloudPlatform.as_ref().to_string());
11934 }
11935
11936 #[allow(clippy::single_element_loop)]
11937 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
11938 url = params.uri_replacement(url, param_name, find_this, true);
11939 }
11940 {
11941 let to_remove = ["parent"];
11942 params.remove_params(&to_remove);
11943 }
11944
11945 let url = params.parse_with_url(&url);
11946
11947 let mut json_mime_type = mime::APPLICATION_JSON;
11948 let mut request_value_reader = {
11949 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11950 common::remove_json_null_values(&mut value);
11951 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11952 serde_json::to_writer(&mut dst, &value).unwrap();
11953 dst
11954 };
11955 let request_size = request_value_reader
11956 .seek(std::io::SeekFrom::End(0))
11957 .unwrap();
11958 request_value_reader
11959 .seek(std::io::SeekFrom::Start(0))
11960 .unwrap();
11961
11962 loop {
11963 let token = match self
11964 .hub
11965 .auth
11966 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11967 .await
11968 {
11969 Ok(token) => token,
11970 Err(e) => match dlg.token(e) {
11971 Ok(token) => token,
11972 Err(e) => {
11973 dlg.finished(false);
11974 return Err(common::Error::MissingToken(e));
11975 }
11976 },
11977 };
11978 request_value_reader
11979 .seek(std::io::SeekFrom::Start(0))
11980 .unwrap();
11981 let mut req_result = {
11982 let client = &self.hub.client;
11983 dlg.pre_request();
11984 let mut req_builder = hyper::Request::builder()
11985 .method(hyper::Method::POST)
11986 .uri(url.as_str())
11987 .header(USER_AGENT, self.hub._user_agent.clone());
11988
11989 if let Some(token) = token.as_ref() {
11990 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11991 }
11992
11993 let request = req_builder
11994 .header(CONTENT_TYPE, json_mime_type.to_string())
11995 .header(CONTENT_LENGTH, request_size as u64)
11996 .body(common::to_body(
11997 request_value_reader.get_ref().clone().into(),
11998 ));
11999
12000 client.request(request.unwrap()).await
12001 };
12002
12003 match req_result {
12004 Err(err) => {
12005 if let common::Retry::After(d) = dlg.http_error(&err) {
12006 sleep(d).await;
12007 continue;
12008 }
12009 dlg.finished(false);
12010 return Err(common::Error::HttpError(err));
12011 }
12012 Ok(res) => {
12013 let (mut parts, body) = res.into_parts();
12014 let mut body = common::Body::new(body);
12015 if !parts.status.is_success() {
12016 let bytes = common::to_bytes(body).await.unwrap_or_default();
12017 let error = serde_json::from_str(&common::to_string(&bytes));
12018 let response = common::to_response(parts, bytes.into());
12019
12020 if let common::Retry::After(d) =
12021 dlg.http_failure(&response, error.as_ref().ok())
12022 {
12023 sleep(d).await;
12024 continue;
12025 }
12026
12027 dlg.finished(false);
12028
12029 return Err(match error {
12030 Ok(value) => common::Error::BadRequest(value),
12031 _ => common::Error::Failure(response),
12032 });
12033 }
12034 let response = {
12035 let bytes = common::to_bytes(body).await.unwrap_or_default();
12036 let encoded = common::to_string(&bytes);
12037 match serde_json::from_str(&encoded) {
12038 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12039 Err(error) => {
12040 dlg.response_json_decode_error(&encoded, &error);
12041 return Err(common::Error::JsonDecodeError(
12042 encoded.to_string(),
12043 error,
12044 ));
12045 }
12046 }
12047 };
12048
12049 dlg.finished(true);
12050 return Ok(response);
12051 }
12052 }
12053 }
12054 }
12055
12056 ///
12057 /// Sets the *request* property to the given value.
12058 ///
12059 /// Even though the property as already been set when instantiating this call,
12060 /// we provide this method for API completeness.
12061 pub fn request(mut self, new_value: Gateway) -> ProjectLocationGatewayCreateCall<'a, C> {
12062 self._request = new_value;
12063 self
12064 }
12065 /// Required. The parent resource of the Gateway. Must be in the format `projects/*/locations/*`.
12066 ///
12067 /// Sets the *parent* path property to the given value.
12068 ///
12069 /// Even though the property as already been set when instantiating this call,
12070 /// we provide this method for API completeness.
12071 pub fn parent(mut self, new_value: &str) -> ProjectLocationGatewayCreateCall<'a, C> {
12072 self._parent = new_value.to_string();
12073 self
12074 }
12075 /// Required. Short name of the Gateway resource to be created.
12076 ///
12077 /// Sets the *gateway id* query property to the given value.
12078 pub fn gateway_id(mut self, new_value: &str) -> ProjectLocationGatewayCreateCall<'a, C> {
12079 self._gateway_id = Some(new_value.to_string());
12080 self
12081 }
12082 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12083 /// while executing the actual API request.
12084 ///
12085 /// ````text
12086 /// It should be used to handle progress information, and to implement a certain level of resilience.
12087 /// ````
12088 ///
12089 /// Sets the *delegate* property to the given value.
12090 pub fn delegate(
12091 mut self,
12092 new_value: &'a mut dyn common::Delegate,
12093 ) -> ProjectLocationGatewayCreateCall<'a, C> {
12094 self._delegate = Some(new_value);
12095 self
12096 }
12097
12098 /// Set any additional parameter of the query string used in the request.
12099 /// It should be used to set parameters which are not yet available through their own
12100 /// setters.
12101 ///
12102 /// Please note that this method must not be used to set any of the known parameters
12103 /// which have their own setter method. If done anyway, the request will fail.
12104 ///
12105 /// # Additional Parameters
12106 ///
12107 /// * *$.xgafv* (query-string) - V1 error format.
12108 /// * *access_token* (query-string) - OAuth access token.
12109 /// * *alt* (query-string) - Data format for response.
12110 /// * *callback* (query-string) - JSONP
12111 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12112 /// * *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.
12113 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12114 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12115 /// * *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.
12116 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12117 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12118 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGatewayCreateCall<'a, C>
12119 where
12120 T: AsRef<str>,
12121 {
12122 self._additional_params
12123 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12124 self
12125 }
12126
12127 /// Identifies the authorization scope for the method you are building.
12128 ///
12129 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12130 /// [`Scope::CloudPlatform`].
12131 ///
12132 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12133 /// tokens for more than one scope.
12134 ///
12135 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12136 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12137 /// sufficient, a read-write scope will do as well.
12138 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGatewayCreateCall<'a, C>
12139 where
12140 St: AsRef<str>,
12141 {
12142 self._scopes.insert(String::from(scope.as_ref()));
12143 self
12144 }
12145 /// Identifies the authorization scope(s) for the method you are building.
12146 ///
12147 /// See [`Self::add_scope()`] for details.
12148 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGatewayCreateCall<'a, C>
12149 where
12150 I: IntoIterator<Item = St>,
12151 St: AsRef<str>,
12152 {
12153 self._scopes
12154 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12155 self
12156 }
12157
12158 /// Removes all scopes, and no default scope will be used either.
12159 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12160 /// for details).
12161 pub fn clear_scopes(mut self) -> ProjectLocationGatewayCreateCall<'a, C> {
12162 self._scopes.clear();
12163 self
12164 }
12165}
12166
12167/// Deletes a single Gateway.
12168///
12169/// A builder for the *locations.gateways.delete* method supported by a *project* resource.
12170/// It is not used directly, but through a [`ProjectMethods`] instance.
12171///
12172/// # Example
12173///
12174/// Instantiate a resource method builder
12175///
12176/// ```test_harness,no_run
12177/// # extern crate hyper;
12178/// # extern crate hyper_rustls;
12179/// # extern crate google_networkservices1 as networkservices1;
12180/// # async fn dox() {
12181/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12182///
12183/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12184/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12185/// # .with_native_roots()
12186/// # .unwrap()
12187/// # .https_only()
12188/// # .enable_http2()
12189/// # .build();
12190///
12191/// # let executor = hyper_util::rt::TokioExecutor::new();
12192/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12193/// # secret,
12194/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12195/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12196/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12197/// # ),
12198/// # ).build().await.unwrap();
12199///
12200/// # let client = hyper_util::client::legacy::Client::builder(
12201/// # hyper_util::rt::TokioExecutor::new()
12202/// # )
12203/// # .build(
12204/// # hyper_rustls::HttpsConnectorBuilder::new()
12205/// # .with_native_roots()
12206/// # .unwrap()
12207/// # .https_or_http()
12208/// # .enable_http2()
12209/// # .build()
12210/// # );
12211/// # let mut hub = NetworkServices::new(client, auth);
12212/// // You can configure optional parameters by calling the respective setters at will, and
12213/// // execute the final call using `doit()`.
12214/// // Values shown here are possibly random and not representative !
12215/// let result = hub.projects().locations_gateways_delete("name")
12216/// .doit().await;
12217/// # }
12218/// ```
12219pub struct ProjectLocationGatewayDeleteCall<'a, C>
12220where
12221 C: 'a,
12222{
12223 hub: &'a NetworkServices<C>,
12224 _name: String,
12225 _delegate: Option<&'a mut dyn common::Delegate>,
12226 _additional_params: HashMap<String, String>,
12227 _scopes: BTreeSet<String>,
12228}
12229
12230impl<'a, C> common::CallBuilder for ProjectLocationGatewayDeleteCall<'a, C> {}
12231
12232impl<'a, C> ProjectLocationGatewayDeleteCall<'a, C>
12233where
12234 C: common::Connector,
12235{
12236 /// Perform the operation you have build so far.
12237 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
12238 use std::borrow::Cow;
12239 use std::io::{Read, Seek};
12240
12241 use common::{url::Params, ToParts};
12242 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12243
12244 let mut dd = common::DefaultDelegate;
12245 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12246 dlg.begin(common::MethodInfo {
12247 id: "networkservices.projects.locations.gateways.delete",
12248 http_method: hyper::Method::DELETE,
12249 });
12250
12251 for &field in ["alt", "name"].iter() {
12252 if self._additional_params.contains_key(field) {
12253 dlg.finished(false);
12254 return Err(common::Error::FieldClash(field));
12255 }
12256 }
12257
12258 let mut params = Params::with_capacity(3 + self._additional_params.len());
12259 params.push("name", self._name);
12260
12261 params.extend(self._additional_params.iter());
12262
12263 params.push("alt", "json");
12264 let mut url = self.hub._base_url.clone() + "v1/{+name}";
12265 if self._scopes.is_empty() {
12266 self._scopes
12267 .insert(Scope::CloudPlatform.as_ref().to_string());
12268 }
12269
12270 #[allow(clippy::single_element_loop)]
12271 for &(find_this, param_name) in [("{+name}", "name")].iter() {
12272 url = params.uri_replacement(url, param_name, find_this, true);
12273 }
12274 {
12275 let to_remove = ["name"];
12276 params.remove_params(&to_remove);
12277 }
12278
12279 let url = params.parse_with_url(&url);
12280
12281 loop {
12282 let token = match self
12283 .hub
12284 .auth
12285 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12286 .await
12287 {
12288 Ok(token) => token,
12289 Err(e) => match dlg.token(e) {
12290 Ok(token) => token,
12291 Err(e) => {
12292 dlg.finished(false);
12293 return Err(common::Error::MissingToken(e));
12294 }
12295 },
12296 };
12297 let mut req_result = {
12298 let client = &self.hub.client;
12299 dlg.pre_request();
12300 let mut req_builder = hyper::Request::builder()
12301 .method(hyper::Method::DELETE)
12302 .uri(url.as_str())
12303 .header(USER_AGENT, self.hub._user_agent.clone());
12304
12305 if let Some(token) = token.as_ref() {
12306 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12307 }
12308
12309 let request = req_builder
12310 .header(CONTENT_LENGTH, 0_u64)
12311 .body(common::to_body::<String>(None));
12312
12313 client.request(request.unwrap()).await
12314 };
12315
12316 match req_result {
12317 Err(err) => {
12318 if let common::Retry::After(d) = dlg.http_error(&err) {
12319 sleep(d).await;
12320 continue;
12321 }
12322 dlg.finished(false);
12323 return Err(common::Error::HttpError(err));
12324 }
12325 Ok(res) => {
12326 let (mut parts, body) = res.into_parts();
12327 let mut body = common::Body::new(body);
12328 if !parts.status.is_success() {
12329 let bytes = common::to_bytes(body).await.unwrap_or_default();
12330 let error = serde_json::from_str(&common::to_string(&bytes));
12331 let response = common::to_response(parts, bytes.into());
12332
12333 if let common::Retry::After(d) =
12334 dlg.http_failure(&response, error.as_ref().ok())
12335 {
12336 sleep(d).await;
12337 continue;
12338 }
12339
12340 dlg.finished(false);
12341
12342 return Err(match error {
12343 Ok(value) => common::Error::BadRequest(value),
12344 _ => common::Error::Failure(response),
12345 });
12346 }
12347 let response = {
12348 let bytes = common::to_bytes(body).await.unwrap_or_default();
12349 let encoded = common::to_string(&bytes);
12350 match serde_json::from_str(&encoded) {
12351 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12352 Err(error) => {
12353 dlg.response_json_decode_error(&encoded, &error);
12354 return Err(common::Error::JsonDecodeError(
12355 encoded.to_string(),
12356 error,
12357 ));
12358 }
12359 }
12360 };
12361
12362 dlg.finished(true);
12363 return Ok(response);
12364 }
12365 }
12366 }
12367 }
12368
12369 /// Required. A name of the Gateway to delete. Must be in the format `projects/*/locations/*/gateways/*`.
12370 ///
12371 /// Sets the *name* path property to the given value.
12372 ///
12373 /// Even though the property as already been set when instantiating this call,
12374 /// we provide this method for API completeness.
12375 pub fn name(mut self, new_value: &str) -> ProjectLocationGatewayDeleteCall<'a, C> {
12376 self._name = new_value.to_string();
12377 self
12378 }
12379 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12380 /// while executing the actual API request.
12381 ///
12382 /// ````text
12383 /// It should be used to handle progress information, and to implement a certain level of resilience.
12384 /// ````
12385 ///
12386 /// Sets the *delegate* property to the given value.
12387 pub fn delegate(
12388 mut self,
12389 new_value: &'a mut dyn common::Delegate,
12390 ) -> ProjectLocationGatewayDeleteCall<'a, C> {
12391 self._delegate = Some(new_value);
12392 self
12393 }
12394
12395 /// Set any additional parameter of the query string used in the request.
12396 /// It should be used to set parameters which are not yet available through their own
12397 /// setters.
12398 ///
12399 /// Please note that this method must not be used to set any of the known parameters
12400 /// which have their own setter method. If done anyway, the request will fail.
12401 ///
12402 /// # Additional Parameters
12403 ///
12404 /// * *$.xgafv* (query-string) - V1 error format.
12405 /// * *access_token* (query-string) - OAuth access token.
12406 /// * *alt* (query-string) - Data format for response.
12407 /// * *callback* (query-string) - JSONP
12408 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12409 /// * *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.
12410 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12411 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12412 /// * *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.
12413 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12414 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12415 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGatewayDeleteCall<'a, C>
12416 where
12417 T: AsRef<str>,
12418 {
12419 self._additional_params
12420 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12421 self
12422 }
12423
12424 /// Identifies the authorization scope for the method you are building.
12425 ///
12426 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12427 /// [`Scope::CloudPlatform`].
12428 ///
12429 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12430 /// tokens for more than one scope.
12431 ///
12432 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12433 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12434 /// sufficient, a read-write scope will do as well.
12435 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGatewayDeleteCall<'a, C>
12436 where
12437 St: AsRef<str>,
12438 {
12439 self._scopes.insert(String::from(scope.as_ref()));
12440 self
12441 }
12442 /// Identifies the authorization scope(s) for the method you are building.
12443 ///
12444 /// See [`Self::add_scope()`] for details.
12445 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGatewayDeleteCall<'a, C>
12446 where
12447 I: IntoIterator<Item = St>,
12448 St: AsRef<str>,
12449 {
12450 self._scopes
12451 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12452 self
12453 }
12454
12455 /// Removes all scopes, and no default scope will be used either.
12456 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12457 /// for details).
12458 pub fn clear_scopes(mut self) -> ProjectLocationGatewayDeleteCall<'a, C> {
12459 self._scopes.clear();
12460 self
12461 }
12462}
12463
12464/// Gets details of a single Gateway.
12465///
12466/// A builder for the *locations.gateways.get* method supported by a *project* resource.
12467/// It is not used directly, but through a [`ProjectMethods`] instance.
12468///
12469/// # Example
12470///
12471/// Instantiate a resource method builder
12472///
12473/// ```test_harness,no_run
12474/// # extern crate hyper;
12475/// # extern crate hyper_rustls;
12476/// # extern crate google_networkservices1 as networkservices1;
12477/// # async fn dox() {
12478/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12479///
12480/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12481/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12482/// # .with_native_roots()
12483/// # .unwrap()
12484/// # .https_only()
12485/// # .enable_http2()
12486/// # .build();
12487///
12488/// # let executor = hyper_util::rt::TokioExecutor::new();
12489/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12490/// # secret,
12491/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12492/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12493/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12494/// # ),
12495/// # ).build().await.unwrap();
12496///
12497/// # let client = hyper_util::client::legacy::Client::builder(
12498/// # hyper_util::rt::TokioExecutor::new()
12499/// # )
12500/// # .build(
12501/// # hyper_rustls::HttpsConnectorBuilder::new()
12502/// # .with_native_roots()
12503/// # .unwrap()
12504/// # .https_or_http()
12505/// # .enable_http2()
12506/// # .build()
12507/// # );
12508/// # let mut hub = NetworkServices::new(client, auth);
12509/// // You can configure optional parameters by calling the respective setters at will, and
12510/// // execute the final call using `doit()`.
12511/// // Values shown here are possibly random and not representative !
12512/// let result = hub.projects().locations_gateways_get("name")
12513/// .doit().await;
12514/// # }
12515/// ```
12516pub struct ProjectLocationGatewayGetCall<'a, C>
12517where
12518 C: 'a,
12519{
12520 hub: &'a NetworkServices<C>,
12521 _name: String,
12522 _delegate: Option<&'a mut dyn common::Delegate>,
12523 _additional_params: HashMap<String, String>,
12524 _scopes: BTreeSet<String>,
12525}
12526
12527impl<'a, C> common::CallBuilder for ProjectLocationGatewayGetCall<'a, C> {}
12528
12529impl<'a, C> ProjectLocationGatewayGetCall<'a, C>
12530where
12531 C: common::Connector,
12532{
12533 /// Perform the operation you have build so far.
12534 pub async fn doit(mut self) -> common::Result<(common::Response, Gateway)> {
12535 use std::borrow::Cow;
12536 use std::io::{Read, Seek};
12537
12538 use common::{url::Params, ToParts};
12539 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12540
12541 let mut dd = common::DefaultDelegate;
12542 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12543 dlg.begin(common::MethodInfo {
12544 id: "networkservices.projects.locations.gateways.get",
12545 http_method: hyper::Method::GET,
12546 });
12547
12548 for &field in ["alt", "name"].iter() {
12549 if self._additional_params.contains_key(field) {
12550 dlg.finished(false);
12551 return Err(common::Error::FieldClash(field));
12552 }
12553 }
12554
12555 let mut params = Params::with_capacity(3 + self._additional_params.len());
12556 params.push("name", self._name);
12557
12558 params.extend(self._additional_params.iter());
12559
12560 params.push("alt", "json");
12561 let mut url = self.hub._base_url.clone() + "v1/{+name}";
12562 if self._scopes.is_empty() {
12563 self._scopes
12564 .insert(Scope::CloudPlatform.as_ref().to_string());
12565 }
12566
12567 #[allow(clippy::single_element_loop)]
12568 for &(find_this, param_name) in [("{+name}", "name")].iter() {
12569 url = params.uri_replacement(url, param_name, find_this, true);
12570 }
12571 {
12572 let to_remove = ["name"];
12573 params.remove_params(&to_remove);
12574 }
12575
12576 let url = params.parse_with_url(&url);
12577
12578 loop {
12579 let token = match self
12580 .hub
12581 .auth
12582 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12583 .await
12584 {
12585 Ok(token) => token,
12586 Err(e) => match dlg.token(e) {
12587 Ok(token) => token,
12588 Err(e) => {
12589 dlg.finished(false);
12590 return Err(common::Error::MissingToken(e));
12591 }
12592 },
12593 };
12594 let mut req_result = {
12595 let client = &self.hub.client;
12596 dlg.pre_request();
12597 let mut req_builder = hyper::Request::builder()
12598 .method(hyper::Method::GET)
12599 .uri(url.as_str())
12600 .header(USER_AGENT, self.hub._user_agent.clone());
12601
12602 if let Some(token) = token.as_ref() {
12603 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12604 }
12605
12606 let request = req_builder
12607 .header(CONTENT_LENGTH, 0_u64)
12608 .body(common::to_body::<String>(None));
12609
12610 client.request(request.unwrap()).await
12611 };
12612
12613 match req_result {
12614 Err(err) => {
12615 if let common::Retry::After(d) = dlg.http_error(&err) {
12616 sleep(d).await;
12617 continue;
12618 }
12619 dlg.finished(false);
12620 return Err(common::Error::HttpError(err));
12621 }
12622 Ok(res) => {
12623 let (mut parts, body) = res.into_parts();
12624 let mut body = common::Body::new(body);
12625 if !parts.status.is_success() {
12626 let bytes = common::to_bytes(body).await.unwrap_or_default();
12627 let error = serde_json::from_str(&common::to_string(&bytes));
12628 let response = common::to_response(parts, bytes.into());
12629
12630 if let common::Retry::After(d) =
12631 dlg.http_failure(&response, error.as_ref().ok())
12632 {
12633 sleep(d).await;
12634 continue;
12635 }
12636
12637 dlg.finished(false);
12638
12639 return Err(match error {
12640 Ok(value) => common::Error::BadRequest(value),
12641 _ => common::Error::Failure(response),
12642 });
12643 }
12644 let response = {
12645 let bytes = common::to_bytes(body).await.unwrap_or_default();
12646 let encoded = common::to_string(&bytes);
12647 match serde_json::from_str(&encoded) {
12648 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12649 Err(error) => {
12650 dlg.response_json_decode_error(&encoded, &error);
12651 return Err(common::Error::JsonDecodeError(
12652 encoded.to_string(),
12653 error,
12654 ));
12655 }
12656 }
12657 };
12658
12659 dlg.finished(true);
12660 return Ok(response);
12661 }
12662 }
12663 }
12664 }
12665
12666 /// Required. A name of the Gateway to get. Must be in the format `projects/*/locations/*/gateways/*`.
12667 ///
12668 /// Sets the *name* path property to the given value.
12669 ///
12670 /// Even though the property as already been set when instantiating this call,
12671 /// we provide this method for API completeness.
12672 pub fn name(mut self, new_value: &str) -> ProjectLocationGatewayGetCall<'a, C> {
12673 self._name = new_value.to_string();
12674 self
12675 }
12676 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12677 /// while executing the actual API request.
12678 ///
12679 /// ````text
12680 /// It should be used to handle progress information, and to implement a certain level of resilience.
12681 /// ````
12682 ///
12683 /// Sets the *delegate* property to the given value.
12684 pub fn delegate(
12685 mut self,
12686 new_value: &'a mut dyn common::Delegate,
12687 ) -> ProjectLocationGatewayGetCall<'a, C> {
12688 self._delegate = Some(new_value);
12689 self
12690 }
12691
12692 /// Set any additional parameter of the query string used in the request.
12693 /// It should be used to set parameters which are not yet available through their own
12694 /// setters.
12695 ///
12696 /// Please note that this method must not be used to set any of the known parameters
12697 /// which have their own setter method. If done anyway, the request will fail.
12698 ///
12699 /// # Additional Parameters
12700 ///
12701 /// * *$.xgafv* (query-string) - V1 error format.
12702 /// * *access_token* (query-string) - OAuth access token.
12703 /// * *alt* (query-string) - Data format for response.
12704 /// * *callback* (query-string) - JSONP
12705 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12706 /// * *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.
12707 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12708 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12709 /// * *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.
12710 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12711 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12712 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGatewayGetCall<'a, C>
12713 where
12714 T: AsRef<str>,
12715 {
12716 self._additional_params
12717 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12718 self
12719 }
12720
12721 /// Identifies the authorization scope for the method you are building.
12722 ///
12723 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12724 /// [`Scope::CloudPlatform`].
12725 ///
12726 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12727 /// tokens for more than one scope.
12728 ///
12729 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12730 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12731 /// sufficient, a read-write scope will do as well.
12732 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGatewayGetCall<'a, C>
12733 where
12734 St: AsRef<str>,
12735 {
12736 self._scopes.insert(String::from(scope.as_ref()));
12737 self
12738 }
12739 /// Identifies the authorization scope(s) for the method you are building.
12740 ///
12741 /// See [`Self::add_scope()`] for details.
12742 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGatewayGetCall<'a, C>
12743 where
12744 I: IntoIterator<Item = St>,
12745 St: AsRef<str>,
12746 {
12747 self._scopes
12748 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12749 self
12750 }
12751
12752 /// Removes all scopes, and no default scope will be used either.
12753 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12754 /// for details).
12755 pub fn clear_scopes(mut self) -> ProjectLocationGatewayGetCall<'a, C> {
12756 self._scopes.clear();
12757 self
12758 }
12759}
12760
12761/// Lists Gateways in a given project and location.
12762///
12763/// A builder for the *locations.gateways.list* method supported by a *project* resource.
12764/// It is not used directly, but through a [`ProjectMethods`] instance.
12765///
12766/// # Example
12767///
12768/// Instantiate a resource method builder
12769///
12770/// ```test_harness,no_run
12771/// # extern crate hyper;
12772/// # extern crate hyper_rustls;
12773/// # extern crate google_networkservices1 as networkservices1;
12774/// # async fn dox() {
12775/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12776///
12777/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12778/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12779/// # .with_native_roots()
12780/// # .unwrap()
12781/// # .https_only()
12782/// # .enable_http2()
12783/// # .build();
12784///
12785/// # let executor = hyper_util::rt::TokioExecutor::new();
12786/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12787/// # secret,
12788/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12789/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12790/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12791/// # ),
12792/// # ).build().await.unwrap();
12793///
12794/// # let client = hyper_util::client::legacy::Client::builder(
12795/// # hyper_util::rt::TokioExecutor::new()
12796/// # )
12797/// # .build(
12798/// # hyper_rustls::HttpsConnectorBuilder::new()
12799/// # .with_native_roots()
12800/// # .unwrap()
12801/// # .https_or_http()
12802/// # .enable_http2()
12803/// # .build()
12804/// # );
12805/// # let mut hub = NetworkServices::new(client, auth);
12806/// // You can configure optional parameters by calling the respective setters at will, and
12807/// // execute the final call using `doit()`.
12808/// // Values shown here are possibly random and not representative !
12809/// let result = hub.projects().locations_gateways_list("parent")
12810/// .page_token("dolore")
12811/// .page_size(-22)
12812/// .doit().await;
12813/// # }
12814/// ```
12815pub struct ProjectLocationGatewayListCall<'a, C>
12816where
12817 C: 'a,
12818{
12819 hub: &'a NetworkServices<C>,
12820 _parent: String,
12821 _page_token: Option<String>,
12822 _page_size: Option<i32>,
12823 _delegate: Option<&'a mut dyn common::Delegate>,
12824 _additional_params: HashMap<String, String>,
12825 _scopes: BTreeSet<String>,
12826}
12827
12828impl<'a, C> common::CallBuilder for ProjectLocationGatewayListCall<'a, C> {}
12829
12830impl<'a, C> ProjectLocationGatewayListCall<'a, C>
12831where
12832 C: common::Connector,
12833{
12834 /// Perform the operation you have build so far.
12835 pub async fn doit(mut self) -> common::Result<(common::Response, ListGatewaysResponse)> {
12836 use std::borrow::Cow;
12837 use std::io::{Read, Seek};
12838
12839 use common::{url::Params, ToParts};
12840 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12841
12842 let mut dd = common::DefaultDelegate;
12843 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12844 dlg.begin(common::MethodInfo {
12845 id: "networkservices.projects.locations.gateways.list",
12846 http_method: hyper::Method::GET,
12847 });
12848
12849 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
12850 if self._additional_params.contains_key(field) {
12851 dlg.finished(false);
12852 return Err(common::Error::FieldClash(field));
12853 }
12854 }
12855
12856 let mut params = Params::with_capacity(5 + self._additional_params.len());
12857 params.push("parent", self._parent);
12858 if let Some(value) = self._page_token.as_ref() {
12859 params.push("pageToken", value);
12860 }
12861 if let Some(value) = self._page_size.as_ref() {
12862 params.push("pageSize", value.to_string());
12863 }
12864
12865 params.extend(self._additional_params.iter());
12866
12867 params.push("alt", "json");
12868 let mut url = self.hub._base_url.clone() + "v1/{+parent}/gateways";
12869 if self._scopes.is_empty() {
12870 self._scopes
12871 .insert(Scope::CloudPlatform.as_ref().to_string());
12872 }
12873
12874 #[allow(clippy::single_element_loop)]
12875 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
12876 url = params.uri_replacement(url, param_name, find_this, true);
12877 }
12878 {
12879 let to_remove = ["parent"];
12880 params.remove_params(&to_remove);
12881 }
12882
12883 let url = params.parse_with_url(&url);
12884
12885 loop {
12886 let token = match self
12887 .hub
12888 .auth
12889 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12890 .await
12891 {
12892 Ok(token) => token,
12893 Err(e) => match dlg.token(e) {
12894 Ok(token) => token,
12895 Err(e) => {
12896 dlg.finished(false);
12897 return Err(common::Error::MissingToken(e));
12898 }
12899 },
12900 };
12901 let mut req_result = {
12902 let client = &self.hub.client;
12903 dlg.pre_request();
12904 let mut req_builder = hyper::Request::builder()
12905 .method(hyper::Method::GET)
12906 .uri(url.as_str())
12907 .header(USER_AGENT, self.hub._user_agent.clone());
12908
12909 if let Some(token) = token.as_ref() {
12910 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12911 }
12912
12913 let request = req_builder
12914 .header(CONTENT_LENGTH, 0_u64)
12915 .body(common::to_body::<String>(None));
12916
12917 client.request(request.unwrap()).await
12918 };
12919
12920 match req_result {
12921 Err(err) => {
12922 if let common::Retry::After(d) = dlg.http_error(&err) {
12923 sleep(d).await;
12924 continue;
12925 }
12926 dlg.finished(false);
12927 return Err(common::Error::HttpError(err));
12928 }
12929 Ok(res) => {
12930 let (mut parts, body) = res.into_parts();
12931 let mut body = common::Body::new(body);
12932 if !parts.status.is_success() {
12933 let bytes = common::to_bytes(body).await.unwrap_or_default();
12934 let error = serde_json::from_str(&common::to_string(&bytes));
12935 let response = common::to_response(parts, bytes.into());
12936
12937 if let common::Retry::After(d) =
12938 dlg.http_failure(&response, error.as_ref().ok())
12939 {
12940 sleep(d).await;
12941 continue;
12942 }
12943
12944 dlg.finished(false);
12945
12946 return Err(match error {
12947 Ok(value) => common::Error::BadRequest(value),
12948 _ => common::Error::Failure(response),
12949 });
12950 }
12951 let response = {
12952 let bytes = common::to_bytes(body).await.unwrap_or_default();
12953 let encoded = common::to_string(&bytes);
12954 match serde_json::from_str(&encoded) {
12955 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12956 Err(error) => {
12957 dlg.response_json_decode_error(&encoded, &error);
12958 return Err(common::Error::JsonDecodeError(
12959 encoded.to_string(),
12960 error,
12961 ));
12962 }
12963 }
12964 };
12965
12966 dlg.finished(true);
12967 return Ok(response);
12968 }
12969 }
12970 }
12971 }
12972
12973 /// Required. The project and location from which the Gateways should be listed, specified in the format `projects/*/locations/*`.
12974 ///
12975 /// Sets the *parent* path property to the given value.
12976 ///
12977 /// Even though the property as already been set when instantiating this call,
12978 /// we provide this method for API completeness.
12979 pub fn parent(mut self, new_value: &str) -> ProjectLocationGatewayListCall<'a, C> {
12980 self._parent = new_value.to_string();
12981 self
12982 }
12983 /// The value returned by the last `ListGatewaysResponse` Indicates that this is a continuation of a prior `ListGateways` call, and that the system should return the next page of data.
12984 ///
12985 /// Sets the *page token* query property to the given value.
12986 pub fn page_token(mut self, new_value: &str) -> ProjectLocationGatewayListCall<'a, C> {
12987 self._page_token = Some(new_value.to_string());
12988 self
12989 }
12990 /// Maximum number of Gateways to return per call.
12991 ///
12992 /// Sets the *page size* query property to the given value.
12993 pub fn page_size(mut self, new_value: i32) -> ProjectLocationGatewayListCall<'a, C> {
12994 self._page_size = Some(new_value);
12995 self
12996 }
12997 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12998 /// while executing the actual API request.
12999 ///
13000 /// ````text
13001 /// It should be used to handle progress information, and to implement a certain level of resilience.
13002 /// ````
13003 ///
13004 /// Sets the *delegate* property to the given value.
13005 pub fn delegate(
13006 mut self,
13007 new_value: &'a mut dyn common::Delegate,
13008 ) -> ProjectLocationGatewayListCall<'a, C> {
13009 self._delegate = Some(new_value);
13010 self
13011 }
13012
13013 /// Set any additional parameter of the query string used in the request.
13014 /// It should be used to set parameters which are not yet available through their own
13015 /// setters.
13016 ///
13017 /// Please note that this method must not be used to set any of the known parameters
13018 /// which have their own setter method. If done anyway, the request will fail.
13019 ///
13020 /// # Additional Parameters
13021 ///
13022 /// * *$.xgafv* (query-string) - V1 error format.
13023 /// * *access_token* (query-string) - OAuth access token.
13024 /// * *alt* (query-string) - Data format for response.
13025 /// * *callback* (query-string) - JSONP
13026 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13027 /// * *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.
13028 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13029 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13030 /// * *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.
13031 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13032 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13033 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGatewayListCall<'a, C>
13034 where
13035 T: AsRef<str>,
13036 {
13037 self._additional_params
13038 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13039 self
13040 }
13041
13042 /// Identifies the authorization scope for the method you are building.
13043 ///
13044 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13045 /// [`Scope::CloudPlatform`].
13046 ///
13047 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13048 /// tokens for more than one scope.
13049 ///
13050 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13051 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13052 /// sufficient, a read-write scope will do as well.
13053 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGatewayListCall<'a, C>
13054 where
13055 St: AsRef<str>,
13056 {
13057 self._scopes.insert(String::from(scope.as_ref()));
13058 self
13059 }
13060 /// Identifies the authorization scope(s) for the method you are building.
13061 ///
13062 /// See [`Self::add_scope()`] for details.
13063 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGatewayListCall<'a, C>
13064 where
13065 I: IntoIterator<Item = St>,
13066 St: AsRef<str>,
13067 {
13068 self._scopes
13069 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13070 self
13071 }
13072
13073 /// Removes all scopes, and no default scope will be used either.
13074 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13075 /// for details).
13076 pub fn clear_scopes(mut self) -> ProjectLocationGatewayListCall<'a, C> {
13077 self._scopes.clear();
13078 self
13079 }
13080}
13081
13082/// Updates the parameters of a single Gateway.
13083///
13084/// A builder for the *locations.gateways.patch* method supported by a *project* resource.
13085/// It is not used directly, but through a [`ProjectMethods`] instance.
13086///
13087/// # Example
13088///
13089/// Instantiate a resource method builder
13090///
13091/// ```test_harness,no_run
13092/// # extern crate hyper;
13093/// # extern crate hyper_rustls;
13094/// # extern crate google_networkservices1 as networkservices1;
13095/// use networkservices1::api::Gateway;
13096/// # async fn dox() {
13097/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13098///
13099/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13100/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13101/// # .with_native_roots()
13102/// # .unwrap()
13103/// # .https_only()
13104/// # .enable_http2()
13105/// # .build();
13106///
13107/// # let executor = hyper_util::rt::TokioExecutor::new();
13108/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13109/// # secret,
13110/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13111/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13112/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13113/// # ),
13114/// # ).build().await.unwrap();
13115///
13116/// # let client = hyper_util::client::legacy::Client::builder(
13117/// # hyper_util::rt::TokioExecutor::new()
13118/// # )
13119/// # .build(
13120/// # hyper_rustls::HttpsConnectorBuilder::new()
13121/// # .with_native_roots()
13122/// # .unwrap()
13123/// # .https_or_http()
13124/// # .enable_http2()
13125/// # .build()
13126/// # );
13127/// # let mut hub = NetworkServices::new(client, auth);
13128/// // As the method needs a request, you would usually fill it with the desired information
13129/// // into the respective structure. Some of the parts shown here might not be applicable !
13130/// // Values shown here are possibly random and not representative !
13131/// let mut req = Gateway::default();
13132///
13133/// // You can configure optional parameters by calling the respective setters at will, and
13134/// // execute the final call using `doit()`.
13135/// // Values shown here are possibly random and not representative !
13136/// let result = hub.projects().locations_gateways_patch(req, "name")
13137/// .update_mask(FieldMask::new::<&str>(&[]))
13138/// .doit().await;
13139/// # }
13140/// ```
13141pub struct ProjectLocationGatewayPatchCall<'a, C>
13142where
13143 C: 'a,
13144{
13145 hub: &'a NetworkServices<C>,
13146 _request: Gateway,
13147 _name: String,
13148 _update_mask: Option<common::FieldMask>,
13149 _delegate: Option<&'a mut dyn common::Delegate>,
13150 _additional_params: HashMap<String, String>,
13151 _scopes: BTreeSet<String>,
13152}
13153
13154impl<'a, C> common::CallBuilder for ProjectLocationGatewayPatchCall<'a, C> {}
13155
13156impl<'a, C> ProjectLocationGatewayPatchCall<'a, C>
13157where
13158 C: common::Connector,
13159{
13160 /// Perform the operation you have build so far.
13161 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
13162 use std::borrow::Cow;
13163 use std::io::{Read, Seek};
13164
13165 use common::{url::Params, ToParts};
13166 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13167
13168 let mut dd = common::DefaultDelegate;
13169 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13170 dlg.begin(common::MethodInfo {
13171 id: "networkservices.projects.locations.gateways.patch",
13172 http_method: hyper::Method::PATCH,
13173 });
13174
13175 for &field in ["alt", "name", "updateMask"].iter() {
13176 if self._additional_params.contains_key(field) {
13177 dlg.finished(false);
13178 return Err(common::Error::FieldClash(field));
13179 }
13180 }
13181
13182 let mut params = Params::with_capacity(5 + self._additional_params.len());
13183 params.push("name", self._name);
13184 if let Some(value) = self._update_mask.as_ref() {
13185 params.push("updateMask", value.to_string());
13186 }
13187
13188 params.extend(self._additional_params.iter());
13189
13190 params.push("alt", "json");
13191 let mut url = self.hub._base_url.clone() + "v1/{+name}";
13192 if self._scopes.is_empty() {
13193 self._scopes
13194 .insert(Scope::CloudPlatform.as_ref().to_string());
13195 }
13196
13197 #[allow(clippy::single_element_loop)]
13198 for &(find_this, param_name) in [("{+name}", "name")].iter() {
13199 url = params.uri_replacement(url, param_name, find_this, true);
13200 }
13201 {
13202 let to_remove = ["name"];
13203 params.remove_params(&to_remove);
13204 }
13205
13206 let url = params.parse_with_url(&url);
13207
13208 let mut json_mime_type = mime::APPLICATION_JSON;
13209 let mut request_value_reader = {
13210 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13211 common::remove_json_null_values(&mut value);
13212 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13213 serde_json::to_writer(&mut dst, &value).unwrap();
13214 dst
13215 };
13216 let request_size = request_value_reader
13217 .seek(std::io::SeekFrom::End(0))
13218 .unwrap();
13219 request_value_reader
13220 .seek(std::io::SeekFrom::Start(0))
13221 .unwrap();
13222
13223 loop {
13224 let token = match self
13225 .hub
13226 .auth
13227 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13228 .await
13229 {
13230 Ok(token) => token,
13231 Err(e) => match dlg.token(e) {
13232 Ok(token) => token,
13233 Err(e) => {
13234 dlg.finished(false);
13235 return Err(common::Error::MissingToken(e));
13236 }
13237 },
13238 };
13239 request_value_reader
13240 .seek(std::io::SeekFrom::Start(0))
13241 .unwrap();
13242 let mut req_result = {
13243 let client = &self.hub.client;
13244 dlg.pre_request();
13245 let mut req_builder = hyper::Request::builder()
13246 .method(hyper::Method::PATCH)
13247 .uri(url.as_str())
13248 .header(USER_AGENT, self.hub._user_agent.clone());
13249
13250 if let Some(token) = token.as_ref() {
13251 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13252 }
13253
13254 let request = req_builder
13255 .header(CONTENT_TYPE, json_mime_type.to_string())
13256 .header(CONTENT_LENGTH, request_size as u64)
13257 .body(common::to_body(
13258 request_value_reader.get_ref().clone().into(),
13259 ));
13260
13261 client.request(request.unwrap()).await
13262 };
13263
13264 match req_result {
13265 Err(err) => {
13266 if let common::Retry::After(d) = dlg.http_error(&err) {
13267 sleep(d).await;
13268 continue;
13269 }
13270 dlg.finished(false);
13271 return Err(common::Error::HttpError(err));
13272 }
13273 Ok(res) => {
13274 let (mut parts, body) = res.into_parts();
13275 let mut body = common::Body::new(body);
13276 if !parts.status.is_success() {
13277 let bytes = common::to_bytes(body).await.unwrap_or_default();
13278 let error = serde_json::from_str(&common::to_string(&bytes));
13279 let response = common::to_response(parts, bytes.into());
13280
13281 if let common::Retry::After(d) =
13282 dlg.http_failure(&response, error.as_ref().ok())
13283 {
13284 sleep(d).await;
13285 continue;
13286 }
13287
13288 dlg.finished(false);
13289
13290 return Err(match error {
13291 Ok(value) => common::Error::BadRequest(value),
13292 _ => common::Error::Failure(response),
13293 });
13294 }
13295 let response = {
13296 let bytes = common::to_bytes(body).await.unwrap_or_default();
13297 let encoded = common::to_string(&bytes);
13298 match serde_json::from_str(&encoded) {
13299 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13300 Err(error) => {
13301 dlg.response_json_decode_error(&encoded, &error);
13302 return Err(common::Error::JsonDecodeError(
13303 encoded.to_string(),
13304 error,
13305 ));
13306 }
13307 }
13308 };
13309
13310 dlg.finished(true);
13311 return Ok(response);
13312 }
13313 }
13314 }
13315 }
13316
13317 ///
13318 /// Sets the *request* property to the given value.
13319 ///
13320 /// Even though the property as already been set when instantiating this call,
13321 /// we provide this method for API completeness.
13322 pub fn request(mut self, new_value: Gateway) -> ProjectLocationGatewayPatchCall<'a, C> {
13323 self._request = new_value;
13324 self
13325 }
13326 /// Identifier. Name of the Gateway resource. It matches pattern `projects/*/locations/*/gateways/`.
13327 ///
13328 /// Sets the *name* path property to the given value.
13329 ///
13330 /// Even though the property as already been set when instantiating this call,
13331 /// we provide this method for API completeness.
13332 pub fn name(mut self, new_value: &str) -> ProjectLocationGatewayPatchCall<'a, C> {
13333 self._name = new_value.to_string();
13334 self
13335 }
13336 /// Optional. Field mask is used to specify the fields to be overwritten in the Gateway 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.
13337 ///
13338 /// Sets the *update mask* query property to the given value.
13339 pub fn update_mask(
13340 mut self,
13341 new_value: common::FieldMask,
13342 ) -> ProjectLocationGatewayPatchCall<'a, C> {
13343 self._update_mask = Some(new_value);
13344 self
13345 }
13346 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13347 /// while executing the actual API request.
13348 ///
13349 /// ````text
13350 /// It should be used to handle progress information, and to implement a certain level of resilience.
13351 /// ````
13352 ///
13353 /// Sets the *delegate* property to the given value.
13354 pub fn delegate(
13355 mut self,
13356 new_value: &'a mut dyn common::Delegate,
13357 ) -> ProjectLocationGatewayPatchCall<'a, C> {
13358 self._delegate = Some(new_value);
13359 self
13360 }
13361
13362 /// Set any additional parameter of the query string used in the request.
13363 /// It should be used to set parameters which are not yet available through their own
13364 /// setters.
13365 ///
13366 /// Please note that this method must not be used to set any of the known parameters
13367 /// which have their own setter method. If done anyway, the request will fail.
13368 ///
13369 /// # Additional Parameters
13370 ///
13371 /// * *$.xgafv* (query-string) - V1 error format.
13372 /// * *access_token* (query-string) - OAuth access token.
13373 /// * *alt* (query-string) - Data format for response.
13374 /// * *callback* (query-string) - JSONP
13375 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13376 /// * *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.
13377 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13378 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13379 /// * *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.
13380 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13381 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13382 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGatewayPatchCall<'a, C>
13383 where
13384 T: AsRef<str>,
13385 {
13386 self._additional_params
13387 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13388 self
13389 }
13390
13391 /// Identifies the authorization scope for the method you are building.
13392 ///
13393 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13394 /// [`Scope::CloudPlatform`].
13395 ///
13396 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13397 /// tokens for more than one scope.
13398 ///
13399 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13400 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13401 /// sufficient, a read-write scope will do as well.
13402 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGatewayPatchCall<'a, C>
13403 where
13404 St: AsRef<str>,
13405 {
13406 self._scopes.insert(String::from(scope.as_ref()));
13407 self
13408 }
13409 /// Identifies the authorization scope(s) for the method you are building.
13410 ///
13411 /// See [`Self::add_scope()`] for details.
13412 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGatewayPatchCall<'a, C>
13413 where
13414 I: IntoIterator<Item = St>,
13415 St: AsRef<str>,
13416 {
13417 self._scopes
13418 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13419 self
13420 }
13421
13422 /// Removes all scopes, and no default scope will be used either.
13423 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13424 /// for details).
13425 pub fn clear_scopes(mut self) -> ProjectLocationGatewayPatchCall<'a, C> {
13426 self._scopes.clear();
13427 self
13428 }
13429}
13430
13431/// Creates a new GrpcRoute in a given project and location.
13432///
13433/// A builder for the *locations.grpcRoutes.create* method supported by a *project* resource.
13434/// It is not used directly, but through a [`ProjectMethods`] instance.
13435///
13436/// # Example
13437///
13438/// Instantiate a resource method builder
13439///
13440/// ```test_harness,no_run
13441/// # extern crate hyper;
13442/// # extern crate hyper_rustls;
13443/// # extern crate google_networkservices1 as networkservices1;
13444/// use networkservices1::api::GrpcRoute;
13445/// # async fn dox() {
13446/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13447///
13448/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13449/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13450/// # .with_native_roots()
13451/// # .unwrap()
13452/// # .https_only()
13453/// # .enable_http2()
13454/// # .build();
13455///
13456/// # let executor = hyper_util::rt::TokioExecutor::new();
13457/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13458/// # secret,
13459/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13460/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13461/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13462/// # ),
13463/// # ).build().await.unwrap();
13464///
13465/// # let client = hyper_util::client::legacy::Client::builder(
13466/// # hyper_util::rt::TokioExecutor::new()
13467/// # )
13468/// # .build(
13469/// # hyper_rustls::HttpsConnectorBuilder::new()
13470/// # .with_native_roots()
13471/// # .unwrap()
13472/// # .https_or_http()
13473/// # .enable_http2()
13474/// # .build()
13475/// # );
13476/// # let mut hub = NetworkServices::new(client, auth);
13477/// // As the method needs a request, you would usually fill it with the desired information
13478/// // into the respective structure. Some of the parts shown here might not be applicable !
13479/// // Values shown here are possibly random and not representative !
13480/// let mut req = GrpcRoute::default();
13481///
13482/// // You can configure optional parameters by calling the respective setters at will, and
13483/// // execute the final call using `doit()`.
13484/// // Values shown here are possibly random and not representative !
13485/// let result = hub.projects().locations_grpc_routes_create(req, "parent")
13486/// .grpc_route_id("consetetur")
13487/// .doit().await;
13488/// # }
13489/// ```
13490pub struct ProjectLocationGrpcRouteCreateCall<'a, C>
13491where
13492 C: 'a,
13493{
13494 hub: &'a NetworkServices<C>,
13495 _request: GrpcRoute,
13496 _parent: String,
13497 _grpc_route_id: Option<String>,
13498 _delegate: Option<&'a mut dyn common::Delegate>,
13499 _additional_params: HashMap<String, String>,
13500 _scopes: BTreeSet<String>,
13501}
13502
13503impl<'a, C> common::CallBuilder for ProjectLocationGrpcRouteCreateCall<'a, C> {}
13504
13505impl<'a, C> ProjectLocationGrpcRouteCreateCall<'a, C>
13506where
13507 C: common::Connector,
13508{
13509 /// Perform the operation you have build so far.
13510 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
13511 use std::borrow::Cow;
13512 use std::io::{Read, Seek};
13513
13514 use common::{url::Params, ToParts};
13515 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13516
13517 let mut dd = common::DefaultDelegate;
13518 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13519 dlg.begin(common::MethodInfo {
13520 id: "networkservices.projects.locations.grpcRoutes.create",
13521 http_method: hyper::Method::POST,
13522 });
13523
13524 for &field in ["alt", "parent", "grpcRouteId"].iter() {
13525 if self._additional_params.contains_key(field) {
13526 dlg.finished(false);
13527 return Err(common::Error::FieldClash(field));
13528 }
13529 }
13530
13531 let mut params = Params::with_capacity(5 + self._additional_params.len());
13532 params.push("parent", self._parent);
13533 if let Some(value) = self._grpc_route_id.as_ref() {
13534 params.push("grpcRouteId", value);
13535 }
13536
13537 params.extend(self._additional_params.iter());
13538
13539 params.push("alt", "json");
13540 let mut url = self.hub._base_url.clone() + "v1/{+parent}/grpcRoutes";
13541 if self._scopes.is_empty() {
13542 self._scopes
13543 .insert(Scope::CloudPlatform.as_ref().to_string());
13544 }
13545
13546 #[allow(clippy::single_element_loop)]
13547 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
13548 url = params.uri_replacement(url, param_name, find_this, true);
13549 }
13550 {
13551 let to_remove = ["parent"];
13552 params.remove_params(&to_remove);
13553 }
13554
13555 let url = params.parse_with_url(&url);
13556
13557 let mut json_mime_type = mime::APPLICATION_JSON;
13558 let mut request_value_reader = {
13559 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13560 common::remove_json_null_values(&mut value);
13561 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13562 serde_json::to_writer(&mut dst, &value).unwrap();
13563 dst
13564 };
13565 let request_size = request_value_reader
13566 .seek(std::io::SeekFrom::End(0))
13567 .unwrap();
13568 request_value_reader
13569 .seek(std::io::SeekFrom::Start(0))
13570 .unwrap();
13571
13572 loop {
13573 let token = match self
13574 .hub
13575 .auth
13576 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13577 .await
13578 {
13579 Ok(token) => token,
13580 Err(e) => match dlg.token(e) {
13581 Ok(token) => token,
13582 Err(e) => {
13583 dlg.finished(false);
13584 return Err(common::Error::MissingToken(e));
13585 }
13586 },
13587 };
13588 request_value_reader
13589 .seek(std::io::SeekFrom::Start(0))
13590 .unwrap();
13591 let mut req_result = {
13592 let client = &self.hub.client;
13593 dlg.pre_request();
13594 let mut req_builder = hyper::Request::builder()
13595 .method(hyper::Method::POST)
13596 .uri(url.as_str())
13597 .header(USER_AGENT, self.hub._user_agent.clone());
13598
13599 if let Some(token) = token.as_ref() {
13600 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13601 }
13602
13603 let request = req_builder
13604 .header(CONTENT_TYPE, json_mime_type.to_string())
13605 .header(CONTENT_LENGTH, request_size as u64)
13606 .body(common::to_body(
13607 request_value_reader.get_ref().clone().into(),
13608 ));
13609
13610 client.request(request.unwrap()).await
13611 };
13612
13613 match req_result {
13614 Err(err) => {
13615 if let common::Retry::After(d) = dlg.http_error(&err) {
13616 sleep(d).await;
13617 continue;
13618 }
13619 dlg.finished(false);
13620 return Err(common::Error::HttpError(err));
13621 }
13622 Ok(res) => {
13623 let (mut parts, body) = res.into_parts();
13624 let mut body = common::Body::new(body);
13625 if !parts.status.is_success() {
13626 let bytes = common::to_bytes(body).await.unwrap_or_default();
13627 let error = serde_json::from_str(&common::to_string(&bytes));
13628 let response = common::to_response(parts, bytes.into());
13629
13630 if let common::Retry::After(d) =
13631 dlg.http_failure(&response, error.as_ref().ok())
13632 {
13633 sleep(d).await;
13634 continue;
13635 }
13636
13637 dlg.finished(false);
13638
13639 return Err(match error {
13640 Ok(value) => common::Error::BadRequest(value),
13641 _ => common::Error::Failure(response),
13642 });
13643 }
13644 let response = {
13645 let bytes = common::to_bytes(body).await.unwrap_or_default();
13646 let encoded = common::to_string(&bytes);
13647 match serde_json::from_str(&encoded) {
13648 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13649 Err(error) => {
13650 dlg.response_json_decode_error(&encoded, &error);
13651 return Err(common::Error::JsonDecodeError(
13652 encoded.to_string(),
13653 error,
13654 ));
13655 }
13656 }
13657 };
13658
13659 dlg.finished(true);
13660 return Ok(response);
13661 }
13662 }
13663 }
13664 }
13665
13666 ///
13667 /// Sets the *request* property to the given value.
13668 ///
13669 /// Even though the property as already been set when instantiating this call,
13670 /// we provide this method for API completeness.
13671 pub fn request(mut self, new_value: GrpcRoute) -> ProjectLocationGrpcRouteCreateCall<'a, C> {
13672 self._request = new_value;
13673 self
13674 }
13675 /// Required. The parent resource of the GrpcRoute. Must be in the format `projects/*/locations/*`.
13676 ///
13677 /// Sets the *parent* path property to the given value.
13678 ///
13679 /// Even though the property as already been set when instantiating this call,
13680 /// we provide this method for API completeness.
13681 pub fn parent(mut self, new_value: &str) -> ProjectLocationGrpcRouteCreateCall<'a, C> {
13682 self._parent = new_value.to_string();
13683 self
13684 }
13685 /// Required. Short name of the GrpcRoute resource to be created.
13686 ///
13687 /// Sets the *grpc route id* query property to the given value.
13688 pub fn grpc_route_id(mut self, new_value: &str) -> ProjectLocationGrpcRouteCreateCall<'a, C> {
13689 self._grpc_route_id = Some(new_value.to_string());
13690 self
13691 }
13692 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13693 /// while executing the actual API request.
13694 ///
13695 /// ````text
13696 /// It should be used to handle progress information, and to implement a certain level of resilience.
13697 /// ````
13698 ///
13699 /// Sets the *delegate* property to the given value.
13700 pub fn delegate(
13701 mut self,
13702 new_value: &'a mut dyn common::Delegate,
13703 ) -> ProjectLocationGrpcRouteCreateCall<'a, C> {
13704 self._delegate = Some(new_value);
13705 self
13706 }
13707
13708 /// Set any additional parameter of the query string used in the request.
13709 /// It should be used to set parameters which are not yet available through their own
13710 /// setters.
13711 ///
13712 /// Please note that this method must not be used to set any of the known parameters
13713 /// which have their own setter method. If done anyway, the request will fail.
13714 ///
13715 /// # Additional Parameters
13716 ///
13717 /// * *$.xgafv* (query-string) - V1 error format.
13718 /// * *access_token* (query-string) - OAuth access token.
13719 /// * *alt* (query-string) - Data format for response.
13720 /// * *callback* (query-string) - JSONP
13721 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13722 /// * *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.
13723 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13724 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13725 /// * *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.
13726 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13727 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13728 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGrpcRouteCreateCall<'a, C>
13729 where
13730 T: AsRef<str>,
13731 {
13732 self._additional_params
13733 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13734 self
13735 }
13736
13737 /// Identifies the authorization scope for the method you are building.
13738 ///
13739 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13740 /// [`Scope::CloudPlatform`].
13741 ///
13742 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13743 /// tokens for more than one scope.
13744 ///
13745 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13746 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13747 /// sufficient, a read-write scope will do as well.
13748 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGrpcRouteCreateCall<'a, C>
13749 where
13750 St: AsRef<str>,
13751 {
13752 self._scopes.insert(String::from(scope.as_ref()));
13753 self
13754 }
13755 /// Identifies the authorization scope(s) for the method you are building.
13756 ///
13757 /// See [`Self::add_scope()`] for details.
13758 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGrpcRouteCreateCall<'a, C>
13759 where
13760 I: IntoIterator<Item = St>,
13761 St: AsRef<str>,
13762 {
13763 self._scopes
13764 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13765 self
13766 }
13767
13768 /// Removes all scopes, and no default scope will be used either.
13769 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13770 /// for details).
13771 pub fn clear_scopes(mut self) -> ProjectLocationGrpcRouteCreateCall<'a, C> {
13772 self._scopes.clear();
13773 self
13774 }
13775}
13776
13777/// Deletes a single GrpcRoute.
13778///
13779/// A builder for the *locations.grpcRoutes.delete* method supported by a *project* resource.
13780/// It is not used directly, but through a [`ProjectMethods`] instance.
13781///
13782/// # Example
13783///
13784/// Instantiate a resource method builder
13785///
13786/// ```test_harness,no_run
13787/// # extern crate hyper;
13788/// # extern crate hyper_rustls;
13789/// # extern crate google_networkservices1 as networkservices1;
13790/// # async fn dox() {
13791/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13792///
13793/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13794/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13795/// # .with_native_roots()
13796/// # .unwrap()
13797/// # .https_only()
13798/// # .enable_http2()
13799/// # .build();
13800///
13801/// # let executor = hyper_util::rt::TokioExecutor::new();
13802/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13803/// # secret,
13804/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13805/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13806/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13807/// # ),
13808/// # ).build().await.unwrap();
13809///
13810/// # let client = hyper_util::client::legacy::Client::builder(
13811/// # hyper_util::rt::TokioExecutor::new()
13812/// # )
13813/// # .build(
13814/// # hyper_rustls::HttpsConnectorBuilder::new()
13815/// # .with_native_roots()
13816/// # .unwrap()
13817/// # .https_or_http()
13818/// # .enable_http2()
13819/// # .build()
13820/// # );
13821/// # let mut hub = NetworkServices::new(client, auth);
13822/// // You can configure optional parameters by calling the respective setters at will, and
13823/// // execute the final call using `doit()`.
13824/// // Values shown here are possibly random and not representative !
13825/// let result = hub.projects().locations_grpc_routes_delete("name")
13826/// .doit().await;
13827/// # }
13828/// ```
13829pub struct ProjectLocationGrpcRouteDeleteCall<'a, C>
13830where
13831 C: 'a,
13832{
13833 hub: &'a NetworkServices<C>,
13834 _name: String,
13835 _delegate: Option<&'a mut dyn common::Delegate>,
13836 _additional_params: HashMap<String, String>,
13837 _scopes: BTreeSet<String>,
13838}
13839
13840impl<'a, C> common::CallBuilder for ProjectLocationGrpcRouteDeleteCall<'a, C> {}
13841
13842impl<'a, C> ProjectLocationGrpcRouteDeleteCall<'a, C>
13843where
13844 C: common::Connector,
13845{
13846 /// Perform the operation you have build so far.
13847 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
13848 use std::borrow::Cow;
13849 use std::io::{Read, Seek};
13850
13851 use common::{url::Params, ToParts};
13852 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13853
13854 let mut dd = common::DefaultDelegate;
13855 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13856 dlg.begin(common::MethodInfo {
13857 id: "networkservices.projects.locations.grpcRoutes.delete",
13858 http_method: hyper::Method::DELETE,
13859 });
13860
13861 for &field in ["alt", "name"].iter() {
13862 if self._additional_params.contains_key(field) {
13863 dlg.finished(false);
13864 return Err(common::Error::FieldClash(field));
13865 }
13866 }
13867
13868 let mut params = Params::with_capacity(3 + self._additional_params.len());
13869 params.push("name", self._name);
13870
13871 params.extend(self._additional_params.iter());
13872
13873 params.push("alt", "json");
13874 let mut url = self.hub._base_url.clone() + "v1/{+name}";
13875 if self._scopes.is_empty() {
13876 self._scopes
13877 .insert(Scope::CloudPlatform.as_ref().to_string());
13878 }
13879
13880 #[allow(clippy::single_element_loop)]
13881 for &(find_this, param_name) in [("{+name}", "name")].iter() {
13882 url = params.uri_replacement(url, param_name, find_this, true);
13883 }
13884 {
13885 let to_remove = ["name"];
13886 params.remove_params(&to_remove);
13887 }
13888
13889 let url = params.parse_with_url(&url);
13890
13891 loop {
13892 let token = match self
13893 .hub
13894 .auth
13895 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13896 .await
13897 {
13898 Ok(token) => token,
13899 Err(e) => match dlg.token(e) {
13900 Ok(token) => token,
13901 Err(e) => {
13902 dlg.finished(false);
13903 return Err(common::Error::MissingToken(e));
13904 }
13905 },
13906 };
13907 let mut req_result = {
13908 let client = &self.hub.client;
13909 dlg.pre_request();
13910 let mut req_builder = hyper::Request::builder()
13911 .method(hyper::Method::DELETE)
13912 .uri(url.as_str())
13913 .header(USER_AGENT, self.hub._user_agent.clone());
13914
13915 if let Some(token) = token.as_ref() {
13916 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13917 }
13918
13919 let request = req_builder
13920 .header(CONTENT_LENGTH, 0_u64)
13921 .body(common::to_body::<String>(None));
13922
13923 client.request(request.unwrap()).await
13924 };
13925
13926 match req_result {
13927 Err(err) => {
13928 if let common::Retry::After(d) = dlg.http_error(&err) {
13929 sleep(d).await;
13930 continue;
13931 }
13932 dlg.finished(false);
13933 return Err(common::Error::HttpError(err));
13934 }
13935 Ok(res) => {
13936 let (mut parts, body) = res.into_parts();
13937 let mut body = common::Body::new(body);
13938 if !parts.status.is_success() {
13939 let bytes = common::to_bytes(body).await.unwrap_or_default();
13940 let error = serde_json::from_str(&common::to_string(&bytes));
13941 let response = common::to_response(parts, bytes.into());
13942
13943 if let common::Retry::After(d) =
13944 dlg.http_failure(&response, error.as_ref().ok())
13945 {
13946 sleep(d).await;
13947 continue;
13948 }
13949
13950 dlg.finished(false);
13951
13952 return Err(match error {
13953 Ok(value) => common::Error::BadRequest(value),
13954 _ => common::Error::Failure(response),
13955 });
13956 }
13957 let response = {
13958 let bytes = common::to_bytes(body).await.unwrap_or_default();
13959 let encoded = common::to_string(&bytes);
13960 match serde_json::from_str(&encoded) {
13961 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13962 Err(error) => {
13963 dlg.response_json_decode_error(&encoded, &error);
13964 return Err(common::Error::JsonDecodeError(
13965 encoded.to_string(),
13966 error,
13967 ));
13968 }
13969 }
13970 };
13971
13972 dlg.finished(true);
13973 return Ok(response);
13974 }
13975 }
13976 }
13977 }
13978
13979 /// Required. A name of the GrpcRoute to delete. Must be in the format `projects/*/locations/*/grpcRoutes/*`.
13980 ///
13981 /// Sets the *name* path property to the given value.
13982 ///
13983 /// Even though the property as already been set when instantiating this call,
13984 /// we provide this method for API completeness.
13985 pub fn name(mut self, new_value: &str) -> ProjectLocationGrpcRouteDeleteCall<'a, C> {
13986 self._name = new_value.to_string();
13987 self
13988 }
13989 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13990 /// while executing the actual API request.
13991 ///
13992 /// ````text
13993 /// It should be used to handle progress information, and to implement a certain level of resilience.
13994 /// ````
13995 ///
13996 /// Sets the *delegate* property to the given value.
13997 pub fn delegate(
13998 mut self,
13999 new_value: &'a mut dyn common::Delegate,
14000 ) -> ProjectLocationGrpcRouteDeleteCall<'a, C> {
14001 self._delegate = Some(new_value);
14002 self
14003 }
14004
14005 /// Set any additional parameter of the query string used in the request.
14006 /// It should be used to set parameters which are not yet available through their own
14007 /// setters.
14008 ///
14009 /// Please note that this method must not be used to set any of the known parameters
14010 /// which have their own setter method. If done anyway, the request will fail.
14011 ///
14012 /// # Additional Parameters
14013 ///
14014 /// * *$.xgafv* (query-string) - V1 error format.
14015 /// * *access_token* (query-string) - OAuth access token.
14016 /// * *alt* (query-string) - Data format for response.
14017 /// * *callback* (query-string) - JSONP
14018 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14019 /// * *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.
14020 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14021 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14022 /// * *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.
14023 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14024 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14025 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGrpcRouteDeleteCall<'a, C>
14026 where
14027 T: AsRef<str>,
14028 {
14029 self._additional_params
14030 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14031 self
14032 }
14033
14034 /// Identifies the authorization scope for the method you are building.
14035 ///
14036 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14037 /// [`Scope::CloudPlatform`].
14038 ///
14039 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14040 /// tokens for more than one scope.
14041 ///
14042 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14043 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14044 /// sufficient, a read-write scope will do as well.
14045 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGrpcRouteDeleteCall<'a, C>
14046 where
14047 St: AsRef<str>,
14048 {
14049 self._scopes.insert(String::from(scope.as_ref()));
14050 self
14051 }
14052 /// Identifies the authorization scope(s) for the method you are building.
14053 ///
14054 /// See [`Self::add_scope()`] for details.
14055 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGrpcRouteDeleteCall<'a, C>
14056 where
14057 I: IntoIterator<Item = St>,
14058 St: AsRef<str>,
14059 {
14060 self._scopes
14061 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14062 self
14063 }
14064
14065 /// Removes all scopes, and no default scope will be used either.
14066 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14067 /// for details).
14068 pub fn clear_scopes(mut self) -> ProjectLocationGrpcRouteDeleteCall<'a, C> {
14069 self._scopes.clear();
14070 self
14071 }
14072}
14073
14074/// Gets details of a single GrpcRoute.
14075///
14076/// A builder for the *locations.grpcRoutes.get* method supported by a *project* resource.
14077/// It is not used directly, but through a [`ProjectMethods`] instance.
14078///
14079/// # Example
14080///
14081/// Instantiate a resource method builder
14082///
14083/// ```test_harness,no_run
14084/// # extern crate hyper;
14085/// # extern crate hyper_rustls;
14086/// # extern crate google_networkservices1 as networkservices1;
14087/// # async fn dox() {
14088/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14089///
14090/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14091/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14092/// # .with_native_roots()
14093/// # .unwrap()
14094/// # .https_only()
14095/// # .enable_http2()
14096/// # .build();
14097///
14098/// # let executor = hyper_util::rt::TokioExecutor::new();
14099/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14100/// # secret,
14101/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14102/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14103/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14104/// # ),
14105/// # ).build().await.unwrap();
14106///
14107/// # let client = hyper_util::client::legacy::Client::builder(
14108/// # hyper_util::rt::TokioExecutor::new()
14109/// # )
14110/// # .build(
14111/// # hyper_rustls::HttpsConnectorBuilder::new()
14112/// # .with_native_roots()
14113/// # .unwrap()
14114/// # .https_or_http()
14115/// # .enable_http2()
14116/// # .build()
14117/// # );
14118/// # let mut hub = NetworkServices::new(client, auth);
14119/// // You can configure optional parameters by calling the respective setters at will, and
14120/// // execute the final call using `doit()`.
14121/// // Values shown here are possibly random and not representative !
14122/// let result = hub.projects().locations_grpc_routes_get("name")
14123/// .doit().await;
14124/// # }
14125/// ```
14126pub struct ProjectLocationGrpcRouteGetCall<'a, C>
14127where
14128 C: 'a,
14129{
14130 hub: &'a NetworkServices<C>,
14131 _name: String,
14132 _delegate: Option<&'a mut dyn common::Delegate>,
14133 _additional_params: HashMap<String, String>,
14134 _scopes: BTreeSet<String>,
14135}
14136
14137impl<'a, C> common::CallBuilder for ProjectLocationGrpcRouteGetCall<'a, C> {}
14138
14139impl<'a, C> ProjectLocationGrpcRouteGetCall<'a, C>
14140where
14141 C: common::Connector,
14142{
14143 /// Perform the operation you have build so far.
14144 pub async fn doit(mut self) -> common::Result<(common::Response, GrpcRoute)> {
14145 use std::borrow::Cow;
14146 use std::io::{Read, Seek};
14147
14148 use common::{url::Params, ToParts};
14149 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14150
14151 let mut dd = common::DefaultDelegate;
14152 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14153 dlg.begin(common::MethodInfo {
14154 id: "networkservices.projects.locations.grpcRoutes.get",
14155 http_method: hyper::Method::GET,
14156 });
14157
14158 for &field in ["alt", "name"].iter() {
14159 if self._additional_params.contains_key(field) {
14160 dlg.finished(false);
14161 return Err(common::Error::FieldClash(field));
14162 }
14163 }
14164
14165 let mut params = Params::with_capacity(3 + self._additional_params.len());
14166 params.push("name", self._name);
14167
14168 params.extend(self._additional_params.iter());
14169
14170 params.push("alt", "json");
14171 let mut url = self.hub._base_url.clone() + "v1/{+name}";
14172 if self._scopes.is_empty() {
14173 self._scopes
14174 .insert(Scope::CloudPlatform.as_ref().to_string());
14175 }
14176
14177 #[allow(clippy::single_element_loop)]
14178 for &(find_this, param_name) in [("{+name}", "name")].iter() {
14179 url = params.uri_replacement(url, param_name, find_this, true);
14180 }
14181 {
14182 let to_remove = ["name"];
14183 params.remove_params(&to_remove);
14184 }
14185
14186 let url = params.parse_with_url(&url);
14187
14188 loop {
14189 let token = match self
14190 .hub
14191 .auth
14192 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14193 .await
14194 {
14195 Ok(token) => token,
14196 Err(e) => match dlg.token(e) {
14197 Ok(token) => token,
14198 Err(e) => {
14199 dlg.finished(false);
14200 return Err(common::Error::MissingToken(e));
14201 }
14202 },
14203 };
14204 let mut req_result = {
14205 let client = &self.hub.client;
14206 dlg.pre_request();
14207 let mut req_builder = hyper::Request::builder()
14208 .method(hyper::Method::GET)
14209 .uri(url.as_str())
14210 .header(USER_AGENT, self.hub._user_agent.clone());
14211
14212 if let Some(token) = token.as_ref() {
14213 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14214 }
14215
14216 let request = req_builder
14217 .header(CONTENT_LENGTH, 0_u64)
14218 .body(common::to_body::<String>(None));
14219
14220 client.request(request.unwrap()).await
14221 };
14222
14223 match req_result {
14224 Err(err) => {
14225 if let common::Retry::After(d) = dlg.http_error(&err) {
14226 sleep(d).await;
14227 continue;
14228 }
14229 dlg.finished(false);
14230 return Err(common::Error::HttpError(err));
14231 }
14232 Ok(res) => {
14233 let (mut parts, body) = res.into_parts();
14234 let mut body = common::Body::new(body);
14235 if !parts.status.is_success() {
14236 let bytes = common::to_bytes(body).await.unwrap_or_default();
14237 let error = serde_json::from_str(&common::to_string(&bytes));
14238 let response = common::to_response(parts, bytes.into());
14239
14240 if let common::Retry::After(d) =
14241 dlg.http_failure(&response, error.as_ref().ok())
14242 {
14243 sleep(d).await;
14244 continue;
14245 }
14246
14247 dlg.finished(false);
14248
14249 return Err(match error {
14250 Ok(value) => common::Error::BadRequest(value),
14251 _ => common::Error::Failure(response),
14252 });
14253 }
14254 let response = {
14255 let bytes = common::to_bytes(body).await.unwrap_or_default();
14256 let encoded = common::to_string(&bytes);
14257 match serde_json::from_str(&encoded) {
14258 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14259 Err(error) => {
14260 dlg.response_json_decode_error(&encoded, &error);
14261 return Err(common::Error::JsonDecodeError(
14262 encoded.to_string(),
14263 error,
14264 ));
14265 }
14266 }
14267 };
14268
14269 dlg.finished(true);
14270 return Ok(response);
14271 }
14272 }
14273 }
14274 }
14275
14276 /// Required. A name of the GrpcRoute to get. Must be in the format `projects/*/locations/*/grpcRoutes/*`.
14277 ///
14278 /// Sets the *name* path property to the given value.
14279 ///
14280 /// Even though the property as already been set when instantiating this call,
14281 /// we provide this method for API completeness.
14282 pub fn name(mut self, new_value: &str) -> ProjectLocationGrpcRouteGetCall<'a, C> {
14283 self._name = new_value.to_string();
14284 self
14285 }
14286 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14287 /// while executing the actual API request.
14288 ///
14289 /// ````text
14290 /// It should be used to handle progress information, and to implement a certain level of resilience.
14291 /// ````
14292 ///
14293 /// Sets the *delegate* property to the given value.
14294 pub fn delegate(
14295 mut self,
14296 new_value: &'a mut dyn common::Delegate,
14297 ) -> ProjectLocationGrpcRouteGetCall<'a, C> {
14298 self._delegate = Some(new_value);
14299 self
14300 }
14301
14302 /// Set any additional parameter of the query string used in the request.
14303 /// It should be used to set parameters which are not yet available through their own
14304 /// setters.
14305 ///
14306 /// Please note that this method must not be used to set any of the known parameters
14307 /// which have their own setter method. If done anyway, the request will fail.
14308 ///
14309 /// # Additional Parameters
14310 ///
14311 /// * *$.xgafv* (query-string) - V1 error format.
14312 /// * *access_token* (query-string) - OAuth access token.
14313 /// * *alt* (query-string) - Data format for response.
14314 /// * *callback* (query-string) - JSONP
14315 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14316 /// * *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.
14317 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14318 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14319 /// * *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.
14320 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14321 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14322 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGrpcRouteGetCall<'a, C>
14323 where
14324 T: AsRef<str>,
14325 {
14326 self._additional_params
14327 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14328 self
14329 }
14330
14331 /// Identifies the authorization scope for the method you are building.
14332 ///
14333 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14334 /// [`Scope::CloudPlatform`].
14335 ///
14336 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14337 /// tokens for more than one scope.
14338 ///
14339 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14340 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14341 /// sufficient, a read-write scope will do as well.
14342 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGrpcRouteGetCall<'a, C>
14343 where
14344 St: AsRef<str>,
14345 {
14346 self._scopes.insert(String::from(scope.as_ref()));
14347 self
14348 }
14349 /// Identifies the authorization scope(s) for the method you are building.
14350 ///
14351 /// See [`Self::add_scope()`] for details.
14352 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGrpcRouteGetCall<'a, C>
14353 where
14354 I: IntoIterator<Item = St>,
14355 St: AsRef<str>,
14356 {
14357 self._scopes
14358 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14359 self
14360 }
14361
14362 /// Removes all scopes, and no default scope will be used either.
14363 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14364 /// for details).
14365 pub fn clear_scopes(mut self) -> ProjectLocationGrpcRouteGetCall<'a, C> {
14366 self._scopes.clear();
14367 self
14368 }
14369}
14370
14371/// Lists GrpcRoutes in a given project and location.
14372///
14373/// A builder for the *locations.grpcRoutes.list* method supported by a *project* resource.
14374/// It is not used directly, but through a [`ProjectMethods`] instance.
14375///
14376/// # Example
14377///
14378/// Instantiate a resource method builder
14379///
14380/// ```test_harness,no_run
14381/// # extern crate hyper;
14382/// # extern crate hyper_rustls;
14383/// # extern crate google_networkservices1 as networkservices1;
14384/// # async fn dox() {
14385/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14386///
14387/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14388/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14389/// # .with_native_roots()
14390/// # .unwrap()
14391/// # .https_only()
14392/// # .enable_http2()
14393/// # .build();
14394///
14395/// # let executor = hyper_util::rt::TokioExecutor::new();
14396/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14397/// # secret,
14398/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14399/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14400/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14401/// # ),
14402/// # ).build().await.unwrap();
14403///
14404/// # let client = hyper_util::client::legacy::Client::builder(
14405/// # hyper_util::rt::TokioExecutor::new()
14406/// # )
14407/// # .build(
14408/// # hyper_rustls::HttpsConnectorBuilder::new()
14409/// # .with_native_roots()
14410/// # .unwrap()
14411/// # .https_or_http()
14412/// # .enable_http2()
14413/// # .build()
14414/// # );
14415/// # let mut hub = NetworkServices::new(client, auth);
14416/// // You can configure optional parameters by calling the respective setters at will, and
14417/// // execute the final call using `doit()`.
14418/// // Values shown here are possibly random and not representative !
14419/// let result = hub.projects().locations_grpc_routes_list("parent")
14420/// .return_partial_success(false)
14421/// .page_token("Stet")
14422/// .page_size(-99)
14423/// .doit().await;
14424/// # }
14425/// ```
14426pub struct ProjectLocationGrpcRouteListCall<'a, C>
14427where
14428 C: 'a,
14429{
14430 hub: &'a NetworkServices<C>,
14431 _parent: String,
14432 _return_partial_success: Option<bool>,
14433 _page_token: Option<String>,
14434 _page_size: Option<i32>,
14435 _delegate: Option<&'a mut dyn common::Delegate>,
14436 _additional_params: HashMap<String, String>,
14437 _scopes: BTreeSet<String>,
14438}
14439
14440impl<'a, C> common::CallBuilder for ProjectLocationGrpcRouteListCall<'a, C> {}
14441
14442impl<'a, C> ProjectLocationGrpcRouteListCall<'a, C>
14443where
14444 C: common::Connector,
14445{
14446 /// Perform the operation you have build so far.
14447 pub async fn doit(mut self) -> common::Result<(common::Response, ListGrpcRoutesResponse)> {
14448 use std::borrow::Cow;
14449 use std::io::{Read, Seek};
14450
14451 use common::{url::Params, ToParts};
14452 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14453
14454 let mut dd = common::DefaultDelegate;
14455 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14456 dlg.begin(common::MethodInfo {
14457 id: "networkservices.projects.locations.grpcRoutes.list",
14458 http_method: hyper::Method::GET,
14459 });
14460
14461 for &field in [
14462 "alt",
14463 "parent",
14464 "returnPartialSuccess",
14465 "pageToken",
14466 "pageSize",
14467 ]
14468 .iter()
14469 {
14470 if self._additional_params.contains_key(field) {
14471 dlg.finished(false);
14472 return Err(common::Error::FieldClash(field));
14473 }
14474 }
14475
14476 let mut params = Params::with_capacity(6 + self._additional_params.len());
14477 params.push("parent", self._parent);
14478 if let Some(value) = self._return_partial_success.as_ref() {
14479 params.push("returnPartialSuccess", value.to_string());
14480 }
14481 if let Some(value) = self._page_token.as_ref() {
14482 params.push("pageToken", value);
14483 }
14484 if let Some(value) = self._page_size.as_ref() {
14485 params.push("pageSize", value.to_string());
14486 }
14487
14488 params.extend(self._additional_params.iter());
14489
14490 params.push("alt", "json");
14491 let mut url = self.hub._base_url.clone() + "v1/{+parent}/grpcRoutes";
14492 if self._scopes.is_empty() {
14493 self._scopes
14494 .insert(Scope::CloudPlatform.as_ref().to_string());
14495 }
14496
14497 #[allow(clippy::single_element_loop)]
14498 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
14499 url = params.uri_replacement(url, param_name, find_this, true);
14500 }
14501 {
14502 let to_remove = ["parent"];
14503 params.remove_params(&to_remove);
14504 }
14505
14506 let url = params.parse_with_url(&url);
14507
14508 loop {
14509 let token = match self
14510 .hub
14511 .auth
14512 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14513 .await
14514 {
14515 Ok(token) => token,
14516 Err(e) => match dlg.token(e) {
14517 Ok(token) => token,
14518 Err(e) => {
14519 dlg.finished(false);
14520 return Err(common::Error::MissingToken(e));
14521 }
14522 },
14523 };
14524 let mut req_result = {
14525 let client = &self.hub.client;
14526 dlg.pre_request();
14527 let mut req_builder = hyper::Request::builder()
14528 .method(hyper::Method::GET)
14529 .uri(url.as_str())
14530 .header(USER_AGENT, self.hub._user_agent.clone());
14531
14532 if let Some(token) = token.as_ref() {
14533 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14534 }
14535
14536 let request = req_builder
14537 .header(CONTENT_LENGTH, 0_u64)
14538 .body(common::to_body::<String>(None));
14539
14540 client.request(request.unwrap()).await
14541 };
14542
14543 match req_result {
14544 Err(err) => {
14545 if let common::Retry::After(d) = dlg.http_error(&err) {
14546 sleep(d).await;
14547 continue;
14548 }
14549 dlg.finished(false);
14550 return Err(common::Error::HttpError(err));
14551 }
14552 Ok(res) => {
14553 let (mut parts, body) = res.into_parts();
14554 let mut body = common::Body::new(body);
14555 if !parts.status.is_success() {
14556 let bytes = common::to_bytes(body).await.unwrap_or_default();
14557 let error = serde_json::from_str(&common::to_string(&bytes));
14558 let response = common::to_response(parts, bytes.into());
14559
14560 if let common::Retry::After(d) =
14561 dlg.http_failure(&response, error.as_ref().ok())
14562 {
14563 sleep(d).await;
14564 continue;
14565 }
14566
14567 dlg.finished(false);
14568
14569 return Err(match error {
14570 Ok(value) => common::Error::BadRequest(value),
14571 _ => common::Error::Failure(response),
14572 });
14573 }
14574 let response = {
14575 let bytes = common::to_bytes(body).await.unwrap_or_default();
14576 let encoded = common::to_string(&bytes);
14577 match serde_json::from_str(&encoded) {
14578 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14579 Err(error) => {
14580 dlg.response_json_decode_error(&encoded, &error);
14581 return Err(common::Error::JsonDecodeError(
14582 encoded.to_string(),
14583 error,
14584 ));
14585 }
14586 }
14587 };
14588
14589 dlg.finished(true);
14590 return Ok(response);
14591 }
14592 }
14593 }
14594 }
14595
14596 /// Required. The project and location from which the GrpcRoutes should be listed, specified in the format `projects/*/locations/*`.
14597 ///
14598 /// Sets the *parent* path property to the given value.
14599 ///
14600 /// Even though the property as already been set when instantiating this call,
14601 /// we provide this method for API completeness.
14602 pub fn parent(mut self, new_value: &str) -> ProjectLocationGrpcRouteListCall<'a, C> {
14603 self._parent = new_value.to_string();
14604 self
14605 }
14606 /// Optional. If true, allow partial responses for multi-regional Aggregated List requests. Otherwise if one of the locations is down or unreachable, the Aggregated List request will fail.
14607 ///
14608 /// Sets the *return partial success* query property to the given value.
14609 pub fn return_partial_success(
14610 mut self,
14611 new_value: bool,
14612 ) -> ProjectLocationGrpcRouteListCall<'a, C> {
14613 self._return_partial_success = Some(new_value);
14614 self
14615 }
14616 /// The value returned by the last `ListGrpcRoutesResponse` Indicates that this is a continuation of a prior `ListGrpcRoutes` call, and that the system should return the next page of data.
14617 ///
14618 /// Sets the *page token* query property to the given value.
14619 pub fn page_token(mut self, new_value: &str) -> ProjectLocationGrpcRouteListCall<'a, C> {
14620 self._page_token = Some(new_value.to_string());
14621 self
14622 }
14623 /// Maximum number of GrpcRoutes to return per call.
14624 ///
14625 /// Sets the *page size* query property to the given value.
14626 pub fn page_size(mut self, new_value: i32) -> ProjectLocationGrpcRouteListCall<'a, C> {
14627 self._page_size = Some(new_value);
14628 self
14629 }
14630 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14631 /// while executing the actual API request.
14632 ///
14633 /// ````text
14634 /// It should be used to handle progress information, and to implement a certain level of resilience.
14635 /// ````
14636 ///
14637 /// Sets the *delegate* property to the given value.
14638 pub fn delegate(
14639 mut self,
14640 new_value: &'a mut dyn common::Delegate,
14641 ) -> ProjectLocationGrpcRouteListCall<'a, C> {
14642 self._delegate = Some(new_value);
14643 self
14644 }
14645
14646 /// Set any additional parameter of the query string used in the request.
14647 /// It should be used to set parameters which are not yet available through their own
14648 /// setters.
14649 ///
14650 /// Please note that this method must not be used to set any of the known parameters
14651 /// which have their own setter method. If done anyway, the request will fail.
14652 ///
14653 /// # Additional Parameters
14654 ///
14655 /// * *$.xgafv* (query-string) - V1 error format.
14656 /// * *access_token* (query-string) - OAuth access token.
14657 /// * *alt* (query-string) - Data format for response.
14658 /// * *callback* (query-string) - JSONP
14659 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14660 /// * *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.
14661 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14662 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14663 /// * *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.
14664 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14665 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14666 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGrpcRouteListCall<'a, C>
14667 where
14668 T: AsRef<str>,
14669 {
14670 self._additional_params
14671 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14672 self
14673 }
14674
14675 /// Identifies the authorization scope for the method you are building.
14676 ///
14677 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14678 /// [`Scope::CloudPlatform`].
14679 ///
14680 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14681 /// tokens for more than one scope.
14682 ///
14683 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14684 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14685 /// sufficient, a read-write scope will do as well.
14686 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGrpcRouteListCall<'a, C>
14687 where
14688 St: AsRef<str>,
14689 {
14690 self._scopes.insert(String::from(scope.as_ref()));
14691 self
14692 }
14693 /// Identifies the authorization scope(s) for the method you are building.
14694 ///
14695 /// See [`Self::add_scope()`] for details.
14696 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGrpcRouteListCall<'a, C>
14697 where
14698 I: IntoIterator<Item = St>,
14699 St: AsRef<str>,
14700 {
14701 self._scopes
14702 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14703 self
14704 }
14705
14706 /// Removes all scopes, and no default scope will be used either.
14707 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14708 /// for details).
14709 pub fn clear_scopes(mut self) -> ProjectLocationGrpcRouteListCall<'a, C> {
14710 self._scopes.clear();
14711 self
14712 }
14713}
14714
14715/// Updates the parameters of a single GrpcRoute.
14716///
14717/// A builder for the *locations.grpcRoutes.patch* method supported by a *project* resource.
14718/// It is not used directly, but through a [`ProjectMethods`] instance.
14719///
14720/// # Example
14721///
14722/// Instantiate a resource method builder
14723///
14724/// ```test_harness,no_run
14725/// # extern crate hyper;
14726/// # extern crate hyper_rustls;
14727/// # extern crate google_networkservices1 as networkservices1;
14728/// use networkservices1::api::GrpcRoute;
14729/// # async fn dox() {
14730/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14731///
14732/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14733/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14734/// # .with_native_roots()
14735/// # .unwrap()
14736/// # .https_only()
14737/// # .enable_http2()
14738/// # .build();
14739///
14740/// # let executor = hyper_util::rt::TokioExecutor::new();
14741/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14742/// # secret,
14743/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14744/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14745/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14746/// # ),
14747/// # ).build().await.unwrap();
14748///
14749/// # let client = hyper_util::client::legacy::Client::builder(
14750/// # hyper_util::rt::TokioExecutor::new()
14751/// # )
14752/// # .build(
14753/// # hyper_rustls::HttpsConnectorBuilder::new()
14754/// # .with_native_roots()
14755/// # .unwrap()
14756/// # .https_or_http()
14757/// # .enable_http2()
14758/// # .build()
14759/// # );
14760/// # let mut hub = NetworkServices::new(client, auth);
14761/// // As the method needs a request, you would usually fill it with the desired information
14762/// // into the respective structure. Some of the parts shown here might not be applicable !
14763/// // Values shown here are possibly random and not representative !
14764/// let mut req = GrpcRoute::default();
14765///
14766/// // You can configure optional parameters by calling the respective setters at will, and
14767/// // execute the final call using `doit()`.
14768/// // Values shown here are possibly random and not representative !
14769/// let result = hub.projects().locations_grpc_routes_patch(req, "name")
14770/// .update_mask(FieldMask::new::<&str>(&[]))
14771/// .doit().await;
14772/// # }
14773/// ```
14774pub struct ProjectLocationGrpcRoutePatchCall<'a, C>
14775where
14776 C: 'a,
14777{
14778 hub: &'a NetworkServices<C>,
14779 _request: GrpcRoute,
14780 _name: String,
14781 _update_mask: Option<common::FieldMask>,
14782 _delegate: Option<&'a mut dyn common::Delegate>,
14783 _additional_params: HashMap<String, String>,
14784 _scopes: BTreeSet<String>,
14785}
14786
14787impl<'a, C> common::CallBuilder for ProjectLocationGrpcRoutePatchCall<'a, C> {}
14788
14789impl<'a, C> ProjectLocationGrpcRoutePatchCall<'a, C>
14790where
14791 C: common::Connector,
14792{
14793 /// Perform the operation you have build so far.
14794 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
14795 use std::borrow::Cow;
14796 use std::io::{Read, Seek};
14797
14798 use common::{url::Params, ToParts};
14799 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14800
14801 let mut dd = common::DefaultDelegate;
14802 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14803 dlg.begin(common::MethodInfo {
14804 id: "networkservices.projects.locations.grpcRoutes.patch",
14805 http_method: hyper::Method::PATCH,
14806 });
14807
14808 for &field in ["alt", "name", "updateMask"].iter() {
14809 if self._additional_params.contains_key(field) {
14810 dlg.finished(false);
14811 return Err(common::Error::FieldClash(field));
14812 }
14813 }
14814
14815 let mut params = Params::with_capacity(5 + self._additional_params.len());
14816 params.push("name", self._name);
14817 if let Some(value) = self._update_mask.as_ref() {
14818 params.push("updateMask", value.to_string());
14819 }
14820
14821 params.extend(self._additional_params.iter());
14822
14823 params.push("alt", "json");
14824 let mut url = self.hub._base_url.clone() + "v1/{+name}";
14825 if self._scopes.is_empty() {
14826 self._scopes
14827 .insert(Scope::CloudPlatform.as_ref().to_string());
14828 }
14829
14830 #[allow(clippy::single_element_loop)]
14831 for &(find_this, param_name) in [("{+name}", "name")].iter() {
14832 url = params.uri_replacement(url, param_name, find_this, true);
14833 }
14834 {
14835 let to_remove = ["name"];
14836 params.remove_params(&to_remove);
14837 }
14838
14839 let url = params.parse_with_url(&url);
14840
14841 let mut json_mime_type = mime::APPLICATION_JSON;
14842 let mut request_value_reader = {
14843 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14844 common::remove_json_null_values(&mut value);
14845 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14846 serde_json::to_writer(&mut dst, &value).unwrap();
14847 dst
14848 };
14849 let request_size = request_value_reader
14850 .seek(std::io::SeekFrom::End(0))
14851 .unwrap();
14852 request_value_reader
14853 .seek(std::io::SeekFrom::Start(0))
14854 .unwrap();
14855
14856 loop {
14857 let token = match self
14858 .hub
14859 .auth
14860 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14861 .await
14862 {
14863 Ok(token) => token,
14864 Err(e) => match dlg.token(e) {
14865 Ok(token) => token,
14866 Err(e) => {
14867 dlg.finished(false);
14868 return Err(common::Error::MissingToken(e));
14869 }
14870 },
14871 };
14872 request_value_reader
14873 .seek(std::io::SeekFrom::Start(0))
14874 .unwrap();
14875 let mut req_result = {
14876 let client = &self.hub.client;
14877 dlg.pre_request();
14878 let mut req_builder = hyper::Request::builder()
14879 .method(hyper::Method::PATCH)
14880 .uri(url.as_str())
14881 .header(USER_AGENT, self.hub._user_agent.clone());
14882
14883 if let Some(token) = token.as_ref() {
14884 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14885 }
14886
14887 let request = req_builder
14888 .header(CONTENT_TYPE, json_mime_type.to_string())
14889 .header(CONTENT_LENGTH, request_size as u64)
14890 .body(common::to_body(
14891 request_value_reader.get_ref().clone().into(),
14892 ));
14893
14894 client.request(request.unwrap()).await
14895 };
14896
14897 match req_result {
14898 Err(err) => {
14899 if let common::Retry::After(d) = dlg.http_error(&err) {
14900 sleep(d).await;
14901 continue;
14902 }
14903 dlg.finished(false);
14904 return Err(common::Error::HttpError(err));
14905 }
14906 Ok(res) => {
14907 let (mut parts, body) = res.into_parts();
14908 let mut body = common::Body::new(body);
14909 if !parts.status.is_success() {
14910 let bytes = common::to_bytes(body).await.unwrap_or_default();
14911 let error = serde_json::from_str(&common::to_string(&bytes));
14912 let response = common::to_response(parts, bytes.into());
14913
14914 if let common::Retry::After(d) =
14915 dlg.http_failure(&response, error.as_ref().ok())
14916 {
14917 sleep(d).await;
14918 continue;
14919 }
14920
14921 dlg.finished(false);
14922
14923 return Err(match error {
14924 Ok(value) => common::Error::BadRequest(value),
14925 _ => common::Error::Failure(response),
14926 });
14927 }
14928 let response = {
14929 let bytes = common::to_bytes(body).await.unwrap_or_default();
14930 let encoded = common::to_string(&bytes);
14931 match serde_json::from_str(&encoded) {
14932 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14933 Err(error) => {
14934 dlg.response_json_decode_error(&encoded, &error);
14935 return Err(common::Error::JsonDecodeError(
14936 encoded.to_string(),
14937 error,
14938 ));
14939 }
14940 }
14941 };
14942
14943 dlg.finished(true);
14944 return Ok(response);
14945 }
14946 }
14947 }
14948 }
14949
14950 ///
14951 /// Sets the *request* property to the given value.
14952 ///
14953 /// Even though the property as already been set when instantiating this call,
14954 /// we provide this method for API completeness.
14955 pub fn request(mut self, new_value: GrpcRoute) -> ProjectLocationGrpcRoutePatchCall<'a, C> {
14956 self._request = new_value;
14957 self
14958 }
14959 /// Identifier. Name of the GrpcRoute resource. It matches pattern `projects/*/locations/*/grpcRoutes/`
14960 ///
14961 /// Sets the *name* path property to the given value.
14962 ///
14963 /// Even though the property as already been set when instantiating this call,
14964 /// we provide this method for API completeness.
14965 pub fn name(mut self, new_value: &str) -> ProjectLocationGrpcRoutePatchCall<'a, C> {
14966 self._name = new_value.to_string();
14967 self
14968 }
14969 /// Optional. Field mask is used to specify the fields to be overwritten in the GrpcRoute 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.
14970 ///
14971 /// Sets the *update mask* query property to the given value.
14972 pub fn update_mask(
14973 mut self,
14974 new_value: common::FieldMask,
14975 ) -> ProjectLocationGrpcRoutePatchCall<'a, C> {
14976 self._update_mask = Some(new_value);
14977 self
14978 }
14979 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14980 /// while executing the actual API request.
14981 ///
14982 /// ````text
14983 /// It should be used to handle progress information, and to implement a certain level of resilience.
14984 /// ````
14985 ///
14986 /// Sets the *delegate* property to the given value.
14987 pub fn delegate(
14988 mut self,
14989 new_value: &'a mut dyn common::Delegate,
14990 ) -> ProjectLocationGrpcRoutePatchCall<'a, C> {
14991 self._delegate = Some(new_value);
14992 self
14993 }
14994
14995 /// Set any additional parameter of the query string used in the request.
14996 /// It should be used to set parameters which are not yet available through their own
14997 /// setters.
14998 ///
14999 /// Please note that this method must not be used to set any of the known parameters
15000 /// which have their own setter method. If done anyway, the request will fail.
15001 ///
15002 /// # Additional Parameters
15003 ///
15004 /// * *$.xgafv* (query-string) - V1 error format.
15005 /// * *access_token* (query-string) - OAuth access token.
15006 /// * *alt* (query-string) - Data format for response.
15007 /// * *callback* (query-string) - JSONP
15008 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15009 /// * *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.
15010 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15011 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15012 /// * *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.
15013 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15014 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15015 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGrpcRoutePatchCall<'a, C>
15016 where
15017 T: AsRef<str>,
15018 {
15019 self._additional_params
15020 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15021 self
15022 }
15023
15024 /// Identifies the authorization scope for the method you are building.
15025 ///
15026 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15027 /// [`Scope::CloudPlatform`].
15028 ///
15029 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15030 /// tokens for more than one scope.
15031 ///
15032 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15033 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15034 /// sufficient, a read-write scope will do as well.
15035 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGrpcRoutePatchCall<'a, C>
15036 where
15037 St: AsRef<str>,
15038 {
15039 self._scopes.insert(String::from(scope.as_ref()));
15040 self
15041 }
15042 /// Identifies the authorization scope(s) for the method you are building.
15043 ///
15044 /// See [`Self::add_scope()`] for details.
15045 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGrpcRoutePatchCall<'a, C>
15046 where
15047 I: IntoIterator<Item = St>,
15048 St: AsRef<str>,
15049 {
15050 self._scopes
15051 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15052 self
15053 }
15054
15055 /// Removes all scopes, and no default scope will be used either.
15056 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15057 /// for details).
15058 pub fn clear_scopes(mut self) -> ProjectLocationGrpcRoutePatchCall<'a, C> {
15059 self._scopes.clear();
15060 self
15061 }
15062}
15063
15064/// Creates a new HttpRoute in a given project and location.
15065///
15066/// A builder for the *locations.httpRoutes.create* method supported by a *project* resource.
15067/// It is not used directly, but through a [`ProjectMethods`] instance.
15068///
15069/// # Example
15070///
15071/// Instantiate a resource method builder
15072///
15073/// ```test_harness,no_run
15074/// # extern crate hyper;
15075/// # extern crate hyper_rustls;
15076/// # extern crate google_networkservices1 as networkservices1;
15077/// use networkservices1::api::HttpRoute;
15078/// # async fn dox() {
15079/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15080///
15081/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15082/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15083/// # .with_native_roots()
15084/// # .unwrap()
15085/// # .https_only()
15086/// # .enable_http2()
15087/// # .build();
15088///
15089/// # let executor = hyper_util::rt::TokioExecutor::new();
15090/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15091/// # secret,
15092/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15093/// # yup_oauth2::client::CustomHyperClientBuilder::from(
15094/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
15095/// # ),
15096/// # ).build().await.unwrap();
15097///
15098/// # let client = hyper_util::client::legacy::Client::builder(
15099/// # hyper_util::rt::TokioExecutor::new()
15100/// # )
15101/// # .build(
15102/// # hyper_rustls::HttpsConnectorBuilder::new()
15103/// # .with_native_roots()
15104/// # .unwrap()
15105/// # .https_or_http()
15106/// # .enable_http2()
15107/// # .build()
15108/// # );
15109/// # let mut hub = NetworkServices::new(client, auth);
15110/// // As the method needs a request, you would usually fill it with the desired information
15111/// // into the respective structure. Some of the parts shown here might not be applicable !
15112/// // Values shown here are possibly random and not representative !
15113/// let mut req = HttpRoute::default();
15114///
15115/// // You can configure optional parameters by calling the respective setters at will, and
15116/// // execute the final call using `doit()`.
15117/// // Values shown here are possibly random and not representative !
15118/// let result = hub.projects().locations_http_routes_create(req, "parent")
15119/// .http_route_id("vero")
15120/// .doit().await;
15121/// # }
15122/// ```
15123pub struct ProjectLocationHttpRouteCreateCall<'a, C>
15124where
15125 C: 'a,
15126{
15127 hub: &'a NetworkServices<C>,
15128 _request: HttpRoute,
15129 _parent: String,
15130 _http_route_id: Option<String>,
15131 _delegate: Option<&'a mut dyn common::Delegate>,
15132 _additional_params: HashMap<String, String>,
15133 _scopes: BTreeSet<String>,
15134}
15135
15136impl<'a, C> common::CallBuilder for ProjectLocationHttpRouteCreateCall<'a, C> {}
15137
15138impl<'a, C> ProjectLocationHttpRouteCreateCall<'a, C>
15139where
15140 C: common::Connector,
15141{
15142 /// Perform the operation you have build so far.
15143 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
15144 use std::borrow::Cow;
15145 use std::io::{Read, Seek};
15146
15147 use common::{url::Params, ToParts};
15148 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15149
15150 let mut dd = common::DefaultDelegate;
15151 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15152 dlg.begin(common::MethodInfo {
15153 id: "networkservices.projects.locations.httpRoutes.create",
15154 http_method: hyper::Method::POST,
15155 });
15156
15157 for &field in ["alt", "parent", "httpRouteId"].iter() {
15158 if self._additional_params.contains_key(field) {
15159 dlg.finished(false);
15160 return Err(common::Error::FieldClash(field));
15161 }
15162 }
15163
15164 let mut params = Params::with_capacity(5 + self._additional_params.len());
15165 params.push("parent", self._parent);
15166 if let Some(value) = self._http_route_id.as_ref() {
15167 params.push("httpRouteId", value);
15168 }
15169
15170 params.extend(self._additional_params.iter());
15171
15172 params.push("alt", "json");
15173 let mut url = self.hub._base_url.clone() + "v1/{+parent}/httpRoutes";
15174 if self._scopes.is_empty() {
15175 self._scopes
15176 .insert(Scope::CloudPlatform.as_ref().to_string());
15177 }
15178
15179 #[allow(clippy::single_element_loop)]
15180 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
15181 url = params.uri_replacement(url, param_name, find_this, true);
15182 }
15183 {
15184 let to_remove = ["parent"];
15185 params.remove_params(&to_remove);
15186 }
15187
15188 let url = params.parse_with_url(&url);
15189
15190 let mut json_mime_type = mime::APPLICATION_JSON;
15191 let mut request_value_reader = {
15192 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15193 common::remove_json_null_values(&mut value);
15194 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15195 serde_json::to_writer(&mut dst, &value).unwrap();
15196 dst
15197 };
15198 let request_size = request_value_reader
15199 .seek(std::io::SeekFrom::End(0))
15200 .unwrap();
15201 request_value_reader
15202 .seek(std::io::SeekFrom::Start(0))
15203 .unwrap();
15204
15205 loop {
15206 let token = match self
15207 .hub
15208 .auth
15209 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15210 .await
15211 {
15212 Ok(token) => token,
15213 Err(e) => match dlg.token(e) {
15214 Ok(token) => token,
15215 Err(e) => {
15216 dlg.finished(false);
15217 return Err(common::Error::MissingToken(e));
15218 }
15219 },
15220 };
15221 request_value_reader
15222 .seek(std::io::SeekFrom::Start(0))
15223 .unwrap();
15224 let mut req_result = {
15225 let client = &self.hub.client;
15226 dlg.pre_request();
15227 let mut req_builder = hyper::Request::builder()
15228 .method(hyper::Method::POST)
15229 .uri(url.as_str())
15230 .header(USER_AGENT, self.hub._user_agent.clone());
15231
15232 if let Some(token) = token.as_ref() {
15233 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15234 }
15235
15236 let request = req_builder
15237 .header(CONTENT_TYPE, json_mime_type.to_string())
15238 .header(CONTENT_LENGTH, request_size as u64)
15239 .body(common::to_body(
15240 request_value_reader.get_ref().clone().into(),
15241 ));
15242
15243 client.request(request.unwrap()).await
15244 };
15245
15246 match req_result {
15247 Err(err) => {
15248 if let common::Retry::After(d) = dlg.http_error(&err) {
15249 sleep(d).await;
15250 continue;
15251 }
15252 dlg.finished(false);
15253 return Err(common::Error::HttpError(err));
15254 }
15255 Ok(res) => {
15256 let (mut parts, body) = res.into_parts();
15257 let mut body = common::Body::new(body);
15258 if !parts.status.is_success() {
15259 let bytes = common::to_bytes(body).await.unwrap_or_default();
15260 let error = serde_json::from_str(&common::to_string(&bytes));
15261 let response = common::to_response(parts, bytes.into());
15262
15263 if let common::Retry::After(d) =
15264 dlg.http_failure(&response, error.as_ref().ok())
15265 {
15266 sleep(d).await;
15267 continue;
15268 }
15269
15270 dlg.finished(false);
15271
15272 return Err(match error {
15273 Ok(value) => common::Error::BadRequest(value),
15274 _ => common::Error::Failure(response),
15275 });
15276 }
15277 let response = {
15278 let bytes = common::to_bytes(body).await.unwrap_or_default();
15279 let encoded = common::to_string(&bytes);
15280 match serde_json::from_str(&encoded) {
15281 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15282 Err(error) => {
15283 dlg.response_json_decode_error(&encoded, &error);
15284 return Err(common::Error::JsonDecodeError(
15285 encoded.to_string(),
15286 error,
15287 ));
15288 }
15289 }
15290 };
15291
15292 dlg.finished(true);
15293 return Ok(response);
15294 }
15295 }
15296 }
15297 }
15298
15299 ///
15300 /// Sets the *request* property to the given value.
15301 ///
15302 /// Even though the property as already been set when instantiating this call,
15303 /// we provide this method for API completeness.
15304 pub fn request(mut self, new_value: HttpRoute) -> ProjectLocationHttpRouteCreateCall<'a, C> {
15305 self._request = new_value;
15306 self
15307 }
15308 /// Required. The parent resource of the HttpRoute. Must be in the format `projects/*/locations/*`.
15309 ///
15310 /// Sets the *parent* path property to the given value.
15311 ///
15312 /// Even though the property as already been set when instantiating this call,
15313 /// we provide this method for API completeness.
15314 pub fn parent(mut self, new_value: &str) -> ProjectLocationHttpRouteCreateCall<'a, C> {
15315 self._parent = new_value.to_string();
15316 self
15317 }
15318 /// Required. Short name of the HttpRoute resource to be created.
15319 ///
15320 /// Sets the *http route id* query property to the given value.
15321 pub fn http_route_id(mut self, new_value: &str) -> ProjectLocationHttpRouteCreateCall<'a, C> {
15322 self._http_route_id = Some(new_value.to_string());
15323 self
15324 }
15325 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15326 /// while executing the actual API request.
15327 ///
15328 /// ````text
15329 /// It should be used to handle progress information, and to implement a certain level of resilience.
15330 /// ````
15331 ///
15332 /// Sets the *delegate* property to the given value.
15333 pub fn delegate(
15334 mut self,
15335 new_value: &'a mut dyn common::Delegate,
15336 ) -> ProjectLocationHttpRouteCreateCall<'a, C> {
15337 self._delegate = Some(new_value);
15338 self
15339 }
15340
15341 /// Set any additional parameter of the query string used in the request.
15342 /// It should be used to set parameters which are not yet available through their own
15343 /// setters.
15344 ///
15345 /// Please note that this method must not be used to set any of the known parameters
15346 /// which have their own setter method. If done anyway, the request will fail.
15347 ///
15348 /// # Additional Parameters
15349 ///
15350 /// * *$.xgafv* (query-string) - V1 error format.
15351 /// * *access_token* (query-string) - OAuth access token.
15352 /// * *alt* (query-string) - Data format for response.
15353 /// * *callback* (query-string) - JSONP
15354 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15355 /// * *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.
15356 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15357 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15358 /// * *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.
15359 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15360 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15361 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationHttpRouteCreateCall<'a, C>
15362 where
15363 T: AsRef<str>,
15364 {
15365 self._additional_params
15366 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15367 self
15368 }
15369
15370 /// Identifies the authorization scope for the method you are building.
15371 ///
15372 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15373 /// [`Scope::CloudPlatform`].
15374 ///
15375 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15376 /// tokens for more than one scope.
15377 ///
15378 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15379 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15380 /// sufficient, a read-write scope will do as well.
15381 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationHttpRouteCreateCall<'a, C>
15382 where
15383 St: AsRef<str>,
15384 {
15385 self._scopes.insert(String::from(scope.as_ref()));
15386 self
15387 }
15388 /// Identifies the authorization scope(s) for the method you are building.
15389 ///
15390 /// See [`Self::add_scope()`] for details.
15391 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationHttpRouteCreateCall<'a, C>
15392 where
15393 I: IntoIterator<Item = St>,
15394 St: AsRef<str>,
15395 {
15396 self._scopes
15397 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15398 self
15399 }
15400
15401 /// Removes all scopes, and no default scope will be used either.
15402 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15403 /// for details).
15404 pub fn clear_scopes(mut self) -> ProjectLocationHttpRouteCreateCall<'a, C> {
15405 self._scopes.clear();
15406 self
15407 }
15408}
15409
15410/// Deletes a single HttpRoute.
15411///
15412/// A builder for the *locations.httpRoutes.delete* method supported by a *project* resource.
15413/// It is not used directly, but through a [`ProjectMethods`] instance.
15414///
15415/// # Example
15416///
15417/// Instantiate a resource method builder
15418///
15419/// ```test_harness,no_run
15420/// # extern crate hyper;
15421/// # extern crate hyper_rustls;
15422/// # extern crate google_networkservices1 as networkservices1;
15423/// # async fn dox() {
15424/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15425///
15426/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15427/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15428/// # .with_native_roots()
15429/// # .unwrap()
15430/// # .https_only()
15431/// # .enable_http2()
15432/// # .build();
15433///
15434/// # let executor = hyper_util::rt::TokioExecutor::new();
15435/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15436/// # secret,
15437/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15438/// # yup_oauth2::client::CustomHyperClientBuilder::from(
15439/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
15440/// # ),
15441/// # ).build().await.unwrap();
15442///
15443/// # let client = hyper_util::client::legacy::Client::builder(
15444/// # hyper_util::rt::TokioExecutor::new()
15445/// # )
15446/// # .build(
15447/// # hyper_rustls::HttpsConnectorBuilder::new()
15448/// # .with_native_roots()
15449/// # .unwrap()
15450/// # .https_or_http()
15451/// # .enable_http2()
15452/// # .build()
15453/// # );
15454/// # let mut hub = NetworkServices::new(client, auth);
15455/// // You can configure optional parameters by calling the respective setters at will, and
15456/// // execute the final call using `doit()`.
15457/// // Values shown here are possibly random and not representative !
15458/// let result = hub.projects().locations_http_routes_delete("name")
15459/// .doit().await;
15460/// # }
15461/// ```
15462pub struct ProjectLocationHttpRouteDeleteCall<'a, C>
15463where
15464 C: 'a,
15465{
15466 hub: &'a NetworkServices<C>,
15467 _name: String,
15468 _delegate: Option<&'a mut dyn common::Delegate>,
15469 _additional_params: HashMap<String, String>,
15470 _scopes: BTreeSet<String>,
15471}
15472
15473impl<'a, C> common::CallBuilder for ProjectLocationHttpRouteDeleteCall<'a, C> {}
15474
15475impl<'a, C> ProjectLocationHttpRouteDeleteCall<'a, C>
15476where
15477 C: common::Connector,
15478{
15479 /// Perform the operation you have build so far.
15480 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
15481 use std::borrow::Cow;
15482 use std::io::{Read, Seek};
15483
15484 use common::{url::Params, ToParts};
15485 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15486
15487 let mut dd = common::DefaultDelegate;
15488 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15489 dlg.begin(common::MethodInfo {
15490 id: "networkservices.projects.locations.httpRoutes.delete",
15491 http_method: hyper::Method::DELETE,
15492 });
15493
15494 for &field in ["alt", "name"].iter() {
15495 if self._additional_params.contains_key(field) {
15496 dlg.finished(false);
15497 return Err(common::Error::FieldClash(field));
15498 }
15499 }
15500
15501 let mut params = Params::with_capacity(3 + self._additional_params.len());
15502 params.push("name", self._name);
15503
15504 params.extend(self._additional_params.iter());
15505
15506 params.push("alt", "json");
15507 let mut url = self.hub._base_url.clone() + "v1/{+name}";
15508 if self._scopes.is_empty() {
15509 self._scopes
15510 .insert(Scope::CloudPlatform.as_ref().to_string());
15511 }
15512
15513 #[allow(clippy::single_element_loop)]
15514 for &(find_this, param_name) in [("{+name}", "name")].iter() {
15515 url = params.uri_replacement(url, param_name, find_this, true);
15516 }
15517 {
15518 let to_remove = ["name"];
15519 params.remove_params(&to_remove);
15520 }
15521
15522 let url = params.parse_with_url(&url);
15523
15524 loop {
15525 let token = match self
15526 .hub
15527 .auth
15528 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15529 .await
15530 {
15531 Ok(token) => token,
15532 Err(e) => match dlg.token(e) {
15533 Ok(token) => token,
15534 Err(e) => {
15535 dlg.finished(false);
15536 return Err(common::Error::MissingToken(e));
15537 }
15538 },
15539 };
15540 let mut req_result = {
15541 let client = &self.hub.client;
15542 dlg.pre_request();
15543 let mut req_builder = hyper::Request::builder()
15544 .method(hyper::Method::DELETE)
15545 .uri(url.as_str())
15546 .header(USER_AGENT, self.hub._user_agent.clone());
15547
15548 if let Some(token) = token.as_ref() {
15549 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15550 }
15551
15552 let request = req_builder
15553 .header(CONTENT_LENGTH, 0_u64)
15554 .body(common::to_body::<String>(None));
15555
15556 client.request(request.unwrap()).await
15557 };
15558
15559 match req_result {
15560 Err(err) => {
15561 if let common::Retry::After(d) = dlg.http_error(&err) {
15562 sleep(d).await;
15563 continue;
15564 }
15565 dlg.finished(false);
15566 return Err(common::Error::HttpError(err));
15567 }
15568 Ok(res) => {
15569 let (mut parts, body) = res.into_parts();
15570 let mut body = common::Body::new(body);
15571 if !parts.status.is_success() {
15572 let bytes = common::to_bytes(body).await.unwrap_or_default();
15573 let error = serde_json::from_str(&common::to_string(&bytes));
15574 let response = common::to_response(parts, bytes.into());
15575
15576 if let common::Retry::After(d) =
15577 dlg.http_failure(&response, error.as_ref().ok())
15578 {
15579 sleep(d).await;
15580 continue;
15581 }
15582
15583 dlg.finished(false);
15584
15585 return Err(match error {
15586 Ok(value) => common::Error::BadRequest(value),
15587 _ => common::Error::Failure(response),
15588 });
15589 }
15590 let response = {
15591 let bytes = common::to_bytes(body).await.unwrap_or_default();
15592 let encoded = common::to_string(&bytes);
15593 match serde_json::from_str(&encoded) {
15594 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15595 Err(error) => {
15596 dlg.response_json_decode_error(&encoded, &error);
15597 return Err(common::Error::JsonDecodeError(
15598 encoded.to_string(),
15599 error,
15600 ));
15601 }
15602 }
15603 };
15604
15605 dlg.finished(true);
15606 return Ok(response);
15607 }
15608 }
15609 }
15610 }
15611
15612 /// Required. A name of the HttpRoute to delete. Must be in the format `projects/*/locations/*/httpRoutes/*`.
15613 ///
15614 /// Sets the *name* path property to the given value.
15615 ///
15616 /// Even though the property as already been set when instantiating this call,
15617 /// we provide this method for API completeness.
15618 pub fn name(mut self, new_value: &str) -> ProjectLocationHttpRouteDeleteCall<'a, C> {
15619 self._name = new_value.to_string();
15620 self
15621 }
15622 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15623 /// while executing the actual API request.
15624 ///
15625 /// ````text
15626 /// It should be used to handle progress information, and to implement a certain level of resilience.
15627 /// ````
15628 ///
15629 /// Sets the *delegate* property to the given value.
15630 pub fn delegate(
15631 mut self,
15632 new_value: &'a mut dyn common::Delegate,
15633 ) -> ProjectLocationHttpRouteDeleteCall<'a, C> {
15634 self._delegate = Some(new_value);
15635 self
15636 }
15637
15638 /// Set any additional parameter of the query string used in the request.
15639 /// It should be used to set parameters which are not yet available through their own
15640 /// setters.
15641 ///
15642 /// Please note that this method must not be used to set any of the known parameters
15643 /// which have their own setter method. If done anyway, the request will fail.
15644 ///
15645 /// # Additional Parameters
15646 ///
15647 /// * *$.xgafv* (query-string) - V1 error format.
15648 /// * *access_token* (query-string) - OAuth access token.
15649 /// * *alt* (query-string) - Data format for response.
15650 /// * *callback* (query-string) - JSONP
15651 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15652 /// * *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.
15653 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15654 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15655 /// * *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.
15656 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15657 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15658 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationHttpRouteDeleteCall<'a, C>
15659 where
15660 T: AsRef<str>,
15661 {
15662 self._additional_params
15663 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15664 self
15665 }
15666
15667 /// Identifies the authorization scope for the method you are building.
15668 ///
15669 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15670 /// [`Scope::CloudPlatform`].
15671 ///
15672 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15673 /// tokens for more than one scope.
15674 ///
15675 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15676 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15677 /// sufficient, a read-write scope will do as well.
15678 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationHttpRouteDeleteCall<'a, C>
15679 where
15680 St: AsRef<str>,
15681 {
15682 self._scopes.insert(String::from(scope.as_ref()));
15683 self
15684 }
15685 /// Identifies the authorization scope(s) for the method you are building.
15686 ///
15687 /// See [`Self::add_scope()`] for details.
15688 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationHttpRouteDeleteCall<'a, C>
15689 where
15690 I: IntoIterator<Item = St>,
15691 St: AsRef<str>,
15692 {
15693 self._scopes
15694 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15695 self
15696 }
15697
15698 /// Removes all scopes, and no default scope will be used either.
15699 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15700 /// for details).
15701 pub fn clear_scopes(mut self) -> ProjectLocationHttpRouteDeleteCall<'a, C> {
15702 self._scopes.clear();
15703 self
15704 }
15705}
15706
15707/// Gets details of a single HttpRoute.
15708///
15709/// A builder for the *locations.httpRoutes.get* method supported by a *project* resource.
15710/// It is not used directly, but through a [`ProjectMethods`] instance.
15711///
15712/// # Example
15713///
15714/// Instantiate a resource method builder
15715///
15716/// ```test_harness,no_run
15717/// # extern crate hyper;
15718/// # extern crate hyper_rustls;
15719/// # extern crate google_networkservices1 as networkservices1;
15720/// # async fn dox() {
15721/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15722///
15723/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15724/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15725/// # .with_native_roots()
15726/// # .unwrap()
15727/// # .https_only()
15728/// # .enable_http2()
15729/// # .build();
15730///
15731/// # let executor = hyper_util::rt::TokioExecutor::new();
15732/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15733/// # secret,
15734/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15735/// # yup_oauth2::client::CustomHyperClientBuilder::from(
15736/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
15737/// # ),
15738/// # ).build().await.unwrap();
15739///
15740/// # let client = hyper_util::client::legacy::Client::builder(
15741/// # hyper_util::rt::TokioExecutor::new()
15742/// # )
15743/// # .build(
15744/// # hyper_rustls::HttpsConnectorBuilder::new()
15745/// # .with_native_roots()
15746/// # .unwrap()
15747/// # .https_or_http()
15748/// # .enable_http2()
15749/// # .build()
15750/// # );
15751/// # let mut hub = NetworkServices::new(client, auth);
15752/// // You can configure optional parameters by calling the respective setters at will, and
15753/// // execute the final call using `doit()`.
15754/// // Values shown here are possibly random and not representative !
15755/// let result = hub.projects().locations_http_routes_get("name")
15756/// .doit().await;
15757/// # }
15758/// ```
15759pub struct ProjectLocationHttpRouteGetCall<'a, C>
15760where
15761 C: 'a,
15762{
15763 hub: &'a NetworkServices<C>,
15764 _name: String,
15765 _delegate: Option<&'a mut dyn common::Delegate>,
15766 _additional_params: HashMap<String, String>,
15767 _scopes: BTreeSet<String>,
15768}
15769
15770impl<'a, C> common::CallBuilder for ProjectLocationHttpRouteGetCall<'a, C> {}
15771
15772impl<'a, C> ProjectLocationHttpRouteGetCall<'a, C>
15773where
15774 C: common::Connector,
15775{
15776 /// Perform the operation you have build so far.
15777 pub async fn doit(mut self) -> common::Result<(common::Response, HttpRoute)> {
15778 use std::borrow::Cow;
15779 use std::io::{Read, Seek};
15780
15781 use common::{url::Params, ToParts};
15782 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15783
15784 let mut dd = common::DefaultDelegate;
15785 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15786 dlg.begin(common::MethodInfo {
15787 id: "networkservices.projects.locations.httpRoutes.get",
15788 http_method: hyper::Method::GET,
15789 });
15790
15791 for &field in ["alt", "name"].iter() {
15792 if self._additional_params.contains_key(field) {
15793 dlg.finished(false);
15794 return Err(common::Error::FieldClash(field));
15795 }
15796 }
15797
15798 let mut params = Params::with_capacity(3 + self._additional_params.len());
15799 params.push("name", self._name);
15800
15801 params.extend(self._additional_params.iter());
15802
15803 params.push("alt", "json");
15804 let mut url = self.hub._base_url.clone() + "v1/{+name}";
15805 if self._scopes.is_empty() {
15806 self._scopes
15807 .insert(Scope::CloudPlatform.as_ref().to_string());
15808 }
15809
15810 #[allow(clippy::single_element_loop)]
15811 for &(find_this, param_name) in [("{+name}", "name")].iter() {
15812 url = params.uri_replacement(url, param_name, find_this, true);
15813 }
15814 {
15815 let to_remove = ["name"];
15816 params.remove_params(&to_remove);
15817 }
15818
15819 let url = params.parse_with_url(&url);
15820
15821 loop {
15822 let token = match self
15823 .hub
15824 .auth
15825 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15826 .await
15827 {
15828 Ok(token) => token,
15829 Err(e) => match dlg.token(e) {
15830 Ok(token) => token,
15831 Err(e) => {
15832 dlg.finished(false);
15833 return Err(common::Error::MissingToken(e));
15834 }
15835 },
15836 };
15837 let mut req_result = {
15838 let client = &self.hub.client;
15839 dlg.pre_request();
15840 let mut req_builder = hyper::Request::builder()
15841 .method(hyper::Method::GET)
15842 .uri(url.as_str())
15843 .header(USER_AGENT, self.hub._user_agent.clone());
15844
15845 if let Some(token) = token.as_ref() {
15846 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15847 }
15848
15849 let request = req_builder
15850 .header(CONTENT_LENGTH, 0_u64)
15851 .body(common::to_body::<String>(None));
15852
15853 client.request(request.unwrap()).await
15854 };
15855
15856 match req_result {
15857 Err(err) => {
15858 if let common::Retry::After(d) = dlg.http_error(&err) {
15859 sleep(d).await;
15860 continue;
15861 }
15862 dlg.finished(false);
15863 return Err(common::Error::HttpError(err));
15864 }
15865 Ok(res) => {
15866 let (mut parts, body) = res.into_parts();
15867 let mut body = common::Body::new(body);
15868 if !parts.status.is_success() {
15869 let bytes = common::to_bytes(body).await.unwrap_or_default();
15870 let error = serde_json::from_str(&common::to_string(&bytes));
15871 let response = common::to_response(parts, bytes.into());
15872
15873 if let common::Retry::After(d) =
15874 dlg.http_failure(&response, error.as_ref().ok())
15875 {
15876 sleep(d).await;
15877 continue;
15878 }
15879
15880 dlg.finished(false);
15881
15882 return Err(match error {
15883 Ok(value) => common::Error::BadRequest(value),
15884 _ => common::Error::Failure(response),
15885 });
15886 }
15887 let response = {
15888 let bytes = common::to_bytes(body).await.unwrap_or_default();
15889 let encoded = common::to_string(&bytes);
15890 match serde_json::from_str(&encoded) {
15891 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15892 Err(error) => {
15893 dlg.response_json_decode_error(&encoded, &error);
15894 return Err(common::Error::JsonDecodeError(
15895 encoded.to_string(),
15896 error,
15897 ));
15898 }
15899 }
15900 };
15901
15902 dlg.finished(true);
15903 return Ok(response);
15904 }
15905 }
15906 }
15907 }
15908
15909 /// Required. A name of the HttpRoute to get. Must be in the format `projects/*/locations/*/httpRoutes/*`.
15910 ///
15911 /// Sets the *name* path property to the given value.
15912 ///
15913 /// Even though the property as already been set when instantiating this call,
15914 /// we provide this method for API completeness.
15915 pub fn name(mut self, new_value: &str) -> ProjectLocationHttpRouteGetCall<'a, C> {
15916 self._name = new_value.to_string();
15917 self
15918 }
15919 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15920 /// while executing the actual API request.
15921 ///
15922 /// ````text
15923 /// It should be used to handle progress information, and to implement a certain level of resilience.
15924 /// ````
15925 ///
15926 /// Sets the *delegate* property to the given value.
15927 pub fn delegate(
15928 mut self,
15929 new_value: &'a mut dyn common::Delegate,
15930 ) -> ProjectLocationHttpRouteGetCall<'a, C> {
15931 self._delegate = Some(new_value);
15932 self
15933 }
15934
15935 /// Set any additional parameter of the query string used in the request.
15936 /// It should be used to set parameters which are not yet available through their own
15937 /// setters.
15938 ///
15939 /// Please note that this method must not be used to set any of the known parameters
15940 /// which have their own setter method. If done anyway, the request will fail.
15941 ///
15942 /// # Additional Parameters
15943 ///
15944 /// * *$.xgafv* (query-string) - V1 error format.
15945 /// * *access_token* (query-string) - OAuth access token.
15946 /// * *alt* (query-string) - Data format for response.
15947 /// * *callback* (query-string) - JSONP
15948 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15949 /// * *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.
15950 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15951 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15952 /// * *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.
15953 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15954 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15955 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationHttpRouteGetCall<'a, C>
15956 where
15957 T: AsRef<str>,
15958 {
15959 self._additional_params
15960 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15961 self
15962 }
15963
15964 /// Identifies the authorization scope for the method you are building.
15965 ///
15966 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15967 /// [`Scope::CloudPlatform`].
15968 ///
15969 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15970 /// tokens for more than one scope.
15971 ///
15972 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15973 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15974 /// sufficient, a read-write scope will do as well.
15975 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationHttpRouteGetCall<'a, C>
15976 where
15977 St: AsRef<str>,
15978 {
15979 self._scopes.insert(String::from(scope.as_ref()));
15980 self
15981 }
15982 /// Identifies the authorization scope(s) for the method you are building.
15983 ///
15984 /// See [`Self::add_scope()`] for details.
15985 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationHttpRouteGetCall<'a, C>
15986 where
15987 I: IntoIterator<Item = St>,
15988 St: AsRef<str>,
15989 {
15990 self._scopes
15991 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15992 self
15993 }
15994
15995 /// Removes all scopes, and no default scope will be used either.
15996 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15997 /// for details).
15998 pub fn clear_scopes(mut self) -> ProjectLocationHttpRouteGetCall<'a, C> {
15999 self._scopes.clear();
16000 self
16001 }
16002}
16003
16004/// Lists HttpRoute in a given project and location.
16005///
16006/// A builder for the *locations.httpRoutes.list* method supported by a *project* resource.
16007/// It is not used directly, but through a [`ProjectMethods`] instance.
16008///
16009/// # Example
16010///
16011/// Instantiate a resource method builder
16012///
16013/// ```test_harness,no_run
16014/// # extern crate hyper;
16015/// # extern crate hyper_rustls;
16016/// # extern crate google_networkservices1 as networkservices1;
16017/// # async fn dox() {
16018/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16019///
16020/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16021/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16022/// # .with_native_roots()
16023/// # .unwrap()
16024/// # .https_only()
16025/// # .enable_http2()
16026/// # .build();
16027///
16028/// # let executor = hyper_util::rt::TokioExecutor::new();
16029/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16030/// # secret,
16031/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16032/// # yup_oauth2::client::CustomHyperClientBuilder::from(
16033/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
16034/// # ),
16035/// # ).build().await.unwrap();
16036///
16037/// # let client = hyper_util::client::legacy::Client::builder(
16038/// # hyper_util::rt::TokioExecutor::new()
16039/// # )
16040/// # .build(
16041/// # hyper_rustls::HttpsConnectorBuilder::new()
16042/// # .with_native_roots()
16043/// # .unwrap()
16044/// # .https_or_http()
16045/// # .enable_http2()
16046/// # .build()
16047/// # );
16048/// # let mut hub = NetworkServices::new(client, auth);
16049/// // You can configure optional parameters by calling the respective setters at will, and
16050/// // execute the final call using `doit()`.
16051/// // Values shown here are possibly random and not representative !
16052/// let result = hub.projects().locations_http_routes_list("parent")
16053/// .return_partial_success(true)
16054/// .page_token("Lorem")
16055/// .page_size(-29)
16056/// .doit().await;
16057/// # }
16058/// ```
16059pub struct ProjectLocationHttpRouteListCall<'a, C>
16060where
16061 C: 'a,
16062{
16063 hub: &'a NetworkServices<C>,
16064 _parent: String,
16065 _return_partial_success: Option<bool>,
16066 _page_token: Option<String>,
16067 _page_size: Option<i32>,
16068 _delegate: Option<&'a mut dyn common::Delegate>,
16069 _additional_params: HashMap<String, String>,
16070 _scopes: BTreeSet<String>,
16071}
16072
16073impl<'a, C> common::CallBuilder for ProjectLocationHttpRouteListCall<'a, C> {}
16074
16075impl<'a, C> ProjectLocationHttpRouteListCall<'a, C>
16076where
16077 C: common::Connector,
16078{
16079 /// Perform the operation you have build so far.
16080 pub async fn doit(mut self) -> common::Result<(common::Response, ListHttpRoutesResponse)> {
16081 use std::borrow::Cow;
16082 use std::io::{Read, Seek};
16083
16084 use common::{url::Params, ToParts};
16085 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16086
16087 let mut dd = common::DefaultDelegate;
16088 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16089 dlg.begin(common::MethodInfo {
16090 id: "networkservices.projects.locations.httpRoutes.list",
16091 http_method: hyper::Method::GET,
16092 });
16093
16094 for &field in [
16095 "alt",
16096 "parent",
16097 "returnPartialSuccess",
16098 "pageToken",
16099 "pageSize",
16100 ]
16101 .iter()
16102 {
16103 if self._additional_params.contains_key(field) {
16104 dlg.finished(false);
16105 return Err(common::Error::FieldClash(field));
16106 }
16107 }
16108
16109 let mut params = Params::with_capacity(6 + self._additional_params.len());
16110 params.push("parent", self._parent);
16111 if let Some(value) = self._return_partial_success.as_ref() {
16112 params.push("returnPartialSuccess", value.to_string());
16113 }
16114 if let Some(value) = self._page_token.as_ref() {
16115 params.push("pageToken", value);
16116 }
16117 if let Some(value) = self._page_size.as_ref() {
16118 params.push("pageSize", value.to_string());
16119 }
16120
16121 params.extend(self._additional_params.iter());
16122
16123 params.push("alt", "json");
16124 let mut url = self.hub._base_url.clone() + "v1/{+parent}/httpRoutes";
16125 if self._scopes.is_empty() {
16126 self._scopes
16127 .insert(Scope::CloudPlatform.as_ref().to_string());
16128 }
16129
16130 #[allow(clippy::single_element_loop)]
16131 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
16132 url = params.uri_replacement(url, param_name, find_this, true);
16133 }
16134 {
16135 let to_remove = ["parent"];
16136 params.remove_params(&to_remove);
16137 }
16138
16139 let url = params.parse_with_url(&url);
16140
16141 loop {
16142 let token = match self
16143 .hub
16144 .auth
16145 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16146 .await
16147 {
16148 Ok(token) => token,
16149 Err(e) => match dlg.token(e) {
16150 Ok(token) => token,
16151 Err(e) => {
16152 dlg.finished(false);
16153 return Err(common::Error::MissingToken(e));
16154 }
16155 },
16156 };
16157 let mut req_result = {
16158 let client = &self.hub.client;
16159 dlg.pre_request();
16160 let mut req_builder = hyper::Request::builder()
16161 .method(hyper::Method::GET)
16162 .uri(url.as_str())
16163 .header(USER_AGENT, self.hub._user_agent.clone());
16164
16165 if let Some(token) = token.as_ref() {
16166 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16167 }
16168
16169 let request = req_builder
16170 .header(CONTENT_LENGTH, 0_u64)
16171 .body(common::to_body::<String>(None));
16172
16173 client.request(request.unwrap()).await
16174 };
16175
16176 match req_result {
16177 Err(err) => {
16178 if let common::Retry::After(d) = dlg.http_error(&err) {
16179 sleep(d).await;
16180 continue;
16181 }
16182 dlg.finished(false);
16183 return Err(common::Error::HttpError(err));
16184 }
16185 Ok(res) => {
16186 let (mut parts, body) = res.into_parts();
16187 let mut body = common::Body::new(body);
16188 if !parts.status.is_success() {
16189 let bytes = common::to_bytes(body).await.unwrap_or_default();
16190 let error = serde_json::from_str(&common::to_string(&bytes));
16191 let response = common::to_response(parts, bytes.into());
16192
16193 if let common::Retry::After(d) =
16194 dlg.http_failure(&response, error.as_ref().ok())
16195 {
16196 sleep(d).await;
16197 continue;
16198 }
16199
16200 dlg.finished(false);
16201
16202 return Err(match error {
16203 Ok(value) => common::Error::BadRequest(value),
16204 _ => common::Error::Failure(response),
16205 });
16206 }
16207 let response = {
16208 let bytes = common::to_bytes(body).await.unwrap_or_default();
16209 let encoded = common::to_string(&bytes);
16210 match serde_json::from_str(&encoded) {
16211 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16212 Err(error) => {
16213 dlg.response_json_decode_error(&encoded, &error);
16214 return Err(common::Error::JsonDecodeError(
16215 encoded.to_string(),
16216 error,
16217 ));
16218 }
16219 }
16220 };
16221
16222 dlg.finished(true);
16223 return Ok(response);
16224 }
16225 }
16226 }
16227 }
16228
16229 /// Required. The project and location from which the HttpRoutes should be listed, specified in the format `projects/*/locations/*`.
16230 ///
16231 /// Sets the *parent* path property to the given value.
16232 ///
16233 /// Even though the property as already been set when instantiating this call,
16234 /// we provide this method for API completeness.
16235 pub fn parent(mut self, new_value: &str) -> ProjectLocationHttpRouteListCall<'a, C> {
16236 self._parent = new_value.to_string();
16237 self
16238 }
16239 /// Optional. If true, allow partial responses for multi-regional Aggregated List requests. Otherwise if one of the locations is down or unreachable, the Aggregated List request will fail.
16240 ///
16241 /// Sets the *return partial success* query property to the given value.
16242 pub fn return_partial_success(
16243 mut self,
16244 new_value: bool,
16245 ) -> ProjectLocationHttpRouteListCall<'a, C> {
16246 self._return_partial_success = Some(new_value);
16247 self
16248 }
16249 /// The value returned by the last `ListHttpRoutesResponse` Indicates that this is a continuation of a prior `ListHttpRoutes` call, and that the system should return the next page of data.
16250 ///
16251 /// Sets the *page token* query property to the given value.
16252 pub fn page_token(mut self, new_value: &str) -> ProjectLocationHttpRouteListCall<'a, C> {
16253 self._page_token = Some(new_value.to_string());
16254 self
16255 }
16256 /// Maximum number of HttpRoutes to return per call.
16257 ///
16258 /// Sets the *page size* query property to the given value.
16259 pub fn page_size(mut self, new_value: i32) -> ProjectLocationHttpRouteListCall<'a, C> {
16260 self._page_size = Some(new_value);
16261 self
16262 }
16263 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16264 /// while executing the actual API request.
16265 ///
16266 /// ````text
16267 /// It should be used to handle progress information, and to implement a certain level of resilience.
16268 /// ````
16269 ///
16270 /// Sets the *delegate* property to the given value.
16271 pub fn delegate(
16272 mut self,
16273 new_value: &'a mut dyn common::Delegate,
16274 ) -> ProjectLocationHttpRouteListCall<'a, C> {
16275 self._delegate = Some(new_value);
16276 self
16277 }
16278
16279 /// Set any additional parameter of the query string used in the request.
16280 /// It should be used to set parameters which are not yet available through their own
16281 /// setters.
16282 ///
16283 /// Please note that this method must not be used to set any of the known parameters
16284 /// which have their own setter method. If done anyway, the request will fail.
16285 ///
16286 /// # Additional Parameters
16287 ///
16288 /// * *$.xgafv* (query-string) - V1 error format.
16289 /// * *access_token* (query-string) - OAuth access token.
16290 /// * *alt* (query-string) - Data format for response.
16291 /// * *callback* (query-string) - JSONP
16292 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16293 /// * *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.
16294 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16295 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16296 /// * *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.
16297 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16298 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16299 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationHttpRouteListCall<'a, C>
16300 where
16301 T: AsRef<str>,
16302 {
16303 self._additional_params
16304 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16305 self
16306 }
16307
16308 /// Identifies the authorization scope for the method you are building.
16309 ///
16310 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16311 /// [`Scope::CloudPlatform`].
16312 ///
16313 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16314 /// tokens for more than one scope.
16315 ///
16316 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16317 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16318 /// sufficient, a read-write scope will do as well.
16319 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationHttpRouteListCall<'a, C>
16320 where
16321 St: AsRef<str>,
16322 {
16323 self._scopes.insert(String::from(scope.as_ref()));
16324 self
16325 }
16326 /// Identifies the authorization scope(s) for the method you are building.
16327 ///
16328 /// See [`Self::add_scope()`] for details.
16329 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationHttpRouteListCall<'a, C>
16330 where
16331 I: IntoIterator<Item = St>,
16332 St: AsRef<str>,
16333 {
16334 self._scopes
16335 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16336 self
16337 }
16338
16339 /// Removes all scopes, and no default scope will be used either.
16340 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16341 /// for details).
16342 pub fn clear_scopes(mut self) -> ProjectLocationHttpRouteListCall<'a, C> {
16343 self._scopes.clear();
16344 self
16345 }
16346}
16347
16348/// Updates the parameters of a single HttpRoute.
16349///
16350/// A builder for the *locations.httpRoutes.patch* method supported by a *project* resource.
16351/// It is not used directly, but through a [`ProjectMethods`] instance.
16352///
16353/// # Example
16354///
16355/// Instantiate a resource method builder
16356///
16357/// ```test_harness,no_run
16358/// # extern crate hyper;
16359/// # extern crate hyper_rustls;
16360/// # extern crate google_networkservices1 as networkservices1;
16361/// use networkservices1::api::HttpRoute;
16362/// # async fn dox() {
16363/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16364///
16365/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16366/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16367/// # .with_native_roots()
16368/// # .unwrap()
16369/// # .https_only()
16370/// # .enable_http2()
16371/// # .build();
16372///
16373/// # let executor = hyper_util::rt::TokioExecutor::new();
16374/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16375/// # secret,
16376/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16377/// # yup_oauth2::client::CustomHyperClientBuilder::from(
16378/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
16379/// # ),
16380/// # ).build().await.unwrap();
16381///
16382/// # let client = hyper_util::client::legacy::Client::builder(
16383/// # hyper_util::rt::TokioExecutor::new()
16384/// # )
16385/// # .build(
16386/// # hyper_rustls::HttpsConnectorBuilder::new()
16387/// # .with_native_roots()
16388/// # .unwrap()
16389/// # .https_or_http()
16390/// # .enable_http2()
16391/// # .build()
16392/// # );
16393/// # let mut hub = NetworkServices::new(client, auth);
16394/// // As the method needs a request, you would usually fill it with the desired information
16395/// // into the respective structure. Some of the parts shown here might not be applicable !
16396/// // Values shown here are possibly random and not representative !
16397/// let mut req = HttpRoute::default();
16398///
16399/// // You can configure optional parameters by calling the respective setters at will, and
16400/// // execute the final call using `doit()`.
16401/// // Values shown here are possibly random and not representative !
16402/// let result = hub.projects().locations_http_routes_patch(req, "name")
16403/// .update_mask(FieldMask::new::<&str>(&[]))
16404/// .doit().await;
16405/// # }
16406/// ```
16407pub struct ProjectLocationHttpRoutePatchCall<'a, C>
16408where
16409 C: 'a,
16410{
16411 hub: &'a NetworkServices<C>,
16412 _request: HttpRoute,
16413 _name: String,
16414 _update_mask: Option<common::FieldMask>,
16415 _delegate: Option<&'a mut dyn common::Delegate>,
16416 _additional_params: HashMap<String, String>,
16417 _scopes: BTreeSet<String>,
16418}
16419
16420impl<'a, C> common::CallBuilder for ProjectLocationHttpRoutePatchCall<'a, C> {}
16421
16422impl<'a, C> ProjectLocationHttpRoutePatchCall<'a, C>
16423where
16424 C: common::Connector,
16425{
16426 /// Perform the operation you have build so far.
16427 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
16428 use std::borrow::Cow;
16429 use std::io::{Read, Seek};
16430
16431 use common::{url::Params, ToParts};
16432 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16433
16434 let mut dd = common::DefaultDelegate;
16435 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16436 dlg.begin(common::MethodInfo {
16437 id: "networkservices.projects.locations.httpRoutes.patch",
16438 http_method: hyper::Method::PATCH,
16439 });
16440
16441 for &field in ["alt", "name", "updateMask"].iter() {
16442 if self._additional_params.contains_key(field) {
16443 dlg.finished(false);
16444 return Err(common::Error::FieldClash(field));
16445 }
16446 }
16447
16448 let mut params = Params::with_capacity(5 + self._additional_params.len());
16449 params.push("name", self._name);
16450 if let Some(value) = self._update_mask.as_ref() {
16451 params.push("updateMask", value.to_string());
16452 }
16453
16454 params.extend(self._additional_params.iter());
16455
16456 params.push("alt", "json");
16457 let mut url = self.hub._base_url.clone() + "v1/{+name}";
16458 if self._scopes.is_empty() {
16459 self._scopes
16460 .insert(Scope::CloudPlatform.as_ref().to_string());
16461 }
16462
16463 #[allow(clippy::single_element_loop)]
16464 for &(find_this, param_name) in [("{+name}", "name")].iter() {
16465 url = params.uri_replacement(url, param_name, find_this, true);
16466 }
16467 {
16468 let to_remove = ["name"];
16469 params.remove_params(&to_remove);
16470 }
16471
16472 let url = params.parse_with_url(&url);
16473
16474 let mut json_mime_type = mime::APPLICATION_JSON;
16475 let mut request_value_reader = {
16476 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16477 common::remove_json_null_values(&mut value);
16478 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16479 serde_json::to_writer(&mut dst, &value).unwrap();
16480 dst
16481 };
16482 let request_size = request_value_reader
16483 .seek(std::io::SeekFrom::End(0))
16484 .unwrap();
16485 request_value_reader
16486 .seek(std::io::SeekFrom::Start(0))
16487 .unwrap();
16488
16489 loop {
16490 let token = match self
16491 .hub
16492 .auth
16493 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16494 .await
16495 {
16496 Ok(token) => token,
16497 Err(e) => match dlg.token(e) {
16498 Ok(token) => token,
16499 Err(e) => {
16500 dlg.finished(false);
16501 return Err(common::Error::MissingToken(e));
16502 }
16503 },
16504 };
16505 request_value_reader
16506 .seek(std::io::SeekFrom::Start(0))
16507 .unwrap();
16508 let mut req_result = {
16509 let client = &self.hub.client;
16510 dlg.pre_request();
16511 let mut req_builder = hyper::Request::builder()
16512 .method(hyper::Method::PATCH)
16513 .uri(url.as_str())
16514 .header(USER_AGENT, self.hub._user_agent.clone());
16515
16516 if let Some(token) = token.as_ref() {
16517 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16518 }
16519
16520 let request = req_builder
16521 .header(CONTENT_TYPE, json_mime_type.to_string())
16522 .header(CONTENT_LENGTH, request_size as u64)
16523 .body(common::to_body(
16524 request_value_reader.get_ref().clone().into(),
16525 ));
16526
16527 client.request(request.unwrap()).await
16528 };
16529
16530 match req_result {
16531 Err(err) => {
16532 if let common::Retry::After(d) = dlg.http_error(&err) {
16533 sleep(d).await;
16534 continue;
16535 }
16536 dlg.finished(false);
16537 return Err(common::Error::HttpError(err));
16538 }
16539 Ok(res) => {
16540 let (mut parts, body) = res.into_parts();
16541 let mut body = common::Body::new(body);
16542 if !parts.status.is_success() {
16543 let bytes = common::to_bytes(body).await.unwrap_or_default();
16544 let error = serde_json::from_str(&common::to_string(&bytes));
16545 let response = common::to_response(parts, bytes.into());
16546
16547 if let common::Retry::After(d) =
16548 dlg.http_failure(&response, error.as_ref().ok())
16549 {
16550 sleep(d).await;
16551 continue;
16552 }
16553
16554 dlg.finished(false);
16555
16556 return Err(match error {
16557 Ok(value) => common::Error::BadRequest(value),
16558 _ => common::Error::Failure(response),
16559 });
16560 }
16561 let response = {
16562 let bytes = common::to_bytes(body).await.unwrap_or_default();
16563 let encoded = common::to_string(&bytes);
16564 match serde_json::from_str(&encoded) {
16565 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16566 Err(error) => {
16567 dlg.response_json_decode_error(&encoded, &error);
16568 return Err(common::Error::JsonDecodeError(
16569 encoded.to_string(),
16570 error,
16571 ));
16572 }
16573 }
16574 };
16575
16576 dlg.finished(true);
16577 return Ok(response);
16578 }
16579 }
16580 }
16581 }
16582
16583 ///
16584 /// Sets the *request* property to the given value.
16585 ///
16586 /// Even though the property as already been set when instantiating this call,
16587 /// we provide this method for API completeness.
16588 pub fn request(mut self, new_value: HttpRoute) -> ProjectLocationHttpRoutePatchCall<'a, C> {
16589 self._request = new_value;
16590 self
16591 }
16592 /// Identifier. Name of the HttpRoute resource. It matches pattern `projects/*/locations/*/httpRoutes/http_route_name>`.
16593 ///
16594 /// Sets the *name* path property to the given value.
16595 ///
16596 /// Even though the property as already been set when instantiating this call,
16597 /// we provide this method for API completeness.
16598 pub fn name(mut self, new_value: &str) -> ProjectLocationHttpRoutePatchCall<'a, C> {
16599 self._name = new_value.to_string();
16600 self
16601 }
16602 /// Optional. Field mask is used to specify the fields to be overwritten in the HttpRoute 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.
16603 ///
16604 /// Sets the *update mask* query property to the given value.
16605 pub fn update_mask(
16606 mut self,
16607 new_value: common::FieldMask,
16608 ) -> ProjectLocationHttpRoutePatchCall<'a, C> {
16609 self._update_mask = Some(new_value);
16610 self
16611 }
16612 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16613 /// while executing the actual API request.
16614 ///
16615 /// ````text
16616 /// It should be used to handle progress information, and to implement a certain level of resilience.
16617 /// ````
16618 ///
16619 /// Sets the *delegate* property to the given value.
16620 pub fn delegate(
16621 mut self,
16622 new_value: &'a mut dyn common::Delegate,
16623 ) -> ProjectLocationHttpRoutePatchCall<'a, C> {
16624 self._delegate = Some(new_value);
16625 self
16626 }
16627
16628 /// Set any additional parameter of the query string used in the request.
16629 /// It should be used to set parameters which are not yet available through their own
16630 /// setters.
16631 ///
16632 /// Please note that this method must not be used to set any of the known parameters
16633 /// which have their own setter method. If done anyway, the request will fail.
16634 ///
16635 /// # Additional Parameters
16636 ///
16637 /// * *$.xgafv* (query-string) - V1 error format.
16638 /// * *access_token* (query-string) - OAuth access token.
16639 /// * *alt* (query-string) - Data format for response.
16640 /// * *callback* (query-string) - JSONP
16641 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16642 /// * *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.
16643 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16644 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16645 /// * *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.
16646 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16647 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16648 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationHttpRoutePatchCall<'a, C>
16649 where
16650 T: AsRef<str>,
16651 {
16652 self._additional_params
16653 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16654 self
16655 }
16656
16657 /// Identifies the authorization scope for the method you are building.
16658 ///
16659 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16660 /// [`Scope::CloudPlatform`].
16661 ///
16662 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16663 /// tokens for more than one scope.
16664 ///
16665 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16666 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16667 /// sufficient, a read-write scope will do as well.
16668 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationHttpRoutePatchCall<'a, C>
16669 where
16670 St: AsRef<str>,
16671 {
16672 self._scopes.insert(String::from(scope.as_ref()));
16673 self
16674 }
16675 /// Identifies the authorization scope(s) for the method you are building.
16676 ///
16677 /// See [`Self::add_scope()`] for details.
16678 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationHttpRoutePatchCall<'a, C>
16679 where
16680 I: IntoIterator<Item = St>,
16681 St: AsRef<str>,
16682 {
16683 self._scopes
16684 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16685 self
16686 }
16687
16688 /// Removes all scopes, and no default scope will be used either.
16689 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16690 /// for details).
16691 pub fn clear_scopes(mut self) -> ProjectLocationHttpRoutePatchCall<'a, C> {
16692 self._scopes.clear();
16693 self
16694 }
16695}
16696
16697/// Creates a new `LbEdgeExtension` resource in a given project and location.
16698///
16699/// A builder for the *locations.lbEdgeExtensions.create* method supported by a *project* resource.
16700/// It is not used directly, but through a [`ProjectMethods`] instance.
16701///
16702/// # Example
16703///
16704/// Instantiate a resource method builder
16705///
16706/// ```test_harness,no_run
16707/// # extern crate hyper;
16708/// # extern crate hyper_rustls;
16709/// # extern crate google_networkservices1 as networkservices1;
16710/// use networkservices1::api::LbEdgeExtension;
16711/// # async fn dox() {
16712/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16713///
16714/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16715/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16716/// # .with_native_roots()
16717/// # .unwrap()
16718/// # .https_only()
16719/// # .enable_http2()
16720/// # .build();
16721///
16722/// # let executor = hyper_util::rt::TokioExecutor::new();
16723/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16724/// # secret,
16725/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16726/// # yup_oauth2::client::CustomHyperClientBuilder::from(
16727/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
16728/// # ),
16729/// # ).build().await.unwrap();
16730///
16731/// # let client = hyper_util::client::legacy::Client::builder(
16732/// # hyper_util::rt::TokioExecutor::new()
16733/// # )
16734/// # .build(
16735/// # hyper_rustls::HttpsConnectorBuilder::new()
16736/// # .with_native_roots()
16737/// # .unwrap()
16738/// # .https_or_http()
16739/// # .enable_http2()
16740/// # .build()
16741/// # );
16742/// # let mut hub = NetworkServices::new(client, auth);
16743/// // As the method needs a request, you would usually fill it with the desired information
16744/// // into the respective structure. Some of the parts shown here might not be applicable !
16745/// // Values shown here are possibly random and not representative !
16746/// let mut req = LbEdgeExtension::default();
16747///
16748/// // You can configure optional parameters by calling the respective setters at will, and
16749/// // execute the final call using `doit()`.
16750/// // Values shown here are possibly random and not representative !
16751/// let result = hub.projects().locations_lb_edge_extensions_create(req, "parent")
16752/// .request_id("accusam")
16753/// .lb_edge_extension_id("takimata")
16754/// .doit().await;
16755/// # }
16756/// ```
16757pub struct ProjectLocationLbEdgeExtensionCreateCall<'a, C>
16758where
16759 C: 'a,
16760{
16761 hub: &'a NetworkServices<C>,
16762 _request: LbEdgeExtension,
16763 _parent: String,
16764 _request_id: Option<String>,
16765 _lb_edge_extension_id: Option<String>,
16766 _delegate: Option<&'a mut dyn common::Delegate>,
16767 _additional_params: HashMap<String, String>,
16768 _scopes: BTreeSet<String>,
16769}
16770
16771impl<'a, C> common::CallBuilder for ProjectLocationLbEdgeExtensionCreateCall<'a, C> {}
16772
16773impl<'a, C> ProjectLocationLbEdgeExtensionCreateCall<'a, C>
16774where
16775 C: common::Connector,
16776{
16777 /// Perform the operation you have build so far.
16778 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
16779 use std::borrow::Cow;
16780 use std::io::{Read, Seek};
16781
16782 use common::{url::Params, ToParts};
16783 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16784
16785 let mut dd = common::DefaultDelegate;
16786 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16787 dlg.begin(common::MethodInfo {
16788 id: "networkservices.projects.locations.lbEdgeExtensions.create",
16789 http_method: hyper::Method::POST,
16790 });
16791
16792 for &field in ["alt", "parent", "requestId", "lbEdgeExtensionId"].iter() {
16793 if self._additional_params.contains_key(field) {
16794 dlg.finished(false);
16795 return Err(common::Error::FieldClash(field));
16796 }
16797 }
16798
16799 let mut params = Params::with_capacity(6 + self._additional_params.len());
16800 params.push("parent", self._parent);
16801 if let Some(value) = self._request_id.as_ref() {
16802 params.push("requestId", value);
16803 }
16804 if let Some(value) = self._lb_edge_extension_id.as_ref() {
16805 params.push("lbEdgeExtensionId", value);
16806 }
16807
16808 params.extend(self._additional_params.iter());
16809
16810 params.push("alt", "json");
16811 let mut url = self.hub._base_url.clone() + "v1/{+parent}/lbEdgeExtensions";
16812 if self._scopes.is_empty() {
16813 self._scopes
16814 .insert(Scope::CloudPlatform.as_ref().to_string());
16815 }
16816
16817 #[allow(clippy::single_element_loop)]
16818 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
16819 url = params.uri_replacement(url, param_name, find_this, true);
16820 }
16821 {
16822 let to_remove = ["parent"];
16823 params.remove_params(&to_remove);
16824 }
16825
16826 let url = params.parse_with_url(&url);
16827
16828 let mut json_mime_type = mime::APPLICATION_JSON;
16829 let mut request_value_reader = {
16830 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16831 common::remove_json_null_values(&mut value);
16832 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16833 serde_json::to_writer(&mut dst, &value).unwrap();
16834 dst
16835 };
16836 let request_size = request_value_reader
16837 .seek(std::io::SeekFrom::End(0))
16838 .unwrap();
16839 request_value_reader
16840 .seek(std::io::SeekFrom::Start(0))
16841 .unwrap();
16842
16843 loop {
16844 let token = match self
16845 .hub
16846 .auth
16847 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16848 .await
16849 {
16850 Ok(token) => token,
16851 Err(e) => match dlg.token(e) {
16852 Ok(token) => token,
16853 Err(e) => {
16854 dlg.finished(false);
16855 return Err(common::Error::MissingToken(e));
16856 }
16857 },
16858 };
16859 request_value_reader
16860 .seek(std::io::SeekFrom::Start(0))
16861 .unwrap();
16862 let mut req_result = {
16863 let client = &self.hub.client;
16864 dlg.pre_request();
16865 let mut req_builder = hyper::Request::builder()
16866 .method(hyper::Method::POST)
16867 .uri(url.as_str())
16868 .header(USER_AGENT, self.hub._user_agent.clone());
16869
16870 if let Some(token) = token.as_ref() {
16871 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16872 }
16873
16874 let request = req_builder
16875 .header(CONTENT_TYPE, json_mime_type.to_string())
16876 .header(CONTENT_LENGTH, request_size as u64)
16877 .body(common::to_body(
16878 request_value_reader.get_ref().clone().into(),
16879 ));
16880
16881 client.request(request.unwrap()).await
16882 };
16883
16884 match req_result {
16885 Err(err) => {
16886 if let common::Retry::After(d) = dlg.http_error(&err) {
16887 sleep(d).await;
16888 continue;
16889 }
16890 dlg.finished(false);
16891 return Err(common::Error::HttpError(err));
16892 }
16893 Ok(res) => {
16894 let (mut parts, body) = res.into_parts();
16895 let mut body = common::Body::new(body);
16896 if !parts.status.is_success() {
16897 let bytes = common::to_bytes(body).await.unwrap_or_default();
16898 let error = serde_json::from_str(&common::to_string(&bytes));
16899 let response = common::to_response(parts, bytes.into());
16900
16901 if let common::Retry::After(d) =
16902 dlg.http_failure(&response, error.as_ref().ok())
16903 {
16904 sleep(d).await;
16905 continue;
16906 }
16907
16908 dlg.finished(false);
16909
16910 return Err(match error {
16911 Ok(value) => common::Error::BadRequest(value),
16912 _ => common::Error::Failure(response),
16913 });
16914 }
16915 let response = {
16916 let bytes = common::to_bytes(body).await.unwrap_or_default();
16917 let encoded = common::to_string(&bytes);
16918 match serde_json::from_str(&encoded) {
16919 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16920 Err(error) => {
16921 dlg.response_json_decode_error(&encoded, &error);
16922 return Err(common::Error::JsonDecodeError(
16923 encoded.to_string(),
16924 error,
16925 ));
16926 }
16927 }
16928 };
16929
16930 dlg.finished(true);
16931 return Ok(response);
16932 }
16933 }
16934 }
16935 }
16936
16937 ///
16938 /// Sets the *request* property to the given value.
16939 ///
16940 /// Even though the property as already been set when instantiating this call,
16941 /// we provide this method for API completeness.
16942 pub fn request(
16943 mut self,
16944 new_value: LbEdgeExtension,
16945 ) -> ProjectLocationLbEdgeExtensionCreateCall<'a, C> {
16946 self._request = new_value;
16947 self
16948 }
16949 /// Required. The parent resource of the `LbEdgeExtension` resource. Must be in the format `projects/{project}/locations/{location}`.
16950 ///
16951 /// Sets the *parent* path property to the given value.
16952 ///
16953 /// Even though the property as already been set when instantiating this call,
16954 /// we provide this method for API completeness.
16955 pub fn parent(mut self, new_value: &str) -> ProjectLocationLbEdgeExtensionCreateCall<'a, C> {
16956 self._parent = new_value.to_string();
16957 self
16958 }
16959 /// Optional. An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server can ignore the request if it has already been completed. The server guarantees that for 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 ignores 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).
16960 ///
16961 /// Sets the *request id* query property to the given value.
16962 pub fn request_id(
16963 mut self,
16964 new_value: &str,
16965 ) -> ProjectLocationLbEdgeExtensionCreateCall<'a, C> {
16966 self._request_id = Some(new_value.to_string());
16967 self
16968 }
16969 /// Required. User-provided ID of the `LbEdgeExtension` resource to be created.
16970 ///
16971 /// Sets the *lb edge extension id* query property to the given value.
16972 pub fn lb_edge_extension_id(
16973 mut self,
16974 new_value: &str,
16975 ) -> ProjectLocationLbEdgeExtensionCreateCall<'a, C> {
16976 self._lb_edge_extension_id = Some(new_value.to_string());
16977 self
16978 }
16979 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16980 /// while executing the actual API request.
16981 ///
16982 /// ````text
16983 /// It should be used to handle progress information, and to implement a certain level of resilience.
16984 /// ````
16985 ///
16986 /// Sets the *delegate* property to the given value.
16987 pub fn delegate(
16988 mut self,
16989 new_value: &'a mut dyn common::Delegate,
16990 ) -> ProjectLocationLbEdgeExtensionCreateCall<'a, C> {
16991 self._delegate = Some(new_value);
16992 self
16993 }
16994
16995 /// Set any additional parameter of the query string used in the request.
16996 /// It should be used to set parameters which are not yet available through their own
16997 /// setters.
16998 ///
16999 /// Please note that this method must not be used to set any of the known parameters
17000 /// which have their own setter method. If done anyway, the request will fail.
17001 ///
17002 /// # Additional Parameters
17003 ///
17004 /// * *$.xgafv* (query-string) - V1 error format.
17005 /// * *access_token* (query-string) - OAuth access token.
17006 /// * *alt* (query-string) - Data format for response.
17007 /// * *callback* (query-string) - JSONP
17008 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17009 /// * *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.
17010 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17011 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17012 /// * *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.
17013 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17014 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17015 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationLbEdgeExtensionCreateCall<'a, C>
17016 where
17017 T: AsRef<str>,
17018 {
17019 self._additional_params
17020 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17021 self
17022 }
17023
17024 /// Identifies the authorization scope for the method you are building.
17025 ///
17026 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17027 /// [`Scope::CloudPlatform`].
17028 ///
17029 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17030 /// tokens for more than one scope.
17031 ///
17032 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17033 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17034 /// sufficient, a read-write scope will do as well.
17035 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationLbEdgeExtensionCreateCall<'a, C>
17036 where
17037 St: AsRef<str>,
17038 {
17039 self._scopes.insert(String::from(scope.as_ref()));
17040 self
17041 }
17042 /// Identifies the authorization scope(s) for the method you are building.
17043 ///
17044 /// See [`Self::add_scope()`] for details.
17045 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationLbEdgeExtensionCreateCall<'a, C>
17046 where
17047 I: IntoIterator<Item = St>,
17048 St: AsRef<str>,
17049 {
17050 self._scopes
17051 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17052 self
17053 }
17054
17055 /// Removes all scopes, and no default scope will be used either.
17056 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17057 /// for details).
17058 pub fn clear_scopes(mut self) -> ProjectLocationLbEdgeExtensionCreateCall<'a, C> {
17059 self._scopes.clear();
17060 self
17061 }
17062}
17063
17064/// Deletes the specified `LbEdgeExtension` resource.
17065///
17066/// A builder for the *locations.lbEdgeExtensions.delete* method supported by a *project* resource.
17067/// It is not used directly, but through a [`ProjectMethods`] instance.
17068///
17069/// # Example
17070///
17071/// Instantiate a resource method builder
17072///
17073/// ```test_harness,no_run
17074/// # extern crate hyper;
17075/// # extern crate hyper_rustls;
17076/// # extern crate google_networkservices1 as networkservices1;
17077/// # async fn dox() {
17078/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17079///
17080/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17081/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17082/// # .with_native_roots()
17083/// # .unwrap()
17084/// # .https_only()
17085/// # .enable_http2()
17086/// # .build();
17087///
17088/// # let executor = hyper_util::rt::TokioExecutor::new();
17089/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17090/// # secret,
17091/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17092/// # yup_oauth2::client::CustomHyperClientBuilder::from(
17093/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
17094/// # ),
17095/// # ).build().await.unwrap();
17096///
17097/// # let client = hyper_util::client::legacy::Client::builder(
17098/// # hyper_util::rt::TokioExecutor::new()
17099/// # )
17100/// # .build(
17101/// # hyper_rustls::HttpsConnectorBuilder::new()
17102/// # .with_native_roots()
17103/// # .unwrap()
17104/// # .https_or_http()
17105/// # .enable_http2()
17106/// # .build()
17107/// # );
17108/// # let mut hub = NetworkServices::new(client, auth);
17109/// // You can configure optional parameters by calling the respective setters at will, and
17110/// // execute the final call using `doit()`.
17111/// // Values shown here are possibly random and not representative !
17112/// let result = hub.projects().locations_lb_edge_extensions_delete("name")
17113/// .request_id("voluptua.")
17114/// .doit().await;
17115/// # }
17116/// ```
17117pub struct ProjectLocationLbEdgeExtensionDeleteCall<'a, C>
17118where
17119 C: 'a,
17120{
17121 hub: &'a NetworkServices<C>,
17122 _name: String,
17123 _request_id: Option<String>,
17124 _delegate: Option<&'a mut dyn common::Delegate>,
17125 _additional_params: HashMap<String, String>,
17126 _scopes: BTreeSet<String>,
17127}
17128
17129impl<'a, C> common::CallBuilder for ProjectLocationLbEdgeExtensionDeleteCall<'a, C> {}
17130
17131impl<'a, C> ProjectLocationLbEdgeExtensionDeleteCall<'a, C>
17132where
17133 C: common::Connector,
17134{
17135 /// Perform the operation you have build so far.
17136 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
17137 use std::borrow::Cow;
17138 use std::io::{Read, Seek};
17139
17140 use common::{url::Params, ToParts};
17141 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17142
17143 let mut dd = common::DefaultDelegate;
17144 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17145 dlg.begin(common::MethodInfo {
17146 id: "networkservices.projects.locations.lbEdgeExtensions.delete",
17147 http_method: hyper::Method::DELETE,
17148 });
17149
17150 for &field in ["alt", "name", "requestId"].iter() {
17151 if self._additional_params.contains_key(field) {
17152 dlg.finished(false);
17153 return Err(common::Error::FieldClash(field));
17154 }
17155 }
17156
17157 let mut params = Params::with_capacity(4 + self._additional_params.len());
17158 params.push("name", self._name);
17159 if let Some(value) = self._request_id.as_ref() {
17160 params.push("requestId", value);
17161 }
17162
17163 params.extend(self._additional_params.iter());
17164
17165 params.push("alt", "json");
17166 let mut url = self.hub._base_url.clone() + "v1/{+name}";
17167 if self._scopes.is_empty() {
17168 self._scopes
17169 .insert(Scope::CloudPlatform.as_ref().to_string());
17170 }
17171
17172 #[allow(clippy::single_element_loop)]
17173 for &(find_this, param_name) in [("{+name}", "name")].iter() {
17174 url = params.uri_replacement(url, param_name, find_this, true);
17175 }
17176 {
17177 let to_remove = ["name"];
17178 params.remove_params(&to_remove);
17179 }
17180
17181 let url = params.parse_with_url(&url);
17182
17183 loop {
17184 let token = match self
17185 .hub
17186 .auth
17187 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17188 .await
17189 {
17190 Ok(token) => token,
17191 Err(e) => match dlg.token(e) {
17192 Ok(token) => token,
17193 Err(e) => {
17194 dlg.finished(false);
17195 return Err(common::Error::MissingToken(e));
17196 }
17197 },
17198 };
17199 let mut req_result = {
17200 let client = &self.hub.client;
17201 dlg.pre_request();
17202 let mut req_builder = hyper::Request::builder()
17203 .method(hyper::Method::DELETE)
17204 .uri(url.as_str())
17205 .header(USER_AGENT, self.hub._user_agent.clone());
17206
17207 if let Some(token) = token.as_ref() {
17208 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17209 }
17210
17211 let request = req_builder
17212 .header(CONTENT_LENGTH, 0_u64)
17213 .body(common::to_body::<String>(None));
17214
17215 client.request(request.unwrap()).await
17216 };
17217
17218 match req_result {
17219 Err(err) => {
17220 if let common::Retry::After(d) = dlg.http_error(&err) {
17221 sleep(d).await;
17222 continue;
17223 }
17224 dlg.finished(false);
17225 return Err(common::Error::HttpError(err));
17226 }
17227 Ok(res) => {
17228 let (mut parts, body) = res.into_parts();
17229 let mut body = common::Body::new(body);
17230 if !parts.status.is_success() {
17231 let bytes = common::to_bytes(body).await.unwrap_or_default();
17232 let error = serde_json::from_str(&common::to_string(&bytes));
17233 let response = common::to_response(parts, bytes.into());
17234
17235 if let common::Retry::After(d) =
17236 dlg.http_failure(&response, error.as_ref().ok())
17237 {
17238 sleep(d).await;
17239 continue;
17240 }
17241
17242 dlg.finished(false);
17243
17244 return Err(match error {
17245 Ok(value) => common::Error::BadRequest(value),
17246 _ => common::Error::Failure(response),
17247 });
17248 }
17249 let response = {
17250 let bytes = common::to_bytes(body).await.unwrap_or_default();
17251 let encoded = common::to_string(&bytes);
17252 match serde_json::from_str(&encoded) {
17253 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17254 Err(error) => {
17255 dlg.response_json_decode_error(&encoded, &error);
17256 return Err(common::Error::JsonDecodeError(
17257 encoded.to_string(),
17258 error,
17259 ));
17260 }
17261 }
17262 };
17263
17264 dlg.finished(true);
17265 return Ok(response);
17266 }
17267 }
17268 }
17269 }
17270
17271 /// Required. The name of the `LbEdgeExtension` resource to delete. Must be in the format `projects/{project}/locations/{location}/lbEdgeExtensions/{lb_edge_extension}`.
17272 ///
17273 /// Sets the *name* path property to the given value.
17274 ///
17275 /// Even though the property as already been set when instantiating this call,
17276 /// we provide this method for API completeness.
17277 pub fn name(mut self, new_value: &str) -> ProjectLocationLbEdgeExtensionDeleteCall<'a, C> {
17278 self._name = new_value.to_string();
17279 self
17280 }
17281 /// Optional. An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server can ignore the request if it has already been completed. The server guarantees that for 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 ignores 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).
17282 ///
17283 /// Sets the *request id* query property to the given value.
17284 pub fn request_id(
17285 mut self,
17286 new_value: &str,
17287 ) -> ProjectLocationLbEdgeExtensionDeleteCall<'a, C> {
17288 self._request_id = Some(new_value.to_string());
17289 self
17290 }
17291 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17292 /// while executing the actual API request.
17293 ///
17294 /// ````text
17295 /// It should be used to handle progress information, and to implement a certain level of resilience.
17296 /// ````
17297 ///
17298 /// Sets the *delegate* property to the given value.
17299 pub fn delegate(
17300 mut self,
17301 new_value: &'a mut dyn common::Delegate,
17302 ) -> ProjectLocationLbEdgeExtensionDeleteCall<'a, C> {
17303 self._delegate = Some(new_value);
17304 self
17305 }
17306
17307 /// Set any additional parameter of the query string used in the request.
17308 /// It should be used to set parameters which are not yet available through their own
17309 /// setters.
17310 ///
17311 /// Please note that this method must not be used to set any of the known parameters
17312 /// which have their own setter method. If done anyway, the request will fail.
17313 ///
17314 /// # Additional Parameters
17315 ///
17316 /// * *$.xgafv* (query-string) - V1 error format.
17317 /// * *access_token* (query-string) - OAuth access token.
17318 /// * *alt* (query-string) - Data format for response.
17319 /// * *callback* (query-string) - JSONP
17320 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17321 /// * *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.
17322 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17323 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17324 /// * *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.
17325 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17326 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17327 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationLbEdgeExtensionDeleteCall<'a, C>
17328 where
17329 T: AsRef<str>,
17330 {
17331 self._additional_params
17332 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17333 self
17334 }
17335
17336 /// Identifies the authorization scope for the method you are building.
17337 ///
17338 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17339 /// [`Scope::CloudPlatform`].
17340 ///
17341 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17342 /// tokens for more than one scope.
17343 ///
17344 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17345 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17346 /// sufficient, a read-write scope will do as well.
17347 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationLbEdgeExtensionDeleteCall<'a, C>
17348 where
17349 St: AsRef<str>,
17350 {
17351 self._scopes.insert(String::from(scope.as_ref()));
17352 self
17353 }
17354 /// Identifies the authorization scope(s) for the method you are building.
17355 ///
17356 /// See [`Self::add_scope()`] for details.
17357 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationLbEdgeExtensionDeleteCall<'a, C>
17358 where
17359 I: IntoIterator<Item = St>,
17360 St: AsRef<str>,
17361 {
17362 self._scopes
17363 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17364 self
17365 }
17366
17367 /// Removes all scopes, and no default scope will be used either.
17368 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17369 /// for details).
17370 pub fn clear_scopes(mut self) -> ProjectLocationLbEdgeExtensionDeleteCall<'a, C> {
17371 self._scopes.clear();
17372 self
17373 }
17374}
17375
17376/// Gets details of the specified `LbEdgeExtension` resource.
17377///
17378/// A builder for the *locations.lbEdgeExtensions.get* method supported by a *project* resource.
17379/// It is not used directly, but through a [`ProjectMethods`] instance.
17380///
17381/// # Example
17382///
17383/// Instantiate a resource method builder
17384///
17385/// ```test_harness,no_run
17386/// # extern crate hyper;
17387/// # extern crate hyper_rustls;
17388/// # extern crate google_networkservices1 as networkservices1;
17389/// # async fn dox() {
17390/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17391///
17392/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17393/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17394/// # .with_native_roots()
17395/// # .unwrap()
17396/// # .https_only()
17397/// # .enable_http2()
17398/// # .build();
17399///
17400/// # let executor = hyper_util::rt::TokioExecutor::new();
17401/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17402/// # secret,
17403/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17404/// # yup_oauth2::client::CustomHyperClientBuilder::from(
17405/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
17406/// # ),
17407/// # ).build().await.unwrap();
17408///
17409/// # let client = hyper_util::client::legacy::Client::builder(
17410/// # hyper_util::rt::TokioExecutor::new()
17411/// # )
17412/// # .build(
17413/// # hyper_rustls::HttpsConnectorBuilder::new()
17414/// # .with_native_roots()
17415/// # .unwrap()
17416/// # .https_or_http()
17417/// # .enable_http2()
17418/// # .build()
17419/// # );
17420/// # let mut hub = NetworkServices::new(client, auth);
17421/// // You can configure optional parameters by calling the respective setters at will, and
17422/// // execute the final call using `doit()`.
17423/// // Values shown here are possibly random and not representative !
17424/// let result = hub.projects().locations_lb_edge_extensions_get("name")
17425/// .doit().await;
17426/// # }
17427/// ```
17428pub struct ProjectLocationLbEdgeExtensionGetCall<'a, C>
17429where
17430 C: 'a,
17431{
17432 hub: &'a NetworkServices<C>,
17433 _name: String,
17434 _delegate: Option<&'a mut dyn common::Delegate>,
17435 _additional_params: HashMap<String, String>,
17436 _scopes: BTreeSet<String>,
17437}
17438
17439impl<'a, C> common::CallBuilder for ProjectLocationLbEdgeExtensionGetCall<'a, C> {}
17440
17441impl<'a, C> ProjectLocationLbEdgeExtensionGetCall<'a, C>
17442where
17443 C: common::Connector,
17444{
17445 /// Perform the operation you have build so far.
17446 pub async fn doit(mut self) -> common::Result<(common::Response, LbEdgeExtension)> {
17447 use std::borrow::Cow;
17448 use std::io::{Read, Seek};
17449
17450 use common::{url::Params, ToParts};
17451 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17452
17453 let mut dd = common::DefaultDelegate;
17454 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17455 dlg.begin(common::MethodInfo {
17456 id: "networkservices.projects.locations.lbEdgeExtensions.get",
17457 http_method: hyper::Method::GET,
17458 });
17459
17460 for &field in ["alt", "name"].iter() {
17461 if self._additional_params.contains_key(field) {
17462 dlg.finished(false);
17463 return Err(common::Error::FieldClash(field));
17464 }
17465 }
17466
17467 let mut params = Params::with_capacity(3 + self._additional_params.len());
17468 params.push("name", self._name);
17469
17470 params.extend(self._additional_params.iter());
17471
17472 params.push("alt", "json");
17473 let mut url = self.hub._base_url.clone() + "v1/{+name}";
17474 if self._scopes.is_empty() {
17475 self._scopes
17476 .insert(Scope::CloudPlatform.as_ref().to_string());
17477 }
17478
17479 #[allow(clippy::single_element_loop)]
17480 for &(find_this, param_name) in [("{+name}", "name")].iter() {
17481 url = params.uri_replacement(url, param_name, find_this, true);
17482 }
17483 {
17484 let to_remove = ["name"];
17485 params.remove_params(&to_remove);
17486 }
17487
17488 let url = params.parse_with_url(&url);
17489
17490 loop {
17491 let token = match self
17492 .hub
17493 .auth
17494 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17495 .await
17496 {
17497 Ok(token) => token,
17498 Err(e) => match dlg.token(e) {
17499 Ok(token) => token,
17500 Err(e) => {
17501 dlg.finished(false);
17502 return Err(common::Error::MissingToken(e));
17503 }
17504 },
17505 };
17506 let mut req_result = {
17507 let client = &self.hub.client;
17508 dlg.pre_request();
17509 let mut req_builder = hyper::Request::builder()
17510 .method(hyper::Method::GET)
17511 .uri(url.as_str())
17512 .header(USER_AGENT, self.hub._user_agent.clone());
17513
17514 if let Some(token) = token.as_ref() {
17515 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17516 }
17517
17518 let request = req_builder
17519 .header(CONTENT_LENGTH, 0_u64)
17520 .body(common::to_body::<String>(None));
17521
17522 client.request(request.unwrap()).await
17523 };
17524
17525 match req_result {
17526 Err(err) => {
17527 if let common::Retry::After(d) = dlg.http_error(&err) {
17528 sleep(d).await;
17529 continue;
17530 }
17531 dlg.finished(false);
17532 return Err(common::Error::HttpError(err));
17533 }
17534 Ok(res) => {
17535 let (mut parts, body) = res.into_parts();
17536 let mut body = common::Body::new(body);
17537 if !parts.status.is_success() {
17538 let bytes = common::to_bytes(body).await.unwrap_or_default();
17539 let error = serde_json::from_str(&common::to_string(&bytes));
17540 let response = common::to_response(parts, bytes.into());
17541
17542 if let common::Retry::After(d) =
17543 dlg.http_failure(&response, error.as_ref().ok())
17544 {
17545 sleep(d).await;
17546 continue;
17547 }
17548
17549 dlg.finished(false);
17550
17551 return Err(match error {
17552 Ok(value) => common::Error::BadRequest(value),
17553 _ => common::Error::Failure(response),
17554 });
17555 }
17556 let response = {
17557 let bytes = common::to_bytes(body).await.unwrap_or_default();
17558 let encoded = common::to_string(&bytes);
17559 match serde_json::from_str(&encoded) {
17560 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17561 Err(error) => {
17562 dlg.response_json_decode_error(&encoded, &error);
17563 return Err(common::Error::JsonDecodeError(
17564 encoded.to_string(),
17565 error,
17566 ));
17567 }
17568 }
17569 };
17570
17571 dlg.finished(true);
17572 return Ok(response);
17573 }
17574 }
17575 }
17576 }
17577
17578 /// Required. A name of the `LbEdgeExtension` resource to get. Must be in the format `projects/{project}/locations/{location}/lbEdgeExtensions/{lb_edge_extension}`.
17579 ///
17580 /// Sets the *name* path property to the given value.
17581 ///
17582 /// Even though the property as already been set when instantiating this call,
17583 /// we provide this method for API completeness.
17584 pub fn name(mut self, new_value: &str) -> ProjectLocationLbEdgeExtensionGetCall<'a, C> {
17585 self._name = new_value.to_string();
17586 self
17587 }
17588 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17589 /// while executing the actual API request.
17590 ///
17591 /// ````text
17592 /// It should be used to handle progress information, and to implement a certain level of resilience.
17593 /// ````
17594 ///
17595 /// Sets the *delegate* property to the given value.
17596 pub fn delegate(
17597 mut self,
17598 new_value: &'a mut dyn common::Delegate,
17599 ) -> ProjectLocationLbEdgeExtensionGetCall<'a, C> {
17600 self._delegate = Some(new_value);
17601 self
17602 }
17603
17604 /// Set any additional parameter of the query string used in the request.
17605 /// It should be used to set parameters which are not yet available through their own
17606 /// setters.
17607 ///
17608 /// Please note that this method must not be used to set any of the known parameters
17609 /// which have their own setter method. If done anyway, the request will fail.
17610 ///
17611 /// # Additional Parameters
17612 ///
17613 /// * *$.xgafv* (query-string) - V1 error format.
17614 /// * *access_token* (query-string) - OAuth access token.
17615 /// * *alt* (query-string) - Data format for response.
17616 /// * *callback* (query-string) - JSONP
17617 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17618 /// * *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.
17619 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17620 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17621 /// * *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.
17622 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17623 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17624 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationLbEdgeExtensionGetCall<'a, C>
17625 where
17626 T: AsRef<str>,
17627 {
17628 self._additional_params
17629 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17630 self
17631 }
17632
17633 /// Identifies the authorization scope for the method you are building.
17634 ///
17635 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17636 /// [`Scope::CloudPlatform`].
17637 ///
17638 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17639 /// tokens for more than one scope.
17640 ///
17641 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17642 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17643 /// sufficient, a read-write scope will do as well.
17644 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationLbEdgeExtensionGetCall<'a, C>
17645 where
17646 St: AsRef<str>,
17647 {
17648 self._scopes.insert(String::from(scope.as_ref()));
17649 self
17650 }
17651 /// Identifies the authorization scope(s) for the method you are building.
17652 ///
17653 /// See [`Self::add_scope()`] for details.
17654 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationLbEdgeExtensionGetCall<'a, C>
17655 where
17656 I: IntoIterator<Item = St>,
17657 St: AsRef<str>,
17658 {
17659 self._scopes
17660 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17661 self
17662 }
17663
17664 /// Removes all scopes, and no default scope will be used either.
17665 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17666 /// for details).
17667 pub fn clear_scopes(mut self) -> ProjectLocationLbEdgeExtensionGetCall<'a, C> {
17668 self._scopes.clear();
17669 self
17670 }
17671}
17672
17673/// Lists `LbEdgeExtension` resources in a given project and location.
17674///
17675/// A builder for the *locations.lbEdgeExtensions.list* method supported by a *project* resource.
17676/// It is not used directly, but through a [`ProjectMethods`] instance.
17677///
17678/// # Example
17679///
17680/// Instantiate a resource method builder
17681///
17682/// ```test_harness,no_run
17683/// # extern crate hyper;
17684/// # extern crate hyper_rustls;
17685/// # extern crate google_networkservices1 as networkservices1;
17686/// # async fn dox() {
17687/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17688///
17689/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17690/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17691/// # .with_native_roots()
17692/// # .unwrap()
17693/// # .https_only()
17694/// # .enable_http2()
17695/// # .build();
17696///
17697/// # let executor = hyper_util::rt::TokioExecutor::new();
17698/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17699/// # secret,
17700/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17701/// # yup_oauth2::client::CustomHyperClientBuilder::from(
17702/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
17703/// # ),
17704/// # ).build().await.unwrap();
17705///
17706/// # let client = hyper_util::client::legacy::Client::builder(
17707/// # hyper_util::rt::TokioExecutor::new()
17708/// # )
17709/// # .build(
17710/// # hyper_rustls::HttpsConnectorBuilder::new()
17711/// # .with_native_roots()
17712/// # .unwrap()
17713/// # .https_or_http()
17714/// # .enable_http2()
17715/// # .build()
17716/// # );
17717/// # let mut hub = NetworkServices::new(client, auth);
17718/// // You can configure optional parameters by calling the respective setters at will, and
17719/// // execute the final call using `doit()`.
17720/// // Values shown here are possibly random and not representative !
17721/// let result = hub.projects().locations_lb_edge_extensions_list("parent")
17722/// .page_token("consetetur")
17723/// .page_size(-2)
17724/// .order_by("sed")
17725/// .filter("takimata")
17726/// .doit().await;
17727/// # }
17728/// ```
17729pub struct ProjectLocationLbEdgeExtensionListCall<'a, C>
17730where
17731 C: 'a,
17732{
17733 hub: &'a NetworkServices<C>,
17734 _parent: String,
17735 _page_token: Option<String>,
17736 _page_size: Option<i32>,
17737 _order_by: Option<String>,
17738 _filter: Option<String>,
17739 _delegate: Option<&'a mut dyn common::Delegate>,
17740 _additional_params: HashMap<String, String>,
17741 _scopes: BTreeSet<String>,
17742}
17743
17744impl<'a, C> common::CallBuilder for ProjectLocationLbEdgeExtensionListCall<'a, C> {}
17745
17746impl<'a, C> ProjectLocationLbEdgeExtensionListCall<'a, C>
17747where
17748 C: common::Connector,
17749{
17750 /// Perform the operation you have build so far.
17751 pub async fn doit(
17752 mut self,
17753 ) -> common::Result<(common::Response, ListLbEdgeExtensionsResponse)> {
17754 use std::borrow::Cow;
17755 use std::io::{Read, Seek};
17756
17757 use common::{url::Params, ToParts};
17758 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17759
17760 let mut dd = common::DefaultDelegate;
17761 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17762 dlg.begin(common::MethodInfo {
17763 id: "networkservices.projects.locations.lbEdgeExtensions.list",
17764 http_method: hyper::Method::GET,
17765 });
17766
17767 for &field in [
17768 "alt",
17769 "parent",
17770 "pageToken",
17771 "pageSize",
17772 "orderBy",
17773 "filter",
17774 ]
17775 .iter()
17776 {
17777 if self._additional_params.contains_key(field) {
17778 dlg.finished(false);
17779 return Err(common::Error::FieldClash(field));
17780 }
17781 }
17782
17783 let mut params = Params::with_capacity(7 + self._additional_params.len());
17784 params.push("parent", self._parent);
17785 if let Some(value) = self._page_token.as_ref() {
17786 params.push("pageToken", value);
17787 }
17788 if let Some(value) = self._page_size.as_ref() {
17789 params.push("pageSize", value.to_string());
17790 }
17791 if let Some(value) = self._order_by.as_ref() {
17792 params.push("orderBy", value);
17793 }
17794 if let Some(value) = self._filter.as_ref() {
17795 params.push("filter", value);
17796 }
17797
17798 params.extend(self._additional_params.iter());
17799
17800 params.push("alt", "json");
17801 let mut url = self.hub._base_url.clone() + "v1/{+parent}/lbEdgeExtensions";
17802 if self._scopes.is_empty() {
17803 self._scopes
17804 .insert(Scope::CloudPlatform.as_ref().to_string());
17805 }
17806
17807 #[allow(clippy::single_element_loop)]
17808 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
17809 url = params.uri_replacement(url, param_name, find_this, true);
17810 }
17811 {
17812 let to_remove = ["parent"];
17813 params.remove_params(&to_remove);
17814 }
17815
17816 let url = params.parse_with_url(&url);
17817
17818 loop {
17819 let token = match self
17820 .hub
17821 .auth
17822 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17823 .await
17824 {
17825 Ok(token) => token,
17826 Err(e) => match dlg.token(e) {
17827 Ok(token) => token,
17828 Err(e) => {
17829 dlg.finished(false);
17830 return Err(common::Error::MissingToken(e));
17831 }
17832 },
17833 };
17834 let mut req_result = {
17835 let client = &self.hub.client;
17836 dlg.pre_request();
17837 let mut req_builder = hyper::Request::builder()
17838 .method(hyper::Method::GET)
17839 .uri(url.as_str())
17840 .header(USER_AGENT, self.hub._user_agent.clone());
17841
17842 if let Some(token) = token.as_ref() {
17843 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17844 }
17845
17846 let request = req_builder
17847 .header(CONTENT_LENGTH, 0_u64)
17848 .body(common::to_body::<String>(None));
17849
17850 client.request(request.unwrap()).await
17851 };
17852
17853 match req_result {
17854 Err(err) => {
17855 if let common::Retry::After(d) = dlg.http_error(&err) {
17856 sleep(d).await;
17857 continue;
17858 }
17859 dlg.finished(false);
17860 return Err(common::Error::HttpError(err));
17861 }
17862 Ok(res) => {
17863 let (mut parts, body) = res.into_parts();
17864 let mut body = common::Body::new(body);
17865 if !parts.status.is_success() {
17866 let bytes = common::to_bytes(body).await.unwrap_or_default();
17867 let error = serde_json::from_str(&common::to_string(&bytes));
17868 let response = common::to_response(parts, bytes.into());
17869
17870 if let common::Retry::After(d) =
17871 dlg.http_failure(&response, error.as_ref().ok())
17872 {
17873 sleep(d).await;
17874 continue;
17875 }
17876
17877 dlg.finished(false);
17878
17879 return Err(match error {
17880 Ok(value) => common::Error::BadRequest(value),
17881 _ => common::Error::Failure(response),
17882 });
17883 }
17884 let response = {
17885 let bytes = common::to_bytes(body).await.unwrap_or_default();
17886 let encoded = common::to_string(&bytes);
17887 match serde_json::from_str(&encoded) {
17888 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17889 Err(error) => {
17890 dlg.response_json_decode_error(&encoded, &error);
17891 return Err(common::Error::JsonDecodeError(
17892 encoded.to_string(),
17893 error,
17894 ));
17895 }
17896 }
17897 };
17898
17899 dlg.finished(true);
17900 return Ok(response);
17901 }
17902 }
17903 }
17904 }
17905
17906 /// Required. The project and location from which the `LbEdgeExtension` resources are listed. These values are specified in the following format: `projects/{project}/locations/{location}`.
17907 ///
17908 /// Sets the *parent* path property to the given value.
17909 ///
17910 /// Even though the property as already been set when instantiating this call,
17911 /// we provide this method for API completeness.
17912 pub fn parent(mut self, new_value: &str) -> ProjectLocationLbEdgeExtensionListCall<'a, C> {
17913 self._parent = new_value.to_string();
17914 self
17915 }
17916 /// Optional. A token identifying a page of results that the server returns.
17917 ///
17918 /// Sets the *page token* query property to the given value.
17919 pub fn page_token(mut self, new_value: &str) -> ProjectLocationLbEdgeExtensionListCall<'a, C> {
17920 self._page_token = Some(new_value.to_string());
17921 self
17922 }
17923 /// Optional. Requested page size. The server might return fewer items than requested. If unspecified, the server picks an appropriate default.
17924 ///
17925 /// Sets the *page size* query property to the given value.
17926 pub fn page_size(mut self, new_value: i32) -> ProjectLocationLbEdgeExtensionListCall<'a, C> {
17927 self._page_size = Some(new_value);
17928 self
17929 }
17930 /// Optional. Hint about how to order the results.
17931 ///
17932 /// Sets the *order by* query property to the given value.
17933 pub fn order_by(mut self, new_value: &str) -> ProjectLocationLbEdgeExtensionListCall<'a, C> {
17934 self._order_by = Some(new_value.to_string());
17935 self
17936 }
17937 /// Optional. Filtering results.
17938 ///
17939 /// Sets the *filter* query property to the given value.
17940 pub fn filter(mut self, new_value: &str) -> ProjectLocationLbEdgeExtensionListCall<'a, C> {
17941 self._filter = Some(new_value.to_string());
17942 self
17943 }
17944 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17945 /// while executing the actual API request.
17946 ///
17947 /// ````text
17948 /// It should be used to handle progress information, and to implement a certain level of resilience.
17949 /// ````
17950 ///
17951 /// Sets the *delegate* property to the given value.
17952 pub fn delegate(
17953 mut self,
17954 new_value: &'a mut dyn common::Delegate,
17955 ) -> ProjectLocationLbEdgeExtensionListCall<'a, C> {
17956 self._delegate = Some(new_value);
17957 self
17958 }
17959
17960 /// Set any additional parameter of the query string used in the request.
17961 /// It should be used to set parameters which are not yet available through their own
17962 /// setters.
17963 ///
17964 /// Please note that this method must not be used to set any of the known parameters
17965 /// which have their own setter method. If done anyway, the request will fail.
17966 ///
17967 /// # Additional Parameters
17968 ///
17969 /// * *$.xgafv* (query-string) - V1 error format.
17970 /// * *access_token* (query-string) - OAuth access token.
17971 /// * *alt* (query-string) - Data format for response.
17972 /// * *callback* (query-string) - JSONP
17973 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17974 /// * *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.
17975 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17976 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17977 /// * *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.
17978 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17979 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17980 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationLbEdgeExtensionListCall<'a, C>
17981 where
17982 T: AsRef<str>,
17983 {
17984 self._additional_params
17985 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17986 self
17987 }
17988
17989 /// Identifies the authorization scope for the method you are building.
17990 ///
17991 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17992 /// [`Scope::CloudPlatform`].
17993 ///
17994 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17995 /// tokens for more than one scope.
17996 ///
17997 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17998 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17999 /// sufficient, a read-write scope will do as well.
18000 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationLbEdgeExtensionListCall<'a, C>
18001 where
18002 St: AsRef<str>,
18003 {
18004 self._scopes.insert(String::from(scope.as_ref()));
18005 self
18006 }
18007 /// Identifies the authorization scope(s) for the method you are building.
18008 ///
18009 /// See [`Self::add_scope()`] for details.
18010 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationLbEdgeExtensionListCall<'a, C>
18011 where
18012 I: IntoIterator<Item = St>,
18013 St: AsRef<str>,
18014 {
18015 self._scopes
18016 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18017 self
18018 }
18019
18020 /// Removes all scopes, and no default scope will be used either.
18021 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18022 /// for details).
18023 pub fn clear_scopes(mut self) -> ProjectLocationLbEdgeExtensionListCall<'a, C> {
18024 self._scopes.clear();
18025 self
18026 }
18027}
18028
18029/// Updates the parameters of the specified `LbEdgeExtension` resource.
18030///
18031/// A builder for the *locations.lbEdgeExtensions.patch* method supported by a *project* resource.
18032/// It is not used directly, but through a [`ProjectMethods`] instance.
18033///
18034/// # Example
18035///
18036/// Instantiate a resource method builder
18037///
18038/// ```test_harness,no_run
18039/// # extern crate hyper;
18040/// # extern crate hyper_rustls;
18041/// # extern crate google_networkservices1 as networkservices1;
18042/// use networkservices1::api::LbEdgeExtension;
18043/// # async fn dox() {
18044/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18045///
18046/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18047/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18048/// # .with_native_roots()
18049/// # .unwrap()
18050/// # .https_only()
18051/// # .enable_http2()
18052/// # .build();
18053///
18054/// # let executor = hyper_util::rt::TokioExecutor::new();
18055/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18056/// # secret,
18057/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18058/// # yup_oauth2::client::CustomHyperClientBuilder::from(
18059/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
18060/// # ),
18061/// # ).build().await.unwrap();
18062///
18063/// # let client = hyper_util::client::legacy::Client::builder(
18064/// # hyper_util::rt::TokioExecutor::new()
18065/// # )
18066/// # .build(
18067/// # hyper_rustls::HttpsConnectorBuilder::new()
18068/// # .with_native_roots()
18069/// # .unwrap()
18070/// # .https_or_http()
18071/// # .enable_http2()
18072/// # .build()
18073/// # );
18074/// # let mut hub = NetworkServices::new(client, auth);
18075/// // As the method needs a request, you would usually fill it with the desired information
18076/// // into the respective structure. Some of the parts shown here might not be applicable !
18077/// // Values shown here are possibly random and not representative !
18078/// let mut req = LbEdgeExtension::default();
18079///
18080/// // You can configure optional parameters by calling the respective setters at will, and
18081/// // execute the final call using `doit()`.
18082/// // Values shown here are possibly random and not representative !
18083/// let result = hub.projects().locations_lb_edge_extensions_patch(req, "name")
18084/// .update_mask(FieldMask::new::<&str>(&[]))
18085/// .request_id("gubergren")
18086/// .doit().await;
18087/// # }
18088/// ```
18089pub struct ProjectLocationLbEdgeExtensionPatchCall<'a, C>
18090where
18091 C: 'a,
18092{
18093 hub: &'a NetworkServices<C>,
18094 _request: LbEdgeExtension,
18095 _name: String,
18096 _update_mask: Option<common::FieldMask>,
18097 _request_id: Option<String>,
18098 _delegate: Option<&'a mut dyn common::Delegate>,
18099 _additional_params: HashMap<String, String>,
18100 _scopes: BTreeSet<String>,
18101}
18102
18103impl<'a, C> common::CallBuilder for ProjectLocationLbEdgeExtensionPatchCall<'a, C> {}
18104
18105impl<'a, C> ProjectLocationLbEdgeExtensionPatchCall<'a, C>
18106where
18107 C: common::Connector,
18108{
18109 /// Perform the operation you have build so far.
18110 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
18111 use std::borrow::Cow;
18112 use std::io::{Read, Seek};
18113
18114 use common::{url::Params, ToParts};
18115 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18116
18117 let mut dd = common::DefaultDelegate;
18118 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18119 dlg.begin(common::MethodInfo {
18120 id: "networkservices.projects.locations.lbEdgeExtensions.patch",
18121 http_method: hyper::Method::PATCH,
18122 });
18123
18124 for &field in ["alt", "name", "updateMask", "requestId"].iter() {
18125 if self._additional_params.contains_key(field) {
18126 dlg.finished(false);
18127 return Err(common::Error::FieldClash(field));
18128 }
18129 }
18130
18131 let mut params = Params::with_capacity(6 + self._additional_params.len());
18132 params.push("name", self._name);
18133 if let Some(value) = self._update_mask.as_ref() {
18134 params.push("updateMask", value.to_string());
18135 }
18136 if let Some(value) = self._request_id.as_ref() {
18137 params.push("requestId", value);
18138 }
18139
18140 params.extend(self._additional_params.iter());
18141
18142 params.push("alt", "json");
18143 let mut url = self.hub._base_url.clone() + "v1/{+name}";
18144 if self._scopes.is_empty() {
18145 self._scopes
18146 .insert(Scope::CloudPlatform.as_ref().to_string());
18147 }
18148
18149 #[allow(clippy::single_element_loop)]
18150 for &(find_this, param_name) in [("{+name}", "name")].iter() {
18151 url = params.uri_replacement(url, param_name, find_this, true);
18152 }
18153 {
18154 let to_remove = ["name"];
18155 params.remove_params(&to_remove);
18156 }
18157
18158 let url = params.parse_with_url(&url);
18159
18160 let mut json_mime_type = mime::APPLICATION_JSON;
18161 let mut request_value_reader = {
18162 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18163 common::remove_json_null_values(&mut value);
18164 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18165 serde_json::to_writer(&mut dst, &value).unwrap();
18166 dst
18167 };
18168 let request_size = request_value_reader
18169 .seek(std::io::SeekFrom::End(0))
18170 .unwrap();
18171 request_value_reader
18172 .seek(std::io::SeekFrom::Start(0))
18173 .unwrap();
18174
18175 loop {
18176 let token = match self
18177 .hub
18178 .auth
18179 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18180 .await
18181 {
18182 Ok(token) => token,
18183 Err(e) => match dlg.token(e) {
18184 Ok(token) => token,
18185 Err(e) => {
18186 dlg.finished(false);
18187 return Err(common::Error::MissingToken(e));
18188 }
18189 },
18190 };
18191 request_value_reader
18192 .seek(std::io::SeekFrom::Start(0))
18193 .unwrap();
18194 let mut req_result = {
18195 let client = &self.hub.client;
18196 dlg.pre_request();
18197 let mut req_builder = hyper::Request::builder()
18198 .method(hyper::Method::PATCH)
18199 .uri(url.as_str())
18200 .header(USER_AGENT, self.hub._user_agent.clone());
18201
18202 if let Some(token) = token.as_ref() {
18203 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18204 }
18205
18206 let request = req_builder
18207 .header(CONTENT_TYPE, json_mime_type.to_string())
18208 .header(CONTENT_LENGTH, request_size as u64)
18209 .body(common::to_body(
18210 request_value_reader.get_ref().clone().into(),
18211 ));
18212
18213 client.request(request.unwrap()).await
18214 };
18215
18216 match req_result {
18217 Err(err) => {
18218 if let common::Retry::After(d) = dlg.http_error(&err) {
18219 sleep(d).await;
18220 continue;
18221 }
18222 dlg.finished(false);
18223 return Err(common::Error::HttpError(err));
18224 }
18225 Ok(res) => {
18226 let (mut parts, body) = res.into_parts();
18227 let mut body = common::Body::new(body);
18228 if !parts.status.is_success() {
18229 let bytes = common::to_bytes(body).await.unwrap_or_default();
18230 let error = serde_json::from_str(&common::to_string(&bytes));
18231 let response = common::to_response(parts, bytes.into());
18232
18233 if let common::Retry::After(d) =
18234 dlg.http_failure(&response, error.as_ref().ok())
18235 {
18236 sleep(d).await;
18237 continue;
18238 }
18239
18240 dlg.finished(false);
18241
18242 return Err(match error {
18243 Ok(value) => common::Error::BadRequest(value),
18244 _ => common::Error::Failure(response),
18245 });
18246 }
18247 let response = {
18248 let bytes = common::to_bytes(body).await.unwrap_or_default();
18249 let encoded = common::to_string(&bytes);
18250 match serde_json::from_str(&encoded) {
18251 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18252 Err(error) => {
18253 dlg.response_json_decode_error(&encoded, &error);
18254 return Err(common::Error::JsonDecodeError(
18255 encoded.to_string(),
18256 error,
18257 ));
18258 }
18259 }
18260 };
18261
18262 dlg.finished(true);
18263 return Ok(response);
18264 }
18265 }
18266 }
18267 }
18268
18269 ///
18270 /// Sets the *request* property to the given value.
18271 ///
18272 /// Even though the property as already been set when instantiating this call,
18273 /// we provide this method for API completeness.
18274 pub fn request(
18275 mut self,
18276 new_value: LbEdgeExtension,
18277 ) -> ProjectLocationLbEdgeExtensionPatchCall<'a, C> {
18278 self._request = new_value;
18279 self
18280 }
18281 /// Required. Identifier. Name of the `LbEdgeExtension` resource in the following format: `projects/{project}/locations/{location}/lbEdgeExtensions/{lb_edge_extension}`.
18282 ///
18283 /// Sets the *name* path property to the given value.
18284 ///
18285 /// Even though the property as already been set when instantiating this call,
18286 /// we provide this method for API completeness.
18287 pub fn name(mut self, new_value: &str) -> ProjectLocationLbEdgeExtensionPatchCall<'a, C> {
18288 self._name = new_value.to_string();
18289 self
18290 }
18291 /// Optional. Used to specify the fields to be overwritten in the `LbEdgeExtension` resource by the update. The fields specified in the `update_mask` are relative to the resource, not the full request. A field is overwritten if it is in the mask. If the user does not specify a mask, then all fields are overwritten.
18292 ///
18293 /// Sets the *update mask* query property to the given value.
18294 pub fn update_mask(
18295 mut self,
18296 new_value: common::FieldMask,
18297 ) -> ProjectLocationLbEdgeExtensionPatchCall<'a, C> {
18298 self._update_mask = Some(new_value);
18299 self
18300 }
18301 /// Optional. An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server can ignore the request if it has already been completed. The server guarantees that for 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 ignores 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).
18302 ///
18303 /// Sets the *request id* query property to the given value.
18304 pub fn request_id(mut self, new_value: &str) -> ProjectLocationLbEdgeExtensionPatchCall<'a, C> {
18305 self._request_id = Some(new_value.to_string());
18306 self
18307 }
18308 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18309 /// while executing the actual API request.
18310 ///
18311 /// ````text
18312 /// It should be used to handle progress information, and to implement a certain level of resilience.
18313 /// ````
18314 ///
18315 /// Sets the *delegate* property to the given value.
18316 pub fn delegate(
18317 mut self,
18318 new_value: &'a mut dyn common::Delegate,
18319 ) -> ProjectLocationLbEdgeExtensionPatchCall<'a, C> {
18320 self._delegate = Some(new_value);
18321 self
18322 }
18323
18324 /// Set any additional parameter of the query string used in the request.
18325 /// It should be used to set parameters which are not yet available through their own
18326 /// setters.
18327 ///
18328 /// Please note that this method must not be used to set any of the known parameters
18329 /// which have their own setter method. If done anyway, the request will fail.
18330 ///
18331 /// # Additional Parameters
18332 ///
18333 /// * *$.xgafv* (query-string) - V1 error format.
18334 /// * *access_token* (query-string) - OAuth access token.
18335 /// * *alt* (query-string) - Data format for response.
18336 /// * *callback* (query-string) - JSONP
18337 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18338 /// * *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.
18339 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18340 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18341 /// * *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.
18342 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18343 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18344 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationLbEdgeExtensionPatchCall<'a, C>
18345 where
18346 T: AsRef<str>,
18347 {
18348 self._additional_params
18349 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18350 self
18351 }
18352
18353 /// Identifies the authorization scope for the method you are building.
18354 ///
18355 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18356 /// [`Scope::CloudPlatform`].
18357 ///
18358 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18359 /// tokens for more than one scope.
18360 ///
18361 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18362 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18363 /// sufficient, a read-write scope will do as well.
18364 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationLbEdgeExtensionPatchCall<'a, C>
18365 where
18366 St: AsRef<str>,
18367 {
18368 self._scopes.insert(String::from(scope.as_ref()));
18369 self
18370 }
18371 /// Identifies the authorization scope(s) for the method you are building.
18372 ///
18373 /// See [`Self::add_scope()`] for details.
18374 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationLbEdgeExtensionPatchCall<'a, C>
18375 where
18376 I: IntoIterator<Item = St>,
18377 St: AsRef<str>,
18378 {
18379 self._scopes
18380 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18381 self
18382 }
18383
18384 /// Removes all scopes, and no default scope will be used either.
18385 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18386 /// for details).
18387 pub fn clear_scopes(mut self) -> ProjectLocationLbEdgeExtensionPatchCall<'a, C> {
18388 self._scopes.clear();
18389 self
18390 }
18391}
18392
18393/// Creates a new `LbRouteExtension` resource in a given project and location.
18394///
18395/// A builder for the *locations.lbRouteExtensions.create* method supported by a *project* resource.
18396/// It is not used directly, but through a [`ProjectMethods`] instance.
18397///
18398/// # Example
18399///
18400/// Instantiate a resource method builder
18401///
18402/// ```test_harness,no_run
18403/// # extern crate hyper;
18404/// # extern crate hyper_rustls;
18405/// # extern crate google_networkservices1 as networkservices1;
18406/// use networkservices1::api::LbRouteExtension;
18407/// # async fn dox() {
18408/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18409///
18410/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18411/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18412/// # .with_native_roots()
18413/// # .unwrap()
18414/// # .https_only()
18415/// # .enable_http2()
18416/// # .build();
18417///
18418/// # let executor = hyper_util::rt::TokioExecutor::new();
18419/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18420/// # secret,
18421/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18422/// # yup_oauth2::client::CustomHyperClientBuilder::from(
18423/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
18424/// # ),
18425/// # ).build().await.unwrap();
18426///
18427/// # let client = hyper_util::client::legacy::Client::builder(
18428/// # hyper_util::rt::TokioExecutor::new()
18429/// # )
18430/// # .build(
18431/// # hyper_rustls::HttpsConnectorBuilder::new()
18432/// # .with_native_roots()
18433/// # .unwrap()
18434/// # .https_or_http()
18435/// # .enable_http2()
18436/// # .build()
18437/// # );
18438/// # let mut hub = NetworkServices::new(client, auth);
18439/// // As the method needs a request, you would usually fill it with the desired information
18440/// // into the respective structure. Some of the parts shown here might not be applicable !
18441/// // Values shown here are possibly random and not representative !
18442/// let mut req = LbRouteExtension::default();
18443///
18444/// // You can configure optional parameters by calling the respective setters at will, and
18445/// // execute the final call using `doit()`.
18446/// // Values shown here are possibly random and not representative !
18447/// let result = hub.projects().locations_lb_route_extensions_create(req, "parent")
18448/// .request_id("accusam")
18449/// .lb_route_extension_id("voluptua.")
18450/// .doit().await;
18451/// # }
18452/// ```
18453pub struct ProjectLocationLbRouteExtensionCreateCall<'a, C>
18454where
18455 C: 'a,
18456{
18457 hub: &'a NetworkServices<C>,
18458 _request: LbRouteExtension,
18459 _parent: String,
18460 _request_id: Option<String>,
18461 _lb_route_extension_id: Option<String>,
18462 _delegate: Option<&'a mut dyn common::Delegate>,
18463 _additional_params: HashMap<String, String>,
18464 _scopes: BTreeSet<String>,
18465}
18466
18467impl<'a, C> common::CallBuilder for ProjectLocationLbRouteExtensionCreateCall<'a, C> {}
18468
18469impl<'a, C> ProjectLocationLbRouteExtensionCreateCall<'a, C>
18470where
18471 C: common::Connector,
18472{
18473 /// Perform the operation you have build so far.
18474 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
18475 use std::borrow::Cow;
18476 use std::io::{Read, Seek};
18477
18478 use common::{url::Params, ToParts};
18479 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18480
18481 let mut dd = common::DefaultDelegate;
18482 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18483 dlg.begin(common::MethodInfo {
18484 id: "networkservices.projects.locations.lbRouteExtensions.create",
18485 http_method: hyper::Method::POST,
18486 });
18487
18488 for &field in ["alt", "parent", "requestId", "lbRouteExtensionId"].iter() {
18489 if self._additional_params.contains_key(field) {
18490 dlg.finished(false);
18491 return Err(common::Error::FieldClash(field));
18492 }
18493 }
18494
18495 let mut params = Params::with_capacity(6 + self._additional_params.len());
18496 params.push("parent", self._parent);
18497 if let Some(value) = self._request_id.as_ref() {
18498 params.push("requestId", value);
18499 }
18500 if let Some(value) = self._lb_route_extension_id.as_ref() {
18501 params.push("lbRouteExtensionId", value);
18502 }
18503
18504 params.extend(self._additional_params.iter());
18505
18506 params.push("alt", "json");
18507 let mut url = self.hub._base_url.clone() + "v1/{+parent}/lbRouteExtensions";
18508 if self._scopes.is_empty() {
18509 self._scopes
18510 .insert(Scope::CloudPlatform.as_ref().to_string());
18511 }
18512
18513 #[allow(clippy::single_element_loop)]
18514 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
18515 url = params.uri_replacement(url, param_name, find_this, true);
18516 }
18517 {
18518 let to_remove = ["parent"];
18519 params.remove_params(&to_remove);
18520 }
18521
18522 let url = params.parse_with_url(&url);
18523
18524 let mut json_mime_type = mime::APPLICATION_JSON;
18525 let mut request_value_reader = {
18526 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18527 common::remove_json_null_values(&mut value);
18528 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18529 serde_json::to_writer(&mut dst, &value).unwrap();
18530 dst
18531 };
18532 let request_size = request_value_reader
18533 .seek(std::io::SeekFrom::End(0))
18534 .unwrap();
18535 request_value_reader
18536 .seek(std::io::SeekFrom::Start(0))
18537 .unwrap();
18538
18539 loop {
18540 let token = match self
18541 .hub
18542 .auth
18543 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18544 .await
18545 {
18546 Ok(token) => token,
18547 Err(e) => match dlg.token(e) {
18548 Ok(token) => token,
18549 Err(e) => {
18550 dlg.finished(false);
18551 return Err(common::Error::MissingToken(e));
18552 }
18553 },
18554 };
18555 request_value_reader
18556 .seek(std::io::SeekFrom::Start(0))
18557 .unwrap();
18558 let mut req_result = {
18559 let client = &self.hub.client;
18560 dlg.pre_request();
18561 let mut req_builder = hyper::Request::builder()
18562 .method(hyper::Method::POST)
18563 .uri(url.as_str())
18564 .header(USER_AGENT, self.hub._user_agent.clone());
18565
18566 if let Some(token) = token.as_ref() {
18567 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18568 }
18569
18570 let request = req_builder
18571 .header(CONTENT_TYPE, json_mime_type.to_string())
18572 .header(CONTENT_LENGTH, request_size as u64)
18573 .body(common::to_body(
18574 request_value_reader.get_ref().clone().into(),
18575 ));
18576
18577 client.request(request.unwrap()).await
18578 };
18579
18580 match req_result {
18581 Err(err) => {
18582 if let common::Retry::After(d) = dlg.http_error(&err) {
18583 sleep(d).await;
18584 continue;
18585 }
18586 dlg.finished(false);
18587 return Err(common::Error::HttpError(err));
18588 }
18589 Ok(res) => {
18590 let (mut parts, body) = res.into_parts();
18591 let mut body = common::Body::new(body);
18592 if !parts.status.is_success() {
18593 let bytes = common::to_bytes(body).await.unwrap_or_default();
18594 let error = serde_json::from_str(&common::to_string(&bytes));
18595 let response = common::to_response(parts, bytes.into());
18596
18597 if let common::Retry::After(d) =
18598 dlg.http_failure(&response, error.as_ref().ok())
18599 {
18600 sleep(d).await;
18601 continue;
18602 }
18603
18604 dlg.finished(false);
18605
18606 return Err(match error {
18607 Ok(value) => common::Error::BadRequest(value),
18608 _ => common::Error::Failure(response),
18609 });
18610 }
18611 let response = {
18612 let bytes = common::to_bytes(body).await.unwrap_or_default();
18613 let encoded = common::to_string(&bytes);
18614 match serde_json::from_str(&encoded) {
18615 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18616 Err(error) => {
18617 dlg.response_json_decode_error(&encoded, &error);
18618 return Err(common::Error::JsonDecodeError(
18619 encoded.to_string(),
18620 error,
18621 ));
18622 }
18623 }
18624 };
18625
18626 dlg.finished(true);
18627 return Ok(response);
18628 }
18629 }
18630 }
18631 }
18632
18633 ///
18634 /// Sets the *request* property to the given value.
18635 ///
18636 /// Even though the property as already been set when instantiating this call,
18637 /// we provide this method for API completeness.
18638 pub fn request(
18639 mut self,
18640 new_value: LbRouteExtension,
18641 ) -> ProjectLocationLbRouteExtensionCreateCall<'a, C> {
18642 self._request = new_value;
18643 self
18644 }
18645 /// Required. The parent resource of the `LbRouteExtension` resource. Must be in the format `projects/{project}/locations/{location}`.
18646 ///
18647 /// Sets the *parent* path property to the given value.
18648 ///
18649 /// Even though the property as already been set when instantiating this call,
18650 /// we provide this method for API completeness.
18651 pub fn parent(mut self, new_value: &str) -> ProjectLocationLbRouteExtensionCreateCall<'a, C> {
18652 self._parent = new_value.to_string();
18653 self
18654 }
18655 /// Optional. An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server can ignore the request if it has already been completed. The server guarantees that for 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 ignores 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).
18656 ///
18657 /// Sets the *request id* query property to the given value.
18658 pub fn request_id(
18659 mut self,
18660 new_value: &str,
18661 ) -> ProjectLocationLbRouteExtensionCreateCall<'a, C> {
18662 self._request_id = Some(new_value.to_string());
18663 self
18664 }
18665 /// Required. User-provided ID of the `LbRouteExtension` resource to be created.
18666 ///
18667 /// Sets the *lb route extension id* query property to the given value.
18668 pub fn lb_route_extension_id(
18669 mut self,
18670 new_value: &str,
18671 ) -> ProjectLocationLbRouteExtensionCreateCall<'a, C> {
18672 self._lb_route_extension_id = Some(new_value.to_string());
18673 self
18674 }
18675 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18676 /// while executing the actual API request.
18677 ///
18678 /// ````text
18679 /// It should be used to handle progress information, and to implement a certain level of resilience.
18680 /// ````
18681 ///
18682 /// Sets the *delegate* property to the given value.
18683 pub fn delegate(
18684 mut self,
18685 new_value: &'a mut dyn common::Delegate,
18686 ) -> ProjectLocationLbRouteExtensionCreateCall<'a, C> {
18687 self._delegate = Some(new_value);
18688 self
18689 }
18690
18691 /// Set any additional parameter of the query string used in the request.
18692 /// It should be used to set parameters which are not yet available through their own
18693 /// setters.
18694 ///
18695 /// Please note that this method must not be used to set any of the known parameters
18696 /// which have their own setter method. If done anyway, the request will fail.
18697 ///
18698 /// # Additional Parameters
18699 ///
18700 /// * *$.xgafv* (query-string) - V1 error format.
18701 /// * *access_token* (query-string) - OAuth access token.
18702 /// * *alt* (query-string) - Data format for response.
18703 /// * *callback* (query-string) - JSONP
18704 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18705 /// * *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.
18706 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18707 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18708 /// * *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.
18709 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18710 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18711 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationLbRouteExtensionCreateCall<'a, C>
18712 where
18713 T: AsRef<str>,
18714 {
18715 self._additional_params
18716 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18717 self
18718 }
18719
18720 /// Identifies the authorization scope for the method you are building.
18721 ///
18722 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18723 /// [`Scope::CloudPlatform`].
18724 ///
18725 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18726 /// tokens for more than one scope.
18727 ///
18728 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18729 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18730 /// sufficient, a read-write scope will do as well.
18731 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationLbRouteExtensionCreateCall<'a, C>
18732 where
18733 St: AsRef<str>,
18734 {
18735 self._scopes.insert(String::from(scope.as_ref()));
18736 self
18737 }
18738 /// Identifies the authorization scope(s) for the method you are building.
18739 ///
18740 /// See [`Self::add_scope()`] for details.
18741 pub fn add_scopes<I, St>(
18742 mut self,
18743 scopes: I,
18744 ) -> ProjectLocationLbRouteExtensionCreateCall<'a, C>
18745 where
18746 I: IntoIterator<Item = St>,
18747 St: AsRef<str>,
18748 {
18749 self._scopes
18750 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18751 self
18752 }
18753
18754 /// Removes all scopes, and no default scope will be used either.
18755 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18756 /// for details).
18757 pub fn clear_scopes(mut self) -> ProjectLocationLbRouteExtensionCreateCall<'a, C> {
18758 self._scopes.clear();
18759 self
18760 }
18761}
18762
18763/// Deletes the specified `LbRouteExtension` resource.
18764///
18765/// A builder for the *locations.lbRouteExtensions.delete* method supported by a *project* resource.
18766/// It is not used directly, but through a [`ProjectMethods`] instance.
18767///
18768/// # Example
18769///
18770/// Instantiate a resource method builder
18771///
18772/// ```test_harness,no_run
18773/// # extern crate hyper;
18774/// # extern crate hyper_rustls;
18775/// # extern crate google_networkservices1 as networkservices1;
18776/// # async fn dox() {
18777/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18778///
18779/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18780/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18781/// # .with_native_roots()
18782/// # .unwrap()
18783/// # .https_only()
18784/// # .enable_http2()
18785/// # .build();
18786///
18787/// # let executor = hyper_util::rt::TokioExecutor::new();
18788/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18789/// # secret,
18790/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18791/// # yup_oauth2::client::CustomHyperClientBuilder::from(
18792/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
18793/// # ),
18794/// # ).build().await.unwrap();
18795///
18796/// # let client = hyper_util::client::legacy::Client::builder(
18797/// # hyper_util::rt::TokioExecutor::new()
18798/// # )
18799/// # .build(
18800/// # hyper_rustls::HttpsConnectorBuilder::new()
18801/// # .with_native_roots()
18802/// # .unwrap()
18803/// # .https_or_http()
18804/// # .enable_http2()
18805/// # .build()
18806/// # );
18807/// # let mut hub = NetworkServices::new(client, auth);
18808/// // You can configure optional parameters by calling the respective setters at will, and
18809/// // execute the final call using `doit()`.
18810/// // Values shown here are possibly random and not representative !
18811/// let result = hub.projects().locations_lb_route_extensions_delete("name")
18812/// .request_id("dolore")
18813/// .doit().await;
18814/// # }
18815/// ```
18816pub struct ProjectLocationLbRouteExtensionDeleteCall<'a, C>
18817where
18818 C: 'a,
18819{
18820 hub: &'a NetworkServices<C>,
18821 _name: String,
18822 _request_id: Option<String>,
18823 _delegate: Option<&'a mut dyn common::Delegate>,
18824 _additional_params: HashMap<String, String>,
18825 _scopes: BTreeSet<String>,
18826}
18827
18828impl<'a, C> common::CallBuilder for ProjectLocationLbRouteExtensionDeleteCall<'a, C> {}
18829
18830impl<'a, C> ProjectLocationLbRouteExtensionDeleteCall<'a, C>
18831where
18832 C: common::Connector,
18833{
18834 /// Perform the operation you have build so far.
18835 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
18836 use std::borrow::Cow;
18837 use std::io::{Read, Seek};
18838
18839 use common::{url::Params, ToParts};
18840 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18841
18842 let mut dd = common::DefaultDelegate;
18843 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18844 dlg.begin(common::MethodInfo {
18845 id: "networkservices.projects.locations.lbRouteExtensions.delete",
18846 http_method: hyper::Method::DELETE,
18847 });
18848
18849 for &field in ["alt", "name", "requestId"].iter() {
18850 if self._additional_params.contains_key(field) {
18851 dlg.finished(false);
18852 return Err(common::Error::FieldClash(field));
18853 }
18854 }
18855
18856 let mut params = Params::with_capacity(4 + self._additional_params.len());
18857 params.push("name", self._name);
18858 if let Some(value) = self._request_id.as_ref() {
18859 params.push("requestId", value);
18860 }
18861
18862 params.extend(self._additional_params.iter());
18863
18864 params.push("alt", "json");
18865 let mut url = self.hub._base_url.clone() + "v1/{+name}";
18866 if self._scopes.is_empty() {
18867 self._scopes
18868 .insert(Scope::CloudPlatform.as_ref().to_string());
18869 }
18870
18871 #[allow(clippy::single_element_loop)]
18872 for &(find_this, param_name) in [("{+name}", "name")].iter() {
18873 url = params.uri_replacement(url, param_name, find_this, true);
18874 }
18875 {
18876 let to_remove = ["name"];
18877 params.remove_params(&to_remove);
18878 }
18879
18880 let url = params.parse_with_url(&url);
18881
18882 loop {
18883 let token = match self
18884 .hub
18885 .auth
18886 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18887 .await
18888 {
18889 Ok(token) => token,
18890 Err(e) => match dlg.token(e) {
18891 Ok(token) => token,
18892 Err(e) => {
18893 dlg.finished(false);
18894 return Err(common::Error::MissingToken(e));
18895 }
18896 },
18897 };
18898 let mut req_result = {
18899 let client = &self.hub.client;
18900 dlg.pre_request();
18901 let mut req_builder = hyper::Request::builder()
18902 .method(hyper::Method::DELETE)
18903 .uri(url.as_str())
18904 .header(USER_AGENT, self.hub._user_agent.clone());
18905
18906 if let Some(token) = token.as_ref() {
18907 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18908 }
18909
18910 let request = req_builder
18911 .header(CONTENT_LENGTH, 0_u64)
18912 .body(common::to_body::<String>(None));
18913
18914 client.request(request.unwrap()).await
18915 };
18916
18917 match req_result {
18918 Err(err) => {
18919 if let common::Retry::After(d) = dlg.http_error(&err) {
18920 sleep(d).await;
18921 continue;
18922 }
18923 dlg.finished(false);
18924 return Err(common::Error::HttpError(err));
18925 }
18926 Ok(res) => {
18927 let (mut parts, body) = res.into_parts();
18928 let mut body = common::Body::new(body);
18929 if !parts.status.is_success() {
18930 let bytes = common::to_bytes(body).await.unwrap_or_default();
18931 let error = serde_json::from_str(&common::to_string(&bytes));
18932 let response = common::to_response(parts, bytes.into());
18933
18934 if let common::Retry::After(d) =
18935 dlg.http_failure(&response, error.as_ref().ok())
18936 {
18937 sleep(d).await;
18938 continue;
18939 }
18940
18941 dlg.finished(false);
18942
18943 return Err(match error {
18944 Ok(value) => common::Error::BadRequest(value),
18945 _ => common::Error::Failure(response),
18946 });
18947 }
18948 let response = {
18949 let bytes = common::to_bytes(body).await.unwrap_or_default();
18950 let encoded = common::to_string(&bytes);
18951 match serde_json::from_str(&encoded) {
18952 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18953 Err(error) => {
18954 dlg.response_json_decode_error(&encoded, &error);
18955 return Err(common::Error::JsonDecodeError(
18956 encoded.to_string(),
18957 error,
18958 ));
18959 }
18960 }
18961 };
18962
18963 dlg.finished(true);
18964 return Ok(response);
18965 }
18966 }
18967 }
18968 }
18969
18970 /// Required. The name of the `LbRouteExtension` resource to delete. Must be in the format `projects/{project}/locations/{location}/lbRouteExtensions/{lb_route_extension}`.
18971 ///
18972 /// Sets the *name* path property to the given value.
18973 ///
18974 /// Even though the property as already been set when instantiating this call,
18975 /// we provide this method for API completeness.
18976 pub fn name(mut self, new_value: &str) -> ProjectLocationLbRouteExtensionDeleteCall<'a, C> {
18977 self._name = new_value.to_string();
18978 self
18979 }
18980 /// Optional. An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server can ignore the request if it has already been completed. The server guarantees that for 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 ignores 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).
18981 ///
18982 /// Sets the *request id* query property to the given value.
18983 pub fn request_id(
18984 mut self,
18985 new_value: &str,
18986 ) -> ProjectLocationLbRouteExtensionDeleteCall<'a, C> {
18987 self._request_id = Some(new_value.to_string());
18988 self
18989 }
18990 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18991 /// while executing the actual API request.
18992 ///
18993 /// ````text
18994 /// It should be used to handle progress information, and to implement a certain level of resilience.
18995 /// ````
18996 ///
18997 /// Sets the *delegate* property to the given value.
18998 pub fn delegate(
18999 mut self,
19000 new_value: &'a mut dyn common::Delegate,
19001 ) -> ProjectLocationLbRouteExtensionDeleteCall<'a, C> {
19002 self._delegate = Some(new_value);
19003 self
19004 }
19005
19006 /// Set any additional parameter of the query string used in the request.
19007 /// It should be used to set parameters which are not yet available through their own
19008 /// setters.
19009 ///
19010 /// Please note that this method must not be used to set any of the known parameters
19011 /// which have their own setter method. If done anyway, the request will fail.
19012 ///
19013 /// # Additional Parameters
19014 ///
19015 /// * *$.xgafv* (query-string) - V1 error format.
19016 /// * *access_token* (query-string) - OAuth access token.
19017 /// * *alt* (query-string) - Data format for response.
19018 /// * *callback* (query-string) - JSONP
19019 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19020 /// * *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.
19021 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19022 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19023 /// * *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.
19024 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19025 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19026 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationLbRouteExtensionDeleteCall<'a, C>
19027 where
19028 T: AsRef<str>,
19029 {
19030 self._additional_params
19031 .insert(name.as_ref().to_string(), value.as_ref().to_string());
19032 self
19033 }
19034
19035 /// Identifies the authorization scope for the method you are building.
19036 ///
19037 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19038 /// [`Scope::CloudPlatform`].
19039 ///
19040 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19041 /// tokens for more than one scope.
19042 ///
19043 /// Usually there is more than one suitable scope to authorize an operation, some of which may
19044 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19045 /// sufficient, a read-write scope will do as well.
19046 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationLbRouteExtensionDeleteCall<'a, C>
19047 where
19048 St: AsRef<str>,
19049 {
19050 self._scopes.insert(String::from(scope.as_ref()));
19051 self
19052 }
19053 /// Identifies the authorization scope(s) for the method you are building.
19054 ///
19055 /// See [`Self::add_scope()`] for details.
19056 pub fn add_scopes<I, St>(
19057 mut self,
19058 scopes: I,
19059 ) -> ProjectLocationLbRouteExtensionDeleteCall<'a, C>
19060 where
19061 I: IntoIterator<Item = St>,
19062 St: AsRef<str>,
19063 {
19064 self._scopes
19065 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19066 self
19067 }
19068
19069 /// Removes all scopes, and no default scope will be used either.
19070 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19071 /// for details).
19072 pub fn clear_scopes(mut self) -> ProjectLocationLbRouteExtensionDeleteCall<'a, C> {
19073 self._scopes.clear();
19074 self
19075 }
19076}
19077
19078/// Gets details of the specified `LbRouteExtension` resource.
19079///
19080/// A builder for the *locations.lbRouteExtensions.get* method supported by a *project* resource.
19081/// It is not used directly, but through a [`ProjectMethods`] instance.
19082///
19083/// # Example
19084///
19085/// Instantiate a resource method builder
19086///
19087/// ```test_harness,no_run
19088/// # extern crate hyper;
19089/// # extern crate hyper_rustls;
19090/// # extern crate google_networkservices1 as networkservices1;
19091/// # async fn dox() {
19092/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19093///
19094/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19095/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
19096/// # .with_native_roots()
19097/// # .unwrap()
19098/// # .https_only()
19099/// # .enable_http2()
19100/// # .build();
19101///
19102/// # let executor = hyper_util::rt::TokioExecutor::new();
19103/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
19104/// # secret,
19105/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19106/// # yup_oauth2::client::CustomHyperClientBuilder::from(
19107/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
19108/// # ),
19109/// # ).build().await.unwrap();
19110///
19111/// # let client = hyper_util::client::legacy::Client::builder(
19112/// # hyper_util::rt::TokioExecutor::new()
19113/// # )
19114/// # .build(
19115/// # hyper_rustls::HttpsConnectorBuilder::new()
19116/// # .with_native_roots()
19117/// # .unwrap()
19118/// # .https_or_http()
19119/// # .enable_http2()
19120/// # .build()
19121/// # );
19122/// # let mut hub = NetworkServices::new(client, auth);
19123/// // You can configure optional parameters by calling the respective setters at will, and
19124/// // execute the final call using `doit()`.
19125/// // Values shown here are possibly random and not representative !
19126/// let result = hub.projects().locations_lb_route_extensions_get("name")
19127/// .doit().await;
19128/// # }
19129/// ```
19130pub struct ProjectLocationLbRouteExtensionGetCall<'a, C>
19131where
19132 C: 'a,
19133{
19134 hub: &'a NetworkServices<C>,
19135 _name: String,
19136 _delegate: Option<&'a mut dyn common::Delegate>,
19137 _additional_params: HashMap<String, String>,
19138 _scopes: BTreeSet<String>,
19139}
19140
19141impl<'a, C> common::CallBuilder for ProjectLocationLbRouteExtensionGetCall<'a, C> {}
19142
19143impl<'a, C> ProjectLocationLbRouteExtensionGetCall<'a, C>
19144where
19145 C: common::Connector,
19146{
19147 /// Perform the operation you have build so far.
19148 pub async fn doit(mut self) -> common::Result<(common::Response, LbRouteExtension)> {
19149 use std::borrow::Cow;
19150 use std::io::{Read, Seek};
19151
19152 use common::{url::Params, ToParts};
19153 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19154
19155 let mut dd = common::DefaultDelegate;
19156 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19157 dlg.begin(common::MethodInfo {
19158 id: "networkservices.projects.locations.lbRouteExtensions.get",
19159 http_method: hyper::Method::GET,
19160 });
19161
19162 for &field in ["alt", "name"].iter() {
19163 if self._additional_params.contains_key(field) {
19164 dlg.finished(false);
19165 return Err(common::Error::FieldClash(field));
19166 }
19167 }
19168
19169 let mut params = Params::with_capacity(3 + self._additional_params.len());
19170 params.push("name", self._name);
19171
19172 params.extend(self._additional_params.iter());
19173
19174 params.push("alt", "json");
19175 let mut url = self.hub._base_url.clone() + "v1/{+name}";
19176 if self._scopes.is_empty() {
19177 self._scopes
19178 .insert(Scope::CloudPlatform.as_ref().to_string());
19179 }
19180
19181 #[allow(clippy::single_element_loop)]
19182 for &(find_this, param_name) in [("{+name}", "name")].iter() {
19183 url = params.uri_replacement(url, param_name, find_this, true);
19184 }
19185 {
19186 let to_remove = ["name"];
19187 params.remove_params(&to_remove);
19188 }
19189
19190 let url = params.parse_with_url(&url);
19191
19192 loop {
19193 let token = match self
19194 .hub
19195 .auth
19196 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19197 .await
19198 {
19199 Ok(token) => token,
19200 Err(e) => match dlg.token(e) {
19201 Ok(token) => token,
19202 Err(e) => {
19203 dlg.finished(false);
19204 return Err(common::Error::MissingToken(e));
19205 }
19206 },
19207 };
19208 let mut req_result = {
19209 let client = &self.hub.client;
19210 dlg.pre_request();
19211 let mut req_builder = hyper::Request::builder()
19212 .method(hyper::Method::GET)
19213 .uri(url.as_str())
19214 .header(USER_AGENT, self.hub._user_agent.clone());
19215
19216 if let Some(token) = token.as_ref() {
19217 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19218 }
19219
19220 let request = req_builder
19221 .header(CONTENT_LENGTH, 0_u64)
19222 .body(common::to_body::<String>(None));
19223
19224 client.request(request.unwrap()).await
19225 };
19226
19227 match req_result {
19228 Err(err) => {
19229 if let common::Retry::After(d) = dlg.http_error(&err) {
19230 sleep(d).await;
19231 continue;
19232 }
19233 dlg.finished(false);
19234 return Err(common::Error::HttpError(err));
19235 }
19236 Ok(res) => {
19237 let (mut parts, body) = res.into_parts();
19238 let mut body = common::Body::new(body);
19239 if !parts.status.is_success() {
19240 let bytes = common::to_bytes(body).await.unwrap_or_default();
19241 let error = serde_json::from_str(&common::to_string(&bytes));
19242 let response = common::to_response(parts, bytes.into());
19243
19244 if let common::Retry::After(d) =
19245 dlg.http_failure(&response, error.as_ref().ok())
19246 {
19247 sleep(d).await;
19248 continue;
19249 }
19250
19251 dlg.finished(false);
19252
19253 return Err(match error {
19254 Ok(value) => common::Error::BadRequest(value),
19255 _ => common::Error::Failure(response),
19256 });
19257 }
19258 let response = {
19259 let bytes = common::to_bytes(body).await.unwrap_or_default();
19260 let encoded = common::to_string(&bytes);
19261 match serde_json::from_str(&encoded) {
19262 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19263 Err(error) => {
19264 dlg.response_json_decode_error(&encoded, &error);
19265 return Err(common::Error::JsonDecodeError(
19266 encoded.to_string(),
19267 error,
19268 ));
19269 }
19270 }
19271 };
19272
19273 dlg.finished(true);
19274 return Ok(response);
19275 }
19276 }
19277 }
19278 }
19279
19280 /// Required. A name of the `LbRouteExtension` resource to get. Must be in the format `projects/{project}/locations/{location}/lbRouteExtensions/{lb_route_extension}`.
19281 ///
19282 /// Sets the *name* path property to the given value.
19283 ///
19284 /// Even though the property as already been set when instantiating this call,
19285 /// we provide this method for API completeness.
19286 pub fn name(mut self, new_value: &str) -> ProjectLocationLbRouteExtensionGetCall<'a, C> {
19287 self._name = new_value.to_string();
19288 self
19289 }
19290 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19291 /// while executing the actual API request.
19292 ///
19293 /// ````text
19294 /// It should be used to handle progress information, and to implement a certain level of resilience.
19295 /// ````
19296 ///
19297 /// Sets the *delegate* property to the given value.
19298 pub fn delegate(
19299 mut self,
19300 new_value: &'a mut dyn common::Delegate,
19301 ) -> ProjectLocationLbRouteExtensionGetCall<'a, C> {
19302 self._delegate = Some(new_value);
19303 self
19304 }
19305
19306 /// Set any additional parameter of the query string used in the request.
19307 /// It should be used to set parameters which are not yet available through their own
19308 /// setters.
19309 ///
19310 /// Please note that this method must not be used to set any of the known parameters
19311 /// which have their own setter method. If done anyway, the request will fail.
19312 ///
19313 /// # Additional Parameters
19314 ///
19315 /// * *$.xgafv* (query-string) - V1 error format.
19316 /// * *access_token* (query-string) - OAuth access token.
19317 /// * *alt* (query-string) - Data format for response.
19318 /// * *callback* (query-string) - JSONP
19319 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19320 /// * *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.
19321 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19322 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19323 /// * *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.
19324 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19325 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19326 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationLbRouteExtensionGetCall<'a, C>
19327 where
19328 T: AsRef<str>,
19329 {
19330 self._additional_params
19331 .insert(name.as_ref().to_string(), value.as_ref().to_string());
19332 self
19333 }
19334
19335 /// Identifies the authorization scope for the method you are building.
19336 ///
19337 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19338 /// [`Scope::CloudPlatform`].
19339 ///
19340 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19341 /// tokens for more than one scope.
19342 ///
19343 /// Usually there is more than one suitable scope to authorize an operation, some of which may
19344 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19345 /// sufficient, a read-write scope will do as well.
19346 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationLbRouteExtensionGetCall<'a, C>
19347 where
19348 St: AsRef<str>,
19349 {
19350 self._scopes.insert(String::from(scope.as_ref()));
19351 self
19352 }
19353 /// Identifies the authorization scope(s) for the method you are building.
19354 ///
19355 /// See [`Self::add_scope()`] for details.
19356 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationLbRouteExtensionGetCall<'a, C>
19357 where
19358 I: IntoIterator<Item = St>,
19359 St: AsRef<str>,
19360 {
19361 self._scopes
19362 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19363 self
19364 }
19365
19366 /// Removes all scopes, and no default scope will be used either.
19367 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19368 /// for details).
19369 pub fn clear_scopes(mut self) -> ProjectLocationLbRouteExtensionGetCall<'a, C> {
19370 self._scopes.clear();
19371 self
19372 }
19373}
19374
19375/// Lists `LbRouteExtension` resources in a given project and location.
19376///
19377/// A builder for the *locations.lbRouteExtensions.list* method supported by a *project* resource.
19378/// It is not used directly, but through a [`ProjectMethods`] instance.
19379///
19380/// # Example
19381///
19382/// Instantiate a resource method builder
19383///
19384/// ```test_harness,no_run
19385/// # extern crate hyper;
19386/// # extern crate hyper_rustls;
19387/// # extern crate google_networkservices1 as networkservices1;
19388/// # async fn dox() {
19389/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19390///
19391/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19392/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
19393/// # .with_native_roots()
19394/// # .unwrap()
19395/// # .https_only()
19396/// # .enable_http2()
19397/// # .build();
19398///
19399/// # let executor = hyper_util::rt::TokioExecutor::new();
19400/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
19401/// # secret,
19402/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19403/// # yup_oauth2::client::CustomHyperClientBuilder::from(
19404/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
19405/// # ),
19406/// # ).build().await.unwrap();
19407///
19408/// # let client = hyper_util::client::legacy::Client::builder(
19409/// # hyper_util::rt::TokioExecutor::new()
19410/// # )
19411/// # .build(
19412/// # hyper_rustls::HttpsConnectorBuilder::new()
19413/// # .with_native_roots()
19414/// # .unwrap()
19415/// # .https_or_http()
19416/// # .enable_http2()
19417/// # .build()
19418/// # );
19419/// # let mut hub = NetworkServices::new(client, auth);
19420/// // You can configure optional parameters by calling the respective setters at will, and
19421/// // execute the final call using `doit()`.
19422/// // Values shown here are possibly random and not representative !
19423/// let result = hub.projects().locations_lb_route_extensions_list("parent")
19424/// .page_token("amet.")
19425/// .page_size(-17)
19426/// .order_by("sadipscing")
19427/// .filter("Lorem")
19428/// .doit().await;
19429/// # }
19430/// ```
19431pub struct ProjectLocationLbRouteExtensionListCall<'a, C>
19432where
19433 C: 'a,
19434{
19435 hub: &'a NetworkServices<C>,
19436 _parent: String,
19437 _page_token: Option<String>,
19438 _page_size: Option<i32>,
19439 _order_by: Option<String>,
19440 _filter: Option<String>,
19441 _delegate: Option<&'a mut dyn common::Delegate>,
19442 _additional_params: HashMap<String, String>,
19443 _scopes: BTreeSet<String>,
19444}
19445
19446impl<'a, C> common::CallBuilder for ProjectLocationLbRouteExtensionListCall<'a, C> {}
19447
19448impl<'a, C> ProjectLocationLbRouteExtensionListCall<'a, C>
19449where
19450 C: common::Connector,
19451{
19452 /// Perform the operation you have build so far.
19453 pub async fn doit(
19454 mut self,
19455 ) -> common::Result<(common::Response, ListLbRouteExtensionsResponse)> {
19456 use std::borrow::Cow;
19457 use std::io::{Read, Seek};
19458
19459 use common::{url::Params, ToParts};
19460 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19461
19462 let mut dd = common::DefaultDelegate;
19463 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19464 dlg.begin(common::MethodInfo {
19465 id: "networkservices.projects.locations.lbRouteExtensions.list",
19466 http_method: hyper::Method::GET,
19467 });
19468
19469 for &field in [
19470 "alt",
19471 "parent",
19472 "pageToken",
19473 "pageSize",
19474 "orderBy",
19475 "filter",
19476 ]
19477 .iter()
19478 {
19479 if self._additional_params.contains_key(field) {
19480 dlg.finished(false);
19481 return Err(common::Error::FieldClash(field));
19482 }
19483 }
19484
19485 let mut params = Params::with_capacity(7 + self._additional_params.len());
19486 params.push("parent", self._parent);
19487 if let Some(value) = self._page_token.as_ref() {
19488 params.push("pageToken", value);
19489 }
19490 if let Some(value) = self._page_size.as_ref() {
19491 params.push("pageSize", value.to_string());
19492 }
19493 if let Some(value) = self._order_by.as_ref() {
19494 params.push("orderBy", value);
19495 }
19496 if let Some(value) = self._filter.as_ref() {
19497 params.push("filter", value);
19498 }
19499
19500 params.extend(self._additional_params.iter());
19501
19502 params.push("alt", "json");
19503 let mut url = self.hub._base_url.clone() + "v1/{+parent}/lbRouteExtensions";
19504 if self._scopes.is_empty() {
19505 self._scopes
19506 .insert(Scope::CloudPlatform.as_ref().to_string());
19507 }
19508
19509 #[allow(clippy::single_element_loop)]
19510 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
19511 url = params.uri_replacement(url, param_name, find_this, true);
19512 }
19513 {
19514 let to_remove = ["parent"];
19515 params.remove_params(&to_remove);
19516 }
19517
19518 let url = params.parse_with_url(&url);
19519
19520 loop {
19521 let token = match self
19522 .hub
19523 .auth
19524 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19525 .await
19526 {
19527 Ok(token) => token,
19528 Err(e) => match dlg.token(e) {
19529 Ok(token) => token,
19530 Err(e) => {
19531 dlg.finished(false);
19532 return Err(common::Error::MissingToken(e));
19533 }
19534 },
19535 };
19536 let mut req_result = {
19537 let client = &self.hub.client;
19538 dlg.pre_request();
19539 let mut req_builder = hyper::Request::builder()
19540 .method(hyper::Method::GET)
19541 .uri(url.as_str())
19542 .header(USER_AGENT, self.hub._user_agent.clone());
19543
19544 if let Some(token) = token.as_ref() {
19545 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19546 }
19547
19548 let request = req_builder
19549 .header(CONTENT_LENGTH, 0_u64)
19550 .body(common::to_body::<String>(None));
19551
19552 client.request(request.unwrap()).await
19553 };
19554
19555 match req_result {
19556 Err(err) => {
19557 if let common::Retry::After(d) = dlg.http_error(&err) {
19558 sleep(d).await;
19559 continue;
19560 }
19561 dlg.finished(false);
19562 return Err(common::Error::HttpError(err));
19563 }
19564 Ok(res) => {
19565 let (mut parts, body) = res.into_parts();
19566 let mut body = common::Body::new(body);
19567 if !parts.status.is_success() {
19568 let bytes = common::to_bytes(body).await.unwrap_or_default();
19569 let error = serde_json::from_str(&common::to_string(&bytes));
19570 let response = common::to_response(parts, bytes.into());
19571
19572 if let common::Retry::After(d) =
19573 dlg.http_failure(&response, error.as_ref().ok())
19574 {
19575 sleep(d).await;
19576 continue;
19577 }
19578
19579 dlg.finished(false);
19580
19581 return Err(match error {
19582 Ok(value) => common::Error::BadRequest(value),
19583 _ => common::Error::Failure(response),
19584 });
19585 }
19586 let response = {
19587 let bytes = common::to_bytes(body).await.unwrap_or_default();
19588 let encoded = common::to_string(&bytes);
19589 match serde_json::from_str(&encoded) {
19590 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19591 Err(error) => {
19592 dlg.response_json_decode_error(&encoded, &error);
19593 return Err(common::Error::JsonDecodeError(
19594 encoded.to_string(),
19595 error,
19596 ));
19597 }
19598 }
19599 };
19600
19601 dlg.finished(true);
19602 return Ok(response);
19603 }
19604 }
19605 }
19606 }
19607
19608 /// Required. The project and location from which the `LbRouteExtension` resources are listed. These values are specified in the following format: `projects/{project}/locations/{location}`.
19609 ///
19610 /// Sets the *parent* path property to the given value.
19611 ///
19612 /// Even though the property as already been set when instantiating this call,
19613 /// we provide this method for API completeness.
19614 pub fn parent(mut self, new_value: &str) -> ProjectLocationLbRouteExtensionListCall<'a, C> {
19615 self._parent = new_value.to_string();
19616 self
19617 }
19618 /// Optional. A token identifying a page of results that the server returns.
19619 ///
19620 /// Sets the *page token* query property to the given value.
19621 pub fn page_token(mut self, new_value: &str) -> ProjectLocationLbRouteExtensionListCall<'a, C> {
19622 self._page_token = Some(new_value.to_string());
19623 self
19624 }
19625 /// Optional. Requested page size. The server might return fewer items than requested. If unspecified, the server picks an appropriate default.
19626 ///
19627 /// Sets the *page size* query property to the given value.
19628 pub fn page_size(mut self, new_value: i32) -> ProjectLocationLbRouteExtensionListCall<'a, C> {
19629 self._page_size = Some(new_value);
19630 self
19631 }
19632 /// Optional. Hint about how to order the results.
19633 ///
19634 /// Sets the *order by* query property to the given value.
19635 pub fn order_by(mut self, new_value: &str) -> ProjectLocationLbRouteExtensionListCall<'a, C> {
19636 self._order_by = Some(new_value.to_string());
19637 self
19638 }
19639 /// Optional. Filtering results.
19640 ///
19641 /// Sets the *filter* query property to the given value.
19642 pub fn filter(mut self, new_value: &str) -> ProjectLocationLbRouteExtensionListCall<'a, C> {
19643 self._filter = Some(new_value.to_string());
19644 self
19645 }
19646 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19647 /// while executing the actual API request.
19648 ///
19649 /// ````text
19650 /// It should be used to handle progress information, and to implement a certain level of resilience.
19651 /// ````
19652 ///
19653 /// Sets the *delegate* property to the given value.
19654 pub fn delegate(
19655 mut self,
19656 new_value: &'a mut dyn common::Delegate,
19657 ) -> ProjectLocationLbRouteExtensionListCall<'a, C> {
19658 self._delegate = Some(new_value);
19659 self
19660 }
19661
19662 /// Set any additional parameter of the query string used in the request.
19663 /// It should be used to set parameters which are not yet available through their own
19664 /// setters.
19665 ///
19666 /// Please note that this method must not be used to set any of the known parameters
19667 /// which have their own setter method. If done anyway, the request will fail.
19668 ///
19669 /// # Additional Parameters
19670 ///
19671 /// * *$.xgafv* (query-string) - V1 error format.
19672 /// * *access_token* (query-string) - OAuth access token.
19673 /// * *alt* (query-string) - Data format for response.
19674 /// * *callback* (query-string) - JSONP
19675 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19676 /// * *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.
19677 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19678 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19679 /// * *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.
19680 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19681 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19682 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationLbRouteExtensionListCall<'a, C>
19683 where
19684 T: AsRef<str>,
19685 {
19686 self._additional_params
19687 .insert(name.as_ref().to_string(), value.as_ref().to_string());
19688 self
19689 }
19690
19691 /// Identifies the authorization scope for the method you are building.
19692 ///
19693 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19694 /// [`Scope::CloudPlatform`].
19695 ///
19696 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19697 /// tokens for more than one scope.
19698 ///
19699 /// Usually there is more than one suitable scope to authorize an operation, some of which may
19700 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19701 /// sufficient, a read-write scope will do as well.
19702 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationLbRouteExtensionListCall<'a, C>
19703 where
19704 St: AsRef<str>,
19705 {
19706 self._scopes.insert(String::from(scope.as_ref()));
19707 self
19708 }
19709 /// Identifies the authorization scope(s) for the method you are building.
19710 ///
19711 /// See [`Self::add_scope()`] for details.
19712 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationLbRouteExtensionListCall<'a, C>
19713 where
19714 I: IntoIterator<Item = St>,
19715 St: AsRef<str>,
19716 {
19717 self._scopes
19718 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19719 self
19720 }
19721
19722 /// Removes all scopes, and no default scope will be used either.
19723 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19724 /// for details).
19725 pub fn clear_scopes(mut self) -> ProjectLocationLbRouteExtensionListCall<'a, C> {
19726 self._scopes.clear();
19727 self
19728 }
19729}
19730
19731/// Updates the parameters of the specified `LbRouteExtension` resource.
19732///
19733/// A builder for the *locations.lbRouteExtensions.patch* method supported by a *project* resource.
19734/// It is not used directly, but through a [`ProjectMethods`] instance.
19735///
19736/// # Example
19737///
19738/// Instantiate a resource method builder
19739///
19740/// ```test_harness,no_run
19741/// # extern crate hyper;
19742/// # extern crate hyper_rustls;
19743/// # extern crate google_networkservices1 as networkservices1;
19744/// use networkservices1::api::LbRouteExtension;
19745/// # async fn dox() {
19746/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19747///
19748/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19749/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
19750/// # .with_native_roots()
19751/// # .unwrap()
19752/// # .https_only()
19753/// # .enable_http2()
19754/// # .build();
19755///
19756/// # let executor = hyper_util::rt::TokioExecutor::new();
19757/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
19758/// # secret,
19759/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19760/// # yup_oauth2::client::CustomHyperClientBuilder::from(
19761/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
19762/// # ),
19763/// # ).build().await.unwrap();
19764///
19765/// # let client = hyper_util::client::legacy::Client::builder(
19766/// # hyper_util::rt::TokioExecutor::new()
19767/// # )
19768/// # .build(
19769/// # hyper_rustls::HttpsConnectorBuilder::new()
19770/// # .with_native_roots()
19771/// # .unwrap()
19772/// # .https_or_http()
19773/// # .enable_http2()
19774/// # .build()
19775/// # );
19776/// # let mut hub = NetworkServices::new(client, auth);
19777/// // As the method needs a request, you would usually fill it with the desired information
19778/// // into the respective structure. Some of the parts shown here might not be applicable !
19779/// // Values shown here are possibly random and not representative !
19780/// let mut req = LbRouteExtension::default();
19781///
19782/// // You can configure optional parameters by calling the respective setters at will, and
19783/// // execute the final call using `doit()`.
19784/// // Values shown here are possibly random and not representative !
19785/// let result = hub.projects().locations_lb_route_extensions_patch(req, "name")
19786/// .update_mask(FieldMask::new::<&str>(&[]))
19787/// .request_id("no")
19788/// .doit().await;
19789/// # }
19790/// ```
19791pub struct ProjectLocationLbRouteExtensionPatchCall<'a, C>
19792where
19793 C: 'a,
19794{
19795 hub: &'a NetworkServices<C>,
19796 _request: LbRouteExtension,
19797 _name: String,
19798 _update_mask: Option<common::FieldMask>,
19799 _request_id: Option<String>,
19800 _delegate: Option<&'a mut dyn common::Delegate>,
19801 _additional_params: HashMap<String, String>,
19802 _scopes: BTreeSet<String>,
19803}
19804
19805impl<'a, C> common::CallBuilder for ProjectLocationLbRouteExtensionPatchCall<'a, C> {}
19806
19807impl<'a, C> ProjectLocationLbRouteExtensionPatchCall<'a, C>
19808where
19809 C: common::Connector,
19810{
19811 /// Perform the operation you have build so far.
19812 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
19813 use std::borrow::Cow;
19814 use std::io::{Read, Seek};
19815
19816 use common::{url::Params, ToParts};
19817 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19818
19819 let mut dd = common::DefaultDelegate;
19820 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19821 dlg.begin(common::MethodInfo {
19822 id: "networkservices.projects.locations.lbRouteExtensions.patch",
19823 http_method: hyper::Method::PATCH,
19824 });
19825
19826 for &field in ["alt", "name", "updateMask", "requestId"].iter() {
19827 if self._additional_params.contains_key(field) {
19828 dlg.finished(false);
19829 return Err(common::Error::FieldClash(field));
19830 }
19831 }
19832
19833 let mut params = Params::with_capacity(6 + self._additional_params.len());
19834 params.push("name", self._name);
19835 if let Some(value) = self._update_mask.as_ref() {
19836 params.push("updateMask", value.to_string());
19837 }
19838 if let Some(value) = self._request_id.as_ref() {
19839 params.push("requestId", value);
19840 }
19841
19842 params.extend(self._additional_params.iter());
19843
19844 params.push("alt", "json");
19845 let mut url = self.hub._base_url.clone() + "v1/{+name}";
19846 if self._scopes.is_empty() {
19847 self._scopes
19848 .insert(Scope::CloudPlatform.as_ref().to_string());
19849 }
19850
19851 #[allow(clippy::single_element_loop)]
19852 for &(find_this, param_name) in [("{+name}", "name")].iter() {
19853 url = params.uri_replacement(url, param_name, find_this, true);
19854 }
19855 {
19856 let to_remove = ["name"];
19857 params.remove_params(&to_remove);
19858 }
19859
19860 let url = params.parse_with_url(&url);
19861
19862 let mut json_mime_type = mime::APPLICATION_JSON;
19863 let mut request_value_reader = {
19864 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
19865 common::remove_json_null_values(&mut value);
19866 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
19867 serde_json::to_writer(&mut dst, &value).unwrap();
19868 dst
19869 };
19870 let request_size = request_value_reader
19871 .seek(std::io::SeekFrom::End(0))
19872 .unwrap();
19873 request_value_reader
19874 .seek(std::io::SeekFrom::Start(0))
19875 .unwrap();
19876
19877 loop {
19878 let token = match self
19879 .hub
19880 .auth
19881 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19882 .await
19883 {
19884 Ok(token) => token,
19885 Err(e) => match dlg.token(e) {
19886 Ok(token) => token,
19887 Err(e) => {
19888 dlg.finished(false);
19889 return Err(common::Error::MissingToken(e));
19890 }
19891 },
19892 };
19893 request_value_reader
19894 .seek(std::io::SeekFrom::Start(0))
19895 .unwrap();
19896 let mut req_result = {
19897 let client = &self.hub.client;
19898 dlg.pre_request();
19899 let mut req_builder = hyper::Request::builder()
19900 .method(hyper::Method::PATCH)
19901 .uri(url.as_str())
19902 .header(USER_AGENT, self.hub._user_agent.clone());
19903
19904 if let Some(token) = token.as_ref() {
19905 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19906 }
19907
19908 let request = req_builder
19909 .header(CONTENT_TYPE, json_mime_type.to_string())
19910 .header(CONTENT_LENGTH, request_size as u64)
19911 .body(common::to_body(
19912 request_value_reader.get_ref().clone().into(),
19913 ));
19914
19915 client.request(request.unwrap()).await
19916 };
19917
19918 match req_result {
19919 Err(err) => {
19920 if let common::Retry::After(d) = dlg.http_error(&err) {
19921 sleep(d).await;
19922 continue;
19923 }
19924 dlg.finished(false);
19925 return Err(common::Error::HttpError(err));
19926 }
19927 Ok(res) => {
19928 let (mut parts, body) = res.into_parts();
19929 let mut body = common::Body::new(body);
19930 if !parts.status.is_success() {
19931 let bytes = common::to_bytes(body).await.unwrap_or_default();
19932 let error = serde_json::from_str(&common::to_string(&bytes));
19933 let response = common::to_response(parts, bytes.into());
19934
19935 if let common::Retry::After(d) =
19936 dlg.http_failure(&response, error.as_ref().ok())
19937 {
19938 sleep(d).await;
19939 continue;
19940 }
19941
19942 dlg.finished(false);
19943
19944 return Err(match error {
19945 Ok(value) => common::Error::BadRequest(value),
19946 _ => common::Error::Failure(response),
19947 });
19948 }
19949 let response = {
19950 let bytes = common::to_bytes(body).await.unwrap_or_default();
19951 let encoded = common::to_string(&bytes);
19952 match serde_json::from_str(&encoded) {
19953 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19954 Err(error) => {
19955 dlg.response_json_decode_error(&encoded, &error);
19956 return Err(common::Error::JsonDecodeError(
19957 encoded.to_string(),
19958 error,
19959 ));
19960 }
19961 }
19962 };
19963
19964 dlg.finished(true);
19965 return Ok(response);
19966 }
19967 }
19968 }
19969 }
19970
19971 ///
19972 /// Sets the *request* property to the given value.
19973 ///
19974 /// Even though the property as already been set when instantiating this call,
19975 /// we provide this method for API completeness.
19976 pub fn request(
19977 mut self,
19978 new_value: LbRouteExtension,
19979 ) -> ProjectLocationLbRouteExtensionPatchCall<'a, C> {
19980 self._request = new_value;
19981 self
19982 }
19983 /// Required. Identifier. Name of the `LbRouteExtension` resource in the following format: `projects/{project}/locations/{location}/lbRouteExtensions/{lb_route_extension}`.
19984 ///
19985 /// Sets the *name* path property to the given value.
19986 ///
19987 /// Even though the property as already been set when instantiating this call,
19988 /// we provide this method for API completeness.
19989 pub fn name(mut self, new_value: &str) -> ProjectLocationLbRouteExtensionPatchCall<'a, C> {
19990 self._name = new_value.to_string();
19991 self
19992 }
19993 /// Optional. Used to specify the fields to be overwritten in the `LbRouteExtension` resource by the update. The fields specified in the `update_mask` are relative to the resource, not the full request. A field is overwritten if it is in the mask. If the user does not specify a mask, then all fields are overwritten.
19994 ///
19995 /// Sets the *update mask* query property to the given value.
19996 pub fn update_mask(
19997 mut self,
19998 new_value: common::FieldMask,
19999 ) -> ProjectLocationLbRouteExtensionPatchCall<'a, C> {
20000 self._update_mask = Some(new_value);
20001 self
20002 }
20003 /// Optional. An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server can ignore the request if it has already been completed. The server guarantees that for 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 ignores 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).
20004 ///
20005 /// Sets the *request id* query property to the given value.
20006 pub fn request_id(
20007 mut self,
20008 new_value: &str,
20009 ) -> ProjectLocationLbRouteExtensionPatchCall<'a, C> {
20010 self._request_id = Some(new_value.to_string());
20011 self
20012 }
20013 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20014 /// while executing the actual API request.
20015 ///
20016 /// ````text
20017 /// It should be used to handle progress information, and to implement a certain level of resilience.
20018 /// ````
20019 ///
20020 /// Sets the *delegate* property to the given value.
20021 pub fn delegate(
20022 mut self,
20023 new_value: &'a mut dyn common::Delegate,
20024 ) -> ProjectLocationLbRouteExtensionPatchCall<'a, C> {
20025 self._delegate = Some(new_value);
20026 self
20027 }
20028
20029 /// Set any additional parameter of the query string used in the request.
20030 /// It should be used to set parameters which are not yet available through their own
20031 /// setters.
20032 ///
20033 /// Please note that this method must not be used to set any of the known parameters
20034 /// which have their own setter method. If done anyway, the request will fail.
20035 ///
20036 /// # Additional Parameters
20037 ///
20038 /// * *$.xgafv* (query-string) - V1 error format.
20039 /// * *access_token* (query-string) - OAuth access token.
20040 /// * *alt* (query-string) - Data format for response.
20041 /// * *callback* (query-string) - JSONP
20042 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20043 /// * *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.
20044 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20045 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20046 /// * *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.
20047 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20048 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20049 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationLbRouteExtensionPatchCall<'a, C>
20050 where
20051 T: AsRef<str>,
20052 {
20053 self._additional_params
20054 .insert(name.as_ref().to_string(), value.as_ref().to_string());
20055 self
20056 }
20057
20058 /// Identifies the authorization scope for the method you are building.
20059 ///
20060 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20061 /// [`Scope::CloudPlatform`].
20062 ///
20063 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20064 /// tokens for more than one scope.
20065 ///
20066 /// Usually there is more than one suitable scope to authorize an operation, some of which may
20067 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20068 /// sufficient, a read-write scope will do as well.
20069 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationLbRouteExtensionPatchCall<'a, C>
20070 where
20071 St: AsRef<str>,
20072 {
20073 self._scopes.insert(String::from(scope.as_ref()));
20074 self
20075 }
20076 /// Identifies the authorization scope(s) for the method you are building.
20077 ///
20078 /// See [`Self::add_scope()`] for details.
20079 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationLbRouteExtensionPatchCall<'a, C>
20080 where
20081 I: IntoIterator<Item = St>,
20082 St: AsRef<str>,
20083 {
20084 self._scopes
20085 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20086 self
20087 }
20088
20089 /// Removes all scopes, and no default scope will be used either.
20090 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20091 /// for details).
20092 pub fn clear_scopes(mut self) -> ProjectLocationLbRouteExtensionPatchCall<'a, C> {
20093 self._scopes.clear();
20094 self
20095 }
20096}
20097
20098/// Creates a new `LbTrafficExtension` resource in a given project and location.
20099///
20100/// A builder for the *locations.lbTrafficExtensions.create* method supported by a *project* resource.
20101/// It is not used directly, but through a [`ProjectMethods`] instance.
20102///
20103/// # Example
20104///
20105/// Instantiate a resource method builder
20106///
20107/// ```test_harness,no_run
20108/// # extern crate hyper;
20109/// # extern crate hyper_rustls;
20110/// # extern crate google_networkservices1 as networkservices1;
20111/// use networkservices1::api::LbTrafficExtension;
20112/// # async fn dox() {
20113/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20114///
20115/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20116/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20117/// # .with_native_roots()
20118/// # .unwrap()
20119/// # .https_only()
20120/// # .enable_http2()
20121/// # .build();
20122///
20123/// # let executor = hyper_util::rt::TokioExecutor::new();
20124/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
20125/// # secret,
20126/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20127/// # yup_oauth2::client::CustomHyperClientBuilder::from(
20128/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
20129/// # ),
20130/// # ).build().await.unwrap();
20131///
20132/// # let client = hyper_util::client::legacy::Client::builder(
20133/// # hyper_util::rt::TokioExecutor::new()
20134/// # )
20135/// # .build(
20136/// # hyper_rustls::HttpsConnectorBuilder::new()
20137/// # .with_native_roots()
20138/// # .unwrap()
20139/// # .https_or_http()
20140/// # .enable_http2()
20141/// # .build()
20142/// # );
20143/// # let mut hub = NetworkServices::new(client, auth);
20144/// // As the method needs a request, you would usually fill it with the desired information
20145/// // into the respective structure. Some of the parts shown here might not be applicable !
20146/// // Values shown here are possibly random and not representative !
20147/// let mut req = LbTrafficExtension::default();
20148///
20149/// // You can configure optional parameters by calling the respective setters at will, and
20150/// // execute the final call using `doit()`.
20151/// // Values shown here are possibly random and not representative !
20152/// let result = hub.projects().locations_lb_traffic_extensions_create(req, "parent")
20153/// .request_id("At")
20154/// .lb_traffic_extension_id("sed")
20155/// .doit().await;
20156/// # }
20157/// ```
20158pub struct ProjectLocationLbTrafficExtensionCreateCall<'a, C>
20159where
20160 C: 'a,
20161{
20162 hub: &'a NetworkServices<C>,
20163 _request: LbTrafficExtension,
20164 _parent: String,
20165 _request_id: Option<String>,
20166 _lb_traffic_extension_id: Option<String>,
20167 _delegate: Option<&'a mut dyn common::Delegate>,
20168 _additional_params: HashMap<String, String>,
20169 _scopes: BTreeSet<String>,
20170}
20171
20172impl<'a, C> common::CallBuilder for ProjectLocationLbTrafficExtensionCreateCall<'a, C> {}
20173
20174impl<'a, C> ProjectLocationLbTrafficExtensionCreateCall<'a, C>
20175where
20176 C: common::Connector,
20177{
20178 /// Perform the operation you have build so far.
20179 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
20180 use std::borrow::Cow;
20181 use std::io::{Read, Seek};
20182
20183 use common::{url::Params, ToParts};
20184 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20185
20186 let mut dd = common::DefaultDelegate;
20187 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20188 dlg.begin(common::MethodInfo {
20189 id: "networkservices.projects.locations.lbTrafficExtensions.create",
20190 http_method: hyper::Method::POST,
20191 });
20192
20193 for &field in ["alt", "parent", "requestId", "lbTrafficExtensionId"].iter() {
20194 if self._additional_params.contains_key(field) {
20195 dlg.finished(false);
20196 return Err(common::Error::FieldClash(field));
20197 }
20198 }
20199
20200 let mut params = Params::with_capacity(6 + self._additional_params.len());
20201 params.push("parent", self._parent);
20202 if let Some(value) = self._request_id.as_ref() {
20203 params.push("requestId", value);
20204 }
20205 if let Some(value) = self._lb_traffic_extension_id.as_ref() {
20206 params.push("lbTrafficExtensionId", value);
20207 }
20208
20209 params.extend(self._additional_params.iter());
20210
20211 params.push("alt", "json");
20212 let mut url = self.hub._base_url.clone() + "v1/{+parent}/lbTrafficExtensions";
20213 if self._scopes.is_empty() {
20214 self._scopes
20215 .insert(Scope::CloudPlatform.as_ref().to_string());
20216 }
20217
20218 #[allow(clippy::single_element_loop)]
20219 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
20220 url = params.uri_replacement(url, param_name, find_this, true);
20221 }
20222 {
20223 let to_remove = ["parent"];
20224 params.remove_params(&to_remove);
20225 }
20226
20227 let url = params.parse_with_url(&url);
20228
20229 let mut json_mime_type = mime::APPLICATION_JSON;
20230 let mut request_value_reader = {
20231 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
20232 common::remove_json_null_values(&mut value);
20233 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
20234 serde_json::to_writer(&mut dst, &value).unwrap();
20235 dst
20236 };
20237 let request_size = request_value_reader
20238 .seek(std::io::SeekFrom::End(0))
20239 .unwrap();
20240 request_value_reader
20241 .seek(std::io::SeekFrom::Start(0))
20242 .unwrap();
20243
20244 loop {
20245 let token = match self
20246 .hub
20247 .auth
20248 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20249 .await
20250 {
20251 Ok(token) => token,
20252 Err(e) => match dlg.token(e) {
20253 Ok(token) => token,
20254 Err(e) => {
20255 dlg.finished(false);
20256 return Err(common::Error::MissingToken(e));
20257 }
20258 },
20259 };
20260 request_value_reader
20261 .seek(std::io::SeekFrom::Start(0))
20262 .unwrap();
20263 let mut req_result = {
20264 let client = &self.hub.client;
20265 dlg.pre_request();
20266 let mut req_builder = hyper::Request::builder()
20267 .method(hyper::Method::POST)
20268 .uri(url.as_str())
20269 .header(USER_AGENT, self.hub._user_agent.clone());
20270
20271 if let Some(token) = token.as_ref() {
20272 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20273 }
20274
20275 let request = req_builder
20276 .header(CONTENT_TYPE, json_mime_type.to_string())
20277 .header(CONTENT_LENGTH, request_size as u64)
20278 .body(common::to_body(
20279 request_value_reader.get_ref().clone().into(),
20280 ));
20281
20282 client.request(request.unwrap()).await
20283 };
20284
20285 match req_result {
20286 Err(err) => {
20287 if let common::Retry::After(d) = dlg.http_error(&err) {
20288 sleep(d).await;
20289 continue;
20290 }
20291 dlg.finished(false);
20292 return Err(common::Error::HttpError(err));
20293 }
20294 Ok(res) => {
20295 let (mut parts, body) = res.into_parts();
20296 let mut body = common::Body::new(body);
20297 if !parts.status.is_success() {
20298 let bytes = common::to_bytes(body).await.unwrap_or_default();
20299 let error = serde_json::from_str(&common::to_string(&bytes));
20300 let response = common::to_response(parts, bytes.into());
20301
20302 if let common::Retry::After(d) =
20303 dlg.http_failure(&response, error.as_ref().ok())
20304 {
20305 sleep(d).await;
20306 continue;
20307 }
20308
20309 dlg.finished(false);
20310
20311 return Err(match error {
20312 Ok(value) => common::Error::BadRequest(value),
20313 _ => common::Error::Failure(response),
20314 });
20315 }
20316 let response = {
20317 let bytes = common::to_bytes(body).await.unwrap_or_default();
20318 let encoded = common::to_string(&bytes);
20319 match serde_json::from_str(&encoded) {
20320 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20321 Err(error) => {
20322 dlg.response_json_decode_error(&encoded, &error);
20323 return Err(common::Error::JsonDecodeError(
20324 encoded.to_string(),
20325 error,
20326 ));
20327 }
20328 }
20329 };
20330
20331 dlg.finished(true);
20332 return Ok(response);
20333 }
20334 }
20335 }
20336 }
20337
20338 ///
20339 /// Sets the *request* property to the given value.
20340 ///
20341 /// Even though the property as already been set when instantiating this call,
20342 /// we provide this method for API completeness.
20343 pub fn request(
20344 mut self,
20345 new_value: LbTrafficExtension,
20346 ) -> ProjectLocationLbTrafficExtensionCreateCall<'a, C> {
20347 self._request = new_value;
20348 self
20349 }
20350 /// Required. The parent resource of the `LbTrafficExtension` resource. Must be in the format `projects/{project}/locations/{location}`.
20351 ///
20352 /// Sets the *parent* path property to the given value.
20353 ///
20354 /// Even though the property as already been set when instantiating this call,
20355 /// we provide this method for API completeness.
20356 pub fn parent(mut self, new_value: &str) -> ProjectLocationLbTrafficExtensionCreateCall<'a, C> {
20357 self._parent = new_value.to_string();
20358 self
20359 }
20360 /// Optional. An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server can ignore the request if it has already been completed. The server guarantees that for 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 ignores 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).
20361 ///
20362 /// Sets the *request id* query property to the given value.
20363 pub fn request_id(
20364 mut self,
20365 new_value: &str,
20366 ) -> ProjectLocationLbTrafficExtensionCreateCall<'a, C> {
20367 self._request_id = Some(new_value.to_string());
20368 self
20369 }
20370 /// Required. User-provided ID of the `LbTrafficExtension` resource to be created.
20371 ///
20372 /// Sets the *lb traffic extension id* query property to the given value.
20373 pub fn lb_traffic_extension_id(
20374 mut self,
20375 new_value: &str,
20376 ) -> ProjectLocationLbTrafficExtensionCreateCall<'a, C> {
20377 self._lb_traffic_extension_id = Some(new_value.to_string());
20378 self
20379 }
20380 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20381 /// while executing the actual API request.
20382 ///
20383 /// ````text
20384 /// It should be used to handle progress information, and to implement a certain level of resilience.
20385 /// ````
20386 ///
20387 /// Sets the *delegate* property to the given value.
20388 pub fn delegate(
20389 mut self,
20390 new_value: &'a mut dyn common::Delegate,
20391 ) -> ProjectLocationLbTrafficExtensionCreateCall<'a, C> {
20392 self._delegate = Some(new_value);
20393 self
20394 }
20395
20396 /// Set any additional parameter of the query string used in the request.
20397 /// It should be used to set parameters which are not yet available through their own
20398 /// setters.
20399 ///
20400 /// Please note that this method must not be used to set any of the known parameters
20401 /// which have their own setter method. If done anyway, the request will fail.
20402 ///
20403 /// # Additional Parameters
20404 ///
20405 /// * *$.xgafv* (query-string) - V1 error format.
20406 /// * *access_token* (query-string) - OAuth access token.
20407 /// * *alt* (query-string) - Data format for response.
20408 /// * *callback* (query-string) - JSONP
20409 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20410 /// * *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.
20411 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20412 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20413 /// * *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.
20414 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20415 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20416 pub fn param<T>(
20417 mut self,
20418 name: T,
20419 value: T,
20420 ) -> ProjectLocationLbTrafficExtensionCreateCall<'a, C>
20421 where
20422 T: AsRef<str>,
20423 {
20424 self._additional_params
20425 .insert(name.as_ref().to_string(), value.as_ref().to_string());
20426 self
20427 }
20428
20429 /// Identifies the authorization scope for the method you are building.
20430 ///
20431 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20432 /// [`Scope::CloudPlatform`].
20433 ///
20434 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20435 /// tokens for more than one scope.
20436 ///
20437 /// Usually there is more than one suitable scope to authorize an operation, some of which may
20438 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20439 /// sufficient, a read-write scope will do as well.
20440 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationLbTrafficExtensionCreateCall<'a, C>
20441 where
20442 St: AsRef<str>,
20443 {
20444 self._scopes.insert(String::from(scope.as_ref()));
20445 self
20446 }
20447 /// Identifies the authorization scope(s) for the method you are building.
20448 ///
20449 /// See [`Self::add_scope()`] for details.
20450 pub fn add_scopes<I, St>(
20451 mut self,
20452 scopes: I,
20453 ) -> ProjectLocationLbTrafficExtensionCreateCall<'a, C>
20454 where
20455 I: IntoIterator<Item = St>,
20456 St: AsRef<str>,
20457 {
20458 self._scopes
20459 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20460 self
20461 }
20462
20463 /// Removes all scopes, and no default scope will be used either.
20464 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20465 /// for details).
20466 pub fn clear_scopes(mut self) -> ProjectLocationLbTrafficExtensionCreateCall<'a, C> {
20467 self._scopes.clear();
20468 self
20469 }
20470}
20471
20472/// Deletes the specified `LbTrafficExtension` resource.
20473///
20474/// A builder for the *locations.lbTrafficExtensions.delete* method supported by a *project* resource.
20475/// It is not used directly, but through a [`ProjectMethods`] instance.
20476///
20477/// # Example
20478///
20479/// Instantiate a resource method builder
20480///
20481/// ```test_harness,no_run
20482/// # extern crate hyper;
20483/// # extern crate hyper_rustls;
20484/// # extern crate google_networkservices1 as networkservices1;
20485/// # async fn dox() {
20486/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20487///
20488/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20489/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20490/// # .with_native_roots()
20491/// # .unwrap()
20492/// # .https_only()
20493/// # .enable_http2()
20494/// # .build();
20495///
20496/// # let executor = hyper_util::rt::TokioExecutor::new();
20497/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
20498/// # secret,
20499/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20500/// # yup_oauth2::client::CustomHyperClientBuilder::from(
20501/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
20502/// # ),
20503/// # ).build().await.unwrap();
20504///
20505/// # let client = hyper_util::client::legacy::Client::builder(
20506/// # hyper_util::rt::TokioExecutor::new()
20507/// # )
20508/// # .build(
20509/// # hyper_rustls::HttpsConnectorBuilder::new()
20510/// # .with_native_roots()
20511/// # .unwrap()
20512/// # .https_or_http()
20513/// # .enable_http2()
20514/// # .build()
20515/// # );
20516/// # let mut hub = NetworkServices::new(client, auth);
20517/// // You can configure optional parameters by calling the respective setters at will, and
20518/// // execute the final call using `doit()`.
20519/// // Values shown here are possibly random and not representative !
20520/// let result = hub.projects().locations_lb_traffic_extensions_delete("name")
20521/// .request_id("et")
20522/// .doit().await;
20523/// # }
20524/// ```
20525pub struct ProjectLocationLbTrafficExtensionDeleteCall<'a, C>
20526where
20527 C: 'a,
20528{
20529 hub: &'a NetworkServices<C>,
20530 _name: String,
20531 _request_id: Option<String>,
20532 _delegate: Option<&'a mut dyn common::Delegate>,
20533 _additional_params: HashMap<String, String>,
20534 _scopes: BTreeSet<String>,
20535}
20536
20537impl<'a, C> common::CallBuilder for ProjectLocationLbTrafficExtensionDeleteCall<'a, C> {}
20538
20539impl<'a, C> ProjectLocationLbTrafficExtensionDeleteCall<'a, C>
20540where
20541 C: common::Connector,
20542{
20543 /// Perform the operation you have build so far.
20544 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
20545 use std::borrow::Cow;
20546 use std::io::{Read, Seek};
20547
20548 use common::{url::Params, ToParts};
20549 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20550
20551 let mut dd = common::DefaultDelegate;
20552 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20553 dlg.begin(common::MethodInfo {
20554 id: "networkservices.projects.locations.lbTrafficExtensions.delete",
20555 http_method: hyper::Method::DELETE,
20556 });
20557
20558 for &field in ["alt", "name", "requestId"].iter() {
20559 if self._additional_params.contains_key(field) {
20560 dlg.finished(false);
20561 return Err(common::Error::FieldClash(field));
20562 }
20563 }
20564
20565 let mut params = Params::with_capacity(4 + self._additional_params.len());
20566 params.push("name", self._name);
20567 if let Some(value) = self._request_id.as_ref() {
20568 params.push("requestId", value);
20569 }
20570
20571 params.extend(self._additional_params.iter());
20572
20573 params.push("alt", "json");
20574 let mut url = self.hub._base_url.clone() + "v1/{+name}";
20575 if self._scopes.is_empty() {
20576 self._scopes
20577 .insert(Scope::CloudPlatform.as_ref().to_string());
20578 }
20579
20580 #[allow(clippy::single_element_loop)]
20581 for &(find_this, param_name) in [("{+name}", "name")].iter() {
20582 url = params.uri_replacement(url, param_name, find_this, true);
20583 }
20584 {
20585 let to_remove = ["name"];
20586 params.remove_params(&to_remove);
20587 }
20588
20589 let url = params.parse_with_url(&url);
20590
20591 loop {
20592 let token = match self
20593 .hub
20594 .auth
20595 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20596 .await
20597 {
20598 Ok(token) => token,
20599 Err(e) => match dlg.token(e) {
20600 Ok(token) => token,
20601 Err(e) => {
20602 dlg.finished(false);
20603 return Err(common::Error::MissingToken(e));
20604 }
20605 },
20606 };
20607 let mut req_result = {
20608 let client = &self.hub.client;
20609 dlg.pre_request();
20610 let mut req_builder = hyper::Request::builder()
20611 .method(hyper::Method::DELETE)
20612 .uri(url.as_str())
20613 .header(USER_AGENT, self.hub._user_agent.clone());
20614
20615 if let Some(token) = token.as_ref() {
20616 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20617 }
20618
20619 let request = req_builder
20620 .header(CONTENT_LENGTH, 0_u64)
20621 .body(common::to_body::<String>(None));
20622
20623 client.request(request.unwrap()).await
20624 };
20625
20626 match req_result {
20627 Err(err) => {
20628 if let common::Retry::After(d) = dlg.http_error(&err) {
20629 sleep(d).await;
20630 continue;
20631 }
20632 dlg.finished(false);
20633 return Err(common::Error::HttpError(err));
20634 }
20635 Ok(res) => {
20636 let (mut parts, body) = res.into_parts();
20637 let mut body = common::Body::new(body);
20638 if !parts.status.is_success() {
20639 let bytes = common::to_bytes(body).await.unwrap_or_default();
20640 let error = serde_json::from_str(&common::to_string(&bytes));
20641 let response = common::to_response(parts, bytes.into());
20642
20643 if let common::Retry::After(d) =
20644 dlg.http_failure(&response, error.as_ref().ok())
20645 {
20646 sleep(d).await;
20647 continue;
20648 }
20649
20650 dlg.finished(false);
20651
20652 return Err(match error {
20653 Ok(value) => common::Error::BadRequest(value),
20654 _ => common::Error::Failure(response),
20655 });
20656 }
20657 let response = {
20658 let bytes = common::to_bytes(body).await.unwrap_or_default();
20659 let encoded = common::to_string(&bytes);
20660 match serde_json::from_str(&encoded) {
20661 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20662 Err(error) => {
20663 dlg.response_json_decode_error(&encoded, &error);
20664 return Err(common::Error::JsonDecodeError(
20665 encoded.to_string(),
20666 error,
20667 ));
20668 }
20669 }
20670 };
20671
20672 dlg.finished(true);
20673 return Ok(response);
20674 }
20675 }
20676 }
20677 }
20678
20679 /// Required. The name of the `LbTrafficExtension` resource to delete. Must be in the format `projects/{project}/locations/{location}/lbTrafficExtensions/{lb_traffic_extension}`.
20680 ///
20681 /// Sets the *name* path property to the given value.
20682 ///
20683 /// Even though the property as already been set when instantiating this call,
20684 /// we provide this method for API completeness.
20685 pub fn name(mut self, new_value: &str) -> ProjectLocationLbTrafficExtensionDeleteCall<'a, C> {
20686 self._name = new_value.to_string();
20687 self
20688 }
20689 /// Optional. An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server can ignore the request if it has already been completed. The server guarantees that for 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 ignores 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).
20690 ///
20691 /// Sets the *request id* query property to the given value.
20692 pub fn request_id(
20693 mut self,
20694 new_value: &str,
20695 ) -> ProjectLocationLbTrafficExtensionDeleteCall<'a, C> {
20696 self._request_id = Some(new_value.to_string());
20697 self
20698 }
20699 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20700 /// while executing the actual API request.
20701 ///
20702 /// ````text
20703 /// It should be used to handle progress information, and to implement a certain level of resilience.
20704 /// ````
20705 ///
20706 /// Sets the *delegate* property to the given value.
20707 pub fn delegate(
20708 mut self,
20709 new_value: &'a mut dyn common::Delegate,
20710 ) -> ProjectLocationLbTrafficExtensionDeleteCall<'a, C> {
20711 self._delegate = Some(new_value);
20712 self
20713 }
20714
20715 /// Set any additional parameter of the query string used in the request.
20716 /// It should be used to set parameters which are not yet available through their own
20717 /// setters.
20718 ///
20719 /// Please note that this method must not be used to set any of the known parameters
20720 /// which have their own setter method. If done anyway, the request will fail.
20721 ///
20722 /// # Additional Parameters
20723 ///
20724 /// * *$.xgafv* (query-string) - V1 error format.
20725 /// * *access_token* (query-string) - OAuth access token.
20726 /// * *alt* (query-string) - Data format for response.
20727 /// * *callback* (query-string) - JSONP
20728 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20729 /// * *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.
20730 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20731 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20732 /// * *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.
20733 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20734 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20735 pub fn param<T>(
20736 mut self,
20737 name: T,
20738 value: T,
20739 ) -> ProjectLocationLbTrafficExtensionDeleteCall<'a, C>
20740 where
20741 T: AsRef<str>,
20742 {
20743 self._additional_params
20744 .insert(name.as_ref().to_string(), value.as_ref().to_string());
20745 self
20746 }
20747
20748 /// Identifies the authorization scope for the method you are building.
20749 ///
20750 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20751 /// [`Scope::CloudPlatform`].
20752 ///
20753 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20754 /// tokens for more than one scope.
20755 ///
20756 /// Usually there is more than one suitable scope to authorize an operation, some of which may
20757 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20758 /// sufficient, a read-write scope will do as well.
20759 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationLbTrafficExtensionDeleteCall<'a, C>
20760 where
20761 St: AsRef<str>,
20762 {
20763 self._scopes.insert(String::from(scope.as_ref()));
20764 self
20765 }
20766 /// Identifies the authorization scope(s) for the method you are building.
20767 ///
20768 /// See [`Self::add_scope()`] for details.
20769 pub fn add_scopes<I, St>(
20770 mut self,
20771 scopes: I,
20772 ) -> ProjectLocationLbTrafficExtensionDeleteCall<'a, C>
20773 where
20774 I: IntoIterator<Item = St>,
20775 St: AsRef<str>,
20776 {
20777 self._scopes
20778 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20779 self
20780 }
20781
20782 /// Removes all scopes, and no default scope will be used either.
20783 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20784 /// for details).
20785 pub fn clear_scopes(mut self) -> ProjectLocationLbTrafficExtensionDeleteCall<'a, C> {
20786 self._scopes.clear();
20787 self
20788 }
20789}
20790
20791/// Gets details of the specified `LbTrafficExtension` resource.
20792///
20793/// A builder for the *locations.lbTrafficExtensions.get* method supported by a *project* resource.
20794/// It is not used directly, but through a [`ProjectMethods`] instance.
20795///
20796/// # Example
20797///
20798/// Instantiate a resource method builder
20799///
20800/// ```test_harness,no_run
20801/// # extern crate hyper;
20802/// # extern crate hyper_rustls;
20803/// # extern crate google_networkservices1 as networkservices1;
20804/// # async fn dox() {
20805/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20806///
20807/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20808/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20809/// # .with_native_roots()
20810/// # .unwrap()
20811/// # .https_only()
20812/// # .enable_http2()
20813/// # .build();
20814///
20815/// # let executor = hyper_util::rt::TokioExecutor::new();
20816/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
20817/// # secret,
20818/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20819/// # yup_oauth2::client::CustomHyperClientBuilder::from(
20820/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
20821/// # ),
20822/// # ).build().await.unwrap();
20823///
20824/// # let client = hyper_util::client::legacy::Client::builder(
20825/// # hyper_util::rt::TokioExecutor::new()
20826/// # )
20827/// # .build(
20828/// # hyper_rustls::HttpsConnectorBuilder::new()
20829/// # .with_native_roots()
20830/// # .unwrap()
20831/// # .https_or_http()
20832/// # .enable_http2()
20833/// # .build()
20834/// # );
20835/// # let mut hub = NetworkServices::new(client, auth);
20836/// // You can configure optional parameters by calling the respective setters at will, and
20837/// // execute the final call using `doit()`.
20838/// // Values shown here are possibly random and not representative !
20839/// let result = hub.projects().locations_lb_traffic_extensions_get("name")
20840/// .doit().await;
20841/// # }
20842/// ```
20843pub struct ProjectLocationLbTrafficExtensionGetCall<'a, C>
20844where
20845 C: 'a,
20846{
20847 hub: &'a NetworkServices<C>,
20848 _name: String,
20849 _delegate: Option<&'a mut dyn common::Delegate>,
20850 _additional_params: HashMap<String, String>,
20851 _scopes: BTreeSet<String>,
20852}
20853
20854impl<'a, C> common::CallBuilder for ProjectLocationLbTrafficExtensionGetCall<'a, C> {}
20855
20856impl<'a, C> ProjectLocationLbTrafficExtensionGetCall<'a, C>
20857where
20858 C: common::Connector,
20859{
20860 /// Perform the operation you have build so far.
20861 pub async fn doit(mut self) -> common::Result<(common::Response, LbTrafficExtension)> {
20862 use std::borrow::Cow;
20863 use std::io::{Read, Seek};
20864
20865 use common::{url::Params, ToParts};
20866 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20867
20868 let mut dd = common::DefaultDelegate;
20869 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20870 dlg.begin(common::MethodInfo {
20871 id: "networkservices.projects.locations.lbTrafficExtensions.get",
20872 http_method: hyper::Method::GET,
20873 });
20874
20875 for &field in ["alt", "name"].iter() {
20876 if self._additional_params.contains_key(field) {
20877 dlg.finished(false);
20878 return Err(common::Error::FieldClash(field));
20879 }
20880 }
20881
20882 let mut params = Params::with_capacity(3 + self._additional_params.len());
20883 params.push("name", self._name);
20884
20885 params.extend(self._additional_params.iter());
20886
20887 params.push("alt", "json");
20888 let mut url = self.hub._base_url.clone() + "v1/{+name}";
20889 if self._scopes.is_empty() {
20890 self._scopes
20891 .insert(Scope::CloudPlatform.as_ref().to_string());
20892 }
20893
20894 #[allow(clippy::single_element_loop)]
20895 for &(find_this, param_name) in [("{+name}", "name")].iter() {
20896 url = params.uri_replacement(url, param_name, find_this, true);
20897 }
20898 {
20899 let to_remove = ["name"];
20900 params.remove_params(&to_remove);
20901 }
20902
20903 let url = params.parse_with_url(&url);
20904
20905 loop {
20906 let token = match self
20907 .hub
20908 .auth
20909 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20910 .await
20911 {
20912 Ok(token) => token,
20913 Err(e) => match dlg.token(e) {
20914 Ok(token) => token,
20915 Err(e) => {
20916 dlg.finished(false);
20917 return Err(common::Error::MissingToken(e));
20918 }
20919 },
20920 };
20921 let mut req_result = {
20922 let client = &self.hub.client;
20923 dlg.pre_request();
20924 let mut req_builder = hyper::Request::builder()
20925 .method(hyper::Method::GET)
20926 .uri(url.as_str())
20927 .header(USER_AGENT, self.hub._user_agent.clone());
20928
20929 if let Some(token) = token.as_ref() {
20930 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20931 }
20932
20933 let request = req_builder
20934 .header(CONTENT_LENGTH, 0_u64)
20935 .body(common::to_body::<String>(None));
20936
20937 client.request(request.unwrap()).await
20938 };
20939
20940 match req_result {
20941 Err(err) => {
20942 if let common::Retry::After(d) = dlg.http_error(&err) {
20943 sleep(d).await;
20944 continue;
20945 }
20946 dlg.finished(false);
20947 return Err(common::Error::HttpError(err));
20948 }
20949 Ok(res) => {
20950 let (mut parts, body) = res.into_parts();
20951 let mut body = common::Body::new(body);
20952 if !parts.status.is_success() {
20953 let bytes = common::to_bytes(body).await.unwrap_or_default();
20954 let error = serde_json::from_str(&common::to_string(&bytes));
20955 let response = common::to_response(parts, bytes.into());
20956
20957 if let common::Retry::After(d) =
20958 dlg.http_failure(&response, error.as_ref().ok())
20959 {
20960 sleep(d).await;
20961 continue;
20962 }
20963
20964 dlg.finished(false);
20965
20966 return Err(match error {
20967 Ok(value) => common::Error::BadRequest(value),
20968 _ => common::Error::Failure(response),
20969 });
20970 }
20971 let response = {
20972 let bytes = common::to_bytes(body).await.unwrap_or_default();
20973 let encoded = common::to_string(&bytes);
20974 match serde_json::from_str(&encoded) {
20975 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20976 Err(error) => {
20977 dlg.response_json_decode_error(&encoded, &error);
20978 return Err(common::Error::JsonDecodeError(
20979 encoded.to_string(),
20980 error,
20981 ));
20982 }
20983 }
20984 };
20985
20986 dlg.finished(true);
20987 return Ok(response);
20988 }
20989 }
20990 }
20991 }
20992
20993 /// Required. A name of the `LbTrafficExtension` resource to get. Must be in the format `projects/{project}/locations/{location}/lbTrafficExtensions/{lb_traffic_extension}`.
20994 ///
20995 /// Sets the *name* path property to the given value.
20996 ///
20997 /// Even though the property as already been set when instantiating this call,
20998 /// we provide this method for API completeness.
20999 pub fn name(mut self, new_value: &str) -> ProjectLocationLbTrafficExtensionGetCall<'a, C> {
21000 self._name = new_value.to_string();
21001 self
21002 }
21003 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21004 /// while executing the actual API request.
21005 ///
21006 /// ````text
21007 /// It should be used to handle progress information, and to implement a certain level of resilience.
21008 /// ````
21009 ///
21010 /// Sets the *delegate* property to the given value.
21011 pub fn delegate(
21012 mut self,
21013 new_value: &'a mut dyn common::Delegate,
21014 ) -> ProjectLocationLbTrafficExtensionGetCall<'a, C> {
21015 self._delegate = Some(new_value);
21016 self
21017 }
21018
21019 /// Set any additional parameter of the query string used in the request.
21020 /// It should be used to set parameters which are not yet available through their own
21021 /// setters.
21022 ///
21023 /// Please note that this method must not be used to set any of the known parameters
21024 /// which have their own setter method. If done anyway, the request will fail.
21025 ///
21026 /// # Additional Parameters
21027 ///
21028 /// * *$.xgafv* (query-string) - V1 error format.
21029 /// * *access_token* (query-string) - OAuth access token.
21030 /// * *alt* (query-string) - Data format for response.
21031 /// * *callback* (query-string) - JSONP
21032 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21033 /// * *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.
21034 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21035 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21036 /// * *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.
21037 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21038 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21039 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationLbTrafficExtensionGetCall<'a, C>
21040 where
21041 T: AsRef<str>,
21042 {
21043 self._additional_params
21044 .insert(name.as_ref().to_string(), value.as_ref().to_string());
21045 self
21046 }
21047
21048 /// Identifies the authorization scope for the method you are building.
21049 ///
21050 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21051 /// [`Scope::CloudPlatform`].
21052 ///
21053 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21054 /// tokens for more than one scope.
21055 ///
21056 /// Usually there is more than one suitable scope to authorize an operation, some of which may
21057 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21058 /// sufficient, a read-write scope will do as well.
21059 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationLbTrafficExtensionGetCall<'a, C>
21060 where
21061 St: AsRef<str>,
21062 {
21063 self._scopes.insert(String::from(scope.as_ref()));
21064 self
21065 }
21066 /// Identifies the authorization scope(s) for the method you are building.
21067 ///
21068 /// See [`Self::add_scope()`] for details.
21069 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationLbTrafficExtensionGetCall<'a, C>
21070 where
21071 I: IntoIterator<Item = St>,
21072 St: AsRef<str>,
21073 {
21074 self._scopes
21075 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21076 self
21077 }
21078
21079 /// Removes all scopes, and no default scope will be used either.
21080 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21081 /// for details).
21082 pub fn clear_scopes(mut self) -> ProjectLocationLbTrafficExtensionGetCall<'a, C> {
21083 self._scopes.clear();
21084 self
21085 }
21086}
21087
21088/// Lists `LbTrafficExtension` resources in a given project and location.
21089///
21090/// A builder for the *locations.lbTrafficExtensions.list* method supported by a *project* resource.
21091/// It is not used directly, but through a [`ProjectMethods`] instance.
21092///
21093/// # Example
21094///
21095/// Instantiate a resource method builder
21096///
21097/// ```test_harness,no_run
21098/// # extern crate hyper;
21099/// # extern crate hyper_rustls;
21100/// # extern crate google_networkservices1 as networkservices1;
21101/// # async fn dox() {
21102/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21103///
21104/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21105/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
21106/// # .with_native_roots()
21107/// # .unwrap()
21108/// # .https_only()
21109/// # .enable_http2()
21110/// # .build();
21111///
21112/// # let executor = hyper_util::rt::TokioExecutor::new();
21113/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
21114/// # secret,
21115/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21116/// # yup_oauth2::client::CustomHyperClientBuilder::from(
21117/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
21118/// # ),
21119/// # ).build().await.unwrap();
21120///
21121/// # let client = hyper_util::client::legacy::Client::builder(
21122/// # hyper_util::rt::TokioExecutor::new()
21123/// # )
21124/// # .build(
21125/// # hyper_rustls::HttpsConnectorBuilder::new()
21126/// # .with_native_roots()
21127/// # .unwrap()
21128/// # .https_or_http()
21129/// # .enable_http2()
21130/// # .build()
21131/// # );
21132/// # let mut hub = NetworkServices::new(client, auth);
21133/// // You can configure optional parameters by calling the respective setters at will, and
21134/// // execute the final call using `doit()`.
21135/// // Values shown here are possibly random and not representative !
21136/// let result = hub.projects().locations_lb_traffic_extensions_list("parent")
21137/// .page_token("ipsum")
21138/// .page_size(-18)
21139/// .order_by("sanctus")
21140/// .filter("Lorem")
21141/// .doit().await;
21142/// # }
21143/// ```
21144pub struct ProjectLocationLbTrafficExtensionListCall<'a, C>
21145where
21146 C: 'a,
21147{
21148 hub: &'a NetworkServices<C>,
21149 _parent: String,
21150 _page_token: Option<String>,
21151 _page_size: Option<i32>,
21152 _order_by: Option<String>,
21153 _filter: Option<String>,
21154 _delegate: Option<&'a mut dyn common::Delegate>,
21155 _additional_params: HashMap<String, String>,
21156 _scopes: BTreeSet<String>,
21157}
21158
21159impl<'a, C> common::CallBuilder for ProjectLocationLbTrafficExtensionListCall<'a, C> {}
21160
21161impl<'a, C> ProjectLocationLbTrafficExtensionListCall<'a, C>
21162where
21163 C: common::Connector,
21164{
21165 /// Perform the operation you have build so far.
21166 pub async fn doit(
21167 mut self,
21168 ) -> common::Result<(common::Response, ListLbTrafficExtensionsResponse)> {
21169 use std::borrow::Cow;
21170 use std::io::{Read, Seek};
21171
21172 use common::{url::Params, ToParts};
21173 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21174
21175 let mut dd = common::DefaultDelegate;
21176 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21177 dlg.begin(common::MethodInfo {
21178 id: "networkservices.projects.locations.lbTrafficExtensions.list",
21179 http_method: hyper::Method::GET,
21180 });
21181
21182 for &field in [
21183 "alt",
21184 "parent",
21185 "pageToken",
21186 "pageSize",
21187 "orderBy",
21188 "filter",
21189 ]
21190 .iter()
21191 {
21192 if self._additional_params.contains_key(field) {
21193 dlg.finished(false);
21194 return Err(common::Error::FieldClash(field));
21195 }
21196 }
21197
21198 let mut params = Params::with_capacity(7 + self._additional_params.len());
21199 params.push("parent", self._parent);
21200 if let Some(value) = self._page_token.as_ref() {
21201 params.push("pageToken", value);
21202 }
21203 if let Some(value) = self._page_size.as_ref() {
21204 params.push("pageSize", value.to_string());
21205 }
21206 if let Some(value) = self._order_by.as_ref() {
21207 params.push("orderBy", value);
21208 }
21209 if let Some(value) = self._filter.as_ref() {
21210 params.push("filter", value);
21211 }
21212
21213 params.extend(self._additional_params.iter());
21214
21215 params.push("alt", "json");
21216 let mut url = self.hub._base_url.clone() + "v1/{+parent}/lbTrafficExtensions";
21217 if self._scopes.is_empty() {
21218 self._scopes
21219 .insert(Scope::CloudPlatform.as_ref().to_string());
21220 }
21221
21222 #[allow(clippy::single_element_loop)]
21223 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
21224 url = params.uri_replacement(url, param_name, find_this, true);
21225 }
21226 {
21227 let to_remove = ["parent"];
21228 params.remove_params(&to_remove);
21229 }
21230
21231 let url = params.parse_with_url(&url);
21232
21233 loop {
21234 let token = match self
21235 .hub
21236 .auth
21237 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21238 .await
21239 {
21240 Ok(token) => token,
21241 Err(e) => match dlg.token(e) {
21242 Ok(token) => token,
21243 Err(e) => {
21244 dlg.finished(false);
21245 return Err(common::Error::MissingToken(e));
21246 }
21247 },
21248 };
21249 let mut req_result = {
21250 let client = &self.hub.client;
21251 dlg.pre_request();
21252 let mut req_builder = hyper::Request::builder()
21253 .method(hyper::Method::GET)
21254 .uri(url.as_str())
21255 .header(USER_AGENT, self.hub._user_agent.clone());
21256
21257 if let Some(token) = token.as_ref() {
21258 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21259 }
21260
21261 let request = req_builder
21262 .header(CONTENT_LENGTH, 0_u64)
21263 .body(common::to_body::<String>(None));
21264
21265 client.request(request.unwrap()).await
21266 };
21267
21268 match req_result {
21269 Err(err) => {
21270 if let common::Retry::After(d) = dlg.http_error(&err) {
21271 sleep(d).await;
21272 continue;
21273 }
21274 dlg.finished(false);
21275 return Err(common::Error::HttpError(err));
21276 }
21277 Ok(res) => {
21278 let (mut parts, body) = res.into_parts();
21279 let mut body = common::Body::new(body);
21280 if !parts.status.is_success() {
21281 let bytes = common::to_bytes(body).await.unwrap_or_default();
21282 let error = serde_json::from_str(&common::to_string(&bytes));
21283 let response = common::to_response(parts, bytes.into());
21284
21285 if let common::Retry::After(d) =
21286 dlg.http_failure(&response, error.as_ref().ok())
21287 {
21288 sleep(d).await;
21289 continue;
21290 }
21291
21292 dlg.finished(false);
21293
21294 return Err(match error {
21295 Ok(value) => common::Error::BadRequest(value),
21296 _ => common::Error::Failure(response),
21297 });
21298 }
21299 let response = {
21300 let bytes = common::to_bytes(body).await.unwrap_or_default();
21301 let encoded = common::to_string(&bytes);
21302 match serde_json::from_str(&encoded) {
21303 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21304 Err(error) => {
21305 dlg.response_json_decode_error(&encoded, &error);
21306 return Err(common::Error::JsonDecodeError(
21307 encoded.to_string(),
21308 error,
21309 ));
21310 }
21311 }
21312 };
21313
21314 dlg.finished(true);
21315 return Ok(response);
21316 }
21317 }
21318 }
21319 }
21320
21321 /// Required. The project and location from which the `LbTrafficExtension` resources are listed. These values are specified in the following format: `projects/{project}/locations/{location}`.
21322 ///
21323 /// Sets the *parent* path property to the given value.
21324 ///
21325 /// Even though the property as already been set when instantiating this call,
21326 /// we provide this method for API completeness.
21327 pub fn parent(mut self, new_value: &str) -> ProjectLocationLbTrafficExtensionListCall<'a, C> {
21328 self._parent = new_value.to_string();
21329 self
21330 }
21331 /// Optional. A token identifying a page of results that the server returns.
21332 ///
21333 /// Sets the *page token* query property to the given value.
21334 pub fn page_token(
21335 mut self,
21336 new_value: &str,
21337 ) -> ProjectLocationLbTrafficExtensionListCall<'a, C> {
21338 self._page_token = Some(new_value.to_string());
21339 self
21340 }
21341 /// Optional. Requested page size. The server might return fewer items than requested. If unspecified, the server picks an appropriate default.
21342 ///
21343 /// Sets the *page size* query property to the given value.
21344 pub fn page_size(mut self, new_value: i32) -> ProjectLocationLbTrafficExtensionListCall<'a, C> {
21345 self._page_size = Some(new_value);
21346 self
21347 }
21348 /// Optional. Hint about how to order the results.
21349 ///
21350 /// Sets the *order by* query property to the given value.
21351 pub fn order_by(mut self, new_value: &str) -> ProjectLocationLbTrafficExtensionListCall<'a, C> {
21352 self._order_by = Some(new_value.to_string());
21353 self
21354 }
21355 /// Optional. Filtering results.
21356 ///
21357 /// Sets the *filter* query property to the given value.
21358 pub fn filter(mut self, new_value: &str) -> ProjectLocationLbTrafficExtensionListCall<'a, C> {
21359 self._filter = Some(new_value.to_string());
21360 self
21361 }
21362 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21363 /// while executing the actual API request.
21364 ///
21365 /// ````text
21366 /// It should be used to handle progress information, and to implement a certain level of resilience.
21367 /// ````
21368 ///
21369 /// Sets the *delegate* property to the given value.
21370 pub fn delegate(
21371 mut self,
21372 new_value: &'a mut dyn common::Delegate,
21373 ) -> ProjectLocationLbTrafficExtensionListCall<'a, C> {
21374 self._delegate = Some(new_value);
21375 self
21376 }
21377
21378 /// Set any additional parameter of the query string used in the request.
21379 /// It should be used to set parameters which are not yet available through their own
21380 /// setters.
21381 ///
21382 /// Please note that this method must not be used to set any of the known parameters
21383 /// which have their own setter method. If done anyway, the request will fail.
21384 ///
21385 /// # Additional Parameters
21386 ///
21387 /// * *$.xgafv* (query-string) - V1 error format.
21388 /// * *access_token* (query-string) - OAuth access token.
21389 /// * *alt* (query-string) - Data format for response.
21390 /// * *callback* (query-string) - JSONP
21391 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21392 /// * *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.
21393 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21394 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21395 /// * *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.
21396 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21397 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21398 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationLbTrafficExtensionListCall<'a, C>
21399 where
21400 T: AsRef<str>,
21401 {
21402 self._additional_params
21403 .insert(name.as_ref().to_string(), value.as_ref().to_string());
21404 self
21405 }
21406
21407 /// Identifies the authorization scope for the method you are building.
21408 ///
21409 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21410 /// [`Scope::CloudPlatform`].
21411 ///
21412 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21413 /// tokens for more than one scope.
21414 ///
21415 /// Usually there is more than one suitable scope to authorize an operation, some of which may
21416 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21417 /// sufficient, a read-write scope will do as well.
21418 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationLbTrafficExtensionListCall<'a, C>
21419 where
21420 St: AsRef<str>,
21421 {
21422 self._scopes.insert(String::from(scope.as_ref()));
21423 self
21424 }
21425 /// Identifies the authorization scope(s) for the method you are building.
21426 ///
21427 /// See [`Self::add_scope()`] for details.
21428 pub fn add_scopes<I, St>(
21429 mut self,
21430 scopes: I,
21431 ) -> ProjectLocationLbTrafficExtensionListCall<'a, C>
21432 where
21433 I: IntoIterator<Item = St>,
21434 St: AsRef<str>,
21435 {
21436 self._scopes
21437 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21438 self
21439 }
21440
21441 /// Removes all scopes, and no default scope will be used either.
21442 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21443 /// for details).
21444 pub fn clear_scopes(mut self) -> ProjectLocationLbTrafficExtensionListCall<'a, C> {
21445 self._scopes.clear();
21446 self
21447 }
21448}
21449
21450/// Updates the parameters of the specified `LbTrafficExtension` resource.
21451///
21452/// A builder for the *locations.lbTrafficExtensions.patch* method supported by a *project* resource.
21453/// It is not used directly, but through a [`ProjectMethods`] instance.
21454///
21455/// # Example
21456///
21457/// Instantiate a resource method builder
21458///
21459/// ```test_harness,no_run
21460/// # extern crate hyper;
21461/// # extern crate hyper_rustls;
21462/// # extern crate google_networkservices1 as networkservices1;
21463/// use networkservices1::api::LbTrafficExtension;
21464/// # async fn dox() {
21465/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21466///
21467/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21468/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
21469/// # .with_native_roots()
21470/// # .unwrap()
21471/// # .https_only()
21472/// # .enable_http2()
21473/// # .build();
21474///
21475/// # let executor = hyper_util::rt::TokioExecutor::new();
21476/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
21477/// # secret,
21478/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21479/// # yup_oauth2::client::CustomHyperClientBuilder::from(
21480/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
21481/// # ),
21482/// # ).build().await.unwrap();
21483///
21484/// # let client = hyper_util::client::legacy::Client::builder(
21485/// # hyper_util::rt::TokioExecutor::new()
21486/// # )
21487/// # .build(
21488/// # hyper_rustls::HttpsConnectorBuilder::new()
21489/// # .with_native_roots()
21490/// # .unwrap()
21491/// # .https_or_http()
21492/// # .enable_http2()
21493/// # .build()
21494/// # );
21495/// # let mut hub = NetworkServices::new(client, auth);
21496/// // As the method needs a request, you would usually fill it with the desired information
21497/// // into the respective structure. Some of the parts shown here might not be applicable !
21498/// // Values shown here are possibly random and not representative !
21499/// let mut req = LbTrafficExtension::default();
21500///
21501/// // You can configure optional parameters by calling the respective setters at will, and
21502/// // execute the final call using `doit()`.
21503/// // Values shown here are possibly random and not representative !
21504/// let result = hub.projects().locations_lb_traffic_extensions_patch(req, "name")
21505/// .update_mask(FieldMask::new::<&str>(&[]))
21506/// .request_id("sed")
21507/// .doit().await;
21508/// # }
21509/// ```
21510pub struct ProjectLocationLbTrafficExtensionPatchCall<'a, C>
21511where
21512 C: 'a,
21513{
21514 hub: &'a NetworkServices<C>,
21515 _request: LbTrafficExtension,
21516 _name: String,
21517 _update_mask: Option<common::FieldMask>,
21518 _request_id: Option<String>,
21519 _delegate: Option<&'a mut dyn common::Delegate>,
21520 _additional_params: HashMap<String, String>,
21521 _scopes: BTreeSet<String>,
21522}
21523
21524impl<'a, C> common::CallBuilder for ProjectLocationLbTrafficExtensionPatchCall<'a, C> {}
21525
21526impl<'a, C> ProjectLocationLbTrafficExtensionPatchCall<'a, C>
21527where
21528 C: common::Connector,
21529{
21530 /// Perform the operation you have build so far.
21531 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
21532 use std::borrow::Cow;
21533 use std::io::{Read, Seek};
21534
21535 use common::{url::Params, ToParts};
21536 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21537
21538 let mut dd = common::DefaultDelegate;
21539 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21540 dlg.begin(common::MethodInfo {
21541 id: "networkservices.projects.locations.lbTrafficExtensions.patch",
21542 http_method: hyper::Method::PATCH,
21543 });
21544
21545 for &field in ["alt", "name", "updateMask", "requestId"].iter() {
21546 if self._additional_params.contains_key(field) {
21547 dlg.finished(false);
21548 return Err(common::Error::FieldClash(field));
21549 }
21550 }
21551
21552 let mut params = Params::with_capacity(6 + self._additional_params.len());
21553 params.push("name", self._name);
21554 if let Some(value) = self._update_mask.as_ref() {
21555 params.push("updateMask", value.to_string());
21556 }
21557 if let Some(value) = self._request_id.as_ref() {
21558 params.push("requestId", value);
21559 }
21560
21561 params.extend(self._additional_params.iter());
21562
21563 params.push("alt", "json");
21564 let mut url = self.hub._base_url.clone() + "v1/{+name}";
21565 if self._scopes.is_empty() {
21566 self._scopes
21567 .insert(Scope::CloudPlatform.as_ref().to_string());
21568 }
21569
21570 #[allow(clippy::single_element_loop)]
21571 for &(find_this, param_name) in [("{+name}", "name")].iter() {
21572 url = params.uri_replacement(url, param_name, find_this, true);
21573 }
21574 {
21575 let to_remove = ["name"];
21576 params.remove_params(&to_remove);
21577 }
21578
21579 let url = params.parse_with_url(&url);
21580
21581 let mut json_mime_type = mime::APPLICATION_JSON;
21582 let mut request_value_reader = {
21583 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
21584 common::remove_json_null_values(&mut value);
21585 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
21586 serde_json::to_writer(&mut dst, &value).unwrap();
21587 dst
21588 };
21589 let request_size = request_value_reader
21590 .seek(std::io::SeekFrom::End(0))
21591 .unwrap();
21592 request_value_reader
21593 .seek(std::io::SeekFrom::Start(0))
21594 .unwrap();
21595
21596 loop {
21597 let token = match self
21598 .hub
21599 .auth
21600 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21601 .await
21602 {
21603 Ok(token) => token,
21604 Err(e) => match dlg.token(e) {
21605 Ok(token) => token,
21606 Err(e) => {
21607 dlg.finished(false);
21608 return Err(common::Error::MissingToken(e));
21609 }
21610 },
21611 };
21612 request_value_reader
21613 .seek(std::io::SeekFrom::Start(0))
21614 .unwrap();
21615 let mut req_result = {
21616 let client = &self.hub.client;
21617 dlg.pre_request();
21618 let mut req_builder = hyper::Request::builder()
21619 .method(hyper::Method::PATCH)
21620 .uri(url.as_str())
21621 .header(USER_AGENT, self.hub._user_agent.clone());
21622
21623 if let Some(token) = token.as_ref() {
21624 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21625 }
21626
21627 let request = req_builder
21628 .header(CONTENT_TYPE, json_mime_type.to_string())
21629 .header(CONTENT_LENGTH, request_size as u64)
21630 .body(common::to_body(
21631 request_value_reader.get_ref().clone().into(),
21632 ));
21633
21634 client.request(request.unwrap()).await
21635 };
21636
21637 match req_result {
21638 Err(err) => {
21639 if let common::Retry::After(d) = dlg.http_error(&err) {
21640 sleep(d).await;
21641 continue;
21642 }
21643 dlg.finished(false);
21644 return Err(common::Error::HttpError(err));
21645 }
21646 Ok(res) => {
21647 let (mut parts, body) = res.into_parts();
21648 let mut body = common::Body::new(body);
21649 if !parts.status.is_success() {
21650 let bytes = common::to_bytes(body).await.unwrap_or_default();
21651 let error = serde_json::from_str(&common::to_string(&bytes));
21652 let response = common::to_response(parts, bytes.into());
21653
21654 if let common::Retry::After(d) =
21655 dlg.http_failure(&response, error.as_ref().ok())
21656 {
21657 sleep(d).await;
21658 continue;
21659 }
21660
21661 dlg.finished(false);
21662
21663 return Err(match error {
21664 Ok(value) => common::Error::BadRequest(value),
21665 _ => common::Error::Failure(response),
21666 });
21667 }
21668 let response = {
21669 let bytes = common::to_bytes(body).await.unwrap_or_default();
21670 let encoded = common::to_string(&bytes);
21671 match serde_json::from_str(&encoded) {
21672 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21673 Err(error) => {
21674 dlg.response_json_decode_error(&encoded, &error);
21675 return Err(common::Error::JsonDecodeError(
21676 encoded.to_string(),
21677 error,
21678 ));
21679 }
21680 }
21681 };
21682
21683 dlg.finished(true);
21684 return Ok(response);
21685 }
21686 }
21687 }
21688 }
21689
21690 ///
21691 /// Sets the *request* property to the given value.
21692 ///
21693 /// Even though the property as already been set when instantiating this call,
21694 /// we provide this method for API completeness.
21695 pub fn request(
21696 mut self,
21697 new_value: LbTrafficExtension,
21698 ) -> ProjectLocationLbTrafficExtensionPatchCall<'a, C> {
21699 self._request = new_value;
21700 self
21701 }
21702 /// Required. Identifier. Name of the `LbTrafficExtension` resource in the following format: `projects/{project}/locations/{location}/lbTrafficExtensions/{lb_traffic_extension}`.
21703 ///
21704 /// Sets the *name* path property to the given value.
21705 ///
21706 /// Even though the property as already been set when instantiating this call,
21707 /// we provide this method for API completeness.
21708 pub fn name(mut self, new_value: &str) -> ProjectLocationLbTrafficExtensionPatchCall<'a, C> {
21709 self._name = new_value.to_string();
21710 self
21711 }
21712 /// Optional. Used to specify the fields to be overwritten in the `LbTrafficExtension` resource by the update. The fields specified in the `update_mask` are relative to the resource, not the full request. A field is overwritten if it is in the mask. If the user does not specify a mask, then all fields are overwritten.
21713 ///
21714 /// Sets the *update mask* query property to the given value.
21715 pub fn update_mask(
21716 mut self,
21717 new_value: common::FieldMask,
21718 ) -> ProjectLocationLbTrafficExtensionPatchCall<'a, C> {
21719 self._update_mask = Some(new_value);
21720 self
21721 }
21722 /// Optional. An optional request ID to identify requests. Specify a unique request ID so that if you must retry your request, the server can ignore the request if it has already been completed. The server guarantees that for 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 ignores 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).
21723 ///
21724 /// Sets the *request id* query property to the given value.
21725 pub fn request_id(
21726 mut self,
21727 new_value: &str,
21728 ) -> ProjectLocationLbTrafficExtensionPatchCall<'a, C> {
21729 self._request_id = Some(new_value.to_string());
21730 self
21731 }
21732 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21733 /// while executing the actual API request.
21734 ///
21735 /// ````text
21736 /// It should be used to handle progress information, and to implement a certain level of resilience.
21737 /// ````
21738 ///
21739 /// Sets the *delegate* property to the given value.
21740 pub fn delegate(
21741 mut self,
21742 new_value: &'a mut dyn common::Delegate,
21743 ) -> ProjectLocationLbTrafficExtensionPatchCall<'a, C> {
21744 self._delegate = Some(new_value);
21745 self
21746 }
21747
21748 /// Set any additional parameter of the query string used in the request.
21749 /// It should be used to set parameters which are not yet available through their own
21750 /// setters.
21751 ///
21752 /// Please note that this method must not be used to set any of the known parameters
21753 /// which have their own setter method. If done anyway, the request will fail.
21754 ///
21755 /// # Additional Parameters
21756 ///
21757 /// * *$.xgafv* (query-string) - V1 error format.
21758 /// * *access_token* (query-string) - OAuth access token.
21759 /// * *alt* (query-string) - Data format for response.
21760 /// * *callback* (query-string) - JSONP
21761 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21762 /// * *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.
21763 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21764 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21765 /// * *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.
21766 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21767 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21768 pub fn param<T>(
21769 mut self,
21770 name: T,
21771 value: T,
21772 ) -> ProjectLocationLbTrafficExtensionPatchCall<'a, C>
21773 where
21774 T: AsRef<str>,
21775 {
21776 self._additional_params
21777 .insert(name.as_ref().to_string(), value.as_ref().to_string());
21778 self
21779 }
21780
21781 /// Identifies the authorization scope for the method you are building.
21782 ///
21783 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21784 /// [`Scope::CloudPlatform`].
21785 ///
21786 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21787 /// tokens for more than one scope.
21788 ///
21789 /// Usually there is more than one suitable scope to authorize an operation, some of which may
21790 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21791 /// sufficient, a read-write scope will do as well.
21792 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationLbTrafficExtensionPatchCall<'a, C>
21793 where
21794 St: AsRef<str>,
21795 {
21796 self._scopes.insert(String::from(scope.as_ref()));
21797 self
21798 }
21799 /// Identifies the authorization scope(s) for the method you are building.
21800 ///
21801 /// See [`Self::add_scope()`] for details.
21802 pub fn add_scopes<I, St>(
21803 mut self,
21804 scopes: I,
21805 ) -> ProjectLocationLbTrafficExtensionPatchCall<'a, C>
21806 where
21807 I: IntoIterator<Item = St>,
21808 St: AsRef<str>,
21809 {
21810 self._scopes
21811 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21812 self
21813 }
21814
21815 /// Removes all scopes, and no default scope will be used either.
21816 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21817 /// for details).
21818 pub fn clear_scopes(mut self) -> ProjectLocationLbTrafficExtensionPatchCall<'a, C> {
21819 self._scopes.clear();
21820 self
21821 }
21822}
21823
21824/// Get a single RouteView of a Mesh.
21825///
21826/// A builder for the *locations.meshes.routeViews.get* method supported by a *project* resource.
21827/// It is not used directly, but through a [`ProjectMethods`] instance.
21828///
21829/// # Example
21830///
21831/// Instantiate a resource method builder
21832///
21833/// ```test_harness,no_run
21834/// # extern crate hyper;
21835/// # extern crate hyper_rustls;
21836/// # extern crate google_networkservices1 as networkservices1;
21837/// # async fn dox() {
21838/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21839///
21840/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21841/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
21842/// # .with_native_roots()
21843/// # .unwrap()
21844/// # .https_only()
21845/// # .enable_http2()
21846/// # .build();
21847///
21848/// # let executor = hyper_util::rt::TokioExecutor::new();
21849/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
21850/// # secret,
21851/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21852/// # yup_oauth2::client::CustomHyperClientBuilder::from(
21853/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
21854/// # ),
21855/// # ).build().await.unwrap();
21856///
21857/// # let client = hyper_util::client::legacy::Client::builder(
21858/// # hyper_util::rt::TokioExecutor::new()
21859/// # )
21860/// # .build(
21861/// # hyper_rustls::HttpsConnectorBuilder::new()
21862/// # .with_native_roots()
21863/// # .unwrap()
21864/// # .https_or_http()
21865/// # .enable_http2()
21866/// # .build()
21867/// # );
21868/// # let mut hub = NetworkServices::new(client, auth);
21869/// // You can configure optional parameters by calling the respective setters at will, and
21870/// // execute the final call using `doit()`.
21871/// // Values shown here are possibly random and not representative !
21872/// let result = hub.projects().locations_meshes_route_views_get("name")
21873/// .doit().await;
21874/// # }
21875/// ```
21876pub struct ProjectLocationMeshRouteViewGetCall<'a, C>
21877where
21878 C: 'a,
21879{
21880 hub: &'a NetworkServices<C>,
21881 _name: String,
21882 _delegate: Option<&'a mut dyn common::Delegate>,
21883 _additional_params: HashMap<String, String>,
21884 _scopes: BTreeSet<String>,
21885}
21886
21887impl<'a, C> common::CallBuilder for ProjectLocationMeshRouteViewGetCall<'a, C> {}
21888
21889impl<'a, C> ProjectLocationMeshRouteViewGetCall<'a, C>
21890where
21891 C: common::Connector,
21892{
21893 /// Perform the operation you have build so far.
21894 pub async fn doit(mut self) -> common::Result<(common::Response, MeshRouteView)> {
21895 use std::borrow::Cow;
21896 use std::io::{Read, Seek};
21897
21898 use common::{url::Params, ToParts};
21899 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21900
21901 let mut dd = common::DefaultDelegate;
21902 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21903 dlg.begin(common::MethodInfo {
21904 id: "networkservices.projects.locations.meshes.routeViews.get",
21905 http_method: hyper::Method::GET,
21906 });
21907
21908 for &field in ["alt", "name"].iter() {
21909 if self._additional_params.contains_key(field) {
21910 dlg.finished(false);
21911 return Err(common::Error::FieldClash(field));
21912 }
21913 }
21914
21915 let mut params = Params::with_capacity(3 + self._additional_params.len());
21916 params.push("name", self._name);
21917
21918 params.extend(self._additional_params.iter());
21919
21920 params.push("alt", "json");
21921 let mut url = self.hub._base_url.clone() + "v1/{+name}";
21922 if self._scopes.is_empty() {
21923 self._scopes
21924 .insert(Scope::CloudPlatform.as_ref().to_string());
21925 }
21926
21927 #[allow(clippy::single_element_loop)]
21928 for &(find_this, param_name) in [("{+name}", "name")].iter() {
21929 url = params.uri_replacement(url, param_name, find_this, true);
21930 }
21931 {
21932 let to_remove = ["name"];
21933 params.remove_params(&to_remove);
21934 }
21935
21936 let url = params.parse_with_url(&url);
21937
21938 loop {
21939 let token = match self
21940 .hub
21941 .auth
21942 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21943 .await
21944 {
21945 Ok(token) => token,
21946 Err(e) => match dlg.token(e) {
21947 Ok(token) => token,
21948 Err(e) => {
21949 dlg.finished(false);
21950 return Err(common::Error::MissingToken(e));
21951 }
21952 },
21953 };
21954 let mut req_result = {
21955 let client = &self.hub.client;
21956 dlg.pre_request();
21957 let mut req_builder = hyper::Request::builder()
21958 .method(hyper::Method::GET)
21959 .uri(url.as_str())
21960 .header(USER_AGENT, self.hub._user_agent.clone());
21961
21962 if let Some(token) = token.as_ref() {
21963 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21964 }
21965
21966 let request = req_builder
21967 .header(CONTENT_LENGTH, 0_u64)
21968 .body(common::to_body::<String>(None));
21969
21970 client.request(request.unwrap()).await
21971 };
21972
21973 match req_result {
21974 Err(err) => {
21975 if let common::Retry::After(d) = dlg.http_error(&err) {
21976 sleep(d).await;
21977 continue;
21978 }
21979 dlg.finished(false);
21980 return Err(common::Error::HttpError(err));
21981 }
21982 Ok(res) => {
21983 let (mut parts, body) = res.into_parts();
21984 let mut body = common::Body::new(body);
21985 if !parts.status.is_success() {
21986 let bytes = common::to_bytes(body).await.unwrap_or_default();
21987 let error = serde_json::from_str(&common::to_string(&bytes));
21988 let response = common::to_response(parts, bytes.into());
21989
21990 if let common::Retry::After(d) =
21991 dlg.http_failure(&response, error.as_ref().ok())
21992 {
21993 sleep(d).await;
21994 continue;
21995 }
21996
21997 dlg.finished(false);
21998
21999 return Err(match error {
22000 Ok(value) => common::Error::BadRequest(value),
22001 _ => common::Error::Failure(response),
22002 });
22003 }
22004 let response = {
22005 let bytes = common::to_bytes(body).await.unwrap_or_default();
22006 let encoded = common::to_string(&bytes);
22007 match serde_json::from_str(&encoded) {
22008 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22009 Err(error) => {
22010 dlg.response_json_decode_error(&encoded, &error);
22011 return Err(common::Error::JsonDecodeError(
22012 encoded.to_string(),
22013 error,
22014 ));
22015 }
22016 }
22017 };
22018
22019 dlg.finished(true);
22020 return Ok(response);
22021 }
22022 }
22023 }
22024 }
22025
22026 /// Required. Name of the MeshRouteView resource. Format: projects/{project_number}/locations/{location}/meshes/{mesh}/routeViews/{route_view}
22027 ///
22028 /// Sets the *name* path property to the given value.
22029 ///
22030 /// Even though the property as already been set when instantiating this call,
22031 /// we provide this method for API completeness.
22032 pub fn name(mut self, new_value: &str) -> ProjectLocationMeshRouteViewGetCall<'a, C> {
22033 self._name = new_value.to_string();
22034 self
22035 }
22036 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22037 /// while executing the actual API request.
22038 ///
22039 /// ````text
22040 /// It should be used to handle progress information, and to implement a certain level of resilience.
22041 /// ````
22042 ///
22043 /// Sets the *delegate* property to the given value.
22044 pub fn delegate(
22045 mut self,
22046 new_value: &'a mut dyn common::Delegate,
22047 ) -> ProjectLocationMeshRouteViewGetCall<'a, C> {
22048 self._delegate = Some(new_value);
22049 self
22050 }
22051
22052 /// Set any additional parameter of the query string used in the request.
22053 /// It should be used to set parameters which are not yet available through their own
22054 /// setters.
22055 ///
22056 /// Please note that this method must not be used to set any of the known parameters
22057 /// which have their own setter method. If done anyway, the request will fail.
22058 ///
22059 /// # Additional Parameters
22060 ///
22061 /// * *$.xgafv* (query-string) - V1 error format.
22062 /// * *access_token* (query-string) - OAuth access token.
22063 /// * *alt* (query-string) - Data format for response.
22064 /// * *callback* (query-string) - JSONP
22065 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22066 /// * *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.
22067 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22068 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22069 /// * *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.
22070 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22071 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22072 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationMeshRouteViewGetCall<'a, C>
22073 where
22074 T: AsRef<str>,
22075 {
22076 self._additional_params
22077 .insert(name.as_ref().to_string(), value.as_ref().to_string());
22078 self
22079 }
22080
22081 /// Identifies the authorization scope for the method you are building.
22082 ///
22083 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22084 /// [`Scope::CloudPlatform`].
22085 ///
22086 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22087 /// tokens for more than one scope.
22088 ///
22089 /// Usually there is more than one suitable scope to authorize an operation, some of which may
22090 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22091 /// sufficient, a read-write scope will do as well.
22092 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationMeshRouteViewGetCall<'a, C>
22093 where
22094 St: AsRef<str>,
22095 {
22096 self._scopes.insert(String::from(scope.as_ref()));
22097 self
22098 }
22099 /// Identifies the authorization scope(s) for the method you are building.
22100 ///
22101 /// See [`Self::add_scope()`] for details.
22102 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationMeshRouteViewGetCall<'a, C>
22103 where
22104 I: IntoIterator<Item = St>,
22105 St: AsRef<str>,
22106 {
22107 self._scopes
22108 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22109 self
22110 }
22111
22112 /// Removes all scopes, and no default scope will be used either.
22113 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22114 /// for details).
22115 pub fn clear_scopes(mut self) -> ProjectLocationMeshRouteViewGetCall<'a, C> {
22116 self._scopes.clear();
22117 self
22118 }
22119}
22120
22121/// Lists RouteViews
22122///
22123/// A builder for the *locations.meshes.routeViews.list* method supported by a *project* resource.
22124/// It is not used directly, but through a [`ProjectMethods`] instance.
22125///
22126/// # Example
22127///
22128/// Instantiate a resource method builder
22129///
22130/// ```test_harness,no_run
22131/// # extern crate hyper;
22132/// # extern crate hyper_rustls;
22133/// # extern crate google_networkservices1 as networkservices1;
22134/// # async fn dox() {
22135/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22136///
22137/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22138/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
22139/// # .with_native_roots()
22140/// # .unwrap()
22141/// # .https_only()
22142/// # .enable_http2()
22143/// # .build();
22144///
22145/// # let executor = hyper_util::rt::TokioExecutor::new();
22146/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
22147/// # secret,
22148/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22149/// # yup_oauth2::client::CustomHyperClientBuilder::from(
22150/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
22151/// # ),
22152/// # ).build().await.unwrap();
22153///
22154/// # let client = hyper_util::client::legacy::Client::builder(
22155/// # hyper_util::rt::TokioExecutor::new()
22156/// # )
22157/// # .build(
22158/// # hyper_rustls::HttpsConnectorBuilder::new()
22159/// # .with_native_roots()
22160/// # .unwrap()
22161/// # .https_or_http()
22162/// # .enable_http2()
22163/// # .build()
22164/// # );
22165/// # let mut hub = NetworkServices::new(client, auth);
22166/// // You can configure optional parameters by calling the respective setters at will, and
22167/// // execute the final call using `doit()`.
22168/// // Values shown here are possibly random and not representative !
22169/// let result = hub.projects().locations_meshes_route_views_list("parent")
22170/// .page_token("dolores")
22171/// .page_size(-68)
22172/// .doit().await;
22173/// # }
22174/// ```
22175pub struct ProjectLocationMeshRouteViewListCall<'a, C>
22176where
22177 C: 'a,
22178{
22179 hub: &'a NetworkServices<C>,
22180 _parent: String,
22181 _page_token: Option<String>,
22182 _page_size: Option<i32>,
22183 _delegate: Option<&'a mut dyn common::Delegate>,
22184 _additional_params: HashMap<String, String>,
22185 _scopes: BTreeSet<String>,
22186}
22187
22188impl<'a, C> common::CallBuilder for ProjectLocationMeshRouteViewListCall<'a, C> {}
22189
22190impl<'a, C> ProjectLocationMeshRouteViewListCall<'a, C>
22191where
22192 C: common::Connector,
22193{
22194 /// Perform the operation you have build so far.
22195 pub async fn doit(mut self) -> common::Result<(common::Response, ListMeshRouteViewsResponse)> {
22196 use std::borrow::Cow;
22197 use std::io::{Read, Seek};
22198
22199 use common::{url::Params, ToParts};
22200 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22201
22202 let mut dd = common::DefaultDelegate;
22203 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22204 dlg.begin(common::MethodInfo {
22205 id: "networkservices.projects.locations.meshes.routeViews.list",
22206 http_method: hyper::Method::GET,
22207 });
22208
22209 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
22210 if self._additional_params.contains_key(field) {
22211 dlg.finished(false);
22212 return Err(common::Error::FieldClash(field));
22213 }
22214 }
22215
22216 let mut params = Params::with_capacity(5 + self._additional_params.len());
22217 params.push("parent", self._parent);
22218 if let Some(value) = self._page_token.as_ref() {
22219 params.push("pageToken", value);
22220 }
22221 if let Some(value) = self._page_size.as_ref() {
22222 params.push("pageSize", value.to_string());
22223 }
22224
22225 params.extend(self._additional_params.iter());
22226
22227 params.push("alt", "json");
22228 let mut url = self.hub._base_url.clone() + "v1/{+parent}/routeViews";
22229 if self._scopes.is_empty() {
22230 self._scopes
22231 .insert(Scope::CloudPlatform.as_ref().to_string());
22232 }
22233
22234 #[allow(clippy::single_element_loop)]
22235 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
22236 url = params.uri_replacement(url, param_name, find_this, true);
22237 }
22238 {
22239 let to_remove = ["parent"];
22240 params.remove_params(&to_remove);
22241 }
22242
22243 let url = params.parse_with_url(&url);
22244
22245 loop {
22246 let token = match self
22247 .hub
22248 .auth
22249 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22250 .await
22251 {
22252 Ok(token) => token,
22253 Err(e) => match dlg.token(e) {
22254 Ok(token) => token,
22255 Err(e) => {
22256 dlg.finished(false);
22257 return Err(common::Error::MissingToken(e));
22258 }
22259 },
22260 };
22261 let mut req_result = {
22262 let client = &self.hub.client;
22263 dlg.pre_request();
22264 let mut req_builder = hyper::Request::builder()
22265 .method(hyper::Method::GET)
22266 .uri(url.as_str())
22267 .header(USER_AGENT, self.hub._user_agent.clone());
22268
22269 if let Some(token) = token.as_ref() {
22270 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22271 }
22272
22273 let request = req_builder
22274 .header(CONTENT_LENGTH, 0_u64)
22275 .body(common::to_body::<String>(None));
22276
22277 client.request(request.unwrap()).await
22278 };
22279
22280 match req_result {
22281 Err(err) => {
22282 if let common::Retry::After(d) = dlg.http_error(&err) {
22283 sleep(d).await;
22284 continue;
22285 }
22286 dlg.finished(false);
22287 return Err(common::Error::HttpError(err));
22288 }
22289 Ok(res) => {
22290 let (mut parts, body) = res.into_parts();
22291 let mut body = common::Body::new(body);
22292 if !parts.status.is_success() {
22293 let bytes = common::to_bytes(body).await.unwrap_or_default();
22294 let error = serde_json::from_str(&common::to_string(&bytes));
22295 let response = common::to_response(parts, bytes.into());
22296
22297 if let common::Retry::After(d) =
22298 dlg.http_failure(&response, error.as_ref().ok())
22299 {
22300 sleep(d).await;
22301 continue;
22302 }
22303
22304 dlg.finished(false);
22305
22306 return Err(match error {
22307 Ok(value) => common::Error::BadRequest(value),
22308 _ => common::Error::Failure(response),
22309 });
22310 }
22311 let response = {
22312 let bytes = common::to_bytes(body).await.unwrap_or_default();
22313 let encoded = common::to_string(&bytes);
22314 match serde_json::from_str(&encoded) {
22315 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22316 Err(error) => {
22317 dlg.response_json_decode_error(&encoded, &error);
22318 return Err(common::Error::JsonDecodeError(
22319 encoded.to_string(),
22320 error,
22321 ));
22322 }
22323 }
22324 };
22325
22326 dlg.finished(true);
22327 return Ok(response);
22328 }
22329 }
22330 }
22331 }
22332
22333 /// Required. The Mesh to which a Route is associated. Format: projects/{project_number}/locations/{location}/meshes/{mesh}
22334 ///
22335 /// Sets the *parent* path property to the given value.
22336 ///
22337 /// Even though the property as already been set when instantiating this call,
22338 /// we provide this method for API completeness.
22339 pub fn parent(mut self, new_value: &str) -> ProjectLocationMeshRouteViewListCall<'a, C> {
22340 self._parent = new_value.to_string();
22341 self
22342 }
22343 /// The value returned by the last `ListMeshRouteViewsResponse` Indicates that this is a continuation of a prior `ListMeshRouteViews` call, and that the system should return the next page of data.
22344 ///
22345 /// Sets the *page token* query property to the given value.
22346 pub fn page_token(mut self, new_value: &str) -> ProjectLocationMeshRouteViewListCall<'a, C> {
22347 self._page_token = Some(new_value.to_string());
22348 self
22349 }
22350 /// Maximum number of MeshRouteViews to return per call.
22351 ///
22352 /// Sets the *page size* query property to the given value.
22353 pub fn page_size(mut self, new_value: i32) -> ProjectLocationMeshRouteViewListCall<'a, C> {
22354 self._page_size = Some(new_value);
22355 self
22356 }
22357 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22358 /// while executing the actual API request.
22359 ///
22360 /// ````text
22361 /// It should be used to handle progress information, and to implement a certain level of resilience.
22362 /// ````
22363 ///
22364 /// Sets the *delegate* property to the given value.
22365 pub fn delegate(
22366 mut self,
22367 new_value: &'a mut dyn common::Delegate,
22368 ) -> ProjectLocationMeshRouteViewListCall<'a, C> {
22369 self._delegate = Some(new_value);
22370 self
22371 }
22372
22373 /// Set any additional parameter of the query string used in the request.
22374 /// It should be used to set parameters which are not yet available through their own
22375 /// setters.
22376 ///
22377 /// Please note that this method must not be used to set any of the known parameters
22378 /// which have their own setter method. If done anyway, the request will fail.
22379 ///
22380 /// # Additional Parameters
22381 ///
22382 /// * *$.xgafv* (query-string) - V1 error format.
22383 /// * *access_token* (query-string) - OAuth access token.
22384 /// * *alt* (query-string) - Data format for response.
22385 /// * *callback* (query-string) - JSONP
22386 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22387 /// * *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.
22388 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22389 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22390 /// * *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.
22391 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22392 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22393 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationMeshRouteViewListCall<'a, C>
22394 where
22395 T: AsRef<str>,
22396 {
22397 self._additional_params
22398 .insert(name.as_ref().to_string(), value.as_ref().to_string());
22399 self
22400 }
22401
22402 /// Identifies the authorization scope for the method you are building.
22403 ///
22404 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22405 /// [`Scope::CloudPlatform`].
22406 ///
22407 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22408 /// tokens for more than one scope.
22409 ///
22410 /// Usually there is more than one suitable scope to authorize an operation, some of which may
22411 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22412 /// sufficient, a read-write scope will do as well.
22413 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationMeshRouteViewListCall<'a, C>
22414 where
22415 St: AsRef<str>,
22416 {
22417 self._scopes.insert(String::from(scope.as_ref()));
22418 self
22419 }
22420 /// Identifies the authorization scope(s) for the method you are building.
22421 ///
22422 /// See [`Self::add_scope()`] for details.
22423 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationMeshRouteViewListCall<'a, C>
22424 where
22425 I: IntoIterator<Item = St>,
22426 St: AsRef<str>,
22427 {
22428 self._scopes
22429 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22430 self
22431 }
22432
22433 /// Removes all scopes, and no default scope will be used either.
22434 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22435 /// for details).
22436 pub fn clear_scopes(mut self) -> ProjectLocationMeshRouteViewListCall<'a, C> {
22437 self._scopes.clear();
22438 self
22439 }
22440}
22441
22442/// Creates a new Mesh in a given project and location.
22443///
22444/// A builder for the *locations.meshes.create* method supported by a *project* resource.
22445/// It is not used directly, but through a [`ProjectMethods`] instance.
22446///
22447/// # Example
22448///
22449/// Instantiate a resource method builder
22450///
22451/// ```test_harness,no_run
22452/// # extern crate hyper;
22453/// # extern crate hyper_rustls;
22454/// # extern crate google_networkservices1 as networkservices1;
22455/// use networkservices1::api::Mesh;
22456/// # async fn dox() {
22457/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22458///
22459/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22460/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
22461/// # .with_native_roots()
22462/// # .unwrap()
22463/// # .https_only()
22464/// # .enable_http2()
22465/// # .build();
22466///
22467/// # let executor = hyper_util::rt::TokioExecutor::new();
22468/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
22469/// # secret,
22470/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22471/// # yup_oauth2::client::CustomHyperClientBuilder::from(
22472/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
22473/// # ),
22474/// # ).build().await.unwrap();
22475///
22476/// # let client = hyper_util::client::legacy::Client::builder(
22477/// # hyper_util::rt::TokioExecutor::new()
22478/// # )
22479/// # .build(
22480/// # hyper_rustls::HttpsConnectorBuilder::new()
22481/// # .with_native_roots()
22482/// # .unwrap()
22483/// # .https_or_http()
22484/// # .enable_http2()
22485/// # .build()
22486/// # );
22487/// # let mut hub = NetworkServices::new(client, auth);
22488/// // As the method needs a request, you would usually fill it with the desired information
22489/// // into the respective structure. Some of the parts shown here might not be applicable !
22490/// // Values shown here are possibly random and not representative !
22491/// let mut req = Mesh::default();
22492///
22493/// // You can configure optional parameters by calling the respective setters at will, and
22494/// // execute the final call using `doit()`.
22495/// // Values shown here are possibly random and not representative !
22496/// let result = hub.projects().locations_meshes_create(req, "parent")
22497/// .mesh_id("no")
22498/// .doit().await;
22499/// # }
22500/// ```
22501pub struct ProjectLocationMeshCreateCall<'a, C>
22502where
22503 C: 'a,
22504{
22505 hub: &'a NetworkServices<C>,
22506 _request: Mesh,
22507 _parent: String,
22508 _mesh_id: Option<String>,
22509 _delegate: Option<&'a mut dyn common::Delegate>,
22510 _additional_params: HashMap<String, String>,
22511 _scopes: BTreeSet<String>,
22512}
22513
22514impl<'a, C> common::CallBuilder for ProjectLocationMeshCreateCall<'a, C> {}
22515
22516impl<'a, C> ProjectLocationMeshCreateCall<'a, C>
22517where
22518 C: common::Connector,
22519{
22520 /// Perform the operation you have build so far.
22521 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
22522 use std::borrow::Cow;
22523 use std::io::{Read, Seek};
22524
22525 use common::{url::Params, ToParts};
22526 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22527
22528 let mut dd = common::DefaultDelegate;
22529 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22530 dlg.begin(common::MethodInfo {
22531 id: "networkservices.projects.locations.meshes.create",
22532 http_method: hyper::Method::POST,
22533 });
22534
22535 for &field in ["alt", "parent", "meshId"].iter() {
22536 if self._additional_params.contains_key(field) {
22537 dlg.finished(false);
22538 return Err(common::Error::FieldClash(field));
22539 }
22540 }
22541
22542 let mut params = Params::with_capacity(5 + self._additional_params.len());
22543 params.push("parent", self._parent);
22544 if let Some(value) = self._mesh_id.as_ref() {
22545 params.push("meshId", value);
22546 }
22547
22548 params.extend(self._additional_params.iter());
22549
22550 params.push("alt", "json");
22551 let mut url = self.hub._base_url.clone() + "v1/{+parent}/meshes";
22552 if self._scopes.is_empty() {
22553 self._scopes
22554 .insert(Scope::CloudPlatform.as_ref().to_string());
22555 }
22556
22557 #[allow(clippy::single_element_loop)]
22558 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
22559 url = params.uri_replacement(url, param_name, find_this, true);
22560 }
22561 {
22562 let to_remove = ["parent"];
22563 params.remove_params(&to_remove);
22564 }
22565
22566 let url = params.parse_with_url(&url);
22567
22568 let mut json_mime_type = mime::APPLICATION_JSON;
22569 let mut request_value_reader = {
22570 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
22571 common::remove_json_null_values(&mut value);
22572 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
22573 serde_json::to_writer(&mut dst, &value).unwrap();
22574 dst
22575 };
22576 let request_size = request_value_reader
22577 .seek(std::io::SeekFrom::End(0))
22578 .unwrap();
22579 request_value_reader
22580 .seek(std::io::SeekFrom::Start(0))
22581 .unwrap();
22582
22583 loop {
22584 let token = match self
22585 .hub
22586 .auth
22587 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22588 .await
22589 {
22590 Ok(token) => token,
22591 Err(e) => match dlg.token(e) {
22592 Ok(token) => token,
22593 Err(e) => {
22594 dlg.finished(false);
22595 return Err(common::Error::MissingToken(e));
22596 }
22597 },
22598 };
22599 request_value_reader
22600 .seek(std::io::SeekFrom::Start(0))
22601 .unwrap();
22602 let mut req_result = {
22603 let client = &self.hub.client;
22604 dlg.pre_request();
22605 let mut req_builder = hyper::Request::builder()
22606 .method(hyper::Method::POST)
22607 .uri(url.as_str())
22608 .header(USER_AGENT, self.hub._user_agent.clone());
22609
22610 if let Some(token) = token.as_ref() {
22611 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22612 }
22613
22614 let request = req_builder
22615 .header(CONTENT_TYPE, json_mime_type.to_string())
22616 .header(CONTENT_LENGTH, request_size as u64)
22617 .body(common::to_body(
22618 request_value_reader.get_ref().clone().into(),
22619 ));
22620
22621 client.request(request.unwrap()).await
22622 };
22623
22624 match req_result {
22625 Err(err) => {
22626 if let common::Retry::After(d) = dlg.http_error(&err) {
22627 sleep(d).await;
22628 continue;
22629 }
22630 dlg.finished(false);
22631 return Err(common::Error::HttpError(err));
22632 }
22633 Ok(res) => {
22634 let (mut parts, body) = res.into_parts();
22635 let mut body = common::Body::new(body);
22636 if !parts.status.is_success() {
22637 let bytes = common::to_bytes(body).await.unwrap_or_default();
22638 let error = serde_json::from_str(&common::to_string(&bytes));
22639 let response = common::to_response(parts, bytes.into());
22640
22641 if let common::Retry::After(d) =
22642 dlg.http_failure(&response, error.as_ref().ok())
22643 {
22644 sleep(d).await;
22645 continue;
22646 }
22647
22648 dlg.finished(false);
22649
22650 return Err(match error {
22651 Ok(value) => common::Error::BadRequest(value),
22652 _ => common::Error::Failure(response),
22653 });
22654 }
22655 let response = {
22656 let bytes = common::to_bytes(body).await.unwrap_or_default();
22657 let encoded = common::to_string(&bytes);
22658 match serde_json::from_str(&encoded) {
22659 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22660 Err(error) => {
22661 dlg.response_json_decode_error(&encoded, &error);
22662 return Err(common::Error::JsonDecodeError(
22663 encoded.to_string(),
22664 error,
22665 ));
22666 }
22667 }
22668 };
22669
22670 dlg.finished(true);
22671 return Ok(response);
22672 }
22673 }
22674 }
22675 }
22676
22677 ///
22678 /// Sets the *request* property to the given value.
22679 ///
22680 /// Even though the property as already been set when instantiating this call,
22681 /// we provide this method for API completeness.
22682 pub fn request(mut self, new_value: Mesh) -> ProjectLocationMeshCreateCall<'a, C> {
22683 self._request = new_value;
22684 self
22685 }
22686 /// Required. The parent resource of the Mesh. Must be in the format `projects/*/locations/*`.
22687 ///
22688 /// Sets the *parent* path property to the given value.
22689 ///
22690 /// Even though the property as already been set when instantiating this call,
22691 /// we provide this method for API completeness.
22692 pub fn parent(mut self, new_value: &str) -> ProjectLocationMeshCreateCall<'a, C> {
22693 self._parent = new_value.to_string();
22694 self
22695 }
22696 /// Required. Short name of the Mesh resource to be created.
22697 ///
22698 /// Sets the *mesh id* query property to the given value.
22699 pub fn mesh_id(mut self, new_value: &str) -> ProjectLocationMeshCreateCall<'a, C> {
22700 self._mesh_id = Some(new_value.to_string());
22701 self
22702 }
22703 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22704 /// while executing the actual API request.
22705 ///
22706 /// ````text
22707 /// It should be used to handle progress information, and to implement a certain level of resilience.
22708 /// ````
22709 ///
22710 /// Sets the *delegate* property to the given value.
22711 pub fn delegate(
22712 mut self,
22713 new_value: &'a mut dyn common::Delegate,
22714 ) -> ProjectLocationMeshCreateCall<'a, C> {
22715 self._delegate = Some(new_value);
22716 self
22717 }
22718
22719 /// Set any additional parameter of the query string used in the request.
22720 /// It should be used to set parameters which are not yet available through their own
22721 /// setters.
22722 ///
22723 /// Please note that this method must not be used to set any of the known parameters
22724 /// which have their own setter method. If done anyway, the request will fail.
22725 ///
22726 /// # Additional Parameters
22727 ///
22728 /// * *$.xgafv* (query-string) - V1 error format.
22729 /// * *access_token* (query-string) - OAuth access token.
22730 /// * *alt* (query-string) - Data format for response.
22731 /// * *callback* (query-string) - JSONP
22732 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22733 /// * *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.
22734 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22735 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22736 /// * *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.
22737 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22738 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22739 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationMeshCreateCall<'a, C>
22740 where
22741 T: AsRef<str>,
22742 {
22743 self._additional_params
22744 .insert(name.as_ref().to_string(), value.as_ref().to_string());
22745 self
22746 }
22747
22748 /// Identifies the authorization scope for the method you are building.
22749 ///
22750 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22751 /// [`Scope::CloudPlatform`].
22752 ///
22753 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22754 /// tokens for more than one scope.
22755 ///
22756 /// Usually there is more than one suitable scope to authorize an operation, some of which may
22757 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22758 /// sufficient, a read-write scope will do as well.
22759 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationMeshCreateCall<'a, C>
22760 where
22761 St: AsRef<str>,
22762 {
22763 self._scopes.insert(String::from(scope.as_ref()));
22764 self
22765 }
22766 /// Identifies the authorization scope(s) for the method you are building.
22767 ///
22768 /// See [`Self::add_scope()`] for details.
22769 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationMeshCreateCall<'a, C>
22770 where
22771 I: IntoIterator<Item = St>,
22772 St: AsRef<str>,
22773 {
22774 self._scopes
22775 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22776 self
22777 }
22778
22779 /// Removes all scopes, and no default scope will be used either.
22780 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22781 /// for details).
22782 pub fn clear_scopes(mut self) -> ProjectLocationMeshCreateCall<'a, C> {
22783 self._scopes.clear();
22784 self
22785 }
22786}
22787
22788/// Deletes a single Mesh.
22789///
22790/// A builder for the *locations.meshes.delete* method supported by a *project* resource.
22791/// It is not used directly, but through a [`ProjectMethods`] instance.
22792///
22793/// # Example
22794///
22795/// Instantiate a resource method builder
22796///
22797/// ```test_harness,no_run
22798/// # extern crate hyper;
22799/// # extern crate hyper_rustls;
22800/// # extern crate google_networkservices1 as networkservices1;
22801/// # async fn dox() {
22802/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22803///
22804/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22805/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
22806/// # .with_native_roots()
22807/// # .unwrap()
22808/// # .https_only()
22809/// # .enable_http2()
22810/// # .build();
22811///
22812/// # let executor = hyper_util::rt::TokioExecutor::new();
22813/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
22814/// # secret,
22815/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22816/// # yup_oauth2::client::CustomHyperClientBuilder::from(
22817/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
22818/// # ),
22819/// # ).build().await.unwrap();
22820///
22821/// # let client = hyper_util::client::legacy::Client::builder(
22822/// # hyper_util::rt::TokioExecutor::new()
22823/// # )
22824/// # .build(
22825/// # hyper_rustls::HttpsConnectorBuilder::new()
22826/// # .with_native_roots()
22827/// # .unwrap()
22828/// # .https_or_http()
22829/// # .enable_http2()
22830/// # .build()
22831/// # );
22832/// # let mut hub = NetworkServices::new(client, auth);
22833/// // You can configure optional parameters by calling the respective setters at will, and
22834/// // execute the final call using `doit()`.
22835/// // Values shown here are possibly random and not representative !
22836/// let result = hub.projects().locations_meshes_delete("name")
22837/// .doit().await;
22838/// # }
22839/// ```
22840pub struct ProjectLocationMeshDeleteCall<'a, C>
22841where
22842 C: 'a,
22843{
22844 hub: &'a NetworkServices<C>,
22845 _name: String,
22846 _delegate: Option<&'a mut dyn common::Delegate>,
22847 _additional_params: HashMap<String, String>,
22848 _scopes: BTreeSet<String>,
22849}
22850
22851impl<'a, C> common::CallBuilder for ProjectLocationMeshDeleteCall<'a, C> {}
22852
22853impl<'a, C> ProjectLocationMeshDeleteCall<'a, C>
22854where
22855 C: common::Connector,
22856{
22857 /// Perform the operation you have build so far.
22858 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
22859 use std::borrow::Cow;
22860 use std::io::{Read, Seek};
22861
22862 use common::{url::Params, ToParts};
22863 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22864
22865 let mut dd = common::DefaultDelegate;
22866 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22867 dlg.begin(common::MethodInfo {
22868 id: "networkservices.projects.locations.meshes.delete",
22869 http_method: hyper::Method::DELETE,
22870 });
22871
22872 for &field in ["alt", "name"].iter() {
22873 if self._additional_params.contains_key(field) {
22874 dlg.finished(false);
22875 return Err(common::Error::FieldClash(field));
22876 }
22877 }
22878
22879 let mut params = Params::with_capacity(3 + self._additional_params.len());
22880 params.push("name", self._name);
22881
22882 params.extend(self._additional_params.iter());
22883
22884 params.push("alt", "json");
22885 let mut url = self.hub._base_url.clone() + "v1/{+name}";
22886 if self._scopes.is_empty() {
22887 self._scopes
22888 .insert(Scope::CloudPlatform.as_ref().to_string());
22889 }
22890
22891 #[allow(clippy::single_element_loop)]
22892 for &(find_this, param_name) in [("{+name}", "name")].iter() {
22893 url = params.uri_replacement(url, param_name, find_this, true);
22894 }
22895 {
22896 let to_remove = ["name"];
22897 params.remove_params(&to_remove);
22898 }
22899
22900 let url = params.parse_with_url(&url);
22901
22902 loop {
22903 let token = match self
22904 .hub
22905 .auth
22906 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22907 .await
22908 {
22909 Ok(token) => token,
22910 Err(e) => match dlg.token(e) {
22911 Ok(token) => token,
22912 Err(e) => {
22913 dlg.finished(false);
22914 return Err(common::Error::MissingToken(e));
22915 }
22916 },
22917 };
22918 let mut req_result = {
22919 let client = &self.hub.client;
22920 dlg.pre_request();
22921 let mut req_builder = hyper::Request::builder()
22922 .method(hyper::Method::DELETE)
22923 .uri(url.as_str())
22924 .header(USER_AGENT, self.hub._user_agent.clone());
22925
22926 if let Some(token) = token.as_ref() {
22927 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22928 }
22929
22930 let request = req_builder
22931 .header(CONTENT_LENGTH, 0_u64)
22932 .body(common::to_body::<String>(None));
22933
22934 client.request(request.unwrap()).await
22935 };
22936
22937 match req_result {
22938 Err(err) => {
22939 if let common::Retry::After(d) = dlg.http_error(&err) {
22940 sleep(d).await;
22941 continue;
22942 }
22943 dlg.finished(false);
22944 return Err(common::Error::HttpError(err));
22945 }
22946 Ok(res) => {
22947 let (mut parts, body) = res.into_parts();
22948 let mut body = common::Body::new(body);
22949 if !parts.status.is_success() {
22950 let bytes = common::to_bytes(body).await.unwrap_or_default();
22951 let error = serde_json::from_str(&common::to_string(&bytes));
22952 let response = common::to_response(parts, bytes.into());
22953
22954 if let common::Retry::After(d) =
22955 dlg.http_failure(&response, error.as_ref().ok())
22956 {
22957 sleep(d).await;
22958 continue;
22959 }
22960
22961 dlg.finished(false);
22962
22963 return Err(match error {
22964 Ok(value) => common::Error::BadRequest(value),
22965 _ => common::Error::Failure(response),
22966 });
22967 }
22968 let response = {
22969 let bytes = common::to_bytes(body).await.unwrap_or_default();
22970 let encoded = common::to_string(&bytes);
22971 match serde_json::from_str(&encoded) {
22972 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22973 Err(error) => {
22974 dlg.response_json_decode_error(&encoded, &error);
22975 return Err(common::Error::JsonDecodeError(
22976 encoded.to_string(),
22977 error,
22978 ));
22979 }
22980 }
22981 };
22982
22983 dlg.finished(true);
22984 return Ok(response);
22985 }
22986 }
22987 }
22988 }
22989
22990 /// Required. A name of the Mesh to delete. Must be in the format `projects/*/locations/*/meshes/*`.
22991 ///
22992 /// Sets the *name* path property to the given value.
22993 ///
22994 /// Even though the property as already been set when instantiating this call,
22995 /// we provide this method for API completeness.
22996 pub fn name(mut self, new_value: &str) -> ProjectLocationMeshDeleteCall<'a, C> {
22997 self._name = new_value.to_string();
22998 self
22999 }
23000 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23001 /// while executing the actual API request.
23002 ///
23003 /// ````text
23004 /// It should be used to handle progress information, and to implement a certain level of resilience.
23005 /// ````
23006 ///
23007 /// Sets the *delegate* property to the given value.
23008 pub fn delegate(
23009 mut self,
23010 new_value: &'a mut dyn common::Delegate,
23011 ) -> ProjectLocationMeshDeleteCall<'a, C> {
23012 self._delegate = Some(new_value);
23013 self
23014 }
23015
23016 /// Set any additional parameter of the query string used in the request.
23017 /// It should be used to set parameters which are not yet available through their own
23018 /// setters.
23019 ///
23020 /// Please note that this method must not be used to set any of the known parameters
23021 /// which have their own setter method. If done anyway, the request will fail.
23022 ///
23023 /// # Additional Parameters
23024 ///
23025 /// * *$.xgafv* (query-string) - V1 error format.
23026 /// * *access_token* (query-string) - OAuth access token.
23027 /// * *alt* (query-string) - Data format for response.
23028 /// * *callback* (query-string) - JSONP
23029 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23030 /// * *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.
23031 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23032 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23033 /// * *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.
23034 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
23035 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
23036 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationMeshDeleteCall<'a, C>
23037 where
23038 T: AsRef<str>,
23039 {
23040 self._additional_params
23041 .insert(name.as_ref().to_string(), value.as_ref().to_string());
23042 self
23043 }
23044
23045 /// Identifies the authorization scope for the method you are building.
23046 ///
23047 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23048 /// [`Scope::CloudPlatform`].
23049 ///
23050 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23051 /// tokens for more than one scope.
23052 ///
23053 /// Usually there is more than one suitable scope to authorize an operation, some of which may
23054 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23055 /// sufficient, a read-write scope will do as well.
23056 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationMeshDeleteCall<'a, C>
23057 where
23058 St: AsRef<str>,
23059 {
23060 self._scopes.insert(String::from(scope.as_ref()));
23061 self
23062 }
23063 /// Identifies the authorization scope(s) for the method you are building.
23064 ///
23065 /// See [`Self::add_scope()`] for details.
23066 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationMeshDeleteCall<'a, C>
23067 where
23068 I: IntoIterator<Item = St>,
23069 St: AsRef<str>,
23070 {
23071 self._scopes
23072 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23073 self
23074 }
23075
23076 /// Removes all scopes, and no default scope will be used either.
23077 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23078 /// for details).
23079 pub fn clear_scopes(mut self) -> ProjectLocationMeshDeleteCall<'a, C> {
23080 self._scopes.clear();
23081 self
23082 }
23083}
23084
23085/// Gets details of a single Mesh.
23086///
23087/// A builder for the *locations.meshes.get* method supported by a *project* resource.
23088/// It is not used directly, but through a [`ProjectMethods`] instance.
23089///
23090/// # Example
23091///
23092/// Instantiate a resource method builder
23093///
23094/// ```test_harness,no_run
23095/// # extern crate hyper;
23096/// # extern crate hyper_rustls;
23097/// # extern crate google_networkservices1 as networkservices1;
23098/// # async fn dox() {
23099/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23100///
23101/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23102/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
23103/// # .with_native_roots()
23104/// # .unwrap()
23105/// # .https_only()
23106/// # .enable_http2()
23107/// # .build();
23108///
23109/// # let executor = hyper_util::rt::TokioExecutor::new();
23110/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
23111/// # secret,
23112/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23113/// # yup_oauth2::client::CustomHyperClientBuilder::from(
23114/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
23115/// # ),
23116/// # ).build().await.unwrap();
23117///
23118/// # let client = hyper_util::client::legacy::Client::builder(
23119/// # hyper_util::rt::TokioExecutor::new()
23120/// # )
23121/// # .build(
23122/// # hyper_rustls::HttpsConnectorBuilder::new()
23123/// # .with_native_roots()
23124/// # .unwrap()
23125/// # .https_or_http()
23126/// # .enable_http2()
23127/// # .build()
23128/// # );
23129/// # let mut hub = NetworkServices::new(client, auth);
23130/// // You can configure optional parameters by calling the respective setters at will, and
23131/// // execute the final call using `doit()`.
23132/// // Values shown here are possibly random and not representative !
23133/// let result = hub.projects().locations_meshes_get("name")
23134/// .doit().await;
23135/// # }
23136/// ```
23137pub struct ProjectLocationMeshGetCall<'a, C>
23138where
23139 C: 'a,
23140{
23141 hub: &'a NetworkServices<C>,
23142 _name: String,
23143 _delegate: Option<&'a mut dyn common::Delegate>,
23144 _additional_params: HashMap<String, String>,
23145 _scopes: BTreeSet<String>,
23146}
23147
23148impl<'a, C> common::CallBuilder for ProjectLocationMeshGetCall<'a, C> {}
23149
23150impl<'a, C> ProjectLocationMeshGetCall<'a, C>
23151where
23152 C: common::Connector,
23153{
23154 /// Perform the operation you have build so far.
23155 pub async fn doit(mut self) -> common::Result<(common::Response, Mesh)> {
23156 use std::borrow::Cow;
23157 use std::io::{Read, Seek};
23158
23159 use common::{url::Params, ToParts};
23160 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23161
23162 let mut dd = common::DefaultDelegate;
23163 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23164 dlg.begin(common::MethodInfo {
23165 id: "networkservices.projects.locations.meshes.get",
23166 http_method: hyper::Method::GET,
23167 });
23168
23169 for &field in ["alt", "name"].iter() {
23170 if self._additional_params.contains_key(field) {
23171 dlg.finished(false);
23172 return Err(common::Error::FieldClash(field));
23173 }
23174 }
23175
23176 let mut params = Params::with_capacity(3 + self._additional_params.len());
23177 params.push("name", self._name);
23178
23179 params.extend(self._additional_params.iter());
23180
23181 params.push("alt", "json");
23182 let mut url = self.hub._base_url.clone() + "v1/{+name}";
23183 if self._scopes.is_empty() {
23184 self._scopes
23185 .insert(Scope::CloudPlatform.as_ref().to_string());
23186 }
23187
23188 #[allow(clippy::single_element_loop)]
23189 for &(find_this, param_name) in [("{+name}", "name")].iter() {
23190 url = params.uri_replacement(url, param_name, find_this, true);
23191 }
23192 {
23193 let to_remove = ["name"];
23194 params.remove_params(&to_remove);
23195 }
23196
23197 let url = params.parse_with_url(&url);
23198
23199 loop {
23200 let token = match self
23201 .hub
23202 .auth
23203 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23204 .await
23205 {
23206 Ok(token) => token,
23207 Err(e) => match dlg.token(e) {
23208 Ok(token) => token,
23209 Err(e) => {
23210 dlg.finished(false);
23211 return Err(common::Error::MissingToken(e));
23212 }
23213 },
23214 };
23215 let mut req_result = {
23216 let client = &self.hub.client;
23217 dlg.pre_request();
23218 let mut req_builder = hyper::Request::builder()
23219 .method(hyper::Method::GET)
23220 .uri(url.as_str())
23221 .header(USER_AGENT, self.hub._user_agent.clone());
23222
23223 if let Some(token) = token.as_ref() {
23224 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23225 }
23226
23227 let request = req_builder
23228 .header(CONTENT_LENGTH, 0_u64)
23229 .body(common::to_body::<String>(None));
23230
23231 client.request(request.unwrap()).await
23232 };
23233
23234 match req_result {
23235 Err(err) => {
23236 if let common::Retry::After(d) = dlg.http_error(&err) {
23237 sleep(d).await;
23238 continue;
23239 }
23240 dlg.finished(false);
23241 return Err(common::Error::HttpError(err));
23242 }
23243 Ok(res) => {
23244 let (mut parts, body) = res.into_parts();
23245 let mut body = common::Body::new(body);
23246 if !parts.status.is_success() {
23247 let bytes = common::to_bytes(body).await.unwrap_or_default();
23248 let error = serde_json::from_str(&common::to_string(&bytes));
23249 let response = common::to_response(parts, bytes.into());
23250
23251 if let common::Retry::After(d) =
23252 dlg.http_failure(&response, error.as_ref().ok())
23253 {
23254 sleep(d).await;
23255 continue;
23256 }
23257
23258 dlg.finished(false);
23259
23260 return Err(match error {
23261 Ok(value) => common::Error::BadRequest(value),
23262 _ => common::Error::Failure(response),
23263 });
23264 }
23265 let response = {
23266 let bytes = common::to_bytes(body).await.unwrap_or_default();
23267 let encoded = common::to_string(&bytes);
23268 match serde_json::from_str(&encoded) {
23269 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23270 Err(error) => {
23271 dlg.response_json_decode_error(&encoded, &error);
23272 return Err(common::Error::JsonDecodeError(
23273 encoded.to_string(),
23274 error,
23275 ));
23276 }
23277 }
23278 };
23279
23280 dlg.finished(true);
23281 return Ok(response);
23282 }
23283 }
23284 }
23285 }
23286
23287 /// Required. A name of the Mesh to get. Must be in the format `projects/*/locations/*/meshes/*`.
23288 ///
23289 /// Sets the *name* path property to the given value.
23290 ///
23291 /// Even though the property as already been set when instantiating this call,
23292 /// we provide this method for API completeness.
23293 pub fn name(mut self, new_value: &str) -> ProjectLocationMeshGetCall<'a, C> {
23294 self._name = new_value.to_string();
23295 self
23296 }
23297 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23298 /// while executing the actual API request.
23299 ///
23300 /// ````text
23301 /// It should be used to handle progress information, and to implement a certain level of resilience.
23302 /// ````
23303 ///
23304 /// Sets the *delegate* property to the given value.
23305 pub fn delegate(
23306 mut self,
23307 new_value: &'a mut dyn common::Delegate,
23308 ) -> ProjectLocationMeshGetCall<'a, C> {
23309 self._delegate = Some(new_value);
23310 self
23311 }
23312
23313 /// Set any additional parameter of the query string used in the request.
23314 /// It should be used to set parameters which are not yet available through their own
23315 /// setters.
23316 ///
23317 /// Please note that this method must not be used to set any of the known parameters
23318 /// which have their own setter method. If done anyway, the request will fail.
23319 ///
23320 /// # Additional Parameters
23321 ///
23322 /// * *$.xgafv* (query-string) - V1 error format.
23323 /// * *access_token* (query-string) - OAuth access token.
23324 /// * *alt* (query-string) - Data format for response.
23325 /// * *callback* (query-string) - JSONP
23326 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23327 /// * *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.
23328 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23329 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23330 /// * *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.
23331 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
23332 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
23333 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationMeshGetCall<'a, C>
23334 where
23335 T: AsRef<str>,
23336 {
23337 self._additional_params
23338 .insert(name.as_ref().to_string(), value.as_ref().to_string());
23339 self
23340 }
23341
23342 /// Identifies the authorization scope for the method you are building.
23343 ///
23344 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23345 /// [`Scope::CloudPlatform`].
23346 ///
23347 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23348 /// tokens for more than one scope.
23349 ///
23350 /// Usually there is more than one suitable scope to authorize an operation, some of which may
23351 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23352 /// sufficient, a read-write scope will do as well.
23353 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationMeshGetCall<'a, C>
23354 where
23355 St: AsRef<str>,
23356 {
23357 self._scopes.insert(String::from(scope.as_ref()));
23358 self
23359 }
23360 /// Identifies the authorization scope(s) for the method you are building.
23361 ///
23362 /// See [`Self::add_scope()`] for details.
23363 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationMeshGetCall<'a, C>
23364 where
23365 I: IntoIterator<Item = St>,
23366 St: AsRef<str>,
23367 {
23368 self._scopes
23369 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23370 self
23371 }
23372
23373 /// Removes all scopes, and no default scope will be used either.
23374 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23375 /// for details).
23376 pub fn clear_scopes(mut self) -> ProjectLocationMeshGetCall<'a, C> {
23377 self._scopes.clear();
23378 self
23379 }
23380}
23381
23382/// Lists Meshes in a given project and location.
23383///
23384/// A builder for the *locations.meshes.list* method supported by a *project* resource.
23385/// It is not used directly, but through a [`ProjectMethods`] instance.
23386///
23387/// # Example
23388///
23389/// Instantiate a resource method builder
23390///
23391/// ```test_harness,no_run
23392/// # extern crate hyper;
23393/// # extern crate hyper_rustls;
23394/// # extern crate google_networkservices1 as networkservices1;
23395/// # async fn dox() {
23396/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23397///
23398/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23399/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
23400/// # .with_native_roots()
23401/// # .unwrap()
23402/// # .https_only()
23403/// # .enable_http2()
23404/// # .build();
23405///
23406/// # let executor = hyper_util::rt::TokioExecutor::new();
23407/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
23408/// # secret,
23409/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23410/// # yup_oauth2::client::CustomHyperClientBuilder::from(
23411/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
23412/// # ),
23413/// # ).build().await.unwrap();
23414///
23415/// # let client = hyper_util::client::legacy::Client::builder(
23416/// # hyper_util::rt::TokioExecutor::new()
23417/// # )
23418/// # .build(
23419/// # hyper_rustls::HttpsConnectorBuilder::new()
23420/// # .with_native_roots()
23421/// # .unwrap()
23422/// # .https_or_http()
23423/// # .enable_http2()
23424/// # .build()
23425/// # );
23426/// # let mut hub = NetworkServices::new(client, auth);
23427/// // You can configure optional parameters by calling the respective setters at will, and
23428/// // execute the final call using `doit()`.
23429/// // Values shown here are possibly random and not representative !
23430/// let result = hub.projects().locations_meshes_list("parent")
23431/// .return_partial_success(true)
23432/// .page_token("nonumy")
23433/// .page_size(-77)
23434/// .doit().await;
23435/// # }
23436/// ```
23437pub struct ProjectLocationMeshListCall<'a, C>
23438where
23439 C: 'a,
23440{
23441 hub: &'a NetworkServices<C>,
23442 _parent: String,
23443 _return_partial_success: Option<bool>,
23444 _page_token: Option<String>,
23445 _page_size: Option<i32>,
23446 _delegate: Option<&'a mut dyn common::Delegate>,
23447 _additional_params: HashMap<String, String>,
23448 _scopes: BTreeSet<String>,
23449}
23450
23451impl<'a, C> common::CallBuilder for ProjectLocationMeshListCall<'a, C> {}
23452
23453impl<'a, C> ProjectLocationMeshListCall<'a, C>
23454where
23455 C: common::Connector,
23456{
23457 /// Perform the operation you have build so far.
23458 pub async fn doit(mut self) -> common::Result<(common::Response, ListMeshesResponse)> {
23459 use std::borrow::Cow;
23460 use std::io::{Read, Seek};
23461
23462 use common::{url::Params, ToParts};
23463 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23464
23465 let mut dd = common::DefaultDelegate;
23466 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23467 dlg.begin(common::MethodInfo {
23468 id: "networkservices.projects.locations.meshes.list",
23469 http_method: hyper::Method::GET,
23470 });
23471
23472 for &field in [
23473 "alt",
23474 "parent",
23475 "returnPartialSuccess",
23476 "pageToken",
23477 "pageSize",
23478 ]
23479 .iter()
23480 {
23481 if self._additional_params.contains_key(field) {
23482 dlg.finished(false);
23483 return Err(common::Error::FieldClash(field));
23484 }
23485 }
23486
23487 let mut params = Params::with_capacity(6 + self._additional_params.len());
23488 params.push("parent", self._parent);
23489 if let Some(value) = self._return_partial_success.as_ref() {
23490 params.push("returnPartialSuccess", value.to_string());
23491 }
23492 if let Some(value) = self._page_token.as_ref() {
23493 params.push("pageToken", value);
23494 }
23495 if let Some(value) = self._page_size.as_ref() {
23496 params.push("pageSize", value.to_string());
23497 }
23498
23499 params.extend(self._additional_params.iter());
23500
23501 params.push("alt", "json");
23502 let mut url = self.hub._base_url.clone() + "v1/{+parent}/meshes";
23503 if self._scopes.is_empty() {
23504 self._scopes
23505 .insert(Scope::CloudPlatform.as_ref().to_string());
23506 }
23507
23508 #[allow(clippy::single_element_loop)]
23509 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
23510 url = params.uri_replacement(url, param_name, find_this, true);
23511 }
23512 {
23513 let to_remove = ["parent"];
23514 params.remove_params(&to_remove);
23515 }
23516
23517 let url = params.parse_with_url(&url);
23518
23519 loop {
23520 let token = match self
23521 .hub
23522 .auth
23523 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23524 .await
23525 {
23526 Ok(token) => token,
23527 Err(e) => match dlg.token(e) {
23528 Ok(token) => token,
23529 Err(e) => {
23530 dlg.finished(false);
23531 return Err(common::Error::MissingToken(e));
23532 }
23533 },
23534 };
23535 let mut req_result = {
23536 let client = &self.hub.client;
23537 dlg.pre_request();
23538 let mut req_builder = hyper::Request::builder()
23539 .method(hyper::Method::GET)
23540 .uri(url.as_str())
23541 .header(USER_AGENT, self.hub._user_agent.clone());
23542
23543 if let Some(token) = token.as_ref() {
23544 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23545 }
23546
23547 let request = req_builder
23548 .header(CONTENT_LENGTH, 0_u64)
23549 .body(common::to_body::<String>(None));
23550
23551 client.request(request.unwrap()).await
23552 };
23553
23554 match req_result {
23555 Err(err) => {
23556 if let common::Retry::After(d) = dlg.http_error(&err) {
23557 sleep(d).await;
23558 continue;
23559 }
23560 dlg.finished(false);
23561 return Err(common::Error::HttpError(err));
23562 }
23563 Ok(res) => {
23564 let (mut parts, body) = res.into_parts();
23565 let mut body = common::Body::new(body);
23566 if !parts.status.is_success() {
23567 let bytes = common::to_bytes(body).await.unwrap_or_default();
23568 let error = serde_json::from_str(&common::to_string(&bytes));
23569 let response = common::to_response(parts, bytes.into());
23570
23571 if let common::Retry::After(d) =
23572 dlg.http_failure(&response, error.as_ref().ok())
23573 {
23574 sleep(d).await;
23575 continue;
23576 }
23577
23578 dlg.finished(false);
23579
23580 return Err(match error {
23581 Ok(value) => common::Error::BadRequest(value),
23582 _ => common::Error::Failure(response),
23583 });
23584 }
23585 let response = {
23586 let bytes = common::to_bytes(body).await.unwrap_or_default();
23587 let encoded = common::to_string(&bytes);
23588 match serde_json::from_str(&encoded) {
23589 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23590 Err(error) => {
23591 dlg.response_json_decode_error(&encoded, &error);
23592 return Err(common::Error::JsonDecodeError(
23593 encoded.to_string(),
23594 error,
23595 ));
23596 }
23597 }
23598 };
23599
23600 dlg.finished(true);
23601 return Ok(response);
23602 }
23603 }
23604 }
23605 }
23606
23607 /// Required. The project and location from which the Meshes should be listed, specified in the format `projects/*/locations/*`.
23608 ///
23609 /// Sets the *parent* path property to the given value.
23610 ///
23611 /// Even though the property as already been set when instantiating this call,
23612 /// we provide this method for API completeness.
23613 pub fn parent(mut self, new_value: &str) -> ProjectLocationMeshListCall<'a, C> {
23614 self._parent = new_value.to_string();
23615 self
23616 }
23617 /// Optional. If true, allow partial responses for multi-regional Aggregated List requests. Otherwise if one of the locations is down or unreachable, the Aggregated List request will fail.
23618 ///
23619 /// Sets the *return partial success* query property to the given value.
23620 pub fn return_partial_success(mut self, new_value: bool) -> ProjectLocationMeshListCall<'a, C> {
23621 self._return_partial_success = Some(new_value);
23622 self
23623 }
23624 /// The value returned by the last `ListMeshesResponse` Indicates that this is a continuation of a prior `ListMeshes` call, and that the system should return the next page of data.
23625 ///
23626 /// Sets the *page token* query property to the given value.
23627 pub fn page_token(mut self, new_value: &str) -> ProjectLocationMeshListCall<'a, C> {
23628 self._page_token = Some(new_value.to_string());
23629 self
23630 }
23631 /// Maximum number of Meshes to return per call.
23632 ///
23633 /// Sets the *page size* query property to the given value.
23634 pub fn page_size(mut self, new_value: i32) -> ProjectLocationMeshListCall<'a, C> {
23635 self._page_size = Some(new_value);
23636 self
23637 }
23638 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23639 /// while executing the actual API request.
23640 ///
23641 /// ````text
23642 /// It should be used to handle progress information, and to implement a certain level of resilience.
23643 /// ````
23644 ///
23645 /// Sets the *delegate* property to the given value.
23646 pub fn delegate(
23647 mut self,
23648 new_value: &'a mut dyn common::Delegate,
23649 ) -> ProjectLocationMeshListCall<'a, C> {
23650 self._delegate = Some(new_value);
23651 self
23652 }
23653
23654 /// Set any additional parameter of the query string used in the request.
23655 /// It should be used to set parameters which are not yet available through their own
23656 /// setters.
23657 ///
23658 /// Please note that this method must not be used to set any of the known parameters
23659 /// which have their own setter method. If done anyway, the request will fail.
23660 ///
23661 /// # Additional Parameters
23662 ///
23663 /// * *$.xgafv* (query-string) - V1 error format.
23664 /// * *access_token* (query-string) - OAuth access token.
23665 /// * *alt* (query-string) - Data format for response.
23666 /// * *callback* (query-string) - JSONP
23667 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23668 /// * *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.
23669 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23670 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23671 /// * *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.
23672 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
23673 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
23674 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationMeshListCall<'a, C>
23675 where
23676 T: AsRef<str>,
23677 {
23678 self._additional_params
23679 .insert(name.as_ref().to_string(), value.as_ref().to_string());
23680 self
23681 }
23682
23683 /// Identifies the authorization scope for the method you are building.
23684 ///
23685 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23686 /// [`Scope::CloudPlatform`].
23687 ///
23688 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23689 /// tokens for more than one scope.
23690 ///
23691 /// Usually there is more than one suitable scope to authorize an operation, some of which may
23692 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23693 /// sufficient, a read-write scope will do as well.
23694 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationMeshListCall<'a, C>
23695 where
23696 St: AsRef<str>,
23697 {
23698 self._scopes.insert(String::from(scope.as_ref()));
23699 self
23700 }
23701 /// Identifies the authorization scope(s) for the method you are building.
23702 ///
23703 /// See [`Self::add_scope()`] for details.
23704 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationMeshListCall<'a, C>
23705 where
23706 I: IntoIterator<Item = St>,
23707 St: AsRef<str>,
23708 {
23709 self._scopes
23710 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23711 self
23712 }
23713
23714 /// Removes all scopes, and no default scope will be used either.
23715 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23716 /// for details).
23717 pub fn clear_scopes(mut self) -> ProjectLocationMeshListCall<'a, C> {
23718 self._scopes.clear();
23719 self
23720 }
23721}
23722
23723/// Updates the parameters of a single Mesh.
23724///
23725/// A builder for the *locations.meshes.patch* method supported by a *project* resource.
23726/// It is not used directly, but through a [`ProjectMethods`] instance.
23727///
23728/// # Example
23729///
23730/// Instantiate a resource method builder
23731///
23732/// ```test_harness,no_run
23733/// # extern crate hyper;
23734/// # extern crate hyper_rustls;
23735/// # extern crate google_networkservices1 as networkservices1;
23736/// use networkservices1::api::Mesh;
23737/// # async fn dox() {
23738/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23739///
23740/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23741/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
23742/// # .with_native_roots()
23743/// # .unwrap()
23744/// # .https_only()
23745/// # .enable_http2()
23746/// # .build();
23747///
23748/// # let executor = hyper_util::rt::TokioExecutor::new();
23749/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
23750/// # secret,
23751/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23752/// # yup_oauth2::client::CustomHyperClientBuilder::from(
23753/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
23754/// # ),
23755/// # ).build().await.unwrap();
23756///
23757/// # let client = hyper_util::client::legacy::Client::builder(
23758/// # hyper_util::rt::TokioExecutor::new()
23759/// # )
23760/// # .build(
23761/// # hyper_rustls::HttpsConnectorBuilder::new()
23762/// # .with_native_roots()
23763/// # .unwrap()
23764/// # .https_or_http()
23765/// # .enable_http2()
23766/// # .build()
23767/// # );
23768/// # let mut hub = NetworkServices::new(client, auth);
23769/// // As the method needs a request, you would usually fill it with the desired information
23770/// // into the respective structure. Some of the parts shown here might not be applicable !
23771/// // Values shown here are possibly random and not representative !
23772/// let mut req = Mesh::default();
23773///
23774/// // You can configure optional parameters by calling the respective setters at will, and
23775/// // execute the final call using `doit()`.
23776/// // Values shown here are possibly random and not representative !
23777/// let result = hub.projects().locations_meshes_patch(req, "name")
23778/// .update_mask(FieldMask::new::<&str>(&[]))
23779/// .doit().await;
23780/// # }
23781/// ```
23782pub struct ProjectLocationMeshPatchCall<'a, C>
23783where
23784 C: 'a,
23785{
23786 hub: &'a NetworkServices<C>,
23787 _request: Mesh,
23788 _name: String,
23789 _update_mask: Option<common::FieldMask>,
23790 _delegate: Option<&'a mut dyn common::Delegate>,
23791 _additional_params: HashMap<String, String>,
23792 _scopes: BTreeSet<String>,
23793}
23794
23795impl<'a, C> common::CallBuilder for ProjectLocationMeshPatchCall<'a, C> {}
23796
23797impl<'a, C> ProjectLocationMeshPatchCall<'a, C>
23798where
23799 C: common::Connector,
23800{
23801 /// Perform the operation you have build so far.
23802 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
23803 use std::borrow::Cow;
23804 use std::io::{Read, Seek};
23805
23806 use common::{url::Params, ToParts};
23807 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23808
23809 let mut dd = common::DefaultDelegate;
23810 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23811 dlg.begin(common::MethodInfo {
23812 id: "networkservices.projects.locations.meshes.patch",
23813 http_method: hyper::Method::PATCH,
23814 });
23815
23816 for &field in ["alt", "name", "updateMask"].iter() {
23817 if self._additional_params.contains_key(field) {
23818 dlg.finished(false);
23819 return Err(common::Error::FieldClash(field));
23820 }
23821 }
23822
23823 let mut params = Params::with_capacity(5 + self._additional_params.len());
23824 params.push("name", self._name);
23825 if let Some(value) = self._update_mask.as_ref() {
23826 params.push("updateMask", value.to_string());
23827 }
23828
23829 params.extend(self._additional_params.iter());
23830
23831 params.push("alt", "json");
23832 let mut url = self.hub._base_url.clone() + "v1/{+name}";
23833 if self._scopes.is_empty() {
23834 self._scopes
23835 .insert(Scope::CloudPlatform.as_ref().to_string());
23836 }
23837
23838 #[allow(clippy::single_element_loop)]
23839 for &(find_this, param_name) in [("{+name}", "name")].iter() {
23840 url = params.uri_replacement(url, param_name, find_this, true);
23841 }
23842 {
23843 let to_remove = ["name"];
23844 params.remove_params(&to_remove);
23845 }
23846
23847 let url = params.parse_with_url(&url);
23848
23849 let mut json_mime_type = mime::APPLICATION_JSON;
23850 let mut request_value_reader = {
23851 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
23852 common::remove_json_null_values(&mut value);
23853 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
23854 serde_json::to_writer(&mut dst, &value).unwrap();
23855 dst
23856 };
23857 let request_size = request_value_reader
23858 .seek(std::io::SeekFrom::End(0))
23859 .unwrap();
23860 request_value_reader
23861 .seek(std::io::SeekFrom::Start(0))
23862 .unwrap();
23863
23864 loop {
23865 let token = match self
23866 .hub
23867 .auth
23868 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23869 .await
23870 {
23871 Ok(token) => token,
23872 Err(e) => match dlg.token(e) {
23873 Ok(token) => token,
23874 Err(e) => {
23875 dlg.finished(false);
23876 return Err(common::Error::MissingToken(e));
23877 }
23878 },
23879 };
23880 request_value_reader
23881 .seek(std::io::SeekFrom::Start(0))
23882 .unwrap();
23883 let mut req_result = {
23884 let client = &self.hub.client;
23885 dlg.pre_request();
23886 let mut req_builder = hyper::Request::builder()
23887 .method(hyper::Method::PATCH)
23888 .uri(url.as_str())
23889 .header(USER_AGENT, self.hub._user_agent.clone());
23890
23891 if let Some(token) = token.as_ref() {
23892 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23893 }
23894
23895 let request = req_builder
23896 .header(CONTENT_TYPE, json_mime_type.to_string())
23897 .header(CONTENT_LENGTH, request_size as u64)
23898 .body(common::to_body(
23899 request_value_reader.get_ref().clone().into(),
23900 ));
23901
23902 client.request(request.unwrap()).await
23903 };
23904
23905 match req_result {
23906 Err(err) => {
23907 if let common::Retry::After(d) = dlg.http_error(&err) {
23908 sleep(d).await;
23909 continue;
23910 }
23911 dlg.finished(false);
23912 return Err(common::Error::HttpError(err));
23913 }
23914 Ok(res) => {
23915 let (mut parts, body) = res.into_parts();
23916 let mut body = common::Body::new(body);
23917 if !parts.status.is_success() {
23918 let bytes = common::to_bytes(body).await.unwrap_or_default();
23919 let error = serde_json::from_str(&common::to_string(&bytes));
23920 let response = common::to_response(parts, bytes.into());
23921
23922 if let common::Retry::After(d) =
23923 dlg.http_failure(&response, error.as_ref().ok())
23924 {
23925 sleep(d).await;
23926 continue;
23927 }
23928
23929 dlg.finished(false);
23930
23931 return Err(match error {
23932 Ok(value) => common::Error::BadRequest(value),
23933 _ => common::Error::Failure(response),
23934 });
23935 }
23936 let response = {
23937 let bytes = common::to_bytes(body).await.unwrap_or_default();
23938 let encoded = common::to_string(&bytes);
23939 match serde_json::from_str(&encoded) {
23940 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23941 Err(error) => {
23942 dlg.response_json_decode_error(&encoded, &error);
23943 return Err(common::Error::JsonDecodeError(
23944 encoded.to_string(),
23945 error,
23946 ));
23947 }
23948 }
23949 };
23950
23951 dlg.finished(true);
23952 return Ok(response);
23953 }
23954 }
23955 }
23956 }
23957
23958 ///
23959 /// Sets the *request* property to the given value.
23960 ///
23961 /// Even though the property as already been set when instantiating this call,
23962 /// we provide this method for API completeness.
23963 pub fn request(mut self, new_value: Mesh) -> ProjectLocationMeshPatchCall<'a, C> {
23964 self._request = new_value;
23965 self
23966 }
23967 /// Identifier. Name of the Mesh resource. It matches pattern `projects/*/locations/*/meshes/`.
23968 ///
23969 /// Sets the *name* path property to the given value.
23970 ///
23971 /// Even though the property as already been set when instantiating this call,
23972 /// we provide this method for API completeness.
23973 pub fn name(mut self, new_value: &str) -> ProjectLocationMeshPatchCall<'a, C> {
23974 self._name = new_value.to_string();
23975 self
23976 }
23977 /// Optional. Field mask is used to specify the fields to be overwritten in the Mesh 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.
23978 ///
23979 /// Sets the *update mask* query property to the given value.
23980 pub fn update_mask(
23981 mut self,
23982 new_value: common::FieldMask,
23983 ) -> ProjectLocationMeshPatchCall<'a, C> {
23984 self._update_mask = Some(new_value);
23985 self
23986 }
23987 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23988 /// while executing the actual API request.
23989 ///
23990 /// ````text
23991 /// It should be used to handle progress information, and to implement a certain level of resilience.
23992 /// ````
23993 ///
23994 /// Sets the *delegate* property to the given value.
23995 pub fn delegate(
23996 mut self,
23997 new_value: &'a mut dyn common::Delegate,
23998 ) -> ProjectLocationMeshPatchCall<'a, C> {
23999 self._delegate = Some(new_value);
24000 self
24001 }
24002
24003 /// Set any additional parameter of the query string used in the request.
24004 /// It should be used to set parameters which are not yet available through their own
24005 /// setters.
24006 ///
24007 /// Please note that this method must not be used to set any of the known parameters
24008 /// which have their own setter method. If done anyway, the request will fail.
24009 ///
24010 /// # Additional Parameters
24011 ///
24012 /// * *$.xgafv* (query-string) - V1 error format.
24013 /// * *access_token* (query-string) - OAuth access token.
24014 /// * *alt* (query-string) - Data format for response.
24015 /// * *callback* (query-string) - JSONP
24016 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24017 /// * *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.
24018 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24019 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24020 /// * *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.
24021 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
24022 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
24023 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationMeshPatchCall<'a, C>
24024 where
24025 T: AsRef<str>,
24026 {
24027 self._additional_params
24028 .insert(name.as_ref().to_string(), value.as_ref().to_string());
24029 self
24030 }
24031
24032 /// Identifies the authorization scope for the method you are building.
24033 ///
24034 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24035 /// [`Scope::CloudPlatform`].
24036 ///
24037 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24038 /// tokens for more than one scope.
24039 ///
24040 /// Usually there is more than one suitable scope to authorize an operation, some of which may
24041 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24042 /// sufficient, a read-write scope will do as well.
24043 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationMeshPatchCall<'a, C>
24044 where
24045 St: AsRef<str>,
24046 {
24047 self._scopes.insert(String::from(scope.as_ref()));
24048 self
24049 }
24050 /// Identifies the authorization scope(s) for the method you are building.
24051 ///
24052 /// See [`Self::add_scope()`] for details.
24053 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationMeshPatchCall<'a, C>
24054 where
24055 I: IntoIterator<Item = St>,
24056 St: AsRef<str>,
24057 {
24058 self._scopes
24059 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24060 self
24061 }
24062
24063 /// Removes all scopes, and no default scope will be used either.
24064 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24065 /// for details).
24066 pub fn clear_scopes(mut self) -> ProjectLocationMeshPatchCall<'a, C> {
24067 self._scopes.clear();
24068 self
24069 }
24070}
24071
24072/// 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`.
24073///
24074/// A builder for the *locations.operations.cancel* method supported by a *project* resource.
24075/// It is not used directly, but through a [`ProjectMethods`] instance.
24076///
24077/// # Example
24078///
24079/// Instantiate a resource method builder
24080///
24081/// ```test_harness,no_run
24082/// # extern crate hyper;
24083/// # extern crate hyper_rustls;
24084/// # extern crate google_networkservices1 as networkservices1;
24085/// use networkservices1::api::CancelOperationRequest;
24086/// # async fn dox() {
24087/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24088///
24089/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
24090/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
24091/// # .with_native_roots()
24092/// # .unwrap()
24093/// # .https_only()
24094/// # .enable_http2()
24095/// # .build();
24096///
24097/// # let executor = hyper_util::rt::TokioExecutor::new();
24098/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
24099/// # secret,
24100/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24101/// # yup_oauth2::client::CustomHyperClientBuilder::from(
24102/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
24103/// # ),
24104/// # ).build().await.unwrap();
24105///
24106/// # let client = hyper_util::client::legacy::Client::builder(
24107/// # hyper_util::rt::TokioExecutor::new()
24108/// # )
24109/// # .build(
24110/// # hyper_rustls::HttpsConnectorBuilder::new()
24111/// # .with_native_roots()
24112/// # .unwrap()
24113/// # .https_or_http()
24114/// # .enable_http2()
24115/// # .build()
24116/// # );
24117/// # let mut hub = NetworkServices::new(client, auth);
24118/// // As the method needs a request, you would usually fill it with the desired information
24119/// // into the respective structure. Some of the parts shown here might not be applicable !
24120/// // Values shown here are possibly random and not representative !
24121/// let mut req = CancelOperationRequest::default();
24122///
24123/// // You can configure optional parameters by calling the respective setters at will, and
24124/// // execute the final call using `doit()`.
24125/// // Values shown here are possibly random and not representative !
24126/// let result = hub.projects().locations_operations_cancel(req, "name")
24127/// .doit().await;
24128/// # }
24129/// ```
24130pub struct ProjectLocationOperationCancelCall<'a, C>
24131where
24132 C: 'a,
24133{
24134 hub: &'a NetworkServices<C>,
24135 _request: CancelOperationRequest,
24136 _name: String,
24137 _delegate: Option<&'a mut dyn common::Delegate>,
24138 _additional_params: HashMap<String, String>,
24139 _scopes: BTreeSet<String>,
24140}
24141
24142impl<'a, C> common::CallBuilder for ProjectLocationOperationCancelCall<'a, C> {}
24143
24144impl<'a, C> ProjectLocationOperationCancelCall<'a, C>
24145where
24146 C: common::Connector,
24147{
24148 /// Perform the operation you have build so far.
24149 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
24150 use std::borrow::Cow;
24151 use std::io::{Read, Seek};
24152
24153 use common::{url::Params, ToParts};
24154 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24155
24156 let mut dd = common::DefaultDelegate;
24157 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24158 dlg.begin(common::MethodInfo {
24159 id: "networkservices.projects.locations.operations.cancel",
24160 http_method: hyper::Method::POST,
24161 });
24162
24163 for &field in ["alt", "name"].iter() {
24164 if self._additional_params.contains_key(field) {
24165 dlg.finished(false);
24166 return Err(common::Error::FieldClash(field));
24167 }
24168 }
24169
24170 let mut params = Params::with_capacity(4 + self._additional_params.len());
24171 params.push("name", self._name);
24172
24173 params.extend(self._additional_params.iter());
24174
24175 params.push("alt", "json");
24176 let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
24177 if self._scopes.is_empty() {
24178 self._scopes
24179 .insert(Scope::CloudPlatform.as_ref().to_string());
24180 }
24181
24182 #[allow(clippy::single_element_loop)]
24183 for &(find_this, param_name) in [("{+name}", "name")].iter() {
24184 url = params.uri_replacement(url, param_name, find_this, true);
24185 }
24186 {
24187 let to_remove = ["name"];
24188 params.remove_params(&to_remove);
24189 }
24190
24191 let url = params.parse_with_url(&url);
24192
24193 let mut json_mime_type = mime::APPLICATION_JSON;
24194 let mut request_value_reader = {
24195 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
24196 common::remove_json_null_values(&mut value);
24197 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
24198 serde_json::to_writer(&mut dst, &value).unwrap();
24199 dst
24200 };
24201 let request_size = request_value_reader
24202 .seek(std::io::SeekFrom::End(0))
24203 .unwrap();
24204 request_value_reader
24205 .seek(std::io::SeekFrom::Start(0))
24206 .unwrap();
24207
24208 loop {
24209 let token = match self
24210 .hub
24211 .auth
24212 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24213 .await
24214 {
24215 Ok(token) => token,
24216 Err(e) => match dlg.token(e) {
24217 Ok(token) => token,
24218 Err(e) => {
24219 dlg.finished(false);
24220 return Err(common::Error::MissingToken(e));
24221 }
24222 },
24223 };
24224 request_value_reader
24225 .seek(std::io::SeekFrom::Start(0))
24226 .unwrap();
24227 let mut req_result = {
24228 let client = &self.hub.client;
24229 dlg.pre_request();
24230 let mut req_builder = hyper::Request::builder()
24231 .method(hyper::Method::POST)
24232 .uri(url.as_str())
24233 .header(USER_AGENT, self.hub._user_agent.clone());
24234
24235 if let Some(token) = token.as_ref() {
24236 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24237 }
24238
24239 let request = req_builder
24240 .header(CONTENT_TYPE, json_mime_type.to_string())
24241 .header(CONTENT_LENGTH, request_size as u64)
24242 .body(common::to_body(
24243 request_value_reader.get_ref().clone().into(),
24244 ));
24245
24246 client.request(request.unwrap()).await
24247 };
24248
24249 match req_result {
24250 Err(err) => {
24251 if let common::Retry::After(d) = dlg.http_error(&err) {
24252 sleep(d).await;
24253 continue;
24254 }
24255 dlg.finished(false);
24256 return Err(common::Error::HttpError(err));
24257 }
24258 Ok(res) => {
24259 let (mut parts, body) = res.into_parts();
24260 let mut body = common::Body::new(body);
24261 if !parts.status.is_success() {
24262 let bytes = common::to_bytes(body).await.unwrap_or_default();
24263 let error = serde_json::from_str(&common::to_string(&bytes));
24264 let response = common::to_response(parts, bytes.into());
24265
24266 if let common::Retry::After(d) =
24267 dlg.http_failure(&response, error.as_ref().ok())
24268 {
24269 sleep(d).await;
24270 continue;
24271 }
24272
24273 dlg.finished(false);
24274
24275 return Err(match error {
24276 Ok(value) => common::Error::BadRequest(value),
24277 _ => common::Error::Failure(response),
24278 });
24279 }
24280 let response = {
24281 let bytes = common::to_bytes(body).await.unwrap_or_default();
24282 let encoded = common::to_string(&bytes);
24283 match serde_json::from_str(&encoded) {
24284 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24285 Err(error) => {
24286 dlg.response_json_decode_error(&encoded, &error);
24287 return Err(common::Error::JsonDecodeError(
24288 encoded.to_string(),
24289 error,
24290 ));
24291 }
24292 }
24293 };
24294
24295 dlg.finished(true);
24296 return Ok(response);
24297 }
24298 }
24299 }
24300 }
24301
24302 ///
24303 /// Sets the *request* property to the given value.
24304 ///
24305 /// Even though the property as already been set when instantiating this call,
24306 /// we provide this method for API completeness.
24307 pub fn request(
24308 mut self,
24309 new_value: CancelOperationRequest,
24310 ) -> ProjectLocationOperationCancelCall<'a, C> {
24311 self._request = new_value;
24312 self
24313 }
24314 /// The name of the operation resource to be cancelled.
24315 ///
24316 /// Sets the *name* path property to the given value.
24317 ///
24318 /// Even though the property as already been set when instantiating this call,
24319 /// we provide this method for API completeness.
24320 pub fn name(mut self, new_value: &str) -> ProjectLocationOperationCancelCall<'a, C> {
24321 self._name = new_value.to_string();
24322 self
24323 }
24324 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24325 /// while executing the actual API request.
24326 ///
24327 /// ````text
24328 /// It should be used to handle progress information, and to implement a certain level of resilience.
24329 /// ````
24330 ///
24331 /// Sets the *delegate* property to the given value.
24332 pub fn delegate(
24333 mut self,
24334 new_value: &'a mut dyn common::Delegate,
24335 ) -> ProjectLocationOperationCancelCall<'a, C> {
24336 self._delegate = Some(new_value);
24337 self
24338 }
24339
24340 /// Set any additional parameter of the query string used in the request.
24341 /// It should be used to set parameters which are not yet available through their own
24342 /// setters.
24343 ///
24344 /// Please note that this method must not be used to set any of the known parameters
24345 /// which have their own setter method. If done anyway, the request will fail.
24346 ///
24347 /// # Additional Parameters
24348 ///
24349 /// * *$.xgafv* (query-string) - V1 error format.
24350 /// * *access_token* (query-string) - OAuth access token.
24351 /// * *alt* (query-string) - Data format for response.
24352 /// * *callback* (query-string) - JSONP
24353 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24354 /// * *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.
24355 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24356 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24357 /// * *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.
24358 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
24359 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
24360 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationCancelCall<'a, C>
24361 where
24362 T: AsRef<str>,
24363 {
24364 self._additional_params
24365 .insert(name.as_ref().to_string(), value.as_ref().to_string());
24366 self
24367 }
24368
24369 /// Identifies the authorization scope for the method you are building.
24370 ///
24371 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24372 /// [`Scope::CloudPlatform`].
24373 ///
24374 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24375 /// tokens for more than one scope.
24376 ///
24377 /// Usually there is more than one suitable scope to authorize an operation, some of which may
24378 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24379 /// sufficient, a read-write scope will do as well.
24380 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationCancelCall<'a, C>
24381 where
24382 St: AsRef<str>,
24383 {
24384 self._scopes.insert(String::from(scope.as_ref()));
24385 self
24386 }
24387 /// Identifies the authorization scope(s) for the method you are building.
24388 ///
24389 /// See [`Self::add_scope()`] for details.
24390 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationCancelCall<'a, C>
24391 where
24392 I: IntoIterator<Item = St>,
24393 St: AsRef<str>,
24394 {
24395 self._scopes
24396 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24397 self
24398 }
24399
24400 /// Removes all scopes, and no default scope will be used either.
24401 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24402 /// for details).
24403 pub fn clear_scopes(mut self) -> ProjectLocationOperationCancelCall<'a, C> {
24404 self._scopes.clear();
24405 self
24406 }
24407}
24408
24409/// 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`.
24410///
24411/// A builder for the *locations.operations.delete* method supported by a *project* resource.
24412/// It is not used directly, but through a [`ProjectMethods`] instance.
24413///
24414/// # Example
24415///
24416/// Instantiate a resource method builder
24417///
24418/// ```test_harness,no_run
24419/// # extern crate hyper;
24420/// # extern crate hyper_rustls;
24421/// # extern crate google_networkservices1 as networkservices1;
24422/// # async fn dox() {
24423/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24424///
24425/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
24426/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
24427/// # .with_native_roots()
24428/// # .unwrap()
24429/// # .https_only()
24430/// # .enable_http2()
24431/// # .build();
24432///
24433/// # let executor = hyper_util::rt::TokioExecutor::new();
24434/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
24435/// # secret,
24436/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24437/// # yup_oauth2::client::CustomHyperClientBuilder::from(
24438/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
24439/// # ),
24440/// # ).build().await.unwrap();
24441///
24442/// # let client = hyper_util::client::legacy::Client::builder(
24443/// # hyper_util::rt::TokioExecutor::new()
24444/// # )
24445/// # .build(
24446/// # hyper_rustls::HttpsConnectorBuilder::new()
24447/// # .with_native_roots()
24448/// # .unwrap()
24449/// # .https_or_http()
24450/// # .enable_http2()
24451/// # .build()
24452/// # );
24453/// # let mut hub = NetworkServices::new(client, auth);
24454/// // You can configure optional parameters by calling the respective setters at will, and
24455/// // execute the final call using `doit()`.
24456/// // Values shown here are possibly random and not representative !
24457/// let result = hub.projects().locations_operations_delete("name")
24458/// .doit().await;
24459/// # }
24460/// ```
24461pub struct ProjectLocationOperationDeleteCall<'a, C>
24462where
24463 C: 'a,
24464{
24465 hub: &'a NetworkServices<C>,
24466 _name: String,
24467 _delegate: Option<&'a mut dyn common::Delegate>,
24468 _additional_params: HashMap<String, String>,
24469 _scopes: BTreeSet<String>,
24470}
24471
24472impl<'a, C> common::CallBuilder for ProjectLocationOperationDeleteCall<'a, C> {}
24473
24474impl<'a, C> ProjectLocationOperationDeleteCall<'a, C>
24475where
24476 C: common::Connector,
24477{
24478 /// Perform the operation you have build so far.
24479 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
24480 use std::borrow::Cow;
24481 use std::io::{Read, Seek};
24482
24483 use common::{url::Params, ToParts};
24484 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24485
24486 let mut dd = common::DefaultDelegate;
24487 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24488 dlg.begin(common::MethodInfo {
24489 id: "networkservices.projects.locations.operations.delete",
24490 http_method: hyper::Method::DELETE,
24491 });
24492
24493 for &field in ["alt", "name"].iter() {
24494 if self._additional_params.contains_key(field) {
24495 dlg.finished(false);
24496 return Err(common::Error::FieldClash(field));
24497 }
24498 }
24499
24500 let mut params = Params::with_capacity(3 + self._additional_params.len());
24501 params.push("name", self._name);
24502
24503 params.extend(self._additional_params.iter());
24504
24505 params.push("alt", "json");
24506 let mut url = self.hub._base_url.clone() + "v1/{+name}";
24507 if self._scopes.is_empty() {
24508 self._scopes
24509 .insert(Scope::CloudPlatform.as_ref().to_string());
24510 }
24511
24512 #[allow(clippy::single_element_loop)]
24513 for &(find_this, param_name) in [("{+name}", "name")].iter() {
24514 url = params.uri_replacement(url, param_name, find_this, true);
24515 }
24516 {
24517 let to_remove = ["name"];
24518 params.remove_params(&to_remove);
24519 }
24520
24521 let url = params.parse_with_url(&url);
24522
24523 loop {
24524 let token = match self
24525 .hub
24526 .auth
24527 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24528 .await
24529 {
24530 Ok(token) => token,
24531 Err(e) => match dlg.token(e) {
24532 Ok(token) => token,
24533 Err(e) => {
24534 dlg.finished(false);
24535 return Err(common::Error::MissingToken(e));
24536 }
24537 },
24538 };
24539 let mut req_result = {
24540 let client = &self.hub.client;
24541 dlg.pre_request();
24542 let mut req_builder = hyper::Request::builder()
24543 .method(hyper::Method::DELETE)
24544 .uri(url.as_str())
24545 .header(USER_AGENT, self.hub._user_agent.clone());
24546
24547 if let Some(token) = token.as_ref() {
24548 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24549 }
24550
24551 let request = req_builder
24552 .header(CONTENT_LENGTH, 0_u64)
24553 .body(common::to_body::<String>(None));
24554
24555 client.request(request.unwrap()).await
24556 };
24557
24558 match req_result {
24559 Err(err) => {
24560 if let common::Retry::After(d) = dlg.http_error(&err) {
24561 sleep(d).await;
24562 continue;
24563 }
24564 dlg.finished(false);
24565 return Err(common::Error::HttpError(err));
24566 }
24567 Ok(res) => {
24568 let (mut parts, body) = res.into_parts();
24569 let mut body = common::Body::new(body);
24570 if !parts.status.is_success() {
24571 let bytes = common::to_bytes(body).await.unwrap_or_default();
24572 let error = serde_json::from_str(&common::to_string(&bytes));
24573 let response = common::to_response(parts, bytes.into());
24574
24575 if let common::Retry::After(d) =
24576 dlg.http_failure(&response, error.as_ref().ok())
24577 {
24578 sleep(d).await;
24579 continue;
24580 }
24581
24582 dlg.finished(false);
24583
24584 return Err(match error {
24585 Ok(value) => common::Error::BadRequest(value),
24586 _ => common::Error::Failure(response),
24587 });
24588 }
24589 let response = {
24590 let bytes = common::to_bytes(body).await.unwrap_or_default();
24591 let encoded = common::to_string(&bytes);
24592 match serde_json::from_str(&encoded) {
24593 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24594 Err(error) => {
24595 dlg.response_json_decode_error(&encoded, &error);
24596 return Err(common::Error::JsonDecodeError(
24597 encoded.to_string(),
24598 error,
24599 ));
24600 }
24601 }
24602 };
24603
24604 dlg.finished(true);
24605 return Ok(response);
24606 }
24607 }
24608 }
24609 }
24610
24611 /// The name of the operation resource to be deleted.
24612 ///
24613 /// Sets the *name* path property to the given value.
24614 ///
24615 /// Even though the property as already been set when instantiating this call,
24616 /// we provide this method for API completeness.
24617 pub fn name(mut self, new_value: &str) -> ProjectLocationOperationDeleteCall<'a, C> {
24618 self._name = new_value.to_string();
24619 self
24620 }
24621 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24622 /// while executing the actual API request.
24623 ///
24624 /// ````text
24625 /// It should be used to handle progress information, and to implement a certain level of resilience.
24626 /// ````
24627 ///
24628 /// Sets the *delegate* property to the given value.
24629 pub fn delegate(
24630 mut self,
24631 new_value: &'a mut dyn common::Delegate,
24632 ) -> ProjectLocationOperationDeleteCall<'a, C> {
24633 self._delegate = Some(new_value);
24634 self
24635 }
24636
24637 /// Set any additional parameter of the query string used in the request.
24638 /// It should be used to set parameters which are not yet available through their own
24639 /// setters.
24640 ///
24641 /// Please note that this method must not be used to set any of the known parameters
24642 /// which have their own setter method. If done anyway, the request will fail.
24643 ///
24644 /// # Additional Parameters
24645 ///
24646 /// * *$.xgafv* (query-string) - V1 error format.
24647 /// * *access_token* (query-string) - OAuth access token.
24648 /// * *alt* (query-string) - Data format for response.
24649 /// * *callback* (query-string) - JSONP
24650 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24651 /// * *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.
24652 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24653 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24654 /// * *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.
24655 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
24656 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
24657 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationDeleteCall<'a, C>
24658 where
24659 T: AsRef<str>,
24660 {
24661 self._additional_params
24662 .insert(name.as_ref().to_string(), value.as_ref().to_string());
24663 self
24664 }
24665
24666 /// Identifies the authorization scope for the method you are building.
24667 ///
24668 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24669 /// [`Scope::CloudPlatform`].
24670 ///
24671 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24672 /// tokens for more than one scope.
24673 ///
24674 /// Usually there is more than one suitable scope to authorize an operation, some of which may
24675 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24676 /// sufficient, a read-write scope will do as well.
24677 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationDeleteCall<'a, C>
24678 where
24679 St: AsRef<str>,
24680 {
24681 self._scopes.insert(String::from(scope.as_ref()));
24682 self
24683 }
24684 /// Identifies the authorization scope(s) for the method you are building.
24685 ///
24686 /// See [`Self::add_scope()`] for details.
24687 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationDeleteCall<'a, C>
24688 where
24689 I: IntoIterator<Item = St>,
24690 St: AsRef<str>,
24691 {
24692 self._scopes
24693 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24694 self
24695 }
24696
24697 /// Removes all scopes, and no default scope will be used either.
24698 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24699 /// for details).
24700 pub fn clear_scopes(mut self) -> ProjectLocationOperationDeleteCall<'a, C> {
24701 self._scopes.clear();
24702 self
24703 }
24704}
24705
24706/// 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.
24707///
24708/// A builder for the *locations.operations.get* method supported by a *project* resource.
24709/// It is not used directly, but through a [`ProjectMethods`] instance.
24710///
24711/// # Example
24712///
24713/// Instantiate a resource method builder
24714///
24715/// ```test_harness,no_run
24716/// # extern crate hyper;
24717/// # extern crate hyper_rustls;
24718/// # extern crate google_networkservices1 as networkservices1;
24719/// # async fn dox() {
24720/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24721///
24722/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
24723/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
24724/// # .with_native_roots()
24725/// # .unwrap()
24726/// # .https_only()
24727/// # .enable_http2()
24728/// # .build();
24729///
24730/// # let executor = hyper_util::rt::TokioExecutor::new();
24731/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
24732/// # secret,
24733/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24734/// # yup_oauth2::client::CustomHyperClientBuilder::from(
24735/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
24736/// # ),
24737/// # ).build().await.unwrap();
24738///
24739/// # let client = hyper_util::client::legacy::Client::builder(
24740/// # hyper_util::rt::TokioExecutor::new()
24741/// # )
24742/// # .build(
24743/// # hyper_rustls::HttpsConnectorBuilder::new()
24744/// # .with_native_roots()
24745/// # .unwrap()
24746/// # .https_or_http()
24747/// # .enable_http2()
24748/// # .build()
24749/// # );
24750/// # let mut hub = NetworkServices::new(client, auth);
24751/// // You can configure optional parameters by calling the respective setters at will, and
24752/// // execute the final call using `doit()`.
24753/// // Values shown here are possibly random and not representative !
24754/// let result = hub.projects().locations_operations_get("name")
24755/// .doit().await;
24756/// # }
24757/// ```
24758pub struct ProjectLocationOperationGetCall<'a, C>
24759where
24760 C: 'a,
24761{
24762 hub: &'a NetworkServices<C>,
24763 _name: String,
24764 _delegate: Option<&'a mut dyn common::Delegate>,
24765 _additional_params: HashMap<String, String>,
24766 _scopes: BTreeSet<String>,
24767}
24768
24769impl<'a, C> common::CallBuilder for ProjectLocationOperationGetCall<'a, C> {}
24770
24771impl<'a, C> ProjectLocationOperationGetCall<'a, C>
24772where
24773 C: common::Connector,
24774{
24775 /// Perform the operation you have build so far.
24776 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
24777 use std::borrow::Cow;
24778 use std::io::{Read, Seek};
24779
24780 use common::{url::Params, ToParts};
24781 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24782
24783 let mut dd = common::DefaultDelegate;
24784 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24785 dlg.begin(common::MethodInfo {
24786 id: "networkservices.projects.locations.operations.get",
24787 http_method: hyper::Method::GET,
24788 });
24789
24790 for &field in ["alt", "name"].iter() {
24791 if self._additional_params.contains_key(field) {
24792 dlg.finished(false);
24793 return Err(common::Error::FieldClash(field));
24794 }
24795 }
24796
24797 let mut params = Params::with_capacity(3 + self._additional_params.len());
24798 params.push("name", self._name);
24799
24800 params.extend(self._additional_params.iter());
24801
24802 params.push("alt", "json");
24803 let mut url = self.hub._base_url.clone() + "v1/{+name}";
24804 if self._scopes.is_empty() {
24805 self._scopes
24806 .insert(Scope::CloudPlatform.as_ref().to_string());
24807 }
24808
24809 #[allow(clippy::single_element_loop)]
24810 for &(find_this, param_name) in [("{+name}", "name")].iter() {
24811 url = params.uri_replacement(url, param_name, find_this, true);
24812 }
24813 {
24814 let to_remove = ["name"];
24815 params.remove_params(&to_remove);
24816 }
24817
24818 let url = params.parse_with_url(&url);
24819
24820 loop {
24821 let token = match self
24822 .hub
24823 .auth
24824 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24825 .await
24826 {
24827 Ok(token) => token,
24828 Err(e) => match dlg.token(e) {
24829 Ok(token) => token,
24830 Err(e) => {
24831 dlg.finished(false);
24832 return Err(common::Error::MissingToken(e));
24833 }
24834 },
24835 };
24836 let mut req_result = {
24837 let client = &self.hub.client;
24838 dlg.pre_request();
24839 let mut req_builder = hyper::Request::builder()
24840 .method(hyper::Method::GET)
24841 .uri(url.as_str())
24842 .header(USER_AGENT, self.hub._user_agent.clone());
24843
24844 if let Some(token) = token.as_ref() {
24845 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24846 }
24847
24848 let request = req_builder
24849 .header(CONTENT_LENGTH, 0_u64)
24850 .body(common::to_body::<String>(None));
24851
24852 client.request(request.unwrap()).await
24853 };
24854
24855 match req_result {
24856 Err(err) => {
24857 if let common::Retry::After(d) = dlg.http_error(&err) {
24858 sleep(d).await;
24859 continue;
24860 }
24861 dlg.finished(false);
24862 return Err(common::Error::HttpError(err));
24863 }
24864 Ok(res) => {
24865 let (mut parts, body) = res.into_parts();
24866 let mut body = common::Body::new(body);
24867 if !parts.status.is_success() {
24868 let bytes = common::to_bytes(body).await.unwrap_or_default();
24869 let error = serde_json::from_str(&common::to_string(&bytes));
24870 let response = common::to_response(parts, bytes.into());
24871
24872 if let common::Retry::After(d) =
24873 dlg.http_failure(&response, error.as_ref().ok())
24874 {
24875 sleep(d).await;
24876 continue;
24877 }
24878
24879 dlg.finished(false);
24880
24881 return Err(match error {
24882 Ok(value) => common::Error::BadRequest(value),
24883 _ => common::Error::Failure(response),
24884 });
24885 }
24886 let response = {
24887 let bytes = common::to_bytes(body).await.unwrap_or_default();
24888 let encoded = common::to_string(&bytes);
24889 match serde_json::from_str(&encoded) {
24890 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24891 Err(error) => {
24892 dlg.response_json_decode_error(&encoded, &error);
24893 return Err(common::Error::JsonDecodeError(
24894 encoded.to_string(),
24895 error,
24896 ));
24897 }
24898 }
24899 };
24900
24901 dlg.finished(true);
24902 return Ok(response);
24903 }
24904 }
24905 }
24906 }
24907
24908 /// The name of the operation resource.
24909 ///
24910 /// Sets the *name* path property to the given value.
24911 ///
24912 /// Even though the property as already been set when instantiating this call,
24913 /// we provide this method for API completeness.
24914 pub fn name(mut self, new_value: &str) -> ProjectLocationOperationGetCall<'a, C> {
24915 self._name = new_value.to_string();
24916 self
24917 }
24918 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24919 /// while executing the actual API request.
24920 ///
24921 /// ````text
24922 /// It should be used to handle progress information, and to implement a certain level of resilience.
24923 /// ````
24924 ///
24925 /// Sets the *delegate* property to the given value.
24926 pub fn delegate(
24927 mut self,
24928 new_value: &'a mut dyn common::Delegate,
24929 ) -> ProjectLocationOperationGetCall<'a, C> {
24930 self._delegate = Some(new_value);
24931 self
24932 }
24933
24934 /// Set any additional parameter of the query string used in the request.
24935 /// It should be used to set parameters which are not yet available through their own
24936 /// setters.
24937 ///
24938 /// Please note that this method must not be used to set any of the known parameters
24939 /// which have their own setter method. If done anyway, the request will fail.
24940 ///
24941 /// # Additional Parameters
24942 ///
24943 /// * *$.xgafv* (query-string) - V1 error format.
24944 /// * *access_token* (query-string) - OAuth access token.
24945 /// * *alt* (query-string) - Data format for response.
24946 /// * *callback* (query-string) - JSONP
24947 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24948 /// * *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.
24949 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24950 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24951 /// * *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.
24952 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
24953 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
24954 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationGetCall<'a, C>
24955 where
24956 T: AsRef<str>,
24957 {
24958 self._additional_params
24959 .insert(name.as_ref().to_string(), value.as_ref().to_string());
24960 self
24961 }
24962
24963 /// Identifies the authorization scope for the method you are building.
24964 ///
24965 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24966 /// [`Scope::CloudPlatform`].
24967 ///
24968 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24969 /// tokens for more than one scope.
24970 ///
24971 /// Usually there is more than one suitable scope to authorize an operation, some of which may
24972 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24973 /// sufficient, a read-write scope will do as well.
24974 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationGetCall<'a, C>
24975 where
24976 St: AsRef<str>,
24977 {
24978 self._scopes.insert(String::from(scope.as_ref()));
24979 self
24980 }
24981 /// Identifies the authorization scope(s) for the method you are building.
24982 ///
24983 /// See [`Self::add_scope()`] for details.
24984 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationGetCall<'a, C>
24985 where
24986 I: IntoIterator<Item = St>,
24987 St: AsRef<str>,
24988 {
24989 self._scopes
24990 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24991 self
24992 }
24993
24994 /// Removes all scopes, and no default scope will be used either.
24995 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24996 /// for details).
24997 pub fn clear_scopes(mut self) -> ProjectLocationOperationGetCall<'a, C> {
24998 self._scopes.clear();
24999 self
25000 }
25001}
25002
25003/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
25004///
25005/// A builder for the *locations.operations.list* method supported by a *project* resource.
25006/// It is not used directly, but through a [`ProjectMethods`] instance.
25007///
25008/// # Example
25009///
25010/// Instantiate a resource method builder
25011///
25012/// ```test_harness,no_run
25013/// # extern crate hyper;
25014/// # extern crate hyper_rustls;
25015/// # extern crate google_networkservices1 as networkservices1;
25016/// # async fn dox() {
25017/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
25018///
25019/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
25020/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
25021/// # .with_native_roots()
25022/// # .unwrap()
25023/// # .https_only()
25024/// # .enable_http2()
25025/// # .build();
25026///
25027/// # let executor = hyper_util::rt::TokioExecutor::new();
25028/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
25029/// # secret,
25030/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
25031/// # yup_oauth2::client::CustomHyperClientBuilder::from(
25032/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
25033/// # ),
25034/// # ).build().await.unwrap();
25035///
25036/// # let client = hyper_util::client::legacy::Client::builder(
25037/// # hyper_util::rt::TokioExecutor::new()
25038/// # )
25039/// # .build(
25040/// # hyper_rustls::HttpsConnectorBuilder::new()
25041/// # .with_native_roots()
25042/// # .unwrap()
25043/// # .https_or_http()
25044/// # .enable_http2()
25045/// # .build()
25046/// # );
25047/// # let mut hub = NetworkServices::new(client, auth);
25048/// // You can configure optional parameters by calling the respective setters at will, and
25049/// // execute the final call using `doit()`.
25050/// // Values shown here are possibly random and not representative !
25051/// let result = hub.projects().locations_operations_list("name")
25052/// .return_partial_success(false)
25053/// .page_token("amet")
25054/// .page_size(-57)
25055/// .filter("et")
25056/// .doit().await;
25057/// # }
25058/// ```
25059pub struct ProjectLocationOperationListCall<'a, C>
25060where
25061 C: 'a,
25062{
25063 hub: &'a NetworkServices<C>,
25064 _name: String,
25065 _return_partial_success: Option<bool>,
25066 _page_token: Option<String>,
25067 _page_size: Option<i32>,
25068 _filter: Option<String>,
25069 _delegate: Option<&'a mut dyn common::Delegate>,
25070 _additional_params: HashMap<String, String>,
25071 _scopes: BTreeSet<String>,
25072}
25073
25074impl<'a, C> common::CallBuilder for ProjectLocationOperationListCall<'a, C> {}
25075
25076impl<'a, C> ProjectLocationOperationListCall<'a, C>
25077where
25078 C: common::Connector,
25079{
25080 /// Perform the operation you have build so far.
25081 pub async fn doit(mut self) -> common::Result<(common::Response, ListOperationsResponse)> {
25082 use std::borrow::Cow;
25083 use std::io::{Read, Seek};
25084
25085 use common::{url::Params, ToParts};
25086 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
25087
25088 let mut dd = common::DefaultDelegate;
25089 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
25090 dlg.begin(common::MethodInfo {
25091 id: "networkservices.projects.locations.operations.list",
25092 http_method: hyper::Method::GET,
25093 });
25094
25095 for &field in [
25096 "alt",
25097 "name",
25098 "returnPartialSuccess",
25099 "pageToken",
25100 "pageSize",
25101 "filter",
25102 ]
25103 .iter()
25104 {
25105 if self._additional_params.contains_key(field) {
25106 dlg.finished(false);
25107 return Err(common::Error::FieldClash(field));
25108 }
25109 }
25110
25111 let mut params = Params::with_capacity(7 + self._additional_params.len());
25112 params.push("name", self._name);
25113 if let Some(value) = self._return_partial_success.as_ref() {
25114 params.push("returnPartialSuccess", value.to_string());
25115 }
25116 if let Some(value) = self._page_token.as_ref() {
25117 params.push("pageToken", value);
25118 }
25119 if let Some(value) = self._page_size.as_ref() {
25120 params.push("pageSize", value.to_string());
25121 }
25122 if let Some(value) = self._filter.as_ref() {
25123 params.push("filter", value);
25124 }
25125
25126 params.extend(self._additional_params.iter());
25127
25128 params.push("alt", "json");
25129 let mut url = self.hub._base_url.clone() + "v1/{+name}/operations";
25130 if self._scopes.is_empty() {
25131 self._scopes
25132 .insert(Scope::CloudPlatform.as_ref().to_string());
25133 }
25134
25135 #[allow(clippy::single_element_loop)]
25136 for &(find_this, param_name) in [("{+name}", "name")].iter() {
25137 url = params.uri_replacement(url, param_name, find_this, true);
25138 }
25139 {
25140 let to_remove = ["name"];
25141 params.remove_params(&to_remove);
25142 }
25143
25144 let url = params.parse_with_url(&url);
25145
25146 loop {
25147 let token = match self
25148 .hub
25149 .auth
25150 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
25151 .await
25152 {
25153 Ok(token) => token,
25154 Err(e) => match dlg.token(e) {
25155 Ok(token) => token,
25156 Err(e) => {
25157 dlg.finished(false);
25158 return Err(common::Error::MissingToken(e));
25159 }
25160 },
25161 };
25162 let mut req_result = {
25163 let client = &self.hub.client;
25164 dlg.pre_request();
25165 let mut req_builder = hyper::Request::builder()
25166 .method(hyper::Method::GET)
25167 .uri(url.as_str())
25168 .header(USER_AGENT, self.hub._user_agent.clone());
25169
25170 if let Some(token) = token.as_ref() {
25171 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
25172 }
25173
25174 let request = req_builder
25175 .header(CONTENT_LENGTH, 0_u64)
25176 .body(common::to_body::<String>(None));
25177
25178 client.request(request.unwrap()).await
25179 };
25180
25181 match req_result {
25182 Err(err) => {
25183 if let common::Retry::After(d) = dlg.http_error(&err) {
25184 sleep(d).await;
25185 continue;
25186 }
25187 dlg.finished(false);
25188 return Err(common::Error::HttpError(err));
25189 }
25190 Ok(res) => {
25191 let (mut parts, body) = res.into_parts();
25192 let mut body = common::Body::new(body);
25193 if !parts.status.is_success() {
25194 let bytes = common::to_bytes(body).await.unwrap_or_default();
25195 let error = serde_json::from_str(&common::to_string(&bytes));
25196 let response = common::to_response(parts, bytes.into());
25197
25198 if let common::Retry::After(d) =
25199 dlg.http_failure(&response, error.as_ref().ok())
25200 {
25201 sleep(d).await;
25202 continue;
25203 }
25204
25205 dlg.finished(false);
25206
25207 return Err(match error {
25208 Ok(value) => common::Error::BadRequest(value),
25209 _ => common::Error::Failure(response),
25210 });
25211 }
25212 let response = {
25213 let bytes = common::to_bytes(body).await.unwrap_or_default();
25214 let encoded = common::to_string(&bytes);
25215 match serde_json::from_str(&encoded) {
25216 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
25217 Err(error) => {
25218 dlg.response_json_decode_error(&encoded, &error);
25219 return Err(common::Error::JsonDecodeError(
25220 encoded.to_string(),
25221 error,
25222 ));
25223 }
25224 }
25225 };
25226
25227 dlg.finished(true);
25228 return Ok(response);
25229 }
25230 }
25231 }
25232 }
25233
25234 /// The name of the operation's parent resource.
25235 ///
25236 /// Sets the *name* path property to the given value.
25237 ///
25238 /// Even though the property as already been set when instantiating this call,
25239 /// we provide this method for API completeness.
25240 pub fn name(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
25241 self._name = new_value.to_string();
25242 self
25243 }
25244 /// When set to `true`, operations that are reachable are returned as normal, and those that are unreachable are returned in the ListOperationsResponse.unreachable field. This can only be `true` when reading across collections. For example, when `parent` is set to `"projects/example/locations/-"`. This field is not supported by default and will result in an `UNIMPLEMENTED` error if set unless explicitly documented otherwise in service or product specific documentation.
25245 ///
25246 /// Sets the *return partial success* query property to the given value.
25247 pub fn return_partial_success(
25248 mut self,
25249 new_value: bool,
25250 ) -> ProjectLocationOperationListCall<'a, C> {
25251 self._return_partial_success = Some(new_value);
25252 self
25253 }
25254 /// The standard list page token.
25255 ///
25256 /// Sets the *page token* query property to the given value.
25257 pub fn page_token(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
25258 self._page_token = Some(new_value.to_string());
25259 self
25260 }
25261 /// The standard list page size.
25262 ///
25263 /// Sets the *page size* query property to the given value.
25264 pub fn page_size(mut self, new_value: i32) -> ProjectLocationOperationListCall<'a, C> {
25265 self._page_size = Some(new_value);
25266 self
25267 }
25268 /// The standard list filter.
25269 ///
25270 /// Sets the *filter* query property to the given value.
25271 pub fn filter(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
25272 self._filter = Some(new_value.to_string());
25273 self
25274 }
25275 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25276 /// while executing the actual API request.
25277 ///
25278 /// ````text
25279 /// It should be used to handle progress information, and to implement a certain level of resilience.
25280 /// ````
25281 ///
25282 /// Sets the *delegate* property to the given value.
25283 pub fn delegate(
25284 mut self,
25285 new_value: &'a mut dyn common::Delegate,
25286 ) -> ProjectLocationOperationListCall<'a, C> {
25287 self._delegate = Some(new_value);
25288 self
25289 }
25290
25291 /// Set any additional parameter of the query string used in the request.
25292 /// It should be used to set parameters which are not yet available through their own
25293 /// setters.
25294 ///
25295 /// Please note that this method must not be used to set any of the known parameters
25296 /// which have their own setter method. If done anyway, the request will fail.
25297 ///
25298 /// # Additional Parameters
25299 ///
25300 /// * *$.xgafv* (query-string) - V1 error format.
25301 /// * *access_token* (query-string) - OAuth access token.
25302 /// * *alt* (query-string) - Data format for response.
25303 /// * *callback* (query-string) - JSONP
25304 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25305 /// * *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.
25306 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25307 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25308 /// * *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.
25309 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
25310 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
25311 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationListCall<'a, C>
25312 where
25313 T: AsRef<str>,
25314 {
25315 self._additional_params
25316 .insert(name.as_ref().to_string(), value.as_ref().to_string());
25317 self
25318 }
25319
25320 /// Identifies the authorization scope for the method you are building.
25321 ///
25322 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
25323 /// [`Scope::CloudPlatform`].
25324 ///
25325 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25326 /// tokens for more than one scope.
25327 ///
25328 /// Usually there is more than one suitable scope to authorize an operation, some of which may
25329 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25330 /// sufficient, a read-write scope will do as well.
25331 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationListCall<'a, C>
25332 where
25333 St: AsRef<str>,
25334 {
25335 self._scopes.insert(String::from(scope.as_ref()));
25336 self
25337 }
25338 /// Identifies the authorization scope(s) for the method you are building.
25339 ///
25340 /// See [`Self::add_scope()`] for details.
25341 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationListCall<'a, C>
25342 where
25343 I: IntoIterator<Item = St>,
25344 St: AsRef<str>,
25345 {
25346 self._scopes
25347 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
25348 self
25349 }
25350
25351 /// Removes all scopes, and no default scope will be used either.
25352 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
25353 /// for details).
25354 pub fn clear_scopes(mut self) -> ProjectLocationOperationListCall<'a, C> {
25355 self._scopes.clear();
25356 self
25357 }
25358}
25359
25360/// Creates a new ServiceBinding in a given project and location.
25361///
25362/// A builder for the *locations.serviceBindings.create* method supported by a *project* resource.
25363/// It is not used directly, but through a [`ProjectMethods`] instance.
25364///
25365/// # Example
25366///
25367/// Instantiate a resource method builder
25368///
25369/// ```test_harness,no_run
25370/// # extern crate hyper;
25371/// # extern crate hyper_rustls;
25372/// # extern crate google_networkservices1 as networkservices1;
25373/// use networkservices1::api::ServiceBinding;
25374/// # async fn dox() {
25375/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
25376///
25377/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
25378/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
25379/// # .with_native_roots()
25380/// # .unwrap()
25381/// # .https_only()
25382/// # .enable_http2()
25383/// # .build();
25384///
25385/// # let executor = hyper_util::rt::TokioExecutor::new();
25386/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
25387/// # secret,
25388/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
25389/// # yup_oauth2::client::CustomHyperClientBuilder::from(
25390/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
25391/// # ),
25392/// # ).build().await.unwrap();
25393///
25394/// # let client = hyper_util::client::legacy::Client::builder(
25395/// # hyper_util::rt::TokioExecutor::new()
25396/// # )
25397/// # .build(
25398/// # hyper_rustls::HttpsConnectorBuilder::new()
25399/// # .with_native_roots()
25400/// # .unwrap()
25401/// # .https_or_http()
25402/// # .enable_http2()
25403/// # .build()
25404/// # );
25405/// # let mut hub = NetworkServices::new(client, auth);
25406/// // As the method needs a request, you would usually fill it with the desired information
25407/// // into the respective structure. Some of the parts shown here might not be applicable !
25408/// // Values shown here are possibly random and not representative !
25409/// let mut req = ServiceBinding::default();
25410///
25411/// // You can configure optional parameters by calling the respective setters at will, and
25412/// // execute the final call using `doit()`.
25413/// // Values shown here are possibly random and not representative !
25414/// let result = hub.projects().locations_service_bindings_create(req, "parent")
25415/// .service_binding_id("consetetur")
25416/// .doit().await;
25417/// # }
25418/// ```
25419pub struct ProjectLocationServiceBindingCreateCall<'a, C>
25420where
25421 C: 'a,
25422{
25423 hub: &'a NetworkServices<C>,
25424 _request: ServiceBinding,
25425 _parent: String,
25426 _service_binding_id: Option<String>,
25427 _delegate: Option<&'a mut dyn common::Delegate>,
25428 _additional_params: HashMap<String, String>,
25429 _scopes: BTreeSet<String>,
25430}
25431
25432impl<'a, C> common::CallBuilder for ProjectLocationServiceBindingCreateCall<'a, C> {}
25433
25434impl<'a, C> ProjectLocationServiceBindingCreateCall<'a, C>
25435where
25436 C: common::Connector,
25437{
25438 /// Perform the operation you have build so far.
25439 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
25440 use std::borrow::Cow;
25441 use std::io::{Read, Seek};
25442
25443 use common::{url::Params, ToParts};
25444 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
25445
25446 let mut dd = common::DefaultDelegate;
25447 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
25448 dlg.begin(common::MethodInfo {
25449 id: "networkservices.projects.locations.serviceBindings.create",
25450 http_method: hyper::Method::POST,
25451 });
25452
25453 for &field in ["alt", "parent", "serviceBindingId"].iter() {
25454 if self._additional_params.contains_key(field) {
25455 dlg.finished(false);
25456 return Err(common::Error::FieldClash(field));
25457 }
25458 }
25459
25460 let mut params = Params::with_capacity(5 + self._additional_params.len());
25461 params.push("parent", self._parent);
25462 if let Some(value) = self._service_binding_id.as_ref() {
25463 params.push("serviceBindingId", value);
25464 }
25465
25466 params.extend(self._additional_params.iter());
25467
25468 params.push("alt", "json");
25469 let mut url = self.hub._base_url.clone() + "v1/{+parent}/serviceBindings";
25470 if self._scopes.is_empty() {
25471 self._scopes
25472 .insert(Scope::CloudPlatform.as_ref().to_string());
25473 }
25474
25475 #[allow(clippy::single_element_loop)]
25476 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
25477 url = params.uri_replacement(url, param_name, find_this, true);
25478 }
25479 {
25480 let to_remove = ["parent"];
25481 params.remove_params(&to_remove);
25482 }
25483
25484 let url = params.parse_with_url(&url);
25485
25486 let mut json_mime_type = mime::APPLICATION_JSON;
25487 let mut request_value_reader = {
25488 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
25489 common::remove_json_null_values(&mut value);
25490 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
25491 serde_json::to_writer(&mut dst, &value).unwrap();
25492 dst
25493 };
25494 let request_size = request_value_reader
25495 .seek(std::io::SeekFrom::End(0))
25496 .unwrap();
25497 request_value_reader
25498 .seek(std::io::SeekFrom::Start(0))
25499 .unwrap();
25500
25501 loop {
25502 let token = match self
25503 .hub
25504 .auth
25505 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
25506 .await
25507 {
25508 Ok(token) => token,
25509 Err(e) => match dlg.token(e) {
25510 Ok(token) => token,
25511 Err(e) => {
25512 dlg.finished(false);
25513 return Err(common::Error::MissingToken(e));
25514 }
25515 },
25516 };
25517 request_value_reader
25518 .seek(std::io::SeekFrom::Start(0))
25519 .unwrap();
25520 let mut req_result = {
25521 let client = &self.hub.client;
25522 dlg.pre_request();
25523 let mut req_builder = hyper::Request::builder()
25524 .method(hyper::Method::POST)
25525 .uri(url.as_str())
25526 .header(USER_AGENT, self.hub._user_agent.clone());
25527
25528 if let Some(token) = token.as_ref() {
25529 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
25530 }
25531
25532 let request = req_builder
25533 .header(CONTENT_TYPE, json_mime_type.to_string())
25534 .header(CONTENT_LENGTH, request_size as u64)
25535 .body(common::to_body(
25536 request_value_reader.get_ref().clone().into(),
25537 ));
25538
25539 client.request(request.unwrap()).await
25540 };
25541
25542 match req_result {
25543 Err(err) => {
25544 if let common::Retry::After(d) = dlg.http_error(&err) {
25545 sleep(d).await;
25546 continue;
25547 }
25548 dlg.finished(false);
25549 return Err(common::Error::HttpError(err));
25550 }
25551 Ok(res) => {
25552 let (mut parts, body) = res.into_parts();
25553 let mut body = common::Body::new(body);
25554 if !parts.status.is_success() {
25555 let bytes = common::to_bytes(body).await.unwrap_or_default();
25556 let error = serde_json::from_str(&common::to_string(&bytes));
25557 let response = common::to_response(parts, bytes.into());
25558
25559 if let common::Retry::After(d) =
25560 dlg.http_failure(&response, error.as_ref().ok())
25561 {
25562 sleep(d).await;
25563 continue;
25564 }
25565
25566 dlg.finished(false);
25567
25568 return Err(match error {
25569 Ok(value) => common::Error::BadRequest(value),
25570 _ => common::Error::Failure(response),
25571 });
25572 }
25573 let response = {
25574 let bytes = common::to_bytes(body).await.unwrap_or_default();
25575 let encoded = common::to_string(&bytes);
25576 match serde_json::from_str(&encoded) {
25577 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
25578 Err(error) => {
25579 dlg.response_json_decode_error(&encoded, &error);
25580 return Err(common::Error::JsonDecodeError(
25581 encoded.to_string(),
25582 error,
25583 ));
25584 }
25585 }
25586 };
25587
25588 dlg.finished(true);
25589 return Ok(response);
25590 }
25591 }
25592 }
25593 }
25594
25595 ///
25596 /// Sets the *request* property to the given value.
25597 ///
25598 /// Even though the property as already been set when instantiating this call,
25599 /// we provide this method for API completeness.
25600 pub fn request(
25601 mut self,
25602 new_value: ServiceBinding,
25603 ) -> ProjectLocationServiceBindingCreateCall<'a, C> {
25604 self._request = new_value;
25605 self
25606 }
25607 /// Required. The parent resource of the ServiceBinding. Must be in the format `projects/*/locations/*`.
25608 ///
25609 /// Sets the *parent* path property to the given value.
25610 ///
25611 /// Even though the property as already been set when instantiating this call,
25612 /// we provide this method for API completeness.
25613 pub fn parent(mut self, new_value: &str) -> ProjectLocationServiceBindingCreateCall<'a, C> {
25614 self._parent = new_value.to_string();
25615 self
25616 }
25617 /// Required. Short name of the ServiceBinding resource to be created.
25618 ///
25619 /// Sets the *service binding id* query property to the given value.
25620 pub fn service_binding_id(
25621 mut self,
25622 new_value: &str,
25623 ) -> ProjectLocationServiceBindingCreateCall<'a, C> {
25624 self._service_binding_id = Some(new_value.to_string());
25625 self
25626 }
25627 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25628 /// while executing the actual API request.
25629 ///
25630 /// ````text
25631 /// It should be used to handle progress information, and to implement a certain level of resilience.
25632 /// ````
25633 ///
25634 /// Sets the *delegate* property to the given value.
25635 pub fn delegate(
25636 mut self,
25637 new_value: &'a mut dyn common::Delegate,
25638 ) -> ProjectLocationServiceBindingCreateCall<'a, C> {
25639 self._delegate = Some(new_value);
25640 self
25641 }
25642
25643 /// Set any additional parameter of the query string used in the request.
25644 /// It should be used to set parameters which are not yet available through their own
25645 /// setters.
25646 ///
25647 /// Please note that this method must not be used to set any of the known parameters
25648 /// which have their own setter method. If done anyway, the request will fail.
25649 ///
25650 /// # Additional Parameters
25651 ///
25652 /// * *$.xgafv* (query-string) - V1 error format.
25653 /// * *access_token* (query-string) - OAuth access token.
25654 /// * *alt* (query-string) - Data format for response.
25655 /// * *callback* (query-string) - JSONP
25656 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25657 /// * *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.
25658 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25659 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25660 /// * *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.
25661 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
25662 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
25663 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationServiceBindingCreateCall<'a, C>
25664 where
25665 T: AsRef<str>,
25666 {
25667 self._additional_params
25668 .insert(name.as_ref().to_string(), value.as_ref().to_string());
25669 self
25670 }
25671
25672 /// Identifies the authorization scope for the method you are building.
25673 ///
25674 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
25675 /// [`Scope::CloudPlatform`].
25676 ///
25677 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25678 /// tokens for more than one scope.
25679 ///
25680 /// Usually there is more than one suitable scope to authorize an operation, some of which may
25681 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25682 /// sufficient, a read-write scope will do as well.
25683 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationServiceBindingCreateCall<'a, C>
25684 where
25685 St: AsRef<str>,
25686 {
25687 self._scopes.insert(String::from(scope.as_ref()));
25688 self
25689 }
25690 /// Identifies the authorization scope(s) for the method you are building.
25691 ///
25692 /// See [`Self::add_scope()`] for details.
25693 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationServiceBindingCreateCall<'a, C>
25694 where
25695 I: IntoIterator<Item = St>,
25696 St: AsRef<str>,
25697 {
25698 self._scopes
25699 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
25700 self
25701 }
25702
25703 /// Removes all scopes, and no default scope will be used either.
25704 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
25705 /// for details).
25706 pub fn clear_scopes(mut self) -> ProjectLocationServiceBindingCreateCall<'a, C> {
25707 self._scopes.clear();
25708 self
25709 }
25710}
25711
25712/// Deletes a single ServiceBinding.
25713///
25714/// A builder for the *locations.serviceBindings.delete* method supported by a *project* resource.
25715/// It is not used directly, but through a [`ProjectMethods`] instance.
25716///
25717/// # Example
25718///
25719/// Instantiate a resource method builder
25720///
25721/// ```test_harness,no_run
25722/// # extern crate hyper;
25723/// # extern crate hyper_rustls;
25724/// # extern crate google_networkservices1 as networkservices1;
25725/// # async fn dox() {
25726/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
25727///
25728/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
25729/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
25730/// # .with_native_roots()
25731/// # .unwrap()
25732/// # .https_only()
25733/// # .enable_http2()
25734/// # .build();
25735///
25736/// # let executor = hyper_util::rt::TokioExecutor::new();
25737/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
25738/// # secret,
25739/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
25740/// # yup_oauth2::client::CustomHyperClientBuilder::from(
25741/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
25742/// # ),
25743/// # ).build().await.unwrap();
25744///
25745/// # let client = hyper_util::client::legacy::Client::builder(
25746/// # hyper_util::rt::TokioExecutor::new()
25747/// # )
25748/// # .build(
25749/// # hyper_rustls::HttpsConnectorBuilder::new()
25750/// # .with_native_roots()
25751/// # .unwrap()
25752/// # .https_or_http()
25753/// # .enable_http2()
25754/// # .build()
25755/// # );
25756/// # let mut hub = NetworkServices::new(client, auth);
25757/// // You can configure optional parameters by calling the respective setters at will, and
25758/// // execute the final call using `doit()`.
25759/// // Values shown here are possibly random and not representative !
25760/// let result = hub.projects().locations_service_bindings_delete("name")
25761/// .doit().await;
25762/// # }
25763/// ```
25764pub struct ProjectLocationServiceBindingDeleteCall<'a, C>
25765where
25766 C: 'a,
25767{
25768 hub: &'a NetworkServices<C>,
25769 _name: String,
25770 _delegate: Option<&'a mut dyn common::Delegate>,
25771 _additional_params: HashMap<String, String>,
25772 _scopes: BTreeSet<String>,
25773}
25774
25775impl<'a, C> common::CallBuilder for ProjectLocationServiceBindingDeleteCall<'a, C> {}
25776
25777impl<'a, C> ProjectLocationServiceBindingDeleteCall<'a, C>
25778where
25779 C: common::Connector,
25780{
25781 /// Perform the operation you have build so far.
25782 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
25783 use std::borrow::Cow;
25784 use std::io::{Read, Seek};
25785
25786 use common::{url::Params, ToParts};
25787 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
25788
25789 let mut dd = common::DefaultDelegate;
25790 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
25791 dlg.begin(common::MethodInfo {
25792 id: "networkservices.projects.locations.serviceBindings.delete",
25793 http_method: hyper::Method::DELETE,
25794 });
25795
25796 for &field in ["alt", "name"].iter() {
25797 if self._additional_params.contains_key(field) {
25798 dlg.finished(false);
25799 return Err(common::Error::FieldClash(field));
25800 }
25801 }
25802
25803 let mut params = Params::with_capacity(3 + self._additional_params.len());
25804 params.push("name", self._name);
25805
25806 params.extend(self._additional_params.iter());
25807
25808 params.push("alt", "json");
25809 let mut url = self.hub._base_url.clone() + "v1/{+name}";
25810 if self._scopes.is_empty() {
25811 self._scopes
25812 .insert(Scope::CloudPlatform.as_ref().to_string());
25813 }
25814
25815 #[allow(clippy::single_element_loop)]
25816 for &(find_this, param_name) in [("{+name}", "name")].iter() {
25817 url = params.uri_replacement(url, param_name, find_this, true);
25818 }
25819 {
25820 let to_remove = ["name"];
25821 params.remove_params(&to_remove);
25822 }
25823
25824 let url = params.parse_with_url(&url);
25825
25826 loop {
25827 let token = match self
25828 .hub
25829 .auth
25830 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
25831 .await
25832 {
25833 Ok(token) => token,
25834 Err(e) => match dlg.token(e) {
25835 Ok(token) => token,
25836 Err(e) => {
25837 dlg.finished(false);
25838 return Err(common::Error::MissingToken(e));
25839 }
25840 },
25841 };
25842 let mut req_result = {
25843 let client = &self.hub.client;
25844 dlg.pre_request();
25845 let mut req_builder = hyper::Request::builder()
25846 .method(hyper::Method::DELETE)
25847 .uri(url.as_str())
25848 .header(USER_AGENT, self.hub._user_agent.clone());
25849
25850 if let Some(token) = token.as_ref() {
25851 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
25852 }
25853
25854 let request = req_builder
25855 .header(CONTENT_LENGTH, 0_u64)
25856 .body(common::to_body::<String>(None));
25857
25858 client.request(request.unwrap()).await
25859 };
25860
25861 match req_result {
25862 Err(err) => {
25863 if let common::Retry::After(d) = dlg.http_error(&err) {
25864 sleep(d).await;
25865 continue;
25866 }
25867 dlg.finished(false);
25868 return Err(common::Error::HttpError(err));
25869 }
25870 Ok(res) => {
25871 let (mut parts, body) = res.into_parts();
25872 let mut body = common::Body::new(body);
25873 if !parts.status.is_success() {
25874 let bytes = common::to_bytes(body).await.unwrap_or_default();
25875 let error = serde_json::from_str(&common::to_string(&bytes));
25876 let response = common::to_response(parts, bytes.into());
25877
25878 if let common::Retry::After(d) =
25879 dlg.http_failure(&response, error.as_ref().ok())
25880 {
25881 sleep(d).await;
25882 continue;
25883 }
25884
25885 dlg.finished(false);
25886
25887 return Err(match error {
25888 Ok(value) => common::Error::BadRequest(value),
25889 _ => common::Error::Failure(response),
25890 });
25891 }
25892 let response = {
25893 let bytes = common::to_bytes(body).await.unwrap_or_default();
25894 let encoded = common::to_string(&bytes);
25895 match serde_json::from_str(&encoded) {
25896 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
25897 Err(error) => {
25898 dlg.response_json_decode_error(&encoded, &error);
25899 return Err(common::Error::JsonDecodeError(
25900 encoded.to_string(),
25901 error,
25902 ));
25903 }
25904 }
25905 };
25906
25907 dlg.finished(true);
25908 return Ok(response);
25909 }
25910 }
25911 }
25912 }
25913
25914 /// Required. A name of the ServiceBinding to delete. Must be in the format `projects/*/locations/*/serviceBindings/*`.
25915 ///
25916 /// Sets the *name* path property to the given value.
25917 ///
25918 /// Even though the property as already been set when instantiating this call,
25919 /// we provide this method for API completeness.
25920 pub fn name(mut self, new_value: &str) -> ProjectLocationServiceBindingDeleteCall<'a, C> {
25921 self._name = new_value.to_string();
25922 self
25923 }
25924 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25925 /// while executing the actual API request.
25926 ///
25927 /// ````text
25928 /// It should be used to handle progress information, and to implement a certain level of resilience.
25929 /// ````
25930 ///
25931 /// Sets the *delegate* property to the given value.
25932 pub fn delegate(
25933 mut self,
25934 new_value: &'a mut dyn common::Delegate,
25935 ) -> ProjectLocationServiceBindingDeleteCall<'a, C> {
25936 self._delegate = Some(new_value);
25937 self
25938 }
25939
25940 /// Set any additional parameter of the query string used in the request.
25941 /// It should be used to set parameters which are not yet available through their own
25942 /// setters.
25943 ///
25944 /// Please note that this method must not be used to set any of the known parameters
25945 /// which have their own setter method. If done anyway, the request will fail.
25946 ///
25947 /// # Additional Parameters
25948 ///
25949 /// * *$.xgafv* (query-string) - V1 error format.
25950 /// * *access_token* (query-string) - OAuth access token.
25951 /// * *alt* (query-string) - Data format for response.
25952 /// * *callback* (query-string) - JSONP
25953 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25954 /// * *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.
25955 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25956 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25957 /// * *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.
25958 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
25959 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
25960 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationServiceBindingDeleteCall<'a, C>
25961 where
25962 T: AsRef<str>,
25963 {
25964 self._additional_params
25965 .insert(name.as_ref().to_string(), value.as_ref().to_string());
25966 self
25967 }
25968
25969 /// Identifies the authorization scope for the method you are building.
25970 ///
25971 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
25972 /// [`Scope::CloudPlatform`].
25973 ///
25974 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25975 /// tokens for more than one scope.
25976 ///
25977 /// Usually there is more than one suitable scope to authorize an operation, some of which may
25978 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25979 /// sufficient, a read-write scope will do as well.
25980 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationServiceBindingDeleteCall<'a, C>
25981 where
25982 St: AsRef<str>,
25983 {
25984 self._scopes.insert(String::from(scope.as_ref()));
25985 self
25986 }
25987 /// Identifies the authorization scope(s) for the method you are building.
25988 ///
25989 /// See [`Self::add_scope()`] for details.
25990 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationServiceBindingDeleteCall<'a, C>
25991 where
25992 I: IntoIterator<Item = St>,
25993 St: AsRef<str>,
25994 {
25995 self._scopes
25996 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
25997 self
25998 }
25999
26000 /// Removes all scopes, and no default scope will be used either.
26001 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
26002 /// for details).
26003 pub fn clear_scopes(mut self) -> ProjectLocationServiceBindingDeleteCall<'a, C> {
26004 self._scopes.clear();
26005 self
26006 }
26007}
26008
26009/// Gets details of a single ServiceBinding.
26010///
26011/// A builder for the *locations.serviceBindings.get* method supported by a *project* resource.
26012/// It is not used directly, but through a [`ProjectMethods`] instance.
26013///
26014/// # Example
26015///
26016/// Instantiate a resource method builder
26017///
26018/// ```test_harness,no_run
26019/// # extern crate hyper;
26020/// # extern crate hyper_rustls;
26021/// # extern crate google_networkservices1 as networkservices1;
26022/// # async fn dox() {
26023/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
26024///
26025/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
26026/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
26027/// # .with_native_roots()
26028/// # .unwrap()
26029/// # .https_only()
26030/// # .enable_http2()
26031/// # .build();
26032///
26033/// # let executor = hyper_util::rt::TokioExecutor::new();
26034/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
26035/// # secret,
26036/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
26037/// # yup_oauth2::client::CustomHyperClientBuilder::from(
26038/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
26039/// # ),
26040/// # ).build().await.unwrap();
26041///
26042/// # let client = hyper_util::client::legacy::Client::builder(
26043/// # hyper_util::rt::TokioExecutor::new()
26044/// # )
26045/// # .build(
26046/// # hyper_rustls::HttpsConnectorBuilder::new()
26047/// # .with_native_roots()
26048/// # .unwrap()
26049/// # .https_or_http()
26050/// # .enable_http2()
26051/// # .build()
26052/// # );
26053/// # let mut hub = NetworkServices::new(client, auth);
26054/// // You can configure optional parameters by calling the respective setters at will, and
26055/// // execute the final call using `doit()`.
26056/// // Values shown here are possibly random and not representative !
26057/// let result = hub.projects().locations_service_bindings_get("name")
26058/// .doit().await;
26059/// # }
26060/// ```
26061pub struct ProjectLocationServiceBindingGetCall<'a, C>
26062where
26063 C: 'a,
26064{
26065 hub: &'a NetworkServices<C>,
26066 _name: String,
26067 _delegate: Option<&'a mut dyn common::Delegate>,
26068 _additional_params: HashMap<String, String>,
26069 _scopes: BTreeSet<String>,
26070}
26071
26072impl<'a, C> common::CallBuilder for ProjectLocationServiceBindingGetCall<'a, C> {}
26073
26074impl<'a, C> ProjectLocationServiceBindingGetCall<'a, C>
26075where
26076 C: common::Connector,
26077{
26078 /// Perform the operation you have build so far.
26079 pub async fn doit(mut self) -> common::Result<(common::Response, ServiceBinding)> {
26080 use std::borrow::Cow;
26081 use std::io::{Read, Seek};
26082
26083 use common::{url::Params, ToParts};
26084 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
26085
26086 let mut dd = common::DefaultDelegate;
26087 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
26088 dlg.begin(common::MethodInfo {
26089 id: "networkservices.projects.locations.serviceBindings.get",
26090 http_method: hyper::Method::GET,
26091 });
26092
26093 for &field in ["alt", "name"].iter() {
26094 if self._additional_params.contains_key(field) {
26095 dlg.finished(false);
26096 return Err(common::Error::FieldClash(field));
26097 }
26098 }
26099
26100 let mut params = Params::with_capacity(3 + self._additional_params.len());
26101 params.push("name", self._name);
26102
26103 params.extend(self._additional_params.iter());
26104
26105 params.push("alt", "json");
26106 let mut url = self.hub._base_url.clone() + "v1/{+name}";
26107 if self._scopes.is_empty() {
26108 self._scopes
26109 .insert(Scope::CloudPlatform.as_ref().to_string());
26110 }
26111
26112 #[allow(clippy::single_element_loop)]
26113 for &(find_this, param_name) in [("{+name}", "name")].iter() {
26114 url = params.uri_replacement(url, param_name, find_this, true);
26115 }
26116 {
26117 let to_remove = ["name"];
26118 params.remove_params(&to_remove);
26119 }
26120
26121 let url = params.parse_with_url(&url);
26122
26123 loop {
26124 let token = match self
26125 .hub
26126 .auth
26127 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
26128 .await
26129 {
26130 Ok(token) => token,
26131 Err(e) => match dlg.token(e) {
26132 Ok(token) => token,
26133 Err(e) => {
26134 dlg.finished(false);
26135 return Err(common::Error::MissingToken(e));
26136 }
26137 },
26138 };
26139 let mut req_result = {
26140 let client = &self.hub.client;
26141 dlg.pre_request();
26142 let mut req_builder = hyper::Request::builder()
26143 .method(hyper::Method::GET)
26144 .uri(url.as_str())
26145 .header(USER_AGENT, self.hub._user_agent.clone());
26146
26147 if let Some(token) = token.as_ref() {
26148 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
26149 }
26150
26151 let request = req_builder
26152 .header(CONTENT_LENGTH, 0_u64)
26153 .body(common::to_body::<String>(None));
26154
26155 client.request(request.unwrap()).await
26156 };
26157
26158 match req_result {
26159 Err(err) => {
26160 if let common::Retry::After(d) = dlg.http_error(&err) {
26161 sleep(d).await;
26162 continue;
26163 }
26164 dlg.finished(false);
26165 return Err(common::Error::HttpError(err));
26166 }
26167 Ok(res) => {
26168 let (mut parts, body) = res.into_parts();
26169 let mut body = common::Body::new(body);
26170 if !parts.status.is_success() {
26171 let bytes = common::to_bytes(body).await.unwrap_or_default();
26172 let error = serde_json::from_str(&common::to_string(&bytes));
26173 let response = common::to_response(parts, bytes.into());
26174
26175 if let common::Retry::After(d) =
26176 dlg.http_failure(&response, error.as_ref().ok())
26177 {
26178 sleep(d).await;
26179 continue;
26180 }
26181
26182 dlg.finished(false);
26183
26184 return Err(match error {
26185 Ok(value) => common::Error::BadRequest(value),
26186 _ => common::Error::Failure(response),
26187 });
26188 }
26189 let response = {
26190 let bytes = common::to_bytes(body).await.unwrap_or_default();
26191 let encoded = common::to_string(&bytes);
26192 match serde_json::from_str(&encoded) {
26193 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
26194 Err(error) => {
26195 dlg.response_json_decode_error(&encoded, &error);
26196 return Err(common::Error::JsonDecodeError(
26197 encoded.to_string(),
26198 error,
26199 ));
26200 }
26201 }
26202 };
26203
26204 dlg.finished(true);
26205 return Ok(response);
26206 }
26207 }
26208 }
26209 }
26210
26211 /// Required. A name of the ServiceBinding to get. Must be in the format `projects/*/locations/*/serviceBindings/*`.
26212 ///
26213 /// Sets the *name* path property to the given value.
26214 ///
26215 /// Even though the property as already been set when instantiating this call,
26216 /// we provide this method for API completeness.
26217 pub fn name(mut self, new_value: &str) -> ProjectLocationServiceBindingGetCall<'a, C> {
26218 self._name = new_value.to_string();
26219 self
26220 }
26221 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26222 /// while executing the actual API request.
26223 ///
26224 /// ````text
26225 /// It should be used to handle progress information, and to implement a certain level of resilience.
26226 /// ````
26227 ///
26228 /// Sets the *delegate* property to the given value.
26229 pub fn delegate(
26230 mut self,
26231 new_value: &'a mut dyn common::Delegate,
26232 ) -> ProjectLocationServiceBindingGetCall<'a, C> {
26233 self._delegate = Some(new_value);
26234 self
26235 }
26236
26237 /// Set any additional parameter of the query string used in the request.
26238 /// It should be used to set parameters which are not yet available through their own
26239 /// setters.
26240 ///
26241 /// Please note that this method must not be used to set any of the known parameters
26242 /// which have their own setter method. If done anyway, the request will fail.
26243 ///
26244 /// # Additional Parameters
26245 ///
26246 /// * *$.xgafv* (query-string) - V1 error format.
26247 /// * *access_token* (query-string) - OAuth access token.
26248 /// * *alt* (query-string) - Data format for response.
26249 /// * *callback* (query-string) - JSONP
26250 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26251 /// * *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.
26252 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26253 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26254 /// * *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.
26255 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
26256 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
26257 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationServiceBindingGetCall<'a, C>
26258 where
26259 T: AsRef<str>,
26260 {
26261 self._additional_params
26262 .insert(name.as_ref().to_string(), value.as_ref().to_string());
26263 self
26264 }
26265
26266 /// Identifies the authorization scope for the method you are building.
26267 ///
26268 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
26269 /// [`Scope::CloudPlatform`].
26270 ///
26271 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
26272 /// tokens for more than one scope.
26273 ///
26274 /// Usually there is more than one suitable scope to authorize an operation, some of which may
26275 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
26276 /// sufficient, a read-write scope will do as well.
26277 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationServiceBindingGetCall<'a, C>
26278 where
26279 St: AsRef<str>,
26280 {
26281 self._scopes.insert(String::from(scope.as_ref()));
26282 self
26283 }
26284 /// Identifies the authorization scope(s) for the method you are building.
26285 ///
26286 /// See [`Self::add_scope()`] for details.
26287 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationServiceBindingGetCall<'a, C>
26288 where
26289 I: IntoIterator<Item = St>,
26290 St: AsRef<str>,
26291 {
26292 self._scopes
26293 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
26294 self
26295 }
26296
26297 /// Removes all scopes, and no default scope will be used either.
26298 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
26299 /// for details).
26300 pub fn clear_scopes(mut self) -> ProjectLocationServiceBindingGetCall<'a, C> {
26301 self._scopes.clear();
26302 self
26303 }
26304}
26305
26306/// Lists ServiceBinding in a given project and location.
26307///
26308/// A builder for the *locations.serviceBindings.list* method supported by a *project* resource.
26309/// It is not used directly, but through a [`ProjectMethods`] instance.
26310///
26311/// # Example
26312///
26313/// Instantiate a resource method builder
26314///
26315/// ```test_harness,no_run
26316/// # extern crate hyper;
26317/// # extern crate hyper_rustls;
26318/// # extern crate google_networkservices1 as networkservices1;
26319/// # async fn dox() {
26320/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
26321///
26322/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
26323/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
26324/// # .with_native_roots()
26325/// # .unwrap()
26326/// # .https_only()
26327/// # .enable_http2()
26328/// # .build();
26329///
26330/// # let executor = hyper_util::rt::TokioExecutor::new();
26331/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
26332/// # secret,
26333/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
26334/// # yup_oauth2::client::CustomHyperClientBuilder::from(
26335/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
26336/// # ),
26337/// # ).build().await.unwrap();
26338///
26339/// # let client = hyper_util::client::legacy::Client::builder(
26340/// # hyper_util::rt::TokioExecutor::new()
26341/// # )
26342/// # .build(
26343/// # hyper_rustls::HttpsConnectorBuilder::new()
26344/// # .with_native_roots()
26345/// # .unwrap()
26346/// # .https_or_http()
26347/// # .enable_http2()
26348/// # .build()
26349/// # );
26350/// # let mut hub = NetworkServices::new(client, auth);
26351/// // You can configure optional parameters by calling the respective setters at will, and
26352/// // execute the final call using `doit()`.
26353/// // Values shown here are possibly random and not representative !
26354/// let result = hub.projects().locations_service_bindings_list("parent")
26355/// .page_token("aliquyam")
26356/// .page_size(-94)
26357/// .doit().await;
26358/// # }
26359/// ```
26360pub struct ProjectLocationServiceBindingListCall<'a, C>
26361where
26362 C: 'a,
26363{
26364 hub: &'a NetworkServices<C>,
26365 _parent: String,
26366 _page_token: Option<String>,
26367 _page_size: Option<i32>,
26368 _delegate: Option<&'a mut dyn common::Delegate>,
26369 _additional_params: HashMap<String, String>,
26370 _scopes: BTreeSet<String>,
26371}
26372
26373impl<'a, C> common::CallBuilder for ProjectLocationServiceBindingListCall<'a, C> {}
26374
26375impl<'a, C> ProjectLocationServiceBindingListCall<'a, C>
26376where
26377 C: common::Connector,
26378{
26379 /// Perform the operation you have build so far.
26380 pub async fn doit(mut self) -> common::Result<(common::Response, ListServiceBindingsResponse)> {
26381 use std::borrow::Cow;
26382 use std::io::{Read, Seek};
26383
26384 use common::{url::Params, ToParts};
26385 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
26386
26387 let mut dd = common::DefaultDelegate;
26388 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
26389 dlg.begin(common::MethodInfo {
26390 id: "networkservices.projects.locations.serviceBindings.list",
26391 http_method: hyper::Method::GET,
26392 });
26393
26394 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
26395 if self._additional_params.contains_key(field) {
26396 dlg.finished(false);
26397 return Err(common::Error::FieldClash(field));
26398 }
26399 }
26400
26401 let mut params = Params::with_capacity(5 + self._additional_params.len());
26402 params.push("parent", self._parent);
26403 if let Some(value) = self._page_token.as_ref() {
26404 params.push("pageToken", value);
26405 }
26406 if let Some(value) = self._page_size.as_ref() {
26407 params.push("pageSize", value.to_string());
26408 }
26409
26410 params.extend(self._additional_params.iter());
26411
26412 params.push("alt", "json");
26413 let mut url = self.hub._base_url.clone() + "v1/{+parent}/serviceBindings";
26414 if self._scopes.is_empty() {
26415 self._scopes
26416 .insert(Scope::CloudPlatform.as_ref().to_string());
26417 }
26418
26419 #[allow(clippy::single_element_loop)]
26420 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
26421 url = params.uri_replacement(url, param_name, find_this, true);
26422 }
26423 {
26424 let to_remove = ["parent"];
26425 params.remove_params(&to_remove);
26426 }
26427
26428 let url = params.parse_with_url(&url);
26429
26430 loop {
26431 let token = match self
26432 .hub
26433 .auth
26434 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
26435 .await
26436 {
26437 Ok(token) => token,
26438 Err(e) => match dlg.token(e) {
26439 Ok(token) => token,
26440 Err(e) => {
26441 dlg.finished(false);
26442 return Err(common::Error::MissingToken(e));
26443 }
26444 },
26445 };
26446 let mut req_result = {
26447 let client = &self.hub.client;
26448 dlg.pre_request();
26449 let mut req_builder = hyper::Request::builder()
26450 .method(hyper::Method::GET)
26451 .uri(url.as_str())
26452 .header(USER_AGENT, self.hub._user_agent.clone());
26453
26454 if let Some(token) = token.as_ref() {
26455 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
26456 }
26457
26458 let request = req_builder
26459 .header(CONTENT_LENGTH, 0_u64)
26460 .body(common::to_body::<String>(None));
26461
26462 client.request(request.unwrap()).await
26463 };
26464
26465 match req_result {
26466 Err(err) => {
26467 if let common::Retry::After(d) = dlg.http_error(&err) {
26468 sleep(d).await;
26469 continue;
26470 }
26471 dlg.finished(false);
26472 return Err(common::Error::HttpError(err));
26473 }
26474 Ok(res) => {
26475 let (mut parts, body) = res.into_parts();
26476 let mut body = common::Body::new(body);
26477 if !parts.status.is_success() {
26478 let bytes = common::to_bytes(body).await.unwrap_or_default();
26479 let error = serde_json::from_str(&common::to_string(&bytes));
26480 let response = common::to_response(parts, bytes.into());
26481
26482 if let common::Retry::After(d) =
26483 dlg.http_failure(&response, error.as_ref().ok())
26484 {
26485 sleep(d).await;
26486 continue;
26487 }
26488
26489 dlg.finished(false);
26490
26491 return Err(match error {
26492 Ok(value) => common::Error::BadRequest(value),
26493 _ => common::Error::Failure(response),
26494 });
26495 }
26496 let response = {
26497 let bytes = common::to_bytes(body).await.unwrap_or_default();
26498 let encoded = common::to_string(&bytes);
26499 match serde_json::from_str(&encoded) {
26500 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
26501 Err(error) => {
26502 dlg.response_json_decode_error(&encoded, &error);
26503 return Err(common::Error::JsonDecodeError(
26504 encoded.to_string(),
26505 error,
26506 ));
26507 }
26508 }
26509 };
26510
26511 dlg.finished(true);
26512 return Ok(response);
26513 }
26514 }
26515 }
26516 }
26517
26518 /// Required. The project and location from which the ServiceBindings should be listed, specified in the format `projects/*/locations/*`.
26519 ///
26520 /// Sets the *parent* path property to the given value.
26521 ///
26522 /// Even though the property as already been set when instantiating this call,
26523 /// we provide this method for API completeness.
26524 pub fn parent(mut self, new_value: &str) -> ProjectLocationServiceBindingListCall<'a, C> {
26525 self._parent = new_value.to_string();
26526 self
26527 }
26528 /// The value returned by the last `ListServiceBindingsResponse` Indicates that this is a continuation of a prior `ListRouters` call, and that the system should return the next page of data.
26529 ///
26530 /// Sets the *page token* query property to the given value.
26531 pub fn page_token(mut self, new_value: &str) -> ProjectLocationServiceBindingListCall<'a, C> {
26532 self._page_token = Some(new_value.to_string());
26533 self
26534 }
26535 /// Maximum number of ServiceBindings to return per call.
26536 ///
26537 /// Sets the *page size* query property to the given value.
26538 pub fn page_size(mut self, new_value: i32) -> ProjectLocationServiceBindingListCall<'a, C> {
26539 self._page_size = Some(new_value);
26540 self
26541 }
26542 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26543 /// while executing the actual API request.
26544 ///
26545 /// ````text
26546 /// It should be used to handle progress information, and to implement a certain level of resilience.
26547 /// ````
26548 ///
26549 /// Sets the *delegate* property to the given value.
26550 pub fn delegate(
26551 mut self,
26552 new_value: &'a mut dyn common::Delegate,
26553 ) -> ProjectLocationServiceBindingListCall<'a, C> {
26554 self._delegate = Some(new_value);
26555 self
26556 }
26557
26558 /// Set any additional parameter of the query string used in the request.
26559 /// It should be used to set parameters which are not yet available through their own
26560 /// setters.
26561 ///
26562 /// Please note that this method must not be used to set any of the known parameters
26563 /// which have their own setter method. If done anyway, the request will fail.
26564 ///
26565 /// # Additional Parameters
26566 ///
26567 /// * *$.xgafv* (query-string) - V1 error format.
26568 /// * *access_token* (query-string) - OAuth access token.
26569 /// * *alt* (query-string) - Data format for response.
26570 /// * *callback* (query-string) - JSONP
26571 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26572 /// * *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.
26573 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26574 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26575 /// * *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.
26576 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
26577 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
26578 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationServiceBindingListCall<'a, C>
26579 where
26580 T: AsRef<str>,
26581 {
26582 self._additional_params
26583 .insert(name.as_ref().to_string(), value.as_ref().to_string());
26584 self
26585 }
26586
26587 /// Identifies the authorization scope for the method you are building.
26588 ///
26589 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
26590 /// [`Scope::CloudPlatform`].
26591 ///
26592 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
26593 /// tokens for more than one scope.
26594 ///
26595 /// Usually there is more than one suitable scope to authorize an operation, some of which may
26596 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
26597 /// sufficient, a read-write scope will do as well.
26598 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationServiceBindingListCall<'a, C>
26599 where
26600 St: AsRef<str>,
26601 {
26602 self._scopes.insert(String::from(scope.as_ref()));
26603 self
26604 }
26605 /// Identifies the authorization scope(s) for the method you are building.
26606 ///
26607 /// See [`Self::add_scope()`] for details.
26608 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationServiceBindingListCall<'a, C>
26609 where
26610 I: IntoIterator<Item = St>,
26611 St: AsRef<str>,
26612 {
26613 self._scopes
26614 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
26615 self
26616 }
26617
26618 /// Removes all scopes, and no default scope will be used either.
26619 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
26620 /// for details).
26621 pub fn clear_scopes(mut self) -> ProjectLocationServiceBindingListCall<'a, C> {
26622 self._scopes.clear();
26623 self
26624 }
26625}
26626
26627/// Updates the parameters of a single ServiceBinding.
26628///
26629/// A builder for the *locations.serviceBindings.patch* method supported by a *project* resource.
26630/// It is not used directly, but through a [`ProjectMethods`] instance.
26631///
26632/// # Example
26633///
26634/// Instantiate a resource method builder
26635///
26636/// ```test_harness,no_run
26637/// # extern crate hyper;
26638/// # extern crate hyper_rustls;
26639/// # extern crate google_networkservices1 as networkservices1;
26640/// use networkservices1::api::ServiceBinding;
26641/// # async fn dox() {
26642/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
26643///
26644/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
26645/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
26646/// # .with_native_roots()
26647/// # .unwrap()
26648/// # .https_only()
26649/// # .enable_http2()
26650/// # .build();
26651///
26652/// # let executor = hyper_util::rt::TokioExecutor::new();
26653/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
26654/// # secret,
26655/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
26656/// # yup_oauth2::client::CustomHyperClientBuilder::from(
26657/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
26658/// # ),
26659/// # ).build().await.unwrap();
26660///
26661/// # let client = hyper_util::client::legacy::Client::builder(
26662/// # hyper_util::rt::TokioExecutor::new()
26663/// # )
26664/// # .build(
26665/// # hyper_rustls::HttpsConnectorBuilder::new()
26666/// # .with_native_roots()
26667/// # .unwrap()
26668/// # .https_or_http()
26669/// # .enable_http2()
26670/// # .build()
26671/// # );
26672/// # let mut hub = NetworkServices::new(client, auth);
26673/// // As the method needs a request, you would usually fill it with the desired information
26674/// // into the respective structure. Some of the parts shown here might not be applicable !
26675/// // Values shown here are possibly random and not representative !
26676/// let mut req = ServiceBinding::default();
26677///
26678/// // You can configure optional parameters by calling the respective setters at will, and
26679/// // execute the final call using `doit()`.
26680/// // Values shown here are possibly random and not representative !
26681/// let result = hub.projects().locations_service_bindings_patch(req, "name")
26682/// .update_mask(FieldMask::new::<&str>(&[]))
26683/// .doit().await;
26684/// # }
26685/// ```
26686pub struct ProjectLocationServiceBindingPatchCall<'a, C>
26687where
26688 C: 'a,
26689{
26690 hub: &'a NetworkServices<C>,
26691 _request: ServiceBinding,
26692 _name: String,
26693 _update_mask: Option<common::FieldMask>,
26694 _delegate: Option<&'a mut dyn common::Delegate>,
26695 _additional_params: HashMap<String, String>,
26696 _scopes: BTreeSet<String>,
26697}
26698
26699impl<'a, C> common::CallBuilder for ProjectLocationServiceBindingPatchCall<'a, C> {}
26700
26701impl<'a, C> ProjectLocationServiceBindingPatchCall<'a, C>
26702where
26703 C: common::Connector,
26704{
26705 /// Perform the operation you have build so far.
26706 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
26707 use std::borrow::Cow;
26708 use std::io::{Read, Seek};
26709
26710 use common::{url::Params, ToParts};
26711 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
26712
26713 let mut dd = common::DefaultDelegate;
26714 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
26715 dlg.begin(common::MethodInfo {
26716 id: "networkservices.projects.locations.serviceBindings.patch",
26717 http_method: hyper::Method::PATCH,
26718 });
26719
26720 for &field in ["alt", "name", "updateMask"].iter() {
26721 if self._additional_params.contains_key(field) {
26722 dlg.finished(false);
26723 return Err(common::Error::FieldClash(field));
26724 }
26725 }
26726
26727 let mut params = Params::with_capacity(5 + self._additional_params.len());
26728 params.push("name", self._name);
26729 if let Some(value) = self._update_mask.as_ref() {
26730 params.push("updateMask", value.to_string());
26731 }
26732
26733 params.extend(self._additional_params.iter());
26734
26735 params.push("alt", "json");
26736 let mut url = self.hub._base_url.clone() + "v1/{+name}";
26737 if self._scopes.is_empty() {
26738 self._scopes
26739 .insert(Scope::CloudPlatform.as_ref().to_string());
26740 }
26741
26742 #[allow(clippy::single_element_loop)]
26743 for &(find_this, param_name) in [("{+name}", "name")].iter() {
26744 url = params.uri_replacement(url, param_name, find_this, true);
26745 }
26746 {
26747 let to_remove = ["name"];
26748 params.remove_params(&to_remove);
26749 }
26750
26751 let url = params.parse_with_url(&url);
26752
26753 let mut json_mime_type = mime::APPLICATION_JSON;
26754 let mut request_value_reader = {
26755 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
26756 common::remove_json_null_values(&mut value);
26757 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
26758 serde_json::to_writer(&mut dst, &value).unwrap();
26759 dst
26760 };
26761 let request_size = request_value_reader
26762 .seek(std::io::SeekFrom::End(0))
26763 .unwrap();
26764 request_value_reader
26765 .seek(std::io::SeekFrom::Start(0))
26766 .unwrap();
26767
26768 loop {
26769 let token = match self
26770 .hub
26771 .auth
26772 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
26773 .await
26774 {
26775 Ok(token) => token,
26776 Err(e) => match dlg.token(e) {
26777 Ok(token) => token,
26778 Err(e) => {
26779 dlg.finished(false);
26780 return Err(common::Error::MissingToken(e));
26781 }
26782 },
26783 };
26784 request_value_reader
26785 .seek(std::io::SeekFrom::Start(0))
26786 .unwrap();
26787 let mut req_result = {
26788 let client = &self.hub.client;
26789 dlg.pre_request();
26790 let mut req_builder = hyper::Request::builder()
26791 .method(hyper::Method::PATCH)
26792 .uri(url.as_str())
26793 .header(USER_AGENT, self.hub._user_agent.clone());
26794
26795 if let Some(token) = token.as_ref() {
26796 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
26797 }
26798
26799 let request = req_builder
26800 .header(CONTENT_TYPE, json_mime_type.to_string())
26801 .header(CONTENT_LENGTH, request_size as u64)
26802 .body(common::to_body(
26803 request_value_reader.get_ref().clone().into(),
26804 ));
26805
26806 client.request(request.unwrap()).await
26807 };
26808
26809 match req_result {
26810 Err(err) => {
26811 if let common::Retry::After(d) = dlg.http_error(&err) {
26812 sleep(d).await;
26813 continue;
26814 }
26815 dlg.finished(false);
26816 return Err(common::Error::HttpError(err));
26817 }
26818 Ok(res) => {
26819 let (mut parts, body) = res.into_parts();
26820 let mut body = common::Body::new(body);
26821 if !parts.status.is_success() {
26822 let bytes = common::to_bytes(body).await.unwrap_or_default();
26823 let error = serde_json::from_str(&common::to_string(&bytes));
26824 let response = common::to_response(parts, bytes.into());
26825
26826 if let common::Retry::After(d) =
26827 dlg.http_failure(&response, error.as_ref().ok())
26828 {
26829 sleep(d).await;
26830 continue;
26831 }
26832
26833 dlg.finished(false);
26834
26835 return Err(match error {
26836 Ok(value) => common::Error::BadRequest(value),
26837 _ => common::Error::Failure(response),
26838 });
26839 }
26840 let response = {
26841 let bytes = common::to_bytes(body).await.unwrap_or_default();
26842 let encoded = common::to_string(&bytes);
26843 match serde_json::from_str(&encoded) {
26844 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
26845 Err(error) => {
26846 dlg.response_json_decode_error(&encoded, &error);
26847 return Err(common::Error::JsonDecodeError(
26848 encoded.to_string(),
26849 error,
26850 ));
26851 }
26852 }
26853 };
26854
26855 dlg.finished(true);
26856 return Ok(response);
26857 }
26858 }
26859 }
26860 }
26861
26862 ///
26863 /// Sets the *request* property to the given value.
26864 ///
26865 /// Even though the property as already been set when instantiating this call,
26866 /// we provide this method for API completeness.
26867 pub fn request(
26868 mut self,
26869 new_value: ServiceBinding,
26870 ) -> ProjectLocationServiceBindingPatchCall<'a, C> {
26871 self._request = new_value;
26872 self
26873 }
26874 /// Identifier. Name of the ServiceBinding resource. It matches pattern `projects/*/locations/*/serviceBindings/`.
26875 ///
26876 /// Sets the *name* path property to the given value.
26877 ///
26878 /// Even though the property as already been set when instantiating this call,
26879 /// we provide this method for API completeness.
26880 pub fn name(mut self, new_value: &str) -> ProjectLocationServiceBindingPatchCall<'a, C> {
26881 self._name = new_value.to_string();
26882 self
26883 }
26884 /// Optional. Field mask is used to specify the fields to be overwritten in the ServiceBinding 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.
26885 ///
26886 /// Sets the *update mask* query property to the given value.
26887 pub fn update_mask(
26888 mut self,
26889 new_value: common::FieldMask,
26890 ) -> ProjectLocationServiceBindingPatchCall<'a, C> {
26891 self._update_mask = Some(new_value);
26892 self
26893 }
26894 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26895 /// while executing the actual API request.
26896 ///
26897 /// ````text
26898 /// It should be used to handle progress information, and to implement a certain level of resilience.
26899 /// ````
26900 ///
26901 /// Sets the *delegate* property to the given value.
26902 pub fn delegate(
26903 mut self,
26904 new_value: &'a mut dyn common::Delegate,
26905 ) -> ProjectLocationServiceBindingPatchCall<'a, C> {
26906 self._delegate = Some(new_value);
26907 self
26908 }
26909
26910 /// Set any additional parameter of the query string used in the request.
26911 /// It should be used to set parameters which are not yet available through their own
26912 /// setters.
26913 ///
26914 /// Please note that this method must not be used to set any of the known parameters
26915 /// which have their own setter method. If done anyway, the request will fail.
26916 ///
26917 /// # Additional Parameters
26918 ///
26919 /// * *$.xgafv* (query-string) - V1 error format.
26920 /// * *access_token* (query-string) - OAuth access token.
26921 /// * *alt* (query-string) - Data format for response.
26922 /// * *callback* (query-string) - JSONP
26923 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26924 /// * *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.
26925 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26926 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26927 /// * *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.
26928 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
26929 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
26930 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationServiceBindingPatchCall<'a, C>
26931 where
26932 T: AsRef<str>,
26933 {
26934 self._additional_params
26935 .insert(name.as_ref().to_string(), value.as_ref().to_string());
26936 self
26937 }
26938
26939 /// Identifies the authorization scope for the method you are building.
26940 ///
26941 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
26942 /// [`Scope::CloudPlatform`].
26943 ///
26944 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
26945 /// tokens for more than one scope.
26946 ///
26947 /// Usually there is more than one suitable scope to authorize an operation, some of which may
26948 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
26949 /// sufficient, a read-write scope will do as well.
26950 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationServiceBindingPatchCall<'a, C>
26951 where
26952 St: AsRef<str>,
26953 {
26954 self._scopes.insert(String::from(scope.as_ref()));
26955 self
26956 }
26957 /// Identifies the authorization scope(s) for the method you are building.
26958 ///
26959 /// See [`Self::add_scope()`] for details.
26960 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationServiceBindingPatchCall<'a, C>
26961 where
26962 I: IntoIterator<Item = St>,
26963 St: AsRef<str>,
26964 {
26965 self._scopes
26966 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
26967 self
26968 }
26969
26970 /// Removes all scopes, and no default scope will be used either.
26971 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
26972 /// for details).
26973 pub fn clear_scopes(mut self) -> ProjectLocationServiceBindingPatchCall<'a, C> {
26974 self._scopes.clear();
26975 self
26976 }
26977}
26978
26979/// Creates a new ServiceLbPolicy in a given project and location.
26980///
26981/// A builder for the *locations.serviceLbPolicies.create* method supported by a *project* resource.
26982/// It is not used directly, but through a [`ProjectMethods`] instance.
26983///
26984/// # Example
26985///
26986/// Instantiate a resource method builder
26987///
26988/// ```test_harness,no_run
26989/// # extern crate hyper;
26990/// # extern crate hyper_rustls;
26991/// # extern crate google_networkservices1 as networkservices1;
26992/// use networkservices1::api::ServiceLbPolicy;
26993/// # async fn dox() {
26994/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
26995///
26996/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
26997/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
26998/// # .with_native_roots()
26999/// # .unwrap()
27000/// # .https_only()
27001/// # .enable_http2()
27002/// # .build();
27003///
27004/// # let executor = hyper_util::rt::TokioExecutor::new();
27005/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
27006/// # secret,
27007/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
27008/// # yup_oauth2::client::CustomHyperClientBuilder::from(
27009/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
27010/// # ),
27011/// # ).build().await.unwrap();
27012///
27013/// # let client = hyper_util::client::legacy::Client::builder(
27014/// # hyper_util::rt::TokioExecutor::new()
27015/// # )
27016/// # .build(
27017/// # hyper_rustls::HttpsConnectorBuilder::new()
27018/// # .with_native_roots()
27019/// # .unwrap()
27020/// # .https_or_http()
27021/// # .enable_http2()
27022/// # .build()
27023/// # );
27024/// # let mut hub = NetworkServices::new(client, auth);
27025/// // As the method needs a request, you would usually fill it with the desired information
27026/// // into the respective structure. Some of the parts shown here might not be applicable !
27027/// // Values shown here are possibly random and not representative !
27028/// let mut req = ServiceLbPolicy::default();
27029///
27030/// // You can configure optional parameters by calling the respective setters at will, and
27031/// // execute the final call using `doit()`.
27032/// // Values shown here are possibly random and not representative !
27033/// let result = hub.projects().locations_service_lb_policies_create(req, "parent")
27034/// .service_lb_policy_id("est")
27035/// .doit().await;
27036/// # }
27037/// ```
27038pub struct ProjectLocationServiceLbPolicyCreateCall<'a, C>
27039where
27040 C: 'a,
27041{
27042 hub: &'a NetworkServices<C>,
27043 _request: ServiceLbPolicy,
27044 _parent: String,
27045 _service_lb_policy_id: Option<String>,
27046 _delegate: Option<&'a mut dyn common::Delegate>,
27047 _additional_params: HashMap<String, String>,
27048 _scopes: BTreeSet<String>,
27049}
27050
27051impl<'a, C> common::CallBuilder for ProjectLocationServiceLbPolicyCreateCall<'a, C> {}
27052
27053impl<'a, C> ProjectLocationServiceLbPolicyCreateCall<'a, C>
27054where
27055 C: common::Connector,
27056{
27057 /// Perform the operation you have build so far.
27058 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
27059 use std::borrow::Cow;
27060 use std::io::{Read, Seek};
27061
27062 use common::{url::Params, ToParts};
27063 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
27064
27065 let mut dd = common::DefaultDelegate;
27066 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
27067 dlg.begin(common::MethodInfo {
27068 id: "networkservices.projects.locations.serviceLbPolicies.create",
27069 http_method: hyper::Method::POST,
27070 });
27071
27072 for &field in ["alt", "parent", "serviceLbPolicyId"].iter() {
27073 if self._additional_params.contains_key(field) {
27074 dlg.finished(false);
27075 return Err(common::Error::FieldClash(field));
27076 }
27077 }
27078
27079 let mut params = Params::with_capacity(5 + self._additional_params.len());
27080 params.push("parent", self._parent);
27081 if let Some(value) = self._service_lb_policy_id.as_ref() {
27082 params.push("serviceLbPolicyId", value);
27083 }
27084
27085 params.extend(self._additional_params.iter());
27086
27087 params.push("alt", "json");
27088 let mut url = self.hub._base_url.clone() + "v1/{+parent}/serviceLbPolicies";
27089 if self._scopes.is_empty() {
27090 self._scopes
27091 .insert(Scope::CloudPlatform.as_ref().to_string());
27092 }
27093
27094 #[allow(clippy::single_element_loop)]
27095 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
27096 url = params.uri_replacement(url, param_name, find_this, true);
27097 }
27098 {
27099 let to_remove = ["parent"];
27100 params.remove_params(&to_remove);
27101 }
27102
27103 let url = params.parse_with_url(&url);
27104
27105 let mut json_mime_type = mime::APPLICATION_JSON;
27106 let mut request_value_reader = {
27107 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
27108 common::remove_json_null_values(&mut value);
27109 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
27110 serde_json::to_writer(&mut dst, &value).unwrap();
27111 dst
27112 };
27113 let request_size = request_value_reader
27114 .seek(std::io::SeekFrom::End(0))
27115 .unwrap();
27116 request_value_reader
27117 .seek(std::io::SeekFrom::Start(0))
27118 .unwrap();
27119
27120 loop {
27121 let token = match self
27122 .hub
27123 .auth
27124 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
27125 .await
27126 {
27127 Ok(token) => token,
27128 Err(e) => match dlg.token(e) {
27129 Ok(token) => token,
27130 Err(e) => {
27131 dlg.finished(false);
27132 return Err(common::Error::MissingToken(e));
27133 }
27134 },
27135 };
27136 request_value_reader
27137 .seek(std::io::SeekFrom::Start(0))
27138 .unwrap();
27139 let mut req_result = {
27140 let client = &self.hub.client;
27141 dlg.pre_request();
27142 let mut req_builder = hyper::Request::builder()
27143 .method(hyper::Method::POST)
27144 .uri(url.as_str())
27145 .header(USER_AGENT, self.hub._user_agent.clone());
27146
27147 if let Some(token) = token.as_ref() {
27148 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
27149 }
27150
27151 let request = req_builder
27152 .header(CONTENT_TYPE, json_mime_type.to_string())
27153 .header(CONTENT_LENGTH, request_size as u64)
27154 .body(common::to_body(
27155 request_value_reader.get_ref().clone().into(),
27156 ));
27157
27158 client.request(request.unwrap()).await
27159 };
27160
27161 match req_result {
27162 Err(err) => {
27163 if let common::Retry::After(d) = dlg.http_error(&err) {
27164 sleep(d).await;
27165 continue;
27166 }
27167 dlg.finished(false);
27168 return Err(common::Error::HttpError(err));
27169 }
27170 Ok(res) => {
27171 let (mut parts, body) = res.into_parts();
27172 let mut body = common::Body::new(body);
27173 if !parts.status.is_success() {
27174 let bytes = common::to_bytes(body).await.unwrap_or_default();
27175 let error = serde_json::from_str(&common::to_string(&bytes));
27176 let response = common::to_response(parts, bytes.into());
27177
27178 if let common::Retry::After(d) =
27179 dlg.http_failure(&response, error.as_ref().ok())
27180 {
27181 sleep(d).await;
27182 continue;
27183 }
27184
27185 dlg.finished(false);
27186
27187 return Err(match error {
27188 Ok(value) => common::Error::BadRequest(value),
27189 _ => common::Error::Failure(response),
27190 });
27191 }
27192 let response = {
27193 let bytes = common::to_bytes(body).await.unwrap_or_default();
27194 let encoded = common::to_string(&bytes);
27195 match serde_json::from_str(&encoded) {
27196 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
27197 Err(error) => {
27198 dlg.response_json_decode_error(&encoded, &error);
27199 return Err(common::Error::JsonDecodeError(
27200 encoded.to_string(),
27201 error,
27202 ));
27203 }
27204 }
27205 };
27206
27207 dlg.finished(true);
27208 return Ok(response);
27209 }
27210 }
27211 }
27212 }
27213
27214 ///
27215 /// Sets the *request* property to the given value.
27216 ///
27217 /// Even though the property as already been set when instantiating this call,
27218 /// we provide this method for API completeness.
27219 pub fn request(
27220 mut self,
27221 new_value: ServiceLbPolicy,
27222 ) -> ProjectLocationServiceLbPolicyCreateCall<'a, C> {
27223 self._request = new_value;
27224 self
27225 }
27226 /// Required. The parent resource of the ServiceLbPolicy. Must be in the format `projects/{project}/locations/{location}`.
27227 ///
27228 /// Sets the *parent* path property to the given value.
27229 ///
27230 /// Even though the property as already been set when instantiating this call,
27231 /// we provide this method for API completeness.
27232 pub fn parent(mut self, new_value: &str) -> ProjectLocationServiceLbPolicyCreateCall<'a, C> {
27233 self._parent = new_value.to_string();
27234 self
27235 }
27236 /// Required. Short name of the ServiceLbPolicy resource to be created. E.g. for resource name `projects/{project}/locations/{location}/serviceLbPolicies/{service_lb_policy_name}`. the id is value of {service_lb_policy_name}
27237 ///
27238 /// Sets the *service lb policy id* query property to the given value.
27239 pub fn service_lb_policy_id(
27240 mut self,
27241 new_value: &str,
27242 ) -> ProjectLocationServiceLbPolicyCreateCall<'a, C> {
27243 self._service_lb_policy_id = Some(new_value.to_string());
27244 self
27245 }
27246 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
27247 /// while executing the actual API request.
27248 ///
27249 /// ````text
27250 /// It should be used to handle progress information, and to implement a certain level of resilience.
27251 /// ````
27252 ///
27253 /// Sets the *delegate* property to the given value.
27254 pub fn delegate(
27255 mut self,
27256 new_value: &'a mut dyn common::Delegate,
27257 ) -> ProjectLocationServiceLbPolicyCreateCall<'a, C> {
27258 self._delegate = Some(new_value);
27259 self
27260 }
27261
27262 /// Set any additional parameter of the query string used in the request.
27263 /// It should be used to set parameters which are not yet available through their own
27264 /// setters.
27265 ///
27266 /// Please note that this method must not be used to set any of the known parameters
27267 /// which have their own setter method. If done anyway, the request will fail.
27268 ///
27269 /// # Additional Parameters
27270 ///
27271 /// * *$.xgafv* (query-string) - V1 error format.
27272 /// * *access_token* (query-string) - OAuth access token.
27273 /// * *alt* (query-string) - Data format for response.
27274 /// * *callback* (query-string) - JSONP
27275 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
27276 /// * *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.
27277 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
27278 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
27279 /// * *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.
27280 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
27281 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
27282 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationServiceLbPolicyCreateCall<'a, C>
27283 where
27284 T: AsRef<str>,
27285 {
27286 self._additional_params
27287 .insert(name.as_ref().to_string(), value.as_ref().to_string());
27288 self
27289 }
27290
27291 /// Identifies the authorization scope for the method you are building.
27292 ///
27293 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
27294 /// [`Scope::CloudPlatform`].
27295 ///
27296 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
27297 /// tokens for more than one scope.
27298 ///
27299 /// Usually there is more than one suitable scope to authorize an operation, some of which may
27300 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
27301 /// sufficient, a read-write scope will do as well.
27302 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationServiceLbPolicyCreateCall<'a, C>
27303 where
27304 St: AsRef<str>,
27305 {
27306 self._scopes.insert(String::from(scope.as_ref()));
27307 self
27308 }
27309 /// Identifies the authorization scope(s) for the method you are building.
27310 ///
27311 /// See [`Self::add_scope()`] for details.
27312 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationServiceLbPolicyCreateCall<'a, C>
27313 where
27314 I: IntoIterator<Item = St>,
27315 St: AsRef<str>,
27316 {
27317 self._scopes
27318 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
27319 self
27320 }
27321
27322 /// Removes all scopes, and no default scope will be used either.
27323 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
27324 /// for details).
27325 pub fn clear_scopes(mut self) -> ProjectLocationServiceLbPolicyCreateCall<'a, C> {
27326 self._scopes.clear();
27327 self
27328 }
27329}
27330
27331/// Deletes a single ServiceLbPolicy.
27332///
27333/// A builder for the *locations.serviceLbPolicies.delete* method supported by a *project* resource.
27334/// It is not used directly, but through a [`ProjectMethods`] instance.
27335///
27336/// # Example
27337///
27338/// Instantiate a resource method builder
27339///
27340/// ```test_harness,no_run
27341/// # extern crate hyper;
27342/// # extern crate hyper_rustls;
27343/// # extern crate google_networkservices1 as networkservices1;
27344/// # async fn dox() {
27345/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
27346///
27347/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
27348/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
27349/// # .with_native_roots()
27350/// # .unwrap()
27351/// # .https_only()
27352/// # .enable_http2()
27353/// # .build();
27354///
27355/// # let executor = hyper_util::rt::TokioExecutor::new();
27356/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
27357/// # secret,
27358/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
27359/// # yup_oauth2::client::CustomHyperClientBuilder::from(
27360/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
27361/// # ),
27362/// # ).build().await.unwrap();
27363///
27364/// # let client = hyper_util::client::legacy::Client::builder(
27365/// # hyper_util::rt::TokioExecutor::new()
27366/// # )
27367/// # .build(
27368/// # hyper_rustls::HttpsConnectorBuilder::new()
27369/// # .with_native_roots()
27370/// # .unwrap()
27371/// # .https_or_http()
27372/// # .enable_http2()
27373/// # .build()
27374/// # );
27375/// # let mut hub = NetworkServices::new(client, auth);
27376/// // You can configure optional parameters by calling the respective setters at will, and
27377/// // execute the final call using `doit()`.
27378/// // Values shown here are possibly random and not representative !
27379/// let result = hub.projects().locations_service_lb_policies_delete("name")
27380/// .doit().await;
27381/// # }
27382/// ```
27383pub struct ProjectLocationServiceLbPolicyDeleteCall<'a, C>
27384where
27385 C: 'a,
27386{
27387 hub: &'a NetworkServices<C>,
27388 _name: String,
27389 _delegate: Option<&'a mut dyn common::Delegate>,
27390 _additional_params: HashMap<String, String>,
27391 _scopes: BTreeSet<String>,
27392}
27393
27394impl<'a, C> common::CallBuilder for ProjectLocationServiceLbPolicyDeleteCall<'a, C> {}
27395
27396impl<'a, C> ProjectLocationServiceLbPolicyDeleteCall<'a, C>
27397where
27398 C: common::Connector,
27399{
27400 /// Perform the operation you have build so far.
27401 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
27402 use std::borrow::Cow;
27403 use std::io::{Read, Seek};
27404
27405 use common::{url::Params, ToParts};
27406 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
27407
27408 let mut dd = common::DefaultDelegate;
27409 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
27410 dlg.begin(common::MethodInfo {
27411 id: "networkservices.projects.locations.serviceLbPolicies.delete",
27412 http_method: hyper::Method::DELETE,
27413 });
27414
27415 for &field in ["alt", "name"].iter() {
27416 if self._additional_params.contains_key(field) {
27417 dlg.finished(false);
27418 return Err(common::Error::FieldClash(field));
27419 }
27420 }
27421
27422 let mut params = Params::with_capacity(3 + self._additional_params.len());
27423 params.push("name", self._name);
27424
27425 params.extend(self._additional_params.iter());
27426
27427 params.push("alt", "json");
27428 let mut url = self.hub._base_url.clone() + "v1/{+name}";
27429 if self._scopes.is_empty() {
27430 self._scopes
27431 .insert(Scope::CloudPlatform.as_ref().to_string());
27432 }
27433
27434 #[allow(clippy::single_element_loop)]
27435 for &(find_this, param_name) in [("{+name}", "name")].iter() {
27436 url = params.uri_replacement(url, param_name, find_this, true);
27437 }
27438 {
27439 let to_remove = ["name"];
27440 params.remove_params(&to_remove);
27441 }
27442
27443 let url = params.parse_with_url(&url);
27444
27445 loop {
27446 let token = match self
27447 .hub
27448 .auth
27449 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
27450 .await
27451 {
27452 Ok(token) => token,
27453 Err(e) => match dlg.token(e) {
27454 Ok(token) => token,
27455 Err(e) => {
27456 dlg.finished(false);
27457 return Err(common::Error::MissingToken(e));
27458 }
27459 },
27460 };
27461 let mut req_result = {
27462 let client = &self.hub.client;
27463 dlg.pre_request();
27464 let mut req_builder = hyper::Request::builder()
27465 .method(hyper::Method::DELETE)
27466 .uri(url.as_str())
27467 .header(USER_AGENT, self.hub._user_agent.clone());
27468
27469 if let Some(token) = token.as_ref() {
27470 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
27471 }
27472
27473 let request = req_builder
27474 .header(CONTENT_LENGTH, 0_u64)
27475 .body(common::to_body::<String>(None));
27476
27477 client.request(request.unwrap()).await
27478 };
27479
27480 match req_result {
27481 Err(err) => {
27482 if let common::Retry::After(d) = dlg.http_error(&err) {
27483 sleep(d).await;
27484 continue;
27485 }
27486 dlg.finished(false);
27487 return Err(common::Error::HttpError(err));
27488 }
27489 Ok(res) => {
27490 let (mut parts, body) = res.into_parts();
27491 let mut body = common::Body::new(body);
27492 if !parts.status.is_success() {
27493 let bytes = common::to_bytes(body).await.unwrap_or_default();
27494 let error = serde_json::from_str(&common::to_string(&bytes));
27495 let response = common::to_response(parts, bytes.into());
27496
27497 if let common::Retry::After(d) =
27498 dlg.http_failure(&response, error.as_ref().ok())
27499 {
27500 sleep(d).await;
27501 continue;
27502 }
27503
27504 dlg.finished(false);
27505
27506 return Err(match error {
27507 Ok(value) => common::Error::BadRequest(value),
27508 _ => common::Error::Failure(response),
27509 });
27510 }
27511 let response = {
27512 let bytes = common::to_bytes(body).await.unwrap_or_default();
27513 let encoded = common::to_string(&bytes);
27514 match serde_json::from_str(&encoded) {
27515 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
27516 Err(error) => {
27517 dlg.response_json_decode_error(&encoded, &error);
27518 return Err(common::Error::JsonDecodeError(
27519 encoded.to_string(),
27520 error,
27521 ));
27522 }
27523 }
27524 };
27525
27526 dlg.finished(true);
27527 return Ok(response);
27528 }
27529 }
27530 }
27531 }
27532
27533 /// Required. A name of the ServiceLbPolicy to delete. Must be in the format `projects/{project}/locations/{location}/serviceLbPolicies/*`.
27534 ///
27535 /// Sets the *name* path property to the given value.
27536 ///
27537 /// Even though the property as already been set when instantiating this call,
27538 /// we provide this method for API completeness.
27539 pub fn name(mut self, new_value: &str) -> ProjectLocationServiceLbPolicyDeleteCall<'a, C> {
27540 self._name = new_value.to_string();
27541 self
27542 }
27543 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
27544 /// while executing the actual API request.
27545 ///
27546 /// ````text
27547 /// It should be used to handle progress information, and to implement a certain level of resilience.
27548 /// ````
27549 ///
27550 /// Sets the *delegate* property to the given value.
27551 pub fn delegate(
27552 mut self,
27553 new_value: &'a mut dyn common::Delegate,
27554 ) -> ProjectLocationServiceLbPolicyDeleteCall<'a, C> {
27555 self._delegate = Some(new_value);
27556 self
27557 }
27558
27559 /// Set any additional parameter of the query string used in the request.
27560 /// It should be used to set parameters which are not yet available through their own
27561 /// setters.
27562 ///
27563 /// Please note that this method must not be used to set any of the known parameters
27564 /// which have their own setter method. If done anyway, the request will fail.
27565 ///
27566 /// # Additional Parameters
27567 ///
27568 /// * *$.xgafv* (query-string) - V1 error format.
27569 /// * *access_token* (query-string) - OAuth access token.
27570 /// * *alt* (query-string) - Data format for response.
27571 /// * *callback* (query-string) - JSONP
27572 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
27573 /// * *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.
27574 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
27575 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
27576 /// * *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.
27577 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
27578 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
27579 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationServiceLbPolicyDeleteCall<'a, C>
27580 where
27581 T: AsRef<str>,
27582 {
27583 self._additional_params
27584 .insert(name.as_ref().to_string(), value.as_ref().to_string());
27585 self
27586 }
27587
27588 /// Identifies the authorization scope for the method you are building.
27589 ///
27590 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
27591 /// [`Scope::CloudPlatform`].
27592 ///
27593 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
27594 /// tokens for more than one scope.
27595 ///
27596 /// Usually there is more than one suitable scope to authorize an operation, some of which may
27597 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
27598 /// sufficient, a read-write scope will do as well.
27599 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationServiceLbPolicyDeleteCall<'a, C>
27600 where
27601 St: AsRef<str>,
27602 {
27603 self._scopes.insert(String::from(scope.as_ref()));
27604 self
27605 }
27606 /// Identifies the authorization scope(s) for the method you are building.
27607 ///
27608 /// See [`Self::add_scope()`] for details.
27609 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationServiceLbPolicyDeleteCall<'a, C>
27610 where
27611 I: IntoIterator<Item = St>,
27612 St: AsRef<str>,
27613 {
27614 self._scopes
27615 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
27616 self
27617 }
27618
27619 /// Removes all scopes, and no default scope will be used either.
27620 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
27621 /// for details).
27622 pub fn clear_scopes(mut self) -> ProjectLocationServiceLbPolicyDeleteCall<'a, C> {
27623 self._scopes.clear();
27624 self
27625 }
27626}
27627
27628/// Gets details of a single ServiceLbPolicy.
27629///
27630/// A builder for the *locations.serviceLbPolicies.get* method supported by a *project* resource.
27631/// It is not used directly, but through a [`ProjectMethods`] instance.
27632///
27633/// # Example
27634///
27635/// Instantiate a resource method builder
27636///
27637/// ```test_harness,no_run
27638/// # extern crate hyper;
27639/// # extern crate hyper_rustls;
27640/// # extern crate google_networkservices1 as networkservices1;
27641/// # async fn dox() {
27642/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
27643///
27644/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
27645/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
27646/// # .with_native_roots()
27647/// # .unwrap()
27648/// # .https_only()
27649/// # .enable_http2()
27650/// # .build();
27651///
27652/// # let executor = hyper_util::rt::TokioExecutor::new();
27653/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
27654/// # secret,
27655/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
27656/// # yup_oauth2::client::CustomHyperClientBuilder::from(
27657/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
27658/// # ),
27659/// # ).build().await.unwrap();
27660///
27661/// # let client = hyper_util::client::legacy::Client::builder(
27662/// # hyper_util::rt::TokioExecutor::new()
27663/// # )
27664/// # .build(
27665/// # hyper_rustls::HttpsConnectorBuilder::new()
27666/// # .with_native_roots()
27667/// # .unwrap()
27668/// # .https_or_http()
27669/// # .enable_http2()
27670/// # .build()
27671/// # );
27672/// # let mut hub = NetworkServices::new(client, auth);
27673/// // You can configure optional parameters by calling the respective setters at will, and
27674/// // execute the final call using `doit()`.
27675/// // Values shown here are possibly random and not representative !
27676/// let result = hub.projects().locations_service_lb_policies_get("name")
27677/// .doit().await;
27678/// # }
27679/// ```
27680pub struct ProjectLocationServiceLbPolicyGetCall<'a, C>
27681where
27682 C: 'a,
27683{
27684 hub: &'a NetworkServices<C>,
27685 _name: String,
27686 _delegate: Option<&'a mut dyn common::Delegate>,
27687 _additional_params: HashMap<String, String>,
27688 _scopes: BTreeSet<String>,
27689}
27690
27691impl<'a, C> common::CallBuilder for ProjectLocationServiceLbPolicyGetCall<'a, C> {}
27692
27693impl<'a, C> ProjectLocationServiceLbPolicyGetCall<'a, C>
27694where
27695 C: common::Connector,
27696{
27697 /// Perform the operation you have build so far.
27698 pub async fn doit(mut self) -> common::Result<(common::Response, ServiceLbPolicy)> {
27699 use std::borrow::Cow;
27700 use std::io::{Read, Seek};
27701
27702 use common::{url::Params, ToParts};
27703 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
27704
27705 let mut dd = common::DefaultDelegate;
27706 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
27707 dlg.begin(common::MethodInfo {
27708 id: "networkservices.projects.locations.serviceLbPolicies.get",
27709 http_method: hyper::Method::GET,
27710 });
27711
27712 for &field in ["alt", "name"].iter() {
27713 if self._additional_params.contains_key(field) {
27714 dlg.finished(false);
27715 return Err(common::Error::FieldClash(field));
27716 }
27717 }
27718
27719 let mut params = Params::with_capacity(3 + self._additional_params.len());
27720 params.push("name", self._name);
27721
27722 params.extend(self._additional_params.iter());
27723
27724 params.push("alt", "json");
27725 let mut url = self.hub._base_url.clone() + "v1/{+name}";
27726 if self._scopes.is_empty() {
27727 self._scopes
27728 .insert(Scope::CloudPlatform.as_ref().to_string());
27729 }
27730
27731 #[allow(clippy::single_element_loop)]
27732 for &(find_this, param_name) in [("{+name}", "name")].iter() {
27733 url = params.uri_replacement(url, param_name, find_this, true);
27734 }
27735 {
27736 let to_remove = ["name"];
27737 params.remove_params(&to_remove);
27738 }
27739
27740 let url = params.parse_with_url(&url);
27741
27742 loop {
27743 let token = match self
27744 .hub
27745 .auth
27746 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
27747 .await
27748 {
27749 Ok(token) => token,
27750 Err(e) => match dlg.token(e) {
27751 Ok(token) => token,
27752 Err(e) => {
27753 dlg.finished(false);
27754 return Err(common::Error::MissingToken(e));
27755 }
27756 },
27757 };
27758 let mut req_result = {
27759 let client = &self.hub.client;
27760 dlg.pre_request();
27761 let mut req_builder = hyper::Request::builder()
27762 .method(hyper::Method::GET)
27763 .uri(url.as_str())
27764 .header(USER_AGENT, self.hub._user_agent.clone());
27765
27766 if let Some(token) = token.as_ref() {
27767 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
27768 }
27769
27770 let request = req_builder
27771 .header(CONTENT_LENGTH, 0_u64)
27772 .body(common::to_body::<String>(None));
27773
27774 client.request(request.unwrap()).await
27775 };
27776
27777 match req_result {
27778 Err(err) => {
27779 if let common::Retry::After(d) = dlg.http_error(&err) {
27780 sleep(d).await;
27781 continue;
27782 }
27783 dlg.finished(false);
27784 return Err(common::Error::HttpError(err));
27785 }
27786 Ok(res) => {
27787 let (mut parts, body) = res.into_parts();
27788 let mut body = common::Body::new(body);
27789 if !parts.status.is_success() {
27790 let bytes = common::to_bytes(body).await.unwrap_or_default();
27791 let error = serde_json::from_str(&common::to_string(&bytes));
27792 let response = common::to_response(parts, bytes.into());
27793
27794 if let common::Retry::After(d) =
27795 dlg.http_failure(&response, error.as_ref().ok())
27796 {
27797 sleep(d).await;
27798 continue;
27799 }
27800
27801 dlg.finished(false);
27802
27803 return Err(match error {
27804 Ok(value) => common::Error::BadRequest(value),
27805 _ => common::Error::Failure(response),
27806 });
27807 }
27808 let response = {
27809 let bytes = common::to_bytes(body).await.unwrap_or_default();
27810 let encoded = common::to_string(&bytes);
27811 match serde_json::from_str(&encoded) {
27812 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
27813 Err(error) => {
27814 dlg.response_json_decode_error(&encoded, &error);
27815 return Err(common::Error::JsonDecodeError(
27816 encoded.to_string(),
27817 error,
27818 ));
27819 }
27820 }
27821 };
27822
27823 dlg.finished(true);
27824 return Ok(response);
27825 }
27826 }
27827 }
27828 }
27829
27830 /// Required. A name of the ServiceLbPolicy to get. Must be in the format `projects/{project}/locations/{location}/serviceLbPolicies/*`.
27831 ///
27832 /// Sets the *name* path property to the given value.
27833 ///
27834 /// Even though the property as already been set when instantiating this call,
27835 /// we provide this method for API completeness.
27836 pub fn name(mut self, new_value: &str) -> ProjectLocationServiceLbPolicyGetCall<'a, C> {
27837 self._name = new_value.to_string();
27838 self
27839 }
27840 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
27841 /// while executing the actual API request.
27842 ///
27843 /// ````text
27844 /// It should be used to handle progress information, and to implement a certain level of resilience.
27845 /// ````
27846 ///
27847 /// Sets the *delegate* property to the given value.
27848 pub fn delegate(
27849 mut self,
27850 new_value: &'a mut dyn common::Delegate,
27851 ) -> ProjectLocationServiceLbPolicyGetCall<'a, C> {
27852 self._delegate = Some(new_value);
27853 self
27854 }
27855
27856 /// Set any additional parameter of the query string used in the request.
27857 /// It should be used to set parameters which are not yet available through their own
27858 /// setters.
27859 ///
27860 /// Please note that this method must not be used to set any of the known parameters
27861 /// which have their own setter method. If done anyway, the request will fail.
27862 ///
27863 /// # Additional Parameters
27864 ///
27865 /// * *$.xgafv* (query-string) - V1 error format.
27866 /// * *access_token* (query-string) - OAuth access token.
27867 /// * *alt* (query-string) - Data format for response.
27868 /// * *callback* (query-string) - JSONP
27869 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
27870 /// * *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.
27871 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
27872 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
27873 /// * *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.
27874 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
27875 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
27876 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationServiceLbPolicyGetCall<'a, C>
27877 where
27878 T: AsRef<str>,
27879 {
27880 self._additional_params
27881 .insert(name.as_ref().to_string(), value.as_ref().to_string());
27882 self
27883 }
27884
27885 /// Identifies the authorization scope for the method you are building.
27886 ///
27887 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
27888 /// [`Scope::CloudPlatform`].
27889 ///
27890 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
27891 /// tokens for more than one scope.
27892 ///
27893 /// Usually there is more than one suitable scope to authorize an operation, some of which may
27894 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
27895 /// sufficient, a read-write scope will do as well.
27896 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationServiceLbPolicyGetCall<'a, C>
27897 where
27898 St: AsRef<str>,
27899 {
27900 self._scopes.insert(String::from(scope.as_ref()));
27901 self
27902 }
27903 /// Identifies the authorization scope(s) for the method you are building.
27904 ///
27905 /// See [`Self::add_scope()`] for details.
27906 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationServiceLbPolicyGetCall<'a, C>
27907 where
27908 I: IntoIterator<Item = St>,
27909 St: AsRef<str>,
27910 {
27911 self._scopes
27912 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
27913 self
27914 }
27915
27916 /// Removes all scopes, and no default scope will be used either.
27917 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
27918 /// for details).
27919 pub fn clear_scopes(mut self) -> ProjectLocationServiceLbPolicyGetCall<'a, C> {
27920 self._scopes.clear();
27921 self
27922 }
27923}
27924
27925/// Lists ServiceLbPolicies in a given project and location.
27926///
27927/// A builder for the *locations.serviceLbPolicies.list* method supported by a *project* resource.
27928/// It is not used directly, but through a [`ProjectMethods`] instance.
27929///
27930/// # Example
27931///
27932/// Instantiate a resource method builder
27933///
27934/// ```test_harness,no_run
27935/// # extern crate hyper;
27936/// # extern crate hyper_rustls;
27937/// # extern crate google_networkservices1 as networkservices1;
27938/// # async fn dox() {
27939/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
27940///
27941/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
27942/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
27943/// # .with_native_roots()
27944/// # .unwrap()
27945/// # .https_only()
27946/// # .enable_http2()
27947/// # .build();
27948///
27949/// # let executor = hyper_util::rt::TokioExecutor::new();
27950/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
27951/// # secret,
27952/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
27953/// # yup_oauth2::client::CustomHyperClientBuilder::from(
27954/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
27955/// # ),
27956/// # ).build().await.unwrap();
27957///
27958/// # let client = hyper_util::client::legacy::Client::builder(
27959/// # hyper_util::rt::TokioExecutor::new()
27960/// # )
27961/// # .build(
27962/// # hyper_rustls::HttpsConnectorBuilder::new()
27963/// # .with_native_roots()
27964/// # .unwrap()
27965/// # .https_or_http()
27966/// # .enable_http2()
27967/// # .build()
27968/// # );
27969/// # let mut hub = NetworkServices::new(client, auth);
27970/// // You can configure optional parameters by calling the respective setters at will, and
27971/// // execute the final call using `doit()`.
27972/// // Values shown here are possibly random and not representative !
27973/// let result = hub.projects().locations_service_lb_policies_list("parent")
27974/// .page_token("Lorem")
27975/// .page_size(-17)
27976/// .doit().await;
27977/// # }
27978/// ```
27979pub struct ProjectLocationServiceLbPolicyListCall<'a, C>
27980where
27981 C: 'a,
27982{
27983 hub: &'a NetworkServices<C>,
27984 _parent: String,
27985 _page_token: Option<String>,
27986 _page_size: Option<i32>,
27987 _delegate: Option<&'a mut dyn common::Delegate>,
27988 _additional_params: HashMap<String, String>,
27989 _scopes: BTreeSet<String>,
27990}
27991
27992impl<'a, C> common::CallBuilder for ProjectLocationServiceLbPolicyListCall<'a, C> {}
27993
27994impl<'a, C> ProjectLocationServiceLbPolicyListCall<'a, C>
27995where
27996 C: common::Connector,
27997{
27998 /// Perform the operation you have build so far.
27999 pub async fn doit(
28000 mut self,
28001 ) -> common::Result<(common::Response, ListServiceLbPoliciesResponse)> {
28002 use std::borrow::Cow;
28003 use std::io::{Read, Seek};
28004
28005 use common::{url::Params, ToParts};
28006 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
28007
28008 let mut dd = common::DefaultDelegate;
28009 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
28010 dlg.begin(common::MethodInfo {
28011 id: "networkservices.projects.locations.serviceLbPolicies.list",
28012 http_method: hyper::Method::GET,
28013 });
28014
28015 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
28016 if self._additional_params.contains_key(field) {
28017 dlg.finished(false);
28018 return Err(common::Error::FieldClash(field));
28019 }
28020 }
28021
28022 let mut params = Params::with_capacity(5 + self._additional_params.len());
28023 params.push("parent", self._parent);
28024 if let Some(value) = self._page_token.as_ref() {
28025 params.push("pageToken", value);
28026 }
28027 if let Some(value) = self._page_size.as_ref() {
28028 params.push("pageSize", value.to_string());
28029 }
28030
28031 params.extend(self._additional_params.iter());
28032
28033 params.push("alt", "json");
28034 let mut url = self.hub._base_url.clone() + "v1/{+parent}/serviceLbPolicies";
28035 if self._scopes.is_empty() {
28036 self._scopes
28037 .insert(Scope::CloudPlatform.as_ref().to_string());
28038 }
28039
28040 #[allow(clippy::single_element_loop)]
28041 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
28042 url = params.uri_replacement(url, param_name, find_this, true);
28043 }
28044 {
28045 let to_remove = ["parent"];
28046 params.remove_params(&to_remove);
28047 }
28048
28049 let url = params.parse_with_url(&url);
28050
28051 loop {
28052 let token = match self
28053 .hub
28054 .auth
28055 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
28056 .await
28057 {
28058 Ok(token) => token,
28059 Err(e) => match dlg.token(e) {
28060 Ok(token) => token,
28061 Err(e) => {
28062 dlg.finished(false);
28063 return Err(common::Error::MissingToken(e));
28064 }
28065 },
28066 };
28067 let mut req_result = {
28068 let client = &self.hub.client;
28069 dlg.pre_request();
28070 let mut req_builder = hyper::Request::builder()
28071 .method(hyper::Method::GET)
28072 .uri(url.as_str())
28073 .header(USER_AGENT, self.hub._user_agent.clone());
28074
28075 if let Some(token) = token.as_ref() {
28076 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
28077 }
28078
28079 let request = req_builder
28080 .header(CONTENT_LENGTH, 0_u64)
28081 .body(common::to_body::<String>(None));
28082
28083 client.request(request.unwrap()).await
28084 };
28085
28086 match req_result {
28087 Err(err) => {
28088 if let common::Retry::After(d) = dlg.http_error(&err) {
28089 sleep(d).await;
28090 continue;
28091 }
28092 dlg.finished(false);
28093 return Err(common::Error::HttpError(err));
28094 }
28095 Ok(res) => {
28096 let (mut parts, body) = res.into_parts();
28097 let mut body = common::Body::new(body);
28098 if !parts.status.is_success() {
28099 let bytes = common::to_bytes(body).await.unwrap_or_default();
28100 let error = serde_json::from_str(&common::to_string(&bytes));
28101 let response = common::to_response(parts, bytes.into());
28102
28103 if let common::Retry::After(d) =
28104 dlg.http_failure(&response, error.as_ref().ok())
28105 {
28106 sleep(d).await;
28107 continue;
28108 }
28109
28110 dlg.finished(false);
28111
28112 return Err(match error {
28113 Ok(value) => common::Error::BadRequest(value),
28114 _ => common::Error::Failure(response),
28115 });
28116 }
28117 let response = {
28118 let bytes = common::to_bytes(body).await.unwrap_or_default();
28119 let encoded = common::to_string(&bytes);
28120 match serde_json::from_str(&encoded) {
28121 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
28122 Err(error) => {
28123 dlg.response_json_decode_error(&encoded, &error);
28124 return Err(common::Error::JsonDecodeError(
28125 encoded.to_string(),
28126 error,
28127 ));
28128 }
28129 }
28130 };
28131
28132 dlg.finished(true);
28133 return Ok(response);
28134 }
28135 }
28136 }
28137 }
28138
28139 /// Required. The project and location from which the ServiceLbPolicies should be listed, specified in the format `projects/{project}/locations/{location}`.
28140 ///
28141 /// Sets the *parent* path property to the given value.
28142 ///
28143 /// Even though the property as already been set when instantiating this call,
28144 /// we provide this method for API completeness.
28145 pub fn parent(mut self, new_value: &str) -> ProjectLocationServiceLbPolicyListCall<'a, C> {
28146 self._parent = new_value.to_string();
28147 self
28148 }
28149 /// The value returned by the last `ListServiceLbPoliciesResponse` Indicates that this is a continuation of a prior `ListRouters` call, and that the system should return the next page of data.
28150 ///
28151 /// Sets the *page token* query property to the given value.
28152 pub fn page_token(mut self, new_value: &str) -> ProjectLocationServiceLbPolicyListCall<'a, C> {
28153 self._page_token = Some(new_value.to_string());
28154 self
28155 }
28156 /// Maximum number of ServiceLbPolicies to return per call.
28157 ///
28158 /// Sets the *page size* query property to the given value.
28159 pub fn page_size(mut self, new_value: i32) -> ProjectLocationServiceLbPolicyListCall<'a, C> {
28160 self._page_size = Some(new_value);
28161 self
28162 }
28163 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
28164 /// while executing the actual API request.
28165 ///
28166 /// ````text
28167 /// It should be used to handle progress information, and to implement a certain level of resilience.
28168 /// ````
28169 ///
28170 /// Sets the *delegate* property to the given value.
28171 pub fn delegate(
28172 mut self,
28173 new_value: &'a mut dyn common::Delegate,
28174 ) -> ProjectLocationServiceLbPolicyListCall<'a, C> {
28175 self._delegate = Some(new_value);
28176 self
28177 }
28178
28179 /// Set any additional parameter of the query string used in the request.
28180 /// It should be used to set parameters which are not yet available through their own
28181 /// setters.
28182 ///
28183 /// Please note that this method must not be used to set any of the known parameters
28184 /// which have their own setter method. If done anyway, the request will fail.
28185 ///
28186 /// # Additional Parameters
28187 ///
28188 /// * *$.xgafv* (query-string) - V1 error format.
28189 /// * *access_token* (query-string) - OAuth access token.
28190 /// * *alt* (query-string) - Data format for response.
28191 /// * *callback* (query-string) - JSONP
28192 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
28193 /// * *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.
28194 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
28195 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
28196 /// * *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.
28197 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
28198 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
28199 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationServiceLbPolicyListCall<'a, C>
28200 where
28201 T: AsRef<str>,
28202 {
28203 self._additional_params
28204 .insert(name.as_ref().to_string(), value.as_ref().to_string());
28205 self
28206 }
28207
28208 /// Identifies the authorization scope for the method you are building.
28209 ///
28210 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
28211 /// [`Scope::CloudPlatform`].
28212 ///
28213 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
28214 /// tokens for more than one scope.
28215 ///
28216 /// Usually there is more than one suitable scope to authorize an operation, some of which may
28217 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
28218 /// sufficient, a read-write scope will do as well.
28219 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationServiceLbPolicyListCall<'a, C>
28220 where
28221 St: AsRef<str>,
28222 {
28223 self._scopes.insert(String::from(scope.as_ref()));
28224 self
28225 }
28226 /// Identifies the authorization scope(s) for the method you are building.
28227 ///
28228 /// See [`Self::add_scope()`] for details.
28229 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationServiceLbPolicyListCall<'a, C>
28230 where
28231 I: IntoIterator<Item = St>,
28232 St: AsRef<str>,
28233 {
28234 self._scopes
28235 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
28236 self
28237 }
28238
28239 /// Removes all scopes, and no default scope will be used either.
28240 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
28241 /// for details).
28242 pub fn clear_scopes(mut self) -> ProjectLocationServiceLbPolicyListCall<'a, C> {
28243 self._scopes.clear();
28244 self
28245 }
28246}
28247
28248/// Updates the parameters of a single ServiceLbPolicy.
28249///
28250/// A builder for the *locations.serviceLbPolicies.patch* method supported by a *project* resource.
28251/// It is not used directly, but through a [`ProjectMethods`] instance.
28252///
28253/// # Example
28254///
28255/// Instantiate a resource method builder
28256///
28257/// ```test_harness,no_run
28258/// # extern crate hyper;
28259/// # extern crate hyper_rustls;
28260/// # extern crate google_networkservices1 as networkservices1;
28261/// use networkservices1::api::ServiceLbPolicy;
28262/// # async fn dox() {
28263/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
28264///
28265/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
28266/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
28267/// # .with_native_roots()
28268/// # .unwrap()
28269/// # .https_only()
28270/// # .enable_http2()
28271/// # .build();
28272///
28273/// # let executor = hyper_util::rt::TokioExecutor::new();
28274/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
28275/// # secret,
28276/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
28277/// # yup_oauth2::client::CustomHyperClientBuilder::from(
28278/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
28279/// # ),
28280/// # ).build().await.unwrap();
28281///
28282/// # let client = hyper_util::client::legacy::Client::builder(
28283/// # hyper_util::rt::TokioExecutor::new()
28284/// # )
28285/// # .build(
28286/// # hyper_rustls::HttpsConnectorBuilder::new()
28287/// # .with_native_roots()
28288/// # .unwrap()
28289/// # .https_or_http()
28290/// # .enable_http2()
28291/// # .build()
28292/// # );
28293/// # let mut hub = NetworkServices::new(client, auth);
28294/// // As the method needs a request, you would usually fill it with the desired information
28295/// // into the respective structure. Some of the parts shown here might not be applicable !
28296/// // Values shown here are possibly random and not representative !
28297/// let mut req = ServiceLbPolicy::default();
28298///
28299/// // You can configure optional parameters by calling the respective setters at will, and
28300/// // execute the final call using `doit()`.
28301/// // Values shown here are possibly random and not representative !
28302/// let result = hub.projects().locations_service_lb_policies_patch(req, "name")
28303/// .update_mask(FieldMask::new::<&str>(&[]))
28304/// .doit().await;
28305/// # }
28306/// ```
28307pub struct ProjectLocationServiceLbPolicyPatchCall<'a, C>
28308where
28309 C: 'a,
28310{
28311 hub: &'a NetworkServices<C>,
28312 _request: ServiceLbPolicy,
28313 _name: String,
28314 _update_mask: Option<common::FieldMask>,
28315 _delegate: Option<&'a mut dyn common::Delegate>,
28316 _additional_params: HashMap<String, String>,
28317 _scopes: BTreeSet<String>,
28318}
28319
28320impl<'a, C> common::CallBuilder for ProjectLocationServiceLbPolicyPatchCall<'a, C> {}
28321
28322impl<'a, C> ProjectLocationServiceLbPolicyPatchCall<'a, C>
28323where
28324 C: common::Connector,
28325{
28326 /// Perform the operation you have build so far.
28327 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
28328 use std::borrow::Cow;
28329 use std::io::{Read, Seek};
28330
28331 use common::{url::Params, ToParts};
28332 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
28333
28334 let mut dd = common::DefaultDelegate;
28335 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
28336 dlg.begin(common::MethodInfo {
28337 id: "networkservices.projects.locations.serviceLbPolicies.patch",
28338 http_method: hyper::Method::PATCH,
28339 });
28340
28341 for &field in ["alt", "name", "updateMask"].iter() {
28342 if self._additional_params.contains_key(field) {
28343 dlg.finished(false);
28344 return Err(common::Error::FieldClash(field));
28345 }
28346 }
28347
28348 let mut params = Params::with_capacity(5 + self._additional_params.len());
28349 params.push("name", self._name);
28350 if let Some(value) = self._update_mask.as_ref() {
28351 params.push("updateMask", value.to_string());
28352 }
28353
28354 params.extend(self._additional_params.iter());
28355
28356 params.push("alt", "json");
28357 let mut url = self.hub._base_url.clone() + "v1/{+name}";
28358 if self._scopes.is_empty() {
28359 self._scopes
28360 .insert(Scope::CloudPlatform.as_ref().to_string());
28361 }
28362
28363 #[allow(clippy::single_element_loop)]
28364 for &(find_this, param_name) in [("{+name}", "name")].iter() {
28365 url = params.uri_replacement(url, param_name, find_this, true);
28366 }
28367 {
28368 let to_remove = ["name"];
28369 params.remove_params(&to_remove);
28370 }
28371
28372 let url = params.parse_with_url(&url);
28373
28374 let mut json_mime_type = mime::APPLICATION_JSON;
28375 let mut request_value_reader = {
28376 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
28377 common::remove_json_null_values(&mut value);
28378 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
28379 serde_json::to_writer(&mut dst, &value).unwrap();
28380 dst
28381 };
28382 let request_size = request_value_reader
28383 .seek(std::io::SeekFrom::End(0))
28384 .unwrap();
28385 request_value_reader
28386 .seek(std::io::SeekFrom::Start(0))
28387 .unwrap();
28388
28389 loop {
28390 let token = match self
28391 .hub
28392 .auth
28393 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
28394 .await
28395 {
28396 Ok(token) => token,
28397 Err(e) => match dlg.token(e) {
28398 Ok(token) => token,
28399 Err(e) => {
28400 dlg.finished(false);
28401 return Err(common::Error::MissingToken(e));
28402 }
28403 },
28404 };
28405 request_value_reader
28406 .seek(std::io::SeekFrom::Start(0))
28407 .unwrap();
28408 let mut req_result = {
28409 let client = &self.hub.client;
28410 dlg.pre_request();
28411 let mut req_builder = hyper::Request::builder()
28412 .method(hyper::Method::PATCH)
28413 .uri(url.as_str())
28414 .header(USER_AGENT, self.hub._user_agent.clone());
28415
28416 if let Some(token) = token.as_ref() {
28417 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
28418 }
28419
28420 let request = req_builder
28421 .header(CONTENT_TYPE, json_mime_type.to_string())
28422 .header(CONTENT_LENGTH, request_size as u64)
28423 .body(common::to_body(
28424 request_value_reader.get_ref().clone().into(),
28425 ));
28426
28427 client.request(request.unwrap()).await
28428 };
28429
28430 match req_result {
28431 Err(err) => {
28432 if let common::Retry::After(d) = dlg.http_error(&err) {
28433 sleep(d).await;
28434 continue;
28435 }
28436 dlg.finished(false);
28437 return Err(common::Error::HttpError(err));
28438 }
28439 Ok(res) => {
28440 let (mut parts, body) = res.into_parts();
28441 let mut body = common::Body::new(body);
28442 if !parts.status.is_success() {
28443 let bytes = common::to_bytes(body).await.unwrap_or_default();
28444 let error = serde_json::from_str(&common::to_string(&bytes));
28445 let response = common::to_response(parts, bytes.into());
28446
28447 if let common::Retry::After(d) =
28448 dlg.http_failure(&response, error.as_ref().ok())
28449 {
28450 sleep(d).await;
28451 continue;
28452 }
28453
28454 dlg.finished(false);
28455
28456 return Err(match error {
28457 Ok(value) => common::Error::BadRequest(value),
28458 _ => common::Error::Failure(response),
28459 });
28460 }
28461 let response = {
28462 let bytes = common::to_bytes(body).await.unwrap_or_default();
28463 let encoded = common::to_string(&bytes);
28464 match serde_json::from_str(&encoded) {
28465 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
28466 Err(error) => {
28467 dlg.response_json_decode_error(&encoded, &error);
28468 return Err(common::Error::JsonDecodeError(
28469 encoded.to_string(),
28470 error,
28471 ));
28472 }
28473 }
28474 };
28475
28476 dlg.finished(true);
28477 return Ok(response);
28478 }
28479 }
28480 }
28481 }
28482
28483 ///
28484 /// Sets the *request* property to the given value.
28485 ///
28486 /// Even though the property as already been set when instantiating this call,
28487 /// we provide this method for API completeness.
28488 pub fn request(
28489 mut self,
28490 new_value: ServiceLbPolicy,
28491 ) -> ProjectLocationServiceLbPolicyPatchCall<'a, C> {
28492 self._request = new_value;
28493 self
28494 }
28495 /// Identifier. Name of the ServiceLbPolicy resource. It matches pattern `projects/{project}/locations/{location}/serviceLbPolicies/{service_lb_policy_name}`.
28496 ///
28497 /// Sets the *name* path property to the given value.
28498 ///
28499 /// Even though the property as already been set when instantiating this call,
28500 /// we provide this method for API completeness.
28501 pub fn name(mut self, new_value: &str) -> ProjectLocationServiceLbPolicyPatchCall<'a, C> {
28502 self._name = new_value.to_string();
28503 self
28504 }
28505 /// Optional. Field mask is used to specify the fields to be overwritten in the ServiceLbPolicy 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.
28506 ///
28507 /// Sets the *update mask* query property to the given value.
28508 pub fn update_mask(
28509 mut self,
28510 new_value: common::FieldMask,
28511 ) -> ProjectLocationServiceLbPolicyPatchCall<'a, C> {
28512 self._update_mask = Some(new_value);
28513 self
28514 }
28515 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
28516 /// while executing the actual API request.
28517 ///
28518 /// ````text
28519 /// It should be used to handle progress information, and to implement a certain level of resilience.
28520 /// ````
28521 ///
28522 /// Sets the *delegate* property to the given value.
28523 pub fn delegate(
28524 mut self,
28525 new_value: &'a mut dyn common::Delegate,
28526 ) -> ProjectLocationServiceLbPolicyPatchCall<'a, C> {
28527 self._delegate = Some(new_value);
28528 self
28529 }
28530
28531 /// Set any additional parameter of the query string used in the request.
28532 /// It should be used to set parameters which are not yet available through their own
28533 /// setters.
28534 ///
28535 /// Please note that this method must not be used to set any of the known parameters
28536 /// which have their own setter method. If done anyway, the request will fail.
28537 ///
28538 /// # Additional Parameters
28539 ///
28540 /// * *$.xgafv* (query-string) - V1 error format.
28541 /// * *access_token* (query-string) - OAuth access token.
28542 /// * *alt* (query-string) - Data format for response.
28543 /// * *callback* (query-string) - JSONP
28544 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
28545 /// * *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.
28546 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
28547 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
28548 /// * *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.
28549 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
28550 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
28551 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationServiceLbPolicyPatchCall<'a, C>
28552 where
28553 T: AsRef<str>,
28554 {
28555 self._additional_params
28556 .insert(name.as_ref().to_string(), value.as_ref().to_string());
28557 self
28558 }
28559
28560 /// Identifies the authorization scope for the method you are building.
28561 ///
28562 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
28563 /// [`Scope::CloudPlatform`].
28564 ///
28565 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
28566 /// tokens for more than one scope.
28567 ///
28568 /// Usually there is more than one suitable scope to authorize an operation, some of which may
28569 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
28570 /// sufficient, a read-write scope will do as well.
28571 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationServiceLbPolicyPatchCall<'a, C>
28572 where
28573 St: AsRef<str>,
28574 {
28575 self._scopes.insert(String::from(scope.as_ref()));
28576 self
28577 }
28578 /// Identifies the authorization scope(s) for the method you are building.
28579 ///
28580 /// See [`Self::add_scope()`] for details.
28581 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationServiceLbPolicyPatchCall<'a, C>
28582 where
28583 I: IntoIterator<Item = St>,
28584 St: AsRef<str>,
28585 {
28586 self._scopes
28587 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
28588 self
28589 }
28590
28591 /// Removes all scopes, and no default scope will be used either.
28592 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
28593 /// for details).
28594 pub fn clear_scopes(mut self) -> ProjectLocationServiceLbPolicyPatchCall<'a, C> {
28595 self._scopes.clear();
28596 self
28597 }
28598}
28599
28600/// Creates a new TcpRoute in a given project and location.
28601///
28602/// A builder for the *locations.tcpRoutes.create* method supported by a *project* resource.
28603/// It is not used directly, but through a [`ProjectMethods`] instance.
28604///
28605/// # Example
28606///
28607/// Instantiate a resource method builder
28608///
28609/// ```test_harness,no_run
28610/// # extern crate hyper;
28611/// # extern crate hyper_rustls;
28612/// # extern crate google_networkservices1 as networkservices1;
28613/// use networkservices1::api::TcpRoute;
28614/// # async fn dox() {
28615/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
28616///
28617/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
28618/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
28619/// # .with_native_roots()
28620/// # .unwrap()
28621/// # .https_only()
28622/// # .enable_http2()
28623/// # .build();
28624///
28625/// # let executor = hyper_util::rt::TokioExecutor::new();
28626/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
28627/// # secret,
28628/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
28629/// # yup_oauth2::client::CustomHyperClientBuilder::from(
28630/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
28631/// # ),
28632/// # ).build().await.unwrap();
28633///
28634/// # let client = hyper_util::client::legacy::Client::builder(
28635/// # hyper_util::rt::TokioExecutor::new()
28636/// # )
28637/// # .build(
28638/// # hyper_rustls::HttpsConnectorBuilder::new()
28639/// # .with_native_roots()
28640/// # .unwrap()
28641/// # .https_or_http()
28642/// # .enable_http2()
28643/// # .build()
28644/// # );
28645/// # let mut hub = NetworkServices::new(client, auth);
28646/// // As the method needs a request, you would usually fill it with the desired information
28647/// // into the respective structure. Some of the parts shown here might not be applicable !
28648/// // Values shown here are possibly random and not representative !
28649/// let mut req = TcpRoute::default();
28650///
28651/// // You can configure optional parameters by calling the respective setters at will, and
28652/// // execute the final call using `doit()`.
28653/// // Values shown here are possibly random and not representative !
28654/// let result = hub.projects().locations_tcp_routes_create(req, "parent")
28655/// .tcp_route_id("eos")
28656/// .doit().await;
28657/// # }
28658/// ```
28659pub struct ProjectLocationTcpRouteCreateCall<'a, C>
28660where
28661 C: 'a,
28662{
28663 hub: &'a NetworkServices<C>,
28664 _request: TcpRoute,
28665 _parent: String,
28666 _tcp_route_id: Option<String>,
28667 _delegate: Option<&'a mut dyn common::Delegate>,
28668 _additional_params: HashMap<String, String>,
28669 _scopes: BTreeSet<String>,
28670}
28671
28672impl<'a, C> common::CallBuilder for ProjectLocationTcpRouteCreateCall<'a, C> {}
28673
28674impl<'a, C> ProjectLocationTcpRouteCreateCall<'a, C>
28675where
28676 C: common::Connector,
28677{
28678 /// Perform the operation you have build so far.
28679 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
28680 use std::borrow::Cow;
28681 use std::io::{Read, Seek};
28682
28683 use common::{url::Params, ToParts};
28684 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
28685
28686 let mut dd = common::DefaultDelegate;
28687 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
28688 dlg.begin(common::MethodInfo {
28689 id: "networkservices.projects.locations.tcpRoutes.create",
28690 http_method: hyper::Method::POST,
28691 });
28692
28693 for &field in ["alt", "parent", "tcpRouteId"].iter() {
28694 if self._additional_params.contains_key(field) {
28695 dlg.finished(false);
28696 return Err(common::Error::FieldClash(field));
28697 }
28698 }
28699
28700 let mut params = Params::with_capacity(5 + self._additional_params.len());
28701 params.push("parent", self._parent);
28702 if let Some(value) = self._tcp_route_id.as_ref() {
28703 params.push("tcpRouteId", value);
28704 }
28705
28706 params.extend(self._additional_params.iter());
28707
28708 params.push("alt", "json");
28709 let mut url = self.hub._base_url.clone() + "v1/{+parent}/tcpRoutes";
28710 if self._scopes.is_empty() {
28711 self._scopes
28712 .insert(Scope::CloudPlatform.as_ref().to_string());
28713 }
28714
28715 #[allow(clippy::single_element_loop)]
28716 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
28717 url = params.uri_replacement(url, param_name, find_this, true);
28718 }
28719 {
28720 let to_remove = ["parent"];
28721 params.remove_params(&to_remove);
28722 }
28723
28724 let url = params.parse_with_url(&url);
28725
28726 let mut json_mime_type = mime::APPLICATION_JSON;
28727 let mut request_value_reader = {
28728 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
28729 common::remove_json_null_values(&mut value);
28730 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
28731 serde_json::to_writer(&mut dst, &value).unwrap();
28732 dst
28733 };
28734 let request_size = request_value_reader
28735 .seek(std::io::SeekFrom::End(0))
28736 .unwrap();
28737 request_value_reader
28738 .seek(std::io::SeekFrom::Start(0))
28739 .unwrap();
28740
28741 loop {
28742 let token = match self
28743 .hub
28744 .auth
28745 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
28746 .await
28747 {
28748 Ok(token) => token,
28749 Err(e) => match dlg.token(e) {
28750 Ok(token) => token,
28751 Err(e) => {
28752 dlg.finished(false);
28753 return Err(common::Error::MissingToken(e));
28754 }
28755 },
28756 };
28757 request_value_reader
28758 .seek(std::io::SeekFrom::Start(0))
28759 .unwrap();
28760 let mut req_result = {
28761 let client = &self.hub.client;
28762 dlg.pre_request();
28763 let mut req_builder = hyper::Request::builder()
28764 .method(hyper::Method::POST)
28765 .uri(url.as_str())
28766 .header(USER_AGENT, self.hub._user_agent.clone());
28767
28768 if let Some(token) = token.as_ref() {
28769 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
28770 }
28771
28772 let request = req_builder
28773 .header(CONTENT_TYPE, json_mime_type.to_string())
28774 .header(CONTENT_LENGTH, request_size as u64)
28775 .body(common::to_body(
28776 request_value_reader.get_ref().clone().into(),
28777 ));
28778
28779 client.request(request.unwrap()).await
28780 };
28781
28782 match req_result {
28783 Err(err) => {
28784 if let common::Retry::After(d) = dlg.http_error(&err) {
28785 sleep(d).await;
28786 continue;
28787 }
28788 dlg.finished(false);
28789 return Err(common::Error::HttpError(err));
28790 }
28791 Ok(res) => {
28792 let (mut parts, body) = res.into_parts();
28793 let mut body = common::Body::new(body);
28794 if !parts.status.is_success() {
28795 let bytes = common::to_bytes(body).await.unwrap_or_default();
28796 let error = serde_json::from_str(&common::to_string(&bytes));
28797 let response = common::to_response(parts, bytes.into());
28798
28799 if let common::Retry::After(d) =
28800 dlg.http_failure(&response, error.as_ref().ok())
28801 {
28802 sleep(d).await;
28803 continue;
28804 }
28805
28806 dlg.finished(false);
28807
28808 return Err(match error {
28809 Ok(value) => common::Error::BadRequest(value),
28810 _ => common::Error::Failure(response),
28811 });
28812 }
28813 let response = {
28814 let bytes = common::to_bytes(body).await.unwrap_or_default();
28815 let encoded = common::to_string(&bytes);
28816 match serde_json::from_str(&encoded) {
28817 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
28818 Err(error) => {
28819 dlg.response_json_decode_error(&encoded, &error);
28820 return Err(common::Error::JsonDecodeError(
28821 encoded.to_string(),
28822 error,
28823 ));
28824 }
28825 }
28826 };
28827
28828 dlg.finished(true);
28829 return Ok(response);
28830 }
28831 }
28832 }
28833 }
28834
28835 ///
28836 /// Sets the *request* property to the given value.
28837 ///
28838 /// Even though the property as already been set when instantiating this call,
28839 /// we provide this method for API completeness.
28840 pub fn request(mut self, new_value: TcpRoute) -> ProjectLocationTcpRouteCreateCall<'a, C> {
28841 self._request = new_value;
28842 self
28843 }
28844 /// Required. The parent resource of the TcpRoute. Must be in the format `projects/*/locations/*`.
28845 ///
28846 /// Sets the *parent* path property to the given value.
28847 ///
28848 /// Even though the property as already been set when instantiating this call,
28849 /// we provide this method for API completeness.
28850 pub fn parent(mut self, new_value: &str) -> ProjectLocationTcpRouteCreateCall<'a, C> {
28851 self._parent = new_value.to_string();
28852 self
28853 }
28854 /// Required. Short name of the TcpRoute resource to be created.
28855 ///
28856 /// Sets the *tcp route id* query property to the given value.
28857 pub fn tcp_route_id(mut self, new_value: &str) -> ProjectLocationTcpRouteCreateCall<'a, C> {
28858 self._tcp_route_id = Some(new_value.to_string());
28859 self
28860 }
28861 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
28862 /// while executing the actual API request.
28863 ///
28864 /// ````text
28865 /// It should be used to handle progress information, and to implement a certain level of resilience.
28866 /// ````
28867 ///
28868 /// Sets the *delegate* property to the given value.
28869 pub fn delegate(
28870 mut self,
28871 new_value: &'a mut dyn common::Delegate,
28872 ) -> ProjectLocationTcpRouteCreateCall<'a, C> {
28873 self._delegate = Some(new_value);
28874 self
28875 }
28876
28877 /// Set any additional parameter of the query string used in the request.
28878 /// It should be used to set parameters which are not yet available through their own
28879 /// setters.
28880 ///
28881 /// Please note that this method must not be used to set any of the known parameters
28882 /// which have their own setter method. If done anyway, the request will fail.
28883 ///
28884 /// # Additional Parameters
28885 ///
28886 /// * *$.xgafv* (query-string) - V1 error format.
28887 /// * *access_token* (query-string) - OAuth access token.
28888 /// * *alt* (query-string) - Data format for response.
28889 /// * *callback* (query-string) - JSONP
28890 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
28891 /// * *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.
28892 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
28893 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
28894 /// * *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.
28895 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
28896 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
28897 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationTcpRouteCreateCall<'a, C>
28898 where
28899 T: AsRef<str>,
28900 {
28901 self._additional_params
28902 .insert(name.as_ref().to_string(), value.as_ref().to_string());
28903 self
28904 }
28905
28906 /// Identifies the authorization scope for the method you are building.
28907 ///
28908 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
28909 /// [`Scope::CloudPlatform`].
28910 ///
28911 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
28912 /// tokens for more than one scope.
28913 ///
28914 /// Usually there is more than one suitable scope to authorize an operation, some of which may
28915 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
28916 /// sufficient, a read-write scope will do as well.
28917 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationTcpRouteCreateCall<'a, C>
28918 where
28919 St: AsRef<str>,
28920 {
28921 self._scopes.insert(String::from(scope.as_ref()));
28922 self
28923 }
28924 /// Identifies the authorization scope(s) for the method you are building.
28925 ///
28926 /// See [`Self::add_scope()`] for details.
28927 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationTcpRouteCreateCall<'a, C>
28928 where
28929 I: IntoIterator<Item = St>,
28930 St: AsRef<str>,
28931 {
28932 self._scopes
28933 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
28934 self
28935 }
28936
28937 /// Removes all scopes, and no default scope will be used either.
28938 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
28939 /// for details).
28940 pub fn clear_scopes(mut self) -> ProjectLocationTcpRouteCreateCall<'a, C> {
28941 self._scopes.clear();
28942 self
28943 }
28944}
28945
28946/// Deletes a single TcpRoute.
28947///
28948/// A builder for the *locations.tcpRoutes.delete* method supported by a *project* resource.
28949/// It is not used directly, but through a [`ProjectMethods`] instance.
28950///
28951/// # Example
28952///
28953/// Instantiate a resource method builder
28954///
28955/// ```test_harness,no_run
28956/// # extern crate hyper;
28957/// # extern crate hyper_rustls;
28958/// # extern crate google_networkservices1 as networkservices1;
28959/// # async fn dox() {
28960/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
28961///
28962/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
28963/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
28964/// # .with_native_roots()
28965/// # .unwrap()
28966/// # .https_only()
28967/// # .enable_http2()
28968/// # .build();
28969///
28970/// # let executor = hyper_util::rt::TokioExecutor::new();
28971/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
28972/// # secret,
28973/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
28974/// # yup_oauth2::client::CustomHyperClientBuilder::from(
28975/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
28976/// # ),
28977/// # ).build().await.unwrap();
28978///
28979/// # let client = hyper_util::client::legacy::Client::builder(
28980/// # hyper_util::rt::TokioExecutor::new()
28981/// # )
28982/// # .build(
28983/// # hyper_rustls::HttpsConnectorBuilder::new()
28984/// # .with_native_roots()
28985/// # .unwrap()
28986/// # .https_or_http()
28987/// # .enable_http2()
28988/// # .build()
28989/// # );
28990/// # let mut hub = NetworkServices::new(client, auth);
28991/// // You can configure optional parameters by calling the respective setters at will, and
28992/// // execute the final call using `doit()`.
28993/// // Values shown here are possibly random and not representative !
28994/// let result = hub.projects().locations_tcp_routes_delete("name")
28995/// .doit().await;
28996/// # }
28997/// ```
28998pub struct ProjectLocationTcpRouteDeleteCall<'a, C>
28999where
29000 C: 'a,
29001{
29002 hub: &'a NetworkServices<C>,
29003 _name: String,
29004 _delegate: Option<&'a mut dyn common::Delegate>,
29005 _additional_params: HashMap<String, String>,
29006 _scopes: BTreeSet<String>,
29007}
29008
29009impl<'a, C> common::CallBuilder for ProjectLocationTcpRouteDeleteCall<'a, C> {}
29010
29011impl<'a, C> ProjectLocationTcpRouteDeleteCall<'a, C>
29012where
29013 C: common::Connector,
29014{
29015 /// Perform the operation you have build so far.
29016 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
29017 use std::borrow::Cow;
29018 use std::io::{Read, Seek};
29019
29020 use common::{url::Params, ToParts};
29021 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
29022
29023 let mut dd = common::DefaultDelegate;
29024 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
29025 dlg.begin(common::MethodInfo {
29026 id: "networkservices.projects.locations.tcpRoutes.delete",
29027 http_method: hyper::Method::DELETE,
29028 });
29029
29030 for &field in ["alt", "name"].iter() {
29031 if self._additional_params.contains_key(field) {
29032 dlg.finished(false);
29033 return Err(common::Error::FieldClash(field));
29034 }
29035 }
29036
29037 let mut params = Params::with_capacity(3 + self._additional_params.len());
29038 params.push("name", self._name);
29039
29040 params.extend(self._additional_params.iter());
29041
29042 params.push("alt", "json");
29043 let mut url = self.hub._base_url.clone() + "v1/{+name}";
29044 if self._scopes.is_empty() {
29045 self._scopes
29046 .insert(Scope::CloudPlatform.as_ref().to_string());
29047 }
29048
29049 #[allow(clippy::single_element_loop)]
29050 for &(find_this, param_name) in [("{+name}", "name")].iter() {
29051 url = params.uri_replacement(url, param_name, find_this, true);
29052 }
29053 {
29054 let to_remove = ["name"];
29055 params.remove_params(&to_remove);
29056 }
29057
29058 let url = params.parse_with_url(&url);
29059
29060 loop {
29061 let token = match self
29062 .hub
29063 .auth
29064 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
29065 .await
29066 {
29067 Ok(token) => token,
29068 Err(e) => match dlg.token(e) {
29069 Ok(token) => token,
29070 Err(e) => {
29071 dlg.finished(false);
29072 return Err(common::Error::MissingToken(e));
29073 }
29074 },
29075 };
29076 let mut req_result = {
29077 let client = &self.hub.client;
29078 dlg.pre_request();
29079 let mut req_builder = hyper::Request::builder()
29080 .method(hyper::Method::DELETE)
29081 .uri(url.as_str())
29082 .header(USER_AGENT, self.hub._user_agent.clone());
29083
29084 if let Some(token) = token.as_ref() {
29085 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
29086 }
29087
29088 let request = req_builder
29089 .header(CONTENT_LENGTH, 0_u64)
29090 .body(common::to_body::<String>(None));
29091
29092 client.request(request.unwrap()).await
29093 };
29094
29095 match req_result {
29096 Err(err) => {
29097 if let common::Retry::After(d) = dlg.http_error(&err) {
29098 sleep(d).await;
29099 continue;
29100 }
29101 dlg.finished(false);
29102 return Err(common::Error::HttpError(err));
29103 }
29104 Ok(res) => {
29105 let (mut parts, body) = res.into_parts();
29106 let mut body = common::Body::new(body);
29107 if !parts.status.is_success() {
29108 let bytes = common::to_bytes(body).await.unwrap_or_default();
29109 let error = serde_json::from_str(&common::to_string(&bytes));
29110 let response = common::to_response(parts, bytes.into());
29111
29112 if let common::Retry::After(d) =
29113 dlg.http_failure(&response, error.as_ref().ok())
29114 {
29115 sleep(d).await;
29116 continue;
29117 }
29118
29119 dlg.finished(false);
29120
29121 return Err(match error {
29122 Ok(value) => common::Error::BadRequest(value),
29123 _ => common::Error::Failure(response),
29124 });
29125 }
29126 let response = {
29127 let bytes = common::to_bytes(body).await.unwrap_or_default();
29128 let encoded = common::to_string(&bytes);
29129 match serde_json::from_str(&encoded) {
29130 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
29131 Err(error) => {
29132 dlg.response_json_decode_error(&encoded, &error);
29133 return Err(common::Error::JsonDecodeError(
29134 encoded.to_string(),
29135 error,
29136 ));
29137 }
29138 }
29139 };
29140
29141 dlg.finished(true);
29142 return Ok(response);
29143 }
29144 }
29145 }
29146 }
29147
29148 /// Required. A name of the TcpRoute to delete. Must be in the format `projects/*/locations/*/tcpRoutes/*`.
29149 ///
29150 /// Sets the *name* path property to the given value.
29151 ///
29152 /// Even though the property as already been set when instantiating this call,
29153 /// we provide this method for API completeness.
29154 pub fn name(mut self, new_value: &str) -> ProjectLocationTcpRouteDeleteCall<'a, C> {
29155 self._name = new_value.to_string();
29156 self
29157 }
29158 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
29159 /// while executing the actual API request.
29160 ///
29161 /// ````text
29162 /// It should be used to handle progress information, and to implement a certain level of resilience.
29163 /// ````
29164 ///
29165 /// Sets the *delegate* property to the given value.
29166 pub fn delegate(
29167 mut self,
29168 new_value: &'a mut dyn common::Delegate,
29169 ) -> ProjectLocationTcpRouteDeleteCall<'a, C> {
29170 self._delegate = Some(new_value);
29171 self
29172 }
29173
29174 /// Set any additional parameter of the query string used in the request.
29175 /// It should be used to set parameters which are not yet available through their own
29176 /// setters.
29177 ///
29178 /// Please note that this method must not be used to set any of the known parameters
29179 /// which have their own setter method. If done anyway, the request will fail.
29180 ///
29181 /// # Additional Parameters
29182 ///
29183 /// * *$.xgafv* (query-string) - V1 error format.
29184 /// * *access_token* (query-string) - OAuth access token.
29185 /// * *alt* (query-string) - Data format for response.
29186 /// * *callback* (query-string) - JSONP
29187 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
29188 /// * *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.
29189 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
29190 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
29191 /// * *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.
29192 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
29193 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
29194 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationTcpRouteDeleteCall<'a, C>
29195 where
29196 T: AsRef<str>,
29197 {
29198 self._additional_params
29199 .insert(name.as_ref().to_string(), value.as_ref().to_string());
29200 self
29201 }
29202
29203 /// Identifies the authorization scope for the method you are building.
29204 ///
29205 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
29206 /// [`Scope::CloudPlatform`].
29207 ///
29208 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
29209 /// tokens for more than one scope.
29210 ///
29211 /// Usually there is more than one suitable scope to authorize an operation, some of which may
29212 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
29213 /// sufficient, a read-write scope will do as well.
29214 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationTcpRouteDeleteCall<'a, C>
29215 where
29216 St: AsRef<str>,
29217 {
29218 self._scopes.insert(String::from(scope.as_ref()));
29219 self
29220 }
29221 /// Identifies the authorization scope(s) for the method you are building.
29222 ///
29223 /// See [`Self::add_scope()`] for details.
29224 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationTcpRouteDeleteCall<'a, C>
29225 where
29226 I: IntoIterator<Item = St>,
29227 St: AsRef<str>,
29228 {
29229 self._scopes
29230 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
29231 self
29232 }
29233
29234 /// Removes all scopes, and no default scope will be used either.
29235 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
29236 /// for details).
29237 pub fn clear_scopes(mut self) -> ProjectLocationTcpRouteDeleteCall<'a, C> {
29238 self._scopes.clear();
29239 self
29240 }
29241}
29242
29243/// Gets details of a single TcpRoute.
29244///
29245/// A builder for the *locations.tcpRoutes.get* method supported by a *project* resource.
29246/// It is not used directly, but through a [`ProjectMethods`] instance.
29247///
29248/// # Example
29249///
29250/// Instantiate a resource method builder
29251///
29252/// ```test_harness,no_run
29253/// # extern crate hyper;
29254/// # extern crate hyper_rustls;
29255/// # extern crate google_networkservices1 as networkservices1;
29256/// # async fn dox() {
29257/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
29258///
29259/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
29260/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
29261/// # .with_native_roots()
29262/// # .unwrap()
29263/// # .https_only()
29264/// # .enable_http2()
29265/// # .build();
29266///
29267/// # let executor = hyper_util::rt::TokioExecutor::new();
29268/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
29269/// # secret,
29270/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
29271/// # yup_oauth2::client::CustomHyperClientBuilder::from(
29272/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
29273/// # ),
29274/// # ).build().await.unwrap();
29275///
29276/// # let client = hyper_util::client::legacy::Client::builder(
29277/// # hyper_util::rt::TokioExecutor::new()
29278/// # )
29279/// # .build(
29280/// # hyper_rustls::HttpsConnectorBuilder::new()
29281/// # .with_native_roots()
29282/// # .unwrap()
29283/// # .https_or_http()
29284/// # .enable_http2()
29285/// # .build()
29286/// # );
29287/// # let mut hub = NetworkServices::new(client, auth);
29288/// // You can configure optional parameters by calling the respective setters at will, and
29289/// // execute the final call using `doit()`.
29290/// // Values shown here are possibly random and not representative !
29291/// let result = hub.projects().locations_tcp_routes_get("name")
29292/// .doit().await;
29293/// # }
29294/// ```
29295pub struct ProjectLocationTcpRouteGetCall<'a, C>
29296where
29297 C: 'a,
29298{
29299 hub: &'a NetworkServices<C>,
29300 _name: String,
29301 _delegate: Option<&'a mut dyn common::Delegate>,
29302 _additional_params: HashMap<String, String>,
29303 _scopes: BTreeSet<String>,
29304}
29305
29306impl<'a, C> common::CallBuilder for ProjectLocationTcpRouteGetCall<'a, C> {}
29307
29308impl<'a, C> ProjectLocationTcpRouteGetCall<'a, C>
29309where
29310 C: common::Connector,
29311{
29312 /// Perform the operation you have build so far.
29313 pub async fn doit(mut self) -> common::Result<(common::Response, TcpRoute)> {
29314 use std::borrow::Cow;
29315 use std::io::{Read, Seek};
29316
29317 use common::{url::Params, ToParts};
29318 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
29319
29320 let mut dd = common::DefaultDelegate;
29321 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
29322 dlg.begin(common::MethodInfo {
29323 id: "networkservices.projects.locations.tcpRoutes.get",
29324 http_method: hyper::Method::GET,
29325 });
29326
29327 for &field in ["alt", "name"].iter() {
29328 if self._additional_params.contains_key(field) {
29329 dlg.finished(false);
29330 return Err(common::Error::FieldClash(field));
29331 }
29332 }
29333
29334 let mut params = Params::with_capacity(3 + self._additional_params.len());
29335 params.push("name", self._name);
29336
29337 params.extend(self._additional_params.iter());
29338
29339 params.push("alt", "json");
29340 let mut url = self.hub._base_url.clone() + "v1/{+name}";
29341 if self._scopes.is_empty() {
29342 self._scopes
29343 .insert(Scope::CloudPlatform.as_ref().to_string());
29344 }
29345
29346 #[allow(clippy::single_element_loop)]
29347 for &(find_this, param_name) in [("{+name}", "name")].iter() {
29348 url = params.uri_replacement(url, param_name, find_this, true);
29349 }
29350 {
29351 let to_remove = ["name"];
29352 params.remove_params(&to_remove);
29353 }
29354
29355 let url = params.parse_with_url(&url);
29356
29357 loop {
29358 let token = match self
29359 .hub
29360 .auth
29361 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
29362 .await
29363 {
29364 Ok(token) => token,
29365 Err(e) => match dlg.token(e) {
29366 Ok(token) => token,
29367 Err(e) => {
29368 dlg.finished(false);
29369 return Err(common::Error::MissingToken(e));
29370 }
29371 },
29372 };
29373 let mut req_result = {
29374 let client = &self.hub.client;
29375 dlg.pre_request();
29376 let mut req_builder = hyper::Request::builder()
29377 .method(hyper::Method::GET)
29378 .uri(url.as_str())
29379 .header(USER_AGENT, self.hub._user_agent.clone());
29380
29381 if let Some(token) = token.as_ref() {
29382 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
29383 }
29384
29385 let request = req_builder
29386 .header(CONTENT_LENGTH, 0_u64)
29387 .body(common::to_body::<String>(None));
29388
29389 client.request(request.unwrap()).await
29390 };
29391
29392 match req_result {
29393 Err(err) => {
29394 if let common::Retry::After(d) = dlg.http_error(&err) {
29395 sleep(d).await;
29396 continue;
29397 }
29398 dlg.finished(false);
29399 return Err(common::Error::HttpError(err));
29400 }
29401 Ok(res) => {
29402 let (mut parts, body) = res.into_parts();
29403 let mut body = common::Body::new(body);
29404 if !parts.status.is_success() {
29405 let bytes = common::to_bytes(body).await.unwrap_or_default();
29406 let error = serde_json::from_str(&common::to_string(&bytes));
29407 let response = common::to_response(parts, bytes.into());
29408
29409 if let common::Retry::After(d) =
29410 dlg.http_failure(&response, error.as_ref().ok())
29411 {
29412 sleep(d).await;
29413 continue;
29414 }
29415
29416 dlg.finished(false);
29417
29418 return Err(match error {
29419 Ok(value) => common::Error::BadRequest(value),
29420 _ => common::Error::Failure(response),
29421 });
29422 }
29423 let response = {
29424 let bytes = common::to_bytes(body).await.unwrap_or_default();
29425 let encoded = common::to_string(&bytes);
29426 match serde_json::from_str(&encoded) {
29427 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
29428 Err(error) => {
29429 dlg.response_json_decode_error(&encoded, &error);
29430 return Err(common::Error::JsonDecodeError(
29431 encoded.to_string(),
29432 error,
29433 ));
29434 }
29435 }
29436 };
29437
29438 dlg.finished(true);
29439 return Ok(response);
29440 }
29441 }
29442 }
29443 }
29444
29445 /// Required. A name of the TcpRoute to get. Must be in the format `projects/*/locations/*/tcpRoutes/*`.
29446 ///
29447 /// Sets the *name* path property to the given value.
29448 ///
29449 /// Even though the property as already been set when instantiating this call,
29450 /// we provide this method for API completeness.
29451 pub fn name(mut self, new_value: &str) -> ProjectLocationTcpRouteGetCall<'a, C> {
29452 self._name = new_value.to_string();
29453 self
29454 }
29455 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
29456 /// while executing the actual API request.
29457 ///
29458 /// ````text
29459 /// It should be used to handle progress information, and to implement a certain level of resilience.
29460 /// ````
29461 ///
29462 /// Sets the *delegate* property to the given value.
29463 pub fn delegate(
29464 mut self,
29465 new_value: &'a mut dyn common::Delegate,
29466 ) -> ProjectLocationTcpRouteGetCall<'a, C> {
29467 self._delegate = Some(new_value);
29468 self
29469 }
29470
29471 /// Set any additional parameter of the query string used in the request.
29472 /// It should be used to set parameters which are not yet available through their own
29473 /// setters.
29474 ///
29475 /// Please note that this method must not be used to set any of the known parameters
29476 /// which have their own setter method. If done anyway, the request will fail.
29477 ///
29478 /// # Additional Parameters
29479 ///
29480 /// * *$.xgafv* (query-string) - V1 error format.
29481 /// * *access_token* (query-string) - OAuth access token.
29482 /// * *alt* (query-string) - Data format for response.
29483 /// * *callback* (query-string) - JSONP
29484 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
29485 /// * *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.
29486 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
29487 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
29488 /// * *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.
29489 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
29490 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
29491 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationTcpRouteGetCall<'a, C>
29492 where
29493 T: AsRef<str>,
29494 {
29495 self._additional_params
29496 .insert(name.as_ref().to_string(), value.as_ref().to_string());
29497 self
29498 }
29499
29500 /// Identifies the authorization scope for the method you are building.
29501 ///
29502 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
29503 /// [`Scope::CloudPlatform`].
29504 ///
29505 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
29506 /// tokens for more than one scope.
29507 ///
29508 /// Usually there is more than one suitable scope to authorize an operation, some of which may
29509 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
29510 /// sufficient, a read-write scope will do as well.
29511 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationTcpRouteGetCall<'a, C>
29512 where
29513 St: AsRef<str>,
29514 {
29515 self._scopes.insert(String::from(scope.as_ref()));
29516 self
29517 }
29518 /// Identifies the authorization scope(s) for the method you are building.
29519 ///
29520 /// See [`Self::add_scope()`] for details.
29521 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationTcpRouteGetCall<'a, C>
29522 where
29523 I: IntoIterator<Item = St>,
29524 St: AsRef<str>,
29525 {
29526 self._scopes
29527 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
29528 self
29529 }
29530
29531 /// Removes all scopes, and no default scope will be used either.
29532 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
29533 /// for details).
29534 pub fn clear_scopes(mut self) -> ProjectLocationTcpRouteGetCall<'a, C> {
29535 self._scopes.clear();
29536 self
29537 }
29538}
29539
29540/// Lists TcpRoute in a given project and location.
29541///
29542/// A builder for the *locations.tcpRoutes.list* method supported by a *project* resource.
29543/// It is not used directly, but through a [`ProjectMethods`] instance.
29544///
29545/// # Example
29546///
29547/// Instantiate a resource method builder
29548///
29549/// ```test_harness,no_run
29550/// # extern crate hyper;
29551/// # extern crate hyper_rustls;
29552/// # extern crate google_networkservices1 as networkservices1;
29553/// # async fn dox() {
29554/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
29555///
29556/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
29557/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
29558/// # .with_native_roots()
29559/// # .unwrap()
29560/// # .https_only()
29561/// # .enable_http2()
29562/// # .build();
29563///
29564/// # let executor = hyper_util::rt::TokioExecutor::new();
29565/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
29566/// # secret,
29567/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
29568/// # yup_oauth2::client::CustomHyperClientBuilder::from(
29569/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
29570/// # ),
29571/// # ).build().await.unwrap();
29572///
29573/// # let client = hyper_util::client::legacy::Client::builder(
29574/// # hyper_util::rt::TokioExecutor::new()
29575/// # )
29576/// # .build(
29577/// # hyper_rustls::HttpsConnectorBuilder::new()
29578/// # .with_native_roots()
29579/// # .unwrap()
29580/// # .https_or_http()
29581/// # .enable_http2()
29582/// # .build()
29583/// # );
29584/// # let mut hub = NetworkServices::new(client, auth);
29585/// // You can configure optional parameters by calling the respective setters at will, and
29586/// // execute the final call using `doit()`.
29587/// // Values shown here are possibly random and not representative !
29588/// let result = hub.projects().locations_tcp_routes_list("parent")
29589/// .return_partial_success(false)
29590/// .page_token("dolore")
29591/// .page_size(-40)
29592/// .doit().await;
29593/// # }
29594/// ```
29595pub struct ProjectLocationTcpRouteListCall<'a, C>
29596where
29597 C: 'a,
29598{
29599 hub: &'a NetworkServices<C>,
29600 _parent: String,
29601 _return_partial_success: Option<bool>,
29602 _page_token: Option<String>,
29603 _page_size: Option<i32>,
29604 _delegate: Option<&'a mut dyn common::Delegate>,
29605 _additional_params: HashMap<String, String>,
29606 _scopes: BTreeSet<String>,
29607}
29608
29609impl<'a, C> common::CallBuilder for ProjectLocationTcpRouteListCall<'a, C> {}
29610
29611impl<'a, C> ProjectLocationTcpRouteListCall<'a, C>
29612where
29613 C: common::Connector,
29614{
29615 /// Perform the operation you have build so far.
29616 pub async fn doit(mut self) -> common::Result<(common::Response, ListTcpRoutesResponse)> {
29617 use std::borrow::Cow;
29618 use std::io::{Read, Seek};
29619
29620 use common::{url::Params, ToParts};
29621 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
29622
29623 let mut dd = common::DefaultDelegate;
29624 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
29625 dlg.begin(common::MethodInfo {
29626 id: "networkservices.projects.locations.tcpRoutes.list",
29627 http_method: hyper::Method::GET,
29628 });
29629
29630 for &field in [
29631 "alt",
29632 "parent",
29633 "returnPartialSuccess",
29634 "pageToken",
29635 "pageSize",
29636 ]
29637 .iter()
29638 {
29639 if self._additional_params.contains_key(field) {
29640 dlg.finished(false);
29641 return Err(common::Error::FieldClash(field));
29642 }
29643 }
29644
29645 let mut params = Params::with_capacity(6 + self._additional_params.len());
29646 params.push("parent", self._parent);
29647 if let Some(value) = self._return_partial_success.as_ref() {
29648 params.push("returnPartialSuccess", value.to_string());
29649 }
29650 if let Some(value) = self._page_token.as_ref() {
29651 params.push("pageToken", value);
29652 }
29653 if let Some(value) = self._page_size.as_ref() {
29654 params.push("pageSize", value.to_string());
29655 }
29656
29657 params.extend(self._additional_params.iter());
29658
29659 params.push("alt", "json");
29660 let mut url = self.hub._base_url.clone() + "v1/{+parent}/tcpRoutes";
29661 if self._scopes.is_empty() {
29662 self._scopes
29663 .insert(Scope::CloudPlatform.as_ref().to_string());
29664 }
29665
29666 #[allow(clippy::single_element_loop)]
29667 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
29668 url = params.uri_replacement(url, param_name, find_this, true);
29669 }
29670 {
29671 let to_remove = ["parent"];
29672 params.remove_params(&to_remove);
29673 }
29674
29675 let url = params.parse_with_url(&url);
29676
29677 loop {
29678 let token = match self
29679 .hub
29680 .auth
29681 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
29682 .await
29683 {
29684 Ok(token) => token,
29685 Err(e) => match dlg.token(e) {
29686 Ok(token) => token,
29687 Err(e) => {
29688 dlg.finished(false);
29689 return Err(common::Error::MissingToken(e));
29690 }
29691 },
29692 };
29693 let mut req_result = {
29694 let client = &self.hub.client;
29695 dlg.pre_request();
29696 let mut req_builder = hyper::Request::builder()
29697 .method(hyper::Method::GET)
29698 .uri(url.as_str())
29699 .header(USER_AGENT, self.hub._user_agent.clone());
29700
29701 if let Some(token) = token.as_ref() {
29702 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
29703 }
29704
29705 let request = req_builder
29706 .header(CONTENT_LENGTH, 0_u64)
29707 .body(common::to_body::<String>(None));
29708
29709 client.request(request.unwrap()).await
29710 };
29711
29712 match req_result {
29713 Err(err) => {
29714 if let common::Retry::After(d) = dlg.http_error(&err) {
29715 sleep(d).await;
29716 continue;
29717 }
29718 dlg.finished(false);
29719 return Err(common::Error::HttpError(err));
29720 }
29721 Ok(res) => {
29722 let (mut parts, body) = res.into_parts();
29723 let mut body = common::Body::new(body);
29724 if !parts.status.is_success() {
29725 let bytes = common::to_bytes(body).await.unwrap_or_default();
29726 let error = serde_json::from_str(&common::to_string(&bytes));
29727 let response = common::to_response(parts, bytes.into());
29728
29729 if let common::Retry::After(d) =
29730 dlg.http_failure(&response, error.as_ref().ok())
29731 {
29732 sleep(d).await;
29733 continue;
29734 }
29735
29736 dlg.finished(false);
29737
29738 return Err(match error {
29739 Ok(value) => common::Error::BadRequest(value),
29740 _ => common::Error::Failure(response),
29741 });
29742 }
29743 let response = {
29744 let bytes = common::to_bytes(body).await.unwrap_or_default();
29745 let encoded = common::to_string(&bytes);
29746 match serde_json::from_str(&encoded) {
29747 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
29748 Err(error) => {
29749 dlg.response_json_decode_error(&encoded, &error);
29750 return Err(common::Error::JsonDecodeError(
29751 encoded.to_string(),
29752 error,
29753 ));
29754 }
29755 }
29756 };
29757
29758 dlg.finished(true);
29759 return Ok(response);
29760 }
29761 }
29762 }
29763 }
29764
29765 /// Required. The project and location from which the TcpRoutes should be listed, specified in the format `projects/*/locations/*`.
29766 ///
29767 /// Sets the *parent* path property to the given value.
29768 ///
29769 /// Even though the property as already been set when instantiating this call,
29770 /// we provide this method for API completeness.
29771 pub fn parent(mut self, new_value: &str) -> ProjectLocationTcpRouteListCall<'a, C> {
29772 self._parent = new_value.to_string();
29773 self
29774 }
29775 /// Optional. If true, allow partial responses for multi-regional Aggregated List requests. Otherwise if one of the locations is down or unreachable, the Aggregated List request will fail.
29776 ///
29777 /// Sets the *return partial success* query property to the given value.
29778 pub fn return_partial_success(
29779 mut self,
29780 new_value: bool,
29781 ) -> ProjectLocationTcpRouteListCall<'a, C> {
29782 self._return_partial_success = Some(new_value);
29783 self
29784 }
29785 /// The value returned by the last `ListTcpRoutesResponse` Indicates that this is a continuation of a prior `ListTcpRoutes` call, and that the system should return the next page of data.
29786 ///
29787 /// Sets the *page token* query property to the given value.
29788 pub fn page_token(mut self, new_value: &str) -> ProjectLocationTcpRouteListCall<'a, C> {
29789 self._page_token = Some(new_value.to_string());
29790 self
29791 }
29792 /// Maximum number of TcpRoutes to return per call.
29793 ///
29794 /// Sets the *page size* query property to the given value.
29795 pub fn page_size(mut self, new_value: i32) -> ProjectLocationTcpRouteListCall<'a, C> {
29796 self._page_size = Some(new_value);
29797 self
29798 }
29799 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
29800 /// while executing the actual API request.
29801 ///
29802 /// ````text
29803 /// It should be used to handle progress information, and to implement a certain level of resilience.
29804 /// ````
29805 ///
29806 /// Sets the *delegate* property to the given value.
29807 pub fn delegate(
29808 mut self,
29809 new_value: &'a mut dyn common::Delegate,
29810 ) -> ProjectLocationTcpRouteListCall<'a, C> {
29811 self._delegate = Some(new_value);
29812 self
29813 }
29814
29815 /// Set any additional parameter of the query string used in the request.
29816 /// It should be used to set parameters which are not yet available through their own
29817 /// setters.
29818 ///
29819 /// Please note that this method must not be used to set any of the known parameters
29820 /// which have their own setter method. If done anyway, the request will fail.
29821 ///
29822 /// # Additional Parameters
29823 ///
29824 /// * *$.xgafv* (query-string) - V1 error format.
29825 /// * *access_token* (query-string) - OAuth access token.
29826 /// * *alt* (query-string) - Data format for response.
29827 /// * *callback* (query-string) - JSONP
29828 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
29829 /// * *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.
29830 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
29831 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
29832 /// * *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.
29833 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
29834 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
29835 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationTcpRouteListCall<'a, C>
29836 where
29837 T: AsRef<str>,
29838 {
29839 self._additional_params
29840 .insert(name.as_ref().to_string(), value.as_ref().to_string());
29841 self
29842 }
29843
29844 /// Identifies the authorization scope for the method you are building.
29845 ///
29846 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
29847 /// [`Scope::CloudPlatform`].
29848 ///
29849 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
29850 /// tokens for more than one scope.
29851 ///
29852 /// Usually there is more than one suitable scope to authorize an operation, some of which may
29853 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
29854 /// sufficient, a read-write scope will do as well.
29855 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationTcpRouteListCall<'a, C>
29856 where
29857 St: AsRef<str>,
29858 {
29859 self._scopes.insert(String::from(scope.as_ref()));
29860 self
29861 }
29862 /// Identifies the authorization scope(s) for the method you are building.
29863 ///
29864 /// See [`Self::add_scope()`] for details.
29865 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationTcpRouteListCall<'a, C>
29866 where
29867 I: IntoIterator<Item = St>,
29868 St: AsRef<str>,
29869 {
29870 self._scopes
29871 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
29872 self
29873 }
29874
29875 /// Removes all scopes, and no default scope will be used either.
29876 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
29877 /// for details).
29878 pub fn clear_scopes(mut self) -> ProjectLocationTcpRouteListCall<'a, C> {
29879 self._scopes.clear();
29880 self
29881 }
29882}
29883
29884/// Updates the parameters of a single TcpRoute.
29885///
29886/// A builder for the *locations.tcpRoutes.patch* method supported by a *project* resource.
29887/// It is not used directly, but through a [`ProjectMethods`] instance.
29888///
29889/// # Example
29890///
29891/// Instantiate a resource method builder
29892///
29893/// ```test_harness,no_run
29894/// # extern crate hyper;
29895/// # extern crate hyper_rustls;
29896/// # extern crate google_networkservices1 as networkservices1;
29897/// use networkservices1::api::TcpRoute;
29898/// # async fn dox() {
29899/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
29900///
29901/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
29902/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
29903/// # .with_native_roots()
29904/// # .unwrap()
29905/// # .https_only()
29906/// # .enable_http2()
29907/// # .build();
29908///
29909/// # let executor = hyper_util::rt::TokioExecutor::new();
29910/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
29911/// # secret,
29912/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
29913/// # yup_oauth2::client::CustomHyperClientBuilder::from(
29914/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
29915/// # ),
29916/// # ).build().await.unwrap();
29917///
29918/// # let client = hyper_util::client::legacy::Client::builder(
29919/// # hyper_util::rt::TokioExecutor::new()
29920/// # )
29921/// # .build(
29922/// # hyper_rustls::HttpsConnectorBuilder::new()
29923/// # .with_native_roots()
29924/// # .unwrap()
29925/// # .https_or_http()
29926/// # .enable_http2()
29927/// # .build()
29928/// # );
29929/// # let mut hub = NetworkServices::new(client, auth);
29930/// // As the method needs a request, you would usually fill it with the desired information
29931/// // into the respective structure. Some of the parts shown here might not be applicable !
29932/// // Values shown here are possibly random and not representative !
29933/// let mut req = TcpRoute::default();
29934///
29935/// // You can configure optional parameters by calling the respective setters at will, and
29936/// // execute the final call using `doit()`.
29937/// // Values shown here are possibly random and not representative !
29938/// let result = hub.projects().locations_tcp_routes_patch(req, "name")
29939/// .update_mask(FieldMask::new::<&str>(&[]))
29940/// .doit().await;
29941/// # }
29942/// ```
29943pub struct ProjectLocationTcpRoutePatchCall<'a, C>
29944where
29945 C: 'a,
29946{
29947 hub: &'a NetworkServices<C>,
29948 _request: TcpRoute,
29949 _name: String,
29950 _update_mask: Option<common::FieldMask>,
29951 _delegate: Option<&'a mut dyn common::Delegate>,
29952 _additional_params: HashMap<String, String>,
29953 _scopes: BTreeSet<String>,
29954}
29955
29956impl<'a, C> common::CallBuilder for ProjectLocationTcpRoutePatchCall<'a, C> {}
29957
29958impl<'a, C> ProjectLocationTcpRoutePatchCall<'a, C>
29959where
29960 C: common::Connector,
29961{
29962 /// Perform the operation you have build so far.
29963 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
29964 use std::borrow::Cow;
29965 use std::io::{Read, Seek};
29966
29967 use common::{url::Params, ToParts};
29968 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
29969
29970 let mut dd = common::DefaultDelegate;
29971 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
29972 dlg.begin(common::MethodInfo {
29973 id: "networkservices.projects.locations.tcpRoutes.patch",
29974 http_method: hyper::Method::PATCH,
29975 });
29976
29977 for &field in ["alt", "name", "updateMask"].iter() {
29978 if self._additional_params.contains_key(field) {
29979 dlg.finished(false);
29980 return Err(common::Error::FieldClash(field));
29981 }
29982 }
29983
29984 let mut params = Params::with_capacity(5 + self._additional_params.len());
29985 params.push("name", self._name);
29986 if let Some(value) = self._update_mask.as_ref() {
29987 params.push("updateMask", value.to_string());
29988 }
29989
29990 params.extend(self._additional_params.iter());
29991
29992 params.push("alt", "json");
29993 let mut url = self.hub._base_url.clone() + "v1/{+name}";
29994 if self._scopes.is_empty() {
29995 self._scopes
29996 .insert(Scope::CloudPlatform.as_ref().to_string());
29997 }
29998
29999 #[allow(clippy::single_element_loop)]
30000 for &(find_this, param_name) in [("{+name}", "name")].iter() {
30001 url = params.uri_replacement(url, param_name, find_this, true);
30002 }
30003 {
30004 let to_remove = ["name"];
30005 params.remove_params(&to_remove);
30006 }
30007
30008 let url = params.parse_with_url(&url);
30009
30010 let mut json_mime_type = mime::APPLICATION_JSON;
30011 let mut request_value_reader = {
30012 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
30013 common::remove_json_null_values(&mut value);
30014 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
30015 serde_json::to_writer(&mut dst, &value).unwrap();
30016 dst
30017 };
30018 let request_size = request_value_reader
30019 .seek(std::io::SeekFrom::End(0))
30020 .unwrap();
30021 request_value_reader
30022 .seek(std::io::SeekFrom::Start(0))
30023 .unwrap();
30024
30025 loop {
30026 let token = match self
30027 .hub
30028 .auth
30029 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
30030 .await
30031 {
30032 Ok(token) => token,
30033 Err(e) => match dlg.token(e) {
30034 Ok(token) => token,
30035 Err(e) => {
30036 dlg.finished(false);
30037 return Err(common::Error::MissingToken(e));
30038 }
30039 },
30040 };
30041 request_value_reader
30042 .seek(std::io::SeekFrom::Start(0))
30043 .unwrap();
30044 let mut req_result = {
30045 let client = &self.hub.client;
30046 dlg.pre_request();
30047 let mut req_builder = hyper::Request::builder()
30048 .method(hyper::Method::PATCH)
30049 .uri(url.as_str())
30050 .header(USER_AGENT, self.hub._user_agent.clone());
30051
30052 if let Some(token) = token.as_ref() {
30053 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
30054 }
30055
30056 let request = req_builder
30057 .header(CONTENT_TYPE, json_mime_type.to_string())
30058 .header(CONTENT_LENGTH, request_size as u64)
30059 .body(common::to_body(
30060 request_value_reader.get_ref().clone().into(),
30061 ));
30062
30063 client.request(request.unwrap()).await
30064 };
30065
30066 match req_result {
30067 Err(err) => {
30068 if let common::Retry::After(d) = dlg.http_error(&err) {
30069 sleep(d).await;
30070 continue;
30071 }
30072 dlg.finished(false);
30073 return Err(common::Error::HttpError(err));
30074 }
30075 Ok(res) => {
30076 let (mut parts, body) = res.into_parts();
30077 let mut body = common::Body::new(body);
30078 if !parts.status.is_success() {
30079 let bytes = common::to_bytes(body).await.unwrap_or_default();
30080 let error = serde_json::from_str(&common::to_string(&bytes));
30081 let response = common::to_response(parts, bytes.into());
30082
30083 if let common::Retry::After(d) =
30084 dlg.http_failure(&response, error.as_ref().ok())
30085 {
30086 sleep(d).await;
30087 continue;
30088 }
30089
30090 dlg.finished(false);
30091
30092 return Err(match error {
30093 Ok(value) => common::Error::BadRequest(value),
30094 _ => common::Error::Failure(response),
30095 });
30096 }
30097 let response = {
30098 let bytes = common::to_bytes(body).await.unwrap_or_default();
30099 let encoded = common::to_string(&bytes);
30100 match serde_json::from_str(&encoded) {
30101 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
30102 Err(error) => {
30103 dlg.response_json_decode_error(&encoded, &error);
30104 return Err(common::Error::JsonDecodeError(
30105 encoded.to_string(),
30106 error,
30107 ));
30108 }
30109 }
30110 };
30111
30112 dlg.finished(true);
30113 return Ok(response);
30114 }
30115 }
30116 }
30117 }
30118
30119 ///
30120 /// Sets the *request* property to the given value.
30121 ///
30122 /// Even though the property as already been set when instantiating this call,
30123 /// we provide this method for API completeness.
30124 pub fn request(mut self, new_value: TcpRoute) -> ProjectLocationTcpRoutePatchCall<'a, C> {
30125 self._request = new_value;
30126 self
30127 }
30128 /// Identifier. Name of the TcpRoute resource. It matches pattern `projects/*/locations/*/tcpRoutes/tcp_route_name>`.
30129 ///
30130 /// Sets the *name* path property to the given value.
30131 ///
30132 /// Even though the property as already been set when instantiating this call,
30133 /// we provide this method for API completeness.
30134 pub fn name(mut self, new_value: &str) -> ProjectLocationTcpRoutePatchCall<'a, C> {
30135 self._name = new_value.to_string();
30136 self
30137 }
30138 /// Optional. Field mask is used to specify the fields to be overwritten in the TcpRoute 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.
30139 ///
30140 /// Sets the *update mask* query property to the given value.
30141 pub fn update_mask(
30142 mut self,
30143 new_value: common::FieldMask,
30144 ) -> ProjectLocationTcpRoutePatchCall<'a, C> {
30145 self._update_mask = Some(new_value);
30146 self
30147 }
30148 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
30149 /// while executing the actual API request.
30150 ///
30151 /// ````text
30152 /// It should be used to handle progress information, and to implement a certain level of resilience.
30153 /// ````
30154 ///
30155 /// Sets the *delegate* property to the given value.
30156 pub fn delegate(
30157 mut self,
30158 new_value: &'a mut dyn common::Delegate,
30159 ) -> ProjectLocationTcpRoutePatchCall<'a, C> {
30160 self._delegate = Some(new_value);
30161 self
30162 }
30163
30164 /// Set any additional parameter of the query string used in the request.
30165 /// It should be used to set parameters which are not yet available through their own
30166 /// setters.
30167 ///
30168 /// Please note that this method must not be used to set any of the known parameters
30169 /// which have their own setter method. If done anyway, the request will fail.
30170 ///
30171 /// # Additional Parameters
30172 ///
30173 /// * *$.xgafv* (query-string) - V1 error format.
30174 /// * *access_token* (query-string) - OAuth access token.
30175 /// * *alt* (query-string) - Data format for response.
30176 /// * *callback* (query-string) - JSONP
30177 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
30178 /// * *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.
30179 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
30180 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
30181 /// * *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.
30182 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
30183 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
30184 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationTcpRoutePatchCall<'a, C>
30185 where
30186 T: AsRef<str>,
30187 {
30188 self._additional_params
30189 .insert(name.as_ref().to_string(), value.as_ref().to_string());
30190 self
30191 }
30192
30193 /// Identifies the authorization scope for the method you are building.
30194 ///
30195 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
30196 /// [`Scope::CloudPlatform`].
30197 ///
30198 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
30199 /// tokens for more than one scope.
30200 ///
30201 /// Usually there is more than one suitable scope to authorize an operation, some of which may
30202 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
30203 /// sufficient, a read-write scope will do as well.
30204 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationTcpRoutePatchCall<'a, C>
30205 where
30206 St: AsRef<str>,
30207 {
30208 self._scopes.insert(String::from(scope.as_ref()));
30209 self
30210 }
30211 /// Identifies the authorization scope(s) for the method you are building.
30212 ///
30213 /// See [`Self::add_scope()`] for details.
30214 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationTcpRoutePatchCall<'a, C>
30215 where
30216 I: IntoIterator<Item = St>,
30217 St: AsRef<str>,
30218 {
30219 self._scopes
30220 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
30221 self
30222 }
30223
30224 /// Removes all scopes, and no default scope will be used either.
30225 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
30226 /// for details).
30227 pub fn clear_scopes(mut self) -> ProjectLocationTcpRoutePatchCall<'a, C> {
30228 self._scopes.clear();
30229 self
30230 }
30231}
30232
30233/// Creates a new TlsRoute in a given project and location.
30234///
30235/// A builder for the *locations.tlsRoutes.create* method supported by a *project* resource.
30236/// It is not used directly, but through a [`ProjectMethods`] instance.
30237///
30238/// # Example
30239///
30240/// Instantiate a resource method builder
30241///
30242/// ```test_harness,no_run
30243/// # extern crate hyper;
30244/// # extern crate hyper_rustls;
30245/// # extern crate google_networkservices1 as networkservices1;
30246/// use networkservices1::api::TlsRoute;
30247/// # async fn dox() {
30248/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
30249///
30250/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
30251/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
30252/// # .with_native_roots()
30253/// # .unwrap()
30254/// # .https_only()
30255/// # .enable_http2()
30256/// # .build();
30257///
30258/// # let executor = hyper_util::rt::TokioExecutor::new();
30259/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
30260/// # secret,
30261/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
30262/// # yup_oauth2::client::CustomHyperClientBuilder::from(
30263/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
30264/// # ),
30265/// # ).build().await.unwrap();
30266///
30267/// # let client = hyper_util::client::legacy::Client::builder(
30268/// # hyper_util::rt::TokioExecutor::new()
30269/// # )
30270/// # .build(
30271/// # hyper_rustls::HttpsConnectorBuilder::new()
30272/// # .with_native_roots()
30273/// # .unwrap()
30274/// # .https_or_http()
30275/// # .enable_http2()
30276/// # .build()
30277/// # );
30278/// # let mut hub = NetworkServices::new(client, auth);
30279/// // As the method needs a request, you would usually fill it with the desired information
30280/// // into the respective structure. Some of the parts shown here might not be applicable !
30281/// // Values shown here are possibly random and not representative !
30282/// let mut req = TlsRoute::default();
30283///
30284/// // You can configure optional parameters by calling the respective setters at will, and
30285/// // execute the final call using `doit()`.
30286/// // Values shown here are possibly random and not representative !
30287/// let result = hub.projects().locations_tls_routes_create(req, "parent")
30288/// .tls_route_id("amet")
30289/// .doit().await;
30290/// # }
30291/// ```
30292pub struct ProjectLocationTlsRouteCreateCall<'a, C>
30293where
30294 C: 'a,
30295{
30296 hub: &'a NetworkServices<C>,
30297 _request: TlsRoute,
30298 _parent: String,
30299 _tls_route_id: Option<String>,
30300 _delegate: Option<&'a mut dyn common::Delegate>,
30301 _additional_params: HashMap<String, String>,
30302 _scopes: BTreeSet<String>,
30303}
30304
30305impl<'a, C> common::CallBuilder for ProjectLocationTlsRouteCreateCall<'a, C> {}
30306
30307impl<'a, C> ProjectLocationTlsRouteCreateCall<'a, C>
30308where
30309 C: common::Connector,
30310{
30311 /// Perform the operation you have build so far.
30312 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
30313 use std::borrow::Cow;
30314 use std::io::{Read, Seek};
30315
30316 use common::{url::Params, ToParts};
30317 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
30318
30319 let mut dd = common::DefaultDelegate;
30320 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
30321 dlg.begin(common::MethodInfo {
30322 id: "networkservices.projects.locations.tlsRoutes.create",
30323 http_method: hyper::Method::POST,
30324 });
30325
30326 for &field in ["alt", "parent", "tlsRouteId"].iter() {
30327 if self._additional_params.contains_key(field) {
30328 dlg.finished(false);
30329 return Err(common::Error::FieldClash(field));
30330 }
30331 }
30332
30333 let mut params = Params::with_capacity(5 + self._additional_params.len());
30334 params.push("parent", self._parent);
30335 if let Some(value) = self._tls_route_id.as_ref() {
30336 params.push("tlsRouteId", value);
30337 }
30338
30339 params.extend(self._additional_params.iter());
30340
30341 params.push("alt", "json");
30342 let mut url = self.hub._base_url.clone() + "v1/{+parent}/tlsRoutes";
30343 if self._scopes.is_empty() {
30344 self._scopes
30345 .insert(Scope::CloudPlatform.as_ref().to_string());
30346 }
30347
30348 #[allow(clippy::single_element_loop)]
30349 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
30350 url = params.uri_replacement(url, param_name, find_this, true);
30351 }
30352 {
30353 let to_remove = ["parent"];
30354 params.remove_params(&to_remove);
30355 }
30356
30357 let url = params.parse_with_url(&url);
30358
30359 let mut json_mime_type = mime::APPLICATION_JSON;
30360 let mut request_value_reader = {
30361 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
30362 common::remove_json_null_values(&mut value);
30363 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
30364 serde_json::to_writer(&mut dst, &value).unwrap();
30365 dst
30366 };
30367 let request_size = request_value_reader
30368 .seek(std::io::SeekFrom::End(0))
30369 .unwrap();
30370 request_value_reader
30371 .seek(std::io::SeekFrom::Start(0))
30372 .unwrap();
30373
30374 loop {
30375 let token = match self
30376 .hub
30377 .auth
30378 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
30379 .await
30380 {
30381 Ok(token) => token,
30382 Err(e) => match dlg.token(e) {
30383 Ok(token) => token,
30384 Err(e) => {
30385 dlg.finished(false);
30386 return Err(common::Error::MissingToken(e));
30387 }
30388 },
30389 };
30390 request_value_reader
30391 .seek(std::io::SeekFrom::Start(0))
30392 .unwrap();
30393 let mut req_result = {
30394 let client = &self.hub.client;
30395 dlg.pre_request();
30396 let mut req_builder = hyper::Request::builder()
30397 .method(hyper::Method::POST)
30398 .uri(url.as_str())
30399 .header(USER_AGENT, self.hub._user_agent.clone());
30400
30401 if let Some(token) = token.as_ref() {
30402 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
30403 }
30404
30405 let request = req_builder
30406 .header(CONTENT_TYPE, json_mime_type.to_string())
30407 .header(CONTENT_LENGTH, request_size as u64)
30408 .body(common::to_body(
30409 request_value_reader.get_ref().clone().into(),
30410 ));
30411
30412 client.request(request.unwrap()).await
30413 };
30414
30415 match req_result {
30416 Err(err) => {
30417 if let common::Retry::After(d) = dlg.http_error(&err) {
30418 sleep(d).await;
30419 continue;
30420 }
30421 dlg.finished(false);
30422 return Err(common::Error::HttpError(err));
30423 }
30424 Ok(res) => {
30425 let (mut parts, body) = res.into_parts();
30426 let mut body = common::Body::new(body);
30427 if !parts.status.is_success() {
30428 let bytes = common::to_bytes(body).await.unwrap_or_default();
30429 let error = serde_json::from_str(&common::to_string(&bytes));
30430 let response = common::to_response(parts, bytes.into());
30431
30432 if let common::Retry::After(d) =
30433 dlg.http_failure(&response, error.as_ref().ok())
30434 {
30435 sleep(d).await;
30436 continue;
30437 }
30438
30439 dlg.finished(false);
30440
30441 return Err(match error {
30442 Ok(value) => common::Error::BadRequest(value),
30443 _ => common::Error::Failure(response),
30444 });
30445 }
30446 let response = {
30447 let bytes = common::to_bytes(body).await.unwrap_or_default();
30448 let encoded = common::to_string(&bytes);
30449 match serde_json::from_str(&encoded) {
30450 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
30451 Err(error) => {
30452 dlg.response_json_decode_error(&encoded, &error);
30453 return Err(common::Error::JsonDecodeError(
30454 encoded.to_string(),
30455 error,
30456 ));
30457 }
30458 }
30459 };
30460
30461 dlg.finished(true);
30462 return Ok(response);
30463 }
30464 }
30465 }
30466 }
30467
30468 ///
30469 /// Sets the *request* property to the given value.
30470 ///
30471 /// Even though the property as already been set when instantiating this call,
30472 /// we provide this method for API completeness.
30473 pub fn request(mut self, new_value: TlsRoute) -> ProjectLocationTlsRouteCreateCall<'a, C> {
30474 self._request = new_value;
30475 self
30476 }
30477 /// Required. The parent resource of the TlsRoute. Must be in the format `projects/*/locations/*`.
30478 ///
30479 /// Sets the *parent* path property to the given value.
30480 ///
30481 /// Even though the property as already been set when instantiating this call,
30482 /// we provide this method for API completeness.
30483 pub fn parent(mut self, new_value: &str) -> ProjectLocationTlsRouteCreateCall<'a, C> {
30484 self._parent = new_value.to_string();
30485 self
30486 }
30487 /// Required. Short name of the TlsRoute resource to be created.
30488 ///
30489 /// Sets the *tls route id* query property to the given value.
30490 pub fn tls_route_id(mut self, new_value: &str) -> ProjectLocationTlsRouteCreateCall<'a, C> {
30491 self._tls_route_id = Some(new_value.to_string());
30492 self
30493 }
30494 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
30495 /// while executing the actual API request.
30496 ///
30497 /// ````text
30498 /// It should be used to handle progress information, and to implement a certain level of resilience.
30499 /// ````
30500 ///
30501 /// Sets the *delegate* property to the given value.
30502 pub fn delegate(
30503 mut self,
30504 new_value: &'a mut dyn common::Delegate,
30505 ) -> ProjectLocationTlsRouteCreateCall<'a, C> {
30506 self._delegate = Some(new_value);
30507 self
30508 }
30509
30510 /// Set any additional parameter of the query string used in the request.
30511 /// It should be used to set parameters which are not yet available through their own
30512 /// setters.
30513 ///
30514 /// Please note that this method must not be used to set any of the known parameters
30515 /// which have their own setter method. If done anyway, the request will fail.
30516 ///
30517 /// # Additional Parameters
30518 ///
30519 /// * *$.xgafv* (query-string) - V1 error format.
30520 /// * *access_token* (query-string) - OAuth access token.
30521 /// * *alt* (query-string) - Data format for response.
30522 /// * *callback* (query-string) - JSONP
30523 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
30524 /// * *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.
30525 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
30526 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
30527 /// * *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.
30528 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
30529 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
30530 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationTlsRouteCreateCall<'a, C>
30531 where
30532 T: AsRef<str>,
30533 {
30534 self._additional_params
30535 .insert(name.as_ref().to_string(), value.as_ref().to_string());
30536 self
30537 }
30538
30539 /// Identifies the authorization scope for the method you are building.
30540 ///
30541 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
30542 /// [`Scope::CloudPlatform`].
30543 ///
30544 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
30545 /// tokens for more than one scope.
30546 ///
30547 /// Usually there is more than one suitable scope to authorize an operation, some of which may
30548 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
30549 /// sufficient, a read-write scope will do as well.
30550 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationTlsRouteCreateCall<'a, C>
30551 where
30552 St: AsRef<str>,
30553 {
30554 self._scopes.insert(String::from(scope.as_ref()));
30555 self
30556 }
30557 /// Identifies the authorization scope(s) for the method you are building.
30558 ///
30559 /// See [`Self::add_scope()`] for details.
30560 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationTlsRouteCreateCall<'a, C>
30561 where
30562 I: IntoIterator<Item = St>,
30563 St: AsRef<str>,
30564 {
30565 self._scopes
30566 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
30567 self
30568 }
30569
30570 /// Removes all scopes, and no default scope will be used either.
30571 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
30572 /// for details).
30573 pub fn clear_scopes(mut self) -> ProjectLocationTlsRouteCreateCall<'a, C> {
30574 self._scopes.clear();
30575 self
30576 }
30577}
30578
30579/// Deletes a single TlsRoute.
30580///
30581/// A builder for the *locations.tlsRoutes.delete* method supported by a *project* resource.
30582/// It is not used directly, but through a [`ProjectMethods`] instance.
30583///
30584/// # Example
30585///
30586/// Instantiate a resource method builder
30587///
30588/// ```test_harness,no_run
30589/// # extern crate hyper;
30590/// # extern crate hyper_rustls;
30591/// # extern crate google_networkservices1 as networkservices1;
30592/// # async fn dox() {
30593/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
30594///
30595/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
30596/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
30597/// # .with_native_roots()
30598/// # .unwrap()
30599/// # .https_only()
30600/// # .enable_http2()
30601/// # .build();
30602///
30603/// # let executor = hyper_util::rt::TokioExecutor::new();
30604/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
30605/// # secret,
30606/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
30607/// # yup_oauth2::client::CustomHyperClientBuilder::from(
30608/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
30609/// # ),
30610/// # ).build().await.unwrap();
30611///
30612/// # let client = hyper_util::client::legacy::Client::builder(
30613/// # hyper_util::rt::TokioExecutor::new()
30614/// # )
30615/// # .build(
30616/// # hyper_rustls::HttpsConnectorBuilder::new()
30617/// # .with_native_roots()
30618/// # .unwrap()
30619/// # .https_or_http()
30620/// # .enable_http2()
30621/// # .build()
30622/// # );
30623/// # let mut hub = NetworkServices::new(client, auth);
30624/// // You can configure optional parameters by calling the respective setters at will, and
30625/// // execute the final call using `doit()`.
30626/// // Values shown here are possibly random and not representative !
30627/// let result = hub.projects().locations_tls_routes_delete("name")
30628/// .doit().await;
30629/// # }
30630/// ```
30631pub struct ProjectLocationTlsRouteDeleteCall<'a, C>
30632where
30633 C: 'a,
30634{
30635 hub: &'a NetworkServices<C>,
30636 _name: String,
30637 _delegate: Option<&'a mut dyn common::Delegate>,
30638 _additional_params: HashMap<String, String>,
30639 _scopes: BTreeSet<String>,
30640}
30641
30642impl<'a, C> common::CallBuilder for ProjectLocationTlsRouteDeleteCall<'a, C> {}
30643
30644impl<'a, C> ProjectLocationTlsRouteDeleteCall<'a, C>
30645where
30646 C: common::Connector,
30647{
30648 /// Perform the operation you have build so far.
30649 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
30650 use std::borrow::Cow;
30651 use std::io::{Read, Seek};
30652
30653 use common::{url::Params, ToParts};
30654 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
30655
30656 let mut dd = common::DefaultDelegate;
30657 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
30658 dlg.begin(common::MethodInfo {
30659 id: "networkservices.projects.locations.tlsRoutes.delete",
30660 http_method: hyper::Method::DELETE,
30661 });
30662
30663 for &field in ["alt", "name"].iter() {
30664 if self._additional_params.contains_key(field) {
30665 dlg.finished(false);
30666 return Err(common::Error::FieldClash(field));
30667 }
30668 }
30669
30670 let mut params = Params::with_capacity(3 + self._additional_params.len());
30671 params.push("name", self._name);
30672
30673 params.extend(self._additional_params.iter());
30674
30675 params.push("alt", "json");
30676 let mut url = self.hub._base_url.clone() + "v1/{+name}";
30677 if self._scopes.is_empty() {
30678 self._scopes
30679 .insert(Scope::CloudPlatform.as_ref().to_string());
30680 }
30681
30682 #[allow(clippy::single_element_loop)]
30683 for &(find_this, param_name) in [("{+name}", "name")].iter() {
30684 url = params.uri_replacement(url, param_name, find_this, true);
30685 }
30686 {
30687 let to_remove = ["name"];
30688 params.remove_params(&to_remove);
30689 }
30690
30691 let url = params.parse_with_url(&url);
30692
30693 loop {
30694 let token = match self
30695 .hub
30696 .auth
30697 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
30698 .await
30699 {
30700 Ok(token) => token,
30701 Err(e) => match dlg.token(e) {
30702 Ok(token) => token,
30703 Err(e) => {
30704 dlg.finished(false);
30705 return Err(common::Error::MissingToken(e));
30706 }
30707 },
30708 };
30709 let mut req_result = {
30710 let client = &self.hub.client;
30711 dlg.pre_request();
30712 let mut req_builder = hyper::Request::builder()
30713 .method(hyper::Method::DELETE)
30714 .uri(url.as_str())
30715 .header(USER_AGENT, self.hub._user_agent.clone());
30716
30717 if let Some(token) = token.as_ref() {
30718 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
30719 }
30720
30721 let request = req_builder
30722 .header(CONTENT_LENGTH, 0_u64)
30723 .body(common::to_body::<String>(None));
30724
30725 client.request(request.unwrap()).await
30726 };
30727
30728 match req_result {
30729 Err(err) => {
30730 if let common::Retry::After(d) = dlg.http_error(&err) {
30731 sleep(d).await;
30732 continue;
30733 }
30734 dlg.finished(false);
30735 return Err(common::Error::HttpError(err));
30736 }
30737 Ok(res) => {
30738 let (mut parts, body) = res.into_parts();
30739 let mut body = common::Body::new(body);
30740 if !parts.status.is_success() {
30741 let bytes = common::to_bytes(body).await.unwrap_or_default();
30742 let error = serde_json::from_str(&common::to_string(&bytes));
30743 let response = common::to_response(parts, bytes.into());
30744
30745 if let common::Retry::After(d) =
30746 dlg.http_failure(&response, error.as_ref().ok())
30747 {
30748 sleep(d).await;
30749 continue;
30750 }
30751
30752 dlg.finished(false);
30753
30754 return Err(match error {
30755 Ok(value) => common::Error::BadRequest(value),
30756 _ => common::Error::Failure(response),
30757 });
30758 }
30759 let response = {
30760 let bytes = common::to_bytes(body).await.unwrap_or_default();
30761 let encoded = common::to_string(&bytes);
30762 match serde_json::from_str(&encoded) {
30763 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
30764 Err(error) => {
30765 dlg.response_json_decode_error(&encoded, &error);
30766 return Err(common::Error::JsonDecodeError(
30767 encoded.to_string(),
30768 error,
30769 ));
30770 }
30771 }
30772 };
30773
30774 dlg.finished(true);
30775 return Ok(response);
30776 }
30777 }
30778 }
30779 }
30780
30781 /// Required. A name of the TlsRoute to delete. Must be in the format `projects/*/locations/*/tlsRoutes/*`.
30782 ///
30783 /// Sets the *name* path property to the given value.
30784 ///
30785 /// Even though the property as already been set when instantiating this call,
30786 /// we provide this method for API completeness.
30787 pub fn name(mut self, new_value: &str) -> ProjectLocationTlsRouteDeleteCall<'a, C> {
30788 self._name = new_value.to_string();
30789 self
30790 }
30791 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
30792 /// while executing the actual API request.
30793 ///
30794 /// ````text
30795 /// It should be used to handle progress information, and to implement a certain level of resilience.
30796 /// ````
30797 ///
30798 /// Sets the *delegate* property to the given value.
30799 pub fn delegate(
30800 mut self,
30801 new_value: &'a mut dyn common::Delegate,
30802 ) -> ProjectLocationTlsRouteDeleteCall<'a, C> {
30803 self._delegate = Some(new_value);
30804 self
30805 }
30806
30807 /// Set any additional parameter of the query string used in the request.
30808 /// It should be used to set parameters which are not yet available through their own
30809 /// setters.
30810 ///
30811 /// Please note that this method must not be used to set any of the known parameters
30812 /// which have their own setter method. If done anyway, the request will fail.
30813 ///
30814 /// # Additional Parameters
30815 ///
30816 /// * *$.xgafv* (query-string) - V1 error format.
30817 /// * *access_token* (query-string) - OAuth access token.
30818 /// * *alt* (query-string) - Data format for response.
30819 /// * *callback* (query-string) - JSONP
30820 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
30821 /// * *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.
30822 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
30823 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
30824 /// * *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.
30825 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
30826 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
30827 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationTlsRouteDeleteCall<'a, C>
30828 where
30829 T: AsRef<str>,
30830 {
30831 self._additional_params
30832 .insert(name.as_ref().to_string(), value.as_ref().to_string());
30833 self
30834 }
30835
30836 /// Identifies the authorization scope for the method you are building.
30837 ///
30838 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
30839 /// [`Scope::CloudPlatform`].
30840 ///
30841 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
30842 /// tokens for more than one scope.
30843 ///
30844 /// Usually there is more than one suitable scope to authorize an operation, some of which may
30845 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
30846 /// sufficient, a read-write scope will do as well.
30847 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationTlsRouteDeleteCall<'a, C>
30848 where
30849 St: AsRef<str>,
30850 {
30851 self._scopes.insert(String::from(scope.as_ref()));
30852 self
30853 }
30854 /// Identifies the authorization scope(s) for the method you are building.
30855 ///
30856 /// See [`Self::add_scope()`] for details.
30857 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationTlsRouteDeleteCall<'a, C>
30858 where
30859 I: IntoIterator<Item = St>,
30860 St: AsRef<str>,
30861 {
30862 self._scopes
30863 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
30864 self
30865 }
30866
30867 /// Removes all scopes, and no default scope will be used either.
30868 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
30869 /// for details).
30870 pub fn clear_scopes(mut self) -> ProjectLocationTlsRouteDeleteCall<'a, C> {
30871 self._scopes.clear();
30872 self
30873 }
30874}
30875
30876/// Gets details of a single TlsRoute.
30877///
30878/// A builder for the *locations.tlsRoutes.get* method supported by a *project* resource.
30879/// It is not used directly, but through a [`ProjectMethods`] instance.
30880///
30881/// # Example
30882///
30883/// Instantiate a resource method builder
30884///
30885/// ```test_harness,no_run
30886/// # extern crate hyper;
30887/// # extern crate hyper_rustls;
30888/// # extern crate google_networkservices1 as networkservices1;
30889/// # async fn dox() {
30890/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
30891///
30892/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
30893/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
30894/// # .with_native_roots()
30895/// # .unwrap()
30896/// # .https_only()
30897/// # .enable_http2()
30898/// # .build();
30899///
30900/// # let executor = hyper_util::rt::TokioExecutor::new();
30901/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
30902/// # secret,
30903/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
30904/// # yup_oauth2::client::CustomHyperClientBuilder::from(
30905/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
30906/// # ),
30907/// # ).build().await.unwrap();
30908///
30909/// # let client = hyper_util::client::legacy::Client::builder(
30910/// # hyper_util::rt::TokioExecutor::new()
30911/// # )
30912/// # .build(
30913/// # hyper_rustls::HttpsConnectorBuilder::new()
30914/// # .with_native_roots()
30915/// # .unwrap()
30916/// # .https_or_http()
30917/// # .enable_http2()
30918/// # .build()
30919/// # );
30920/// # let mut hub = NetworkServices::new(client, auth);
30921/// // You can configure optional parameters by calling the respective setters at will, and
30922/// // execute the final call using `doit()`.
30923/// // Values shown here are possibly random and not representative !
30924/// let result = hub.projects().locations_tls_routes_get("name")
30925/// .doit().await;
30926/// # }
30927/// ```
30928pub struct ProjectLocationTlsRouteGetCall<'a, C>
30929where
30930 C: 'a,
30931{
30932 hub: &'a NetworkServices<C>,
30933 _name: String,
30934 _delegate: Option<&'a mut dyn common::Delegate>,
30935 _additional_params: HashMap<String, String>,
30936 _scopes: BTreeSet<String>,
30937}
30938
30939impl<'a, C> common::CallBuilder for ProjectLocationTlsRouteGetCall<'a, C> {}
30940
30941impl<'a, C> ProjectLocationTlsRouteGetCall<'a, C>
30942where
30943 C: common::Connector,
30944{
30945 /// Perform the operation you have build so far.
30946 pub async fn doit(mut self) -> common::Result<(common::Response, TlsRoute)> {
30947 use std::borrow::Cow;
30948 use std::io::{Read, Seek};
30949
30950 use common::{url::Params, ToParts};
30951 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
30952
30953 let mut dd = common::DefaultDelegate;
30954 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
30955 dlg.begin(common::MethodInfo {
30956 id: "networkservices.projects.locations.tlsRoutes.get",
30957 http_method: hyper::Method::GET,
30958 });
30959
30960 for &field in ["alt", "name"].iter() {
30961 if self._additional_params.contains_key(field) {
30962 dlg.finished(false);
30963 return Err(common::Error::FieldClash(field));
30964 }
30965 }
30966
30967 let mut params = Params::with_capacity(3 + self._additional_params.len());
30968 params.push("name", self._name);
30969
30970 params.extend(self._additional_params.iter());
30971
30972 params.push("alt", "json");
30973 let mut url = self.hub._base_url.clone() + "v1/{+name}";
30974 if self._scopes.is_empty() {
30975 self._scopes
30976 .insert(Scope::CloudPlatform.as_ref().to_string());
30977 }
30978
30979 #[allow(clippy::single_element_loop)]
30980 for &(find_this, param_name) in [("{+name}", "name")].iter() {
30981 url = params.uri_replacement(url, param_name, find_this, true);
30982 }
30983 {
30984 let to_remove = ["name"];
30985 params.remove_params(&to_remove);
30986 }
30987
30988 let url = params.parse_with_url(&url);
30989
30990 loop {
30991 let token = match self
30992 .hub
30993 .auth
30994 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
30995 .await
30996 {
30997 Ok(token) => token,
30998 Err(e) => match dlg.token(e) {
30999 Ok(token) => token,
31000 Err(e) => {
31001 dlg.finished(false);
31002 return Err(common::Error::MissingToken(e));
31003 }
31004 },
31005 };
31006 let mut req_result = {
31007 let client = &self.hub.client;
31008 dlg.pre_request();
31009 let mut req_builder = hyper::Request::builder()
31010 .method(hyper::Method::GET)
31011 .uri(url.as_str())
31012 .header(USER_AGENT, self.hub._user_agent.clone());
31013
31014 if let Some(token) = token.as_ref() {
31015 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
31016 }
31017
31018 let request = req_builder
31019 .header(CONTENT_LENGTH, 0_u64)
31020 .body(common::to_body::<String>(None));
31021
31022 client.request(request.unwrap()).await
31023 };
31024
31025 match req_result {
31026 Err(err) => {
31027 if let common::Retry::After(d) = dlg.http_error(&err) {
31028 sleep(d).await;
31029 continue;
31030 }
31031 dlg.finished(false);
31032 return Err(common::Error::HttpError(err));
31033 }
31034 Ok(res) => {
31035 let (mut parts, body) = res.into_parts();
31036 let mut body = common::Body::new(body);
31037 if !parts.status.is_success() {
31038 let bytes = common::to_bytes(body).await.unwrap_or_default();
31039 let error = serde_json::from_str(&common::to_string(&bytes));
31040 let response = common::to_response(parts, bytes.into());
31041
31042 if let common::Retry::After(d) =
31043 dlg.http_failure(&response, error.as_ref().ok())
31044 {
31045 sleep(d).await;
31046 continue;
31047 }
31048
31049 dlg.finished(false);
31050
31051 return Err(match error {
31052 Ok(value) => common::Error::BadRequest(value),
31053 _ => common::Error::Failure(response),
31054 });
31055 }
31056 let response = {
31057 let bytes = common::to_bytes(body).await.unwrap_or_default();
31058 let encoded = common::to_string(&bytes);
31059 match serde_json::from_str(&encoded) {
31060 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
31061 Err(error) => {
31062 dlg.response_json_decode_error(&encoded, &error);
31063 return Err(common::Error::JsonDecodeError(
31064 encoded.to_string(),
31065 error,
31066 ));
31067 }
31068 }
31069 };
31070
31071 dlg.finished(true);
31072 return Ok(response);
31073 }
31074 }
31075 }
31076 }
31077
31078 /// Required. A name of the TlsRoute to get. Must be in the format `projects/*/locations/*/tlsRoutes/*`.
31079 ///
31080 /// Sets the *name* path property to the given value.
31081 ///
31082 /// Even though the property as already been set when instantiating this call,
31083 /// we provide this method for API completeness.
31084 pub fn name(mut self, new_value: &str) -> ProjectLocationTlsRouteGetCall<'a, C> {
31085 self._name = new_value.to_string();
31086 self
31087 }
31088 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
31089 /// while executing the actual API request.
31090 ///
31091 /// ````text
31092 /// It should be used to handle progress information, and to implement a certain level of resilience.
31093 /// ````
31094 ///
31095 /// Sets the *delegate* property to the given value.
31096 pub fn delegate(
31097 mut self,
31098 new_value: &'a mut dyn common::Delegate,
31099 ) -> ProjectLocationTlsRouteGetCall<'a, C> {
31100 self._delegate = Some(new_value);
31101 self
31102 }
31103
31104 /// Set any additional parameter of the query string used in the request.
31105 /// It should be used to set parameters which are not yet available through their own
31106 /// setters.
31107 ///
31108 /// Please note that this method must not be used to set any of the known parameters
31109 /// which have their own setter method. If done anyway, the request will fail.
31110 ///
31111 /// # Additional Parameters
31112 ///
31113 /// * *$.xgafv* (query-string) - V1 error format.
31114 /// * *access_token* (query-string) - OAuth access token.
31115 /// * *alt* (query-string) - Data format for response.
31116 /// * *callback* (query-string) - JSONP
31117 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
31118 /// * *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.
31119 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
31120 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
31121 /// * *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.
31122 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
31123 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
31124 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationTlsRouteGetCall<'a, C>
31125 where
31126 T: AsRef<str>,
31127 {
31128 self._additional_params
31129 .insert(name.as_ref().to_string(), value.as_ref().to_string());
31130 self
31131 }
31132
31133 /// Identifies the authorization scope for the method you are building.
31134 ///
31135 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
31136 /// [`Scope::CloudPlatform`].
31137 ///
31138 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
31139 /// tokens for more than one scope.
31140 ///
31141 /// Usually there is more than one suitable scope to authorize an operation, some of which may
31142 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
31143 /// sufficient, a read-write scope will do as well.
31144 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationTlsRouteGetCall<'a, C>
31145 where
31146 St: AsRef<str>,
31147 {
31148 self._scopes.insert(String::from(scope.as_ref()));
31149 self
31150 }
31151 /// Identifies the authorization scope(s) for the method you are building.
31152 ///
31153 /// See [`Self::add_scope()`] for details.
31154 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationTlsRouteGetCall<'a, C>
31155 where
31156 I: IntoIterator<Item = St>,
31157 St: AsRef<str>,
31158 {
31159 self._scopes
31160 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
31161 self
31162 }
31163
31164 /// Removes all scopes, and no default scope will be used either.
31165 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
31166 /// for details).
31167 pub fn clear_scopes(mut self) -> ProjectLocationTlsRouteGetCall<'a, C> {
31168 self._scopes.clear();
31169 self
31170 }
31171}
31172
31173/// Lists TlsRoute in a given project and location.
31174///
31175/// A builder for the *locations.tlsRoutes.list* method supported by a *project* resource.
31176/// It is not used directly, but through a [`ProjectMethods`] instance.
31177///
31178/// # Example
31179///
31180/// Instantiate a resource method builder
31181///
31182/// ```test_harness,no_run
31183/// # extern crate hyper;
31184/// # extern crate hyper_rustls;
31185/// # extern crate google_networkservices1 as networkservices1;
31186/// # async fn dox() {
31187/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
31188///
31189/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
31190/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
31191/// # .with_native_roots()
31192/// # .unwrap()
31193/// # .https_only()
31194/// # .enable_http2()
31195/// # .build();
31196///
31197/// # let executor = hyper_util::rt::TokioExecutor::new();
31198/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
31199/// # secret,
31200/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
31201/// # yup_oauth2::client::CustomHyperClientBuilder::from(
31202/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
31203/// # ),
31204/// # ).build().await.unwrap();
31205///
31206/// # let client = hyper_util::client::legacy::Client::builder(
31207/// # hyper_util::rt::TokioExecutor::new()
31208/// # )
31209/// # .build(
31210/// # hyper_rustls::HttpsConnectorBuilder::new()
31211/// # .with_native_roots()
31212/// # .unwrap()
31213/// # .https_or_http()
31214/// # .enable_http2()
31215/// # .build()
31216/// # );
31217/// # let mut hub = NetworkServices::new(client, auth);
31218/// // You can configure optional parameters by calling the respective setters at will, and
31219/// // execute the final call using `doit()`.
31220/// // Values shown here are possibly random and not representative !
31221/// let result = hub.projects().locations_tls_routes_list("parent")
31222/// .return_partial_success(false)
31223/// .page_token("sea")
31224/// .page_size(-59)
31225/// .doit().await;
31226/// # }
31227/// ```
31228pub struct ProjectLocationTlsRouteListCall<'a, C>
31229where
31230 C: 'a,
31231{
31232 hub: &'a NetworkServices<C>,
31233 _parent: String,
31234 _return_partial_success: Option<bool>,
31235 _page_token: Option<String>,
31236 _page_size: Option<i32>,
31237 _delegate: Option<&'a mut dyn common::Delegate>,
31238 _additional_params: HashMap<String, String>,
31239 _scopes: BTreeSet<String>,
31240}
31241
31242impl<'a, C> common::CallBuilder for ProjectLocationTlsRouteListCall<'a, C> {}
31243
31244impl<'a, C> ProjectLocationTlsRouteListCall<'a, C>
31245where
31246 C: common::Connector,
31247{
31248 /// Perform the operation you have build so far.
31249 pub async fn doit(mut self) -> common::Result<(common::Response, ListTlsRoutesResponse)> {
31250 use std::borrow::Cow;
31251 use std::io::{Read, Seek};
31252
31253 use common::{url::Params, ToParts};
31254 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
31255
31256 let mut dd = common::DefaultDelegate;
31257 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
31258 dlg.begin(common::MethodInfo {
31259 id: "networkservices.projects.locations.tlsRoutes.list",
31260 http_method: hyper::Method::GET,
31261 });
31262
31263 for &field in [
31264 "alt",
31265 "parent",
31266 "returnPartialSuccess",
31267 "pageToken",
31268 "pageSize",
31269 ]
31270 .iter()
31271 {
31272 if self._additional_params.contains_key(field) {
31273 dlg.finished(false);
31274 return Err(common::Error::FieldClash(field));
31275 }
31276 }
31277
31278 let mut params = Params::with_capacity(6 + self._additional_params.len());
31279 params.push("parent", self._parent);
31280 if let Some(value) = self._return_partial_success.as_ref() {
31281 params.push("returnPartialSuccess", value.to_string());
31282 }
31283 if let Some(value) = self._page_token.as_ref() {
31284 params.push("pageToken", value);
31285 }
31286 if let Some(value) = self._page_size.as_ref() {
31287 params.push("pageSize", value.to_string());
31288 }
31289
31290 params.extend(self._additional_params.iter());
31291
31292 params.push("alt", "json");
31293 let mut url = self.hub._base_url.clone() + "v1/{+parent}/tlsRoutes";
31294 if self._scopes.is_empty() {
31295 self._scopes
31296 .insert(Scope::CloudPlatform.as_ref().to_string());
31297 }
31298
31299 #[allow(clippy::single_element_loop)]
31300 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
31301 url = params.uri_replacement(url, param_name, find_this, true);
31302 }
31303 {
31304 let to_remove = ["parent"];
31305 params.remove_params(&to_remove);
31306 }
31307
31308 let url = params.parse_with_url(&url);
31309
31310 loop {
31311 let token = match self
31312 .hub
31313 .auth
31314 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
31315 .await
31316 {
31317 Ok(token) => token,
31318 Err(e) => match dlg.token(e) {
31319 Ok(token) => token,
31320 Err(e) => {
31321 dlg.finished(false);
31322 return Err(common::Error::MissingToken(e));
31323 }
31324 },
31325 };
31326 let mut req_result = {
31327 let client = &self.hub.client;
31328 dlg.pre_request();
31329 let mut req_builder = hyper::Request::builder()
31330 .method(hyper::Method::GET)
31331 .uri(url.as_str())
31332 .header(USER_AGENT, self.hub._user_agent.clone());
31333
31334 if let Some(token) = token.as_ref() {
31335 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
31336 }
31337
31338 let request = req_builder
31339 .header(CONTENT_LENGTH, 0_u64)
31340 .body(common::to_body::<String>(None));
31341
31342 client.request(request.unwrap()).await
31343 };
31344
31345 match req_result {
31346 Err(err) => {
31347 if let common::Retry::After(d) = dlg.http_error(&err) {
31348 sleep(d).await;
31349 continue;
31350 }
31351 dlg.finished(false);
31352 return Err(common::Error::HttpError(err));
31353 }
31354 Ok(res) => {
31355 let (mut parts, body) = res.into_parts();
31356 let mut body = common::Body::new(body);
31357 if !parts.status.is_success() {
31358 let bytes = common::to_bytes(body).await.unwrap_or_default();
31359 let error = serde_json::from_str(&common::to_string(&bytes));
31360 let response = common::to_response(parts, bytes.into());
31361
31362 if let common::Retry::After(d) =
31363 dlg.http_failure(&response, error.as_ref().ok())
31364 {
31365 sleep(d).await;
31366 continue;
31367 }
31368
31369 dlg.finished(false);
31370
31371 return Err(match error {
31372 Ok(value) => common::Error::BadRequest(value),
31373 _ => common::Error::Failure(response),
31374 });
31375 }
31376 let response = {
31377 let bytes = common::to_bytes(body).await.unwrap_or_default();
31378 let encoded = common::to_string(&bytes);
31379 match serde_json::from_str(&encoded) {
31380 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
31381 Err(error) => {
31382 dlg.response_json_decode_error(&encoded, &error);
31383 return Err(common::Error::JsonDecodeError(
31384 encoded.to_string(),
31385 error,
31386 ));
31387 }
31388 }
31389 };
31390
31391 dlg.finished(true);
31392 return Ok(response);
31393 }
31394 }
31395 }
31396 }
31397
31398 /// Required. The project and location from which the TlsRoutes should be listed, specified in the format `projects/*/locations/*`.
31399 ///
31400 /// Sets the *parent* path property to the given value.
31401 ///
31402 /// Even though the property as already been set when instantiating this call,
31403 /// we provide this method for API completeness.
31404 pub fn parent(mut self, new_value: &str) -> ProjectLocationTlsRouteListCall<'a, C> {
31405 self._parent = new_value.to_string();
31406 self
31407 }
31408 /// Optional. If true, allow partial responses for multi-regional Aggregated List requests. Otherwise if one of the locations is down or unreachable, the Aggregated List request will fail.
31409 ///
31410 /// Sets the *return partial success* query property to the given value.
31411 pub fn return_partial_success(
31412 mut self,
31413 new_value: bool,
31414 ) -> ProjectLocationTlsRouteListCall<'a, C> {
31415 self._return_partial_success = Some(new_value);
31416 self
31417 }
31418 /// The value returned by the last `ListTlsRoutesResponse` Indicates that this is a continuation of a prior `ListTlsRoutes` call, and that the system should return the next page of data.
31419 ///
31420 /// Sets the *page token* query property to the given value.
31421 pub fn page_token(mut self, new_value: &str) -> ProjectLocationTlsRouteListCall<'a, C> {
31422 self._page_token = Some(new_value.to_string());
31423 self
31424 }
31425 /// Maximum number of TlsRoutes to return per call.
31426 ///
31427 /// Sets the *page size* query property to the given value.
31428 pub fn page_size(mut self, new_value: i32) -> ProjectLocationTlsRouteListCall<'a, C> {
31429 self._page_size = Some(new_value);
31430 self
31431 }
31432 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
31433 /// while executing the actual API request.
31434 ///
31435 /// ````text
31436 /// It should be used to handle progress information, and to implement a certain level of resilience.
31437 /// ````
31438 ///
31439 /// Sets the *delegate* property to the given value.
31440 pub fn delegate(
31441 mut self,
31442 new_value: &'a mut dyn common::Delegate,
31443 ) -> ProjectLocationTlsRouteListCall<'a, C> {
31444 self._delegate = Some(new_value);
31445 self
31446 }
31447
31448 /// Set any additional parameter of the query string used in the request.
31449 /// It should be used to set parameters which are not yet available through their own
31450 /// setters.
31451 ///
31452 /// Please note that this method must not be used to set any of the known parameters
31453 /// which have their own setter method. If done anyway, the request will fail.
31454 ///
31455 /// # Additional Parameters
31456 ///
31457 /// * *$.xgafv* (query-string) - V1 error format.
31458 /// * *access_token* (query-string) - OAuth access token.
31459 /// * *alt* (query-string) - Data format for response.
31460 /// * *callback* (query-string) - JSONP
31461 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
31462 /// * *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.
31463 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
31464 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
31465 /// * *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.
31466 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
31467 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
31468 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationTlsRouteListCall<'a, C>
31469 where
31470 T: AsRef<str>,
31471 {
31472 self._additional_params
31473 .insert(name.as_ref().to_string(), value.as_ref().to_string());
31474 self
31475 }
31476
31477 /// Identifies the authorization scope for the method you are building.
31478 ///
31479 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
31480 /// [`Scope::CloudPlatform`].
31481 ///
31482 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
31483 /// tokens for more than one scope.
31484 ///
31485 /// Usually there is more than one suitable scope to authorize an operation, some of which may
31486 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
31487 /// sufficient, a read-write scope will do as well.
31488 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationTlsRouteListCall<'a, C>
31489 where
31490 St: AsRef<str>,
31491 {
31492 self._scopes.insert(String::from(scope.as_ref()));
31493 self
31494 }
31495 /// Identifies the authorization scope(s) for the method you are building.
31496 ///
31497 /// See [`Self::add_scope()`] for details.
31498 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationTlsRouteListCall<'a, C>
31499 where
31500 I: IntoIterator<Item = St>,
31501 St: AsRef<str>,
31502 {
31503 self._scopes
31504 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
31505 self
31506 }
31507
31508 /// Removes all scopes, and no default scope will be used either.
31509 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
31510 /// for details).
31511 pub fn clear_scopes(mut self) -> ProjectLocationTlsRouteListCall<'a, C> {
31512 self._scopes.clear();
31513 self
31514 }
31515}
31516
31517/// Updates the parameters of a single TlsRoute.
31518///
31519/// A builder for the *locations.tlsRoutes.patch* method supported by a *project* resource.
31520/// It is not used directly, but through a [`ProjectMethods`] instance.
31521///
31522/// # Example
31523///
31524/// Instantiate a resource method builder
31525///
31526/// ```test_harness,no_run
31527/// # extern crate hyper;
31528/// # extern crate hyper_rustls;
31529/// # extern crate google_networkservices1 as networkservices1;
31530/// use networkservices1::api::TlsRoute;
31531/// # async fn dox() {
31532/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
31533///
31534/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
31535/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
31536/// # .with_native_roots()
31537/// # .unwrap()
31538/// # .https_only()
31539/// # .enable_http2()
31540/// # .build();
31541///
31542/// # let executor = hyper_util::rt::TokioExecutor::new();
31543/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
31544/// # secret,
31545/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
31546/// # yup_oauth2::client::CustomHyperClientBuilder::from(
31547/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
31548/// # ),
31549/// # ).build().await.unwrap();
31550///
31551/// # let client = hyper_util::client::legacy::Client::builder(
31552/// # hyper_util::rt::TokioExecutor::new()
31553/// # )
31554/// # .build(
31555/// # hyper_rustls::HttpsConnectorBuilder::new()
31556/// # .with_native_roots()
31557/// # .unwrap()
31558/// # .https_or_http()
31559/// # .enable_http2()
31560/// # .build()
31561/// # );
31562/// # let mut hub = NetworkServices::new(client, auth);
31563/// // As the method needs a request, you would usually fill it with the desired information
31564/// // into the respective structure. Some of the parts shown here might not be applicable !
31565/// // Values shown here are possibly random and not representative !
31566/// let mut req = TlsRoute::default();
31567///
31568/// // You can configure optional parameters by calling the respective setters at will, and
31569/// // execute the final call using `doit()`.
31570/// // Values shown here are possibly random and not representative !
31571/// let result = hub.projects().locations_tls_routes_patch(req, "name")
31572/// .update_mask(FieldMask::new::<&str>(&[]))
31573/// .doit().await;
31574/// # }
31575/// ```
31576pub struct ProjectLocationTlsRoutePatchCall<'a, C>
31577where
31578 C: 'a,
31579{
31580 hub: &'a NetworkServices<C>,
31581 _request: TlsRoute,
31582 _name: String,
31583 _update_mask: Option<common::FieldMask>,
31584 _delegate: Option<&'a mut dyn common::Delegate>,
31585 _additional_params: HashMap<String, String>,
31586 _scopes: BTreeSet<String>,
31587}
31588
31589impl<'a, C> common::CallBuilder for ProjectLocationTlsRoutePatchCall<'a, C> {}
31590
31591impl<'a, C> ProjectLocationTlsRoutePatchCall<'a, C>
31592where
31593 C: common::Connector,
31594{
31595 /// Perform the operation you have build so far.
31596 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
31597 use std::borrow::Cow;
31598 use std::io::{Read, Seek};
31599
31600 use common::{url::Params, ToParts};
31601 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
31602
31603 let mut dd = common::DefaultDelegate;
31604 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
31605 dlg.begin(common::MethodInfo {
31606 id: "networkservices.projects.locations.tlsRoutes.patch",
31607 http_method: hyper::Method::PATCH,
31608 });
31609
31610 for &field in ["alt", "name", "updateMask"].iter() {
31611 if self._additional_params.contains_key(field) {
31612 dlg.finished(false);
31613 return Err(common::Error::FieldClash(field));
31614 }
31615 }
31616
31617 let mut params = Params::with_capacity(5 + self._additional_params.len());
31618 params.push("name", self._name);
31619 if let Some(value) = self._update_mask.as_ref() {
31620 params.push("updateMask", value.to_string());
31621 }
31622
31623 params.extend(self._additional_params.iter());
31624
31625 params.push("alt", "json");
31626 let mut url = self.hub._base_url.clone() + "v1/{+name}";
31627 if self._scopes.is_empty() {
31628 self._scopes
31629 .insert(Scope::CloudPlatform.as_ref().to_string());
31630 }
31631
31632 #[allow(clippy::single_element_loop)]
31633 for &(find_this, param_name) in [("{+name}", "name")].iter() {
31634 url = params.uri_replacement(url, param_name, find_this, true);
31635 }
31636 {
31637 let to_remove = ["name"];
31638 params.remove_params(&to_remove);
31639 }
31640
31641 let url = params.parse_with_url(&url);
31642
31643 let mut json_mime_type = mime::APPLICATION_JSON;
31644 let mut request_value_reader = {
31645 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
31646 common::remove_json_null_values(&mut value);
31647 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
31648 serde_json::to_writer(&mut dst, &value).unwrap();
31649 dst
31650 };
31651 let request_size = request_value_reader
31652 .seek(std::io::SeekFrom::End(0))
31653 .unwrap();
31654 request_value_reader
31655 .seek(std::io::SeekFrom::Start(0))
31656 .unwrap();
31657
31658 loop {
31659 let token = match self
31660 .hub
31661 .auth
31662 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
31663 .await
31664 {
31665 Ok(token) => token,
31666 Err(e) => match dlg.token(e) {
31667 Ok(token) => token,
31668 Err(e) => {
31669 dlg.finished(false);
31670 return Err(common::Error::MissingToken(e));
31671 }
31672 },
31673 };
31674 request_value_reader
31675 .seek(std::io::SeekFrom::Start(0))
31676 .unwrap();
31677 let mut req_result = {
31678 let client = &self.hub.client;
31679 dlg.pre_request();
31680 let mut req_builder = hyper::Request::builder()
31681 .method(hyper::Method::PATCH)
31682 .uri(url.as_str())
31683 .header(USER_AGENT, self.hub._user_agent.clone());
31684
31685 if let Some(token) = token.as_ref() {
31686 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
31687 }
31688
31689 let request = req_builder
31690 .header(CONTENT_TYPE, json_mime_type.to_string())
31691 .header(CONTENT_LENGTH, request_size as u64)
31692 .body(common::to_body(
31693 request_value_reader.get_ref().clone().into(),
31694 ));
31695
31696 client.request(request.unwrap()).await
31697 };
31698
31699 match req_result {
31700 Err(err) => {
31701 if let common::Retry::After(d) = dlg.http_error(&err) {
31702 sleep(d).await;
31703 continue;
31704 }
31705 dlg.finished(false);
31706 return Err(common::Error::HttpError(err));
31707 }
31708 Ok(res) => {
31709 let (mut parts, body) = res.into_parts();
31710 let mut body = common::Body::new(body);
31711 if !parts.status.is_success() {
31712 let bytes = common::to_bytes(body).await.unwrap_or_default();
31713 let error = serde_json::from_str(&common::to_string(&bytes));
31714 let response = common::to_response(parts, bytes.into());
31715
31716 if let common::Retry::After(d) =
31717 dlg.http_failure(&response, error.as_ref().ok())
31718 {
31719 sleep(d).await;
31720 continue;
31721 }
31722
31723 dlg.finished(false);
31724
31725 return Err(match error {
31726 Ok(value) => common::Error::BadRequest(value),
31727 _ => common::Error::Failure(response),
31728 });
31729 }
31730 let response = {
31731 let bytes = common::to_bytes(body).await.unwrap_or_default();
31732 let encoded = common::to_string(&bytes);
31733 match serde_json::from_str(&encoded) {
31734 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
31735 Err(error) => {
31736 dlg.response_json_decode_error(&encoded, &error);
31737 return Err(common::Error::JsonDecodeError(
31738 encoded.to_string(),
31739 error,
31740 ));
31741 }
31742 }
31743 };
31744
31745 dlg.finished(true);
31746 return Ok(response);
31747 }
31748 }
31749 }
31750 }
31751
31752 ///
31753 /// Sets the *request* property to the given value.
31754 ///
31755 /// Even though the property as already been set when instantiating this call,
31756 /// we provide this method for API completeness.
31757 pub fn request(mut self, new_value: TlsRoute) -> ProjectLocationTlsRoutePatchCall<'a, C> {
31758 self._request = new_value;
31759 self
31760 }
31761 /// Identifier. Name of the TlsRoute resource. It matches pattern `projects/*/locations/*/tlsRoutes/tls_route_name>`.
31762 ///
31763 /// Sets the *name* path property to the given value.
31764 ///
31765 /// Even though the property as already been set when instantiating this call,
31766 /// we provide this method for API completeness.
31767 pub fn name(mut self, new_value: &str) -> ProjectLocationTlsRoutePatchCall<'a, C> {
31768 self._name = new_value.to_string();
31769 self
31770 }
31771 /// Optional. Field mask is used to specify the fields to be overwritten in the TlsRoute 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.
31772 ///
31773 /// Sets the *update mask* query property to the given value.
31774 pub fn update_mask(
31775 mut self,
31776 new_value: common::FieldMask,
31777 ) -> ProjectLocationTlsRoutePatchCall<'a, C> {
31778 self._update_mask = Some(new_value);
31779 self
31780 }
31781 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
31782 /// while executing the actual API request.
31783 ///
31784 /// ````text
31785 /// It should be used to handle progress information, and to implement a certain level of resilience.
31786 /// ````
31787 ///
31788 /// Sets the *delegate* property to the given value.
31789 pub fn delegate(
31790 mut self,
31791 new_value: &'a mut dyn common::Delegate,
31792 ) -> ProjectLocationTlsRoutePatchCall<'a, C> {
31793 self._delegate = Some(new_value);
31794 self
31795 }
31796
31797 /// Set any additional parameter of the query string used in the request.
31798 /// It should be used to set parameters which are not yet available through their own
31799 /// setters.
31800 ///
31801 /// Please note that this method must not be used to set any of the known parameters
31802 /// which have their own setter method. If done anyway, the request will fail.
31803 ///
31804 /// # Additional Parameters
31805 ///
31806 /// * *$.xgafv* (query-string) - V1 error format.
31807 /// * *access_token* (query-string) - OAuth access token.
31808 /// * *alt* (query-string) - Data format for response.
31809 /// * *callback* (query-string) - JSONP
31810 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
31811 /// * *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.
31812 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
31813 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
31814 /// * *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.
31815 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
31816 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
31817 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationTlsRoutePatchCall<'a, C>
31818 where
31819 T: AsRef<str>,
31820 {
31821 self._additional_params
31822 .insert(name.as_ref().to_string(), value.as_ref().to_string());
31823 self
31824 }
31825
31826 /// Identifies the authorization scope for the method you are building.
31827 ///
31828 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
31829 /// [`Scope::CloudPlatform`].
31830 ///
31831 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
31832 /// tokens for more than one scope.
31833 ///
31834 /// Usually there is more than one suitable scope to authorize an operation, some of which may
31835 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
31836 /// sufficient, a read-write scope will do as well.
31837 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationTlsRoutePatchCall<'a, C>
31838 where
31839 St: AsRef<str>,
31840 {
31841 self._scopes.insert(String::from(scope.as_ref()));
31842 self
31843 }
31844 /// Identifies the authorization scope(s) for the method you are building.
31845 ///
31846 /// See [`Self::add_scope()`] for details.
31847 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationTlsRoutePatchCall<'a, C>
31848 where
31849 I: IntoIterator<Item = St>,
31850 St: AsRef<str>,
31851 {
31852 self._scopes
31853 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
31854 self
31855 }
31856
31857 /// Removes all scopes, and no default scope will be used either.
31858 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
31859 /// for details).
31860 pub fn clear_scopes(mut self) -> ProjectLocationTlsRoutePatchCall<'a, C> {
31861 self._scopes.clear();
31862 self
31863 }
31864}
31865
31866/// Creates a new `WasmPluginVersion` resource in a given project and location.
31867///
31868/// A builder for the *locations.wasmPlugins.versions.create* method supported by a *project* resource.
31869/// It is not used directly, but through a [`ProjectMethods`] instance.
31870///
31871/// # Example
31872///
31873/// Instantiate a resource method builder
31874///
31875/// ```test_harness,no_run
31876/// # extern crate hyper;
31877/// # extern crate hyper_rustls;
31878/// # extern crate google_networkservices1 as networkservices1;
31879/// use networkservices1::api::WasmPluginVersion;
31880/// # async fn dox() {
31881/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
31882///
31883/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
31884/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
31885/// # .with_native_roots()
31886/// # .unwrap()
31887/// # .https_only()
31888/// # .enable_http2()
31889/// # .build();
31890///
31891/// # let executor = hyper_util::rt::TokioExecutor::new();
31892/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
31893/// # secret,
31894/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
31895/// # yup_oauth2::client::CustomHyperClientBuilder::from(
31896/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
31897/// # ),
31898/// # ).build().await.unwrap();
31899///
31900/// # let client = hyper_util::client::legacy::Client::builder(
31901/// # hyper_util::rt::TokioExecutor::new()
31902/// # )
31903/// # .build(
31904/// # hyper_rustls::HttpsConnectorBuilder::new()
31905/// # .with_native_roots()
31906/// # .unwrap()
31907/// # .https_or_http()
31908/// # .enable_http2()
31909/// # .build()
31910/// # );
31911/// # let mut hub = NetworkServices::new(client, auth);
31912/// // As the method needs a request, you would usually fill it with the desired information
31913/// // into the respective structure. Some of the parts shown here might not be applicable !
31914/// // Values shown here are possibly random and not representative !
31915/// let mut req = WasmPluginVersion::default();
31916///
31917/// // You can configure optional parameters by calling the respective setters at will, and
31918/// // execute the final call using `doit()`.
31919/// // Values shown here are possibly random and not representative !
31920/// let result = hub.projects().locations_wasm_plugins_versions_create(req, "parent")
31921/// .wasm_plugin_version_id("At")
31922/// .doit().await;
31923/// # }
31924/// ```
31925pub struct ProjectLocationWasmPluginVersionCreateCall<'a, C>
31926where
31927 C: 'a,
31928{
31929 hub: &'a NetworkServices<C>,
31930 _request: WasmPluginVersion,
31931 _parent: String,
31932 _wasm_plugin_version_id: Option<String>,
31933 _delegate: Option<&'a mut dyn common::Delegate>,
31934 _additional_params: HashMap<String, String>,
31935 _scopes: BTreeSet<String>,
31936}
31937
31938impl<'a, C> common::CallBuilder for ProjectLocationWasmPluginVersionCreateCall<'a, C> {}
31939
31940impl<'a, C> ProjectLocationWasmPluginVersionCreateCall<'a, C>
31941where
31942 C: common::Connector,
31943{
31944 /// Perform the operation you have build so far.
31945 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
31946 use std::borrow::Cow;
31947 use std::io::{Read, Seek};
31948
31949 use common::{url::Params, ToParts};
31950 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
31951
31952 let mut dd = common::DefaultDelegate;
31953 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
31954 dlg.begin(common::MethodInfo {
31955 id: "networkservices.projects.locations.wasmPlugins.versions.create",
31956 http_method: hyper::Method::POST,
31957 });
31958
31959 for &field in ["alt", "parent", "wasmPluginVersionId"].iter() {
31960 if self._additional_params.contains_key(field) {
31961 dlg.finished(false);
31962 return Err(common::Error::FieldClash(field));
31963 }
31964 }
31965
31966 let mut params = Params::with_capacity(5 + self._additional_params.len());
31967 params.push("parent", self._parent);
31968 if let Some(value) = self._wasm_plugin_version_id.as_ref() {
31969 params.push("wasmPluginVersionId", value);
31970 }
31971
31972 params.extend(self._additional_params.iter());
31973
31974 params.push("alt", "json");
31975 let mut url = self.hub._base_url.clone() + "v1/{+parent}/versions";
31976 if self._scopes.is_empty() {
31977 self._scopes
31978 .insert(Scope::CloudPlatform.as_ref().to_string());
31979 }
31980
31981 #[allow(clippy::single_element_loop)]
31982 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
31983 url = params.uri_replacement(url, param_name, find_this, true);
31984 }
31985 {
31986 let to_remove = ["parent"];
31987 params.remove_params(&to_remove);
31988 }
31989
31990 let url = params.parse_with_url(&url);
31991
31992 let mut json_mime_type = mime::APPLICATION_JSON;
31993 let mut request_value_reader = {
31994 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
31995 common::remove_json_null_values(&mut value);
31996 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
31997 serde_json::to_writer(&mut dst, &value).unwrap();
31998 dst
31999 };
32000 let request_size = request_value_reader
32001 .seek(std::io::SeekFrom::End(0))
32002 .unwrap();
32003 request_value_reader
32004 .seek(std::io::SeekFrom::Start(0))
32005 .unwrap();
32006
32007 loop {
32008 let token = match self
32009 .hub
32010 .auth
32011 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
32012 .await
32013 {
32014 Ok(token) => token,
32015 Err(e) => match dlg.token(e) {
32016 Ok(token) => token,
32017 Err(e) => {
32018 dlg.finished(false);
32019 return Err(common::Error::MissingToken(e));
32020 }
32021 },
32022 };
32023 request_value_reader
32024 .seek(std::io::SeekFrom::Start(0))
32025 .unwrap();
32026 let mut req_result = {
32027 let client = &self.hub.client;
32028 dlg.pre_request();
32029 let mut req_builder = hyper::Request::builder()
32030 .method(hyper::Method::POST)
32031 .uri(url.as_str())
32032 .header(USER_AGENT, self.hub._user_agent.clone());
32033
32034 if let Some(token) = token.as_ref() {
32035 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
32036 }
32037
32038 let request = req_builder
32039 .header(CONTENT_TYPE, json_mime_type.to_string())
32040 .header(CONTENT_LENGTH, request_size as u64)
32041 .body(common::to_body(
32042 request_value_reader.get_ref().clone().into(),
32043 ));
32044
32045 client.request(request.unwrap()).await
32046 };
32047
32048 match req_result {
32049 Err(err) => {
32050 if let common::Retry::After(d) = dlg.http_error(&err) {
32051 sleep(d).await;
32052 continue;
32053 }
32054 dlg.finished(false);
32055 return Err(common::Error::HttpError(err));
32056 }
32057 Ok(res) => {
32058 let (mut parts, body) = res.into_parts();
32059 let mut body = common::Body::new(body);
32060 if !parts.status.is_success() {
32061 let bytes = common::to_bytes(body).await.unwrap_or_default();
32062 let error = serde_json::from_str(&common::to_string(&bytes));
32063 let response = common::to_response(parts, bytes.into());
32064
32065 if let common::Retry::After(d) =
32066 dlg.http_failure(&response, error.as_ref().ok())
32067 {
32068 sleep(d).await;
32069 continue;
32070 }
32071
32072 dlg.finished(false);
32073
32074 return Err(match error {
32075 Ok(value) => common::Error::BadRequest(value),
32076 _ => common::Error::Failure(response),
32077 });
32078 }
32079 let response = {
32080 let bytes = common::to_bytes(body).await.unwrap_or_default();
32081 let encoded = common::to_string(&bytes);
32082 match serde_json::from_str(&encoded) {
32083 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
32084 Err(error) => {
32085 dlg.response_json_decode_error(&encoded, &error);
32086 return Err(common::Error::JsonDecodeError(
32087 encoded.to_string(),
32088 error,
32089 ));
32090 }
32091 }
32092 };
32093
32094 dlg.finished(true);
32095 return Ok(response);
32096 }
32097 }
32098 }
32099 }
32100
32101 ///
32102 /// Sets the *request* property to the given value.
32103 ///
32104 /// Even though the property as already been set when instantiating this call,
32105 /// we provide this method for API completeness.
32106 pub fn request(
32107 mut self,
32108 new_value: WasmPluginVersion,
32109 ) -> ProjectLocationWasmPluginVersionCreateCall<'a, C> {
32110 self._request = new_value;
32111 self
32112 }
32113 /// Required. The parent resource of the `WasmPluginVersion` resource. Must be in the format `projects/{project}/locations/global/wasmPlugins/{wasm_plugin}`.
32114 ///
32115 /// Sets the *parent* path property to the given value.
32116 ///
32117 /// Even though the property as already been set when instantiating this call,
32118 /// we provide this method for API completeness.
32119 pub fn parent(mut self, new_value: &str) -> ProjectLocationWasmPluginVersionCreateCall<'a, C> {
32120 self._parent = new_value.to_string();
32121 self
32122 }
32123 /// Required. User-provided ID of the `WasmPluginVersion` resource to be created.
32124 ///
32125 /// Sets the *wasm plugin version id* query property to the given value.
32126 pub fn wasm_plugin_version_id(
32127 mut self,
32128 new_value: &str,
32129 ) -> ProjectLocationWasmPluginVersionCreateCall<'a, C> {
32130 self._wasm_plugin_version_id = Some(new_value.to_string());
32131 self
32132 }
32133 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
32134 /// while executing the actual API request.
32135 ///
32136 /// ````text
32137 /// It should be used to handle progress information, and to implement a certain level of resilience.
32138 /// ````
32139 ///
32140 /// Sets the *delegate* property to the given value.
32141 pub fn delegate(
32142 mut self,
32143 new_value: &'a mut dyn common::Delegate,
32144 ) -> ProjectLocationWasmPluginVersionCreateCall<'a, C> {
32145 self._delegate = Some(new_value);
32146 self
32147 }
32148
32149 /// Set any additional parameter of the query string used in the request.
32150 /// It should be used to set parameters which are not yet available through their own
32151 /// setters.
32152 ///
32153 /// Please note that this method must not be used to set any of the known parameters
32154 /// which have their own setter method. If done anyway, the request will fail.
32155 ///
32156 /// # Additional Parameters
32157 ///
32158 /// * *$.xgafv* (query-string) - V1 error format.
32159 /// * *access_token* (query-string) - OAuth access token.
32160 /// * *alt* (query-string) - Data format for response.
32161 /// * *callback* (query-string) - JSONP
32162 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
32163 /// * *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.
32164 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
32165 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
32166 /// * *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.
32167 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
32168 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
32169 pub fn param<T>(
32170 mut self,
32171 name: T,
32172 value: T,
32173 ) -> ProjectLocationWasmPluginVersionCreateCall<'a, C>
32174 where
32175 T: AsRef<str>,
32176 {
32177 self._additional_params
32178 .insert(name.as_ref().to_string(), value.as_ref().to_string());
32179 self
32180 }
32181
32182 /// Identifies the authorization scope for the method you are building.
32183 ///
32184 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
32185 /// [`Scope::CloudPlatform`].
32186 ///
32187 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
32188 /// tokens for more than one scope.
32189 ///
32190 /// Usually there is more than one suitable scope to authorize an operation, some of which may
32191 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
32192 /// sufficient, a read-write scope will do as well.
32193 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationWasmPluginVersionCreateCall<'a, C>
32194 where
32195 St: AsRef<str>,
32196 {
32197 self._scopes.insert(String::from(scope.as_ref()));
32198 self
32199 }
32200 /// Identifies the authorization scope(s) for the method you are building.
32201 ///
32202 /// See [`Self::add_scope()`] for details.
32203 pub fn add_scopes<I, St>(
32204 mut self,
32205 scopes: I,
32206 ) -> ProjectLocationWasmPluginVersionCreateCall<'a, C>
32207 where
32208 I: IntoIterator<Item = St>,
32209 St: AsRef<str>,
32210 {
32211 self._scopes
32212 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
32213 self
32214 }
32215
32216 /// Removes all scopes, and no default scope will be used either.
32217 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
32218 /// for details).
32219 pub fn clear_scopes(mut self) -> ProjectLocationWasmPluginVersionCreateCall<'a, C> {
32220 self._scopes.clear();
32221 self
32222 }
32223}
32224
32225/// Deletes the specified `WasmPluginVersion` resource.
32226///
32227/// A builder for the *locations.wasmPlugins.versions.delete* method supported by a *project* resource.
32228/// It is not used directly, but through a [`ProjectMethods`] instance.
32229///
32230/// # Example
32231///
32232/// Instantiate a resource method builder
32233///
32234/// ```test_harness,no_run
32235/// # extern crate hyper;
32236/// # extern crate hyper_rustls;
32237/// # extern crate google_networkservices1 as networkservices1;
32238/// # async fn dox() {
32239/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
32240///
32241/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
32242/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
32243/// # .with_native_roots()
32244/// # .unwrap()
32245/// # .https_only()
32246/// # .enable_http2()
32247/// # .build();
32248///
32249/// # let executor = hyper_util::rt::TokioExecutor::new();
32250/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
32251/// # secret,
32252/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
32253/// # yup_oauth2::client::CustomHyperClientBuilder::from(
32254/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
32255/// # ),
32256/// # ).build().await.unwrap();
32257///
32258/// # let client = hyper_util::client::legacy::Client::builder(
32259/// # hyper_util::rt::TokioExecutor::new()
32260/// # )
32261/// # .build(
32262/// # hyper_rustls::HttpsConnectorBuilder::new()
32263/// # .with_native_roots()
32264/// # .unwrap()
32265/// # .https_or_http()
32266/// # .enable_http2()
32267/// # .build()
32268/// # );
32269/// # let mut hub = NetworkServices::new(client, auth);
32270/// // You can configure optional parameters by calling the respective setters at will, and
32271/// // execute the final call using `doit()`.
32272/// // Values shown here are possibly random and not representative !
32273/// let result = hub.projects().locations_wasm_plugins_versions_delete("name")
32274/// .doit().await;
32275/// # }
32276/// ```
32277pub struct ProjectLocationWasmPluginVersionDeleteCall<'a, C>
32278where
32279 C: 'a,
32280{
32281 hub: &'a NetworkServices<C>,
32282 _name: String,
32283 _delegate: Option<&'a mut dyn common::Delegate>,
32284 _additional_params: HashMap<String, String>,
32285 _scopes: BTreeSet<String>,
32286}
32287
32288impl<'a, C> common::CallBuilder for ProjectLocationWasmPluginVersionDeleteCall<'a, C> {}
32289
32290impl<'a, C> ProjectLocationWasmPluginVersionDeleteCall<'a, C>
32291where
32292 C: common::Connector,
32293{
32294 /// Perform the operation you have build so far.
32295 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
32296 use std::borrow::Cow;
32297 use std::io::{Read, Seek};
32298
32299 use common::{url::Params, ToParts};
32300 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
32301
32302 let mut dd = common::DefaultDelegate;
32303 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
32304 dlg.begin(common::MethodInfo {
32305 id: "networkservices.projects.locations.wasmPlugins.versions.delete",
32306 http_method: hyper::Method::DELETE,
32307 });
32308
32309 for &field in ["alt", "name"].iter() {
32310 if self._additional_params.contains_key(field) {
32311 dlg.finished(false);
32312 return Err(common::Error::FieldClash(field));
32313 }
32314 }
32315
32316 let mut params = Params::with_capacity(3 + self._additional_params.len());
32317 params.push("name", self._name);
32318
32319 params.extend(self._additional_params.iter());
32320
32321 params.push("alt", "json");
32322 let mut url = self.hub._base_url.clone() + "v1/{+name}";
32323 if self._scopes.is_empty() {
32324 self._scopes
32325 .insert(Scope::CloudPlatform.as_ref().to_string());
32326 }
32327
32328 #[allow(clippy::single_element_loop)]
32329 for &(find_this, param_name) in [("{+name}", "name")].iter() {
32330 url = params.uri_replacement(url, param_name, find_this, true);
32331 }
32332 {
32333 let to_remove = ["name"];
32334 params.remove_params(&to_remove);
32335 }
32336
32337 let url = params.parse_with_url(&url);
32338
32339 loop {
32340 let token = match self
32341 .hub
32342 .auth
32343 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
32344 .await
32345 {
32346 Ok(token) => token,
32347 Err(e) => match dlg.token(e) {
32348 Ok(token) => token,
32349 Err(e) => {
32350 dlg.finished(false);
32351 return Err(common::Error::MissingToken(e));
32352 }
32353 },
32354 };
32355 let mut req_result = {
32356 let client = &self.hub.client;
32357 dlg.pre_request();
32358 let mut req_builder = hyper::Request::builder()
32359 .method(hyper::Method::DELETE)
32360 .uri(url.as_str())
32361 .header(USER_AGENT, self.hub._user_agent.clone());
32362
32363 if let Some(token) = token.as_ref() {
32364 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
32365 }
32366
32367 let request = req_builder
32368 .header(CONTENT_LENGTH, 0_u64)
32369 .body(common::to_body::<String>(None));
32370
32371 client.request(request.unwrap()).await
32372 };
32373
32374 match req_result {
32375 Err(err) => {
32376 if let common::Retry::After(d) = dlg.http_error(&err) {
32377 sleep(d).await;
32378 continue;
32379 }
32380 dlg.finished(false);
32381 return Err(common::Error::HttpError(err));
32382 }
32383 Ok(res) => {
32384 let (mut parts, body) = res.into_parts();
32385 let mut body = common::Body::new(body);
32386 if !parts.status.is_success() {
32387 let bytes = common::to_bytes(body).await.unwrap_or_default();
32388 let error = serde_json::from_str(&common::to_string(&bytes));
32389 let response = common::to_response(parts, bytes.into());
32390
32391 if let common::Retry::After(d) =
32392 dlg.http_failure(&response, error.as_ref().ok())
32393 {
32394 sleep(d).await;
32395 continue;
32396 }
32397
32398 dlg.finished(false);
32399
32400 return Err(match error {
32401 Ok(value) => common::Error::BadRequest(value),
32402 _ => common::Error::Failure(response),
32403 });
32404 }
32405 let response = {
32406 let bytes = common::to_bytes(body).await.unwrap_or_default();
32407 let encoded = common::to_string(&bytes);
32408 match serde_json::from_str(&encoded) {
32409 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
32410 Err(error) => {
32411 dlg.response_json_decode_error(&encoded, &error);
32412 return Err(common::Error::JsonDecodeError(
32413 encoded.to_string(),
32414 error,
32415 ));
32416 }
32417 }
32418 };
32419
32420 dlg.finished(true);
32421 return Ok(response);
32422 }
32423 }
32424 }
32425 }
32426
32427 /// Required. A name of the `WasmPluginVersion` resource to delete. Must be in the format `projects/{project}/locations/global/wasmPlugins/{wasm_plugin}/versions/{wasm_plugin_version}`.
32428 ///
32429 /// Sets the *name* path property to the given value.
32430 ///
32431 /// Even though the property as already been set when instantiating this call,
32432 /// we provide this method for API completeness.
32433 pub fn name(mut self, new_value: &str) -> ProjectLocationWasmPluginVersionDeleteCall<'a, C> {
32434 self._name = new_value.to_string();
32435 self
32436 }
32437 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
32438 /// while executing the actual API request.
32439 ///
32440 /// ````text
32441 /// It should be used to handle progress information, and to implement a certain level of resilience.
32442 /// ````
32443 ///
32444 /// Sets the *delegate* property to the given value.
32445 pub fn delegate(
32446 mut self,
32447 new_value: &'a mut dyn common::Delegate,
32448 ) -> ProjectLocationWasmPluginVersionDeleteCall<'a, C> {
32449 self._delegate = Some(new_value);
32450 self
32451 }
32452
32453 /// Set any additional parameter of the query string used in the request.
32454 /// It should be used to set parameters which are not yet available through their own
32455 /// setters.
32456 ///
32457 /// Please note that this method must not be used to set any of the known parameters
32458 /// which have their own setter method. If done anyway, the request will fail.
32459 ///
32460 /// # Additional Parameters
32461 ///
32462 /// * *$.xgafv* (query-string) - V1 error format.
32463 /// * *access_token* (query-string) - OAuth access token.
32464 /// * *alt* (query-string) - Data format for response.
32465 /// * *callback* (query-string) - JSONP
32466 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
32467 /// * *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.
32468 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
32469 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
32470 /// * *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.
32471 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
32472 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
32473 pub fn param<T>(
32474 mut self,
32475 name: T,
32476 value: T,
32477 ) -> ProjectLocationWasmPluginVersionDeleteCall<'a, C>
32478 where
32479 T: AsRef<str>,
32480 {
32481 self._additional_params
32482 .insert(name.as_ref().to_string(), value.as_ref().to_string());
32483 self
32484 }
32485
32486 /// Identifies the authorization scope for the method you are building.
32487 ///
32488 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
32489 /// [`Scope::CloudPlatform`].
32490 ///
32491 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
32492 /// tokens for more than one scope.
32493 ///
32494 /// Usually there is more than one suitable scope to authorize an operation, some of which may
32495 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
32496 /// sufficient, a read-write scope will do as well.
32497 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationWasmPluginVersionDeleteCall<'a, C>
32498 where
32499 St: AsRef<str>,
32500 {
32501 self._scopes.insert(String::from(scope.as_ref()));
32502 self
32503 }
32504 /// Identifies the authorization scope(s) for the method you are building.
32505 ///
32506 /// See [`Self::add_scope()`] for details.
32507 pub fn add_scopes<I, St>(
32508 mut self,
32509 scopes: I,
32510 ) -> ProjectLocationWasmPluginVersionDeleteCall<'a, C>
32511 where
32512 I: IntoIterator<Item = St>,
32513 St: AsRef<str>,
32514 {
32515 self._scopes
32516 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
32517 self
32518 }
32519
32520 /// Removes all scopes, and no default scope will be used either.
32521 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
32522 /// for details).
32523 pub fn clear_scopes(mut self) -> ProjectLocationWasmPluginVersionDeleteCall<'a, C> {
32524 self._scopes.clear();
32525 self
32526 }
32527}
32528
32529/// Gets details of the specified `WasmPluginVersion` resource.
32530///
32531/// A builder for the *locations.wasmPlugins.versions.get* method supported by a *project* resource.
32532/// It is not used directly, but through a [`ProjectMethods`] instance.
32533///
32534/// # Example
32535///
32536/// Instantiate a resource method builder
32537///
32538/// ```test_harness,no_run
32539/// # extern crate hyper;
32540/// # extern crate hyper_rustls;
32541/// # extern crate google_networkservices1 as networkservices1;
32542/// # async fn dox() {
32543/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
32544///
32545/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
32546/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
32547/// # .with_native_roots()
32548/// # .unwrap()
32549/// # .https_only()
32550/// # .enable_http2()
32551/// # .build();
32552///
32553/// # let executor = hyper_util::rt::TokioExecutor::new();
32554/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
32555/// # secret,
32556/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
32557/// # yup_oauth2::client::CustomHyperClientBuilder::from(
32558/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
32559/// # ),
32560/// # ).build().await.unwrap();
32561///
32562/// # let client = hyper_util::client::legacy::Client::builder(
32563/// # hyper_util::rt::TokioExecutor::new()
32564/// # )
32565/// # .build(
32566/// # hyper_rustls::HttpsConnectorBuilder::new()
32567/// # .with_native_roots()
32568/// # .unwrap()
32569/// # .https_or_http()
32570/// # .enable_http2()
32571/// # .build()
32572/// # );
32573/// # let mut hub = NetworkServices::new(client, auth);
32574/// // You can configure optional parameters by calling the respective setters at will, and
32575/// // execute the final call using `doit()`.
32576/// // Values shown here are possibly random and not representative !
32577/// let result = hub.projects().locations_wasm_plugins_versions_get("name")
32578/// .doit().await;
32579/// # }
32580/// ```
32581pub struct ProjectLocationWasmPluginVersionGetCall<'a, C>
32582where
32583 C: 'a,
32584{
32585 hub: &'a NetworkServices<C>,
32586 _name: String,
32587 _delegate: Option<&'a mut dyn common::Delegate>,
32588 _additional_params: HashMap<String, String>,
32589 _scopes: BTreeSet<String>,
32590}
32591
32592impl<'a, C> common::CallBuilder for ProjectLocationWasmPluginVersionGetCall<'a, C> {}
32593
32594impl<'a, C> ProjectLocationWasmPluginVersionGetCall<'a, C>
32595where
32596 C: common::Connector,
32597{
32598 /// Perform the operation you have build so far.
32599 pub async fn doit(mut self) -> common::Result<(common::Response, WasmPluginVersion)> {
32600 use std::borrow::Cow;
32601 use std::io::{Read, Seek};
32602
32603 use common::{url::Params, ToParts};
32604 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
32605
32606 let mut dd = common::DefaultDelegate;
32607 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
32608 dlg.begin(common::MethodInfo {
32609 id: "networkservices.projects.locations.wasmPlugins.versions.get",
32610 http_method: hyper::Method::GET,
32611 });
32612
32613 for &field in ["alt", "name"].iter() {
32614 if self._additional_params.contains_key(field) {
32615 dlg.finished(false);
32616 return Err(common::Error::FieldClash(field));
32617 }
32618 }
32619
32620 let mut params = Params::with_capacity(3 + self._additional_params.len());
32621 params.push("name", self._name);
32622
32623 params.extend(self._additional_params.iter());
32624
32625 params.push("alt", "json");
32626 let mut url = self.hub._base_url.clone() + "v1/{+name}";
32627 if self._scopes.is_empty() {
32628 self._scopes
32629 .insert(Scope::CloudPlatform.as_ref().to_string());
32630 }
32631
32632 #[allow(clippy::single_element_loop)]
32633 for &(find_this, param_name) in [("{+name}", "name")].iter() {
32634 url = params.uri_replacement(url, param_name, find_this, true);
32635 }
32636 {
32637 let to_remove = ["name"];
32638 params.remove_params(&to_remove);
32639 }
32640
32641 let url = params.parse_with_url(&url);
32642
32643 loop {
32644 let token = match self
32645 .hub
32646 .auth
32647 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
32648 .await
32649 {
32650 Ok(token) => token,
32651 Err(e) => match dlg.token(e) {
32652 Ok(token) => token,
32653 Err(e) => {
32654 dlg.finished(false);
32655 return Err(common::Error::MissingToken(e));
32656 }
32657 },
32658 };
32659 let mut req_result = {
32660 let client = &self.hub.client;
32661 dlg.pre_request();
32662 let mut req_builder = hyper::Request::builder()
32663 .method(hyper::Method::GET)
32664 .uri(url.as_str())
32665 .header(USER_AGENT, self.hub._user_agent.clone());
32666
32667 if let Some(token) = token.as_ref() {
32668 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
32669 }
32670
32671 let request = req_builder
32672 .header(CONTENT_LENGTH, 0_u64)
32673 .body(common::to_body::<String>(None));
32674
32675 client.request(request.unwrap()).await
32676 };
32677
32678 match req_result {
32679 Err(err) => {
32680 if let common::Retry::After(d) = dlg.http_error(&err) {
32681 sleep(d).await;
32682 continue;
32683 }
32684 dlg.finished(false);
32685 return Err(common::Error::HttpError(err));
32686 }
32687 Ok(res) => {
32688 let (mut parts, body) = res.into_parts();
32689 let mut body = common::Body::new(body);
32690 if !parts.status.is_success() {
32691 let bytes = common::to_bytes(body).await.unwrap_or_default();
32692 let error = serde_json::from_str(&common::to_string(&bytes));
32693 let response = common::to_response(parts, bytes.into());
32694
32695 if let common::Retry::After(d) =
32696 dlg.http_failure(&response, error.as_ref().ok())
32697 {
32698 sleep(d).await;
32699 continue;
32700 }
32701
32702 dlg.finished(false);
32703
32704 return Err(match error {
32705 Ok(value) => common::Error::BadRequest(value),
32706 _ => common::Error::Failure(response),
32707 });
32708 }
32709 let response = {
32710 let bytes = common::to_bytes(body).await.unwrap_or_default();
32711 let encoded = common::to_string(&bytes);
32712 match serde_json::from_str(&encoded) {
32713 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
32714 Err(error) => {
32715 dlg.response_json_decode_error(&encoded, &error);
32716 return Err(common::Error::JsonDecodeError(
32717 encoded.to_string(),
32718 error,
32719 ));
32720 }
32721 }
32722 };
32723
32724 dlg.finished(true);
32725 return Ok(response);
32726 }
32727 }
32728 }
32729 }
32730
32731 /// Required. A name of the `WasmPluginVersion` resource to get. Must be in the format `projects/{project}/locations/global/wasmPlugins/{wasm_plugin}/versions/{wasm_plugin_version}`.
32732 ///
32733 /// Sets the *name* path property to the given value.
32734 ///
32735 /// Even though the property as already been set when instantiating this call,
32736 /// we provide this method for API completeness.
32737 pub fn name(mut self, new_value: &str) -> ProjectLocationWasmPluginVersionGetCall<'a, C> {
32738 self._name = new_value.to_string();
32739 self
32740 }
32741 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
32742 /// while executing the actual API request.
32743 ///
32744 /// ````text
32745 /// It should be used to handle progress information, and to implement a certain level of resilience.
32746 /// ````
32747 ///
32748 /// Sets the *delegate* property to the given value.
32749 pub fn delegate(
32750 mut self,
32751 new_value: &'a mut dyn common::Delegate,
32752 ) -> ProjectLocationWasmPluginVersionGetCall<'a, C> {
32753 self._delegate = Some(new_value);
32754 self
32755 }
32756
32757 /// Set any additional parameter of the query string used in the request.
32758 /// It should be used to set parameters which are not yet available through their own
32759 /// setters.
32760 ///
32761 /// Please note that this method must not be used to set any of the known parameters
32762 /// which have their own setter method. If done anyway, the request will fail.
32763 ///
32764 /// # Additional Parameters
32765 ///
32766 /// * *$.xgafv* (query-string) - V1 error format.
32767 /// * *access_token* (query-string) - OAuth access token.
32768 /// * *alt* (query-string) - Data format for response.
32769 /// * *callback* (query-string) - JSONP
32770 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
32771 /// * *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.
32772 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
32773 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
32774 /// * *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.
32775 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
32776 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
32777 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationWasmPluginVersionGetCall<'a, C>
32778 where
32779 T: AsRef<str>,
32780 {
32781 self._additional_params
32782 .insert(name.as_ref().to_string(), value.as_ref().to_string());
32783 self
32784 }
32785
32786 /// Identifies the authorization scope for the method you are building.
32787 ///
32788 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
32789 /// [`Scope::CloudPlatform`].
32790 ///
32791 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
32792 /// tokens for more than one scope.
32793 ///
32794 /// Usually there is more than one suitable scope to authorize an operation, some of which may
32795 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
32796 /// sufficient, a read-write scope will do as well.
32797 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationWasmPluginVersionGetCall<'a, C>
32798 where
32799 St: AsRef<str>,
32800 {
32801 self._scopes.insert(String::from(scope.as_ref()));
32802 self
32803 }
32804 /// Identifies the authorization scope(s) for the method you are building.
32805 ///
32806 /// See [`Self::add_scope()`] for details.
32807 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationWasmPluginVersionGetCall<'a, C>
32808 where
32809 I: IntoIterator<Item = St>,
32810 St: AsRef<str>,
32811 {
32812 self._scopes
32813 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
32814 self
32815 }
32816
32817 /// Removes all scopes, and no default scope will be used either.
32818 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
32819 /// for details).
32820 pub fn clear_scopes(mut self) -> ProjectLocationWasmPluginVersionGetCall<'a, C> {
32821 self._scopes.clear();
32822 self
32823 }
32824}
32825
32826/// Lists `WasmPluginVersion` resources in a given project and location.
32827///
32828/// A builder for the *locations.wasmPlugins.versions.list* method supported by a *project* resource.
32829/// It is not used directly, but through a [`ProjectMethods`] instance.
32830///
32831/// # Example
32832///
32833/// Instantiate a resource method builder
32834///
32835/// ```test_harness,no_run
32836/// # extern crate hyper;
32837/// # extern crate hyper_rustls;
32838/// # extern crate google_networkservices1 as networkservices1;
32839/// # async fn dox() {
32840/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
32841///
32842/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
32843/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
32844/// # .with_native_roots()
32845/// # .unwrap()
32846/// # .https_only()
32847/// # .enable_http2()
32848/// # .build();
32849///
32850/// # let executor = hyper_util::rt::TokioExecutor::new();
32851/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
32852/// # secret,
32853/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
32854/// # yup_oauth2::client::CustomHyperClientBuilder::from(
32855/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
32856/// # ),
32857/// # ).build().await.unwrap();
32858///
32859/// # let client = hyper_util::client::legacy::Client::builder(
32860/// # hyper_util::rt::TokioExecutor::new()
32861/// # )
32862/// # .build(
32863/// # hyper_rustls::HttpsConnectorBuilder::new()
32864/// # .with_native_roots()
32865/// # .unwrap()
32866/// # .https_or_http()
32867/// # .enable_http2()
32868/// # .build()
32869/// # );
32870/// # let mut hub = NetworkServices::new(client, auth);
32871/// // You can configure optional parameters by calling the respective setters at will, and
32872/// // execute the final call using `doit()`.
32873/// // Values shown here are possibly random and not representative !
32874/// let result = hub.projects().locations_wasm_plugins_versions_list("parent")
32875/// .page_token("erat")
32876/// .page_size(-10)
32877/// .doit().await;
32878/// # }
32879/// ```
32880pub struct ProjectLocationWasmPluginVersionListCall<'a, C>
32881where
32882 C: 'a,
32883{
32884 hub: &'a NetworkServices<C>,
32885 _parent: String,
32886 _page_token: Option<String>,
32887 _page_size: Option<i32>,
32888 _delegate: Option<&'a mut dyn common::Delegate>,
32889 _additional_params: HashMap<String, String>,
32890 _scopes: BTreeSet<String>,
32891}
32892
32893impl<'a, C> common::CallBuilder for ProjectLocationWasmPluginVersionListCall<'a, C> {}
32894
32895impl<'a, C> ProjectLocationWasmPluginVersionListCall<'a, C>
32896where
32897 C: common::Connector,
32898{
32899 /// Perform the operation you have build so far.
32900 pub async fn doit(
32901 mut self,
32902 ) -> common::Result<(common::Response, ListWasmPluginVersionsResponse)> {
32903 use std::borrow::Cow;
32904 use std::io::{Read, Seek};
32905
32906 use common::{url::Params, ToParts};
32907 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
32908
32909 let mut dd = common::DefaultDelegate;
32910 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
32911 dlg.begin(common::MethodInfo {
32912 id: "networkservices.projects.locations.wasmPlugins.versions.list",
32913 http_method: hyper::Method::GET,
32914 });
32915
32916 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
32917 if self._additional_params.contains_key(field) {
32918 dlg.finished(false);
32919 return Err(common::Error::FieldClash(field));
32920 }
32921 }
32922
32923 let mut params = Params::with_capacity(5 + self._additional_params.len());
32924 params.push("parent", self._parent);
32925 if let Some(value) = self._page_token.as_ref() {
32926 params.push("pageToken", value);
32927 }
32928 if let Some(value) = self._page_size.as_ref() {
32929 params.push("pageSize", value.to_string());
32930 }
32931
32932 params.extend(self._additional_params.iter());
32933
32934 params.push("alt", "json");
32935 let mut url = self.hub._base_url.clone() + "v1/{+parent}/versions";
32936 if self._scopes.is_empty() {
32937 self._scopes
32938 .insert(Scope::CloudPlatform.as_ref().to_string());
32939 }
32940
32941 #[allow(clippy::single_element_loop)]
32942 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
32943 url = params.uri_replacement(url, param_name, find_this, true);
32944 }
32945 {
32946 let to_remove = ["parent"];
32947 params.remove_params(&to_remove);
32948 }
32949
32950 let url = params.parse_with_url(&url);
32951
32952 loop {
32953 let token = match self
32954 .hub
32955 .auth
32956 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
32957 .await
32958 {
32959 Ok(token) => token,
32960 Err(e) => match dlg.token(e) {
32961 Ok(token) => token,
32962 Err(e) => {
32963 dlg.finished(false);
32964 return Err(common::Error::MissingToken(e));
32965 }
32966 },
32967 };
32968 let mut req_result = {
32969 let client = &self.hub.client;
32970 dlg.pre_request();
32971 let mut req_builder = hyper::Request::builder()
32972 .method(hyper::Method::GET)
32973 .uri(url.as_str())
32974 .header(USER_AGENT, self.hub._user_agent.clone());
32975
32976 if let Some(token) = token.as_ref() {
32977 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
32978 }
32979
32980 let request = req_builder
32981 .header(CONTENT_LENGTH, 0_u64)
32982 .body(common::to_body::<String>(None));
32983
32984 client.request(request.unwrap()).await
32985 };
32986
32987 match req_result {
32988 Err(err) => {
32989 if let common::Retry::After(d) = dlg.http_error(&err) {
32990 sleep(d).await;
32991 continue;
32992 }
32993 dlg.finished(false);
32994 return Err(common::Error::HttpError(err));
32995 }
32996 Ok(res) => {
32997 let (mut parts, body) = res.into_parts();
32998 let mut body = common::Body::new(body);
32999 if !parts.status.is_success() {
33000 let bytes = common::to_bytes(body).await.unwrap_or_default();
33001 let error = serde_json::from_str(&common::to_string(&bytes));
33002 let response = common::to_response(parts, bytes.into());
33003
33004 if let common::Retry::After(d) =
33005 dlg.http_failure(&response, error.as_ref().ok())
33006 {
33007 sleep(d).await;
33008 continue;
33009 }
33010
33011 dlg.finished(false);
33012
33013 return Err(match error {
33014 Ok(value) => common::Error::BadRequest(value),
33015 _ => common::Error::Failure(response),
33016 });
33017 }
33018 let response = {
33019 let bytes = common::to_bytes(body).await.unwrap_or_default();
33020 let encoded = common::to_string(&bytes);
33021 match serde_json::from_str(&encoded) {
33022 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
33023 Err(error) => {
33024 dlg.response_json_decode_error(&encoded, &error);
33025 return Err(common::Error::JsonDecodeError(
33026 encoded.to_string(),
33027 error,
33028 ));
33029 }
33030 }
33031 };
33032
33033 dlg.finished(true);
33034 return Ok(response);
33035 }
33036 }
33037 }
33038 }
33039
33040 /// Required. The `WasmPlugin` resource whose `WasmPluginVersion`s are listed, specified in the following format: `projects/{project}/locations/global/wasmPlugins/{wasm_plugin}`.
33041 ///
33042 /// Sets the *parent* path property to the given value.
33043 ///
33044 /// Even though the property as already been set when instantiating this call,
33045 /// we provide this method for API completeness.
33046 pub fn parent(mut self, new_value: &str) -> ProjectLocationWasmPluginVersionListCall<'a, C> {
33047 self._parent = new_value.to_string();
33048 self
33049 }
33050 /// The value returned by the last `ListWasmPluginVersionsResponse` call. Indicates that this is a continuation of a prior `ListWasmPluginVersions` call, and that the next page of data is to be returned.
33051 ///
33052 /// Sets the *page token* query property to the given value.
33053 pub fn page_token(
33054 mut self,
33055 new_value: &str,
33056 ) -> ProjectLocationWasmPluginVersionListCall<'a, C> {
33057 self._page_token = Some(new_value.to_string());
33058 self
33059 }
33060 /// Maximum number of `WasmPluginVersion` resources to return per call. If not specified, at most 50 `WasmPluginVersion` resources are returned. The maximum value is 1000; values above 1000 are coerced to 1000.
33061 ///
33062 /// Sets the *page size* query property to the given value.
33063 pub fn page_size(mut self, new_value: i32) -> ProjectLocationWasmPluginVersionListCall<'a, C> {
33064 self._page_size = Some(new_value);
33065 self
33066 }
33067 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
33068 /// while executing the actual API request.
33069 ///
33070 /// ````text
33071 /// It should be used to handle progress information, and to implement a certain level of resilience.
33072 /// ````
33073 ///
33074 /// Sets the *delegate* property to the given value.
33075 pub fn delegate(
33076 mut self,
33077 new_value: &'a mut dyn common::Delegate,
33078 ) -> ProjectLocationWasmPluginVersionListCall<'a, C> {
33079 self._delegate = Some(new_value);
33080 self
33081 }
33082
33083 /// Set any additional parameter of the query string used in the request.
33084 /// It should be used to set parameters which are not yet available through their own
33085 /// setters.
33086 ///
33087 /// Please note that this method must not be used to set any of the known parameters
33088 /// which have their own setter method. If done anyway, the request will fail.
33089 ///
33090 /// # Additional Parameters
33091 ///
33092 /// * *$.xgafv* (query-string) - V1 error format.
33093 /// * *access_token* (query-string) - OAuth access token.
33094 /// * *alt* (query-string) - Data format for response.
33095 /// * *callback* (query-string) - JSONP
33096 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
33097 /// * *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.
33098 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
33099 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
33100 /// * *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.
33101 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
33102 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
33103 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationWasmPluginVersionListCall<'a, C>
33104 where
33105 T: AsRef<str>,
33106 {
33107 self._additional_params
33108 .insert(name.as_ref().to_string(), value.as_ref().to_string());
33109 self
33110 }
33111
33112 /// Identifies the authorization scope for the method you are building.
33113 ///
33114 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
33115 /// [`Scope::CloudPlatform`].
33116 ///
33117 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
33118 /// tokens for more than one scope.
33119 ///
33120 /// Usually there is more than one suitable scope to authorize an operation, some of which may
33121 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
33122 /// sufficient, a read-write scope will do as well.
33123 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationWasmPluginVersionListCall<'a, C>
33124 where
33125 St: AsRef<str>,
33126 {
33127 self._scopes.insert(String::from(scope.as_ref()));
33128 self
33129 }
33130 /// Identifies the authorization scope(s) for the method you are building.
33131 ///
33132 /// See [`Self::add_scope()`] for details.
33133 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationWasmPluginVersionListCall<'a, C>
33134 where
33135 I: IntoIterator<Item = St>,
33136 St: AsRef<str>,
33137 {
33138 self._scopes
33139 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
33140 self
33141 }
33142
33143 /// Removes all scopes, and no default scope will be used either.
33144 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
33145 /// for details).
33146 pub fn clear_scopes(mut self) -> ProjectLocationWasmPluginVersionListCall<'a, C> {
33147 self._scopes.clear();
33148 self
33149 }
33150}
33151
33152/// Creates a new `WasmPlugin` resource in a given project and location.
33153///
33154/// A builder for the *locations.wasmPlugins.create* method supported by a *project* resource.
33155/// It is not used directly, but through a [`ProjectMethods`] instance.
33156///
33157/// # Example
33158///
33159/// Instantiate a resource method builder
33160///
33161/// ```test_harness,no_run
33162/// # extern crate hyper;
33163/// # extern crate hyper_rustls;
33164/// # extern crate google_networkservices1 as networkservices1;
33165/// use networkservices1::api::WasmPlugin;
33166/// # async fn dox() {
33167/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
33168///
33169/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
33170/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
33171/// # .with_native_roots()
33172/// # .unwrap()
33173/// # .https_only()
33174/// # .enable_http2()
33175/// # .build();
33176///
33177/// # let executor = hyper_util::rt::TokioExecutor::new();
33178/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
33179/// # secret,
33180/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
33181/// # yup_oauth2::client::CustomHyperClientBuilder::from(
33182/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
33183/// # ),
33184/// # ).build().await.unwrap();
33185///
33186/// # let client = hyper_util::client::legacy::Client::builder(
33187/// # hyper_util::rt::TokioExecutor::new()
33188/// # )
33189/// # .build(
33190/// # hyper_rustls::HttpsConnectorBuilder::new()
33191/// # .with_native_roots()
33192/// # .unwrap()
33193/// # .https_or_http()
33194/// # .enable_http2()
33195/// # .build()
33196/// # );
33197/// # let mut hub = NetworkServices::new(client, auth);
33198/// // As the method needs a request, you would usually fill it with the desired information
33199/// // into the respective structure. Some of the parts shown here might not be applicable !
33200/// // Values shown here are possibly random and not representative !
33201/// let mut req = WasmPlugin::default();
33202///
33203/// // You can configure optional parameters by calling the respective setters at will, and
33204/// // execute the final call using `doit()`.
33205/// // Values shown here are possibly random and not representative !
33206/// let result = hub.projects().locations_wasm_plugins_create(req, "parent")
33207/// .wasm_plugin_id("et")
33208/// .doit().await;
33209/// # }
33210/// ```
33211pub struct ProjectLocationWasmPluginCreateCall<'a, C>
33212where
33213 C: 'a,
33214{
33215 hub: &'a NetworkServices<C>,
33216 _request: WasmPlugin,
33217 _parent: String,
33218 _wasm_plugin_id: Option<String>,
33219 _delegate: Option<&'a mut dyn common::Delegate>,
33220 _additional_params: HashMap<String, String>,
33221 _scopes: BTreeSet<String>,
33222}
33223
33224impl<'a, C> common::CallBuilder for ProjectLocationWasmPluginCreateCall<'a, C> {}
33225
33226impl<'a, C> ProjectLocationWasmPluginCreateCall<'a, C>
33227where
33228 C: common::Connector,
33229{
33230 /// Perform the operation you have build so far.
33231 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
33232 use std::borrow::Cow;
33233 use std::io::{Read, Seek};
33234
33235 use common::{url::Params, ToParts};
33236 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
33237
33238 let mut dd = common::DefaultDelegate;
33239 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
33240 dlg.begin(common::MethodInfo {
33241 id: "networkservices.projects.locations.wasmPlugins.create",
33242 http_method: hyper::Method::POST,
33243 });
33244
33245 for &field in ["alt", "parent", "wasmPluginId"].iter() {
33246 if self._additional_params.contains_key(field) {
33247 dlg.finished(false);
33248 return Err(common::Error::FieldClash(field));
33249 }
33250 }
33251
33252 let mut params = Params::with_capacity(5 + self._additional_params.len());
33253 params.push("parent", self._parent);
33254 if let Some(value) = self._wasm_plugin_id.as_ref() {
33255 params.push("wasmPluginId", value);
33256 }
33257
33258 params.extend(self._additional_params.iter());
33259
33260 params.push("alt", "json");
33261 let mut url = self.hub._base_url.clone() + "v1/{+parent}/wasmPlugins";
33262 if self._scopes.is_empty() {
33263 self._scopes
33264 .insert(Scope::CloudPlatform.as_ref().to_string());
33265 }
33266
33267 #[allow(clippy::single_element_loop)]
33268 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
33269 url = params.uri_replacement(url, param_name, find_this, true);
33270 }
33271 {
33272 let to_remove = ["parent"];
33273 params.remove_params(&to_remove);
33274 }
33275
33276 let url = params.parse_with_url(&url);
33277
33278 let mut json_mime_type = mime::APPLICATION_JSON;
33279 let mut request_value_reader = {
33280 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
33281 common::remove_json_null_values(&mut value);
33282 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
33283 serde_json::to_writer(&mut dst, &value).unwrap();
33284 dst
33285 };
33286 let request_size = request_value_reader
33287 .seek(std::io::SeekFrom::End(0))
33288 .unwrap();
33289 request_value_reader
33290 .seek(std::io::SeekFrom::Start(0))
33291 .unwrap();
33292
33293 loop {
33294 let token = match self
33295 .hub
33296 .auth
33297 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
33298 .await
33299 {
33300 Ok(token) => token,
33301 Err(e) => match dlg.token(e) {
33302 Ok(token) => token,
33303 Err(e) => {
33304 dlg.finished(false);
33305 return Err(common::Error::MissingToken(e));
33306 }
33307 },
33308 };
33309 request_value_reader
33310 .seek(std::io::SeekFrom::Start(0))
33311 .unwrap();
33312 let mut req_result = {
33313 let client = &self.hub.client;
33314 dlg.pre_request();
33315 let mut req_builder = hyper::Request::builder()
33316 .method(hyper::Method::POST)
33317 .uri(url.as_str())
33318 .header(USER_AGENT, self.hub._user_agent.clone());
33319
33320 if let Some(token) = token.as_ref() {
33321 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
33322 }
33323
33324 let request = req_builder
33325 .header(CONTENT_TYPE, json_mime_type.to_string())
33326 .header(CONTENT_LENGTH, request_size as u64)
33327 .body(common::to_body(
33328 request_value_reader.get_ref().clone().into(),
33329 ));
33330
33331 client.request(request.unwrap()).await
33332 };
33333
33334 match req_result {
33335 Err(err) => {
33336 if let common::Retry::After(d) = dlg.http_error(&err) {
33337 sleep(d).await;
33338 continue;
33339 }
33340 dlg.finished(false);
33341 return Err(common::Error::HttpError(err));
33342 }
33343 Ok(res) => {
33344 let (mut parts, body) = res.into_parts();
33345 let mut body = common::Body::new(body);
33346 if !parts.status.is_success() {
33347 let bytes = common::to_bytes(body).await.unwrap_or_default();
33348 let error = serde_json::from_str(&common::to_string(&bytes));
33349 let response = common::to_response(parts, bytes.into());
33350
33351 if let common::Retry::After(d) =
33352 dlg.http_failure(&response, error.as_ref().ok())
33353 {
33354 sleep(d).await;
33355 continue;
33356 }
33357
33358 dlg.finished(false);
33359
33360 return Err(match error {
33361 Ok(value) => common::Error::BadRequest(value),
33362 _ => common::Error::Failure(response),
33363 });
33364 }
33365 let response = {
33366 let bytes = common::to_bytes(body).await.unwrap_or_default();
33367 let encoded = common::to_string(&bytes);
33368 match serde_json::from_str(&encoded) {
33369 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
33370 Err(error) => {
33371 dlg.response_json_decode_error(&encoded, &error);
33372 return Err(common::Error::JsonDecodeError(
33373 encoded.to_string(),
33374 error,
33375 ));
33376 }
33377 }
33378 };
33379
33380 dlg.finished(true);
33381 return Ok(response);
33382 }
33383 }
33384 }
33385 }
33386
33387 ///
33388 /// Sets the *request* property to the given value.
33389 ///
33390 /// Even though the property as already been set when instantiating this call,
33391 /// we provide this method for API completeness.
33392 pub fn request(mut self, new_value: WasmPlugin) -> ProjectLocationWasmPluginCreateCall<'a, C> {
33393 self._request = new_value;
33394 self
33395 }
33396 /// Required. The parent resource of the `WasmPlugin` resource. Must be in the format `projects/{project}/locations/global`.
33397 ///
33398 /// Sets the *parent* path property to the given value.
33399 ///
33400 /// Even though the property as already been set when instantiating this call,
33401 /// we provide this method for API completeness.
33402 pub fn parent(mut self, new_value: &str) -> ProjectLocationWasmPluginCreateCall<'a, C> {
33403 self._parent = new_value.to_string();
33404 self
33405 }
33406 /// Required. User-provided ID of the `WasmPlugin` resource to be created.
33407 ///
33408 /// Sets the *wasm plugin id* query property to the given value.
33409 pub fn wasm_plugin_id(mut self, new_value: &str) -> ProjectLocationWasmPluginCreateCall<'a, C> {
33410 self._wasm_plugin_id = Some(new_value.to_string());
33411 self
33412 }
33413 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
33414 /// while executing the actual API request.
33415 ///
33416 /// ````text
33417 /// It should be used to handle progress information, and to implement a certain level of resilience.
33418 /// ````
33419 ///
33420 /// Sets the *delegate* property to the given value.
33421 pub fn delegate(
33422 mut self,
33423 new_value: &'a mut dyn common::Delegate,
33424 ) -> ProjectLocationWasmPluginCreateCall<'a, C> {
33425 self._delegate = Some(new_value);
33426 self
33427 }
33428
33429 /// Set any additional parameter of the query string used in the request.
33430 /// It should be used to set parameters which are not yet available through their own
33431 /// setters.
33432 ///
33433 /// Please note that this method must not be used to set any of the known parameters
33434 /// which have their own setter method. If done anyway, the request will fail.
33435 ///
33436 /// # Additional Parameters
33437 ///
33438 /// * *$.xgafv* (query-string) - V1 error format.
33439 /// * *access_token* (query-string) - OAuth access token.
33440 /// * *alt* (query-string) - Data format for response.
33441 /// * *callback* (query-string) - JSONP
33442 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
33443 /// * *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.
33444 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
33445 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
33446 /// * *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.
33447 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
33448 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
33449 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationWasmPluginCreateCall<'a, C>
33450 where
33451 T: AsRef<str>,
33452 {
33453 self._additional_params
33454 .insert(name.as_ref().to_string(), value.as_ref().to_string());
33455 self
33456 }
33457
33458 /// Identifies the authorization scope for the method you are building.
33459 ///
33460 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
33461 /// [`Scope::CloudPlatform`].
33462 ///
33463 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
33464 /// tokens for more than one scope.
33465 ///
33466 /// Usually there is more than one suitable scope to authorize an operation, some of which may
33467 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
33468 /// sufficient, a read-write scope will do as well.
33469 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationWasmPluginCreateCall<'a, C>
33470 where
33471 St: AsRef<str>,
33472 {
33473 self._scopes.insert(String::from(scope.as_ref()));
33474 self
33475 }
33476 /// Identifies the authorization scope(s) for the method you are building.
33477 ///
33478 /// See [`Self::add_scope()`] for details.
33479 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationWasmPluginCreateCall<'a, C>
33480 where
33481 I: IntoIterator<Item = St>,
33482 St: AsRef<str>,
33483 {
33484 self._scopes
33485 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
33486 self
33487 }
33488
33489 /// Removes all scopes, and no default scope will be used either.
33490 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
33491 /// for details).
33492 pub fn clear_scopes(mut self) -> ProjectLocationWasmPluginCreateCall<'a, C> {
33493 self._scopes.clear();
33494 self
33495 }
33496}
33497
33498/// Deletes the specified `WasmPlugin` resource.
33499///
33500/// A builder for the *locations.wasmPlugins.delete* method supported by a *project* resource.
33501/// It is not used directly, but through a [`ProjectMethods`] instance.
33502///
33503/// # Example
33504///
33505/// Instantiate a resource method builder
33506///
33507/// ```test_harness,no_run
33508/// # extern crate hyper;
33509/// # extern crate hyper_rustls;
33510/// # extern crate google_networkservices1 as networkservices1;
33511/// # async fn dox() {
33512/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
33513///
33514/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
33515/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
33516/// # .with_native_roots()
33517/// # .unwrap()
33518/// # .https_only()
33519/// # .enable_http2()
33520/// # .build();
33521///
33522/// # let executor = hyper_util::rt::TokioExecutor::new();
33523/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
33524/// # secret,
33525/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
33526/// # yup_oauth2::client::CustomHyperClientBuilder::from(
33527/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
33528/// # ),
33529/// # ).build().await.unwrap();
33530///
33531/// # let client = hyper_util::client::legacy::Client::builder(
33532/// # hyper_util::rt::TokioExecutor::new()
33533/// # )
33534/// # .build(
33535/// # hyper_rustls::HttpsConnectorBuilder::new()
33536/// # .with_native_roots()
33537/// # .unwrap()
33538/// # .https_or_http()
33539/// # .enable_http2()
33540/// # .build()
33541/// # );
33542/// # let mut hub = NetworkServices::new(client, auth);
33543/// // You can configure optional parameters by calling the respective setters at will, and
33544/// // execute the final call using `doit()`.
33545/// // Values shown here are possibly random and not representative !
33546/// let result = hub.projects().locations_wasm_plugins_delete("name")
33547/// .doit().await;
33548/// # }
33549/// ```
33550pub struct ProjectLocationWasmPluginDeleteCall<'a, C>
33551where
33552 C: 'a,
33553{
33554 hub: &'a NetworkServices<C>,
33555 _name: String,
33556 _delegate: Option<&'a mut dyn common::Delegate>,
33557 _additional_params: HashMap<String, String>,
33558 _scopes: BTreeSet<String>,
33559}
33560
33561impl<'a, C> common::CallBuilder for ProjectLocationWasmPluginDeleteCall<'a, C> {}
33562
33563impl<'a, C> ProjectLocationWasmPluginDeleteCall<'a, C>
33564where
33565 C: common::Connector,
33566{
33567 /// Perform the operation you have build so far.
33568 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
33569 use std::borrow::Cow;
33570 use std::io::{Read, Seek};
33571
33572 use common::{url::Params, ToParts};
33573 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
33574
33575 let mut dd = common::DefaultDelegate;
33576 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
33577 dlg.begin(common::MethodInfo {
33578 id: "networkservices.projects.locations.wasmPlugins.delete",
33579 http_method: hyper::Method::DELETE,
33580 });
33581
33582 for &field in ["alt", "name"].iter() {
33583 if self._additional_params.contains_key(field) {
33584 dlg.finished(false);
33585 return Err(common::Error::FieldClash(field));
33586 }
33587 }
33588
33589 let mut params = Params::with_capacity(3 + self._additional_params.len());
33590 params.push("name", self._name);
33591
33592 params.extend(self._additional_params.iter());
33593
33594 params.push("alt", "json");
33595 let mut url = self.hub._base_url.clone() + "v1/{+name}";
33596 if self._scopes.is_empty() {
33597 self._scopes
33598 .insert(Scope::CloudPlatform.as_ref().to_string());
33599 }
33600
33601 #[allow(clippy::single_element_loop)]
33602 for &(find_this, param_name) in [("{+name}", "name")].iter() {
33603 url = params.uri_replacement(url, param_name, find_this, true);
33604 }
33605 {
33606 let to_remove = ["name"];
33607 params.remove_params(&to_remove);
33608 }
33609
33610 let url = params.parse_with_url(&url);
33611
33612 loop {
33613 let token = match self
33614 .hub
33615 .auth
33616 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
33617 .await
33618 {
33619 Ok(token) => token,
33620 Err(e) => match dlg.token(e) {
33621 Ok(token) => token,
33622 Err(e) => {
33623 dlg.finished(false);
33624 return Err(common::Error::MissingToken(e));
33625 }
33626 },
33627 };
33628 let mut req_result = {
33629 let client = &self.hub.client;
33630 dlg.pre_request();
33631 let mut req_builder = hyper::Request::builder()
33632 .method(hyper::Method::DELETE)
33633 .uri(url.as_str())
33634 .header(USER_AGENT, self.hub._user_agent.clone());
33635
33636 if let Some(token) = token.as_ref() {
33637 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
33638 }
33639
33640 let request = req_builder
33641 .header(CONTENT_LENGTH, 0_u64)
33642 .body(common::to_body::<String>(None));
33643
33644 client.request(request.unwrap()).await
33645 };
33646
33647 match req_result {
33648 Err(err) => {
33649 if let common::Retry::After(d) = dlg.http_error(&err) {
33650 sleep(d).await;
33651 continue;
33652 }
33653 dlg.finished(false);
33654 return Err(common::Error::HttpError(err));
33655 }
33656 Ok(res) => {
33657 let (mut parts, body) = res.into_parts();
33658 let mut body = common::Body::new(body);
33659 if !parts.status.is_success() {
33660 let bytes = common::to_bytes(body).await.unwrap_or_default();
33661 let error = serde_json::from_str(&common::to_string(&bytes));
33662 let response = common::to_response(parts, bytes.into());
33663
33664 if let common::Retry::After(d) =
33665 dlg.http_failure(&response, error.as_ref().ok())
33666 {
33667 sleep(d).await;
33668 continue;
33669 }
33670
33671 dlg.finished(false);
33672
33673 return Err(match error {
33674 Ok(value) => common::Error::BadRequest(value),
33675 _ => common::Error::Failure(response),
33676 });
33677 }
33678 let response = {
33679 let bytes = common::to_bytes(body).await.unwrap_or_default();
33680 let encoded = common::to_string(&bytes);
33681 match serde_json::from_str(&encoded) {
33682 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
33683 Err(error) => {
33684 dlg.response_json_decode_error(&encoded, &error);
33685 return Err(common::Error::JsonDecodeError(
33686 encoded.to_string(),
33687 error,
33688 ));
33689 }
33690 }
33691 };
33692
33693 dlg.finished(true);
33694 return Ok(response);
33695 }
33696 }
33697 }
33698 }
33699
33700 /// Required. A name of the `WasmPlugin` resource to delete. Must be in the format `projects/{project}/locations/global/wasmPlugins/{wasm_plugin}`.
33701 ///
33702 /// Sets the *name* path property to the given value.
33703 ///
33704 /// Even though the property as already been set when instantiating this call,
33705 /// we provide this method for API completeness.
33706 pub fn name(mut self, new_value: &str) -> ProjectLocationWasmPluginDeleteCall<'a, C> {
33707 self._name = new_value.to_string();
33708 self
33709 }
33710 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
33711 /// while executing the actual API request.
33712 ///
33713 /// ````text
33714 /// It should be used to handle progress information, and to implement a certain level of resilience.
33715 /// ````
33716 ///
33717 /// Sets the *delegate* property to the given value.
33718 pub fn delegate(
33719 mut self,
33720 new_value: &'a mut dyn common::Delegate,
33721 ) -> ProjectLocationWasmPluginDeleteCall<'a, C> {
33722 self._delegate = Some(new_value);
33723 self
33724 }
33725
33726 /// Set any additional parameter of the query string used in the request.
33727 /// It should be used to set parameters which are not yet available through their own
33728 /// setters.
33729 ///
33730 /// Please note that this method must not be used to set any of the known parameters
33731 /// which have their own setter method. If done anyway, the request will fail.
33732 ///
33733 /// # Additional Parameters
33734 ///
33735 /// * *$.xgafv* (query-string) - V1 error format.
33736 /// * *access_token* (query-string) - OAuth access token.
33737 /// * *alt* (query-string) - Data format for response.
33738 /// * *callback* (query-string) - JSONP
33739 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
33740 /// * *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.
33741 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
33742 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
33743 /// * *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.
33744 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
33745 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
33746 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationWasmPluginDeleteCall<'a, C>
33747 where
33748 T: AsRef<str>,
33749 {
33750 self._additional_params
33751 .insert(name.as_ref().to_string(), value.as_ref().to_string());
33752 self
33753 }
33754
33755 /// Identifies the authorization scope for the method you are building.
33756 ///
33757 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
33758 /// [`Scope::CloudPlatform`].
33759 ///
33760 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
33761 /// tokens for more than one scope.
33762 ///
33763 /// Usually there is more than one suitable scope to authorize an operation, some of which may
33764 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
33765 /// sufficient, a read-write scope will do as well.
33766 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationWasmPluginDeleteCall<'a, C>
33767 where
33768 St: AsRef<str>,
33769 {
33770 self._scopes.insert(String::from(scope.as_ref()));
33771 self
33772 }
33773 /// Identifies the authorization scope(s) for the method you are building.
33774 ///
33775 /// See [`Self::add_scope()`] for details.
33776 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationWasmPluginDeleteCall<'a, C>
33777 where
33778 I: IntoIterator<Item = St>,
33779 St: AsRef<str>,
33780 {
33781 self._scopes
33782 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
33783 self
33784 }
33785
33786 /// Removes all scopes, and no default scope will be used either.
33787 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
33788 /// for details).
33789 pub fn clear_scopes(mut self) -> ProjectLocationWasmPluginDeleteCall<'a, C> {
33790 self._scopes.clear();
33791 self
33792 }
33793}
33794
33795/// Gets details of the specified `WasmPlugin` resource.
33796///
33797/// A builder for the *locations.wasmPlugins.get* method supported by a *project* resource.
33798/// It is not used directly, but through a [`ProjectMethods`] instance.
33799///
33800/// # Example
33801///
33802/// Instantiate a resource method builder
33803///
33804/// ```test_harness,no_run
33805/// # extern crate hyper;
33806/// # extern crate hyper_rustls;
33807/// # extern crate google_networkservices1 as networkservices1;
33808/// # async fn dox() {
33809/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
33810///
33811/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
33812/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
33813/// # .with_native_roots()
33814/// # .unwrap()
33815/// # .https_only()
33816/// # .enable_http2()
33817/// # .build();
33818///
33819/// # let executor = hyper_util::rt::TokioExecutor::new();
33820/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
33821/// # secret,
33822/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
33823/// # yup_oauth2::client::CustomHyperClientBuilder::from(
33824/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
33825/// # ),
33826/// # ).build().await.unwrap();
33827///
33828/// # let client = hyper_util::client::legacy::Client::builder(
33829/// # hyper_util::rt::TokioExecutor::new()
33830/// # )
33831/// # .build(
33832/// # hyper_rustls::HttpsConnectorBuilder::new()
33833/// # .with_native_roots()
33834/// # .unwrap()
33835/// # .https_or_http()
33836/// # .enable_http2()
33837/// # .build()
33838/// # );
33839/// # let mut hub = NetworkServices::new(client, auth);
33840/// // You can configure optional parameters by calling the respective setters at will, and
33841/// // execute the final call using `doit()`.
33842/// // Values shown here are possibly random and not representative !
33843/// let result = hub.projects().locations_wasm_plugins_get("name")
33844/// .view("sea")
33845/// .doit().await;
33846/// # }
33847/// ```
33848pub struct ProjectLocationWasmPluginGetCall<'a, C>
33849where
33850 C: 'a,
33851{
33852 hub: &'a NetworkServices<C>,
33853 _name: String,
33854 _view: Option<String>,
33855 _delegate: Option<&'a mut dyn common::Delegate>,
33856 _additional_params: HashMap<String, String>,
33857 _scopes: BTreeSet<String>,
33858}
33859
33860impl<'a, C> common::CallBuilder for ProjectLocationWasmPluginGetCall<'a, C> {}
33861
33862impl<'a, C> ProjectLocationWasmPluginGetCall<'a, C>
33863where
33864 C: common::Connector,
33865{
33866 /// Perform the operation you have build so far.
33867 pub async fn doit(mut self) -> common::Result<(common::Response, WasmPlugin)> {
33868 use std::borrow::Cow;
33869 use std::io::{Read, Seek};
33870
33871 use common::{url::Params, ToParts};
33872 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
33873
33874 let mut dd = common::DefaultDelegate;
33875 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
33876 dlg.begin(common::MethodInfo {
33877 id: "networkservices.projects.locations.wasmPlugins.get",
33878 http_method: hyper::Method::GET,
33879 });
33880
33881 for &field in ["alt", "name", "view"].iter() {
33882 if self._additional_params.contains_key(field) {
33883 dlg.finished(false);
33884 return Err(common::Error::FieldClash(field));
33885 }
33886 }
33887
33888 let mut params = Params::with_capacity(4 + self._additional_params.len());
33889 params.push("name", self._name);
33890 if let Some(value) = self._view.as_ref() {
33891 params.push("view", value);
33892 }
33893
33894 params.extend(self._additional_params.iter());
33895
33896 params.push("alt", "json");
33897 let mut url = self.hub._base_url.clone() + "v1/{+name}";
33898 if self._scopes.is_empty() {
33899 self._scopes
33900 .insert(Scope::CloudPlatform.as_ref().to_string());
33901 }
33902
33903 #[allow(clippy::single_element_loop)]
33904 for &(find_this, param_name) in [("{+name}", "name")].iter() {
33905 url = params.uri_replacement(url, param_name, find_this, true);
33906 }
33907 {
33908 let to_remove = ["name"];
33909 params.remove_params(&to_remove);
33910 }
33911
33912 let url = params.parse_with_url(&url);
33913
33914 loop {
33915 let token = match self
33916 .hub
33917 .auth
33918 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
33919 .await
33920 {
33921 Ok(token) => token,
33922 Err(e) => match dlg.token(e) {
33923 Ok(token) => token,
33924 Err(e) => {
33925 dlg.finished(false);
33926 return Err(common::Error::MissingToken(e));
33927 }
33928 },
33929 };
33930 let mut req_result = {
33931 let client = &self.hub.client;
33932 dlg.pre_request();
33933 let mut req_builder = hyper::Request::builder()
33934 .method(hyper::Method::GET)
33935 .uri(url.as_str())
33936 .header(USER_AGENT, self.hub._user_agent.clone());
33937
33938 if let Some(token) = token.as_ref() {
33939 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
33940 }
33941
33942 let request = req_builder
33943 .header(CONTENT_LENGTH, 0_u64)
33944 .body(common::to_body::<String>(None));
33945
33946 client.request(request.unwrap()).await
33947 };
33948
33949 match req_result {
33950 Err(err) => {
33951 if let common::Retry::After(d) = dlg.http_error(&err) {
33952 sleep(d).await;
33953 continue;
33954 }
33955 dlg.finished(false);
33956 return Err(common::Error::HttpError(err));
33957 }
33958 Ok(res) => {
33959 let (mut parts, body) = res.into_parts();
33960 let mut body = common::Body::new(body);
33961 if !parts.status.is_success() {
33962 let bytes = common::to_bytes(body).await.unwrap_or_default();
33963 let error = serde_json::from_str(&common::to_string(&bytes));
33964 let response = common::to_response(parts, bytes.into());
33965
33966 if let common::Retry::After(d) =
33967 dlg.http_failure(&response, error.as_ref().ok())
33968 {
33969 sleep(d).await;
33970 continue;
33971 }
33972
33973 dlg.finished(false);
33974
33975 return Err(match error {
33976 Ok(value) => common::Error::BadRequest(value),
33977 _ => common::Error::Failure(response),
33978 });
33979 }
33980 let response = {
33981 let bytes = common::to_bytes(body).await.unwrap_or_default();
33982 let encoded = common::to_string(&bytes);
33983 match serde_json::from_str(&encoded) {
33984 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
33985 Err(error) => {
33986 dlg.response_json_decode_error(&encoded, &error);
33987 return Err(common::Error::JsonDecodeError(
33988 encoded.to_string(),
33989 error,
33990 ));
33991 }
33992 }
33993 };
33994
33995 dlg.finished(true);
33996 return Ok(response);
33997 }
33998 }
33999 }
34000 }
34001
34002 /// Required. A name of the `WasmPlugin` resource to get. Must be in the format `projects/{project}/locations/global/wasmPlugins/{wasm_plugin}`.
34003 ///
34004 /// Sets the *name* path property to the given value.
34005 ///
34006 /// Even though the property as already been set when instantiating this call,
34007 /// we provide this method for API completeness.
34008 pub fn name(mut self, new_value: &str) -> ProjectLocationWasmPluginGetCall<'a, C> {
34009 self._name = new_value.to_string();
34010 self
34011 }
34012 /// Determines how much data must be returned in the response. See [AIP-157](https://google.aip.dev/157).
34013 ///
34014 /// Sets the *view* query property to the given value.
34015 pub fn view(mut self, new_value: &str) -> ProjectLocationWasmPluginGetCall<'a, C> {
34016 self._view = Some(new_value.to_string());
34017 self
34018 }
34019 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
34020 /// while executing the actual API request.
34021 ///
34022 /// ````text
34023 /// It should be used to handle progress information, and to implement a certain level of resilience.
34024 /// ````
34025 ///
34026 /// Sets the *delegate* property to the given value.
34027 pub fn delegate(
34028 mut self,
34029 new_value: &'a mut dyn common::Delegate,
34030 ) -> ProjectLocationWasmPluginGetCall<'a, C> {
34031 self._delegate = Some(new_value);
34032 self
34033 }
34034
34035 /// Set any additional parameter of the query string used in the request.
34036 /// It should be used to set parameters which are not yet available through their own
34037 /// setters.
34038 ///
34039 /// Please note that this method must not be used to set any of the known parameters
34040 /// which have their own setter method. If done anyway, the request will fail.
34041 ///
34042 /// # Additional Parameters
34043 ///
34044 /// * *$.xgafv* (query-string) - V1 error format.
34045 /// * *access_token* (query-string) - OAuth access token.
34046 /// * *alt* (query-string) - Data format for response.
34047 /// * *callback* (query-string) - JSONP
34048 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
34049 /// * *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.
34050 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
34051 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
34052 /// * *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.
34053 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
34054 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
34055 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationWasmPluginGetCall<'a, C>
34056 where
34057 T: AsRef<str>,
34058 {
34059 self._additional_params
34060 .insert(name.as_ref().to_string(), value.as_ref().to_string());
34061 self
34062 }
34063
34064 /// Identifies the authorization scope for the method you are building.
34065 ///
34066 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
34067 /// [`Scope::CloudPlatform`].
34068 ///
34069 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
34070 /// tokens for more than one scope.
34071 ///
34072 /// Usually there is more than one suitable scope to authorize an operation, some of which may
34073 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
34074 /// sufficient, a read-write scope will do as well.
34075 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationWasmPluginGetCall<'a, C>
34076 where
34077 St: AsRef<str>,
34078 {
34079 self._scopes.insert(String::from(scope.as_ref()));
34080 self
34081 }
34082 /// Identifies the authorization scope(s) for the method you are building.
34083 ///
34084 /// See [`Self::add_scope()`] for details.
34085 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationWasmPluginGetCall<'a, C>
34086 where
34087 I: IntoIterator<Item = St>,
34088 St: AsRef<str>,
34089 {
34090 self._scopes
34091 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
34092 self
34093 }
34094
34095 /// Removes all scopes, and no default scope will be used either.
34096 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
34097 /// for details).
34098 pub fn clear_scopes(mut self) -> ProjectLocationWasmPluginGetCall<'a, C> {
34099 self._scopes.clear();
34100 self
34101 }
34102}
34103
34104/// Lists `WasmPlugin` resources in a given project and location.
34105///
34106/// A builder for the *locations.wasmPlugins.list* method supported by a *project* resource.
34107/// It is not used directly, but through a [`ProjectMethods`] instance.
34108///
34109/// # Example
34110///
34111/// Instantiate a resource method builder
34112///
34113/// ```test_harness,no_run
34114/// # extern crate hyper;
34115/// # extern crate hyper_rustls;
34116/// # extern crate google_networkservices1 as networkservices1;
34117/// # async fn dox() {
34118/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
34119///
34120/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
34121/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
34122/// # .with_native_roots()
34123/// # .unwrap()
34124/// # .https_only()
34125/// # .enable_http2()
34126/// # .build();
34127///
34128/// # let executor = hyper_util::rt::TokioExecutor::new();
34129/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
34130/// # secret,
34131/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
34132/// # yup_oauth2::client::CustomHyperClientBuilder::from(
34133/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
34134/// # ),
34135/// # ).build().await.unwrap();
34136///
34137/// # let client = hyper_util::client::legacy::Client::builder(
34138/// # hyper_util::rt::TokioExecutor::new()
34139/// # )
34140/// # .build(
34141/// # hyper_rustls::HttpsConnectorBuilder::new()
34142/// # .with_native_roots()
34143/// # .unwrap()
34144/// # .https_or_http()
34145/// # .enable_http2()
34146/// # .build()
34147/// # );
34148/// # let mut hub = NetworkServices::new(client, auth);
34149/// // You can configure optional parameters by calling the respective setters at will, and
34150/// // execute the final call using `doit()`.
34151/// // Values shown here are possibly random and not representative !
34152/// let result = hub.projects().locations_wasm_plugins_list("parent")
34153/// .page_token("sit")
34154/// .page_size(-32)
34155/// .doit().await;
34156/// # }
34157/// ```
34158pub struct ProjectLocationWasmPluginListCall<'a, C>
34159where
34160 C: 'a,
34161{
34162 hub: &'a NetworkServices<C>,
34163 _parent: String,
34164 _page_token: Option<String>,
34165 _page_size: Option<i32>,
34166 _delegate: Option<&'a mut dyn common::Delegate>,
34167 _additional_params: HashMap<String, String>,
34168 _scopes: BTreeSet<String>,
34169}
34170
34171impl<'a, C> common::CallBuilder for ProjectLocationWasmPluginListCall<'a, C> {}
34172
34173impl<'a, C> ProjectLocationWasmPluginListCall<'a, C>
34174where
34175 C: common::Connector,
34176{
34177 /// Perform the operation you have build so far.
34178 pub async fn doit(mut self) -> common::Result<(common::Response, ListWasmPluginsResponse)> {
34179 use std::borrow::Cow;
34180 use std::io::{Read, Seek};
34181
34182 use common::{url::Params, ToParts};
34183 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
34184
34185 let mut dd = common::DefaultDelegate;
34186 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
34187 dlg.begin(common::MethodInfo {
34188 id: "networkservices.projects.locations.wasmPlugins.list",
34189 http_method: hyper::Method::GET,
34190 });
34191
34192 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
34193 if self._additional_params.contains_key(field) {
34194 dlg.finished(false);
34195 return Err(common::Error::FieldClash(field));
34196 }
34197 }
34198
34199 let mut params = Params::with_capacity(5 + self._additional_params.len());
34200 params.push("parent", self._parent);
34201 if let Some(value) = self._page_token.as_ref() {
34202 params.push("pageToken", value);
34203 }
34204 if let Some(value) = self._page_size.as_ref() {
34205 params.push("pageSize", value.to_string());
34206 }
34207
34208 params.extend(self._additional_params.iter());
34209
34210 params.push("alt", "json");
34211 let mut url = self.hub._base_url.clone() + "v1/{+parent}/wasmPlugins";
34212 if self._scopes.is_empty() {
34213 self._scopes
34214 .insert(Scope::CloudPlatform.as_ref().to_string());
34215 }
34216
34217 #[allow(clippy::single_element_loop)]
34218 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
34219 url = params.uri_replacement(url, param_name, find_this, true);
34220 }
34221 {
34222 let to_remove = ["parent"];
34223 params.remove_params(&to_remove);
34224 }
34225
34226 let url = params.parse_with_url(&url);
34227
34228 loop {
34229 let token = match self
34230 .hub
34231 .auth
34232 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
34233 .await
34234 {
34235 Ok(token) => token,
34236 Err(e) => match dlg.token(e) {
34237 Ok(token) => token,
34238 Err(e) => {
34239 dlg.finished(false);
34240 return Err(common::Error::MissingToken(e));
34241 }
34242 },
34243 };
34244 let mut req_result = {
34245 let client = &self.hub.client;
34246 dlg.pre_request();
34247 let mut req_builder = hyper::Request::builder()
34248 .method(hyper::Method::GET)
34249 .uri(url.as_str())
34250 .header(USER_AGENT, self.hub._user_agent.clone());
34251
34252 if let Some(token) = token.as_ref() {
34253 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
34254 }
34255
34256 let request = req_builder
34257 .header(CONTENT_LENGTH, 0_u64)
34258 .body(common::to_body::<String>(None));
34259
34260 client.request(request.unwrap()).await
34261 };
34262
34263 match req_result {
34264 Err(err) => {
34265 if let common::Retry::After(d) = dlg.http_error(&err) {
34266 sleep(d).await;
34267 continue;
34268 }
34269 dlg.finished(false);
34270 return Err(common::Error::HttpError(err));
34271 }
34272 Ok(res) => {
34273 let (mut parts, body) = res.into_parts();
34274 let mut body = common::Body::new(body);
34275 if !parts.status.is_success() {
34276 let bytes = common::to_bytes(body).await.unwrap_or_default();
34277 let error = serde_json::from_str(&common::to_string(&bytes));
34278 let response = common::to_response(parts, bytes.into());
34279
34280 if let common::Retry::After(d) =
34281 dlg.http_failure(&response, error.as_ref().ok())
34282 {
34283 sleep(d).await;
34284 continue;
34285 }
34286
34287 dlg.finished(false);
34288
34289 return Err(match error {
34290 Ok(value) => common::Error::BadRequest(value),
34291 _ => common::Error::Failure(response),
34292 });
34293 }
34294 let response = {
34295 let bytes = common::to_bytes(body).await.unwrap_or_default();
34296 let encoded = common::to_string(&bytes);
34297 match serde_json::from_str(&encoded) {
34298 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
34299 Err(error) => {
34300 dlg.response_json_decode_error(&encoded, &error);
34301 return Err(common::Error::JsonDecodeError(
34302 encoded.to_string(),
34303 error,
34304 ));
34305 }
34306 }
34307 };
34308
34309 dlg.finished(true);
34310 return Ok(response);
34311 }
34312 }
34313 }
34314 }
34315
34316 /// Required. The project and location from which the `WasmPlugin` resources are listed, specified in the following format: `projects/{project}/locations/global`.
34317 ///
34318 /// Sets the *parent* path property to the given value.
34319 ///
34320 /// Even though the property as already been set when instantiating this call,
34321 /// we provide this method for API completeness.
34322 pub fn parent(mut self, new_value: &str) -> ProjectLocationWasmPluginListCall<'a, C> {
34323 self._parent = new_value.to_string();
34324 self
34325 }
34326 /// The value returned by the last `ListWasmPluginsResponse` call. Indicates that this is a continuation of a prior `ListWasmPlugins` call, and that the next page of data is to be returned.
34327 ///
34328 /// Sets the *page token* query property to the given value.
34329 pub fn page_token(mut self, new_value: &str) -> ProjectLocationWasmPluginListCall<'a, C> {
34330 self._page_token = Some(new_value.to_string());
34331 self
34332 }
34333 /// Maximum number of `WasmPlugin` resources to return per call. If not specified, at most 50 `WasmPlugin` resources are returned. The maximum value is 1000; values above 1000 are coerced to 1000.
34334 ///
34335 /// Sets the *page size* query property to the given value.
34336 pub fn page_size(mut self, new_value: i32) -> ProjectLocationWasmPluginListCall<'a, C> {
34337 self._page_size = Some(new_value);
34338 self
34339 }
34340 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
34341 /// while executing the actual API request.
34342 ///
34343 /// ````text
34344 /// It should be used to handle progress information, and to implement a certain level of resilience.
34345 /// ````
34346 ///
34347 /// Sets the *delegate* property to the given value.
34348 pub fn delegate(
34349 mut self,
34350 new_value: &'a mut dyn common::Delegate,
34351 ) -> ProjectLocationWasmPluginListCall<'a, C> {
34352 self._delegate = Some(new_value);
34353 self
34354 }
34355
34356 /// Set any additional parameter of the query string used in the request.
34357 /// It should be used to set parameters which are not yet available through their own
34358 /// setters.
34359 ///
34360 /// Please note that this method must not be used to set any of the known parameters
34361 /// which have their own setter method. If done anyway, the request will fail.
34362 ///
34363 /// # Additional Parameters
34364 ///
34365 /// * *$.xgafv* (query-string) - V1 error format.
34366 /// * *access_token* (query-string) - OAuth access token.
34367 /// * *alt* (query-string) - Data format for response.
34368 /// * *callback* (query-string) - JSONP
34369 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
34370 /// * *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.
34371 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
34372 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
34373 /// * *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.
34374 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
34375 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
34376 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationWasmPluginListCall<'a, C>
34377 where
34378 T: AsRef<str>,
34379 {
34380 self._additional_params
34381 .insert(name.as_ref().to_string(), value.as_ref().to_string());
34382 self
34383 }
34384
34385 /// Identifies the authorization scope for the method you are building.
34386 ///
34387 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
34388 /// [`Scope::CloudPlatform`].
34389 ///
34390 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
34391 /// tokens for more than one scope.
34392 ///
34393 /// Usually there is more than one suitable scope to authorize an operation, some of which may
34394 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
34395 /// sufficient, a read-write scope will do as well.
34396 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationWasmPluginListCall<'a, C>
34397 where
34398 St: AsRef<str>,
34399 {
34400 self._scopes.insert(String::from(scope.as_ref()));
34401 self
34402 }
34403 /// Identifies the authorization scope(s) for the method you are building.
34404 ///
34405 /// See [`Self::add_scope()`] for details.
34406 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationWasmPluginListCall<'a, C>
34407 where
34408 I: IntoIterator<Item = St>,
34409 St: AsRef<str>,
34410 {
34411 self._scopes
34412 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
34413 self
34414 }
34415
34416 /// Removes all scopes, and no default scope will be used either.
34417 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
34418 /// for details).
34419 pub fn clear_scopes(mut self) -> ProjectLocationWasmPluginListCall<'a, C> {
34420 self._scopes.clear();
34421 self
34422 }
34423}
34424
34425/// Updates the parameters of the specified `WasmPlugin` resource.
34426///
34427/// A builder for the *locations.wasmPlugins.patch* method supported by a *project* resource.
34428/// It is not used directly, but through a [`ProjectMethods`] instance.
34429///
34430/// # Example
34431///
34432/// Instantiate a resource method builder
34433///
34434/// ```test_harness,no_run
34435/// # extern crate hyper;
34436/// # extern crate hyper_rustls;
34437/// # extern crate google_networkservices1 as networkservices1;
34438/// use networkservices1::api::WasmPlugin;
34439/// # async fn dox() {
34440/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
34441///
34442/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
34443/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
34444/// # .with_native_roots()
34445/// # .unwrap()
34446/// # .https_only()
34447/// # .enable_http2()
34448/// # .build();
34449///
34450/// # let executor = hyper_util::rt::TokioExecutor::new();
34451/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
34452/// # secret,
34453/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
34454/// # yup_oauth2::client::CustomHyperClientBuilder::from(
34455/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
34456/// # ),
34457/// # ).build().await.unwrap();
34458///
34459/// # let client = hyper_util::client::legacy::Client::builder(
34460/// # hyper_util::rt::TokioExecutor::new()
34461/// # )
34462/// # .build(
34463/// # hyper_rustls::HttpsConnectorBuilder::new()
34464/// # .with_native_roots()
34465/// # .unwrap()
34466/// # .https_or_http()
34467/// # .enable_http2()
34468/// # .build()
34469/// # );
34470/// # let mut hub = NetworkServices::new(client, auth);
34471/// // As the method needs a request, you would usually fill it with the desired information
34472/// // into the respective structure. Some of the parts shown here might not be applicable !
34473/// // Values shown here are possibly random and not representative !
34474/// let mut req = WasmPlugin::default();
34475///
34476/// // You can configure optional parameters by calling the respective setters at will, and
34477/// // execute the final call using `doit()`.
34478/// // Values shown here are possibly random and not representative !
34479/// let result = hub.projects().locations_wasm_plugins_patch(req, "name")
34480/// .update_mask(FieldMask::new::<&str>(&[]))
34481/// .doit().await;
34482/// # }
34483/// ```
34484pub struct ProjectLocationWasmPluginPatchCall<'a, C>
34485where
34486 C: 'a,
34487{
34488 hub: &'a NetworkServices<C>,
34489 _request: WasmPlugin,
34490 _name: String,
34491 _update_mask: Option<common::FieldMask>,
34492 _delegate: Option<&'a mut dyn common::Delegate>,
34493 _additional_params: HashMap<String, String>,
34494 _scopes: BTreeSet<String>,
34495}
34496
34497impl<'a, C> common::CallBuilder for ProjectLocationWasmPluginPatchCall<'a, C> {}
34498
34499impl<'a, C> ProjectLocationWasmPluginPatchCall<'a, C>
34500where
34501 C: common::Connector,
34502{
34503 /// Perform the operation you have build so far.
34504 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
34505 use std::borrow::Cow;
34506 use std::io::{Read, Seek};
34507
34508 use common::{url::Params, ToParts};
34509 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
34510
34511 let mut dd = common::DefaultDelegate;
34512 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
34513 dlg.begin(common::MethodInfo {
34514 id: "networkservices.projects.locations.wasmPlugins.patch",
34515 http_method: hyper::Method::PATCH,
34516 });
34517
34518 for &field in ["alt", "name", "updateMask"].iter() {
34519 if self._additional_params.contains_key(field) {
34520 dlg.finished(false);
34521 return Err(common::Error::FieldClash(field));
34522 }
34523 }
34524
34525 let mut params = Params::with_capacity(5 + self._additional_params.len());
34526 params.push("name", self._name);
34527 if let Some(value) = self._update_mask.as_ref() {
34528 params.push("updateMask", value.to_string());
34529 }
34530
34531 params.extend(self._additional_params.iter());
34532
34533 params.push("alt", "json");
34534 let mut url = self.hub._base_url.clone() + "v1/{+name}";
34535 if self._scopes.is_empty() {
34536 self._scopes
34537 .insert(Scope::CloudPlatform.as_ref().to_string());
34538 }
34539
34540 #[allow(clippy::single_element_loop)]
34541 for &(find_this, param_name) in [("{+name}", "name")].iter() {
34542 url = params.uri_replacement(url, param_name, find_this, true);
34543 }
34544 {
34545 let to_remove = ["name"];
34546 params.remove_params(&to_remove);
34547 }
34548
34549 let url = params.parse_with_url(&url);
34550
34551 let mut json_mime_type = mime::APPLICATION_JSON;
34552 let mut request_value_reader = {
34553 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
34554 common::remove_json_null_values(&mut value);
34555 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
34556 serde_json::to_writer(&mut dst, &value).unwrap();
34557 dst
34558 };
34559 let request_size = request_value_reader
34560 .seek(std::io::SeekFrom::End(0))
34561 .unwrap();
34562 request_value_reader
34563 .seek(std::io::SeekFrom::Start(0))
34564 .unwrap();
34565
34566 loop {
34567 let token = match self
34568 .hub
34569 .auth
34570 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
34571 .await
34572 {
34573 Ok(token) => token,
34574 Err(e) => match dlg.token(e) {
34575 Ok(token) => token,
34576 Err(e) => {
34577 dlg.finished(false);
34578 return Err(common::Error::MissingToken(e));
34579 }
34580 },
34581 };
34582 request_value_reader
34583 .seek(std::io::SeekFrom::Start(0))
34584 .unwrap();
34585 let mut req_result = {
34586 let client = &self.hub.client;
34587 dlg.pre_request();
34588 let mut req_builder = hyper::Request::builder()
34589 .method(hyper::Method::PATCH)
34590 .uri(url.as_str())
34591 .header(USER_AGENT, self.hub._user_agent.clone());
34592
34593 if let Some(token) = token.as_ref() {
34594 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
34595 }
34596
34597 let request = req_builder
34598 .header(CONTENT_TYPE, json_mime_type.to_string())
34599 .header(CONTENT_LENGTH, request_size as u64)
34600 .body(common::to_body(
34601 request_value_reader.get_ref().clone().into(),
34602 ));
34603
34604 client.request(request.unwrap()).await
34605 };
34606
34607 match req_result {
34608 Err(err) => {
34609 if let common::Retry::After(d) = dlg.http_error(&err) {
34610 sleep(d).await;
34611 continue;
34612 }
34613 dlg.finished(false);
34614 return Err(common::Error::HttpError(err));
34615 }
34616 Ok(res) => {
34617 let (mut parts, body) = res.into_parts();
34618 let mut body = common::Body::new(body);
34619 if !parts.status.is_success() {
34620 let bytes = common::to_bytes(body).await.unwrap_or_default();
34621 let error = serde_json::from_str(&common::to_string(&bytes));
34622 let response = common::to_response(parts, bytes.into());
34623
34624 if let common::Retry::After(d) =
34625 dlg.http_failure(&response, error.as_ref().ok())
34626 {
34627 sleep(d).await;
34628 continue;
34629 }
34630
34631 dlg.finished(false);
34632
34633 return Err(match error {
34634 Ok(value) => common::Error::BadRequest(value),
34635 _ => common::Error::Failure(response),
34636 });
34637 }
34638 let response = {
34639 let bytes = common::to_bytes(body).await.unwrap_or_default();
34640 let encoded = common::to_string(&bytes);
34641 match serde_json::from_str(&encoded) {
34642 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
34643 Err(error) => {
34644 dlg.response_json_decode_error(&encoded, &error);
34645 return Err(common::Error::JsonDecodeError(
34646 encoded.to_string(),
34647 error,
34648 ));
34649 }
34650 }
34651 };
34652
34653 dlg.finished(true);
34654 return Ok(response);
34655 }
34656 }
34657 }
34658 }
34659
34660 ///
34661 /// Sets the *request* property to the given value.
34662 ///
34663 /// Even though the property as already been set when instantiating this call,
34664 /// we provide this method for API completeness.
34665 pub fn request(mut self, new_value: WasmPlugin) -> ProjectLocationWasmPluginPatchCall<'a, C> {
34666 self._request = new_value;
34667 self
34668 }
34669 /// Identifier. Name of the `WasmPlugin` resource in the following format: `projects/{project}/locations/{location}/wasmPlugins/{wasm_plugin}`.
34670 ///
34671 /// Sets the *name* path property to the given value.
34672 ///
34673 /// Even though the property as already been set when instantiating this call,
34674 /// we provide this method for API completeness.
34675 pub fn name(mut self, new_value: &str) -> ProjectLocationWasmPluginPatchCall<'a, C> {
34676 self._name = new_value.to_string();
34677 self
34678 }
34679 /// Optional. Used to specify the fields to be overwritten in the `WasmPlugin` resource by the update. The fields specified in the `update_mask` field are relative to the resource, not the full request. An omitted `update_mask` field is treated as an implied `update_mask` field equivalent to all fields that are populated (that have a non-empty value). The `update_mask` field supports a special value `*`, which means that each field in the given `WasmPlugin` resource (including the empty ones) replaces the current value.
34680 ///
34681 /// Sets the *update mask* query property to the given value.
34682 pub fn update_mask(
34683 mut self,
34684 new_value: common::FieldMask,
34685 ) -> ProjectLocationWasmPluginPatchCall<'a, C> {
34686 self._update_mask = Some(new_value);
34687 self
34688 }
34689 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
34690 /// while executing the actual API request.
34691 ///
34692 /// ````text
34693 /// It should be used to handle progress information, and to implement a certain level of resilience.
34694 /// ````
34695 ///
34696 /// Sets the *delegate* property to the given value.
34697 pub fn delegate(
34698 mut self,
34699 new_value: &'a mut dyn common::Delegate,
34700 ) -> ProjectLocationWasmPluginPatchCall<'a, C> {
34701 self._delegate = Some(new_value);
34702 self
34703 }
34704
34705 /// Set any additional parameter of the query string used in the request.
34706 /// It should be used to set parameters which are not yet available through their own
34707 /// setters.
34708 ///
34709 /// Please note that this method must not be used to set any of the known parameters
34710 /// which have their own setter method. If done anyway, the request will fail.
34711 ///
34712 /// # Additional Parameters
34713 ///
34714 /// * *$.xgafv* (query-string) - V1 error format.
34715 /// * *access_token* (query-string) - OAuth access token.
34716 /// * *alt* (query-string) - Data format for response.
34717 /// * *callback* (query-string) - JSONP
34718 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
34719 /// * *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.
34720 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
34721 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
34722 /// * *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.
34723 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
34724 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
34725 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationWasmPluginPatchCall<'a, C>
34726 where
34727 T: AsRef<str>,
34728 {
34729 self._additional_params
34730 .insert(name.as_ref().to_string(), value.as_ref().to_string());
34731 self
34732 }
34733
34734 /// Identifies the authorization scope for the method you are building.
34735 ///
34736 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
34737 /// [`Scope::CloudPlatform`].
34738 ///
34739 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
34740 /// tokens for more than one scope.
34741 ///
34742 /// Usually there is more than one suitable scope to authorize an operation, some of which may
34743 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
34744 /// sufficient, a read-write scope will do as well.
34745 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationWasmPluginPatchCall<'a, C>
34746 where
34747 St: AsRef<str>,
34748 {
34749 self._scopes.insert(String::from(scope.as_ref()));
34750 self
34751 }
34752 /// Identifies the authorization scope(s) for the method you are building.
34753 ///
34754 /// See [`Self::add_scope()`] for details.
34755 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationWasmPluginPatchCall<'a, C>
34756 where
34757 I: IntoIterator<Item = St>,
34758 St: AsRef<str>,
34759 {
34760 self._scopes
34761 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
34762 self
34763 }
34764
34765 /// Removes all scopes, and no default scope will be used either.
34766 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
34767 /// for details).
34768 pub fn clear_scopes(mut self) -> ProjectLocationWasmPluginPatchCall<'a, C> {
34769 self._scopes.clear();
34770 self
34771 }
34772}
34773
34774/// Gets information about a location.
34775///
34776/// A builder for the *locations.get* method supported by a *project* resource.
34777/// It is not used directly, but through a [`ProjectMethods`] instance.
34778///
34779/// # Example
34780///
34781/// Instantiate a resource method builder
34782///
34783/// ```test_harness,no_run
34784/// # extern crate hyper;
34785/// # extern crate hyper_rustls;
34786/// # extern crate google_networkservices1 as networkservices1;
34787/// # async fn dox() {
34788/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
34789///
34790/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
34791/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
34792/// # .with_native_roots()
34793/// # .unwrap()
34794/// # .https_only()
34795/// # .enable_http2()
34796/// # .build();
34797///
34798/// # let executor = hyper_util::rt::TokioExecutor::new();
34799/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
34800/// # secret,
34801/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
34802/// # yup_oauth2::client::CustomHyperClientBuilder::from(
34803/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
34804/// # ),
34805/// # ).build().await.unwrap();
34806///
34807/// # let client = hyper_util::client::legacy::Client::builder(
34808/// # hyper_util::rt::TokioExecutor::new()
34809/// # )
34810/// # .build(
34811/// # hyper_rustls::HttpsConnectorBuilder::new()
34812/// # .with_native_roots()
34813/// # .unwrap()
34814/// # .https_or_http()
34815/// # .enable_http2()
34816/// # .build()
34817/// # );
34818/// # let mut hub = NetworkServices::new(client, auth);
34819/// // You can configure optional parameters by calling the respective setters at will, and
34820/// // execute the final call using `doit()`.
34821/// // Values shown here are possibly random and not representative !
34822/// let result = hub.projects().locations_get("name")
34823/// .doit().await;
34824/// # }
34825/// ```
34826pub struct ProjectLocationGetCall<'a, C>
34827where
34828 C: 'a,
34829{
34830 hub: &'a NetworkServices<C>,
34831 _name: String,
34832 _delegate: Option<&'a mut dyn common::Delegate>,
34833 _additional_params: HashMap<String, String>,
34834 _scopes: BTreeSet<String>,
34835}
34836
34837impl<'a, C> common::CallBuilder for ProjectLocationGetCall<'a, C> {}
34838
34839impl<'a, C> ProjectLocationGetCall<'a, C>
34840where
34841 C: common::Connector,
34842{
34843 /// Perform the operation you have build so far.
34844 pub async fn doit(mut self) -> common::Result<(common::Response, Location)> {
34845 use std::borrow::Cow;
34846 use std::io::{Read, Seek};
34847
34848 use common::{url::Params, ToParts};
34849 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
34850
34851 let mut dd = common::DefaultDelegate;
34852 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
34853 dlg.begin(common::MethodInfo {
34854 id: "networkservices.projects.locations.get",
34855 http_method: hyper::Method::GET,
34856 });
34857
34858 for &field in ["alt", "name"].iter() {
34859 if self._additional_params.contains_key(field) {
34860 dlg.finished(false);
34861 return Err(common::Error::FieldClash(field));
34862 }
34863 }
34864
34865 let mut params = Params::with_capacity(3 + self._additional_params.len());
34866 params.push("name", self._name);
34867
34868 params.extend(self._additional_params.iter());
34869
34870 params.push("alt", "json");
34871 let mut url = self.hub._base_url.clone() + "v1/{+name}";
34872 if self._scopes.is_empty() {
34873 self._scopes
34874 .insert(Scope::CloudPlatform.as_ref().to_string());
34875 }
34876
34877 #[allow(clippy::single_element_loop)]
34878 for &(find_this, param_name) in [("{+name}", "name")].iter() {
34879 url = params.uri_replacement(url, param_name, find_this, true);
34880 }
34881 {
34882 let to_remove = ["name"];
34883 params.remove_params(&to_remove);
34884 }
34885
34886 let url = params.parse_with_url(&url);
34887
34888 loop {
34889 let token = match self
34890 .hub
34891 .auth
34892 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
34893 .await
34894 {
34895 Ok(token) => token,
34896 Err(e) => match dlg.token(e) {
34897 Ok(token) => token,
34898 Err(e) => {
34899 dlg.finished(false);
34900 return Err(common::Error::MissingToken(e));
34901 }
34902 },
34903 };
34904 let mut req_result = {
34905 let client = &self.hub.client;
34906 dlg.pre_request();
34907 let mut req_builder = hyper::Request::builder()
34908 .method(hyper::Method::GET)
34909 .uri(url.as_str())
34910 .header(USER_AGENT, self.hub._user_agent.clone());
34911
34912 if let Some(token) = token.as_ref() {
34913 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
34914 }
34915
34916 let request = req_builder
34917 .header(CONTENT_LENGTH, 0_u64)
34918 .body(common::to_body::<String>(None));
34919
34920 client.request(request.unwrap()).await
34921 };
34922
34923 match req_result {
34924 Err(err) => {
34925 if let common::Retry::After(d) = dlg.http_error(&err) {
34926 sleep(d).await;
34927 continue;
34928 }
34929 dlg.finished(false);
34930 return Err(common::Error::HttpError(err));
34931 }
34932 Ok(res) => {
34933 let (mut parts, body) = res.into_parts();
34934 let mut body = common::Body::new(body);
34935 if !parts.status.is_success() {
34936 let bytes = common::to_bytes(body).await.unwrap_or_default();
34937 let error = serde_json::from_str(&common::to_string(&bytes));
34938 let response = common::to_response(parts, bytes.into());
34939
34940 if let common::Retry::After(d) =
34941 dlg.http_failure(&response, error.as_ref().ok())
34942 {
34943 sleep(d).await;
34944 continue;
34945 }
34946
34947 dlg.finished(false);
34948
34949 return Err(match error {
34950 Ok(value) => common::Error::BadRequest(value),
34951 _ => common::Error::Failure(response),
34952 });
34953 }
34954 let response = {
34955 let bytes = common::to_bytes(body).await.unwrap_or_default();
34956 let encoded = common::to_string(&bytes);
34957 match serde_json::from_str(&encoded) {
34958 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
34959 Err(error) => {
34960 dlg.response_json_decode_error(&encoded, &error);
34961 return Err(common::Error::JsonDecodeError(
34962 encoded.to_string(),
34963 error,
34964 ));
34965 }
34966 }
34967 };
34968
34969 dlg.finished(true);
34970 return Ok(response);
34971 }
34972 }
34973 }
34974 }
34975
34976 /// Resource name for the location.
34977 ///
34978 /// Sets the *name* path property to the given value.
34979 ///
34980 /// Even though the property as already been set when instantiating this call,
34981 /// we provide this method for API completeness.
34982 pub fn name(mut self, new_value: &str) -> ProjectLocationGetCall<'a, C> {
34983 self._name = new_value.to_string();
34984 self
34985 }
34986 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
34987 /// while executing the actual API request.
34988 ///
34989 /// ````text
34990 /// It should be used to handle progress information, and to implement a certain level of resilience.
34991 /// ````
34992 ///
34993 /// Sets the *delegate* property to the given value.
34994 pub fn delegate(
34995 mut self,
34996 new_value: &'a mut dyn common::Delegate,
34997 ) -> ProjectLocationGetCall<'a, C> {
34998 self._delegate = Some(new_value);
34999 self
35000 }
35001
35002 /// Set any additional parameter of the query string used in the request.
35003 /// It should be used to set parameters which are not yet available through their own
35004 /// setters.
35005 ///
35006 /// Please note that this method must not be used to set any of the known parameters
35007 /// which have their own setter method. If done anyway, the request will fail.
35008 ///
35009 /// # Additional Parameters
35010 ///
35011 /// * *$.xgafv* (query-string) - V1 error format.
35012 /// * *access_token* (query-string) - OAuth access token.
35013 /// * *alt* (query-string) - Data format for response.
35014 /// * *callback* (query-string) - JSONP
35015 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
35016 /// * *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.
35017 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
35018 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
35019 /// * *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.
35020 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
35021 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
35022 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGetCall<'a, C>
35023 where
35024 T: AsRef<str>,
35025 {
35026 self._additional_params
35027 .insert(name.as_ref().to_string(), value.as_ref().to_string());
35028 self
35029 }
35030
35031 /// Identifies the authorization scope for the method you are building.
35032 ///
35033 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
35034 /// [`Scope::CloudPlatform`].
35035 ///
35036 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
35037 /// tokens for more than one scope.
35038 ///
35039 /// Usually there is more than one suitable scope to authorize an operation, some of which may
35040 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
35041 /// sufficient, a read-write scope will do as well.
35042 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGetCall<'a, C>
35043 where
35044 St: AsRef<str>,
35045 {
35046 self._scopes.insert(String::from(scope.as_ref()));
35047 self
35048 }
35049 /// Identifies the authorization scope(s) for the method you are building.
35050 ///
35051 /// See [`Self::add_scope()`] for details.
35052 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGetCall<'a, C>
35053 where
35054 I: IntoIterator<Item = St>,
35055 St: AsRef<str>,
35056 {
35057 self._scopes
35058 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
35059 self
35060 }
35061
35062 /// Removes all scopes, and no default scope will be used either.
35063 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
35064 /// for details).
35065 pub fn clear_scopes(mut self) -> ProjectLocationGetCall<'a, C> {
35066 self._scopes.clear();
35067 self
35068 }
35069}
35070
35071/// Lists information about the supported locations for this service.
35072///
35073/// A builder for the *locations.list* method supported by a *project* resource.
35074/// It is not used directly, but through a [`ProjectMethods`] instance.
35075///
35076/// # Example
35077///
35078/// Instantiate a resource method builder
35079///
35080/// ```test_harness,no_run
35081/// # extern crate hyper;
35082/// # extern crate hyper_rustls;
35083/// # extern crate google_networkservices1 as networkservices1;
35084/// # async fn dox() {
35085/// # use networkservices1::{NetworkServices, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
35086///
35087/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
35088/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
35089/// # .with_native_roots()
35090/// # .unwrap()
35091/// # .https_only()
35092/// # .enable_http2()
35093/// # .build();
35094///
35095/// # let executor = hyper_util::rt::TokioExecutor::new();
35096/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
35097/// # secret,
35098/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
35099/// # yup_oauth2::client::CustomHyperClientBuilder::from(
35100/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
35101/// # ),
35102/// # ).build().await.unwrap();
35103///
35104/// # let client = hyper_util::client::legacy::Client::builder(
35105/// # hyper_util::rt::TokioExecutor::new()
35106/// # )
35107/// # .build(
35108/// # hyper_rustls::HttpsConnectorBuilder::new()
35109/// # .with_native_roots()
35110/// # .unwrap()
35111/// # .https_or_http()
35112/// # .enable_http2()
35113/// # .build()
35114/// # );
35115/// # let mut hub = NetworkServices::new(client, auth);
35116/// // You can configure optional parameters by calling the respective setters at will, and
35117/// // execute the final call using `doit()`.
35118/// // Values shown here are possibly random and not representative !
35119/// let result = hub.projects().locations_list("name")
35120/// .page_token("consetetur")
35121/// .page_size(-62)
35122/// .filter("dolor")
35123/// .add_extra_location_types("aliquyam")
35124/// .doit().await;
35125/// # }
35126/// ```
35127pub struct ProjectLocationListCall<'a, C>
35128where
35129 C: 'a,
35130{
35131 hub: &'a NetworkServices<C>,
35132 _name: String,
35133 _page_token: Option<String>,
35134 _page_size: Option<i32>,
35135 _filter: Option<String>,
35136 _extra_location_types: Vec<String>,
35137 _delegate: Option<&'a mut dyn common::Delegate>,
35138 _additional_params: HashMap<String, String>,
35139 _scopes: BTreeSet<String>,
35140}
35141
35142impl<'a, C> common::CallBuilder for ProjectLocationListCall<'a, C> {}
35143
35144impl<'a, C> ProjectLocationListCall<'a, C>
35145where
35146 C: common::Connector,
35147{
35148 /// Perform the operation you have build so far.
35149 pub async fn doit(mut self) -> common::Result<(common::Response, ListLocationsResponse)> {
35150 use std::borrow::Cow;
35151 use std::io::{Read, Seek};
35152
35153 use common::{url::Params, ToParts};
35154 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
35155
35156 let mut dd = common::DefaultDelegate;
35157 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
35158 dlg.begin(common::MethodInfo {
35159 id: "networkservices.projects.locations.list",
35160 http_method: hyper::Method::GET,
35161 });
35162
35163 for &field in [
35164 "alt",
35165 "name",
35166 "pageToken",
35167 "pageSize",
35168 "filter",
35169 "extraLocationTypes",
35170 ]
35171 .iter()
35172 {
35173 if self._additional_params.contains_key(field) {
35174 dlg.finished(false);
35175 return Err(common::Error::FieldClash(field));
35176 }
35177 }
35178
35179 let mut params = Params::with_capacity(7 + self._additional_params.len());
35180 params.push("name", self._name);
35181 if let Some(value) = self._page_token.as_ref() {
35182 params.push("pageToken", value);
35183 }
35184 if let Some(value) = self._page_size.as_ref() {
35185 params.push("pageSize", value.to_string());
35186 }
35187 if let Some(value) = self._filter.as_ref() {
35188 params.push("filter", value);
35189 }
35190 if !self._extra_location_types.is_empty() {
35191 for f in self._extra_location_types.iter() {
35192 params.push("extraLocationTypes", f);
35193 }
35194 }
35195
35196 params.extend(self._additional_params.iter());
35197
35198 params.push("alt", "json");
35199 let mut url = self.hub._base_url.clone() + "v1/{+name}/locations";
35200 if self._scopes.is_empty() {
35201 self._scopes
35202 .insert(Scope::CloudPlatform.as_ref().to_string());
35203 }
35204
35205 #[allow(clippy::single_element_loop)]
35206 for &(find_this, param_name) in [("{+name}", "name")].iter() {
35207 url = params.uri_replacement(url, param_name, find_this, true);
35208 }
35209 {
35210 let to_remove = ["name"];
35211 params.remove_params(&to_remove);
35212 }
35213
35214 let url = params.parse_with_url(&url);
35215
35216 loop {
35217 let token = match self
35218 .hub
35219 .auth
35220 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
35221 .await
35222 {
35223 Ok(token) => token,
35224 Err(e) => match dlg.token(e) {
35225 Ok(token) => token,
35226 Err(e) => {
35227 dlg.finished(false);
35228 return Err(common::Error::MissingToken(e));
35229 }
35230 },
35231 };
35232 let mut req_result = {
35233 let client = &self.hub.client;
35234 dlg.pre_request();
35235 let mut req_builder = hyper::Request::builder()
35236 .method(hyper::Method::GET)
35237 .uri(url.as_str())
35238 .header(USER_AGENT, self.hub._user_agent.clone());
35239
35240 if let Some(token) = token.as_ref() {
35241 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
35242 }
35243
35244 let request = req_builder
35245 .header(CONTENT_LENGTH, 0_u64)
35246 .body(common::to_body::<String>(None));
35247
35248 client.request(request.unwrap()).await
35249 };
35250
35251 match req_result {
35252 Err(err) => {
35253 if let common::Retry::After(d) = dlg.http_error(&err) {
35254 sleep(d).await;
35255 continue;
35256 }
35257 dlg.finished(false);
35258 return Err(common::Error::HttpError(err));
35259 }
35260 Ok(res) => {
35261 let (mut parts, body) = res.into_parts();
35262 let mut body = common::Body::new(body);
35263 if !parts.status.is_success() {
35264 let bytes = common::to_bytes(body).await.unwrap_or_default();
35265 let error = serde_json::from_str(&common::to_string(&bytes));
35266 let response = common::to_response(parts, bytes.into());
35267
35268 if let common::Retry::After(d) =
35269 dlg.http_failure(&response, error.as_ref().ok())
35270 {
35271 sleep(d).await;
35272 continue;
35273 }
35274
35275 dlg.finished(false);
35276
35277 return Err(match error {
35278 Ok(value) => common::Error::BadRequest(value),
35279 _ => common::Error::Failure(response),
35280 });
35281 }
35282 let response = {
35283 let bytes = common::to_bytes(body).await.unwrap_or_default();
35284 let encoded = common::to_string(&bytes);
35285 match serde_json::from_str(&encoded) {
35286 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
35287 Err(error) => {
35288 dlg.response_json_decode_error(&encoded, &error);
35289 return Err(common::Error::JsonDecodeError(
35290 encoded.to_string(),
35291 error,
35292 ));
35293 }
35294 }
35295 };
35296
35297 dlg.finished(true);
35298 return Ok(response);
35299 }
35300 }
35301 }
35302 }
35303
35304 /// The resource that owns the locations collection, if applicable.
35305 ///
35306 /// Sets the *name* path property to the given value.
35307 ///
35308 /// Even though the property as already been set when instantiating this call,
35309 /// we provide this method for API completeness.
35310 pub fn name(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
35311 self._name = new_value.to_string();
35312 self
35313 }
35314 /// A page token received from the `next_page_token` field in the response. Send that page token to receive the subsequent page.
35315 ///
35316 /// Sets the *page token* query property to the given value.
35317 pub fn page_token(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
35318 self._page_token = Some(new_value.to_string());
35319 self
35320 }
35321 /// The maximum number of results to return. If not set, the service selects a default.
35322 ///
35323 /// Sets the *page size* query property to the given value.
35324 pub fn page_size(mut self, new_value: i32) -> ProjectLocationListCall<'a, C> {
35325 self._page_size = Some(new_value);
35326 self
35327 }
35328 /// 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).
35329 ///
35330 /// Sets the *filter* query property to the given value.
35331 pub fn filter(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
35332 self._filter = Some(new_value.to_string());
35333 self
35334 }
35335 /// Optional. Do not use this field. It is unsupported and is ignored unless explicitly documented otherwise. This is primarily for internal usage.
35336 ///
35337 /// Append the given value to the *extra location types* query property.
35338 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
35339 pub fn add_extra_location_types(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
35340 self._extra_location_types.push(new_value.to_string());
35341 self
35342 }
35343 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
35344 /// while executing the actual API request.
35345 ///
35346 /// ````text
35347 /// It should be used to handle progress information, and to implement a certain level of resilience.
35348 /// ````
35349 ///
35350 /// Sets the *delegate* property to the given value.
35351 pub fn delegate(
35352 mut self,
35353 new_value: &'a mut dyn common::Delegate,
35354 ) -> ProjectLocationListCall<'a, C> {
35355 self._delegate = Some(new_value);
35356 self
35357 }
35358
35359 /// Set any additional parameter of the query string used in the request.
35360 /// It should be used to set parameters which are not yet available through their own
35361 /// setters.
35362 ///
35363 /// Please note that this method must not be used to set any of the known parameters
35364 /// which have their own setter method. If done anyway, the request will fail.
35365 ///
35366 /// # Additional Parameters
35367 ///
35368 /// * *$.xgafv* (query-string) - V1 error format.
35369 /// * *access_token* (query-string) - OAuth access token.
35370 /// * *alt* (query-string) - Data format for response.
35371 /// * *callback* (query-string) - JSONP
35372 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
35373 /// * *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.
35374 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
35375 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
35376 /// * *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.
35377 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
35378 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
35379 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationListCall<'a, C>
35380 where
35381 T: AsRef<str>,
35382 {
35383 self._additional_params
35384 .insert(name.as_ref().to_string(), value.as_ref().to_string());
35385 self
35386 }
35387
35388 /// Identifies the authorization scope for the method you are building.
35389 ///
35390 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
35391 /// [`Scope::CloudPlatform`].
35392 ///
35393 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
35394 /// tokens for more than one scope.
35395 ///
35396 /// Usually there is more than one suitable scope to authorize an operation, some of which may
35397 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
35398 /// sufficient, a read-write scope will do as well.
35399 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationListCall<'a, C>
35400 where
35401 St: AsRef<str>,
35402 {
35403 self._scopes.insert(String::from(scope.as_ref()));
35404 self
35405 }
35406 /// Identifies the authorization scope(s) for the method you are building.
35407 ///
35408 /// See [`Self::add_scope()`] for details.
35409 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationListCall<'a, C>
35410 where
35411 I: IntoIterator<Item = St>,
35412 St: AsRef<str>,
35413 {
35414 self._scopes
35415 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
35416 self
35417 }
35418
35419 /// Removes all scopes, and no default scope will be used either.
35420 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
35421 /// for details).
35422 pub fn clear_scopes(mut self) -> ProjectLocationListCall<'a, C> {
35423 self._scopes.clear();
35424 self
35425 }
35426}