google_apigateway1/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 Apigateway 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_apigateway1 as apigateway1;
49/// use apigateway1::api::ApigatewayApiConfig;
50/// use apigateway1::{Result, Error};
51/// # async fn dox() {
52/// use apigateway1::{Apigateway, 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 = Apigateway::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 = ApigatewayApiConfig::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_apis_configs_create(req, "parent")
99/// .api_config_id("At")
100/// .doit().await;
101///
102/// match result {
103/// Err(e) => match e {
104/// // The Error enum provides details about what exactly happened.
105/// // You can also just use its `Debug`, `Display` or `Error` traits
106/// Error::HttpError(_)
107/// |Error::Io(_)
108/// |Error::MissingAPIKey
109/// |Error::MissingToken(_)
110/// |Error::Cancelled
111/// |Error::UploadSizeLimitExceeded(_, _)
112/// |Error::Failure(_)
113/// |Error::BadRequest(_)
114/// |Error::FieldClash(_)
115/// |Error::JsonDecodeError(_, _) => println!("{}", e),
116/// },
117/// Ok(res) => println!("Success: {:?}", res),
118/// }
119/// # }
120/// ```
121#[derive(Clone)]
122pub struct Apigateway<C> {
123 pub client: common::Client<C>,
124 pub auth: Box<dyn common::GetToken>,
125 _user_agent: String,
126 _base_url: String,
127 _root_url: String,
128}
129
130impl<C> common::Hub for Apigateway<C> {}
131
132impl<'a, C> Apigateway<C> {
133 pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> Apigateway<C> {
134 Apigateway {
135 client,
136 auth: Box::new(auth),
137 _user_agent: "google-api-rust-client/7.0.0".to_string(),
138 _base_url: "https://apigateway.googleapis.com/".to_string(),
139 _root_url: "https://apigateway.googleapis.com/".to_string(),
140 }
141 }
142
143 pub fn projects(&'a self) -> ProjectMethods<'a, C> {
144 ProjectMethods { hub: self }
145 }
146
147 /// Set the user-agent header field to use in all requests to the server.
148 /// It defaults to `google-api-rust-client/7.0.0`.
149 ///
150 /// Returns the previously set user-agent.
151 pub fn user_agent(&mut self, agent_name: String) -> String {
152 std::mem::replace(&mut self._user_agent, agent_name)
153 }
154
155 /// Set the base url to use in all requests to the server.
156 /// It defaults to `https://apigateway.googleapis.com/`.
157 ///
158 /// Returns the previously set base url.
159 pub fn base_url(&mut self, new_base_url: String) -> String {
160 std::mem::replace(&mut self._base_url, new_base_url)
161 }
162
163 /// Set the root url to use in all requests to the server.
164 /// It defaults to `https://apigateway.googleapis.com/`.
165 ///
166 /// Returns the previously set root url.
167 pub fn root_url(&mut self, new_root_url: String) -> String {
168 std::mem::replace(&mut self._root_url, new_root_url)
169 }
170}
171
172// ############
173// SCHEMAS ###
174// ##########
175/// An API that can be served by one or more Gateways.
176///
177/// # Activities
178///
179/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
180/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
181///
182/// * [locations apis create projects](ProjectLocationApiCreateCall) (request)
183/// * [locations apis get projects](ProjectLocationApiGetCall) (response)
184/// * [locations apis patch projects](ProjectLocationApiPatchCall) (request)
185#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
186#[serde_with::serde_as]
187#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
188pub struct ApigatewayApi {
189 /// Output only. Created time.
190 #[serde(rename = "createTime")]
191 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
192 /// Optional. Display name.
193 #[serde(rename = "displayName")]
194 pub display_name: Option<String>,
195 /// Optional. Resource labels to represent user-provided metadata. Refer to cloud documentation on labels for more details. https://cloud.google.com/compute/docs/labeling-resources
196 pub labels: Option<HashMap<String, String>>,
197 /// Optional. Immutable. The name of a Google Managed Service ( https://cloud.google.com/service-infrastructure/docs/glossary#managed). If not specified, a new Service will automatically be created in the same project as this API.
198 #[serde(rename = "managedService")]
199 pub managed_service: Option<String>,
200 /// Output only. Resource name of the API. Format: projects/{project}/locations/global/apis/{api}
201 pub name: Option<String>,
202 /// Output only. State of the API.
203 pub state: Option<String>,
204 /// Output only. Updated time.
205 #[serde(rename = "updateTime")]
206 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
207}
208
209impl common::RequestValue for ApigatewayApi {}
210impl common::ResponseResult for ApigatewayApi {}
211
212/// An API Configuration is a combination of settings for both the Managed Service and Gateways serving this API Config.
213///
214/// # Activities
215///
216/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
217/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
218///
219/// * [locations apis configs create projects](ProjectLocationApiConfigCreateCall) (request)
220/// * [locations apis configs get projects](ProjectLocationApiConfigGetCall) (response)
221/// * [locations apis configs patch projects](ProjectLocationApiConfigPatchCall) (request)
222#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
223#[serde_with::serde_as]
224#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
225pub struct ApigatewayApiConfig {
226 /// Output only. Created time.
227 #[serde(rename = "createTime")]
228 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
229 /// Optional. Display name.
230 #[serde(rename = "displayName")]
231 pub display_name: Option<String>,
232 /// Immutable. The Google Cloud IAM Service Account that Gateways serving this config should use to authenticate to other services. This may either be the Service Account's email (`{ACCOUNT_ID}@{PROJECT}.iam.gserviceaccount.com`) or its full resource name (`projects/{PROJECT}/accounts/{UNIQUE_ID}`). This is most often used when the service is a GCP resource such as a Cloud Run Service or an IAP-secured service.
233 #[serde(rename = "gatewayServiceAccount")]
234 pub gateway_service_account: Option<String>,
235 /// Optional. gRPC service definition files. If specified, openapi_documents must not be included.
236 #[serde(rename = "grpcServices")]
237 pub grpc_services: Option<Vec<ApigatewayApiConfigGrpcServiceDefinition>>,
238 /// Optional. Resource labels to represent user-provided metadata. Refer to cloud documentation on labels for more details. https://cloud.google.com/compute/docs/labeling-resources
239 pub labels: Option<HashMap<String, String>>,
240 /// Optional. Service Configuration files. At least one must be included when using gRPC service definitions. See https://cloud.google.com/endpoints/docs/grpc/grpc-service-config#service_configuration_overview for the expected file contents. If multiple files are specified, the files are merged with the following rules: * All singular scalar fields are merged using "last one wins" semantics in the order of the files uploaded. * Repeated fields are concatenated. * Singular embedded messages are merged using these rules for nested fields.
241 #[serde(rename = "managedServiceConfigs")]
242 pub managed_service_configs: Option<Vec<ApigatewayApiConfigFile>>,
243 /// Output only. Resource name of the API Config. Format: projects/{project}/locations/global/apis/{api}/configs/{api_config}
244 pub name: Option<String>,
245 /// Optional. OpenAPI specification documents. If specified, grpc_services and managed_service_configs must not be included.
246 #[serde(rename = "openapiDocuments")]
247 pub openapi_documents: Option<Vec<ApigatewayApiConfigOpenApiDocument>>,
248 /// Output only. The ID of the associated Service Config ( https://cloud.google.com/service-infrastructure/docs/glossary#config).
249 #[serde(rename = "serviceConfigId")]
250 pub service_config_id: Option<String>,
251 /// Output only. State of the API Config.
252 pub state: Option<String>,
253 /// Output only. Updated time.
254 #[serde(rename = "updateTime")]
255 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
256}
257
258impl common::RequestValue for ApigatewayApiConfig {}
259impl common::ResponseResult for ApigatewayApiConfig {}
260
261/// A lightweight description of a file.
262///
263/// This type is not used in any activity, and only used as *part* of another schema.
264///
265#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
266#[serde_with::serde_as]
267#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
268pub struct ApigatewayApiConfigFile {
269 /// The bytes that constitute the file.
270 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
271 pub contents: Option<Vec<u8>>,
272 /// The file path (full or relative path). This is typically the path of the file when it is uploaded.
273 pub path: Option<String>,
274}
275
276impl common::Part for ApigatewayApiConfigFile {}
277
278/// A gRPC service definition.
279///
280/// This type is not used in any activity, and only used as *part* of another schema.
281///
282#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
283#[serde_with::serde_as]
284#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
285pub struct ApigatewayApiConfigGrpcServiceDefinition {
286 /// Input only. File descriptor set, generated by protoc. To generate, use protoc with imports and source info included. For an example test.proto file, the following command would put the value in a new file named out.pb. $ protoc --include_imports --include_source_info test.proto -o out.pb
287 #[serde(rename = "fileDescriptorSet")]
288 pub file_descriptor_set: Option<ApigatewayApiConfigFile>,
289 /// Optional. Uncompiled proto files associated with the descriptor set, used for display purposes (server-side compilation is not supported). These should match the inputs to 'protoc' command used to generate file_descriptor_set.
290 pub source: Option<Vec<ApigatewayApiConfigFile>>,
291}
292
293impl common::Part for ApigatewayApiConfigGrpcServiceDefinition {}
294
295/// An OpenAPI Specification Document describing an API.
296///
297/// This type is not used in any activity, and only used as *part* of another schema.
298///
299#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
300#[serde_with::serde_as]
301#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
302pub struct ApigatewayApiConfigOpenApiDocument {
303 /// The OpenAPI Specification document file.
304 pub document: Option<ApigatewayApiConfigFile>,
305}
306
307impl common::Part for ApigatewayApiConfigOpenApiDocument {}
308
309/// 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.
310///
311/// This type is not used in any activity, and only used as *part* of another schema.
312///
313#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
314#[serde_with::serde_as]
315#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
316pub struct ApigatewayAuditConfig {
317 /// The configuration for logging of each type of permission.
318 #[serde(rename = "auditLogConfigs")]
319 pub audit_log_configs: Option<Vec<ApigatewayAuditLogConfig>>,
320 /// 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.
321 pub service: Option<String>,
322}
323
324impl common::Part for ApigatewayAuditConfig {}
325
326/// 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.
327///
328/// This type is not used in any activity, and only used as *part* of another schema.
329///
330#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
331#[serde_with::serde_as]
332#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
333pub struct ApigatewayAuditLogConfig {
334 /// Specifies the identities that do not cause logging for this type of permission. Follows the same format of Binding.members.
335 #[serde(rename = "exemptedMembers")]
336 pub exempted_members: Option<Vec<String>>,
337 /// The log type that this config enables.
338 #[serde(rename = "logType")]
339 pub log_type: Option<String>,
340}
341
342impl common::Part for ApigatewayAuditLogConfig {}
343
344/// Associates `members`, or principals, with a `role`.
345///
346/// This type is not used in any activity, and only used as *part* of another schema.
347///
348#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
349#[serde_with::serde_as]
350#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
351pub struct ApigatewayBinding {
352 /// 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).
353 pub condition: Option<ApigatewayExpr>,
354 /// 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`.
355 pub members: Option<Vec<String>>,
356 /// 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).
357 pub role: Option<String>,
358}
359
360impl common::Part for ApigatewayBinding {}
361
362/// The request message for Operations.CancelOperation.
363///
364/// # Activities
365///
366/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
367/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
368///
369/// * [locations operations cancel projects](ProjectLocationOperationCancelCall) (request)
370#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
371#[serde_with::serde_as]
372#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
373pub struct ApigatewayCancelOperationRequest {
374 _never_set: Option<bool>,
375}
376
377impl common::RequestValue for ApigatewayCancelOperationRequest {}
378
379/// 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.
380///
381/// This type is not used in any activity, and only used as *part* of another schema.
382///
383#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
384#[serde_with::serde_as]
385#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
386pub struct ApigatewayExpr {
387 /// Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.
388 pub description: Option<String>,
389 /// Textual representation of an expression in Common Expression Language syntax.
390 pub expression: Option<String>,
391 /// Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.
392 pub location: Option<String>,
393 /// 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.
394 pub title: Option<String>,
395}
396
397impl common::Part for ApigatewayExpr {}
398
399/// A Gateway is an API-aware HTTP proxy. It performs API-Method and/or API-Consumer specific actions based on an API Config such as authentication, policy enforcement, and backend selection.
400///
401/// # Activities
402///
403/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
404/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
405///
406/// * [locations gateways create projects](ProjectLocationGatewayCreateCall) (request)
407/// * [locations gateways get projects](ProjectLocationGatewayGetCall) (response)
408/// * [locations gateways patch projects](ProjectLocationGatewayPatchCall) (request)
409#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
410#[serde_with::serde_as]
411#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
412pub struct ApigatewayGateway {
413 /// Required. Resource name of the API Config for this Gateway. Format: projects/{project}/locations/global/apis/{api}/configs/{apiConfig}
414 #[serde(rename = "apiConfig")]
415 pub api_config: Option<String>,
416 /// Output only. Created time.
417 #[serde(rename = "createTime")]
418 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
419 /// Output only. The default API Gateway host name of the form `{gateway_id}-{hash}.{region_code}.gateway.dev`.
420 #[serde(rename = "defaultHostname")]
421 pub default_hostname: Option<String>,
422 /// Optional. Display name.
423 #[serde(rename = "displayName")]
424 pub display_name: Option<String>,
425 /// Optional. Resource labels to represent user-provided metadata. Refer to cloud documentation on labels for more details. https://cloud.google.com/compute/docs/labeling-resources
426 pub labels: Option<HashMap<String, String>>,
427 /// Output only. Resource name of the Gateway. Format: projects/{project}/locations/{location}/gateways/{gateway}
428 pub name: Option<String>,
429 /// Output only. The current state of the Gateway.
430 pub state: Option<String>,
431 /// Output only. Updated time.
432 #[serde(rename = "updateTime")]
433 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
434}
435
436impl common::RequestValue for ApigatewayGateway {}
437impl common::ResponseResult for ApigatewayGateway {}
438
439/// Response message for ApiGatewayService.ListApiConfigs
440///
441/// # Activities
442///
443/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
444/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
445///
446/// * [locations apis configs list projects](ProjectLocationApiConfigListCall) (response)
447#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
448#[serde_with::serde_as]
449#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
450pub struct ApigatewayListApiConfigsResponse {
451 /// API Configs.
452 #[serde(rename = "apiConfigs")]
453 pub api_configs: Option<Vec<ApigatewayApiConfig>>,
454 /// Next page token.
455 #[serde(rename = "nextPageToken")]
456 pub next_page_token: Option<String>,
457 /// Locations that could not be reached.
458 #[serde(rename = "unreachableLocations")]
459 pub unreachable_locations: Option<Vec<String>>,
460}
461
462impl common::ResponseResult for ApigatewayListApiConfigsResponse {}
463
464/// Response message for ApiGatewayService.ListApis
465///
466/// # Activities
467///
468/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
469/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
470///
471/// * [locations apis list projects](ProjectLocationApiListCall) (response)
472#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
473#[serde_with::serde_as]
474#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
475pub struct ApigatewayListApisResponse {
476 /// APIs.
477 pub apis: Option<Vec<ApigatewayApi>>,
478 /// Next page token.
479 #[serde(rename = "nextPageToken")]
480 pub next_page_token: Option<String>,
481 /// Locations that could not be reached.
482 #[serde(rename = "unreachableLocations")]
483 pub unreachable_locations: Option<Vec<String>>,
484}
485
486impl common::ResponseResult for ApigatewayListApisResponse {}
487
488/// Response message for ApiGatewayService.ListGateways
489///
490/// # Activities
491///
492/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
493/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
494///
495/// * [locations gateways list projects](ProjectLocationGatewayListCall) (response)
496#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
497#[serde_with::serde_as]
498#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
499pub struct ApigatewayListGatewaysResponse {
500 /// Gateways.
501 pub gateways: Option<Vec<ApigatewayGateway>>,
502 /// Next page token.
503 #[serde(rename = "nextPageToken")]
504 pub next_page_token: Option<String>,
505 /// Locations that could not be reached.
506 #[serde(rename = "unreachableLocations")]
507 pub unreachable_locations: Option<Vec<String>>,
508}
509
510impl common::ResponseResult for ApigatewayListGatewaysResponse {}
511
512/// The response message for Locations.ListLocations.
513///
514/// # Activities
515///
516/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
517/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
518///
519/// * [locations list projects](ProjectLocationListCall) (response)
520#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
521#[serde_with::serde_as]
522#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
523pub struct ApigatewayListLocationsResponse {
524 /// A list of locations that matches the specified filter in the request.
525 pub locations: Option<Vec<ApigatewayLocation>>,
526 /// The standard List next-page token.
527 #[serde(rename = "nextPageToken")]
528 pub next_page_token: Option<String>,
529}
530
531impl common::ResponseResult for ApigatewayListLocationsResponse {}
532
533/// The response message for Operations.ListOperations.
534///
535/// # Activities
536///
537/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
538/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
539///
540/// * [locations operations list projects](ProjectLocationOperationListCall) (response)
541#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
542#[serde_with::serde_as]
543#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
544pub struct ApigatewayListOperationsResponse {
545 /// The standard List next-page token.
546 #[serde(rename = "nextPageToken")]
547 pub next_page_token: Option<String>,
548 /// A list of operations that matches the specified filter in the request.
549 pub operations: Option<Vec<ApigatewayOperation>>,
550 /// 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.
551 pub unreachable: Option<Vec<String>>,
552}
553
554impl common::ResponseResult for ApigatewayListOperationsResponse {}
555
556/// A resource that represents a Google Cloud location.
557///
558/// # Activities
559///
560/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
561/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
562///
563/// * [locations get projects](ProjectLocationGetCall) (response)
564#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
565#[serde_with::serde_as]
566#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
567pub struct ApigatewayLocation {
568 /// The friendly name for this location, typically a nearby city name. For example, "Tokyo".
569 #[serde(rename = "displayName")]
570 pub display_name: Option<String>,
571 /// Cross-service attributes for the location. For example {"cloud.googleapis.com/region": "us-east1"}
572 pub labels: Option<HashMap<String, String>>,
573 /// The canonical id for this location. For example: `"us-east1"`.
574 #[serde(rename = "locationId")]
575 pub location_id: Option<String>,
576 /// Service-specific metadata. For example the available capacity at the given location.
577 pub metadata: Option<HashMap<String, serde_json::Value>>,
578 /// Resource name for the location, which may vary between implementations. For example: `"projects/example-project/locations/us-east1"`
579 pub name: Option<String>,
580}
581
582impl common::ResponseResult for ApigatewayLocation {}
583
584/// This resource represents a long-running operation that is the result of a network API call.
585///
586/// # Activities
587///
588/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
589/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
590///
591/// * [locations apis configs create projects](ProjectLocationApiConfigCreateCall) (response)
592/// * [locations apis configs delete projects](ProjectLocationApiConfigDeleteCall) (response)
593/// * [locations apis configs patch projects](ProjectLocationApiConfigPatchCall) (response)
594/// * [locations apis create projects](ProjectLocationApiCreateCall) (response)
595/// * [locations apis delete projects](ProjectLocationApiDeleteCall) (response)
596/// * [locations apis patch projects](ProjectLocationApiPatchCall) (response)
597/// * [locations gateways create projects](ProjectLocationGatewayCreateCall) (response)
598/// * [locations gateways delete projects](ProjectLocationGatewayDeleteCall) (response)
599/// * [locations gateways patch projects](ProjectLocationGatewayPatchCall) (response)
600/// * [locations operations get projects](ProjectLocationOperationGetCall) (response)
601#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
602#[serde_with::serde_as]
603#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
604pub struct ApigatewayOperation {
605 /// 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.
606 pub done: Option<bool>,
607 /// The error result of the operation in case of failure or cancellation.
608 pub error: Option<ApigatewayStatus>,
609 /// 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.
610 pub metadata: Option<HashMap<String, serde_json::Value>>,
611 /// 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}`.
612 pub name: Option<String>,
613 /// 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`.
614 pub response: Option<HashMap<String, serde_json::Value>>,
615}
616
617impl common::ResponseResult for ApigatewayOperation {}
618
619/// 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/).
620///
621/// # Activities
622///
623/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
624/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
625///
626/// * [locations apis configs get iam policy projects](ProjectLocationApiConfigGetIamPolicyCall) (response)
627/// * [locations apis configs set iam policy projects](ProjectLocationApiConfigSetIamPolicyCall) (response)
628/// * [locations apis get iam policy projects](ProjectLocationApiGetIamPolicyCall) (response)
629/// * [locations apis set iam policy projects](ProjectLocationApiSetIamPolicyCall) (response)
630/// * [locations gateways get iam policy projects](ProjectLocationGatewayGetIamPolicyCall) (response)
631/// * [locations gateways set iam policy projects](ProjectLocationGatewaySetIamPolicyCall) (response)
632#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
633#[serde_with::serde_as]
634#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
635pub struct ApigatewayPolicy {
636 /// Specifies cloud audit logging configuration for this policy.
637 #[serde(rename = "auditConfigs")]
638 pub audit_configs: Option<Vec<ApigatewayAuditConfig>>,
639 /// 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`.
640 pub bindings: Option<Vec<ApigatewayBinding>>,
641 /// `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.
642 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
643 pub etag: Option<Vec<u8>>,
644 /// 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).
645 pub version: Option<i32>,
646}
647
648impl common::ResponseResult for ApigatewayPolicy {}
649
650/// Request message for `SetIamPolicy` method.
651///
652/// # Activities
653///
654/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
655/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
656///
657/// * [locations apis configs set iam policy projects](ProjectLocationApiConfigSetIamPolicyCall) (request)
658/// * [locations apis set iam policy projects](ProjectLocationApiSetIamPolicyCall) (request)
659/// * [locations gateways set iam policy projects](ProjectLocationGatewaySetIamPolicyCall) (request)
660#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
661#[serde_with::serde_as]
662#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
663pub struct ApigatewaySetIamPolicyRequest {
664 /// 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.
665 pub policy: Option<ApigatewayPolicy>,
666 /// 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"`
667 #[serde(rename = "updateMask")]
668 pub update_mask: Option<common::FieldMask>,
669}
670
671impl common::RequestValue for ApigatewaySetIamPolicyRequest {}
672
673/// 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).
674///
675/// This type is not used in any activity, and only used as *part* of another schema.
676///
677#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
678#[serde_with::serde_as]
679#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
680pub struct ApigatewayStatus {
681 /// The status code, which should be an enum value of google.rpc.Code.
682 pub code: Option<i32>,
683 /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
684 pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
685 /// 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.
686 pub message: Option<String>,
687}
688
689impl common::Part for ApigatewayStatus {}
690
691/// Request message for `TestIamPermissions` method.
692///
693/// # Activities
694///
695/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
696/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
697///
698/// * [locations apis configs test iam permissions projects](ProjectLocationApiConfigTestIamPermissionCall) (request)
699/// * [locations apis test iam permissions projects](ProjectLocationApiTestIamPermissionCall) (request)
700/// * [locations gateways test iam permissions projects](ProjectLocationGatewayTestIamPermissionCall) (request)
701#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
702#[serde_with::serde_as]
703#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
704pub struct ApigatewayTestIamPermissionsRequest {
705 /// 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).
706 pub permissions: Option<Vec<String>>,
707}
708
709impl common::RequestValue for ApigatewayTestIamPermissionsRequest {}
710
711/// Response message for `TestIamPermissions` method.
712///
713/// # Activities
714///
715/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
716/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
717///
718/// * [locations apis configs test iam permissions projects](ProjectLocationApiConfigTestIamPermissionCall) (response)
719/// * [locations apis test iam permissions projects](ProjectLocationApiTestIamPermissionCall) (response)
720/// * [locations gateways test iam permissions projects](ProjectLocationGatewayTestIamPermissionCall) (response)
721#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
722#[serde_with::serde_as]
723#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
724pub struct ApigatewayTestIamPermissionsResponse {
725 /// A subset of `TestPermissionsRequest.permissions` that the caller is allowed.
726 pub permissions: Option<Vec<String>>,
727}
728
729impl common::ResponseResult for ApigatewayTestIamPermissionsResponse {}
730
731/// 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); }
732///
733/// # Activities
734///
735/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
736/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
737///
738/// * [locations operations cancel projects](ProjectLocationOperationCancelCall) (response)
739/// * [locations operations delete projects](ProjectLocationOperationDeleteCall) (response)
740#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
741#[serde_with::serde_as]
742#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
743pub struct Empty {
744 _never_set: Option<bool>,
745}
746
747impl common::ResponseResult for Empty {}
748
749// ###################
750// MethodBuilders ###
751// #################
752
753/// A builder providing access to all methods supported on *project* resources.
754/// It is not used directly, but through the [`Apigateway`] hub.
755///
756/// # Example
757///
758/// Instantiate a resource builder
759///
760/// ```test_harness,no_run
761/// extern crate hyper;
762/// extern crate hyper_rustls;
763/// extern crate google_apigateway1 as apigateway1;
764///
765/// # async fn dox() {
766/// use apigateway1::{Apigateway, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
767///
768/// let secret: yup_oauth2::ApplicationSecret = Default::default();
769/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
770/// .with_native_roots()
771/// .unwrap()
772/// .https_only()
773/// .enable_http2()
774/// .build();
775///
776/// let executor = hyper_util::rt::TokioExecutor::new();
777/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
778/// secret,
779/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
780/// yup_oauth2::client::CustomHyperClientBuilder::from(
781/// hyper_util::client::legacy::Client::builder(executor).build(connector),
782/// ),
783/// ).build().await.unwrap();
784///
785/// let client = hyper_util::client::legacy::Client::builder(
786/// hyper_util::rt::TokioExecutor::new()
787/// )
788/// .build(
789/// hyper_rustls::HttpsConnectorBuilder::new()
790/// .with_native_roots()
791/// .unwrap()
792/// .https_or_http()
793/// .enable_http2()
794/// .build()
795/// );
796/// let mut hub = Apigateway::new(client, auth);
797/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
798/// // like `locations_apis_configs_create(...)`, `locations_apis_configs_delete(...)`, `locations_apis_configs_get(...)`, `locations_apis_configs_get_iam_policy(...)`, `locations_apis_configs_list(...)`, `locations_apis_configs_patch(...)`, `locations_apis_configs_set_iam_policy(...)`, `locations_apis_configs_test_iam_permissions(...)`, `locations_apis_create(...)`, `locations_apis_delete(...)`, `locations_apis_get(...)`, `locations_apis_get_iam_policy(...)`, `locations_apis_list(...)`, `locations_apis_patch(...)`, `locations_apis_set_iam_policy(...)`, `locations_apis_test_iam_permissions(...)`, `locations_gateways_create(...)`, `locations_gateways_delete(...)`, `locations_gateways_get(...)`, `locations_gateways_get_iam_policy(...)`, `locations_gateways_list(...)`, `locations_gateways_patch(...)`, `locations_gateways_set_iam_policy(...)`, `locations_gateways_test_iam_permissions(...)`, `locations_get(...)`, `locations_list(...)`, `locations_operations_cancel(...)`, `locations_operations_delete(...)`, `locations_operations_get(...)` and `locations_operations_list(...)`
799/// // to build up your call.
800/// let rb = hub.projects();
801/// # }
802/// ```
803pub struct ProjectMethods<'a, C>
804where
805 C: 'a,
806{
807 hub: &'a Apigateway<C>,
808}
809
810impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
811
812impl<'a, C> ProjectMethods<'a, C> {
813 /// Create a builder to help you perform the following task:
814 ///
815 /// Creates a new ApiConfig in a given project and location.
816 ///
817 /// # Arguments
818 ///
819 /// * `request` - No description provided.
820 /// * `parent` - Required. Parent resource of the API Config, of the form: `projects/*/locations/global/apis/*`
821 pub fn locations_apis_configs_create(
822 &self,
823 request: ApigatewayApiConfig,
824 parent: &str,
825 ) -> ProjectLocationApiConfigCreateCall<'a, C> {
826 ProjectLocationApiConfigCreateCall {
827 hub: self.hub,
828 _request: request,
829 _parent: parent.to_string(),
830 _api_config_id: Default::default(),
831 _delegate: Default::default(),
832 _additional_params: Default::default(),
833 _scopes: Default::default(),
834 }
835 }
836
837 /// Create a builder to help you perform the following task:
838 ///
839 /// Deletes a single ApiConfig.
840 ///
841 /// # Arguments
842 ///
843 /// * `name` - Required. Resource name of the form: `projects/*/locations/global/apis/*/configs/*`
844 pub fn locations_apis_configs_delete(
845 &self,
846 name: &str,
847 ) -> ProjectLocationApiConfigDeleteCall<'a, C> {
848 ProjectLocationApiConfigDeleteCall {
849 hub: self.hub,
850 _name: name.to_string(),
851 _delegate: Default::default(),
852 _additional_params: Default::default(),
853 _scopes: Default::default(),
854 }
855 }
856
857 /// Create a builder to help you perform the following task:
858 ///
859 /// Gets details of a single ApiConfig.
860 ///
861 /// # Arguments
862 ///
863 /// * `name` - Required. Resource name of the form: `projects/*/locations/global/apis/*/configs/*`
864 pub fn locations_apis_configs_get(&self, name: &str) -> ProjectLocationApiConfigGetCall<'a, C> {
865 ProjectLocationApiConfigGetCall {
866 hub: self.hub,
867 _name: name.to_string(),
868 _view: Default::default(),
869 _delegate: Default::default(),
870 _additional_params: Default::default(),
871 _scopes: Default::default(),
872 }
873 }
874
875 /// Create a builder to help you perform the following task:
876 ///
877 /// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
878 ///
879 /// # Arguments
880 ///
881 /// * `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.
882 pub fn locations_apis_configs_get_iam_policy(
883 &self,
884 resource: &str,
885 ) -> ProjectLocationApiConfigGetIamPolicyCall<'a, C> {
886 ProjectLocationApiConfigGetIamPolicyCall {
887 hub: self.hub,
888 _resource: resource.to_string(),
889 _options_requested_policy_version: Default::default(),
890 _delegate: Default::default(),
891 _additional_params: Default::default(),
892 _scopes: Default::default(),
893 }
894 }
895
896 /// Create a builder to help you perform the following task:
897 ///
898 /// Lists ApiConfigs in a given project and location.
899 ///
900 /// # Arguments
901 ///
902 /// * `parent` - Required. Parent resource of the API Config, of the form: `projects/*/locations/global/apis/*`
903 pub fn locations_apis_configs_list(
904 &self,
905 parent: &str,
906 ) -> ProjectLocationApiConfigListCall<'a, C> {
907 ProjectLocationApiConfigListCall {
908 hub: self.hub,
909 _parent: parent.to_string(),
910 _page_token: Default::default(),
911 _page_size: Default::default(),
912 _order_by: Default::default(),
913 _filter: Default::default(),
914 _delegate: Default::default(),
915 _additional_params: Default::default(),
916 _scopes: Default::default(),
917 }
918 }
919
920 /// Create a builder to help you perform the following task:
921 ///
922 /// Updates the parameters of a single ApiConfig.
923 ///
924 /// # Arguments
925 ///
926 /// * `request` - No description provided.
927 /// * `name` - Output only. Resource name of the API Config. Format: projects/{project}/locations/global/apis/{api}/configs/{api_config}
928 pub fn locations_apis_configs_patch(
929 &self,
930 request: ApigatewayApiConfig,
931 name: &str,
932 ) -> ProjectLocationApiConfigPatchCall<'a, C> {
933 ProjectLocationApiConfigPatchCall {
934 hub: self.hub,
935 _request: request,
936 _name: name.to_string(),
937 _update_mask: Default::default(),
938 _delegate: Default::default(),
939 _additional_params: Default::default(),
940 _scopes: Default::default(),
941 }
942 }
943
944 /// Create a builder to help you perform the following task:
945 ///
946 /// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
947 ///
948 /// # Arguments
949 ///
950 /// * `request` - No description provided.
951 /// * `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.
952 pub fn locations_apis_configs_set_iam_policy(
953 &self,
954 request: ApigatewaySetIamPolicyRequest,
955 resource: &str,
956 ) -> ProjectLocationApiConfigSetIamPolicyCall<'a, C> {
957 ProjectLocationApiConfigSetIamPolicyCall {
958 hub: self.hub,
959 _request: request,
960 _resource: resource.to_string(),
961 _delegate: Default::default(),
962 _additional_params: Default::default(),
963 _scopes: Default::default(),
964 }
965 }
966
967 /// Create a builder to help you perform the following task:
968 ///
969 /// 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.
970 ///
971 /// # Arguments
972 ///
973 /// * `request` - No description provided.
974 /// * `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.
975 pub fn locations_apis_configs_test_iam_permissions(
976 &self,
977 request: ApigatewayTestIamPermissionsRequest,
978 resource: &str,
979 ) -> ProjectLocationApiConfigTestIamPermissionCall<'a, C> {
980 ProjectLocationApiConfigTestIamPermissionCall {
981 hub: self.hub,
982 _request: request,
983 _resource: resource.to_string(),
984 _delegate: Default::default(),
985 _additional_params: Default::default(),
986 _scopes: Default::default(),
987 }
988 }
989
990 /// Create a builder to help you perform the following task:
991 ///
992 /// Creates a new Api in a given project and location.
993 ///
994 /// # Arguments
995 ///
996 /// * `request` - No description provided.
997 /// * `parent` - Required. Parent resource of the API, of the form: `projects/*/locations/global`
998 pub fn locations_apis_create(
999 &self,
1000 request: ApigatewayApi,
1001 parent: &str,
1002 ) -> ProjectLocationApiCreateCall<'a, C> {
1003 ProjectLocationApiCreateCall {
1004 hub: self.hub,
1005 _request: request,
1006 _parent: parent.to_string(),
1007 _api_id: Default::default(),
1008 _delegate: Default::default(),
1009 _additional_params: Default::default(),
1010 _scopes: Default::default(),
1011 }
1012 }
1013
1014 /// Create a builder to help you perform the following task:
1015 ///
1016 /// Deletes a single Api.
1017 ///
1018 /// # Arguments
1019 ///
1020 /// * `name` - Required. Resource name of the form: `projects/*/locations/global/apis/*`
1021 pub fn locations_apis_delete(&self, name: &str) -> ProjectLocationApiDeleteCall<'a, C> {
1022 ProjectLocationApiDeleteCall {
1023 hub: self.hub,
1024 _name: name.to_string(),
1025 _delegate: Default::default(),
1026 _additional_params: Default::default(),
1027 _scopes: Default::default(),
1028 }
1029 }
1030
1031 /// Create a builder to help you perform the following task:
1032 ///
1033 /// Gets details of a single Api.
1034 ///
1035 /// # Arguments
1036 ///
1037 /// * `name` - Required. Resource name of the form: `projects/*/locations/global/apis/*`
1038 pub fn locations_apis_get(&self, name: &str) -> ProjectLocationApiGetCall<'a, C> {
1039 ProjectLocationApiGetCall {
1040 hub: self.hub,
1041 _name: name.to_string(),
1042 _delegate: Default::default(),
1043 _additional_params: Default::default(),
1044 _scopes: Default::default(),
1045 }
1046 }
1047
1048 /// Create a builder to help you perform the following task:
1049 ///
1050 /// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
1051 ///
1052 /// # Arguments
1053 ///
1054 /// * `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.
1055 pub fn locations_apis_get_iam_policy(
1056 &self,
1057 resource: &str,
1058 ) -> ProjectLocationApiGetIamPolicyCall<'a, C> {
1059 ProjectLocationApiGetIamPolicyCall {
1060 hub: self.hub,
1061 _resource: resource.to_string(),
1062 _options_requested_policy_version: Default::default(),
1063 _delegate: Default::default(),
1064 _additional_params: Default::default(),
1065 _scopes: Default::default(),
1066 }
1067 }
1068
1069 /// Create a builder to help you perform the following task:
1070 ///
1071 /// Lists Apis in a given project and location.
1072 ///
1073 /// # Arguments
1074 ///
1075 /// * `parent` - Required. Parent resource of the API, of the form: `projects/*/locations/global`
1076 pub fn locations_apis_list(&self, parent: &str) -> ProjectLocationApiListCall<'a, C> {
1077 ProjectLocationApiListCall {
1078 hub: self.hub,
1079 _parent: parent.to_string(),
1080 _page_token: Default::default(),
1081 _page_size: Default::default(),
1082 _order_by: Default::default(),
1083 _filter: Default::default(),
1084 _delegate: Default::default(),
1085 _additional_params: Default::default(),
1086 _scopes: Default::default(),
1087 }
1088 }
1089
1090 /// Create a builder to help you perform the following task:
1091 ///
1092 /// Updates the parameters of a single Api.
1093 ///
1094 /// # Arguments
1095 ///
1096 /// * `request` - No description provided.
1097 /// * `name` - Output only. Resource name of the API. Format: projects/{project}/locations/global/apis/{api}
1098 pub fn locations_apis_patch(
1099 &self,
1100 request: ApigatewayApi,
1101 name: &str,
1102 ) -> ProjectLocationApiPatchCall<'a, C> {
1103 ProjectLocationApiPatchCall {
1104 hub: self.hub,
1105 _request: request,
1106 _name: name.to_string(),
1107 _update_mask: Default::default(),
1108 _delegate: Default::default(),
1109 _additional_params: Default::default(),
1110 _scopes: Default::default(),
1111 }
1112 }
1113
1114 /// Create a builder to help you perform the following task:
1115 ///
1116 /// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
1117 ///
1118 /// # Arguments
1119 ///
1120 /// * `request` - No description provided.
1121 /// * `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.
1122 pub fn locations_apis_set_iam_policy(
1123 &self,
1124 request: ApigatewaySetIamPolicyRequest,
1125 resource: &str,
1126 ) -> ProjectLocationApiSetIamPolicyCall<'a, C> {
1127 ProjectLocationApiSetIamPolicyCall {
1128 hub: self.hub,
1129 _request: request,
1130 _resource: resource.to_string(),
1131 _delegate: Default::default(),
1132 _additional_params: Default::default(),
1133 _scopes: Default::default(),
1134 }
1135 }
1136
1137 /// Create a builder to help you perform the following task:
1138 ///
1139 /// 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.
1140 ///
1141 /// # Arguments
1142 ///
1143 /// * `request` - No description provided.
1144 /// * `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.
1145 pub fn locations_apis_test_iam_permissions(
1146 &self,
1147 request: ApigatewayTestIamPermissionsRequest,
1148 resource: &str,
1149 ) -> ProjectLocationApiTestIamPermissionCall<'a, C> {
1150 ProjectLocationApiTestIamPermissionCall {
1151 hub: self.hub,
1152 _request: request,
1153 _resource: resource.to_string(),
1154 _delegate: Default::default(),
1155 _additional_params: Default::default(),
1156 _scopes: Default::default(),
1157 }
1158 }
1159
1160 /// Create a builder to help you perform the following task:
1161 ///
1162 /// Creates a new Gateway in a given project and location.
1163 ///
1164 /// # Arguments
1165 ///
1166 /// * `request` - No description provided.
1167 /// * `parent` - Required. Parent resource of the Gateway, of the form: `projects/*/locations/*`
1168 pub fn locations_gateways_create(
1169 &self,
1170 request: ApigatewayGateway,
1171 parent: &str,
1172 ) -> ProjectLocationGatewayCreateCall<'a, C> {
1173 ProjectLocationGatewayCreateCall {
1174 hub: self.hub,
1175 _request: request,
1176 _parent: parent.to_string(),
1177 _gateway_id: Default::default(),
1178 _delegate: Default::default(),
1179 _additional_params: Default::default(),
1180 _scopes: Default::default(),
1181 }
1182 }
1183
1184 /// Create a builder to help you perform the following task:
1185 ///
1186 /// Deletes a single Gateway.
1187 ///
1188 /// # Arguments
1189 ///
1190 /// * `name` - Required. Resource name of the form: `projects/*/locations/*/gateways/*`
1191 pub fn locations_gateways_delete(&self, name: &str) -> ProjectLocationGatewayDeleteCall<'a, C> {
1192 ProjectLocationGatewayDeleteCall {
1193 hub: self.hub,
1194 _name: name.to_string(),
1195 _delegate: Default::default(),
1196 _additional_params: Default::default(),
1197 _scopes: Default::default(),
1198 }
1199 }
1200
1201 /// Create a builder to help you perform the following task:
1202 ///
1203 /// Gets details of a single Gateway.
1204 ///
1205 /// # Arguments
1206 ///
1207 /// * `name` - Required. Resource name of the form: `projects/*/locations/*/gateways/*`
1208 pub fn locations_gateways_get(&self, name: &str) -> ProjectLocationGatewayGetCall<'a, C> {
1209 ProjectLocationGatewayGetCall {
1210 hub: self.hub,
1211 _name: name.to_string(),
1212 _delegate: Default::default(),
1213 _additional_params: Default::default(),
1214 _scopes: Default::default(),
1215 }
1216 }
1217
1218 /// Create a builder to help you perform the following task:
1219 ///
1220 /// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
1221 ///
1222 /// # Arguments
1223 ///
1224 /// * `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.
1225 pub fn locations_gateways_get_iam_policy(
1226 &self,
1227 resource: &str,
1228 ) -> ProjectLocationGatewayGetIamPolicyCall<'a, C> {
1229 ProjectLocationGatewayGetIamPolicyCall {
1230 hub: self.hub,
1231 _resource: resource.to_string(),
1232 _options_requested_policy_version: Default::default(),
1233 _delegate: Default::default(),
1234 _additional_params: Default::default(),
1235 _scopes: Default::default(),
1236 }
1237 }
1238
1239 /// Create a builder to help you perform the following task:
1240 ///
1241 /// Lists Gateways in a given project and location.
1242 ///
1243 /// # Arguments
1244 ///
1245 /// * `parent` - Required. Parent resource of the Gateway, of the form: `projects/*/locations/*`
1246 pub fn locations_gateways_list(&self, parent: &str) -> ProjectLocationGatewayListCall<'a, C> {
1247 ProjectLocationGatewayListCall {
1248 hub: self.hub,
1249 _parent: parent.to_string(),
1250 _page_token: Default::default(),
1251 _page_size: Default::default(),
1252 _order_by: Default::default(),
1253 _filter: Default::default(),
1254 _delegate: Default::default(),
1255 _additional_params: Default::default(),
1256 _scopes: Default::default(),
1257 }
1258 }
1259
1260 /// Create a builder to help you perform the following task:
1261 ///
1262 /// Updates the parameters of a single Gateway.
1263 ///
1264 /// # Arguments
1265 ///
1266 /// * `request` - No description provided.
1267 /// * `name` - Output only. Resource name of the Gateway. Format: projects/{project}/locations/{location}/gateways/{gateway}
1268 pub fn locations_gateways_patch(
1269 &self,
1270 request: ApigatewayGateway,
1271 name: &str,
1272 ) -> ProjectLocationGatewayPatchCall<'a, C> {
1273 ProjectLocationGatewayPatchCall {
1274 hub: self.hub,
1275 _request: request,
1276 _name: name.to_string(),
1277 _update_mask: Default::default(),
1278 _delegate: Default::default(),
1279 _additional_params: Default::default(),
1280 _scopes: Default::default(),
1281 }
1282 }
1283
1284 /// Create a builder to help you perform the following task:
1285 ///
1286 /// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
1287 ///
1288 /// # Arguments
1289 ///
1290 /// * `request` - No description provided.
1291 /// * `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.
1292 pub fn locations_gateways_set_iam_policy(
1293 &self,
1294 request: ApigatewaySetIamPolicyRequest,
1295 resource: &str,
1296 ) -> ProjectLocationGatewaySetIamPolicyCall<'a, C> {
1297 ProjectLocationGatewaySetIamPolicyCall {
1298 hub: self.hub,
1299 _request: request,
1300 _resource: resource.to_string(),
1301 _delegate: Default::default(),
1302 _additional_params: Default::default(),
1303 _scopes: Default::default(),
1304 }
1305 }
1306
1307 /// Create a builder to help you perform the following task:
1308 ///
1309 /// 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.
1310 ///
1311 /// # Arguments
1312 ///
1313 /// * `request` - No description provided.
1314 /// * `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.
1315 pub fn locations_gateways_test_iam_permissions(
1316 &self,
1317 request: ApigatewayTestIamPermissionsRequest,
1318 resource: &str,
1319 ) -> ProjectLocationGatewayTestIamPermissionCall<'a, C> {
1320 ProjectLocationGatewayTestIamPermissionCall {
1321 hub: self.hub,
1322 _request: request,
1323 _resource: resource.to_string(),
1324 _delegate: Default::default(),
1325 _additional_params: Default::default(),
1326 _scopes: Default::default(),
1327 }
1328 }
1329
1330 /// Create a builder to help you perform the following task:
1331 ///
1332 /// 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`.
1333 ///
1334 /// # Arguments
1335 ///
1336 /// * `request` - No description provided.
1337 /// * `name` - The name of the operation resource to be cancelled.
1338 pub fn locations_operations_cancel(
1339 &self,
1340 request: ApigatewayCancelOperationRequest,
1341 name: &str,
1342 ) -> ProjectLocationOperationCancelCall<'a, C> {
1343 ProjectLocationOperationCancelCall {
1344 hub: self.hub,
1345 _request: request,
1346 _name: name.to_string(),
1347 _delegate: Default::default(),
1348 _additional_params: Default::default(),
1349 _scopes: Default::default(),
1350 }
1351 }
1352
1353 /// Create a builder to help you perform the following task:
1354 ///
1355 /// 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`.
1356 ///
1357 /// # Arguments
1358 ///
1359 /// * `name` - The name of the operation resource to be deleted.
1360 pub fn locations_operations_delete(
1361 &self,
1362 name: &str,
1363 ) -> ProjectLocationOperationDeleteCall<'a, C> {
1364 ProjectLocationOperationDeleteCall {
1365 hub: self.hub,
1366 _name: name.to_string(),
1367 _delegate: Default::default(),
1368 _additional_params: Default::default(),
1369 _scopes: Default::default(),
1370 }
1371 }
1372
1373 /// Create a builder to help you perform the following task:
1374 ///
1375 /// 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.
1376 ///
1377 /// # Arguments
1378 ///
1379 /// * `name` - The name of the operation resource.
1380 pub fn locations_operations_get(&self, name: &str) -> ProjectLocationOperationGetCall<'a, C> {
1381 ProjectLocationOperationGetCall {
1382 hub: self.hub,
1383 _name: name.to_string(),
1384 _delegate: Default::default(),
1385 _additional_params: Default::default(),
1386 _scopes: Default::default(),
1387 }
1388 }
1389
1390 /// Create a builder to help you perform the following task:
1391 ///
1392 /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
1393 ///
1394 /// # Arguments
1395 ///
1396 /// * `name` - The name of the operation's parent resource.
1397 pub fn locations_operations_list(&self, name: &str) -> ProjectLocationOperationListCall<'a, C> {
1398 ProjectLocationOperationListCall {
1399 hub: self.hub,
1400 _name: name.to_string(),
1401 _return_partial_success: Default::default(),
1402 _page_token: Default::default(),
1403 _page_size: Default::default(),
1404 _filter: Default::default(),
1405 _delegate: Default::default(),
1406 _additional_params: Default::default(),
1407 _scopes: Default::default(),
1408 }
1409 }
1410
1411 /// Create a builder to help you perform the following task:
1412 ///
1413 /// Gets information about a location.
1414 ///
1415 /// # Arguments
1416 ///
1417 /// * `name` - Resource name for the location.
1418 pub fn locations_get(&self, name: &str) -> ProjectLocationGetCall<'a, C> {
1419 ProjectLocationGetCall {
1420 hub: self.hub,
1421 _name: name.to_string(),
1422 _delegate: Default::default(),
1423 _additional_params: Default::default(),
1424 _scopes: Default::default(),
1425 }
1426 }
1427
1428 /// Create a builder to help you perform the following task:
1429 ///
1430 /// Lists information about the supported locations for this service.
1431 ///
1432 /// # Arguments
1433 ///
1434 /// * `name` - The resource that owns the locations collection, if applicable.
1435 pub fn locations_list(&self, name: &str) -> ProjectLocationListCall<'a, C> {
1436 ProjectLocationListCall {
1437 hub: self.hub,
1438 _name: name.to_string(),
1439 _page_token: Default::default(),
1440 _page_size: Default::default(),
1441 _filter: Default::default(),
1442 _extra_location_types: Default::default(),
1443 _delegate: Default::default(),
1444 _additional_params: Default::default(),
1445 _scopes: Default::default(),
1446 }
1447 }
1448}
1449
1450// ###################
1451// CallBuilders ###
1452// #################
1453
1454/// Creates a new ApiConfig in a given project and location.
1455///
1456/// A builder for the *locations.apis.configs.create* method supported by a *project* resource.
1457/// It is not used directly, but through a [`ProjectMethods`] instance.
1458///
1459/// # Example
1460///
1461/// Instantiate a resource method builder
1462///
1463/// ```test_harness,no_run
1464/// # extern crate hyper;
1465/// # extern crate hyper_rustls;
1466/// # extern crate google_apigateway1 as apigateway1;
1467/// use apigateway1::api::ApigatewayApiConfig;
1468/// # async fn dox() {
1469/// # use apigateway1::{Apigateway, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1470///
1471/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1472/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1473/// # .with_native_roots()
1474/// # .unwrap()
1475/// # .https_only()
1476/// # .enable_http2()
1477/// # .build();
1478///
1479/// # let executor = hyper_util::rt::TokioExecutor::new();
1480/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1481/// # secret,
1482/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1483/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1484/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1485/// # ),
1486/// # ).build().await.unwrap();
1487///
1488/// # let client = hyper_util::client::legacy::Client::builder(
1489/// # hyper_util::rt::TokioExecutor::new()
1490/// # )
1491/// # .build(
1492/// # hyper_rustls::HttpsConnectorBuilder::new()
1493/// # .with_native_roots()
1494/// # .unwrap()
1495/// # .https_or_http()
1496/// # .enable_http2()
1497/// # .build()
1498/// # );
1499/// # let mut hub = Apigateway::new(client, auth);
1500/// // As the method needs a request, you would usually fill it with the desired information
1501/// // into the respective structure. Some of the parts shown here might not be applicable !
1502/// // Values shown here are possibly random and not representative !
1503/// let mut req = ApigatewayApiConfig::default();
1504///
1505/// // You can configure optional parameters by calling the respective setters at will, and
1506/// // execute the final call using `doit()`.
1507/// // Values shown here are possibly random and not representative !
1508/// let result = hub.projects().locations_apis_configs_create(req, "parent")
1509/// .api_config_id("sed")
1510/// .doit().await;
1511/// # }
1512/// ```
1513pub struct ProjectLocationApiConfigCreateCall<'a, C>
1514where
1515 C: 'a,
1516{
1517 hub: &'a Apigateway<C>,
1518 _request: ApigatewayApiConfig,
1519 _parent: String,
1520 _api_config_id: Option<String>,
1521 _delegate: Option<&'a mut dyn common::Delegate>,
1522 _additional_params: HashMap<String, String>,
1523 _scopes: BTreeSet<String>,
1524}
1525
1526impl<'a, C> common::CallBuilder for ProjectLocationApiConfigCreateCall<'a, C> {}
1527
1528impl<'a, C> ProjectLocationApiConfigCreateCall<'a, C>
1529where
1530 C: common::Connector,
1531{
1532 /// Perform the operation you have build so far.
1533 pub async fn doit(mut self) -> common::Result<(common::Response, ApigatewayOperation)> {
1534 use std::borrow::Cow;
1535 use std::io::{Read, Seek};
1536
1537 use common::{url::Params, ToParts};
1538 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1539
1540 let mut dd = common::DefaultDelegate;
1541 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1542 dlg.begin(common::MethodInfo {
1543 id: "apigateway.projects.locations.apis.configs.create",
1544 http_method: hyper::Method::POST,
1545 });
1546
1547 for &field in ["alt", "parent", "apiConfigId"].iter() {
1548 if self._additional_params.contains_key(field) {
1549 dlg.finished(false);
1550 return Err(common::Error::FieldClash(field));
1551 }
1552 }
1553
1554 let mut params = Params::with_capacity(5 + self._additional_params.len());
1555 params.push("parent", self._parent);
1556 if let Some(value) = self._api_config_id.as_ref() {
1557 params.push("apiConfigId", value);
1558 }
1559
1560 params.extend(self._additional_params.iter());
1561
1562 params.push("alt", "json");
1563 let mut url = self.hub._base_url.clone() + "v1/{+parent}/configs";
1564 if self._scopes.is_empty() {
1565 self._scopes
1566 .insert(Scope::CloudPlatform.as_ref().to_string());
1567 }
1568
1569 #[allow(clippy::single_element_loop)]
1570 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
1571 url = params.uri_replacement(url, param_name, find_this, true);
1572 }
1573 {
1574 let to_remove = ["parent"];
1575 params.remove_params(&to_remove);
1576 }
1577
1578 let url = params.parse_with_url(&url);
1579
1580 let mut json_mime_type = mime::APPLICATION_JSON;
1581 let mut request_value_reader = {
1582 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1583 common::remove_json_null_values(&mut value);
1584 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1585 serde_json::to_writer(&mut dst, &value).unwrap();
1586 dst
1587 };
1588 let request_size = request_value_reader
1589 .seek(std::io::SeekFrom::End(0))
1590 .unwrap();
1591 request_value_reader
1592 .seek(std::io::SeekFrom::Start(0))
1593 .unwrap();
1594
1595 loop {
1596 let token = match self
1597 .hub
1598 .auth
1599 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1600 .await
1601 {
1602 Ok(token) => token,
1603 Err(e) => match dlg.token(e) {
1604 Ok(token) => token,
1605 Err(e) => {
1606 dlg.finished(false);
1607 return Err(common::Error::MissingToken(e));
1608 }
1609 },
1610 };
1611 request_value_reader
1612 .seek(std::io::SeekFrom::Start(0))
1613 .unwrap();
1614 let mut req_result = {
1615 let client = &self.hub.client;
1616 dlg.pre_request();
1617 let mut req_builder = hyper::Request::builder()
1618 .method(hyper::Method::POST)
1619 .uri(url.as_str())
1620 .header(USER_AGENT, self.hub._user_agent.clone());
1621
1622 if let Some(token) = token.as_ref() {
1623 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1624 }
1625
1626 let request = req_builder
1627 .header(CONTENT_TYPE, json_mime_type.to_string())
1628 .header(CONTENT_LENGTH, request_size as u64)
1629 .body(common::to_body(
1630 request_value_reader.get_ref().clone().into(),
1631 ));
1632
1633 client.request(request.unwrap()).await
1634 };
1635
1636 match req_result {
1637 Err(err) => {
1638 if let common::Retry::After(d) = dlg.http_error(&err) {
1639 sleep(d).await;
1640 continue;
1641 }
1642 dlg.finished(false);
1643 return Err(common::Error::HttpError(err));
1644 }
1645 Ok(res) => {
1646 let (mut parts, body) = res.into_parts();
1647 let mut body = common::Body::new(body);
1648 if !parts.status.is_success() {
1649 let bytes = common::to_bytes(body).await.unwrap_or_default();
1650 let error = serde_json::from_str(&common::to_string(&bytes));
1651 let response = common::to_response(parts, bytes.into());
1652
1653 if let common::Retry::After(d) =
1654 dlg.http_failure(&response, error.as_ref().ok())
1655 {
1656 sleep(d).await;
1657 continue;
1658 }
1659
1660 dlg.finished(false);
1661
1662 return Err(match error {
1663 Ok(value) => common::Error::BadRequest(value),
1664 _ => common::Error::Failure(response),
1665 });
1666 }
1667 let response = {
1668 let bytes = common::to_bytes(body).await.unwrap_or_default();
1669 let encoded = common::to_string(&bytes);
1670 match serde_json::from_str(&encoded) {
1671 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1672 Err(error) => {
1673 dlg.response_json_decode_error(&encoded, &error);
1674 return Err(common::Error::JsonDecodeError(
1675 encoded.to_string(),
1676 error,
1677 ));
1678 }
1679 }
1680 };
1681
1682 dlg.finished(true);
1683 return Ok(response);
1684 }
1685 }
1686 }
1687 }
1688
1689 ///
1690 /// Sets the *request* property to the given value.
1691 ///
1692 /// Even though the property as already been set when instantiating this call,
1693 /// we provide this method for API completeness.
1694 pub fn request(
1695 mut self,
1696 new_value: ApigatewayApiConfig,
1697 ) -> ProjectLocationApiConfigCreateCall<'a, C> {
1698 self._request = new_value;
1699 self
1700 }
1701 /// Required. Parent resource of the API Config, of the form: `projects/*/locations/global/apis/*`
1702 ///
1703 /// Sets the *parent* path property to the given value.
1704 ///
1705 /// Even though the property as already been set when instantiating this call,
1706 /// we provide this method for API completeness.
1707 pub fn parent(mut self, new_value: &str) -> ProjectLocationApiConfigCreateCall<'a, C> {
1708 self._parent = new_value.to_string();
1709 self
1710 }
1711 /// Required. Identifier to assign to the API Config. Must be unique within scope of the parent resource.
1712 ///
1713 /// Sets the *api config id* query property to the given value.
1714 pub fn api_config_id(mut self, new_value: &str) -> ProjectLocationApiConfigCreateCall<'a, C> {
1715 self._api_config_id = Some(new_value.to_string());
1716 self
1717 }
1718 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1719 /// while executing the actual API request.
1720 ///
1721 /// ````text
1722 /// It should be used to handle progress information, and to implement a certain level of resilience.
1723 /// ````
1724 ///
1725 /// Sets the *delegate* property to the given value.
1726 pub fn delegate(
1727 mut self,
1728 new_value: &'a mut dyn common::Delegate,
1729 ) -> ProjectLocationApiConfigCreateCall<'a, C> {
1730 self._delegate = Some(new_value);
1731 self
1732 }
1733
1734 /// Set any additional parameter of the query string used in the request.
1735 /// It should be used to set parameters which are not yet available through their own
1736 /// setters.
1737 ///
1738 /// Please note that this method must not be used to set any of the known parameters
1739 /// which have their own setter method. If done anyway, the request will fail.
1740 ///
1741 /// # Additional Parameters
1742 ///
1743 /// * *$.xgafv* (query-string) - V1 error format.
1744 /// * *access_token* (query-string) - OAuth access token.
1745 /// * *alt* (query-string) - Data format for response.
1746 /// * *callback* (query-string) - JSONP
1747 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1748 /// * *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.
1749 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1750 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1751 /// * *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.
1752 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1753 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1754 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationApiConfigCreateCall<'a, C>
1755 where
1756 T: AsRef<str>,
1757 {
1758 self._additional_params
1759 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1760 self
1761 }
1762
1763 /// Identifies the authorization scope for the method you are building.
1764 ///
1765 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1766 /// [`Scope::CloudPlatform`].
1767 ///
1768 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1769 /// tokens for more than one scope.
1770 ///
1771 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1772 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1773 /// sufficient, a read-write scope will do as well.
1774 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationApiConfigCreateCall<'a, C>
1775 where
1776 St: AsRef<str>,
1777 {
1778 self._scopes.insert(String::from(scope.as_ref()));
1779 self
1780 }
1781 /// Identifies the authorization scope(s) for the method you are building.
1782 ///
1783 /// See [`Self::add_scope()`] for details.
1784 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationApiConfigCreateCall<'a, C>
1785 where
1786 I: IntoIterator<Item = St>,
1787 St: AsRef<str>,
1788 {
1789 self._scopes
1790 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1791 self
1792 }
1793
1794 /// Removes all scopes, and no default scope will be used either.
1795 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1796 /// for details).
1797 pub fn clear_scopes(mut self) -> ProjectLocationApiConfigCreateCall<'a, C> {
1798 self._scopes.clear();
1799 self
1800 }
1801}
1802
1803/// Deletes a single ApiConfig.
1804///
1805/// A builder for the *locations.apis.configs.delete* method supported by a *project* resource.
1806/// It is not used directly, but through a [`ProjectMethods`] instance.
1807///
1808/// # Example
1809///
1810/// Instantiate a resource method builder
1811///
1812/// ```test_harness,no_run
1813/// # extern crate hyper;
1814/// # extern crate hyper_rustls;
1815/// # extern crate google_apigateway1 as apigateway1;
1816/// # async fn dox() {
1817/// # use apigateway1::{Apigateway, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1818///
1819/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1820/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1821/// # .with_native_roots()
1822/// # .unwrap()
1823/// # .https_only()
1824/// # .enable_http2()
1825/// # .build();
1826///
1827/// # let executor = hyper_util::rt::TokioExecutor::new();
1828/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1829/// # secret,
1830/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1831/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1832/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1833/// # ),
1834/// # ).build().await.unwrap();
1835///
1836/// # let client = hyper_util::client::legacy::Client::builder(
1837/// # hyper_util::rt::TokioExecutor::new()
1838/// # )
1839/// # .build(
1840/// # hyper_rustls::HttpsConnectorBuilder::new()
1841/// # .with_native_roots()
1842/// # .unwrap()
1843/// # .https_or_http()
1844/// # .enable_http2()
1845/// # .build()
1846/// # );
1847/// # let mut hub = Apigateway::new(client, auth);
1848/// // You can configure optional parameters by calling the respective setters at will, and
1849/// // execute the final call using `doit()`.
1850/// // Values shown here are possibly random and not representative !
1851/// let result = hub.projects().locations_apis_configs_delete("name")
1852/// .doit().await;
1853/// # }
1854/// ```
1855pub struct ProjectLocationApiConfigDeleteCall<'a, C>
1856where
1857 C: 'a,
1858{
1859 hub: &'a Apigateway<C>,
1860 _name: String,
1861 _delegate: Option<&'a mut dyn common::Delegate>,
1862 _additional_params: HashMap<String, String>,
1863 _scopes: BTreeSet<String>,
1864}
1865
1866impl<'a, C> common::CallBuilder for ProjectLocationApiConfigDeleteCall<'a, C> {}
1867
1868impl<'a, C> ProjectLocationApiConfigDeleteCall<'a, C>
1869where
1870 C: common::Connector,
1871{
1872 /// Perform the operation you have build so far.
1873 pub async fn doit(mut self) -> common::Result<(common::Response, ApigatewayOperation)> {
1874 use std::borrow::Cow;
1875 use std::io::{Read, Seek};
1876
1877 use common::{url::Params, ToParts};
1878 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1879
1880 let mut dd = common::DefaultDelegate;
1881 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1882 dlg.begin(common::MethodInfo {
1883 id: "apigateway.projects.locations.apis.configs.delete",
1884 http_method: hyper::Method::DELETE,
1885 });
1886
1887 for &field in ["alt", "name"].iter() {
1888 if self._additional_params.contains_key(field) {
1889 dlg.finished(false);
1890 return Err(common::Error::FieldClash(field));
1891 }
1892 }
1893
1894 let mut params = Params::with_capacity(3 + self._additional_params.len());
1895 params.push("name", self._name);
1896
1897 params.extend(self._additional_params.iter());
1898
1899 params.push("alt", "json");
1900 let mut url = self.hub._base_url.clone() + "v1/{+name}";
1901 if self._scopes.is_empty() {
1902 self._scopes
1903 .insert(Scope::CloudPlatform.as_ref().to_string());
1904 }
1905
1906 #[allow(clippy::single_element_loop)]
1907 for &(find_this, param_name) in [("{+name}", "name")].iter() {
1908 url = params.uri_replacement(url, param_name, find_this, true);
1909 }
1910 {
1911 let to_remove = ["name"];
1912 params.remove_params(&to_remove);
1913 }
1914
1915 let url = params.parse_with_url(&url);
1916
1917 loop {
1918 let token = match self
1919 .hub
1920 .auth
1921 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1922 .await
1923 {
1924 Ok(token) => token,
1925 Err(e) => match dlg.token(e) {
1926 Ok(token) => token,
1927 Err(e) => {
1928 dlg.finished(false);
1929 return Err(common::Error::MissingToken(e));
1930 }
1931 },
1932 };
1933 let mut req_result = {
1934 let client = &self.hub.client;
1935 dlg.pre_request();
1936 let mut req_builder = hyper::Request::builder()
1937 .method(hyper::Method::DELETE)
1938 .uri(url.as_str())
1939 .header(USER_AGENT, self.hub._user_agent.clone());
1940
1941 if let Some(token) = token.as_ref() {
1942 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1943 }
1944
1945 let request = req_builder
1946 .header(CONTENT_LENGTH, 0_u64)
1947 .body(common::to_body::<String>(None));
1948
1949 client.request(request.unwrap()).await
1950 };
1951
1952 match req_result {
1953 Err(err) => {
1954 if let common::Retry::After(d) = dlg.http_error(&err) {
1955 sleep(d).await;
1956 continue;
1957 }
1958 dlg.finished(false);
1959 return Err(common::Error::HttpError(err));
1960 }
1961 Ok(res) => {
1962 let (mut parts, body) = res.into_parts();
1963 let mut body = common::Body::new(body);
1964 if !parts.status.is_success() {
1965 let bytes = common::to_bytes(body).await.unwrap_or_default();
1966 let error = serde_json::from_str(&common::to_string(&bytes));
1967 let response = common::to_response(parts, bytes.into());
1968
1969 if let common::Retry::After(d) =
1970 dlg.http_failure(&response, error.as_ref().ok())
1971 {
1972 sleep(d).await;
1973 continue;
1974 }
1975
1976 dlg.finished(false);
1977
1978 return Err(match error {
1979 Ok(value) => common::Error::BadRequest(value),
1980 _ => common::Error::Failure(response),
1981 });
1982 }
1983 let response = {
1984 let bytes = common::to_bytes(body).await.unwrap_or_default();
1985 let encoded = common::to_string(&bytes);
1986 match serde_json::from_str(&encoded) {
1987 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1988 Err(error) => {
1989 dlg.response_json_decode_error(&encoded, &error);
1990 return Err(common::Error::JsonDecodeError(
1991 encoded.to_string(),
1992 error,
1993 ));
1994 }
1995 }
1996 };
1997
1998 dlg.finished(true);
1999 return Ok(response);
2000 }
2001 }
2002 }
2003 }
2004
2005 /// Required. Resource name of the form: `projects/*/locations/global/apis/*/configs/*`
2006 ///
2007 /// Sets the *name* path property to the given value.
2008 ///
2009 /// Even though the property as already been set when instantiating this call,
2010 /// we provide this method for API completeness.
2011 pub fn name(mut self, new_value: &str) -> ProjectLocationApiConfigDeleteCall<'a, C> {
2012 self._name = new_value.to_string();
2013 self
2014 }
2015 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2016 /// while executing the actual API request.
2017 ///
2018 /// ````text
2019 /// It should be used to handle progress information, and to implement a certain level of resilience.
2020 /// ````
2021 ///
2022 /// Sets the *delegate* property to the given value.
2023 pub fn delegate(
2024 mut self,
2025 new_value: &'a mut dyn common::Delegate,
2026 ) -> ProjectLocationApiConfigDeleteCall<'a, C> {
2027 self._delegate = Some(new_value);
2028 self
2029 }
2030
2031 /// Set any additional parameter of the query string used in the request.
2032 /// It should be used to set parameters which are not yet available through their own
2033 /// setters.
2034 ///
2035 /// Please note that this method must not be used to set any of the known parameters
2036 /// which have their own setter method. If done anyway, the request will fail.
2037 ///
2038 /// # Additional Parameters
2039 ///
2040 /// * *$.xgafv* (query-string) - V1 error format.
2041 /// * *access_token* (query-string) - OAuth access token.
2042 /// * *alt* (query-string) - Data format for response.
2043 /// * *callback* (query-string) - JSONP
2044 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2045 /// * *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.
2046 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2047 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2048 /// * *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.
2049 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2050 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2051 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationApiConfigDeleteCall<'a, C>
2052 where
2053 T: AsRef<str>,
2054 {
2055 self._additional_params
2056 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2057 self
2058 }
2059
2060 /// Identifies the authorization scope for the method you are building.
2061 ///
2062 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2063 /// [`Scope::CloudPlatform`].
2064 ///
2065 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2066 /// tokens for more than one scope.
2067 ///
2068 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2069 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2070 /// sufficient, a read-write scope will do as well.
2071 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationApiConfigDeleteCall<'a, C>
2072 where
2073 St: AsRef<str>,
2074 {
2075 self._scopes.insert(String::from(scope.as_ref()));
2076 self
2077 }
2078 /// Identifies the authorization scope(s) for the method you are building.
2079 ///
2080 /// See [`Self::add_scope()`] for details.
2081 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationApiConfigDeleteCall<'a, C>
2082 where
2083 I: IntoIterator<Item = St>,
2084 St: AsRef<str>,
2085 {
2086 self._scopes
2087 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2088 self
2089 }
2090
2091 /// Removes all scopes, and no default scope will be used either.
2092 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2093 /// for details).
2094 pub fn clear_scopes(mut self) -> ProjectLocationApiConfigDeleteCall<'a, C> {
2095 self._scopes.clear();
2096 self
2097 }
2098}
2099
2100/// Gets details of a single ApiConfig.
2101///
2102/// A builder for the *locations.apis.configs.get* method supported by a *project* resource.
2103/// It is not used directly, but through a [`ProjectMethods`] instance.
2104///
2105/// # Example
2106///
2107/// Instantiate a resource method builder
2108///
2109/// ```test_harness,no_run
2110/// # extern crate hyper;
2111/// # extern crate hyper_rustls;
2112/// # extern crate google_apigateway1 as apigateway1;
2113/// # async fn dox() {
2114/// # use apigateway1::{Apigateway, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2115///
2116/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2117/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2118/// # .with_native_roots()
2119/// # .unwrap()
2120/// # .https_only()
2121/// # .enable_http2()
2122/// # .build();
2123///
2124/// # let executor = hyper_util::rt::TokioExecutor::new();
2125/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2126/// # secret,
2127/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2128/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2129/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2130/// # ),
2131/// # ).build().await.unwrap();
2132///
2133/// # let client = hyper_util::client::legacy::Client::builder(
2134/// # hyper_util::rt::TokioExecutor::new()
2135/// # )
2136/// # .build(
2137/// # hyper_rustls::HttpsConnectorBuilder::new()
2138/// # .with_native_roots()
2139/// # .unwrap()
2140/// # .https_or_http()
2141/// # .enable_http2()
2142/// # .build()
2143/// # );
2144/// # let mut hub = Apigateway::new(client, auth);
2145/// // You can configure optional parameters by calling the respective setters at will, and
2146/// // execute the final call using `doit()`.
2147/// // Values shown here are possibly random and not representative !
2148/// let result = hub.projects().locations_apis_configs_get("name")
2149/// .view("amet.")
2150/// .doit().await;
2151/// # }
2152/// ```
2153pub struct ProjectLocationApiConfigGetCall<'a, C>
2154where
2155 C: 'a,
2156{
2157 hub: &'a Apigateway<C>,
2158 _name: String,
2159 _view: Option<String>,
2160 _delegate: Option<&'a mut dyn common::Delegate>,
2161 _additional_params: HashMap<String, String>,
2162 _scopes: BTreeSet<String>,
2163}
2164
2165impl<'a, C> common::CallBuilder for ProjectLocationApiConfigGetCall<'a, C> {}
2166
2167impl<'a, C> ProjectLocationApiConfigGetCall<'a, C>
2168where
2169 C: common::Connector,
2170{
2171 /// Perform the operation you have build so far.
2172 pub async fn doit(mut self) -> common::Result<(common::Response, ApigatewayApiConfig)> {
2173 use std::borrow::Cow;
2174 use std::io::{Read, Seek};
2175
2176 use common::{url::Params, ToParts};
2177 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2178
2179 let mut dd = common::DefaultDelegate;
2180 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2181 dlg.begin(common::MethodInfo {
2182 id: "apigateway.projects.locations.apis.configs.get",
2183 http_method: hyper::Method::GET,
2184 });
2185
2186 for &field in ["alt", "name", "view"].iter() {
2187 if self._additional_params.contains_key(field) {
2188 dlg.finished(false);
2189 return Err(common::Error::FieldClash(field));
2190 }
2191 }
2192
2193 let mut params = Params::with_capacity(4 + self._additional_params.len());
2194 params.push("name", self._name);
2195 if let Some(value) = self._view.as_ref() {
2196 params.push("view", value);
2197 }
2198
2199 params.extend(self._additional_params.iter());
2200
2201 params.push("alt", "json");
2202 let mut url = self.hub._base_url.clone() + "v1/{+name}";
2203 if self._scopes.is_empty() {
2204 self._scopes
2205 .insert(Scope::CloudPlatform.as_ref().to_string());
2206 }
2207
2208 #[allow(clippy::single_element_loop)]
2209 for &(find_this, param_name) in [("{+name}", "name")].iter() {
2210 url = params.uri_replacement(url, param_name, find_this, true);
2211 }
2212 {
2213 let to_remove = ["name"];
2214 params.remove_params(&to_remove);
2215 }
2216
2217 let url = params.parse_with_url(&url);
2218
2219 loop {
2220 let token = match self
2221 .hub
2222 .auth
2223 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2224 .await
2225 {
2226 Ok(token) => token,
2227 Err(e) => match dlg.token(e) {
2228 Ok(token) => token,
2229 Err(e) => {
2230 dlg.finished(false);
2231 return Err(common::Error::MissingToken(e));
2232 }
2233 },
2234 };
2235 let mut req_result = {
2236 let client = &self.hub.client;
2237 dlg.pre_request();
2238 let mut req_builder = hyper::Request::builder()
2239 .method(hyper::Method::GET)
2240 .uri(url.as_str())
2241 .header(USER_AGENT, self.hub._user_agent.clone());
2242
2243 if let Some(token) = token.as_ref() {
2244 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2245 }
2246
2247 let request = req_builder
2248 .header(CONTENT_LENGTH, 0_u64)
2249 .body(common::to_body::<String>(None));
2250
2251 client.request(request.unwrap()).await
2252 };
2253
2254 match req_result {
2255 Err(err) => {
2256 if let common::Retry::After(d) = dlg.http_error(&err) {
2257 sleep(d).await;
2258 continue;
2259 }
2260 dlg.finished(false);
2261 return Err(common::Error::HttpError(err));
2262 }
2263 Ok(res) => {
2264 let (mut parts, body) = res.into_parts();
2265 let mut body = common::Body::new(body);
2266 if !parts.status.is_success() {
2267 let bytes = common::to_bytes(body).await.unwrap_or_default();
2268 let error = serde_json::from_str(&common::to_string(&bytes));
2269 let response = common::to_response(parts, bytes.into());
2270
2271 if let common::Retry::After(d) =
2272 dlg.http_failure(&response, error.as_ref().ok())
2273 {
2274 sleep(d).await;
2275 continue;
2276 }
2277
2278 dlg.finished(false);
2279
2280 return Err(match error {
2281 Ok(value) => common::Error::BadRequest(value),
2282 _ => common::Error::Failure(response),
2283 });
2284 }
2285 let response = {
2286 let bytes = common::to_bytes(body).await.unwrap_or_default();
2287 let encoded = common::to_string(&bytes);
2288 match serde_json::from_str(&encoded) {
2289 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2290 Err(error) => {
2291 dlg.response_json_decode_error(&encoded, &error);
2292 return Err(common::Error::JsonDecodeError(
2293 encoded.to_string(),
2294 error,
2295 ));
2296 }
2297 }
2298 };
2299
2300 dlg.finished(true);
2301 return Ok(response);
2302 }
2303 }
2304 }
2305 }
2306
2307 /// Required. Resource name of the form: `projects/*/locations/global/apis/*/configs/*`
2308 ///
2309 /// Sets the *name* path property to the given value.
2310 ///
2311 /// Even though the property as already been set when instantiating this call,
2312 /// we provide this method for API completeness.
2313 pub fn name(mut self, new_value: &str) -> ProjectLocationApiConfigGetCall<'a, C> {
2314 self._name = new_value.to_string();
2315 self
2316 }
2317 /// Specifies which fields of the API Config are returned in the response. Defaults to `BASIC` view.
2318 ///
2319 /// Sets the *view* query property to the given value.
2320 pub fn view(mut self, new_value: &str) -> ProjectLocationApiConfigGetCall<'a, C> {
2321 self._view = Some(new_value.to_string());
2322 self
2323 }
2324 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2325 /// while executing the actual API request.
2326 ///
2327 /// ````text
2328 /// It should be used to handle progress information, and to implement a certain level of resilience.
2329 /// ````
2330 ///
2331 /// Sets the *delegate* property to the given value.
2332 pub fn delegate(
2333 mut self,
2334 new_value: &'a mut dyn common::Delegate,
2335 ) -> ProjectLocationApiConfigGetCall<'a, C> {
2336 self._delegate = Some(new_value);
2337 self
2338 }
2339
2340 /// Set any additional parameter of the query string used in the request.
2341 /// It should be used to set parameters which are not yet available through their own
2342 /// setters.
2343 ///
2344 /// Please note that this method must not be used to set any of the known parameters
2345 /// which have their own setter method. If done anyway, the request will fail.
2346 ///
2347 /// # Additional Parameters
2348 ///
2349 /// * *$.xgafv* (query-string) - V1 error format.
2350 /// * *access_token* (query-string) - OAuth access token.
2351 /// * *alt* (query-string) - Data format for response.
2352 /// * *callback* (query-string) - JSONP
2353 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2354 /// * *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.
2355 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2356 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2357 /// * *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.
2358 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2359 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2360 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationApiConfigGetCall<'a, C>
2361 where
2362 T: AsRef<str>,
2363 {
2364 self._additional_params
2365 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2366 self
2367 }
2368
2369 /// Identifies the authorization scope for the method you are building.
2370 ///
2371 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2372 /// [`Scope::CloudPlatform`].
2373 ///
2374 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2375 /// tokens for more than one scope.
2376 ///
2377 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2378 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2379 /// sufficient, a read-write scope will do as well.
2380 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationApiConfigGetCall<'a, C>
2381 where
2382 St: AsRef<str>,
2383 {
2384 self._scopes.insert(String::from(scope.as_ref()));
2385 self
2386 }
2387 /// Identifies the authorization scope(s) for the method you are building.
2388 ///
2389 /// See [`Self::add_scope()`] for details.
2390 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationApiConfigGetCall<'a, C>
2391 where
2392 I: IntoIterator<Item = St>,
2393 St: AsRef<str>,
2394 {
2395 self._scopes
2396 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2397 self
2398 }
2399
2400 /// Removes all scopes, and no default scope will be used either.
2401 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2402 /// for details).
2403 pub fn clear_scopes(mut self) -> ProjectLocationApiConfigGetCall<'a, C> {
2404 self._scopes.clear();
2405 self
2406 }
2407}
2408
2409/// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
2410///
2411/// A builder for the *locations.apis.configs.getIamPolicy* method supported by a *project* resource.
2412/// It is not used directly, but through a [`ProjectMethods`] instance.
2413///
2414/// # Example
2415///
2416/// Instantiate a resource method builder
2417///
2418/// ```test_harness,no_run
2419/// # extern crate hyper;
2420/// # extern crate hyper_rustls;
2421/// # extern crate google_apigateway1 as apigateway1;
2422/// # async fn dox() {
2423/// # use apigateway1::{Apigateway, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2424///
2425/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2426/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2427/// # .with_native_roots()
2428/// # .unwrap()
2429/// # .https_only()
2430/// # .enable_http2()
2431/// # .build();
2432///
2433/// # let executor = hyper_util::rt::TokioExecutor::new();
2434/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2435/// # secret,
2436/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2437/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2438/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2439/// # ),
2440/// # ).build().await.unwrap();
2441///
2442/// # let client = hyper_util::client::legacy::Client::builder(
2443/// # hyper_util::rt::TokioExecutor::new()
2444/// # )
2445/// # .build(
2446/// # hyper_rustls::HttpsConnectorBuilder::new()
2447/// # .with_native_roots()
2448/// # .unwrap()
2449/// # .https_or_http()
2450/// # .enable_http2()
2451/// # .build()
2452/// # );
2453/// # let mut hub = Apigateway::new(client, auth);
2454/// // You can configure optional parameters by calling the respective setters at will, and
2455/// // execute the final call using `doit()`.
2456/// // Values shown here are possibly random and not representative !
2457/// let result = hub.projects().locations_apis_configs_get_iam_policy("resource")
2458/// .options_requested_policy_version(-55)
2459/// .doit().await;
2460/// # }
2461/// ```
2462pub struct ProjectLocationApiConfigGetIamPolicyCall<'a, C>
2463where
2464 C: 'a,
2465{
2466 hub: &'a Apigateway<C>,
2467 _resource: String,
2468 _options_requested_policy_version: Option<i32>,
2469 _delegate: Option<&'a mut dyn common::Delegate>,
2470 _additional_params: HashMap<String, String>,
2471 _scopes: BTreeSet<String>,
2472}
2473
2474impl<'a, C> common::CallBuilder for ProjectLocationApiConfigGetIamPolicyCall<'a, C> {}
2475
2476impl<'a, C> ProjectLocationApiConfigGetIamPolicyCall<'a, C>
2477where
2478 C: common::Connector,
2479{
2480 /// Perform the operation you have build so far.
2481 pub async fn doit(mut self) -> common::Result<(common::Response, ApigatewayPolicy)> {
2482 use std::borrow::Cow;
2483 use std::io::{Read, Seek};
2484
2485 use common::{url::Params, ToParts};
2486 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2487
2488 let mut dd = common::DefaultDelegate;
2489 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2490 dlg.begin(common::MethodInfo {
2491 id: "apigateway.projects.locations.apis.configs.getIamPolicy",
2492 http_method: hyper::Method::GET,
2493 });
2494
2495 for &field in ["alt", "resource", "options.requestedPolicyVersion"].iter() {
2496 if self._additional_params.contains_key(field) {
2497 dlg.finished(false);
2498 return Err(common::Error::FieldClash(field));
2499 }
2500 }
2501
2502 let mut params = Params::with_capacity(4 + self._additional_params.len());
2503 params.push("resource", self._resource);
2504 if let Some(value) = self._options_requested_policy_version.as_ref() {
2505 params.push("options.requestedPolicyVersion", value.to_string());
2506 }
2507
2508 params.extend(self._additional_params.iter());
2509
2510 params.push("alt", "json");
2511 let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
2512 if self._scopes.is_empty() {
2513 self._scopes
2514 .insert(Scope::CloudPlatform.as_ref().to_string());
2515 }
2516
2517 #[allow(clippy::single_element_loop)]
2518 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
2519 url = params.uri_replacement(url, param_name, find_this, true);
2520 }
2521 {
2522 let to_remove = ["resource"];
2523 params.remove_params(&to_remove);
2524 }
2525
2526 let url = params.parse_with_url(&url);
2527
2528 loop {
2529 let token = match self
2530 .hub
2531 .auth
2532 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2533 .await
2534 {
2535 Ok(token) => token,
2536 Err(e) => match dlg.token(e) {
2537 Ok(token) => token,
2538 Err(e) => {
2539 dlg.finished(false);
2540 return Err(common::Error::MissingToken(e));
2541 }
2542 },
2543 };
2544 let mut req_result = {
2545 let client = &self.hub.client;
2546 dlg.pre_request();
2547 let mut req_builder = hyper::Request::builder()
2548 .method(hyper::Method::GET)
2549 .uri(url.as_str())
2550 .header(USER_AGENT, self.hub._user_agent.clone());
2551
2552 if let Some(token) = token.as_ref() {
2553 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2554 }
2555
2556 let request = req_builder
2557 .header(CONTENT_LENGTH, 0_u64)
2558 .body(common::to_body::<String>(None));
2559
2560 client.request(request.unwrap()).await
2561 };
2562
2563 match req_result {
2564 Err(err) => {
2565 if let common::Retry::After(d) = dlg.http_error(&err) {
2566 sleep(d).await;
2567 continue;
2568 }
2569 dlg.finished(false);
2570 return Err(common::Error::HttpError(err));
2571 }
2572 Ok(res) => {
2573 let (mut parts, body) = res.into_parts();
2574 let mut body = common::Body::new(body);
2575 if !parts.status.is_success() {
2576 let bytes = common::to_bytes(body).await.unwrap_or_default();
2577 let error = serde_json::from_str(&common::to_string(&bytes));
2578 let response = common::to_response(parts, bytes.into());
2579
2580 if let common::Retry::After(d) =
2581 dlg.http_failure(&response, error.as_ref().ok())
2582 {
2583 sleep(d).await;
2584 continue;
2585 }
2586
2587 dlg.finished(false);
2588
2589 return Err(match error {
2590 Ok(value) => common::Error::BadRequest(value),
2591 _ => common::Error::Failure(response),
2592 });
2593 }
2594 let response = {
2595 let bytes = common::to_bytes(body).await.unwrap_or_default();
2596 let encoded = common::to_string(&bytes);
2597 match serde_json::from_str(&encoded) {
2598 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2599 Err(error) => {
2600 dlg.response_json_decode_error(&encoded, &error);
2601 return Err(common::Error::JsonDecodeError(
2602 encoded.to_string(),
2603 error,
2604 ));
2605 }
2606 }
2607 };
2608
2609 dlg.finished(true);
2610 return Ok(response);
2611 }
2612 }
2613 }
2614 }
2615
2616 /// 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.
2617 ///
2618 /// Sets the *resource* path property to the given value.
2619 ///
2620 /// Even though the property as already been set when instantiating this call,
2621 /// we provide this method for API completeness.
2622 pub fn resource(mut self, new_value: &str) -> ProjectLocationApiConfigGetIamPolicyCall<'a, C> {
2623 self._resource = new_value.to_string();
2624 self
2625 }
2626 /// 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).
2627 ///
2628 /// Sets the *options.requested policy version* query property to the given value.
2629 pub fn options_requested_policy_version(
2630 mut self,
2631 new_value: i32,
2632 ) -> ProjectLocationApiConfigGetIamPolicyCall<'a, C> {
2633 self._options_requested_policy_version = Some(new_value);
2634 self
2635 }
2636 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2637 /// while executing the actual API request.
2638 ///
2639 /// ````text
2640 /// It should be used to handle progress information, and to implement a certain level of resilience.
2641 /// ````
2642 ///
2643 /// Sets the *delegate* property to the given value.
2644 pub fn delegate(
2645 mut self,
2646 new_value: &'a mut dyn common::Delegate,
2647 ) -> ProjectLocationApiConfigGetIamPolicyCall<'a, C> {
2648 self._delegate = Some(new_value);
2649 self
2650 }
2651
2652 /// Set any additional parameter of the query string used in the request.
2653 /// It should be used to set parameters which are not yet available through their own
2654 /// setters.
2655 ///
2656 /// Please note that this method must not be used to set any of the known parameters
2657 /// which have their own setter method. If done anyway, the request will fail.
2658 ///
2659 /// # Additional Parameters
2660 ///
2661 /// * *$.xgafv* (query-string) - V1 error format.
2662 /// * *access_token* (query-string) - OAuth access token.
2663 /// * *alt* (query-string) - Data format for response.
2664 /// * *callback* (query-string) - JSONP
2665 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2666 /// * *key* (query-string) - API key. Your API key identifies your project and provides you with API access, quota, and reports. Required unless you provide an OAuth 2.0 token.
2667 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2668 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2669 /// * *quotaUser* (query-string) - Available to use for quota purposes for server-side applications. Can be any arbitrary string assigned to a user, but should not exceed 40 characters.
2670 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2671 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2672 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationApiConfigGetIamPolicyCall<'a, C>
2673 where
2674 T: AsRef<str>,
2675 {
2676 self._additional_params
2677 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2678 self
2679 }
2680
2681 /// Identifies the authorization scope for the method you are building.
2682 ///
2683 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2684 /// [`Scope::CloudPlatform`].
2685 ///
2686 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2687 /// tokens for more than one scope.
2688 ///
2689 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2690 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2691 /// sufficient, a read-write scope will do as well.
2692 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationApiConfigGetIamPolicyCall<'a, C>
2693 where
2694 St: AsRef<str>,
2695 {
2696 self._scopes.insert(String::from(scope.as_ref()));
2697 self
2698 }
2699 /// Identifies the authorization scope(s) for the method you are building.
2700 ///
2701 /// See [`Self::add_scope()`] for details.
2702 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationApiConfigGetIamPolicyCall<'a, C>
2703 where
2704 I: IntoIterator<Item = St>,
2705 St: AsRef<str>,
2706 {
2707 self._scopes
2708 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2709 self
2710 }
2711
2712 /// Removes all scopes, and no default scope will be used either.
2713 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2714 /// for details).
2715 pub fn clear_scopes(mut self) -> ProjectLocationApiConfigGetIamPolicyCall<'a, C> {
2716 self._scopes.clear();
2717 self
2718 }
2719}
2720
2721/// Lists ApiConfigs in a given project and location.
2722///
2723/// A builder for the *locations.apis.configs.list* method supported by a *project* resource.
2724/// It is not used directly, but through a [`ProjectMethods`] instance.
2725///
2726/// # Example
2727///
2728/// Instantiate a resource method builder
2729///
2730/// ```test_harness,no_run
2731/// # extern crate hyper;
2732/// # extern crate hyper_rustls;
2733/// # extern crate google_apigateway1 as apigateway1;
2734/// # async fn dox() {
2735/// # use apigateway1::{Apigateway, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2736///
2737/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2738/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2739/// # .with_native_roots()
2740/// # .unwrap()
2741/// # .https_only()
2742/// # .enable_http2()
2743/// # .build();
2744///
2745/// # let executor = hyper_util::rt::TokioExecutor::new();
2746/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2747/// # secret,
2748/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2749/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2750/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2751/// # ),
2752/// # ).build().await.unwrap();
2753///
2754/// # let client = hyper_util::client::legacy::Client::builder(
2755/// # hyper_util::rt::TokioExecutor::new()
2756/// # )
2757/// # .build(
2758/// # hyper_rustls::HttpsConnectorBuilder::new()
2759/// # .with_native_roots()
2760/// # .unwrap()
2761/// # .https_or_http()
2762/// # .enable_http2()
2763/// # .build()
2764/// # );
2765/// # let mut hub = Apigateway::new(client, auth);
2766/// // You can configure optional parameters by calling the respective setters at will, and
2767/// // execute the final call using `doit()`.
2768/// // Values shown here are possibly random and not representative !
2769/// let result = hub.projects().locations_apis_configs_list("parent")
2770/// .page_token("Lorem")
2771/// .page_size(-12)
2772/// .order_by("eos")
2773/// .filter("dolor")
2774/// .doit().await;
2775/// # }
2776/// ```
2777pub struct ProjectLocationApiConfigListCall<'a, C>
2778where
2779 C: 'a,
2780{
2781 hub: &'a Apigateway<C>,
2782 _parent: String,
2783 _page_token: Option<String>,
2784 _page_size: Option<i32>,
2785 _order_by: Option<String>,
2786 _filter: Option<String>,
2787 _delegate: Option<&'a mut dyn common::Delegate>,
2788 _additional_params: HashMap<String, String>,
2789 _scopes: BTreeSet<String>,
2790}
2791
2792impl<'a, C> common::CallBuilder for ProjectLocationApiConfigListCall<'a, C> {}
2793
2794impl<'a, C> ProjectLocationApiConfigListCall<'a, C>
2795where
2796 C: common::Connector,
2797{
2798 /// Perform the operation you have build so far.
2799 pub async fn doit(
2800 mut self,
2801 ) -> common::Result<(common::Response, ApigatewayListApiConfigsResponse)> {
2802 use std::borrow::Cow;
2803 use std::io::{Read, Seek};
2804
2805 use common::{url::Params, ToParts};
2806 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2807
2808 let mut dd = common::DefaultDelegate;
2809 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2810 dlg.begin(common::MethodInfo {
2811 id: "apigateway.projects.locations.apis.configs.list",
2812 http_method: hyper::Method::GET,
2813 });
2814
2815 for &field in [
2816 "alt",
2817 "parent",
2818 "pageToken",
2819 "pageSize",
2820 "orderBy",
2821 "filter",
2822 ]
2823 .iter()
2824 {
2825 if self._additional_params.contains_key(field) {
2826 dlg.finished(false);
2827 return Err(common::Error::FieldClash(field));
2828 }
2829 }
2830
2831 let mut params = Params::with_capacity(7 + self._additional_params.len());
2832 params.push("parent", self._parent);
2833 if let Some(value) = self._page_token.as_ref() {
2834 params.push("pageToken", value);
2835 }
2836 if let Some(value) = self._page_size.as_ref() {
2837 params.push("pageSize", value.to_string());
2838 }
2839 if let Some(value) = self._order_by.as_ref() {
2840 params.push("orderBy", value);
2841 }
2842 if let Some(value) = self._filter.as_ref() {
2843 params.push("filter", value);
2844 }
2845
2846 params.extend(self._additional_params.iter());
2847
2848 params.push("alt", "json");
2849 let mut url = self.hub._base_url.clone() + "v1/{+parent}/configs";
2850 if self._scopes.is_empty() {
2851 self._scopes
2852 .insert(Scope::CloudPlatform.as_ref().to_string());
2853 }
2854
2855 #[allow(clippy::single_element_loop)]
2856 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
2857 url = params.uri_replacement(url, param_name, find_this, true);
2858 }
2859 {
2860 let to_remove = ["parent"];
2861 params.remove_params(&to_remove);
2862 }
2863
2864 let url = params.parse_with_url(&url);
2865
2866 loop {
2867 let token = match self
2868 .hub
2869 .auth
2870 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2871 .await
2872 {
2873 Ok(token) => token,
2874 Err(e) => match dlg.token(e) {
2875 Ok(token) => token,
2876 Err(e) => {
2877 dlg.finished(false);
2878 return Err(common::Error::MissingToken(e));
2879 }
2880 },
2881 };
2882 let mut req_result = {
2883 let client = &self.hub.client;
2884 dlg.pre_request();
2885 let mut req_builder = hyper::Request::builder()
2886 .method(hyper::Method::GET)
2887 .uri(url.as_str())
2888 .header(USER_AGENT, self.hub._user_agent.clone());
2889
2890 if let Some(token) = token.as_ref() {
2891 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2892 }
2893
2894 let request = req_builder
2895 .header(CONTENT_LENGTH, 0_u64)
2896 .body(common::to_body::<String>(None));
2897
2898 client.request(request.unwrap()).await
2899 };
2900
2901 match req_result {
2902 Err(err) => {
2903 if let common::Retry::After(d) = dlg.http_error(&err) {
2904 sleep(d).await;
2905 continue;
2906 }
2907 dlg.finished(false);
2908 return Err(common::Error::HttpError(err));
2909 }
2910 Ok(res) => {
2911 let (mut parts, body) = res.into_parts();
2912 let mut body = common::Body::new(body);
2913 if !parts.status.is_success() {
2914 let bytes = common::to_bytes(body).await.unwrap_or_default();
2915 let error = serde_json::from_str(&common::to_string(&bytes));
2916 let response = common::to_response(parts, bytes.into());
2917
2918 if let common::Retry::After(d) =
2919 dlg.http_failure(&response, error.as_ref().ok())
2920 {
2921 sleep(d).await;
2922 continue;
2923 }
2924
2925 dlg.finished(false);
2926
2927 return Err(match error {
2928 Ok(value) => common::Error::BadRequest(value),
2929 _ => common::Error::Failure(response),
2930 });
2931 }
2932 let response = {
2933 let bytes = common::to_bytes(body).await.unwrap_or_default();
2934 let encoded = common::to_string(&bytes);
2935 match serde_json::from_str(&encoded) {
2936 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2937 Err(error) => {
2938 dlg.response_json_decode_error(&encoded, &error);
2939 return Err(common::Error::JsonDecodeError(
2940 encoded.to_string(),
2941 error,
2942 ));
2943 }
2944 }
2945 };
2946
2947 dlg.finished(true);
2948 return Ok(response);
2949 }
2950 }
2951 }
2952 }
2953
2954 /// Required. Parent resource of the API Config, of the form: `projects/*/locations/global/apis/*`
2955 ///
2956 /// Sets the *parent* path property to the given value.
2957 ///
2958 /// Even though the property as already been set when instantiating this call,
2959 /// we provide this method for API completeness.
2960 pub fn parent(mut self, new_value: &str) -> ProjectLocationApiConfigListCall<'a, C> {
2961 self._parent = new_value.to_string();
2962 self
2963 }
2964 /// Page token.
2965 ///
2966 /// Sets the *page token* query property to the given value.
2967 pub fn page_token(mut self, new_value: &str) -> ProjectLocationApiConfigListCall<'a, C> {
2968 self._page_token = Some(new_value.to_string());
2969 self
2970 }
2971 /// Page size.
2972 ///
2973 /// Sets the *page size* query property to the given value.
2974 pub fn page_size(mut self, new_value: i32) -> ProjectLocationApiConfigListCall<'a, C> {
2975 self._page_size = Some(new_value);
2976 self
2977 }
2978 /// Order by parameters.
2979 ///
2980 /// Sets the *order by* query property to the given value.
2981 pub fn order_by(mut self, new_value: &str) -> ProjectLocationApiConfigListCall<'a, C> {
2982 self._order_by = Some(new_value.to_string());
2983 self
2984 }
2985 /// Filter.
2986 ///
2987 /// Sets the *filter* query property to the given value.
2988 pub fn filter(mut self, new_value: &str) -> ProjectLocationApiConfigListCall<'a, C> {
2989 self._filter = Some(new_value.to_string());
2990 self
2991 }
2992 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2993 /// while executing the actual API request.
2994 ///
2995 /// ````text
2996 /// It should be used to handle progress information, and to implement a certain level of resilience.
2997 /// ````
2998 ///
2999 /// Sets the *delegate* property to the given value.
3000 pub fn delegate(
3001 mut self,
3002 new_value: &'a mut dyn common::Delegate,
3003 ) -> ProjectLocationApiConfigListCall<'a, C> {
3004 self._delegate = Some(new_value);
3005 self
3006 }
3007
3008 /// Set any additional parameter of the query string used in the request.
3009 /// It should be used to set parameters which are not yet available through their own
3010 /// setters.
3011 ///
3012 /// Please note that this method must not be used to set any of the known parameters
3013 /// which have their own setter method. If done anyway, the request will fail.
3014 ///
3015 /// # Additional Parameters
3016 ///
3017 /// * *$.xgafv* (query-string) - V1 error format.
3018 /// * *access_token* (query-string) - OAuth access token.
3019 /// * *alt* (query-string) - Data format for response.
3020 /// * *callback* (query-string) - JSONP
3021 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3022 /// * *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.
3023 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3024 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3025 /// * *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.
3026 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3027 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3028 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationApiConfigListCall<'a, C>
3029 where
3030 T: AsRef<str>,
3031 {
3032 self._additional_params
3033 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3034 self
3035 }
3036
3037 /// Identifies the authorization scope for the method you are building.
3038 ///
3039 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3040 /// [`Scope::CloudPlatform`].
3041 ///
3042 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3043 /// tokens for more than one scope.
3044 ///
3045 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3046 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3047 /// sufficient, a read-write scope will do as well.
3048 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationApiConfigListCall<'a, C>
3049 where
3050 St: AsRef<str>,
3051 {
3052 self._scopes.insert(String::from(scope.as_ref()));
3053 self
3054 }
3055 /// Identifies the authorization scope(s) for the method you are building.
3056 ///
3057 /// See [`Self::add_scope()`] for details.
3058 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationApiConfigListCall<'a, C>
3059 where
3060 I: IntoIterator<Item = St>,
3061 St: AsRef<str>,
3062 {
3063 self._scopes
3064 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3065 self
3066 }
3067
3068 /// Removes all scopes, and no default scope will be used either.
3069 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3070 /// for details).
3071 pub fn clear_scopes(mut self) -> ProjectLocationApiConfigListCall<'a, C> {
3072 self._scopes.clear();
3073 self
3074 }
3075}
3076
3077/// Updates the parameters of a single ApiConfig.
3078///
3079/// A builder for the *locations.apis.configs.patch* method supported by a *project* resource.
3080/// It is not used directly, but through a [`ProjectMethods`] instance.
3081///
3082/// # Example
3083///
3084/// Instantiate a resource method builder
3085///
3086/// ```test_harness,no_run
3087/// # extern crate hyper;
3088/// # extern crate hyper_rustls;
3089/// # extern crate google_apigateway1 as apigateway1;
3090/// use apigateway1::api::ApigatewayApiConfig;
3091/// # async fn dox() {
3092/// # use apigateway1::{Apigateway, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3093///
3094/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3095/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3096/// # .with_native_roots()
3097/// # .unwrap()
3098/// # .https_only()
3099/// # .enable_http2()
3100/// # .build();
3101///
3102/// # let executor = hyper_util::rt::TokioExecutor::new();
3103/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3104/// # secret,
3105/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3106/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3107/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3108/// # ),
3109/// # ).build().await.unwrap();
3110///
3111/// # let client = hyper_util::client::legacy::Client::builder(
3112/// # hyper_util::rt::TokioExecutor::new()
3113/// # )
3114/// # .build(
3115/// # hyper_rustls::HttpsConnectorBuilder::new()
3116/// # .with_native_roots()
3117/// # .unwrap()
3118/// # .https_or_http()
3119/// # .enable_http2()
3120/// # .build()
3121/// # );
3122/// # let mut hub = Apigateway::new(client, auth);
3123/// // As the method needs a request, you would usually fill it with the desired information
3124/// // into the respective structure. Some of the parts shown here might not be applicable !
3125/// // Values shown here are possibly random and not representative !
3126/// let mut req = ApigatewayApiConfig::default();
3127///
3128/// // You can configure optional parameters by calling the respective setters at will, and
3129/// // execute the final call using `doit()`.
3130/// // Values shown here are possibly random and not representative !
3131/// let result = hub.projects().locations_apis_configs_patch(req, "name")
3132/// .update_mask(FieldMask::new::<&str>(&[]))
3133/// .doit().await;
3134/// # }
3135/// ```
3136pub struct ProjectLocationApiConfigPatchCall<'a, C>
3137where
3138 C: 'a,
3139{
3140 hub: &'a Apigateway<C>,
3141 _request: ApigatewayApiConfig,
3142 _name: String,
3143 _update_mask: Option<common::FieldMask>,
3144 _delegate: Option<&'a mut dyn common::Delegate>,
3145 _additional_params: HashMap<String, String>,
3146 _scopes: BTreeSet<String>,
3147}
3148
3149impl<'a, C> common::CallBuilder for ProjectLocationApiConfigPatchCall<'a, C> {}
3150
3151impl<'a, C> ProjectLocationApiConfigPatchCall<'a, C>
3152where
3153 C: common::Connector,
3154{
3155 /// Perform the operation you have build so far.
3156 pub async fn doit(mut self) -> common::Result<(common::Response, ApigatewayOperation)> {
3157 use std::borrow::Cow;
3158 use std::io::{Read, Seek};
3159
3160 use common::{url::Params, ToParts};
3161 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3162
3163 let mut dd = common::DefaultDelegate;
3164 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3165 dlg.begin(common::MethodInfo {
3166 id: "apigateway.projects.locations.apis.configs.patch",
3167 http_method: hyper::Method::PATCH,
3168 });
3169
3170 for &field in ["alt", "name", "updateMask"].iter() {
3171 if self._additional_params.contains_key(field) {
3172 dlg.finished(false);
3173 return Err(common::Error::FieldClash(field));
3174 }
3175 }
3176
3177 let mut params = Params::with_capacity(5 + self._additional_params.len());
3178 params.push("name", self._name);
3179 if let Some(value) = self._update_mask.as_ref() {
3180 params.push("updateMask", value.to_string());
3181 }
3182
3183 params.extend(self._additional_params.iter());
3184
3185 params.push("alt", "json");
3186 let mut url = self.hub._base_url.clone() + "v1/{+name}";
3187 if self._scopes.is_empty() {
3188 self._scopes
3189 .insert(Scope::CloudPlatform.as_ref().to_string());
3190 }
3191
3192 #[allow(clippy::single_element_loop)]
3193 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3194 url = params.uri_replacement(url, param_name, find_this, true);
3195 }
3196 {
3197 let to_remove = ["name"];
3198 params.remove_params(&to_remove);
3199 }
3200
3201 let url = params.parse_with_url(&url);
3202
3203 let mut json_mime_type = mime::APPLICATION_JSON;
3204 let mut request_value_reader = {
3205 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3206 common::remove_json_null_values(&mut value);
3207 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3208 serde_json::to_writer(&mut dst, &value).unwrap();
3209 dst
3210 };
3211 let request_size = request_value_reader
3212 .seek(std::io::SeekFrom::End(0))
3213 .unwrap();
3214 request_value_reader
3215 .seek(std::io::SeekFrom::Start(0))
3216 .unwrap();
3217
3218 loop {
3219 let token = match self
3220 .hub
3221 .auth
3222 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3223 .await
3224 {
3225 Ok(token) => token,
3226 Err(e) => match dlg.token(e) {
3227 Ok(token) => token,
3228 Err(e) => {
3229 dlg.finished(false);
3230 return Err(common::Error::MissingToken(e));
3231 }
3232 },
3233 };
3234 request_value_reader
3235 .seek(std::io::SeekFrom::Start(0))
3236 .unwrap();
3237 let mut req_result = {
3238 let client = &self.hub.client;
3239 dlg.pre_request();
3240 let mut req_builder = hyper::Request::builder()
3241 .method(hyper::Method::PATCH)
3242 .uri(url.as_str())
3243 .header(USER_AGENT, self.hub._user_agent.clone());
3244
3245 if let Some(token) = token.as_ref() {
3246 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3247 }
3248
3249 let request = req_builder
3250 .header(CONTENT_TYPE, json_mime_type.to_string())
3251 .header(CONTENT_LENGTH, request_size as u64)
3252 .body(common::to_body(
3253 request_value_reader.get_ref().clone().into(),
3254 ));
3255
3256 client.request(request.unwrap()).await
3257 };
3258
3259 match req_result {
3260 Err(err) => {
3261 if let common::Retry::After(d) = dlg.http_error(&err) {
3262 sleep(d).await;
3263 continue;
3264 }
3265 dlg.finished(false);
3266 return Err(common::Error::HttpError(err));
3267 }
3268 Ok(res) => {
3269 let (mut parts, body) = res.into_parts();
3270 let mut body = common::Body::new(body);
3271 if !parts.status.is_success() {
3272 let bytes = common::to_bytes(body).await.unwrap_or_default();
3273 let error = serde_json::from_str(&common::to_string(&bytes));
3274 let response = common::to_response(parts, bytes.into());
3275
3276 if let common::Retry::After(d) =
3277 dlg.http_failure(&response, error.as_ref().ok())
3278 {
3279 sleep(d).await;
3280 continue;
3281 }
3282
3283 dlg.finished(false);
3284
3285 return Err(match error {
3286 Ok(value) => common::Error::BadRequest(value),
3287 _ => common::Error::Failure(response),
3288 });
3289 }
3290 let response = {
3291 let bytes = common::to_bytes(body).await.unwrap_or_default();
3292 let encoded = common::to_string(&bytes);
3293 match serde_json::from_str(&encoded) {
3294 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3295 Err(error) => {
3296 dlg.response_json_decode_error(&encoded, &error);
3297 return Err(common::Error::JsonDecodeError(
3298 encoded.to_string(),
3299 error,
3300 ));
3301 }
3302 }
3303 };
3304
3305 dlg.finished(true);
3306 return Ok(response);
3307 }
3308 }
3309 }
3310 }
3311
3312 ///
3313 /// Sets the *request* property to the given value.
3314 ///
3315 /// Even though the property as already been set when instantiating this call,
3316 /// we provide this method for API completeness.
3317 pub fn request(
3318 mut self,
3319 new_value: ApigatewayApiConfig,
3320 ) -> ProjectLocationApiConfigPatchCall<'a, C> {
3321 self._request = new_value;
3322 self
3323 }
3324 /// Output only. Resource name of the API Config. Format: projects/{project}/locations/global/apis/{api}/configs/{api_config}
3325 ///
3326 /// Sets the *name* path property to the given value.
3327 ///
3328 /// Even though the property as already been set when instantiating this call,
3329 /// we provide this method for API completeness.
3330 pub fn name(mut self, new_value: &str) -> ProjectLocationApiConfigPatchCall<'a, C> {
3331 self._name = new_value.to_string();
3332 self
3333 }
3334 /// Field mask is used to specify the fields to be overwritten in the ApiConfig 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.
3335 ///
3336 /// Sets the *update mask* query property to the given value.
3337 pub fn update_mask(
3338 mut self,
3339 new_value: common::FieldMask,
3340 ) -> ProjectLocationApiConfigPatchCall<'a, C> {
3341 self._update_mask = Some(new_value);
3342 self
3343 }
3344 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3345 /// while executing the actual API request.
3346 ///
3347 /// ````text
3348 /// It should be used to handle progress information, and to implement a certain level of resilience.
3349 /// ````
3350 ///
3351 /// Sets the *delegate* property to the given value.
3352 pub fn delegate(
3353 mut self,
3354 new_value: &'a mut dyn common::Delegate,
3355 ) -> ProjectLocationApiConfigPatchCall<'a, C> {
3356 self._delegate = Some(new_value);
3357 self
3358 }
3359
3360 /// Set any additional parameter of the query string used in the request.
3361 /// It should be used to set parameters which are not yet available through their own
3362 /// setters.
3363 ///
3364 /// Please note that this method must not be used to set any of the known parameters
3365 /// which have their own setter method. If done anyway, the request will fail.
3366 ///
3367 /// # Additional Parameters
3368 ///
3369 /// * *$.xgafv* (query-string) - V1 error format.
3370 /// * *access_token* (query-string) - OAuth access token.
3371 /// * *alt* (query-string) - Data format for response.
3372 /// * *callback* (query-string) - JSONP
3373 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3374 /// * *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.
3375 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3376 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3377 /// * *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.
3378 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3379 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3380 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationApiConfigPatchCall<'a, C>
3381 where
3382 T: AsRef<str>,
3383 {
3384 self._additional_params
3385 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3386 self
3387 }
3388
3389 /// Identifies the authorization scope for the method you are building.
3390 ///
3391 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3392 /// [`Scope::CloudPlatform`].
3393 ///
3394 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3395 /// tokens for more than one scope.
3396 ///
3397 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3398 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3399 /// sufficient, a read-write scope will do as well.
3400 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationApiConfigPatchCall<'a, C>
3401 where
3402 St: AsRef<str>,
3403 {
3404 self._scopes.insert(String::from(scope.as_ref()));
3405 self
3406 }
3407 /// Identifies the authorization scope(s) for the method you are building.
3408 ///
3409 /// See [`Self::add_scope()`] for details.
3410 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationApiConfigPatchCall<'a, C>
3411 where
3412 I: IntoIterator<Item = St>,
3413 St: AsRef<str>,
3414 {
3415 self._scopes
3416 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3417 self
3418 }
3419
3420 /// Removes all scopes, and no default scope will be used either.
3421 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3422 /// for details).
3423 pub fn clear_scopes(mut self) -> ProjectLocationApiConfigPatchCall<'a, C> {
3424 self._scopes.clear();
3425 self
3426 }
3427}
3428
3429/// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
3430///
3431/// A builder for the *locations.apis.configs.setIamPolicy* method supported by a *project* resource.
3432/// It is not used directly, but through a [`ProjectMethods`] instance.
3433///
3434/// # Example
3435///
3436/// Instantiate a resource method builder
3437///
3438/// ```test_harness,no_run
3439/// # extern crate hyper;
3440/// # extern crate hyper_rustls;
3441/// # extern crate google_apigateway1 as apigateway1;
3442/// use apigateway1::api::ApigatewaySetIamPolicyRequest;
3443/// # async fn dox() {
3444/// # use apigateway1::{Apigateway, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3445///
3446/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3447/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3448/// # .with_native_roots()
3449/// # .unwrap()
3450/// # .https_only()
3451/// # .enable_http2()
3452/// # .build();
3453///
3454/// # let executor = hyper_util::rt::TokioExecutor::new();
3455/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3456/// # secret,
3457/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3458/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3459/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3460/// # ),
3461/// # ).build().await.unwrap();
3462///
3463/// # let client = hyper_util::client::legacy::Client::builder(
3464/// # hyper_util::rt::TokioExecutor::new()
3465/// # )
3466/// # .build(
3467/// # hyper_rustls::HttpsConnectorBuilder::new()
3468/// # .with_native_roots()
3469/// # .unwrap()
3470/// # .https_or_http()
3471/// # .enable_http2()
3472/// # .build()
3473/// # );
3474/// # let mut hub = Apigateway::new(client, auth);
3475/// // As the method needs a request, you would usually fill it with the desired information
3476/// // into the respective structure. Some of the parts shown here might not be applicable !
3477/// // Values shown here are possibly random and not representative !
3478/// let mut req = ApigatewaySetIamPolicyRequest::default();
3479///
3480/// // You can configure optional parameters by calling the respective setters at will, and
3481/// // execute the final call using `doit()`.
3482/// // Values shown here are possibly random and not representative !
3483/// let result = hub.projects().locations_apis_configs_set_iam_policy(req, "resource")
3484/// .doit().await;
3485/// # }
3486/// ```
3487pub struct ProjectLocationApiConfigSetIamPolicyCall<'a, C>
3488where
3489 C: 'a,
3490{
3491 hub: &'a Apigateway<C>,
3492 _request: ApigatewaySetIamPolicyRequest,
3493 _resource: String,
3494 _delegate: Option<&'a mut dyn common::Delegate>,
3495 _additional_params: HashMap<String, String>,
3496 _scopes: BTreeSet<String>,
3497}
3498
3499impl<'a, C> common::CallBuilder for ProjectLocationApiConfigSetIamPolicyCall<'a, C> {}
3500
3501impl<'a, C> ProjectLocationApiConfigSetIamPolicyCall<'a, C>
3502where
3503 C: common::Connector,
3504{
3505 /// Perform the operation you have build so far.
3506 pub async fn doit(mut self) -> common::Result<(common::Response, ApigatewayPolicy)> {
3507 use std::borrow::Cow;
3508 use std::io::{Read, Seek};
3509
3510 use common::{url::Params, ToParts};
3511 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3512
3513 let mut dd = common::DefaultDelegate;
3514 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3515 dlg.begin(common::MethodInfo {
3516 id: "apigateway.projects.locations.apis.configs.setIamPolicy",
3517 http_method: hyper::Method::POST,
3518 });
3519
3520 for &field in ["alt", "resource"].iter() {
3521 if self._additional_params.contains_key(field) {
3522 dlg.finished(false);
3523 return Err(common::Error::FieldClash(field));
3524 }
3525 }
3526
3527 let mut params = Params::with_capacity(4 + self._additional_params.len());
3528 params.push("resource", self._resource);
3529
3530 params.extend(self._additional_params.iter());
3531
3532 params.push("alt", "json");
3533 let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
3534 if self._scopes.is_empty() {
3535 self._scopes
3536 .insert(Scope::CloudPlatform.as_ref().to_string());
3537 }
3538
3539 #[allow(clippy::single_element_loop)]
3540 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
3541 url = params.uri_replacement(url, param_name, find_this, true);
3542 }
3543 {
3544 let to_remove = ["resource"];
3545 params.remove_params(&to_remove);
3546 }
3547
3548 let url = params.parse_with_url(&url);
3549
3550 let mut json_mime_type = mime::APPLICATION_JSON;
3551 let mut request_value_reader = {
3552 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3553 common::remove_json_null_values(&mut value);
3554 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3555 serde_json::to_writer(&mut dst, &value).unwrap();
3556 dst
3557 };
3558 let request_size = request_value_reader
3559 .seek(std::io::SeekFrom::End(0))
3560 .unwrap();
3561 request_value_reader
3562 .seek(std::io::SeekFrom::Start(0))
3563 .unwrap();
3564
3565 loop {
3566 let token = match self
3567 .hub
3568 .auth
3569 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3570 .await
3571 {
3572 Ok(token) => token,
3573 Err(e) => match dlg.token(e) {
3574 Ok(token) => token,
3575 Err(e) => {
3576 dlg.finished(false);
3577 return Err(common::Error::MissingToken(e));
3578 }
3579 },
3580 };
3581 request_value_reader
3582 .seek(std::io::SeekFrom::Start(0))
3583 .unwrap();
3584 let mut req_result = {
3585 let client = &self.hub.client;
3586 dlg.pre_request();
3587 let mut req_builder = hyper::Request::builder()
3588 .method(hyper::Method::POST)
3589 .uri(url.as_str())
3590 .header(USER_AGENT, self.hub._user_agent.clone());
3591
3592 if let Some(token) = token.as_ref() {
3593 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3594 }
3595
3596 let request = req_builder
3597 .header(CONTENT_TYPE, json_mime_type.to_string())
3598 .header(CONTENT_LENGTH, request_size as u64)
3599 .body(common::to_body(
3600 request_value_reader.get_ref().clone().into(),
3601 ));
3602
3603 client.request(request.unwrap()).await
3604 };
3605
3606 match req_result {
3607 Err(err) => {
3608 if let common::Retry::After(d) = dlg.http_error(&err) {
3609 sleep(d).await;
3610 continue;
3611 }
3612 dlg.finished(false);
3613 return Err(common::Error::HttpError(err));
3614 }
3615 Ok(res) => {
3616 let (mut parts, body) = res.into_parts();
3617 let mut body = common::Body::new(body);
3618 if !parts.status.is_success() {
3619 let bytes = common::to_bytes(body).await.unwrap_or_default();
3620 let error = serde_json::from_str(&common::to_string(&bytes));
3621 let response = common::to_response(parts, bytes.into());
3622
3623 if let common::Retry::After(d) =
3624 dlg.http_failure(&response, error.as_ref().ok())
3625 {
3626 sleep(d).await;
3627 continue;
3628 }
3629
3630 dlg.finished(false);
3631
3632 return Err(match error {
3633 Ok(value) => common::Error::BadRequest(value),
3634 _ => common::Error::Failure(response),
3635 });
3636 }
3637 let response = {
3638 let bytes = common::to_bytes(body).await.unwrap_or_default();
3639 let encoded = common::to_string(&bytes);
3640 match serde_json::from_str(&encoded) {
3641 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3642 Err(error) => {
3643 dlg.response_json_decode_error(&encoded, &error);
3644 return Err(common::Error::JsonDecodeError(
3645 encoded.to_string(),
3646 error,
3647 ));
3648 }
3649 }
3650 };
3651
3652 dlg.finished(true);
3653 return Ok(response);
3654 }
3655 }
3656 }
3657 }
3658
3659 ///
3660 /// Sets the *request* property to the given value.
3661 ///
3662 /// Even though the property as already been set when instantiating this call,
3663 /// we provide this method for API completeness.
3664 pub fn request(
3665 mut self,
3666 new_value: ApigatewaySetIamPolicyRequest,
3667 ) -> ProjectLocationApiConfigSetIamPolicyCall<'a, C> {
3668 self._request = new_value;
3669 self
3670 }
3671 /// 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.
3672 ///
3673 /// Sets the *resource* path property to the given value.
3674 ///
3675 /// Even though the property as already been set when instantiating this call,
3676 /// we provide this method for API completeness.
3677 pub fn resource(mut self, new_value: &str) -> ProjectLocationApiConfigSetIamPolicyCall<'a, C> {
3678 self._resource = new_value.to_string();
3679 self
3680 }
3681 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3682 /// while executing the actual API request.
3683 ///
3684 /// ````text
3685 /// It should be used to handle progress information, and to implement a certain level of resilience.
3686 /// ````
3687 ///
3688 /// Sets the *delegate* property to the given value.
3689 pub fn delegate(
3690 mut self,
3691 new_value: &'a mut dyn common::Delegate,
3692 ) -> ProjectLocationApiConfigSetIamPolicyCall<'a, C> {
3693 self._delegate = Some(new_value);
3694 self
3695 }
3696
3697 /// Set any additional parameter of the query string used in the request.
3698 /// It should be used to set parameters which are not yet available through their own
3699 /// setters.
3700 ///
3701 /// Please note that this method must not be used to set any of the known parameters
3702 /// which have their own setter method. If done anyway, the request will fail.
3703 ///
3704 /// # Additional Parameters
3705 ///
3706 /// * *$.xgafv* (query-string) - V1 error format.
3707 /// * *access_token* (query-string) - OAuth access token.
3708 /// * *alt* (query-string) - Data format for response.
3709 /// * *callback* (query-string) - JSONP
3710 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3711 /// * *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.
3712 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3713 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3714 /// * *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.
3715 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3716 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3717 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationApiConfigSetIamPolicyCall<'a, C>
3718 where
3719 T: AsRef<str>,
3720 {
3721 self._additional_params
3722 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3723 self
3724 }
3725
3726 /// Identifies the authorization scope for the method you are building.
3727 ///
3728 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3729 /// [`Scope::CloudPlatform`].
3730 ///
3731 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3732 /// tokens for more than one scope.
3733 ///
3734 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3735 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3736 /// sufficient, a read-write scope will do as well.
3737 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationApiConfigSetIamPolicyCall<'a, C>
3738 where
3739 St: AsRef<str>,
3740 {
3741 self._scopes.insert(String::from(scope.as_ref()));
3742 self
3743 }
3744 /// Identifies the authorization scope(s) for the method you are building.
3745 ///
3746 /// See [`Self::add_scope()`] for details.
3747 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationApiConfigSetIamPolicyCall<'a, C>
3748 where
3749 I: IntoIterator<Item = St>,
3750 St: AsRef<str>,
3751 {
3752 self._scopes
3753 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3754 self
3755 }
3756
3757 /// Removes all scopes, and no default scope will be used either.
3758 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3759 /// for details).
3760 pub fn clear_scopes(mut self) -> ProjectLocationApiConfigSetIamPolicyCall<'a, C> {
3761 self._scopes.clear();
3762 self
3763 }
3764}
3765
3766/// 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.
3767///
3768/// A builder for the *locations.apis.configs.testIamPermissions* method supported by a *project* resource.
3769/// It is not used directly, but through a [`ProjectMethods`] instance.
3770///
3771/// # Example
3772///
3773/// Instantiate a resource method builder
3774///
3775/// ```test_harness,no_run
3776/// # extern crate hyper;
3777/// # extern crate hyper_rustls;
3778/// # extern crate google_apigateway1 as apigateway1;
3779/// use apigateway1::api::ApigatewayTestIamPermissionsRequest;
3780/// # async fn dox() {
3781/// # use apigateway1::{Apigateway, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3782///
3783/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3784/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3785/// # .with_native_roots()
3786/// # .unwrap()
3787/// # .https_only()
3788/// # .enable_http2()
3789/// # .build();
3790///
3791/// # let executor = hyper_util::rt::TokioExecutor::new();
3792/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3793/// # secret,
3794/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3795/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3796/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3797/// # ),
3798/// # ).build().await.unwrap();
3799///
3800/// # let client = hyper_util::client::legacy::Client::builder(
3801/// # hyper_util::rt::TokioExecutor::new()
3802/// # )
3803/// # .build(
3804/// # hyper_rustls::HttpsConnectorBuilder::new()
3805/// # .with_native_roots()
3806/// # .unwrap()
3807/// # .https_or_http()
3808/// # .enable_http2()
3809/// # .build()
3810/// # );
3811/// # let mut hub = Apigateway::new(client, auth);
3812/// // As the method needs a request, you would usually fill it with the desired information
3813/// // into the respective structure. Some of the parts shown here might not be applicable !
3814/// // Values shown here are possibly random and not representative !
3815/// let mut req = ApigatewayTestIamPermissionsRequest::default();
3816///
3817/// // You can configure optional parameters by calling the respective setters at will, and
3818/// // execute the final call using `doit()`.
3819/// // Values shown here are possibly random and not representative !
3820/// let result = hub.projects().locations_apis_configs_test_iam_permissions(req, "resource")
3821/// .doit().await;
3822/// # }
3823/// ```
3824pub struct ProjectLocationApiConfigTestIamPermissionCall<'a, C>
3825where
3826 C: 'a,
3827{
3828 hub: &'a Apigateway<C>,
3829 _request: ApigatewayTestIamPermissionsRequest,
3830 _resource: String,
3831 _delegate: Option<&'a mut dyn common::Delegate>,
3832 _additional_params: HashMap<String, String>,
3833 _scopes: BTreeSet<String>,
3834}
3835
3836impl<'a, C> common::CallBuilder for ProjectLocationApiConfigTestIamPermissionCall<'a, C> {}
3837
3838impl<'a, C> ProjectLocationApiConfigTestIamPermissionCall<'a, C>
3839where
3840 C: common::Connector,
3841{
3842 /// Perform the operation you have build so far.
3843 pub async fn doit(
3844 mut self,
3845 ) -> common::Result<(common::Response, ApigatewayTestIamPermissionsResponse)> {
3846 use std::borrow::Cow;
3847 use std::io::{Read, Seek};
3848
3849 use common::{url::Params, ToParts};
3850 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3851
3852 let mut dd = common::DefaultDelegate;
3853 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3854 dlg.begin(common::MethodInfo {
3855 id: "apigateway.projects.locations.apis.configs.testIamPermissions",
3856 http_method: hyper::Method::POST,
3857 });
3858
3859 for &field in ["alt", "resource"].iter() {
3860 if self._additional_params.contains_key(field) {
3861 dlg.finished(false);
3862 return Err(common::Error::FieldClash(field));
3863 }
3864 }
3865
3866 let mut params = Params::with_capacity(4 + self._additional_params.len());
3867 params.push("resource", self._resource);
3868
3869 params.extend(self._additional_params.iter());
3870
3871 params.push("alt", "json");
3872 let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
3873 if self._scopes.is_empty() {
3874 self._scopes
3875 .insert(Scope::CloudPlatform.as_ref().to_string());
3876 }
3877
3878 #[allow(clippy::single_element_loop)]
3879 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
3880 url = params.uri_replacement(url, param_name, find_this, true);
3881 }
3882 {
3883 let to_remove = ["resource"];
3884 params.remove_params(&to_remove);
3885 }
3886
3887 let url = params.parse_with_url(&url);
3888
3889 let mut json_mime_type = mime::APPLICATION_JSON;
3890 let mut request_value_reader = {
3891 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3892 common::remove_json_null_values(&mut value);
3893 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3894 serde_json::to_writer(&mut dst, &value).unwrap();
3895 dst
3896 };
3897 let request_size = request_value_reader
3898 .seek(std::io::SeekFrom::End(0))
3899 .unwrap();
3900 request_value_reader
3901 .seek(std::io::SeekFrom::Start(0))
3902 .unwrap();
3903
3904 loop {
3905 let token = match self
3906 .hub
3907 .auth
3908 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3909 .await
3910 {
3911 Ok(token) => token,
3912 Err(e) => match dlg.token(e) {
3913 Ok(token) => token,
3914 Err(e) => {
3915 dlg.finished(false);
3916 return Err(common::Error::MissingToken(e));
3917 }
3918 },
3919 };
3920 request_value_reader
3921 .seek(std::io::SeekFrom::Start(0))
3922 .unwrap();
3923 let mut req_result = {
3924 let client = &self.hub.client;
3925 dlg.pre_request();
3926 let mut req_builder = hyper::Request::builder()
3927 .method(hyper::Method::POST)
3928 .uri(url.as_str())
3929 .header(USER_AGENT, self.hub._user_agent.clone());
3930
3931 if let Some(token) = token.as_ref() {
3932 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3933 }
3934
3935 let request = req_builder
3936 .header(CONTENT_TYPE, json_mime_type.to_string())
3937 .header(CONTENT_LENGTH, request_size as u64)
3938 .body(common::to_body(
3939 request_value_reader.get_ref().clone().into(),
3940 ));
3941
3942 client.request(request.unwrap()).await
3943 };
3944
3945 match req_result {
3946 Err(err) => {
3947 if let common::Retry::After(d) = dlg.http_error(&err) {
3948 sleep(d).await;
3949 continue;
3950 }
3951 dlg.finished(false);
3952 return Err(common::Error::HttpError(err));
3953 }
3954 Ok(res) => {
3955 let (mut parts, body) = res.into_parts();
3956 let mut body = common::Body::new(body);
3957 if !parts.status.is_success() {
3958 let bytes = common::to_bytes(body).await.unwrap_or_default();
3959 let error = serde_json::from_str(&common::to_string(&bytes));
3960 let response = common::to_response(parts, bytes.into());
3961
3962 if let common::Retry::After(d) =
3963 dlg.http_failure(&response, error.as_ref().ok())
3964 {
3965 sleep(d).await;
3966 continue;
3967 }
3968
3969 dlg.finished(false);
3970
3971 return Err(match error {
3972 Ok(value) => common::Error::BadRequest(value),
3973 _ => common::Error::Failure(response),
3974 });
3975 }
3976 let response = {
3977 let bytes = common::to_bytes(body).await.unwrap_or_default();
3978 let encoded = common::to_string(&bytes);
3979 match serde_json::from_str(&encoded) {
3980 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3981 Err(error) => {
3982 dlg.response_json_decode_error(&encoded, &error);
3983 return Err(common::Error::JsonDecodeError(
3984 encoded.to_string(),
3985 error,
3986 ));
3987 }
3988 }
3989 };
3990
3991 dlg.finished(true);
3992 return Ok(response);
3993 }
3994 }
3995 }
3996 }
3997
3998 ///
3999 /// Sets the *request* property to the given value.
4000 ///
4001 /// Even though the property as already been set when instantiating this call,
4002 /// we provide this method for API completeness.
4003 pub fn request(
4004 mut self,
4005 new_value: ApigatewayTestIamPermissionsRequest,
4006 ) -> ProjectLocationApiConfigTestIamPermissionCall<'a, C> {
4007 self._request = new_value;
4008 self
4009 }
4010 /// 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.
4011 ///
4012 /// Sets the *resource* path property to the given value.
4013 ///
4014 /// Even though the property as already been set when instantiating this call,
4015 /// we provide this method for API completeness.
4016 pub fn resource(
4017 mut self,
4018 new_value: &str,
4019 ) -> ProjectLocationApiConfigTestIamPermissionCall<'a, C> {
4020 self._resource = new_value.to_string();
4021 self
4022 }
4023 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4024 /// while executing the actual API request.
4025 ///
4026 /// ````text
4027 /// It should be used to handle progress information, and to implement a certain level of resilience.
4028 /// ````
4029 ///
4030 /// Sets the *delegate* property to the given value.
4031 pub fn delegate(
4032 mut self,
4033 new_value: &'a mut dyn common::Delegate,
4034 ) -> ProjectLocationApiConfigTestIamPermissionCall<'a, C> {
4035 self._delegate = Some(new_value);
4036 self
4037 }
4038
4039 /// Set any additional parameter of the query string used in the request.
4040 /// It should be used to set parameters which are not yet available through their own
4041 /// setters.
4042 ///
4043 /// Please note that this method must not be used to set any of the known parameters
4044 /// which have their own setter method. If done anyway, the request will fail.
4045 ///
4046 /// # Additional Parameters
4047 ///
4048 /// * *$.xgafv* (query-string) - V1 error format.
4049 /// * *access_token* (query-string) - OAuth access token.
4050 /// * *alt* (query-string) - Data format for response.
4051 /// * *callback* (query-string) - JSONP
4052 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4053 /// * *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.
4054 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4055 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4056 /// * *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.
4057 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4058 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4059 pub fn param<T>(
4060 mut self,
4061 name: T,
4062 value: T,
4063 ) -> ProjectLocationApiConfigTestIamPermissionCall<'a, C>
4064 where
4065 T: AsRef<str>,
4066 {
4067 self._additional_params
4068 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4069 self
4070 }
4071
4072 /// Identifies the authorization scope for the method you are building.
4073 ///
4074 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4075 /// [`Scope::CloudPlatform`].
4076 ///
4077 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4078 /// tokens for more than one scope.
4079 ///
4080 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4081 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4082 /// sufficient, a read-write scope will do as well.
4083 pub fn add_scope<St>(
4084 mut self,
4085 scope: St,
4086 ) -> ProjectLocationApiConfigTestIamPermissionCall<'a, C>
4087 where
4088 St: AsRef<str>,
4089 {
4090 self._scopes.insert(String::from(scope.as_ref()));
4091 self
4092 }
4093 /// Identifies the authorization scope(s) for the method you are building.
4094 ///
4095 /// See [`Self::add_scope()`] for details.
4096 pub fn add_scopes<I, St>(
4097 mut self,
4098 scopes: I,
4099 ) -> ProjectLocationApiConfigTestIamPermissionCall<'a, C>
4100 where
4101 I: IntoIterator<Item = St>,
4102 St: AsRef<str>,
4103 {
4104 self._scopes
4105 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4106 self
4107 }
4108
4109 /// Removes all scopes, and no default scope will be used either.
4110 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4111 /// for details).
4112 pub fn clear_scopes(mut self) -> ProjectLocationApiConfigTestIamPermissionCall<'a, C> {
4113 self._scopes.clear();
4114 self
4115 }
4116}
4117
4118/// Creates a new Api in a given project and location.
4119///
4120/// A builder for the *locations.apis.create* method supported by a *project* resource.
4121/// It is not used directly, but through a [`ProjectMethods`] instance.
4122///
4123/// # Example
4124///
4125/// Instantiate a resource method builder
4126///
4127/// ```test_harness,no_run
4128/// # extern crate hyper;
4129/// # extern crate hyper_rustls;
4130/// # extern crate google_apigateway1 as apigateway1;
4131/// use apigateway1::api::ApigatewayApi;
4132/// # async fn dox() {
4133/// # use apigateway1::{Apigateway, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4134///
4135/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4136/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4137/// # .with_native_roots()
4138/// # .unwrap()
4139/// # .https_only()
4140/// # .enable_http2()
4141/// # .build();
4142///
4143/// # let executor = hyper_util::rt::TokioExecutor::new();
4144/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4145/// # secret,
4146/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4147/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4148/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4149/// # ),
4150/// # ).build().await.unwrap();
4151///
4152/// # let client = hyper_util::client::legacy::Client::builder(
4153/// # hyper_util::rt::TokioExecutor::new()
4154/// # )
4155/// # .build(
4156/// # hyper_rustls::HttpsConnectorBuilder::new()
4157/// # .with_native_roots()
4158/// # .unwrap()
4159/// # .https_or_http()
4160/// # .enable_http2()
4161/// # .build()
4162/// # );
4163/// # let mut hub = Apigateway::new(client, auth);
4164/// // As the method needs a request, you would usually fill it with the desired information
4165/// // into the respective structure. Some of the parts shown here might not be applicable !
4166/// // Values shown here are possibly random and not representative !
4167/// let mut req = ApigatewayApi::default();
4168///
4169/// // You can configure optional parameters by calling the respective setters at will, and
4170/// // execute the final call using `doit()`.
4171/// // Values shown here are possibly random and not representative !
4172/// let result = hub.projects().locations_apis_create(req, "parent")
4173/// .api_id("duo")
4174/// .doit().await;
4175/// # }
4176/// ```
4177pub struct ProjectLocationApiCreateCall<'a, C>
4178where
4179 C: 'a,
4180{
4181 hub: &'a Apigateway<C>,
4182 _request: ApigatewayApi,
4183 _parent: String,
4184 _api_id: Option<String>,
4185 _delegate: Option<&'a mut dyn common::Delegate>,
4186 _additional_params: HashMap<String, String>,
4187 _scopes: BTreeSet<String>,
4188}
4189
4190impl<'a, C> common::CallBuilder for ProjectLocationApiCreateCall<'a, C> {}
4191
4192impl<'a, C> ProjectLocationApiCreateCall<'a, C>
4193where
4194 C: common::Connector,
4195{
4196 /// Perform the operation you have build so far.
4197 pub async fn doit(mut self) -> common::Result<(common::Response, ApigatewayOperation)> {
4198 use std::borrow::Cow;
4199 use std::io::{Read, Seek};
4200
4201 use common::{url::Params, ToParts};
4202 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4203
4204 let mut dd = common::DefaultDelegate;
4205 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4206 dlg.begin(common::MethodInfo {
4207 id: "apigateway.projects.locations.apis.create",
4208 http_method: hyper::Method::POST,
4209 });
4210
4211 for &field in ["alt", "parent", "apiId"].iter() {
4212 if self._additional_params.contains_key(field) {
4213 dlg.finished(false);
4214 return Err(common::Error::FieldClash(field));
4215 }
4216 }
4217
4218 let mut params = Params::with_capacity(5 + self._additional_params.len());
4219 params.push("parent", self._parent);
4220 if let Some(value) = self._api_id.as_ref() {
4221 params.push("apiId", value);
4222 }
4223
4224 params.extend(self._additional_params.iter());
4225
4226 params.push("alt", "json");
4227 let mut url = self.hub._base_url.clone() + "v1/{+parent}/apis";
4228 if self._scopes.is_empty() {
4229 self._scopes
4230 .insert(Scope::CloudPlatform.as_ref().to_string());
4231 }
4232
4233 #[allow(clippy::single_element_loop)]
4234 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4235 url = params.uri_replacement(url, param_name, find_this, true);
4236 }
4237 {
4238 let to_remove = ["parent"];
4239 params.remove_params(&to_remove);
4240 }
4241
4242 let url = params.parse_with_url(&url);
4243
4244 let mut json_mime_type = mime::APPLICATION_JSON;
4245 let mut request_value_reader = {
4246 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4247 common::remove_json_null_values(&mut value);
4248 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4249 serde_json::to_writer(&mut dst, &value).unwrap();
4250 dst
4251 };
4252 let request_size = request_value_reader
4253 .seek(std::io::SeekFrom::End(0))
4254 .unwrap();
4255 request_value_reader
4256 .seek(std::io::SeekFrom::Start(0))
4257 .unwrap();
4258
4259 loop {
4260 let token = match self
4261 .hub
4262 .auth
4263 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4264 .await
4265 {
4266 Ok(token) => token,
4267 Err(e) => match dlg.token(e) {
4268 Ok(token) => token,
4269 Err(e) => {
4270 dlg.finished(false);
4271 return Err(common::Error::MissingToken(e));
4272 }
4273 },
4274 };
4275 request_value_reader
4276 .seek(std::io::SeekFrom::Start(0))
4277 .unwrap();
4278 let mut req_result = {
4279 let client = &self.hub.client;
4280 dlg.pre_request();
4281 let mut req_builder = hyper::Request::builder()
4282 .method(hyper::Method::POST)
4283 .uri(url.as_str())
4284 .header(USER_AGENT, self.hub._user_agent.clone());
4285
4286 if let Some(token) = token.as_ref() {
4287 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4288 }
4289
4290 let request = req_builder
4291 .header(CONTENT_TYPE, json_mime_type.to_string())
4292 .header(CONTENT_LENGTH, request_size as u64)
4293 .body(common::to_body(
4294 request_value_reader.get_ref().clone().into(),
4295 ));
4296
4297 client.request(request.unwrap()).await
4298 };
4299
4300 match req_result {
4301 Err(err) => {
4302 if let common::Retry::After(d) = dlg.http_error(&err) {
4303 sleep(d).await;
4304 continue;
4305 }
4306 dlg.finished(false);
4307 return Err(common::Error::HttpError(err));
4308 }
4309 Ok(res) => {
4310 let (mut parts, body) = res.into_parts();
4311 let mut body = common::Body::new(body);
4312 if !parts.status.is_success() {
4313 let bytes = common::to_bytes(body).await.unwrap_or_default();
4314 let error = serde_json::from_str(&common::to_string(&bytes));
4315 let response = common::to_response(parts, bytes.into());
4316
4317 if let common::Retry::After(d) =
4318 dlg.http_failure(&response, error.as_ref().ok())
4319 {
4320 sleep(d).await;
4321 continue;
4322 }
4323
4324 dlg.finished(false);
4325
4326 return Err(match error {
4327 Ok(value) => common::Error::BadRequest(value),
4328 _ => common::Error::Failure(response),
4329 });
4330 }
4331 let response = {
4332 let bytes = common::to_bytes(body).await.unwrap_or_default();
4333 let encoded = common::to_string(&bytes);
4334 match serde_json::from_str(&encoded) {
4335 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4336 Err(error) => {
4337 dlg.response_json_decode_error(&encoded, &error);
4338 return Err(common::Error::JsonDecodeError(
4339 encoded.to_string(),
4340 error,
4341 ));
4342 }
4343 }
4344 };
4345
4346 dlg.finished(true);
4347 return Ok(response);
4348 }
4349 }
4350 }
4351 }
4352
4353 ///
4354 /// Sets the *request* property to the given value.
4355 ///
4356 /// Even though the property as already been set when instantiating this call,
4357 /// we provide this method for API completeness.
4358 pub fn request(mut self, new_value: ApigatewayApi) -> ProjectLocationApiCreateCall<'a, C> {
4359 self._request = new_value;
4360 self
4361 }
4362 /// Required. Parent resource of the API, of the form: `projects/*/locations/global`
4363 ///
4364 /// Sets the *parent* path property to the given value.
4365 ///
4366 /// Even though the property as already been set when instantiating this call,
4367 /// we provide this method for API completeness.
4368 pub fn parent(mut self, new_value: &str) -> ProjectLocationApiCreateCall<'a, C> {
4369 self._parent = new_value.to_string();
4370 self
4371 }
4372 /// Required. Identifier to assign to the API. Must be unique within scope of the parent resource.
4373 ///
4374 /// Sets the *api id* query property to the given value.
4375 pub fn api_id(mut self, new_value: &str) -> ProjectLocationApiCreateCall<'a, C> {
4376 self._api_id = Some(new_value.to_string());
4377 self
4378 }
4379 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4380 /// while executing the actual API request.
4381 ///
4382 /// ````text
4383 /// It should be used to handle progress information, and to implement a certain level of resilience.
4384 /// ````
4385 ///
4386 /// Sets the *delegate* property to the given value.
4387 pub fn delegate(
4388 mut self,
4389 new_value: &'a mut dyn common::Delegate,
4390 ) -> ProjectLocationApiCreateCall<'a, C> {
4391 self._delegate = Some(new_value);
4392 self
4393 }
4394
4395 /// Set any additional parameter of the query string used in the request.
4396 /// It should be used to set parameters which are not yet available through their own
4397 /// setters.
4398 ///
4399 /// Please note that this method must not be used to set any of the known parameters
4400 /// which have their own setter method. If done anyway, the request will fail.
4401 ///
4402 /// # Additional Parameters
4403 ///
4404 /// * *$.xgafv* (query-string) - V1 error format.
4405 /// * *access_token* (query-string) - OAuth access token.
4406 /// * *alt* (query-string) - Data format for response.
4407 /// * *callback* (query-string) - JSONP
4408 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4409 /// * *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.
4410 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4411 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4412 /// * *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.
4413 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4414 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4415 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationApiCreateCall<'a, C>
4416 where
4417 T: AsRef<str>,
4418 {
4419 self._additional_params
4420 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4421 self
4422 }
4423
4424 /// Identifies the authorization scope for the method you are building.
4425 ///
4426 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4427 /// [`Scope::CloudPlatform`].
4428 ///
4429 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4430 /// tokens for more than one scope.
4431 ///
4432 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4433 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4434 /// sufficient, a read-write scope will do as well.
4435 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationApiCreateCall<'a, C>
4436 where
4437 St: AsRef<str>,
4438 {
4439 self._scopes.insert(String::from(scope.as_ref()));
4440 self
4441 }
4442 /// Identifies the authorization scope(s) for the method you are building.
4443 ///
4444 /// See [`Self::add_scope()`] for details.
4445 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationApiCreateCall<'a, C>
4446 where
4447 I: IntoIterator<Item = St>,
4448 St: AsRef<str>,
4449 {
4450 self._scopes
4451 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4452 self
4453 }
4454
4455 /// Removes all scopes, and no default scope will be used either.
4456 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4457 /// for details).
4458 pub fn clear_scopes(mut self) -> ProjectLocationApiCreateCall<'a, C> {
4459 self._scopes.clear();
4460 self
4461 }
4462}
4463
4464/// Deletes a single Api.
4465///
4466/// A builder for the *locations.apis.delete* method supported by a *project* resource.
4467/// It is not used directly, but through a [`ProjectMethods`] instance.
4468///
4469/// # Example
4470///
4471/// Instantiate a resource method builder
4472///
4473/// ```test_harness,no_run
4474/// # extern crate hyper;
4475/// # extern crate hyper_rustls;
4476/// # extern crate google_apigateway1 as apigateway1;
4477/// # async fn dox() {
4478/// # use apigateway1::{Apigateway, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4479///
4480/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4481/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4482/// # .with_native_roots()
4483/// # .unwrap()
4484/// # .https_only()
4485/// # .enable_http2()
4486/// # .build();
4487///
4488/// # let executor = hyper_util::rt::TokioExecutor::new();
4489/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4490/// # secret,
4491/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4492/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4493/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4494/// # ),
4495/// # ).build().await.unwrap();
4496///
4497/// # let client = hyper_util::client::legacy::Client::builder(
4498/// # hyper_util::rt::TokioExecutor::new()
4499/// # )
4500/// # .build(
4501/// # hyper_rustls::HttpsConnectorBuilder::new()
4502/// # .with_native_roots()
4503/// # .unwrap()
4504/// # .https_or_http()
4505/// # .enable_http2()
4506/// # .build()
4507/// # );
4508/// # let mut hub = Apigateway::new(client, auth);
4509/// // You can configure optional parameters by calling the respective setters at will, and
4510/// // execute the final call using `doit()`.
4511/// // Values shown here are possibly random and not representative !
4512/// let result = hub.projects().locations_apis_delete("name")
4513/// .doit().await;
4514/// # }
4515/// ```
4516pub struct ProjectLocationApiDeleteCall<'a, C>
4517where
4518 C: 'a,
4519{
4520 hub: &'a Apigateway<C>,
4521 _name: String,
4522 _delegate: Option<&'a mut dyn common::Delegate>,
4523 _additional_params: HashMap<String, String>,
4524 _scopes: BTreeSet<String>,
4525}
4526
4527impl<'a, C> common::CallBuilder for ProjectLocationApiDeleteCall<'a, C> {}
4528
4529impl<'a, C> ProjectLocationApiDeleteCall<'a, C>
4530where
4531 C: common::Connector,
4532{
4533 /// Perform the operation you have build so far.
4534 pub async fn doit(mut self) -> common::Result<(common::Response, ApigatewayOperation)> {
4535 use std::borrow::Cow;
4536 use std::io::{Read, Seek};
4537
4538 use common::{url::Params, ToParts};
4539 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4540
4541 let mut dd = common::DefaultDelegate;
4542 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4543 dlg.begin(common::MethodInfo {
4544 id: "apigateway.projects.locations.apis.delete",
4545 http_method: hyper::Method::DELETE,
4546 });
4547
4548 for &field in ["alt", "name"].iter() {
4549 if self._additional_params.contains_key(field) {
4550 dlg.finished(false);
4551 return Err(common::Error::FieldClash(field));
4552 }
4553 }
4554
4555 let mut params = Params::with_capacity(3 + self._additional_params.len());
4556 params.push("name", self._name);
4557
4558 params.extend(self._additional_params.iter());
4559
4560 params.push("alt", "json");
4561 let mut url = self.hub._base_url.clone() + "v1/{+name}";
4562 if self._scopes.is_empty() {
4563 self._scopes
4564 .insert(Scope::CloudPlatform.as_ref().to_string());
4565 }
4566
4567 #[allow(clippy::single_element_loop)]
4568 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4569 url = params.uri_replacement(url, param_name, find_this, true);
4570 }
4571 {
4572 let to_remove = ["name"];
4573 params.remove_params(&to_remove);
4574 }
4575
4576 let url = params.parse_with_url(&url);
4577
4578 loop {
4579 let token = match self
4580 .hub
4581 .auth
4582 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4583 .await
4584 {
4585 Ok(token) => token,
4586 Err(e) => match dlg.token(e) {
4587 Ok(token) => token,
4588 Err(e) => {
4589 dlg.finished(false);
4590 return Err(common::Error::MissingToken(e));
4591 }
4592 },
4593 };
4594 let mut req_result = {
4595 let client = &self.hub.client;
4596 dlg.pre_request();
4597 let mut req_builder = hyper::Request::builder()
4598 .method(hyper::Method::DELETE)
4599 .uri(url.as_str())
4600 .header(USER_AGENT, self.hub._user_agent.clone());
4601
4602 if let Some(token) = token.as_ref() {
4603 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4604 }
4605
4606 let request = req_builder
4607 .header(CONTENT_LENGTH, 0_u64)
4608 .body(common::to_body::<String>(None));
4609
4610 client.request(request.unwrap()).await
4611 };
4612
4613 match req_result {
4614 Err(err) => {
4615 if let common::Retry::After(d) = dlg.http_error(&err) {
4616 sleep(d).await;
4617 continue;
4618 }
4619 dlg.finished(false);
4620 return Err(common::Error::HttpError(err));
4621 }
4622 Ok(res) => {
4623 let (mut parts, body) = res.into_parts();
4624 let mut body = common::Body::new(body);
4625 if !parts.status.is_success() {
4626 let bytes = common::to_bytes(body).await.unwrap_or_default();
4627 let error = serde_json::from_str(&common::to_string(&bytes));
4628 let response = common::to_response(parts, bytes.into());
4629
4630 if let common::Retry::After(d) =
4631 dlg.http_failure(&response, error.as_ref().ok())
4632 {
4633 sleep(d).await;
4634 continue;
4635 }
4636
4637 dlg.finished(false);
4638
4639 return Err(match error {
4640 Ok(value) => common::Error::BadRequest(value),
4641 _ => common::Error::Failure(response),
4642 });
4643 }
4644 let response = {
4645 let bytes = common::to_bytes(body).await.unwrap_or_default();
4646 let encoded = common::to_string(&bytes);
4647 match serde_json::from_str(&encoded) {
4648 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4649 Err(error) => {
4650 dlg.response_json_decode_error(&encoded, &error);
4651 return Err(common::Error::JsonDecodeError(
4652 encoded.to_string(),
4653 error,
4654 ));
4655 }
4656 }
4657 };
4658
4659 dlg.finished(true);
4660 return Ok(response);
4661 }
4662 }
4663 }
4664 }
4665
4666 /// Required. Resource name of the form: `projects/*/locations/global/apis/*`
4667 ///
4668 /// Sets the *name* path property to the given value.
4669 ///
4670 /// Even though the property as already been set when instantiating this call,
4671 /// we provide this method for API completeness.
4672 pub fn name(mut self, new_value: &str) -> ProjectLocationApiDeleteCall<'a, C> {
4673 self._name = new_value.to_string();
4674 self
4675 }
4676 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4677 /// while executing the actual API request.
4678 ///
4679 /// ````text
4680 /// It should be used to handle progress information, and to implement a certain level of resilience.
4681 /// ````
4682 ///
4683 /// Sets the *delegate* property to the given value.
4684 pub fn delegate(
4685 mut self,
4686 new_value: &'a mut dyn common::Delegate,
4687 ) -> ProjectLocationApiDeleteCall<'a, C> {
4688 self._delegate = Some(new_value);
4689 self
4690 }
4691
4692 /// Set any additional parameter of the query string used in the request.
4693 /// It should be used to set parameters which are not yet available through their own
4694 /// setters.
4695 ///
4696 /// Please note that this method must not be used to set any of the known parameters
4697 /// which have their own setter method. If done anyway, the request will fail.
4698 ///
4699 /// # Additional Parameters
4700 ///
4701 /// * *$.xgafv* (query-string) - V1 error format.
4702 /// * *access_token* (query-string) - OAuth access token.
4703 /// * *alt* (query-string) - Data format for response.
4704 /// * *callback* (query-string) - JSONP
4705 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4706 /// * *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.
4707 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4708 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4709 /// * *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.
4710 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4711 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4712 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationApiDeleteCall<'a, C>
4713 where
4714 T: AsRef<str>,
4715 {
4716 self._additional_params
4717 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4718 self
4719 }
4720
4721 /// Identifies the authorization scope for the method you are building.
4722 ///
4723 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4724 /// [`Scope::CloudPlatform`].
4725 ///
4726 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4727 /// tokens for more than one scope.
4728 ///
4729 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4730 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4731 /// sufficient, a read-write scope will do as well.
4732 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationApiDeleteCall<'a, C>
4733 where
4734 St: AsRef<str>,
4735 {
4736 self._scopes.insert(String::from(scope.as_ref()));
4737 self
4738 }
4739 /// Identifies the authorization scope(s) for the method you are building.
4740 ///
4741 /// See [`Self::add_scope()`] for details.
4742 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationApiDeleteCall<'a, C>
4743 where
4744 I: IntoIterator<Item = St>,
4745 St: AsRef<str>,
4746 {
4747 self._scopes
4748 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4749 self
4750 }
4751
4752 /// Removes all scopes, and no default scope will be used either.
4753 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4754 /// for details).
4755 pub fn clear_scopes(mut self) -> ProjectLocationApiDeleteCall<'a, C> {
4756 self._scopes.clear();
4757 self
4758 }
4759}
4760
4761/// Gets details of a single Api.
4762///
4763/// A builder for the *locations.apis.get* method supported by a *project* resource.
4764/// It is not used directly, but through a [`ProjectMethods`] instance.
4765///
4766/// # Example
4767///
4768/// Instantiate a resource method builder
4769///
4770/// ```test_harness,no_run
4771/// # extern crate hyper;
4772/// # extern crate hyper_rustls;
4773/// # extern crate google_apigateway1 as apigateway1;
4774/// # async fn dox() {
4775/// # use apigateway1::{Apigateway, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4776///
4777/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4778/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4779/// # .with_native_roots()
4780/// # .unwrap()
4781/// # .https_only()
4782/// # .enable_http2()
4783/// # .build();
4784///
4785/// # let executor = hyper_util::rt::TokioExecutor::new();
4786/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4787/// # secret,
4788/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4789/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4790/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4791/// # ),
4792/// # ).build().await.unwrap();
4793///
4794/// # let client = hyper_util::client::legacy::Client::builder(
4795/// # hyper_util::rt::TokioExecutor::new()
4796/// # )
4797/// # .build(
4798/// # hyper_rustls::HttpsConnectorBuilder::new()
4799/// # .with_native_roots()
4800/// # .unwrap()
4801/// # .https_or_http()
4802/// # .enable_http2()
4803/// # .build()
4804/// # );
4805/// # let mut hub = Apigateway::new(client, auth);
4806/// // You can configure optional parameters by calling the respective setters at will, and
4807/// // execute the final call using `doit()`.
4808/// // Values shown here are possibly random and not representative !
4809/// let result = hub.projects().locations_apis_get("name")
4810/// .doit().await;
4811/// # }
4812/// ```
4813pub struct ProjectLocationApiGetCall<'a, C>
4814where
4815 C: 'a,
4816{
4817 hub: &'a Apigateway<C>,
4818 _name: String,
4819 _delegate: Option<&'a mut dyn common::Delegate>,
4820 _additional_params: HashMap<String, String>,
4821 _scopes: BTreeSet<String>,
4822}
4823
4824impl<'a, C> common::CallBuilder for ProjectLocationApiGetCall<'a, C> {}
4825
4826impl<'a, C> ProjectLocationApiGetCall<'a, C>
4827where
4828 C: common::Connector,
4829{
4830 /// Perform the operation you have build so far.
4831 pub async fn doit(mut self) -> common::Result<(common::Response, ApigatewayApi)> {
4832 use std::borrow::Cow;
4833 use std::io::{Read, Seek};
4834
4835 use common::{url::Params, ToParts};
4836 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4837
4838 let mut dd = common::DefaultDelegate;
4839 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4840 dlg.begin(common::MethodInfo {
4841 id: "apigateway.projects.locations.apis.get",
4842 http_method: hyper::Method::GET,
4843 });
4844
4845 for &field in ["alt", "name"].iter() {
4846 if self._additional_params.contains_key(field) {
4847 dlg.finished(false);
4848 return Err(common::Error::FieldClash(field));
4849 }
4850 }
4851
4852 let mut params = Params::with_capacity(3 + self._additional_params.len());
4853 params.push("name", self._name);
4854
4855 params.extend(self._additional_params.iter());
4856
4857 params.push("alt", "json");
4858 let mut url = self.hub._base_url.clone() + "v1/{+name}";
4859 if self._scopes.is_empty() {
4860 self._scopes
4861 .insert(Scope::CloudPlatform.as_ref().to_string());
4862 }
4863
4864 #[allow(clippy::single_element_loop)]
4865 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4866 url = params.uri_replacement(url, param_name, find_this, true);
4867 }
4868 {
4869 let to_remove = ["name"];
4870 params.remove_params(&to_remove);
4871 }
4872
4873 let url = params.parse_with_url(&url);
4874
4875 loop {
4876 let token = match self
4877 .hub
4878 .auth
4879 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4880 .await
4881 {
4882 Ok(token) => token,
4883 Err(e) => match dlg.token(e) {
4884 Ok(token) => token,
4885 Err(e) => {
4886 dlg.finished(false);
4887 return Err(common::Error::MissingToken(e));
4888 }
4889 },
4890 };
4891 let mut req_result = {
4892 let client = &self.hub.client;
4893 dlg.pre_request();
4894 let mut req_builder = hyper::Request::builder()
4895 .method(hyper::Method::GET)
4896 .uri(url.as_str())
4897 .header(USER_AGENT, self.hub._user_agent.clone());
4898
4899 if let Some(token) = token.as_ref() {
4900 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4901 }
4902
4903 let request = req_builder
4904 .header(CONTENT_LENGTH, 0_u64)
4905 .body(common::to_body::<String>(None));
4906
4907 client.request(request.unwrap()).await
4908 };
4909
4910 match req_result {
4911 Err(err) => {
4912 if let common::Retry::After(d) = dlg.http_error(&err) {
4913 sleep(d).await;
4914 continue;
4915 }
4916 dlg.finished(false);
4917 return Err(common::Error::HttpError(err));
4918 }
4919 Ok(res) => {
4920 let (mut parts, body) = res.into_parts();
4921 let mut body = common::Body::new(body);
4922 if !parts.status.is_success() {
4923 let bytes = common::to_bytes(body).await.unwrap_or_default();
4924 let error = serde_json::from_str(&common::to_string(&bytes));
4925 let response = common::to_response(parts, bytes.into());
4926
4927 if let common::Retry::After(d) =
4928 dlg.http_failure(&response, error.as_ref().ok())
4929 {
4930 sleep(d).await;
4931 continue;
4932 }
4933
4934 dlg.finished(false);
4935
4936 return Err(match error {
4937 Ok(value) => common::Error::BadRequest(value),
4938 _ => common::Error::Failure(response),
4939 });
4940 }
4941 let response = {
4942 let bytes = common::to_bytes(body).await.unwrap_or_default();
4943 let encoded = common::to_string(&bytes);
4944 match serde_json::from_str(&encoded) {
4945 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4946 Err(error) => {
4947 dlg.response_json_decode_error(&encoded, &error);
4948 return Err(common::Error::JsonDecodeError(
4949 encoded.to_string(),
4950 error,
4951 ));
4952 }
4953 }
4954 };
4955
4956 dlg.finished(true);
4957 return Ok(response);
4958 }
4959 }
4960 }
4961 }
4962
4963 /// Required. Resource name of the form: `projects/*/locations/global/apis/*`
4964 ///
4965 /// Sets the *name* path property to the given value.
4966 ///
4967 /// Even though the property as already been set when instantiating this call,
4968 /// we provide this method for API completeness.
4969 pub fn name(mut self, new_value: &str) -> ProjectLocationApiGetCall<'a, C> {
4970 self._name = new_value.to_string();
4971 self
4972 }
4973 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4974 /// while executing the actual API request.
4975 ///
4976 /// ````text
4977 /// It should be used to handle progress information, and to implement a certain level of resilience.
4978 /// ````
4979 ///
4980 /// Sets the *delegate* property to the given value.
4981 pub fn delegate(
4982 mut self,
4983 new_value: &'a mut dyn common::Delegate,
4984 ) -> ProjectLocationApiGetCall<'a, C> {
4985 self._delegate = Some(new_value);
4986 self
4987 }
4988
4989 /// Set any additional parameter of the query string used in the request.
4990 /// It should be used to set parameters which are not yet available through their own
4991 /// setters.
4992 ///
4993 /// Please note that this method must not be used to set any of the known parameters
4994 /// which have their own setter method. If done anyway, the request will fail.
4995 ///
4996 /// # Additional Parameters
4997 ///
4998 /// * *$.xgafv* (query-string) - V1 error format.
4999 /// * *access_token* (query-string) - OAuth access token.
5000 /// * *alt* (query-string) - Data format for response.
5001 /// * *callback* (query-string) - JSONP
5002 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5003 /// * *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.
5004 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5005 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5006 /// * *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.
5007 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5008 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5009 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationApiGetCall<'a, C>
5010 where
5011 T: AsRef<str>,
5012 {
5013 self._additional_params
5014 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5015 self
5016 }
5017
5018 /// Identifies the authorization scope for the method you are building.
5019 ///
5020 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5021 /// [`Scope::CloudPlatform`].
5022 ///
5023 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5024 /// tokens for more than one scope.
5025 ///
5026 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5027 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5028 /// sufficient, a read-write scope will do as well.
5029 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationApiGetCall<'a, C>
5030 where
5031 St: AsRef<str>,
5032 {
5033 self._scopes.insert(String::from(scope.as_ref()));
5034 self
5035 }
5036 /// Identifies the authorization scope(s) for the method you are building.
5037 ///
5038 /// See [`Self::add_scope()`] for details.
5039 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationApiGetCall<'a, C>
5040 where
5041 I: IntoIterator<Item = St>,
5042 St: AsRef<str>,
5043 {
5044 self._scopes
5045 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5046 self
5047 }
5048
5049 /// Removes all scopes, and no default scope will be used either.
5050 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5051 /// for details).
5052 pub fn clear_scopes(mut self) -> ProjectLocationApiGetCall<'a, C> {
5053 self._scopes.clear();
5054 self
5055 }
5056}
5057
5058/// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
5059///
5060/// A builder for the *locations.apis.getIamPolicy* method supported by a *project* resource.
5061/// It is not used directly, but through a [`ProjectMethods`] instance.
5062///
5063/// # Example
5064///
5065/// Instantiate a resource method builder
5066///
5067/// ```test_harness,no_run
5068/// # extern crate hyper;
5069/// # extern crate hyper_rustls;
5070/// # extern crate google_apigateway1 as apigateway1;
5071/// # async fn dox() {
5072/// # use apigateway1::{Apigateway, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5073///
5074/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5075/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5076/// # .with_native_roots()
5077/// # .unwrap()
5078/// # .https_only()
5079/// # .enable_http2()
5080/// # .build();
5081///
5082/// # let executor = hyper_util::rt::TokioExecutor::new();
5083/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5084/// # secret,
5085/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5086/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5087/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5088/// # ),
5089/// # ).build().await.unwrap();
5090///
5091/// # let client = hyper_util::client::legacy::Client::builder(
5092/// # hyper_util::rt::TokioExecutor::new()
5093/// # )
5094/// # .build(
5095/// # hyper_rustls::HttpsConnectorBuilder::new()
5096/// # .with_native_roots()
5097/// # .unwrap()
5098/// # .https_or_http()
5099/// # .enable_http2()
5100/// # .build()
5101/// # );
5102/// # let mut hub = Apigateway::new(client, auth);
5103/// // You can configure optional parameters by calling the respective setters at will, and
5104/// // execute the final call using `doit()`.
5105/// // Values shown here are possibly random and not representative !
5106/// let result = hub.projects().locations_apis_get_iam_policy("resource")
5107/// .options_requested_policy_version(-12)
5108/// .doit().await;
5109/// # }
5110/// ```
5111pub struct ProjectLocationApiGetIamPolicyCall<'a, C>
5112where
5113 C: 'a,
5114{
5115 hub: &'a Apigateway<C>,
5116 _resource: String,
5117 _options_requested_policy_version: Option<i32>,
5118 _delegate: Option<&'a mut dyn common::Delegate>,
5119 _additional_params: HashMap<String, String>,
5120 _scopes: BTreeSet<String>,
5121}
5122
5123impl<'a, C> common::CallBuilder for ProjectLocationApiGetIamPolicyCall<'a, C> {}
5124
5125impl<'a, C> ProjectLocationApiGetIamPolicyCall<'a, C>
5126where
5127 C: common::Connector,
5128{
5129 /// Perform the operation you have build so far.
5130 pub async fn doit(mut self) -> common::Result<(common::Response, ApigatewayPolicy)> {
5131 use std::borrow::Cow;
5132 use std::io::{Read, Seek};
5133
5134 use common::{url::Params, ToParts};
5135 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5136
5137 let mut dd = common::DefaultDelegate;
5138 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5139 dlg.begin(common::MethodInfo {
5140 id: "apigateway.projects.locations.apis.getIamPolicy",
5141 http_method: hyper::Method::GET,
5142 });
5143
5144 for &field in ["alt", "resource", "options.requestedPolicyVersion"].iter() {
5145 if self._additional_params.contains_key(field) {
5146 dlg.finished(false);
5147 return Err(common::Error::FieldClash(field));
5148 }
5149 }
5150
5151 let mut params = Params::with_capacity(4 + self._additional_params.len());
5152 params.push("resource", self._resource);
5153 if let Some(value) = self._options_requested_policy_version.as_ref() {
5154 params.push("options.requestedPolicyVersion", value.to_string());
5155 }
5156
5157 params.extend(self._additional_params.iter());
5158
5159 params.push("alt", "json");
5160 let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
5161 if self._scopes.is_empty() {
5162 self._scopes
5163 .insert(Scope::CloudPlatform.as_ref().to_string());
5164 }
5165
5166 #[allow(clippy::single_element_loop)]
5167 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
5168 url = params.uri_replacement(url, param_name, find_this, true);
5169 }
5170 {
5171 let to_remove = ["resource"];
5172 params.remove_params(&to_remove);
5173 }
5174
5175 let url = params.parse_with_url(&url);
5176
5177 loop {
5178 let token = match self
5179 .hub
5180 .auth
5181 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5182 .await
5183 {
5184 Ok(token) => token,
5185 Err(e) => match dlg.token(e) {
5186 Ok(token) => token,
5187 Err(e) => {
5188 dlg.finished(false);
5189 return Err(common::Error::MissingToken(e));
5190 }
5191 },
5192 };
5193 let mut req_result = {
5194 let client = &self.hub.client;
5195 dlg.pre_request();
5196 let mut req_builder = hyper::Request::builder()
5197 .method(hyper::Method::GET)
5198 .uri(url.as_str())
5199 .header(USER_AGENT, self.hub._user_agent.clone());
5200
5201 if let Some(token) = token.as_ref() {
5202 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5203 }
5204
5205 let request = req_builder
5206 .header(CONTENT_LENGTH, 0_u64)
5207 .body(common::to_body::<String>(None));
5208
5209 client.request(request.unwrap()).await
5210 };
5211
5212 match req_result {
5213 Err(err) => {
5214 if let common::Retry::After(d) = dlg.http_error(&err) {
5215 sleep(d).await;
5216 continue;
5217 }
5218 dlg.finished(false);
5219 return Err(common::Error::HttpError(err));
5220 }
5221 Ok(res) => {
5222 let (mut parts, body) = res.into_parts();
5223 let mut body = common::Body::new(body);
5224 if !parts.status.is_success() {
5225 let bytes = common::to_bytes(body).await.unwrap_or_default();
5226 let error = serde_json::from_str(&common::to_string(&bytes));
5227 let response = common::to_response(parts, bytes.into());
5228
5229 if let common::Retry::After(d) =
5230 dlg.http_failure(&response, error.as_ref().ok())
5231 {
5232 sleep(d).await;
5233 continue;
5234 }
5235
5236 dlg.finished(false);
5237
5238 return Err(match error {
5239 Ok(value) => common::Error::BadRequest(value),
5240 _ => common::Error::Failure(response),
5241 });
5242 }
5243 let response = {
5244 let bytes = common::to_bytes(body).await.unwrap_or_default();
5245 let encoded = common::to_string(&bytes);
5246 match serde_json::from_str(&encoded) {
5247 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5248 Err(error) => {
5249 dlg.response_json_decode_error(&encoded, &error);
5250 return Err(common::Error::JsonDecodeError(
5251 encoded.to_string(),
5252 error,
5253 ));
5254 }
5255 }
5256 };
5257
5258 dlg.finished(true);
5259 return Ok(response);
5260 }
5261 }
5262 }
5263 }
5264
5265 /// 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.
5266 ///
5267 /// Sets the *resource* path property to the given value.
5268 ///
5269 /// Even though the property as already been set when instantiating this call,
5270 /// we provide this method for API completeness.
5271 pub fn resource(mut self, new_value: &str) -> ProjectLocationApiGetIamPolicyCall<'a, C> {
5272 self._resource = new_value.to_string();
5273 self
5274 }
5275 /// 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).
5276 ///
5277 /// Sets the *options.requested policy version* query property to the given value.
5278 pub fn options_requested_policy_version(
5279 mut self,
5280 new_value: i32,
5281 ) -> ProjectLocationApiGetIamPolicyCall<'a, C> {
5282 self._options_requested_policy_version = Some(new_value);
5283 self
5284 }
5285 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5286 /// while executing the actual API request.
5287 ///
5288 /// ````text
5289 /// It should be used to handle progress information, and to implement a certain level of resilience.
5290 /// ````
5291 ///
5292 /// Sets the *delegate* property to the given value.
5293 pub fn delegate(
5294 mut self,
5295 new_value: &'a mut dyn common::Delegate,
5296 ) -> ProjectLocationApiGetIamPolicyCall<'a, C> {
5297 self._delegate = Some(new_value);
5298 self
5299 }
5300
5301 /// Set any additional parameter of the query string used in the request.
5302 /// It should be used to set parameters which are not yet available through their own
5303 /// setters.
5304 ///
5305 /// Please note that this method must not be used to set any of the known parameters
5306 /// which have their own setter method. If done anyway, the request will fail.
5307 ///
5308 /// # Additional Parameters
5309 ///
5310 /// * *$.xgafv* (query-string) - V1 error format.
5311 /// * *access_token* (query-string) - OAuth access token.
5312 /// * *alt* (query-string) - Data format for response.
5313 /// * *callback* (query-string) - JSONP
5314 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5315 /// * *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.
5316 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5317 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5318 /// * *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.
5319 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5320 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5321 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationApiGetIamPolicyCall<'a, C>
5322 where
5323 T: AsRef<str>,
5324 {
5325 self._additional_params
5326 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5327 self
5328 }
5329
5330 /// Identifies the authorization scope for the method you are building.
5331 ///
5332 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5333 /// [`Scope::CloudPlatform`].
5334 ///
5335 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5336 /// tokens for more than one scope.
5337 ///
5338 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5339 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5340 /// sufficient, a read-write scope will do as well.
5341 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationApiGetIamPolicyCall<'a, C>
5342 where
5343 St: AsRef<str>,
5344 {
5345 self._scopes.insert(String::from(scope.as_ref()));
5346 self
5347 }
5348 /// Identifies the authorization scope(s) for the method you are building.
5349 ///
5350 /// See [`Self::add_scope()`] for details.
5351 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationApiGetIamPolicyCall<'a, C>
5352 where
5353 I: IntoIterator<Item = St>,
5354 St: AsRef<str>,
5355 {
5356 self._scopes
5357 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5358 self
5359 }
5360
5361 /// Removes all scopes, and no default scope will be used either.
5362 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5363 /// for details).
5364 pub fn clear_scopes(mut self) -> ProjectLocationApiGetIamPolicyCall<'a, C> {
5365 self._scopes.clear();
5366 self
5367 }
5368}
5369
5370/// Lists Apis in a given project and location.
5371///
5372/// A builder for the *locations.apis.list* method supported by a *project* resource.
5373/// It is not used directly, but through a [`ProjectMethods`] instance.
5374///
5375/// # Example
5376///
5377/// Instantiate a resource method builder
5378///
5379/// ```test_harness,no_run
5380/// # extern crate hyper;
5381/// # extern crate hyper_rustls;
5382/// # extern crate google_apigateway1 as apigateway1;
5383/// # async fn dox() {
5384/// # use apigateway1::{Apigateway, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5385///
5386/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5387/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5388/// # .with_native_roots()
5389/// # .unwrap()
5390/// # .https_only()
5391/// # .enable_http2()
5392/// # .build();
5393///
5394/// # let executor = hyper_util::rt::TokioExecutor::new();
5395/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5396/// # secret,
5397/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5398/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5399/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5400/// # ),
5401/// # ).build().await.unwrap();
5402///
5403/// # let client = hyper_util::client::legacy::Client::builder(
5404/// # hyper_util::rt::TokioExecutor::new()
5405/// # )
5406/// # .build(
5407/// # hyper_rustls::HttpsConnectorBuilder::new()
5408/// # .with_native_roots()
5409/// # .unwrap()
5410/// # .https_or_http()
5411/// # .enable_http2()
5412/// # .build()
5413/// # );
5414/// # let mut hub = Apigateway::new(client, auth);
5415/// // You can configure optional parameters by calling the respective setters at will, and
5416/// // execute the final call using `doit()`.
5417/// // Values shown here are possibly random and not representative !
5418/// let result = hub.projects().locations_apis_list("parent")
5419/// .page_token("est")
5420/// .page_size(-50)
5421/// .order_by("ipsum")
5422/// .filter("est")
5423/// .doit().await;
5424/// # }
5425/// ```
5426pub struct ProjectLocationApiListCall<'a, C>
5427where
5428 C: 'a,
5429{
5430 hub: &'a Apigateway<C>,
5431 _parent: String,
5432 _page_token: Option<String>,
5433 _page_size: Option<i32>,
5434 _order_by: Option<String>,
5435 _filter: Option<String>,
5436 _delegate: Option<&'a mut dyn common::Delegate>,
5437 _additional_params: HashMap<String, String>,
5438 _scopes: BTreeSet<String>,
5439}
5440
5441impl<'a, C> common::CallBuilder for ProjectLocationApiListCall<'a, C> {}
5442
5443impl<'a, C> ProjectLocationApiListCall<'a, C>
5444where
5445 C: common::Connector,
5446{
5447 /// Perform the operation you have build so far.
5448 pub async fn doit(mut self) -> common::Result<(common::Response, ApigatewayListApisResponse)> {
5449 use std::borrow::Cow;
5450 use std::io::{Read, Seek};
5451
5452 use common::{url::Params, ToParts};
5453 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5454
5455 let mut dd = common::DefaultDelegate;
5456 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5457 dlg.begin(common::MethodInfo {
5458 id: "apigateway.projects.locations.apis.list",
5459 http_method: hyper::Method::GET,
5460 });
5461
5462 for &field in [
5463 "alt",
5464 "parent",
5465 "pageToken",
5466 "pageSize",
5467 "orderBy",
5468 "filter",
5469 ]
5470 .iter()
5471 {
5472 if self._additional_params.contains_key(field) {
5473 dlg.finished(false);
5474 return Err(common::Error::FieldClash(field));
5475 }
5476 }
5477
5478 let mut params = Params::with_capacity(7 + self._additional_params.len());
5479 params.push("parent", self._parent);
5480 if let Some(value) = self._page_token.as_ref() {
5481 params.push("pageToken", value);
5482 }
5483 if let Some(value) = self._page_size.as_ref() {
5484 params.push("pageSize", value.to_string());
5485 }
5486 if let Some(value) = self._order_by.as_ref() {
5487 params.push("orderBy", value);
5488 }
5489 if let Some(value) = self._filter.as_ref() {
5490 params.push("filter", value);
5491 }
5492
5493 params.extend(self._additional_params.iter());
5494
5495 params.push("alt", "json");
5496 let mut url = self.hub._base_url.clone() + "v1/{+parent}/apis";
5497 if self._scopes.is_empty() {
5498 self._scopes
5499 .insert(Scope::CloudPlatform.as_ref().to_string());
5500 }
5501
5502 #[allow(clippy::single_element_loop)]
5503 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
5504 url = params.uri_replacement(url, param_name, find_this, true);
5505 }
5506 {
5507 let to_remove = ["parent"];
5508 params.remove_params(&to_remove);
5509 }
5510
5511 let url = params.parse_with_url(&url);
5512
5513 loop {
5514 let token = match self
5515 .hub
5516 .auth
5517 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5518 .await
5519 {
5520 Ok(token) => token,
5521 Err(e) => match dlg.token(e) {
5522 Ok(token) => token,
5523 Err(e) => {
5524 dlg.finished(false);
5525 return Err(common::Error::MissingToken(e));
5526 }
5527 },
5528 };
5529 let mut req_result = {
5530 let client = &self.hub.client;
5531 dlg.pre_request();
5532 let mut req_builder = hyper::Request::builder()
5533 .method(hyper::Method::GET)
5534 .uri(url.as_str())
5535 .header(USER_AGENT, self.hub._user_agent.clone());
5536
5537 if let Some(token) = token.as_ref() {
5538 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5539 }
5540
5541 let request = req_builder
5542 .header(CONTENT_LENGTH, 0_u64)
5543 .body(common::to_body::<String>(None));
5544
5545 client.request(request.unwrap()).await
5546 };
5547
5548 match req_result {
5549 Err(err) => {
5550 if let common::Retry::After(d) = dlg.http_error(&err) {
5551 sleep(d).await;
5552 continue;
5553 }
5554 dlg.finished(false);
5555 return Err(common::Error::HttpError(err));
5556 }
5557 Ok(res) => {
5558 let (mut parts, body) = res.into_parts();
5559 let mut body = common::Body::new(body);
5560 if !parts.status.is_success() {
5561 let bytes = common::to_bytes(body).await.unwrap_or_default();
5562 let error = serde_json::from_str(&common::to_string(&bytes));
5563 let response = common::to_response(parts, bytes.into());
5564
5565 if let common::Retry::After(d) =
5566 dlg.http_failure(&response, error.as_ref().ok())
5567 {
5568 sleep(d).await;
5569 continue;
5570 }
5571
5572 dlg.finished(false);
5573
5574 return Err(match error {
5575 Ok(value) => common::Error::BadRequest(value),
5576 _ => common::Error::Failure(response),
5577 });
5578 }
5579 let response = {
5580 let bytes = common::to_bytes(body).await.unwrap_or_default();
5581 let encoded = common::to_string(&bytes);
5582 match serde_json::from_str(&encoded) {
5583 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5584 Err(error) => {
5585 dlg.response_json_decode_error(&encoded, &error);
5586 return Err(common::Error::JsonDecodeError(
5587 encoded.to_string(),
5588 error,
5589 ));
5590 }
5591 }
5592 };
5593
5594 dlg.finished(true);
5595 return Ok(response);
5596 }
5597 }
5598 }
5599 }
5600
5601 /// Required. Parent resource of the API, of the form: `projects/*/locations/global`
5602 ///
5603 /// Sets the *parent* path property to the given value.
5604 ///
5605 /// Even though the property as already been set when instantiating this call,
5606 /// we provide this method for API completeness.
5607 pub fn parent(mut self, new_value: &str) -> ProjectLocationApiListCall<'a, C> {
5608 self._parent = new_value.to_string();
5609 self
5610 }
5611 /// Page token.
5612 ///
5613 /// Sets the *page token* query property to the given value.
5614 pub fn page_token(mut self, new_value: &str) -> ProjectLocationApiListCall<'a, C> {
5615 self._page_token = Some(new_value.to_string());
5616 self
5617 }
5618 /// Page size.
5619 ///
5620 /// Sets the *page size* query property to the given value.
5621 pub fn page_size(mut self, new_value: i32) -> ProjectLocationApiListCall<'a, C> {
5622 self._page_size = Some(new_value);
5623 self
5624 }
5625 /// Order by parameters.
5626 ///
5627 /// Sets the *order by* query property to the given value.
5628 pub fn order_by(mut self, new_value: &str) -> ProjectLocationApiListCall<'a, C> {
5629 self._order_by = Some(new_value.to_string());
5630 self
5631 }
5632 /// Filter.
5633 ///
5634 /// Sets the *filter* query property to the given value.
5635 pub fn filter(mut self, new_value: &str) -> ProjectLocationApiListCall<'a, C> {
5636 self._filter = Some(new_value.to_string());
5637 self
5638 }
5639 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5640 /// while executing the actual API request.
5641 ///
5642 /// ````text
5643 /// It should be used to handle progress information, and to implement a certain level of resilience.
5644 /// ````
5645 ///
5646 /// Sets the *delegate* property to the given value.
5647 pub fn delegate(
5648 mut self,
5649 new_value: &'a mut dyn common::Delegate,
5650 ) -> ProjectLocationApiListCall<'a, C> {
5651 self._delegate = Some(new_value);
5652 self
5653 }
5654
5655 /// Set any additional parameter of the query string used in the request.
5656 /// It should be used to set parameters which are not yet available through their own
5657 /// setters.
5658 ///
5659 /// Please note that this method must not be used to set any of the known parameters
5660 /// which have their own setter method. If done anyway, the request will fail.
5661 ///
5662 /// # Additional Parameters
5663 ///
5664 /// * *$.xgafv* (query-string) - V1 error format.
5665 /// * *access_token* (query-string) - OAuth access token.
5666 /// * *alt* (query-string) - Data format for response.
5667 /// * *callback* (query-string) - JSONP
5668 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5669 /// * *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.
5670 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5671 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5672 /// * *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.
5673 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5674 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5675 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationApiListCall<'a, C>
5676 where
5677 T: AsRef<str>,
5678 {
5679 self._additional_params
5680 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5681 self
5682 }
5683
5684 /// Identifies the authorization scope for the method you are building.
5685 ///
5686 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5687 /// [`Scope::CloudPlatform`].
5688 ///
5689 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5690 /// tokens for more than one scope.
5691 ///
5692 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5693 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5694 /// sufficient, a read-write scope will do as well.
5695 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationApiListCall<'a, C>
5696 where
5697 St: AsRef<str>,
5698 {
5699 self._scopes.insert(String::from(scope.as_ref()));
5700 self
5701 }
5702 /// Identifies the authorization scope(s) for the method you are building.
5703 ///
5704 /// See [`Self::add_scope()`] for details.
5705 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationApiListCall<'a, C>
5706 where
5707 I: IntoIterator<Item = St>,
5708 St: AsRef<str>,
5709 {
5710 self._scopes
5711 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5712 self
5713 }
5714
5715 /// Removes all scopes, and no default scope will be used either.
5716 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5717 /// for details).
5718 pub fn clear_scopes(mut self) -> ProjectLocationApiListCall<'a, C> {
5719 self._scopes.clear();
5720 self
5721 }
5722}
5723
5724/// Updates the parameters of a single Api.
5725///
5726/// A builder for the *locations.apis.patch* method supported by a *project* resource.
5727/// It is not used directly, but through a [`ProjectMethods`] instance.
5728///
5729/// # Example
5730///
5731/// Instantiate a resource method builder
5732///
5733/// ```test_harness,no_run
5734/// # extern crate hyper;
5735/// # extern crate hyper_rustls;
5736/// # extern crate google_apigateway1 as apigateway1;
5737/// use apigateway1::api::ApigatewayApi;
5738/// # async fn dox() {
5739/// # use apigateway1::{Apigateway, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5740///
5741/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5742/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5743/// # .with_native_roots()
5744/// # .unwrap()
5745/// # .https_only()
5746/// # .enable_http2()
5747/// # .build();
5748///
5749/// # let executor = hyper_util::rt::TokioExecutor::new();
5750/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5751/// # secret,
5752/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5753/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5754/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5755/// # ),
5756/// # ).build().await.unwrap();
5757///
5758/// # let client = hyper_util::client::legacy::Client::builder(
5759/// # hyper_util::rt::TokioExecutor::new()
5760/// # )
5761/// # .build(
5762/// # hyper_rustls::HttpsConnectorBuilder::new()
5763/// # .with_native_roots()
5764/// # .unwrap()
5765/// # .https_or_http()
5766/// # .enable_http2()
5767/// # .build()
5768/// # );
5769/// # let mut hub = Apigateway::new(client, auth);
5770/// // As the method needs a request, you would usually fill it with the desired information
5771/// // into the respective structure. Some of the parts shown here might not be applicable !
5772/// // Values shown here are possibly random and not representative !
5773/// let mut req = ApigatewayApi::default();
5774///
5775/// // You can configure optional parameters by calling the respective setters at will, and
5776/// // execute the final call using `doit()`.
5777/// // Values shown here are possibly random and not representative !
5778/// let result = hub.projects().locations_apis_patch(req, "name")
5779/// .update_mask(FieldMask::new::<&str>(&[]))
5780/// .doit().await;
5781/// # }
5782/// ```
5783pub struct ProjectLocationApiPatchCall<'a, C>
5784where
5785 C: 'a,
5786{
5787 hub: &'a Apigateway<C>,
5788 _request: ApigatewayApi,
5789 _name: String,
5790 _update_mask: Option<common::FieldMask>,
5791 _delegate: Option<&'a mut dyn common::Delegate>,
5792 _additional_params: HashMap<String, String>,
5793 _scopes: BTreeSet<String>,
5794}
5795
5796impl<'a, C> common::CallBuilder for ProjectLocationApiPatchCall<'a, C> {}
5797
5798impl<'a, C> ProjectLocationApiPatchCall<'a, C>
5799where
5800 C: common::Connector,
5801{
5802 /// Perform the operation you have build so far.
5803 pub async fn doit(mut self) -> common::Result<(common::Response, ApigatewayOperation)> {
5804 use std::borrow::Cow;
5805 use std::io::{Read, Seek};
5806
5807 use common::{url::Params, ToParts};
5808 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5809
5810 let mut dd = common::DefaultDelegate;
5811 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5812 dlg.begin(common::MethodInfo {
5813 id: "apigateway.projects.locations.apis.patch",
5814 http_method: hyper::Method::PATCH,
5815 });
5816
5817 for &field in ["alt", "name", "updateMask"].iter() {
5818 if self._additional_params.contains_key(field) {
5819 dlg.finished(false);
5820 return Err(common::Error::FieldClash(field));
5821 }
5822 }
5823
5824 let mut params = Params::with_capacity(5 + self._additional_params.len());
5825 params.push("name", self._name);
5826 if let Some(value) = self._update_mask.as_ref() {
5827 params.push("updateMask", value.to_string());
5828 }
5829
5830 params.extend(self._additional_params.iter());
5831
5832 params.push("alt", "json");
5833 let mut url = self.hub._base_url.clone() + "v1/{+name}";
5834 if self._scopes.is_empty() {
5835 self._scopes
5836 .insert(Scope::CloudPlatform.as_ref().to_string());
5837 }
5838
5839 #[allow(clippy::single_element_loop)]
5840 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5841 url = params.uri_replacement(url, param_name, find_this, true);
5842 }
5843 {
5844 let to_remove = ["name"];
5845 params.remove_params(&to_remove);
5846 }
5847
5848 let url = params.parse_with_url(&url);
5849
5850 let mut json_mime_type = mime::APPLICATION_JSON;
5851 let mut request_value_reader = {
5852 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5853 common::remove_json_null_values(&mut value);
5854 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5855 serde_json::to_writer(&mut dst, &value).unwrap();
5856 dst
5857 };
5858 let request_size = request_value_reader
5859 .seek(std::io::SeekFrom::End(0))
5860 .unwrap();
5861 request_value_reader
5862 .seek(std::io::SeekFrom::Start(0))
5863 .unwrap();
5864
5865 loop {
5866 let token = match self
5867 .hub
5868 .auth
5869 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5870 .await
5871 {
5872 Ok(token) => token,
5873 Err(e) => match dlg.token(e) {
5874 Ok(token) => token,
5875 Err(e) => {
5876 dlg.finished(false);
5877 return Err(common::Error::MissingToken(e));
5878 }
5879 },
5880 };
5881 request_value_reader
5882 .seek(std::io::SeekFrom::Start(0))
5883 .unwrap();
5884 let mut req_result = {
5885 let client = &self.hub.client;
5886 dlg.pre_request();
5887 let mut req_builder = hyper::Request::builder()
5888 .method(hyper::Method::PATCH)
5889 .uri(url.as_str())
5890 .header(USER_AGENT, self.hub._user_agent.clone());
5891
5892 if let Some(token) = token.as_ref() {
5893 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5894 }
5895
5896 let request = req_builder
5897 .header(CONTENT_TYPE, json_mime_type.to_string())
5898 .header(CONTENT_LENGTH, request_size as u64)
5899 .body(common::to_body(
5900 request_value_reader.get_ref().clone().into(),
5901 ));
5902
5903 client.request(request.unwrap()).await
5904 };
5905
5906 match req_result {
5907 Err(err) => {
5908 if let common::Retry::After(d) = dlg.http_error(&err) {
5909 sleep(d).await;
5910 continue;
5911 }
5912 dlg.finished(false);
5913 return Err(common::Error::HttpError(err));
5914 }
5915 Ok(res) => {
5916 let (mut parts, body) = res.into_parts();
5917 let mut body = common::Body::new(body);
5918 if !parts.status.is_success() {
5919 let bytes = common::to_bytes(body).await.unwrap_or_default();
5920 let error = serde_json::from_str(&common::to_string(&bytes));
5921 let response = common::to_response(parts, bytes.into());
5922
5923 if let common::Retry::After(d) =
5924 dlg.http_failure(&response, error.as_ref().ok())
5925 {
5926 sleep(d).await;
5927 continue;
5928 }
5929
5930 dlg.finished(false);
5931
5932 return Err(match error {
5933 Ok(value) => common::Error::BadRequest(value),
5934 _ => common::Error::Failure(response),
5935 });
5936 }
5937 let response = {
5938 let bytes = common::to_bytes(body).await.unwrap_or_default();
5939 let encoded = common::to_string(&bytes);
5940 match serde_json::from_str(&encoded) {
5941 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5942 Err(error) => {
5943 dlg.response_json_decode_error(&encoded, &error);
5944 return Err(common::Error::JsonDecodeError(
5945 encoded.to_string(),
5946 error,
5947 ));
5948 }
5949 }
5950 };
5951
5952 dlg.finished(true);
5953 return Ok(response);
5954 }
5955 }
5956 }
5957 }
5958
5959 ///
5960 /// Sets the *request* property to the given value.
5961 ///
5962 /// Even though the property as already been set when instantiating this call,
5963 /// we provide this method for API completeness.
5964 pub fn request(mut self, new_value: ApigatewayApi) -> ProjectLocationApiPatchCall<'a, C> {
5965 self._request = new_value;
5966 self
5967 }
5968 /// Output only. Resource name of the API. Format: projects/{project}/locations/global/apis/{api}
5969 ///
5970 /// Sets the *name* path property to the given value.
5971 ///
5972 /// Even though the property as already been set when instantiating this call,
5973 /// we provide this method for API completeness.
5974 pub fn name(mut self, new_value: &str) -> ProjectLocationApiPatchCall<'a, C> {
5975 self._name = new_value.to_string();
5976 self
5977 }
5978 /// Field mask is used to specify the fields to be overwritten in the Api 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.
5979 ///
5980 /// Sets the *update mask* query property to the given value.
5981 pub fn update_mask(
5982 mut self,
5983 new_value: common::FieldMask,
5984 ) -> ProjectLocationApiPatchCall<'a, C> {
5985 self._update_mask = Some(new_value);
5986 self
5987 }
5988 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5989 /// while executing the actual API request.
5990 ///
5991 /// ````text
5992 /// It should be used to handle progress information, and to implement a certain level of resilience.
5993 /// ````
5994 ///
5995 /// Sets the *delegate* property to the given value.
5996 pub fn delegate(
5997 mut self,
5998 new_value: &'a mut dyn common::Delegate,
5999 ) -> ProjectLocationApiPatchCall<'a, C> {
6000 self._delegate = Some(new_value);
6001 self
6002 }
6003
6004 /// Set any additional parameter of the query string used in the request.
6005 /// It should be used to set parameters which are not yet available through their own
6006 /// setters.
6007 ///
6008 /// Please note that this method must not be used to set any of the known parameters
6009 /// which have their own setter method. If done anyway, the request will fail.
6010 ///
6011 /// # Additional Parameters
6012 ///
6013 /// * *$.xgafv* (query-string) - V1 error format.
6014 /// * *access_token* (query-string) - OAuth access token.
6015 /// * *alt* (query-string) - Data format for response.
6016 /// * *callback* (query-string) - JSONP
6017 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6018 /// * *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.
6019 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6020 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6021 /// * *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.
6022 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6023 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6024 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationApiPatchCall<'a, C>
6025 where
6026 T: AsRef<str>,
6027 {
6028 self._additional_params
6029 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6030 self
6031 }
6032
6033 /// Identifies the authorization scope for the method you are building.
6034 ///
6035 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6036 /// [`Scope::CloudPlatform`].
6037 ///
6038 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6039 /// tokens for more than one scope.
6040 ///
6041 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6042 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6043 /// sufficient, a read-write scope will do as well.
6044 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationApiPatchCall<'a, C>
6045 where
6046 St: AsRef<str>,
6047 {
6048 self._scopes.insert(String::from(scope.as_ref()));
6049 self
6050 }
6051 /// Identifies the authorization scope(s) for the method you are building.
6052 ///
6053 /// See [`Self::add_scope()`] for details.
6054 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationApiPatchCall<'a, C>
6055 where
6056 I: IntoIterator<Item = St>,
6057 St: AsRef<str>,
6058 {
6059 self._scopes
6060 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6061 self
6062 }
6063
6064 /// Removes all scopes, and no default scope will be used either.
6065 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6066 /// for details).
6067 pub fn clear_scopes(mut self) -> ProjectLocationApiPatchCall<'a, C> {
6068 self._scopes.clear();
6069 self
6070 }
6071}
6072
6073/// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
6074///
6075/// A builder for the *locations.apis.setIamPolicy* method supported by a *project* resource.
6076/// It is not used directly, but through a [`ProjectMethods`] instance.
6077///
6078/// # Example
6079///
6080/// Instantiate a resource method builder
6081///
6082/// ```test_harness,no_run
6083/// # extern crate hyper;
6084/// # extern crate hyper_rustls;
6085/// # extern crate google_apigateway1 as apigateway1;
6086/// use apigateway1::api::ApigatewaySetIamPolicyRequest;
6087/// # async fn dox() {
6088/// # use apigateway1::{Apigateway, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6089///
6090/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6091/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6092/// # .with_native_roots()
6093/// # .unwrap()
6094/// # .https_only()
6095/// # .enable_http2()
6096/// # .build();
6097///
6098/// # let executor = hyper_util::rt::TokioExecutor::new();
6099/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6100/// # secret,
6101/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6102/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6103/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6104/// # ),
6105/// # ).build().await.unwrap();
6106///
6107/// # let client = hyper_util::client::legacy::Client::builder(
6108/// # hyper_util::rt::TokioExecutor::new()
6109/// # )
6110/// # .build(
6111/// # hyper_rustls::HttpsConnectorBuilder::new()
6112/// # .with_native_roots()
6113/// # .unwrap()
6114/// # .https_or_http()
6115/// # .enable_http2()
6116/// # .build()
6117/// # );
6118/// # let mut hub = Apigateway::new(client, auth);
6119/// // As the method needs a request, you would usually fill it with the desired information
6120/// // into the respective structure. Some of the parts shown here might not be applicable !
6121/// // Values shown here are possibly random and not representative !
6122/// let mut req = ApigatewaySetIamPolicyRequest::default();
6123///
6124/// // You can configure optional parameters by calling the respective setters at will, and
6125/// // execute the final call using `doit()`.
6126/// // Values shown here are possibly random and not representative !
6127/// let result = hub.projects().locations_apis_set_iam_policy(req, "resource")
6128/// .doit().await;
6129/// # }
6130/// ```
6131pub struct ProjectLocationApiSetIamPolicyCall<'a, C>
6132where
6133 C: 'a,
6134{
6135 hub: &'a Apigateway<C>,
6136 _request: ApigatewaySetIamPolicyRequest,
6137 _resource: String,
6138 _delegate: Option<&'a mut dyn common::Delegate>,
6139 _additional_params: HashMap<String, String>,
6140 _scopes: BTreeSet<String>,
6141}
6142
6143impl<'a, C> common::CallBuilder for ProjectLocationApiSetIamPolicyCall<'a, C> {}
6144
6145impl<'a, C> ProjectLocationApiSetIamPolicyCall<'a, C>
6146where
6147 C: common::Connector,
6148{
6149 /// Perform the operation you have build so far.
6150 pub async fn doit(mut self) -> common::Result<(common::Response, ApigatewayPolicy)> {
6151 use std::borrow::Cow;
6152 use std::io::{Read, Seek};
6153
6154 use common::{url::Params, ToParts};
6155 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6156
6157 let mut dd = common::DefaultDelegate;
6158 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6159 dlg.begin(common::MethodInfo {
6160 id: "apigateway.projects.locations.apis.setIamPolicy",
6161 http_method: hyper::Method::POST,
6162 });
6163
6164 for &field in ["alt", "resource"].iter() {
6165 if self._additional_params.contains_key(field) {
6166 dlg.finished(false);
6167 return Err(common::Error::FieldClash(field));
6168 }
6169 }
6170
6171 let mut params = Params::with_capacity(4 + self._additional_params.len());
6172 params.push("resource", self._resource);
6173
6174 params.extend(self._additional_params.iter());
6175
6176 params.push("alt", "json");
6177 let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
6178 if self._scopes.is_empty() {
6179 self._scopes
6180 .insert(Scope::CloudPlatform.as_ref().to_string());
6181 }
6182
6183 #[allow(clippy::single_element_loop)]
6184 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
6185 url = params.uri_replacement(url, param_name, find_this, true);
6186 }
6187 {
6188 let to_remove = ["resource"];
6189 params.remove_params(&to_remove);
6190 }
6191
6192 let url = params.parse_with_url(&url);
6193
6194 let mut json_mime_type = mime::APPLICATION_JSON;
6195 let mut request_value_reader = {
6196 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6197 common::remove_json_null_values(&mut value);
6198 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6199 serde_json::to_writer(&mut dst, &value).unwrap();
6200 dst
6201 };
6202 let request_size = request_value_reader
6203 .seek(std::io::SeekFrom::End(0))
6204 .unwrap();
6205 request_value_reader
6206 .seek(std::io::SeekFrom::Start(0))
6207 .unwrap();
6208
6209 loop {
6210 let token = match self
6211 .hub
6212 .auth
6213 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6214 .await
6215 {
6216 Ok(token) => token,
6217 Err(e) => match dlg.token(e) {
6218 Ok(token) => token,
6219 Err(e) => {
6220 dlg.finished(false);
6221 return Err(common::Error::MissingToken(e));
6222 }
6223 },
6224 };
6225 request_value_reader
6226 .seek(std::io::SeekFrom::Start(0))
6227 .unwrap();
6228 let mut req_result = {
6229 let client = &self.hub.client;
6230 dlg.pre_request();
6231 let mut req_builder = hyper::Request::builder()
6232 .method(hyper::Method::POST)
6233 .uri(url.as_str())
6234 .header(USER_AGENT, self.hub._user_agent.clone());
6235
6236 if let Some(token) = token.as_ref() {
6237 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6238 }
6239
6240 let request = req_builder
6241 .header(CONTENT_TYPE, json_mime_type.to_string())
6242 .header(CONTENT_LENGTH, request_size as u64)
6243 .body(common::to_body(
6244 request_value_reader.get_ref().clone().into(),
6245 ));
6246
6247 client.request(request.unwrap()).await
6248 };
6249
6250 match req_result {
6251 Err(err) => {
6252 if let common::Retry::After(d) = dlg.http_error(&err) {
6253 sleep(d).await;
6254 continue;
6255 }
6256 dlg.finished(false);
6257 return Err(common::Error::HttpError(err));
6258 }
6259 Ok(res) => {
6260 let (mut parts, body) = res.into_parts();
6261 let mut body = common::Body::new(body);
6262 if !parts.status.is_success() {
6263 let bytes = common::to_bytes(body).await.unwrap_or_default();
6264 let error = serde_json::from_str(&common::to_string(&bytes));
6265 let response = common::to_response(parts, bytes.into());
6266
6267 if let common::Retry::After(d) =
6268 dlg.http_failure(&response, error.as_ref().ok())
6269 {
6270 sleep(d).await;
6271 continue;
6272 }
6273
6274 dlg.finished(false);
6275
6276 return Err(match error {
6277 Ok(value) => common::Error::BadRequest(value),
6278 _ => common::Error::Failure(response),
6279 });
6280 }
6281 let response = {
6282 let bytes = common::to_bytes(body).await.unwrap_or_default();
6283 let encoded = common::to_string(&bytes);
6284 match serde_json::from_str(&encoded) {
6285 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6286 Err(error) => {
6287 dlg.response_json_decode_error(&encoded, &error);
6288 return Err(common::Error::JsonDecodeError(
6289 encoded.to_string(),
6290 error,
6291 ));
6292 }
6293 }
6294 };
6295
6296 dlg.finished(true);
6297 return Ok(response);
6298 }
6299 }
6300 }
6301 }
6302
6303 ///
6304 /// Sets the *request* property to the given value.
6305 ///
6306 /// Even though the property as already been set when instantiating this call,
6307 /// we provide this method for API completeness.
6308 pub fn request(
6309 mut self,
6310 new_value: ApigatewaySetIamPolicyRequest,
6311 ) -> ProjectLocationApiSetIamPolicyCall<'a, C> {
6312 self._request = new_value;
6313 self
6314 }
6315 /// 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.
6316 ///
6317 /// Sets the *resource* path property to the given value.
6318 ///
6319 /// Even though the property as already been set when instantiating this call,
6320 /// we provide this method for API completeness.
6321 pub fn resource(mut self, new_value: &str) -> ProjectLocationApiSetIamPolicyCall<'a, C> {
6322 self._resource = new_value.to_string();
6323 self
6324 }
6325 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6326 /// while executing the actual API request.
6327 ///
6328 /// ````text
6329 /// It should be used to handle progress information, and to implement a certain level of resilience.
6330 /// ````
6331 ///
6332 /// Sets the *delegate* property to the given value.
6333 pub fn delegate(
6334 mut self,
6335 new_value: &'a mut dyn common::Delegate,
6336 ) -> ProjectLocationApiSetIamPolicyCall<'a, C> {
6337 self._delegate = Some(new_value);
6338 self
6339 }
6340
6341 /// Set any additional parameter of the query string used in the request.
6342 /// It should be used to set parameters which are not yet available through their own
6343 /// setters.
6344 ///
6345 /// Please note that this method must not be used to set any of the known parameters
6346 /// which have their own setter method. If done anyway, the request will fail.
6347 ///
6348 /// # Additional Parameters
6349 ///
6350 /// * *$.xgafv* (query-string) - V1 error format.
6351 /// * *access_token* (query-string) - OAuth access token.
6352 /// * *alt* (query-string) - Data format for response.
6353 /// * *callback* (query-string) - JSONP
6354 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6355 /// * *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.
6356 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6357 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6358 /// * *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.
6359 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6360 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6361 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationApiSetIamPolicyCall<'a, C>
6362 where
6363 T: AsRef<str>,
6364 {
6365 self._additional_params
6366 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6367 self
6368 }
6369
6370 /// Identifies the authorization scope for the method you are building.
6371 ///
6372 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6373 /// [`Scope::CloudPlatform`].
6374 ///
6375 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6376 /// tokens for more than one scope.
6377 ///
6378 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6379 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6380 /// sufficient, a read-write scope will do as well.
6381 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationApiSetIamPolicyCall<'a, C>
6382 where
6383 St: AsRef<str>,
6384 {
6385 self._scopes.insert(String::from(scope.as_ref()));
6386 self
6387 }
6388 /// Identifies the authorization scope(s) for the method you are building.
6389 ///
6390 /// See [`Self::add_scope()`] for details.
6391 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationApiSetIamPolicyCall<'a, C>
6392 where
6393 I: IntoIterator<Item = St>,
6394 St: AsRef<str>,
6395 {
6396 self._scopes
6397 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6398 self
6399 }
6400
6401 /// Removes all scopes, and no default scope will be used either.
6402 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6403 /// for details).
6404 pub fn clear_scopes(mut self) -> ProjectLocationApiSetIamPolicyCall<'a, C> {
6405 self._scopes.clear();
6406 self
6407 }
6408}
6409
6410/// 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.
6411///
6412/// A builder for the *locations.apis.testIamPermissions* method supported by a *project* resource.
6413/// It is not used directly, but through a [`ProjectMethods`] instance.
6414///
6415/// # Example
6416///
6417/// Instantiate a resource method builder
6418///
6419/// ```test_harness,no_run
6420/// # extern crate hyper;
6421/// # extern crate hyper_rustls;
6422/// # extern crate google_apigateway1 as apigateway1;
6423/// use apigateway1::api::ApigatewayTestIamPermissionsRequest;
6424/// # async fn dox() {
6425/// # use apigateway1::{Apigateway, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6426///
6427/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6428/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6429/// # .with_native_roots()
6430/// # .unwrap()
6431/// # .https_only()
6432/// # .enable_http2()
6433/// # .build();
6434///
6435/// # let executor = hyper_util::rt::TokioExecutor::new();
6436/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6437/// # secret,
6438/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6439/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6440/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6441/// # ),
6442/// # ).build().await.unwrap();
6443///
6444/// # let client = hyper_util::client::legacy::Client::builder(
6445/// # hyper_util::rt::TokioExecutor::new()
6446/// # )
6447/// # .build(
6448/// # hyper_rustls::HttpsConnectorBuilder::new()
6449/// # .with_native_roots()
6450/// # .unwrap()
6451/// # .https_or_http()
6452/// # .enable_http2()
6453/// # .build()
6454/// # );
6455/// # let mut hub = Apigateway::new(client, auth);
6456/// // As the method needs a request, you would usually fill it with the desired information
6457/// // into the respective structure. Some of the parts shown here might not be applicable !
6458/// // Values shown here are possibly random and not representative !
6459/// let mut req = ApigatewayTestIamPermissionsRequest::default();
6460///
6461/// // You can configure optional parameters by calling the respective setters at will, and
6462/// // execute the final call using `doit()`.
6463/// // Values shown here are possibly random and not representative !
6464/// let result = hub.projects().locations_apis_test_iam_permissions(req, "resource")
6465/// .doit().await;
6466/// # }
6467/// ```
6468pub struct ProjectLocationApiTestIamPermissionCall<'a, C>
6469where
6470 C: 'a,
6471{
6472 hub: &'a Apigateway<C>,
6473 _request: ApigatewayTestIamPermissionsRequest,
6474 _resource: String,
6475 _delegate: Option<&'a mut dyn common::Delegate>,
6476 _additional_params: HashMap<String, String>,
6477 _scopes: BTreeSet<String>,
6478}
6479
6480impl<'a, C> common::CallBuilder for ProjectLocationApiTestIamPermissionCall<'a, C> {}
6481
6482impl<'a, C> ProjectLocationApiTestIamPermissionCall<'a, C>
6483where
6484 C: common::Connector,
6485{
6486 /// Perform the operation you have build so far.
6487 pub async fn doit(
6488 mut self,
6489 ) -> common::Result<(common::Response, ApigatewayTestIamPermissionsResponse)> {
6490 use std::borrow::Cow;
6491 use std::io::{Read, Seek};
6492
6493 use common::{url::Params, ToParts};
6494 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6495
6496 let mut dd = common::DefaultDelegate;
6497 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6498 dlg.begin(common::MethodInfo {
6499 id: "apigateway.projects.locations.apis.testIamPermissions",
6500 http_method: hyper::Method::POST,
6501 });
6502
6503 for &field in ["alt", "resource"].iter() {
6504 if self._additional_params.contains_key(field) {
6505 dlg.finished(false);
6506 return Err(common::Error::FieldClash(field));
6507 }
6508 }
6509
6510 let mut params = Params::with_capacity(4 + self._additional_params.len());
6511 params.push("resource", self._resource);
6512
6513 params.extend(self._additional_params.iter());
6514
6515 params.push("alt", "json");
6516 let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
6517 if self._scopes.is_empty() {
6518 self._scopes
6519 .insert(Scope::CloudPlatform.as_ref().to_string());
6520 }
6521
6522 #[allow(clippy::single_element_loop)]
6523 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
6524 url = params.uri_replacement(url, param_name, find_this, true);
6525 }
6526 {
6527 let to_remove = ["resource"];
6528 params.remove_params(&to_remove);
6529 }
6530
6531 let url = params.parse_with_url(&url);
6532
6533 let mut json_mime_type = mime::APPLICATION_JSON;
6534 let mut request_value_reader = {
6535 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6536 common::remove_json_null_values(&mut value);
6537 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6538 serde_json::to_writer(&mut dst, &value).unwrap();
6539 dst
6540 };
6541 let request_size = request_value_reader
6542 .seek(std::io::SeekFrom::End(0))
6543 .unwrap();
6544 request_value_reader
6545 .seek(std::io::SeekFrom::Start(0))
6546 .unwrap();
6547
6548 loop {
6549 let token = match self
6550 .hub
6551 .auth
6552 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6553 .await
6554 {
6555 Ok(token) => token,
6556 Err(e) => match dlg.token(e) {
6557 Ok(token) => token,
6558 Err(e) => {
6559 dlg.finished(false);
6560 return Err(common::Error::MissingToken(e));
6561 }
6562 },
6563 };
6564 request_value_reader
6565 .seek(std::io::SeekFrom::Start(0))
6566 .unwrap();
6567 let mut req_result = {
6568 let client = &self.hub.client;
6569 dlg.pre_request();
6570 let mut req_builder = hyper::Request::builder()
6571 .method(hyper::Method::POST)
6572 .uri(url.as_str())
6573 .header(USER_AGENT, self.hub._user_agent.clone());
6574
6575 if let Some(token) = token.as_ref() {
6576 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6577 }
6578
6579 let request = req_builder
6580 .header(CONTENT_TYPE, json_mime_type.to_string())
6581 .header(CONTENT_LENGTH, request_size as u64)
6582 .body(common::to_body(
6583 request_value_reader.get_ref().clone().into(),
6584 ));
6585
6586 client.request(request.unwrap()).await
6587 };
6588
6589 match req_result {
6590 Err(err) => {
6591 if let common::Retry::After(d) = dlg.http_error(&err) {
6592 sleep(d).await;
6593 continue;
6594 }
6595 dlg.finished(false);
6596 return Err(common::Error::HttpError(err));
6597 }
6598 Ok(res) => {
6599 let (mut parts, body) = res.into_parts();
6600 let mut body = common::Body::new(body);
6601 if !parts.status.is_success() {
6602 let bytes = common::to_bytes(body).await.unwrap_or_default();
6603 let error = serde_json::from_str(&common::to_string(&bytes));
6604 let response = common::to_response(parts, bytes.into());
6605
6606 if let common::Retry::After(d) =
6607 dlg.http_failure(&response, error.as_ref().ok())
6608 {
6609 sleep(d).await;
6610 continue;
6611 }
6612
6613 dlg.finished(false);
6614
6615 return Err(match error {
6616 Ok(value) => common::Error::BadRequest(value),
6617 _ => common::Error::Failure(response),
6618 });
6619 }
6620 let response = {
6621 let bytes = common::to_bytes(body).await.unwrap_or_default();
6622 let encoded = common::to_string(&bytes);
6623 match serde_json::from_str(&encoded) {
6624 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6625 Err(error) => {
6626 dlg.response_json_decode_error(&encoded, &error);
6627 return Err(common::Error::JsonDecodeError(
6628 encoded.to_string(),
6629 error,
6630 ));
6631 }
6632 }
6633 };
6634
6635 dlg.finished(true);
6636 return Ok(response);
6637 }
6638 }
6639 }
6640 }
6641
6642 ///
6643 /// Sets the *request* property to the given value.
6644 ///
6645 /// Even though the property as already been set when instantiating this call,
6646 /// we provide this method for API completeness.
6647 pub fn request(
6648 mut self,
6649 new_value: ApigatewayTestIamPermissionsRequest,
6650 ) -> ProjectLocationApiTestIamPermissionCall<'a, C> {
6651 self._request = new_value;
6652 self
6653 }
6654 /// 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.
6655 ///
6656 /// Sets the *resource* path property to the given value.
6657 ///
6658 /// Even though the property as already been set when instantiating this call,
6659 /// we provide this method for API completeness.
6660 pub fn resource(mut self, new_value: &str) -> ProjectLocationApiTestIamPermissionCall<'a, C> {
6661 self._resource = new_value.to_string();
6662 self
6663 }
6664 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6665 /// while executing the actual API request.
6666 ///
6667 /// ````text
6668 /// It should be used to handle progress information, and to implement a certain level of resilience.
6669 /// ````
6670 ///
6671 /// Sets the *delegate* property to the given value.
6672 pub fn delegate(
6673 mut self,
6674 new_value: &'a mut dyn common::Delegate,
6675 ) -> ProjectLocationApiTestIamPermissionCall<'a, C> {
6676 self._delegate = Some(new_value);
6677 self
6678 }
6679
6680 /// Set any additional parameter of the query string used in the request.
6681 /// It should be used to set parameters which are not yet available through their own
6682 /// setters.
6683 ///
6684 /// Please note that this method must not be used to set any of the known parameters
6685 /// which have their own setter method. If done anyway, the request will fail.
6686 ///
6687 /// # Additional Parameters
6688 ///
6689 /// * *$.xgafv* (query-string) - V1 error format.
6690 /// * *access_token* (query-string) - OAuth access token.
6691 /// * *alt* (query-string) - Data format for response.
6692 /// * *callback* (query-string) - JSONP
6693 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6694 /// * *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.
6695 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6696 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6697 /// * *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.
6698 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6699 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6700 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationApiTestIamPermissionCall<'a, C>
6701 where
6702 T: AsRef<str>,
6703 {
6704 self._additional_params
6705 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6706 self
6707 }
6708
6709 /// Identifies the authorization scope for the method you are building.
6710 ///
6711 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6712 /// [`Scope::CloudPlatform`].
6713 ///
6714 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6715 /// tokens for more than one scope.
6716 ///
6717 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6718 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6719 /// sufficient, a read-write scope will do as well.
6720 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationApiTestIamPermissionCall<'a, C>
6721 where
6722 St: AsRef<str>,
6723 {
6724 self._scopes.insert(String::from(scope.as_ref()));
6725 self
6726 }
6727 /// Identifies the authorization scope(s) for the method you are building.
6728 ///
6729 /// See [`Self::add_scope()`] for details.
6730 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationApiTestIamPermissionCall<'a, C>
6731 where
6732 I: IntoIterator<Item = St>,
6733 St: AsRef<str>,
6734 {
6735 self._scopes
6736 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6737 self
6738 }
6739
6740 /// Removes all scopes, and no default scope will be used either.
6741 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6742 /// for details).
6743 pub fn clear_scopes(mut self) -> ProjectLocationApiTestIamPermissionCall<'a, C> {
6744 self._scopes.clear();
6745 self
6746 }
6747}
6748
6749/// Creates a new Gateway in a given project and location.
6750///
6751/// A builder for the *locations.gateways.create* method supported by a *project* resource.
6752/// It is not used directly, but through a [`ProjectMethods`] instance.
6753///
6754/// # Example
6755///
6756/// Instantiate a resource method builder
6757///
6758/// ```test_harness,no_run
6759/// # extern crate hyper;
6760/// # extern crate hyper_rustls;
6761/// # extern crate google_apigateway1 as apigateway1;
6762/// use apigateway1::api::ApigatewayGateway;
6763/// # async fn dox() {
6764/// # use apigateway1::{Apigateway, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6765///
6766/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6767/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6768/// # .with_native_roots()
6769/// # .unwrap()
6770/// # .https_only()
6771/// # .enable_http2()
6772/// # .build();
6773///
6774/// # let executor = hyper_util::rt::TokioExecutor::new();
6775/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6776/// # secret,
6777/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6778/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6779/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6780/// # ),
6781/// # ).build().await.unwrap();
6782///
6783/// # let client = hyper_util::client::legacy::Client::builder(
6784/// # hyper_util::rt::TokioExecutor::new()
6785/// # )
6786/// # .build(
6787/// # hyper_rustls::HttpsConnectorBuilder::new()
6788/// # .with_native_roots()
6789/// # .unwrap()
6790/// # .https_or_http()
6791/// # .enable_http2()
6792/// # .build()
6793/// # );
6794/// # let mut hub = Apigateway::new(client, auth);
6795/// // As the method needs a request, you would usually fill it with the desired information
6796/// // into the respective structure. Some of the parts shown here might not be applicable !
6797/// // Values shown here are possibly random and not representative !
6798/// let mut req = ApigatewayGateway::default();
6799///
6800/// // You can configure optional parameters by calling the respective setters at will, and
6801/// // execute the final call using `doit()`.
6802/// // Values shown here are possibly random and not representative !
6803/// let result = hub.projects().locations_gateways_create(req, "parent")
6804/// .gateway_id("eos")
6805/// .doit().await;
6806/// # }
6807/// ```
6808pub struct ProjectLocationGatewayCreateCall<'a, C>
6809where
6810 C: 'a,
6811{
6812 hub: &'a Apigateway<C>,
6813 _request: ApigatewayGateway,
6814 _parent: String,
6815 _gateway_id: Option<String>,
6816 _delegate: Option<&'a mut dyn common::Delegate>,
6817 _additional_params: HashMap<String, String>,
6818 _scopes: BTreeSet<String>,
6819}
6820
6821impl<'a, C> common::CallBuilder for ProjectLocationGatewayCreateCall<'a, C> {}
6822
6823impl<'a, C> ProjectLocationGatewayCreateCall<'a, C>
6824where
6825 C: common::Connector,
6826{
6827 /// Perform the operation you have build so far.
6828 pub async fn doit(mut self) -> common::Result<(common::Response, ApigatewayOperation)> {
6829 use std::borrow::Cow;
6830 use std::io::{Read, Seek};
6831
6832 use common::{url::Params, ToParts};
6833 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6834
6835 let mut dd = common::DefaultDelegate;
6836 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6837 dlg.begin(common::MethodInfo {
6838 id: "apigateway.projects.locations.gateways.create",
6839 http_method: hyper::Method::POST,
6840 });
6841
6842 for &field in ["alt", "parent", "gatewayId"].iter() {
6843 if self._additional_params.contains_key(field) {
6844 dlg.finished(false);
6845 return Err(common::Error::FieldClash(field));
6846 }
6847 }
6848
6849 let mut params = Params::with_capacity(5 + self._additional_params.len());
6850 params.push("parent", self._parent);
6851 if let Some(value) = self._gateway_id.as_ref() {
6852 params.push("gatewayId", value);
6853 }
6854
6855 params.extend(self._additional_params.iter());
6856
6857 params.push("alt", "json");
6858 let mut url = self.hub._base_url.clone() + "v1/{+parent}/gateways";
6859 if self._scopes.is_empty() {
6860 self._scopes
6861 .insert(Scope::CloudPlatform.as_ref().to_string());
6862 }
6863
6864 #[allow(clippy::single_element_loop)]
6865 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6866 url = params.uri_replacement(url, param_name, find_this, true);
6867 }
6868 {
6869 let to_remove = ["parent"];
6870 params.remove_params(&to_remove);
6871 }
6872
6873 let url = params.parse_with_url(&url);
6874
6875 let mut json_mime_type = mime::APPLICATION_JSON;
6876 let mut request_value_reader = {
6877 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6878 common::remove_json_null_values(&mut value);
6879 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6880 serde_json::to_writer(&mut dst, &value).unwrap();
6881 dst
6882 };
6883 let request_size = request_value_reader
6884 .seek(std::io::SeekFrom::End(0))
6885 .unwrap();
6886 request_value_reader
6887 .seek(std::io::SeekFrom::Start(0))
6888 .unwrap();
6889
6890 loop {
6891 let token = match self
6892 .hub
6893 .auth
6894 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6895 .await
6896 {
6897 Ok(token) => token,
6898 Err(e) => match dlg.token(e) {
6899 Ok(token) => token,
6900 Err(e) => {
6901 dlg.finished(false);
6902 return Err(common::Error::MissingToken(e));
6903 }
6904 },
6905 };
6906 request_value_reader
6907 .seek(std::io::SeekFrom::Start(0))
6908 .unwrap();
6909 let mut req_result = {
6910 let client = &self.hub.client;
6911 dlg.pre_request();
6912 let mut req_builder = hyper::Request::builder()
6913 .method(hyper::Method::POST)
6914 .uri(url.as_str())
6915 .header(USER_AGENT, self.hub._user_agent.clone());
6916
6917 if let Some(token) = token.as_ref() {
6918 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6919 }
6920
6921 let request = req_builder
6922 .header(CONTENT_TYPE, json_mime_type.to_string())
6923 .header(CONTENT_LENGTH, request_size as u64)
6924 .body(common::to_body(
6925 request_value_reader.get_ref().clone().into(),
6926 ));
6927
6928 client.request(request.unwrap()).await
6929 };
6930
6931 match req_result {
6932 Err(err) => {
6933 if let common::Retry::After(d) = dlg.http_error(&err) {
6934 sleep(d).await;
6935 continue;
6936 }
6937 dlg.finished(false);
6938 return Err(common::Error::HttpError(err));
6939 }
6940 Ok(res) => {
6941 let (mut parts, body) = res.into_parts();
6942 let mut body = common::Body::new(body);
6943 if !parts.status.is_success() {
6944 let bytes = common::to_bytes(body).await.unwrap_or_default();
6945 let error = serde_json::from_str(&common::to_string(&bytes));
6946 let response = common::to_response(parts, bytes.into());
6947
6948 if let common::Retry::After(d) =
6949 dlg.http_failure(&response, error.as_ref().ok())
6950 {
6951 sleep(d).await;
6952 continue;
6953 }
6954
6955 dlg.finished(false);
6956
6957 return Err(match error {
6958 Ok(value) => common::Error::BadRequest(value),
6959 _ => common::Error::Failure(response),
6960 });
6961 }
6962 let response = {
6963 let bytes = common::to_bytes(body).await.unwrap_or_default();
6964 let encoded = common::to_string(&bytes);
6965 match serde_json::from_str(&encoded) {
6966 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6967 Err(error) => {
6968 dlg.response_json_decode_error(&encoded, &error);
6969 return Err(common::Error::JsonDecodeError(
6970 encoded.to_string(),
6971 error,
6972 ));
6973 }
6974 }
6975 };
6976
6977 dlg.finished(true);
6978 return Ok(response);
6979 }
6980 }
6981 }
6982 }
6983
6984 ///
6985 /// Sets the *request* property to the given value.
6986 ///
6987 /// Even though the property as already been set when instantiating this call,
6988 /// we provide this method for API completeness.
6989 pub fn request(
6990 mut self,
6991 new_value: ApigatewayGateway,
6992 ) -> ProjectLocationGatewayCreateCall<'a, C> {
6993 self._request = new_value;
6994 self
6995 }
6996 /// Required. Parent resource of the Gateway, of the form: `projects/*/locations/*`
6997 ///
6998 /// Sets the *parent* path property to the given value.
6999 ///
7000 /// Even though the property as already been set when instantiating this call,
7001 /// we provide this method for API completeness.
7002 pub fn parent(mut self, new_value: &str) -> ProjectLocationGatewayCreateCall<'a, C> {
7003 self._parent = new_value.to_string();
7004 self
7005 }
7006 /// Required. Identifier to assign to the Gateway. Must be unique within scope of the parent resource.
7007 ///
7008 /// Sets the *gateway id* query property to the given value.
7009 pub fn gateway_id(mut self, new_value: &str) -> ProjectLocationGatewayCreateCall<'a, C> {
7010 self._gateway_id = Some(new_value.to_string());
7011 self
7012 }
7013 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7014 /// while executing the actual API request.
7015 ///
7016 /// ````text
7017 /// It should be used to handle progress information, and to implement a certain level of resilience.
7018 /// ````
7019 ///
7020 /// Sets the *delegate* property to the given value.
7021 pub fn delegate(
7022 mut self,
7023 new_value: &'a mut dyn common::Delegate,
7024 ) -> ProjectLocationGatewayCreateCall<'a, C> {
7025 self._delegate = Some(new_value);
7026 self
7027 }
7028
7029 /// Set any additional parameter of the query string used in the request.
7030 /// It should be used to set parameters which are not yet available through their own
7031 /// setters.
7032 ///
7033 /// Please note that this method must not be used to set any of the known parameters
7034 /// which have their own setter method. If done anyway, the request will fail.
7035 ///
7036 /// # Additional Parameters
7037 ///
7038 /// * *$.xgafv* (query-string) - V1 error format.
7039 /// * *access_token* (query-string) - OAuth access token.
7040 /// * *alt* (query-string) - Data format for response.
7041 /// * *callback* (query-string) - JSONP
7042 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7043 /// * *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.
7044 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7045 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7046 /// * *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.
7047 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7048 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7049 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGatewayCreateCall<'a, C>
7050 where
7051 T: AsRef<str>,
7052 {
7053 self._additional_params
7054 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7055 self
7056 }
7057
7058 /// Identifies the authorization scope for the method you are building.
7059 ///
7060 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7061 /// [`Scope::CloudPlatform`].
7062 ///
7063 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7064 /// tokens for more than one scope.
7065 ///
7066 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7067 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7068 /// sufficient, a read-write scope will do as well.
7069 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGatewayCreateCall<'a, C>
7070 where
7071 St: AsRef<str>,
7072 {
7073 self._scopes.insert(String::from(scope.as_ref()));
7074 self
7075 }
7076 /// Identifies the authorization scope(s) for the method you are building.
7077 ///
7078 /// See [`Self::add_scope()`] for details.
7079 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGatewayCreateCall<'a, C>
7080 where
7081 I: IntoIterator<Item = St>,
7082 St: AsRef<str>,
7083 {
7084 self._scopes
7085 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7086 self
7087 }
7088
7089 /// Removes all scopes, and no default scope will be used either.
7090 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7091 /// for details).
7092 pub fn clear_scopes(mut self) -> ProjectLocationGatewayCreateCall<'a, C> {
7093 self._scopes.clear();
7094 self
7095 }
7096}
7097
7098/// Deletes a single Gateway.
7099///
7100/// A builder for the *locations.gateways.delete* method supported by a *project* resource.
7101/// It is not used directly, but through a [`ProjectMethods`] instance.
7102///
7103/// # Example
7104///
7105/// Instantiate a resource method builder
7106///
7107/// ```test_harness,no_run
7108/// # extern crate hyper;
7109/// # extern crate hyper_rustls;
7110/// # extern crate google_apigateway1 as apigateway1;
7111/// # async fn dox() {
7112/// # use apigateway1::{Apigateway, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7113///
7114/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7115/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7116/// # .with_native_roots()
7117/// # .unwrap()
7118/// # .https_only()
7119/// # .enable_http2()
7120/// # .build();
7121///
7122/// # let executor = hyper_util::rt::TokioExecutor::new();
7123/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7124/// # secret,
7125/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7126/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7127/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7128/// # ),
7129/// # ).build().await.unwrap();
7130///
7131/// # let client = hyper_util::client::legacy::Client::builder(
7132/// # hyper_util::rt::TokioExecutor::new()
7133/// # )
7134/// # .build(
7135/// # hyper_rustls::HttpsConnectorBuilder::new()
7136/// # .with_native_roots()
7137/// # .unwrap()
7138/// # .https_or_http()
7139/// # .enable_http2()
7140/// # .build()
7141/// # );
7142/// # let mut hub = Apigateway::new(client, auth);
7143/// // You can configure optional parameters by calling the respective setters at will, and
7144/// // execute the final call using `doit()`.
7145/// // Values shown here are possibly random and not representative !
7146/// let result = hub.projects().locations_gateways_delete("name")
7147/// .doit().await;
7148/// # }
7149/// ```
7150pub struct ProjectLocationGatewayDeleteCall<'a, C>
7151where
7152 C: 'a,
7153{
7154 hub: &'a Apigateway<C>,
7155 _name: String,
7156 _delegate: Option<&'a mut dyn common::Delegate>,
7157 _additional_params: HashMap<String, String>,
7158 _scopes: BTreeSet<String>,
7159}
7160
7161impl<'a, C> common::CallBuilder for ProjectLocationGatewayDeleteCall<'a, C> {}
7162
7163impl<'a, C> ProjectLocationGatewayDeleteCall<'a, C>
7164where
7165 C: common::Connector,
7166{
7167 /// Perform the operation you have build so far.
7168 pub async fn doit(mut self) -> common::Result<(common::Response, ApigatewayOperation)> {
7169 use std::borrow::Cow;
7170 use std::io::{Read, Seek};
7171
7172 use common::{url::Params, ToParts};
7173 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7174
7175 let mut dd = common::DefaultDelegate;
7176 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7177 dlg.begin(common::MethodInfo {
7178 id: "apigateway.projects.locations.gateways.delete",
7179 http_method: hyper::Method::DELETE,
7180 });
7181
7182 for &field in ["alt", "name"].iter() {
7183 if self._additional_params.contains_key(field) {
7184 dlg.finished(false);
7185 return Err(common::Error::FieldClash(field));
7186 }
7187 }
7188
7189 let mut params = Params::with_capacity(3 + self._additional_params.len());
7190 params.push("name", self._name);
7191
7192 params.extend(self._additional_params.iter());
7193
7194 params.push("alt", "json");
7195 let mut url = self.hub._base_url.clone() + "v1/{+name}";
7196 if self._scopes.is_empty() {
7197 self._scopes
7198 .insert(Scope::CloudPlatform.as_ref().to_string());
7199 }
7200
7201 #[allow(clippy::single_element_loop)]
7202 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7203 url = params.uri_replacement(url, param_name, find_this, true);
7204 }
7205 {
7206 let to_remove = ["name"];
7207 params.remove_params(&to_remove);
7208 }
7209
7210 let url = params.parse_with_url(&url);
7211
7212 loop {
7213 let token = match self
7214 .hub
7215 .auth
7216 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7217 .await
7218 {
7219 Ok(token) => token,
7220 Err(e) => match dlg.token(e) {
7221 Ok(token) => token,
7222 Err(e) => {
7223 dlg.finished(false);
7224 return Err(common::Error::MissingToken(e));
7225 }
7226 },
7227 };
7228 let mut req_result = {
7229 let client = &self.hub.client;
7230 dlg.pre_request();
7231 let mut req_builder = hyper::Request::builder()
7232 .method(hyper::Method::DELETE)
7233 .uri(url.as_str())
7234 .header(USER_AGENT, self.hub._user_agent.clone());
7235
7236 if let Some(token) = token.as_ref() {
7237 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7238 }
7239
7240 let request = req_builder
7241 .header(CONTENT_LENGTH, 0_u64)
7242 .body(common::to_body::<String>(None));
7243
7244 client.request(request.unwrap()).await
7245 };
7246
7247 match req_result {
7248 Err(err) => {
7249 if let common::Retry::After(d) = dlg.http_error(&err) {
7250 sleep(d).await;
7251 continue;
7252 }
7253 dlg.finished(false);
7254 return Err(common::Error::HttpError(err));
7255 }
7256 Ok(res) => {
7257 let (mut parts, body) = res.into_parts();
7258 let mut body = common::Body::new(body);
7259 if !parts.status.is_success() {
7260 let bytes = common::to_bytes(body).await.unwrap_or_default();
7261 let error = serde_json::from_str(&common::to_string(&bytes));
7262 let response = common::to_response(parts, bytes.into());
7263
7264 if let common::Retry::After(d) =
7265 dlg.http_failure(&response, error.as_ref().ok())
7266 {
7267 sleep(d).await;
7268 continue;
7269 }
7270
7271 dlg.finished(false);
7272
7273 return Err(match error {
7274 Ok(value) => common::Error::BadRequest(value),
7275 _ => common::Error::Failure(response),
7276 });
7277 }
7278 let response = {
7279 let bytes = common::to_bytes(body).await.unwrap_or_default();
7280 let encoded = common::to_string(&bytes);
7281 match serde_json::from_str(&encoded) {
7282 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7283 Err(error) => {
7284 dlg.response_json_decode_error(&encoded, &error);
7285 return Err(common::Error::JsonDecodeError(
7286 encoded.to_string(),
7287 error,
7288 ));
7289 }
7290 }
7291 };
7292
7293 dlg.finished(true);
7294 return Ok(response);
7295 }
7296 }
7297 }
7298 }
7299
7300 /// Required. Resource name of the form: `projects/*/locations/*/gateways/*`
7301 ///
7302 /// Sets the *name* path property to the given value.
7303 ///
7304 /// Even though the property as already been set when instantiating this call,
7305 /// we provide this method for API completeness.
7306 pub fn name(mut self, new_value: &str) -> ProjectLocationGatewayDeleteCall<'a, C> {
7307 self._name = new_value.to_string();
7308 self
7309 }
7310 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7311 /// while executing the actual API request.
7312 ///
7313 /// ````text
7314 /// It should be used to handle progress information, and to implement a certain level of resilience.
7315 /// ````
7316 ///
7317 /// Sets the *delegate* property to the given value.
7318 pub fn delegate(
7319 mut self,
7320 new_value: &'a mut dyn common::Delegate,
7321 ) -> ProjectLocationGatewayDeleteCall<'a, C> {
7322 self._delegate = Some(new_value);
7323 self
7324 }
7325
7326 /// Set any additional parameter of the query string used in the request.
7327 /// It should be used to set parameters which are not yet available through their own
7328 /// setters.
7329 ///
7330 /// Please note that this method must not be used to set any of the known parameters
7331 /// which have their own setter method. If done anyway, the request will fail.
7332 ///
7333 /// # Additional Parameters
7334 ///
7335 /// * *$.xgafv* (query-string) - V1 error format.
7336 /// * *access_token* (query-string) - OAuth access token.
7337 /// * *alt* (query-string) - Data format for response.
7338 /// * *callback* (query-string) - JSONP
7339 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7340 /// * *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.
7341 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7342 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7343 /// * *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.
7344 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7345 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7346 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGatewayDeleteCall<'a, C>
7347 where
7348 T: AsRef<str>,
7349 {
7350 self._additional_params
7351 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7352 self
7353 }
7354
7355 /// Identifies the authorization scope for the method you are building.
7356 ///
7357 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7358 /// [`Scope::CloudPlatform`].
7359 ///
7360 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7361 /// tokens for more than one scope.
7362 ///
7363 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7364 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7365 /// sufficient, a read-write scope will do as well.
7366 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGatewayDeleteCall<'a, C>
7367 where
7368 St: AsRef<str>,
7369 {
7370 self._scopes.insert(String::from(scope.as_ref()));
7371 self
7372 }
7373 /// Identifies the authorization scope(s) for the method you are building.
7374 ///
7375 /// See [`Self::add_scope()`] for details.
7376 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGatewayDeleteCall<'a, C>
7377 where
7378 I: IntoIterator<Item = St>,
7379 St: AsRef<str>,
7380 {
7381 self._scopes
7382 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7383 self
7384 }
7385
7386 /// Removes all scopes, and no default scope will be used either.
7387 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7388 /// for details).
7389 pub fn clear_scopes(mut self) -> ProjectLocationGatewayDeleteCall<'a, C> {
7390 self._scopes.clear();
7391 self
7392 }
7393}
7394
7395/// Gets details of a single Gateway.
7396///
7397/// A builder for the *locations.gateways.get* method supported by a *project* resource.
7398/// It is not used directly, but through a [`ProjectMethods`] instance.
7399///
7400/// # Example
7401///
7402/// Instantiate a resource method builder
7403///
7404/// ```test_harness,no_run
7405/// # extern crate hyper;
7406/// # extern crate hyper_rustls;
7407/// # extern crate google_apigateway1 as apigateway1;
7408/// # async fn dox() {
7409/// # use apigateway1::{Apigateway, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7410///
7411/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7412/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7413/// # .with_native_roots()
7414/// # .unwrap()
7415/// # .https_only()
7416/// # .enable_http2()
7417/// # .build();
7418///
7419/// # let executor = hyper_util::rt::TokioExecutor::new();
7420/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7421/// # secret,
7422/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7423/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7424/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7425/// # ),
7426/// # ).build().await.unwrap();
7427///
7428/// # let client = hyper_util::client::legacy::Client::builder(
7429/// # hyper_util::rt::TokioExecutor::new()
7430/// # )
7431/// # .build(
7432/// # hyper_rustls::HttpsConnectorBuilder::new()
7433/// # .with_native_roots()
7434/// # .unwrap()
7435/// # .https_or_http()
7436/// # .enable_http2()
7437/// # .build()
7438/// # );
7439/// # let mut hub = Apigateway::new(client, auth);
7440/// // You can configure optional parameters by calling the respective setters at will, and
7441/// // execute the final call using `doit()`.
7442/// // Values shown here are possibly random and not representative !
7443/// let result = hub.projects().locations_gateways_get("name")
7444/// .doit().await;
7445/// # }
7446/// ```
7447pub struct ProjectLocationGatewayGetCall<'a, C>
7448where
7449 C: 'a,
7450{
7451 hub: &'a Apigateway<C>,
7452 _name: String,
7453 _delegate: Option<&'a mut dyn common::Delegate>,
7454 _additional_params: HashMap<String, String>,
7455 _scopes: BTreeSet<String>,
7456}
7457
7458impl<'a, C> common::CallBuilder for ProjectLocationGatewayGetCall<'a, C> {}
7459
7460impl<'a, C> ProjectLocationGatewayGetCall<'a, C>
7461where
7462 C: common::Connector,
7463{
7464 /// Perform the operation you have build so far.
7465 pub async fn doit(mut self) -> common::Result<(common::Response, ApigatewayGateway)> {
7466 use std::borrow::Cow;
7467 use std::io::{Read, Seek};
7468
7469 use common::{url::Params, ToParts};
7470 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7471
7472 let mut dd = common::DefaultDelegate;
7473 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7474 dlg.begin(common::MethodInfo {
7475 id: "apigateway.projects.locations.gateways.get",
7476 http_method: hyper::Method::GET,
7477 });
7478
7479 for &field in ["alt", "name"].iter() {
7480 if self._additional_params.contains_key(field) {
7481 dlg.finished(false);
7482 return Err(common::Error::FieldClash(field));
7483 }
7484 }
7485
7486 let mut params = Params::with_capacity(3 + self._additional_params.len());
7487 params.push("name", self._name);
7488
7489 params.extend(self._additional_params.iter());
7490
7491 params.push("alt", "json");
7492 let mut url = self.hub._base_url.clone() + "v1/{+name}";
7493 if self._scopes.is_empty() {
7494 self._scopes
7495 .insert(Scope::CloudPlatform.as_ref().to_string());
7496 }
7497
7498 #[allow(clippy::single_element_loop)]
7499 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7500 url = params.uri_replacement(url, param_name, find_this, true);
7501 }
7502 {
7503 let to_remove = ["name"];
7504 params.remove_params(&to_remove);
7505 }
7506
7507 let url = params.parse_with_url(&url);
7508
7509 loop {
7510 let token = match self
7511 .hub
7512 .auth
7513 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7514 .await
7515 {
7516 Ok(token) => token,
7517 Err(e) => match dlg.token(e) {
7518 Ok(token) => token,
7519 Err(e) => {
7520 dlg.finished(false);
7521 return Err(common::Error::MissingToken(e));
7522 }
7523 },
7524 };
7525 let mut req_result = {
7526 let client = &self.hub.client;
7527 dlg.pre_request();
7528 let mut req_builder = hyper::Request::builder()
7529 .method(hyper::Method::GET)
7530 .uri(url.as_str())
7531 .header(USER_AGENT, self.hub._user_agent.clone());
7532
7533 if let Some(token) = token.as_ref() {
7534 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7535 }
7536
7537 let request = req_builder
7538 .header(CONTENT_LENGTH, 0_u64)
7539 .body(common::to_body::<String>(None));
7540
7541 client.request(request.unwrap()).await
7542 };
7543
7544 match req_result {
7545 Err(err) => {
7546 if let common::Retry::After(d) = dlg.http_error(&err) {
7547 sleep(d).await;
7548 continue;
7549 }
7550 dlg.finished(false);
7551 return Err(common::Error::HttpError(err));
7552 }
7553 Ok(res) => {
7554 let (mut parts, body) = res.into_parts();
7555 let mut body = common::Body::new(body);
7556 if !parts.status.is_success() {
7557 let bytes = common::to_bytes(body).await.unwrap_or_default();
7558 let error = serde_json::from_str(&common::to_string(&bytes));
7559 let response = common::to_response(parts, bytes.into());
7560
7561 if let common::Retry::After(d) =
7562 dlg.http_failure(&response, error.as_ref().ok())
7563 {
7564 sleep(d).await;
7565 continue;
7566 }
7567
7568 dlg.finished(false);
7569
7570 return Err(match error {
7571 Ok(value) => common::Error::BadRequest(value),
7572 _ => common::Error::Failure(response),
7573 });
7574 }
7575 let response = {
7576 let bytes = common::to_bytes(body).await.unwrap_or_default();
7577 let encoded = common::to_string(&bytes);
7578 match serde_json::from_str(&encoded) {
7579 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7580 Err(error) => {
7581 dlg.response_json_decode_error(&encoded, &error);
7582 return Err(common::Error::JsonDecodeError(
7583 encoded.to_string(),
7584 error,
7585 ));
7586 }
7587 }
7588 };
7589
7590 dlg.finished(true);
7591 return Ok(response);
7592 }
7593 }
7594 }
7595 }
7596
7597 /// Required. Resource name of the form: `projects/*/locations/*/gateways/*`
7598 ///
7599 /// Sets the *name* path property to the given value.
7600 ///
7601 /// Even though the property as already been set when instantiating this call,
7602 /// we provide this method for API completeness.
7603 pub fn name(mut self, new_value: &str) -> ProjectLocationGatewayGetCall<'a, C> {
7604 self._name = new_value.to_string();
7605 self
7606 }
7607 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7608 /// while executing the actual API request.
7609 ///
7610 /// ````text
7611 /// It should be used to handle progress information, and to implement a certain level of resilience.
7612 /// ````
7613 ///
7614 /// Sets the *delegate* property to the given value.
7615 pub fn delegate(
7616 mut self,
7617 new_value: &'a mut dyn common::Delegate,
7618 ) -> ProjectLocationGatewayGetCall<'a, C> {
7619 self._delegate = Some(new_value);
7620 self
7621 }
7622
7623 /// Set any additional parameter of the query string used in the request.
7624 /// It should be used to set parameters which are not yet available through their own
7625 /// setters.
7626 ///
7627 /// Please note that this method must not be used to set any of the known parameters
7628 /// which have their own setter method. If done anyway, the request will fail.
7629 ///
7630 /// # Additional Parameters
7631 ///
7632 /// * *$.xgafv* (query-string) - V1 error format.
7633 /// * *access_token* (query-string) - OAuth access token.
7634 /// * *alt* (query-string) - Data format for response.
7635 /// * *callback* (query-string) - JSONP
7636 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7637 /// * *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.
7638 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7639 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7640 /// * *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.
7641 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7642 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7643 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGatewayGetCall<'a, C>
7644 where
7645 T: AsRef<str>,
7646 {
7647 self._additional_params
7648 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7649 self
7650 }
7651
7652 /// Identifies the authorization scope for the method you are building.
7653 ///
7654 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7655 /// [`Scope::CloudPlatform`].
7656 ///
7657 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7658 /// tokens for more than one scope.
7659 ///
7660 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7661 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7662 /// sufficient, a read-write scope will do as well.
7663 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGatewayGetCall<'a, C>
7664 where
7665 St: AsRef<str>,
7666 {
7667 self._scopes.insert(String::from(scope.as_ref()));
7668 self
7669 }
7670 /// Identifies the authorization scope(s) for the method you are building.
7671 ///
7672 /// See [`Self::add_scope()`] for details.
7673 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGatewayGetCall<'a, C>
7674 where
7675 I: IntoIterator<Item = St>,
7676 St: AsRef<str>,
7677 {
7678 self._scopes
7679 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7680 self
7681 }
7682
7683 /// Removes all scopes, and no default scope will be used either.
7684 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7685 /// for details).
7686 pub fn clear_scopes(mut self) -> ProjectLocationGatewayGetCall<'a, C> {
7687 self._scopes.clear();
7688 self
7689 }
7690}
7691
7692/// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
7693///
7694/// A builder for the *locations.gateways.getIamPolicy* method supported by a *project* resource.
7695/// It is not used directly, but through a [`ProjectMethods`] instance.
7696///
7697/// # Example
7698///
7699/// Instantiate a resource method builder
7700///
7701/// ```test_harness,no_run
7702/// # extern crate hyper;
7703/// # extern crate hyper_rustls;
7704/// # extern crate google_apigateway1 as apigateway1;
7705/// # async fn dox() {
7706/// # use apigateway1::{Apigateway, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7707///
7708/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7709/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7710/// # .with_native_roots()
7711/// # .unwrap()
7712/// # .https_only()
7713/// # .enable_http2()
7714/// # .build();
7715///
7716/// # let executor = hyper_util::rt::TokioExecutor::new();
7717/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7718/// # secret,
7719/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7720/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7721/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7722/// # ),
7723/// # ).build().await.unwrap();
7724///
7725/// # let client = hyper_util::client::legacy::Client::builder(
7726/// # hyper_util::rt::TokioExecutor::new()
7727/// # )
7728/// # .build(
7729/// # hyper_rustls::HttpsConnectorBuilder::new()
7730/// # .with_native_roots()
7731/// # .unwrap()
7732/// # .https_or_http()
7733/// # .enable_http2()
7734/// # .build()
7735/// # );
7736/// # let mut hub = Apigateway::new(client, auth);
7737/// // You can configure optional parameters by calling the respective setters at will, and
7738/// // execute the final call using `doit()`.
7739/// // Values shown here are possibly random and not representative !
7740/// let result = hub.projects().locations_gateways_get_iam_policy("resource")
7741/// .options_requested_policy_version(-80)
7742/// .doit().await;
7743/// # }
7744/// ```
7745pub struct ProjectLocationGatewayGetIamPolicyCall<'a, C>
7746where
7747 C: 'a,
7748{
7749 hub: &'a Apigateway<C>,
7750 _resource: String,
7751 _options_requested_policy_version: Option<i32>,
7752 _delegate: Option<&'a mut dyn common::Delegate>,
7753 _additional_params: HashMap<String, String>,
7754 _scopes: BTreeSet<String>,
7755}
7756
7757impl<'a, C> common::CallBuilder for ProjectLocationGatewayGetIamPolicyCall<'a, C> {}
7758
7759impl<'a, C> ProjectLocationGatewayGetIamPolicyCall<'a, C>
7760where
7761 C: common::Connector,
7762{
7763 /// Perform the operation you have build so far.
7764 pub async fn doit(mut self) -> common::Result<(common::Response, ApigatewayPolicy)> {
7765 use std::borrow::Cow;
7766 use std::io::{Read, Seek};
7767
7768 use common::{url::Params, ToParts};
7769 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7770
7771 let mut dd = common::DefaultDelegate;
7772 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7773 dlg.begin(common::MethodInfo {
7774 id: "apigateway.projects.locations.gateways.getIamPolicy",
7775 http_method: hyper::Method::GET,
7776 });
7777
7778 for &field in ["alt", "resource", "options.requestedPolicyVersion"].iter() {
7779 if self._additional_params.contains_key(field) {
7780 dlg.finished(false);
7781 return Err(common::Error::FieldClash(field));
7782 }
7783 }
7784
7785 let mut params = Params::with_capacity(4 + self._additional_params.len());
7786 params.push("resource", self._resource);
7787 if let Some(value) = self._options_requested_policy_version.as_ref() {
7788 params.push("options.requestedPolicyVersion", value.to_string());
7789 }
7790
7791 params.extend(self._additional_params.iter());
7792
7793 params.push("alt", "json");
7794 let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
7795 if self._scopes.is_empty() {
7796 self._scopes
7797 .insert(Scope::CloudPlatform.as_ref().to_string());
7798 }
7799
7800 #[allow(clippy::single_element_loop)]
7801 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
7802 url = params.uri_replacement(url, param_name, find_this, true);
7803 }
7804 {
7805 let to_remove = ["resource"];
7806 params.remove_params(&to_remove);
7807 }
7808
7809 let url = params.parse_with_url(&url);
7810
7811 loop {
7812 let token = match self
7813 .hub
7814 .auth
7815 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7816 .await
7817 {
7818 Ok(token) => token,
7819 Err(e) => match dlg.token(e) {
7820 Ok(token) => token,
7821 Err(e) => {
7822 dlg.finished(false);
7823 return Err(common::Error::MissingToken(e));
7824 }
7825 },
7826 };
7827 let mut req_result = {
7828 let client = &self.hub.client;
7829 dlg.pre_request();
7830 let mut req_builder = hyper::Request::builder()
7831 .method(hyper::Method::GET)
7832 .uri(url.as_str())
7833 .header(USER_AGENT, self.hub._user_agent.clone());
7834
7835 if let Some(token) = token.as_ref() {
7836 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7837 }
7838
7839 let request = req_builder
7840 .header(CONTENT_LENGTH, 0_u64)
7841 .body(common::to_body::<String>(None));
7842
7843 client.request(request.unwrap()).await
7844 };
7845
7846 match req_result {
7847 Err(err) => {
7848 if let common::Retry::After(d) = dlg.http_error(&err) {
7849 sleep(d).await;
7850 continue;
7851 }
7852 dlg.finished(false);
7853 return Err(common::Error::HttpError(err));
7854 }
7855 Ok(res) => {
7856 let (mut parts, body) = res.into_parts();
7857 let mut body = common::Body::new(body);
7858 if !parts.status.is_success() {
7859 let bytes = common::to_bytes(body).await.unwrap_or_default();
7860 let error = serde_json::from_str(&common::to_string(&bytes));
7861 let response = common::to_response(parts, bytes.into());
7862
7863 if let common::Retry::After(d) =
7864 dlg.http_failure(&response, error.as_ref().ok())
7865 {
7866 sleep(d).await;
7867 continue;
7868 }
7869
7870 dlg.finished(false);
7871
7872 return Err(match error {
7873 Ok(value) => common::Error::BadRequest(value),
7874 _ => common::Error::Failure(response),
7875 });
7876 }
7877 let response = {
7878 let bytes = common::to_bytes(body).await.unwrap_or_default();
7879 let encoded = common::to_string(&bytes);
7880 match serde_json::from_str(&encoded) {
7881 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7882 Err(error) => {
7883 dlg.response_json_decode_error(&encoded, &error);
7884 return Err(common::Error::JsonDecodeError(
7885 encoded.to_string(),
7886 error,
7887 ));
7888 }
7889 }
7890 };
7891
7892 dlg.finished(true);
7893 return Ok(response);
7894 }
7895 }
7896 }
7897 }
7898
7899 /// 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.
7900 ///
7901 /// Sets the *resource* path property to the given value.
7902 ///
7903 /// Even though the property as already been set when instantiating this call,
7904 /// we provide this method for API completeness.
7905 pub fn resource(mut self, new_value: &str) -> ProjectLocationGatewayGetIamPolicyCall<'a, C> {
7906 self._resource = new_value.to_string();
7907 self
7908 }
7909 /// 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).
7910 ///
7911 /// Sets the *options.requested policy version* query property to the given value.
7912 pub fn options_requested_policy_version(
7913 mut self,
7914 new_value: i32,
7915 ) -> ProjectLocationGatewayGetIamPolicyCall<'a, C> {
7916 self._options_requested_policy_version = Some(new_value);
7917 self
7918 }
7919 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7920 /// while executing the actual API request.
7921 ///
7922 /// ````text
7923 /// It should be used to handle progress information, and to implement a certain level of resilience.
7924 /// ````
7925 ///
7926 /// Sets the *delegate* property to the given value.
7927 pub fn delegate(
7928 mut self,
7929 new_value: &'a mut dyn common::Delegate,
7930 ) -> ProjectLocationGatewayGetIamPolicyCall<'a, C> {
7931 self._delegate = Some(new_value);
7932 self
7933 }
7934
7935 /// Set any additional parameter of the query string used in the request.
7936 /// It should be used to set parameters which are not yet available through their own
7937 /// setters.
7938 ///
7939 /// Please note that this method must not be used to set any of the known parameters
7940 /// which have their own setter method. If done anyway, the request will fail.
7941 ///
7942 /// # Additional Parameters
7943 ///
7944 /// * *$.xgafv* (query-string) - V1 error format.
7945 /// * *access_token* (query-string) - OAuth access token.
7946 /// * *alt* (query-string) - Data format for response.
7947 /// * *callback* (query-string) - JSONP
7948 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7949 /// * *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.
7950 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7951 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7952 /// * *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.
7953 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7954 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7955 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGatewayGetIamPolicyCall<'a, C>
7956 where
7957 T: AsRef<str>,
7958 {
7959 self._additional_params
7960 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7961 self
7962 }
7963
7964 /// Identifies the authorization scope for the method you are building.
7965 ///
7966 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7967 /// [`Scope::CloudPlatform`].
7968 ///
7969 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7970 /// tokens for more than one scope.
7971 ///
7972 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7973 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7974 /// sufficient, a read-write scope will do as well.
7975 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGatewayGetIamPolicyCall<'a, C>
7976 where
7977 St: AsRef<str>,
7978 {
7979 self._scopes.insert(String::from(scope.as_ref()));
7980 self
7981 }
7982 /// Identifies the authorization scope(s) for the method you are building.
7983 ///
7984 /// See [`Self::add_scope()`] for details.
7985 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGatewayGetIamPolicyCall<'a, C>
7986 where
7987 I: IntoIterator<Item = St>,
7988 St: AsRef<str>,
7989 {
7990 self._scopes
7991 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7992 self
7993 }
7994
7995 /// Removes all scopes, and no default scope will be used either.
7996 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7997 /// for details).
7998 pub fn clear_scopes(mut self) -> ProjectLocationGatewayGetIamPolicyCall<'a, C> {
7999 self._scopes.clear();
8000 self
8001 }
8002}
8003
8004/// Lists Gateways in a given project and location.
8005///
8006/// A builder for the *locations.gateways.list* method supported by a *project* resource.
8007/// It is not used directly, but through a [`ProjectMethods`] instance.
8008///
8009/// # Example
8010///
8011/// Instantiate a resource method builder
8012///
8013/// ```test_harness,no_run
8014/// # extern crate hyper;
8015/// # extern crate hyper_rustls;
8016/// # extern crate google_apigateway1 as apigateway1;
8017/// # async fn dox() {
8018/// # use apigateway1::{Apigateway, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8019///
8020/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8021/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8022/// # .with_native_roots()
8023/// # .unwrap()
8024/// # .https_only()
8025/// # .enable_http2()
8026/// # .build();
8027///
8028/// # let executor = hyper_util::rt::TokioExecutor::new();
8029/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8030/// # secret,
8031/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8032/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8033/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8034/// # ),
8035/// # ).build().await.unwrap();
8036///
8037/// # let client = hyper_util::client::legacy::Client::builder(
8038/// # hyper_util::rt::TokioExecutor::new()
8039/// # )
8040/// # .build(
8041/// # hyper_rustls::HttpsConnectorBuilder::new()
8042/// # .with_native_roots()
8043/// # .unwrap()
8044/// # .https_or_http()
8045/// # .enable_http2()
8046/// # .build()
8047/// # );
8048/// # let mut hub = Apigateway::new(client, auth);
8049/// // You can configure optional parameters by calling the respective setters at will, and
8050/// // execute the final call using `doit()`.
8051/// // Values shown here are possibly random and not representative !
8052/// let result = hub.projects().locations_gateways_list("parent")
8053/// .page_token("Stet")
8054/// .page_size(-13)
8055/// .order_by("et")
8056/// .filter("sed")
8057/// .doit().await;
8058/// # }
8059/// ```
8060pub struct ProjectLocationGatewayListCall<'a, C>
8061where
8062 C: 'a,
8063{
8064 hub: &'a Apigateway<C>,
8065 _parent: String,
8066 _page_token: Option<String>,
8067 _page_size: Option<i32>,
8068 _order_by: Option<String>,
8069 _filter: Option<String>,
8070 _delegate: Option<&'a mut dyn common::Delegate>,
8071 _additional_params: HashMap<String, String>,
8072 _scopes: BTreeSet<String>,
8073}
8074
8075impl<'a, C> common::CallBuilder for ProjectLocationGatewayListCall<'a, C> {}
8076
8077impl<'a, C> ProjectLocationGatewayListCall<'a, C>
8078where
8079 C: common::Connector,
8080{
8081 /// Perform the operation you have build so far.
8082 pub async fn doit(
8083 mut self,
8084 ) -> common::Result<(common::Response, ApigatewayListGatewaysResponse)> {
8085 use std::borrow::Cow;
8086 use std::io::{Read, Seek};
8087
8088 use common::{url::Params, ToParts};
8089 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8090
8091 let mut dd = common::DefaultDelegate;
8092 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8093 dlg.begin(common::MethodInfo {
8094 id: "apigateway.projects.locations.gateways.list",
8095 http_method: hyper::Method::GET,
8096 });
8097
8098 for &field in [
8099 "alt",
8100 "parent",
8101 "pageToken",
8102 "pageSize",
8103 "orderBy",
8104 "filter",
8105 ]
8106 .iter()
8107 {
8108 if self._additional_params.contains_key(field) {
8109 dlg.finished(false);
8110 return Err(common::Error::FieldClash(field));
8111 }
8112 }
8113
8114 let mut params = Params::with_capacity(7 + self._additional_params.len());
8115 params.push("parent", self._parent);
8116 if let Some(value) = self._page_token.as_ref() {
8117 params.push("pageToken", value);
8118 }
8119 if let Some(value) = self._page_size.as_ref() {
8120 params.push("pageSize", value.to_string());
8121 }
8122 if let Some(value) = self._order_by.as_ref() {
8123 params.push("orderBy", value);
8124 }
8125 if let Some(value) = self._filter.as_ref() {
8126 params.push("filter", value);
8127 }
8128
8129 params.extend(self._additional_params.iter());
8130
8131 params.push("alt", "json");
8132 let mut url = self.hub._base_url.clone() + "v1/{+parent}/gateways";
8133 if self._scopes.is_empty() {
8134 self._scopes
8135 .insert(Scope::CloudPlatform.as_ref().to_string());
8136 }
8137
8138 #[allow(clippy::single_element_loop)]
8139 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
8140 url = params.uri_replacement(url, param_name, find_this, true);
8141 }
8142 {
8143 let to_remove = ["parent"];
8144 params.remove_params(&to_remove);
8145 }
8146
8147 let url = params.parse_with_url(&url);
8148
8149 loop {
8150 let token = match self
8151 .hub
8152 .auth
8153 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8154 .await
8155 {
8156 Ok(token) => token,
8157 Err(e) => match dlg.token(e) {
8158 Ok(token) => token,
8159 Err(e) => {
8160 dlg.finished(false);
8161 return Err(common::Error::MissingToken(e));
8162 }
8163 },
8164 };
8165 let mut req_result = {
8166 let client = &self.hub.client;
8167 dlg.pre_request();
8168 let mut req_builder = hyper::Request::builder()
8169 .method(hyper::Method::GET)
8170 .uri(url.as_str())
8171 .header(USER_AGENT, self.hub._user_agent.clone());
8172
8173 if let Some(token) = token.as_ref() {
8174 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8175 }
8176
8177 let request = req_builder
8178 .header(CONTENT_LENGTH, 0_u64)
8179 .body(common::to_body::<String>(None));
8180
8181 client.request(request.unwrap()).await
8182 };
8183
8184 match req_result {
8185 Err(err) => {
8186 if let common::Retry::After(d) = dlg.http_error(&err) {
8187 sleep(d).await;
8188 continue;
8189 }
8190 dlg.finished(false);
8191 return Err(common::Error::HttpError(err));
8192 }
8193 Ok(res) => {
8194 let (mut parts, body) = res.into_parts();
8195 let mut body = common::Body::new(body);
8196 if !parts.status.is_success() {
8197 let bytes = common::to_bytes(body).await.unwrap_or_default();
8198 let error = serde_json::from_str(&common::to_string(&bytes));
8199 let response = common::to_response(parts, bytes.into());
8200
8201 if let common::Retry::After(d) =
8202 dlg.http_failure(&response, error.as_ref().ok())
8203 {
8204 sleep(d).await;
8205 continue;
8206 }
8207
8208 dlg.finished(false);
8209
8210 return Err(match error {
8211 Ok(value) => common::Error::BadRequest(value),
8212 _ => common::Error::Failure(response),
8213 });
8214 }
8215 let response = {
8216 let bytes = common::to_bytes(body).await.unwrap_or_default();
8217 let encoded = common::to_string(&bytes);
8218 match serde_json::from_str(&encoded) {
8219 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8220 Err(error) => {
8221 dlg.response_json_decode_error(&encoded, &error);
8222 return Err(common::Error::JsonDecodeError(
8223 encoded.to_string(),
8224 error,
8225 ));
8226 }
8227 }
8228 };
8229
8230 dlg.finished(true);
8231 return Ok(response);
8232 }
8233 }
8234 }
8235 }
8236
8237 /// Required. Parent resource of the Gateway, of the form: `projects/*/locations/*`
8238 ///
8239 /// Sets the *parent* path property to the given value.
8240 ///
8241 /// Even though the property as already been set when instantiating this call,
8242 /// we provide this method for API completeness.
8243 pub fn parent(mut self, new_value: &str) -> ProjectLocationGatewayListCall<'a, C> {
8244 self._parent = new_value.to_string();
8245 self
8246 }
8247 /// Page token.
8248 ///
8249 /// Sets the *page token* query property to the given value.
8250 pub fn page_token(mut self, new_value: &str) -> ProjectLocationGatewayListCall<'a, C> {
8251 self._page_token = Some(new_value.to_string());
8252 self
8253 }
8254 /// Page size.
8255 ///
8256 /// Sets the *page size* query property to the given value.
8257 pub fn page_size(mut self, new_value: i32) -> ProjectLocationGatewayListCall<'a, C> {
8258 self._page_size = Some(new_value);
8259 self
8260 }
8261 /// Order by parameters.
8262 ///
8263 /// Sets the *order by* query property to the given value.
8264 pub fn order_by(mut self, new_value: &str) -> ProjectLocationGatewayListCall<'a, C> {
8265 self._order_by = Some(new_value.to_string());
8266 self
8267 }
8268 /// Filter.
8269 ///
8270 /// Sets the *filter* query property to the given value.
8271 pub fn filter(mut self, new_value: &str) -> ProjectLocationGatewayListCall<'a, C> {
8272 self._filter = Some(new_value.to_string());
8273 self
8274 }
8275 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8276 /// while executing the actual API request.
8277 ///
8278 /// ````text
8279 /// It should be used to handle progress information, and to implement a certain level of resilience.
8280 /// ````
8281 ///
8282 /// Sets the *delegate* property to the given value.
8283 pub fn delegate(
8284 mut self,
8285 new_value: &'a mut dyn common::Delegate,
8286 ) -> ProjectLocationGatewayListCall<'a, C> {
8287 self._delegate = Some(new_value);
8288 self
8289 }
8290
8291 /// Set any additional parameter of the query string used in the request.
8292 /// It should be used to set parameters which are not yet available through their own
8293 /// setters.
8294 ///
8295 /// Please note that this method must not be used to set any of the known parameters
8296 /// which have their own setter method. If done anyway, the request will fail.
8297 ///
8298 /// # Additional Parameters
8299 ///
8300 /// * *$.xgafv* (query-string) - V1 error format.
8301 /// * *access_token* (query-string) - OAuth access token.
8302 /// * *alt* (query-string) - Data format for response.
8303 /// * *callback* (query-string) - JSONP
8304 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8305 /// * *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.
8306 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8307 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8308 /// * *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.
8309 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8310 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8311 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGatewayListCall<'a, C>
8312 where
8313 T: AsRef<str>,
8314 {
8315 self._additional_params
8316 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8317 self
8318 }
8319
8320 /// Identifies the authorization scope for the method you are building.
8321 ///
8322 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8323 /// [`Scope::CloudPlatform`].
8324 ///
8325 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8326 /// tokens for more than one scope.
8327 ///
8328 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8329 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8330 /// sufficient, a read-write scope will do as well.
8331 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGatewayListCall<'a, C>
8332 where
8333 St: AsRef<str>,
8334 {
8335 self._scopes.insert(String::from(scope.as_ref()));
8336 self
8337 }
8338 /// Identifies the authorization scope(s) for the method you are building.
8339 ///
8340 /// See [`Self::add_scope()`] for details.
8341 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGatewayListCall<'a, C>
8342 where
8343 I: IntoIterator<Item = St>,
8344 St: AsRef<str>,
8345 {
8346 self._scopes
8347 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8348 self
8349 }
8350
8351 /// Removes all scopes, and no default scope will be used either.
8352 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8353 /// for details).
8354 pub fn clear_scopes(mut self) -> ProjectLocationGatewayListCall<'a, C> {
8355 self._scopes.clear();
8356 self
8357 }
8358}
8359
8360/// Updates the parameters of a single Gateway.
8361///
8362/// A builder for the *locations.gateways.patch* method supported by a *project* resource.
8363/// It is not used directly, but through a [`ProjectMethods`] instance.
8364///
8365/// # Example
8366///
8367/// Instantiate a resource method builder
8368///
8369/// ```test_harness,no_run
8370/// # extern crate hyper;
8371/// # extern crate hyper_rustls;
8372/// # extern crate google_apigateway1 as apigateway1;
8373/// use apigateway1::api::ApigatewayGateway;
8374/// # async fn dox() {
8375/// # use apigateway1::{Apigateway, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8376///
8377/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8378/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8379/// # .with_native_roots()
8380/// # .unwrap()
8381/// # .https_only()
8382/// # .enable_http2()
8383/// # .build();
8384///
8385/// # let executor = hyper_util::rt::TokioExecutor::new();
8386/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8387/// # secret,
8388/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8389/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8390/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8391/// # ),
8392/// # ).build().await.unwrap();
8393///
8394/// # let client = hyper_util::client::legacy::Client::builder(
8395/// # hyper_util::rt::TokioExecutor::new()
8396/// # )
8397/// # .build(
8398/// # hyper_rustls::HttpsConnectorBuilder::new()
8399/// # .with_native_roots()
8400/// # .unwrap()
8401/// # .https_or_http()
8402/// # .enable_http2()
8403/// # .build()
8404/// # );
8405/// # let mut hub = Apigateway::new(client, auth);
8406/// // As the method needs a request, you would usually fill it with the desired information
8407/// // into the respective structure. Some of the parts shown here might not be applicable !
8408/// // Values shown here are possibly random and not representative !
8409/// let mut req = ApigatewayGateway::default();
8410///
8411/// // You can configure optional parameters by calling the respective setters at will, and
8412/// // execute the final call using `doit()`.
8413/// // Values shown here are possibly random and not representative !
8414/// let result = hub.projects().locations_gateways_patch(req, "name")
8415/// .update_mask(FieldMask::new::<&str>(&[]))
8416/// .doit().await;
8417/// # }
8418/// ```
8419pub struct ProjectLocationGatewayPatchCall<'a, C>
8420where
8421 C: 'a,
8422{
8423 hub: &'a Apigateway<C>,
8424 _request: ApigatewayGateway,
8425 _name: String,
8426 _update_mask: Option<common::FieldMask>,
8427 _delegate: Option<&'a mut dyn common::Delegate>,
8428 _additional_params: HashMap<String, String>,
8429 _scopes: BTreeSet<String>,
8430}
8431
8432impl<'a, C> common::CallBuilder for ProjectLocationGatewayPatchCall<'a, C> {}
8433
8434impl<'a, C> ProjectLocationGatewayPatchCall<'a, C>
8435where
8436 C: common::Connector,
8437{
8438 /// Perform the operation you have build so far.
8439 pub async fn doit(mut self) -> common::Result<(common::Response, ApigatewayOperation)> {
8440 use std::borrow::Cow;
8441 use std::io::{Read, Seek};
8442
8443 use common::{url::Params, ToParts};
8444 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8445
8446 let mut dd = common::DefaultDelegate;
8447 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8448 dlg.begin(common::MethodInfo {
8449 id: "apigateway.projects.locations.gateways.patch",
8450 http_method: hyper::Method::PATCH,
8451 });
8452
8453 for &field in ["alt", "name", "updateMask"].iter() {
8454 if self._additional_params.contains_key(field) {
8455 dlg.finished(false);
8456 return Err(common::Error::FieldClash(field));
8457 }
8458 }
8459
8460 let mut params = Params::with_capacity(5 + self._additional_params.len());
8461 params.push("name", self._name);
8462 if let Some(value) = self._update_mask.as_ref() {
8463 params.push("updateMask", value.to_string());
8464 }
8465
8466 params.extend(self._additional_params.iter());
8467
8468 params.push("alt", "json");
8469 let mut url = self.hub._base_url.clone() + "v1/{+name}";
8470 if self._scopes.is_empty() {
8471 self._scopes
8472 .insert(Scope::CloudPlatform.as_ref().to_string());
8473 }
8474
8475 #[allow(clippy::single_element_loop)]
8476 for &(find_this, param_name) in [("{+name}", "name")].iter() {
8477 url = params.uri_replacement(url, param_name, find_this, true);
8478 }
8479 {
8480 let to_remove = ["name"];
8481 params.remove_params(&to_remove);
8482 }
8483
8484 let url = params.parse_with_url(&url);
8485
8486 let mut json_mime_type = mime::APPLICATION_JSON;
8487 let mut request_value_reader = {
8488 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8489 common::remove_json_null_values(&mut value);
8490 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8491 serde_json::to_writer(&mut dst, &value).unwrap();
8492 dst
8493 };
8494 let request_size = request_value_reader
8495 .seek(std::io::SeekFrom::End(0))
8496 .unwrap();
8497 request_value_reader
8498 .seek(std::io::SeekFrom::Start(0))
8499 .unwrap();
8500
8501 loop {
8502 let token = match self
8503 .hub
8504 .auth
8505 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8506 .await
8507 {
8508 Ok(token) => token,
8509 Err(e) => match dlg.token(e) {
8510 Ok(token) => token,
8511 Err(e) => {
8512 dlg.finished(false);
8513 return Err(common::Error::MissingToken(e));
8514 }
8515 },
8516 };
8517 request_value_reader
8518 .seek(std::io::SeekFrom::Start(0))
8519 .unwrap();
8520 let mut req_result = {
8521 let client = &self.hub.client;
8522 dlg.pre_request();
8523 let mut req_builder = hyper::Request::builder()
8524 .method(hyper::Method::PATCH)
8525 .uri(url.as_str())
8526 .header(USER_AGENT, self.hub._user_agent.clone());
8527
8528 if let Some(token) = token.as_ref() {
8529 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8530 }
8531
8532 let request = req_builder
8533 .header(CONTENT_TYPE, json_mime_type.to_string())
8534 .header(CONTENT_LENGTH, request_size as u64)
8535 .body(common::to_body(
8536 request_value_reader.get_ref().clone().into(),
8537 ));
8538
8539 client.request(request.unwrap()).await
8540 };
8541
8542 match req_result {
8543 Err(err) => {
8544 if let common::Retry::After(d) = dlg.http_error(&err) {
8545 sleep(d).await;
8546 continue;
8547 }
8548 dlg.finished(false);
8549 return Err(common::Error::HttpError(err));
8550 }
8551 Ok(res) => {
8552 let (mut parts, body) = res.into_parts();
8553 let mut body = common::Body::new(body);
8554 if !parts.status.is_success() {
8555 let bytes = common::to_bytes(body).await.unwrap_or_default();
8556 let error = serde_json::from_str(&common::to_string(&bytes));
8557 let response = common::to_response(parts, bytes.into());
8558
8559 if let common::Retry::After(d) =
8560 dlg.http_failure(&response, error.as_ref().ok())
8561 {
8562 sleep(d).await;
8563 continue;
8564 }
8565
8566 dlg.finished(false);
8567
8568 return Err(match error {
8569 Ok(value) => common::Error::BadRequest(value),
8570 _ => common::Error::Failure(response),
8571 });
8572 }
8573 let response = {
8574 let bytes = common::to_bytes(body).await.unwrap_or_default();
8575 let encoded = common::to_string(&bytes);
8576 match serde_json::from_str(&encoded) {
8577 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8578 Err(error) => {
8579 dlg.response_json_decode_error(&encoded, &error);
8580 return Err(common::Error::JsonDecodeError(
8581 encoded.to_string(),
8582 error,
8583 ));
8584 }
8585 }
8586 };
8587
8588 dlg.finished(true);
8589 return Ok(response);
8590 }
8591 }
8592 }
8593 }
8594
8595 ///
8596 /// Sets the *request* property to the given value.
8597 ///
8598 /// Even though the property as already been set when instantiating this call,
8599 /// we provide this method for API completeness.
8600 pub fn request(
8601 mut self,
8602 new_value: ApigatewayGateway,
8603 ) -> ProjectLocationGatewayPatchCall<'a, C> {
8604 self._request = new_value;
8605 self
8606 }
8607 /// Output only. Resource name of the Gateway. Format: projects/{project}/locations/{location}/gateways/{gateway}
8608 ///
8609 /// Sets the *name* path property to the given value.
8610 ///
8611 /// Even though the property as already been set when instantiating this call,
8612 /// we provide this method for API completeness.
8613 pub fn name(mut self, new_value: &str) -> ProjectLocationGatewayPatchCall<'a, C> {
8614 self._name = new_value.to_string();
8615 self
8616 }
8617 /// 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.
8618 ///
8619 /// Sets the *update mask* query property to the given value.
8620 pub fn update_mask(
8621 mut self,
8622 new_value: common::FieldMask,
8623 ) -> ProjectLocationGatewayPatchCall<'a, C> {
8624 self._update_mask = Some(new_value);
8625 self
8626 }
8627 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8628 /// while executing the actual API request.
8629 ///
8630 /// ````text
8631 /// It should be used to handle progress information, and to implement a certain level of resilience.
8632 /// ````
8633 ///
8634 /// Sets the *delegate* property to the given value.
8635 pub fn delegate(
8636 mut self,
8637 new_value: &'a mut dyn common::Delegate,
8638 ) -> ProjectLocationGatewayPatchCall<'a, C> {
8639 self._delegate = Some(new_value);
8640 self
8641 }
8642
8643 /// Set any additional parameter of the query string used in the request.
8644 /// It should be used to set parameters which are not yet available through their own
8645 /// setters.
8646 ///
8647 /// Please note that this method must not be used to set any of the known parameters
8648 /// which have their own setter method. If done anyway, the request will fail.
8649 ///
8650 /// # Additional Parameters
8651 ///
8652 /// * *$.xgafv* (query-string) - V1 error format.
8653 /// * *access_token* (query-string) - OAuth access token.
8654 /// * *alt* (query-string) - Data format for response.
8655 /// * *callback* (query-string) - JSONP
8656 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8657 /// * *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.
8658 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8659 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8660 /// * *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.
8661 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8662 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8663 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGatewayPatchCall<'a, C>
8664 where
8665 T: AsRef<str>,
8666 {
8667 self._additional_params
8668 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8669 self
8670 }
8671
8672 /// Identifies the authorization scope for the method you are building.
8673 ///
8674 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8675 /// [`Scope::CloudPlatform`].
8676 ///
8677 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8678 /// tokens for more than one scope.
8679 ///
8680 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8681 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8682 /// sufficient, a read-write scope will do as well.
8683 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGatewayPatchCall<'a, C>
8684 where
8685 St: AsRef<str>,
8686 {
8687 self._scopes.insert(String::from(scope.as_ref()));
8688 self
8689 }
8690 /// Identifies the authorization scope(s) for the method you are building.
8691 ///
8692 /// See [`Self::add_scope()`] for details.
8693 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGatewayPatchCall<'a, C>
8694 where
8695 I: IntoIterator<Item = St>,
8696 St: AsRef<str>,
8697 {
8698 self._scopes
8699 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8700 self
8701 }
8702
8703 /// Removes all scopes, and no default scope will be used either.
8704 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8705 /// for details).
8706 pub fn clear_scopes(mut self) -> ProjectLocationGatewayPatchCall<'a, C> {
8707 self._scopes.clear();
8708 self
8709 }
8710}
8711
8712/// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
8713///
8714/// A builder for the *locations.gateways.setIamPolicy* method supported by a *project* resource.
8715/// It is not used directly, but through a [`ProjectMethods`] instance.
8716///
8717/// # Example
8718///
8719/// Instantiate a resource method builder
8720///
8721/// ```test_harness,no_run
8722/// # extern crate hyper;
8723/// # extern crate hyper_rustls;
8724/// # extern crate google_apigateway1 as apigateway1;
8725/// use apigateway1::api::ApigatewaySetIamPolicyRequest;
8726/// # async fn dox() {
8727/// # use apigateway1::{Apigateway, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8728///
8729/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8730/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8731/// # .with_native_roots()
8732/// # .unwrap()
8733/// # .https_only()
8734/// # .enable_http2()
8735/// # .build();
8736///
8737/// # let executor = hyper_util::rt::TokioExecutor::new();
8738/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8739/// # secret,
8740/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8741/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8742/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8743/// # ),
8744/// # ).build().await.unwrap();
8745///
8746/// # let client = hyper_util::client::legacy::Client::builder(
8747/// # hyper_util::rt::TokioExecutor::new()
8748/// # )
8749/// # .build(
8750/// # hyper_rustls::HttpsConnectorBuilder::new()
8751/// # .with_native_roots()
8752/// # .unwrap()
8753/// # .https_or_http()
8754/// # .enable_http2()
8755/// # .build()
8756/// # );
8757/// # let mut hub = Apigateway::new(client, auth);
8758/// // As the method needs a request, you would usually fill it with the desired information
8759/// // into the respective structure. Some of the parts shown here might not be applicable !
8760/// // Values shown here are possibly random and not representative !
8761/// let mut req = ApigatewaySetIamPolicyRequest::default();
8762///
8763/// // You can configure optional parameters by calling the respective setters at will, and
8764/// // execute the final call using `doit()`.
8765/// // Values shown here are possibly random and not representative !
8766/// let result = hub.projects().locations_gateways_set_iam_policy(req, "resource")
8767/// .doit().await;
8768/// # }
8769/// ```
8770pub struct ProjectLocationGatewaySetIamPolicyCall<'a, C>
8771where
8772 C: 'a,
8773{
8774 hub: &'a Apigateway<C>,
8775 _request: ApigatewaySetIamPolicyRequest,
8776 _resource: String,
8777 _delegate: Option<&'a mut dyn common::Delegate>,
8778 _additional_params: HashMap<String, String>,
8779 _scopes: BTreeSet<String>,
8780}
8781
8782impl<'a, C> common::CallBuilder for ProjectLocationGatewaySetIamPolicyCall<'a, C> {}
8783
8784impl<'a, C> ProjectLocationGatewaySetIamPolicyCall<'a, C>
8785where
8786 C: common::Connector,
8787{
8788 /// Perform the operation you have build so far.
8789 pub async fn doit(mut self) -> common::Result<(common::Response, ApigatewayPolicy)> {
8790 use std::borrow::Cow;
8791 use std::io::{Read, Seek};
8792
8793 use common::{url::Params, ToParts};
8794 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8795
8796 let mut dd = common::DefaultDelegate;
8797 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8798 dlg.begin(common::MethodInfo {
8799 id: "apigateway.projects.locations.gateways.setIamPolicy",
8800 http_method: hyper::Method::POST,
8801 });
8802
8803 for &field in ["alt", "resource"].iter() {
8804 if self._additional_params.contains_key(field) {
8805 dlg.finished(false);
8806 return Err(common::Error::FieldClash(field));
8807 }
8808 }
8809
8810 let mut params = Params::with_capacity(4 + self._additional_params.len());
8811 params.push("resource", self._resource);
8812
8813 params.extend(self._additional_params.iter());
8814
8815 params.push("alt", "json");
8816 let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
8817 if self._scopes.is_empty() {
8818 self._scopes
8819 .insert(Scope::CloudPlatform.as_ref().to_string());
8820 }
8821
8822 #[allow(clippy::single_element_loop)]
8823 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
8824 url = params.uri_replacement(url, param_name, find_this, true);
8825 }
8826 {
8827 let to_remove = ["resource"];
8828 params.remove_params(&to_remove);
8829 }
8830
8831 let url = params.parse_with_url(&url);
8832
8833 let mut json_mime_type = mime::APPLICATION_JSON;
8834 let mut request_value_reader = {
8835 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8836 common::remove_json_null_values(&mut value);
8837 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8838 serde_json::to_writer(&mut dst, &value).unwrap();
8839 dst
8840 };
8841 let request_size = request_value_reader
8842 .seek(std::io::SeekFrom::End(0))
8843 .unwrap();
8844 request_value_reader
8845 .seek(std::io::SeekFrom::Start(0))
8846 .unwrap();
8847
8848 loop {
8849 let token = match self
8850 .hub
8851 .auth
8852 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8853 .await
8854 {
8855 Ok(token) => token,
8856 Err(e) => match dlg.token(e) {
8857 Ok(token) => token,
8858 Err(e) => {
8859 dlg.finished(false);
8860 return Err(common::Error::MissingToken(e));
8861 }
8862 },
8863 };
8864 request_value_reader
8865 .seek(std::io::SeekFrom::Start(0))
8866 .unwrap();
8867 let mut req_result = {
8868 let client = &self.hub.client;
8869 dlg.pre_request();
8870 let mut req_builder = hyper::Request::builder()
8871 .method(hyper::Method::POST)
8872 .uri(url.as_str())
8873 .header(USER_AGENT, self.hub._user_agent.clone());
8874
8875 if let Some(token) = token.as_ref() {
8876 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8877 }
8878
8879 let request = req_builder
8880 .header(CONTENT_TYPE, json_mime_type.to_string())
8881 .header(CONTENT_LENGTH, request_size as u64)
8882 .body(common::to_body(
8883 request_value_reader.get_ref().clone().into(),
8884 ));
8885
8886 client.request(request.unwrap()).await
8887 };
8888
8889 match req_result {
8890 Err(err) => {
8891 if let common::Retry::After(d) = dlg.http_error(&err) {
8892 sleep(d).await;
8893 continue;
8894 }
8895 dlg.finished(false);
8896 return Err(common::Error::HttpError(err));
8897 }
8898 Ok(res) => {
8899 let (mut parts, body) = res.into_parts();
8900 let mut body = common::Body::new(body);
8901 if !parts.status.is_success() {
8902 let bytes = common::to_bytes(body).await.unwrap_or_default();
8903 let error = serde_json::from_str(&common::to_string(&bytes));
8904 let response = common::to_response(parts, bytes.into());
8905
8906 if let common::Retry::After(d) =
8907 dlg.http_failure(&response, error.as_ref().ok())
8908 {
8909 sleep(d).await;
8910 continue;
8911 }
8912
8913 dlg.finished(false);
8914
8915 return Err(match error {
8916 Ok(value) => common::Error::BadRequest(value),
8917 _ => common::Error::Failure(response),
8918 });
8919 }
8920 let response = {
8921 let bytes = common::to_bytes(body).await.unwrap_or_default();
8922 let encoded = common::to_string(&bytes);
8923 match serde_json::from_str(&encoded) {
8924 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8925 Err(error) => {
8926 dlg.response_json_decode_error(&encoded, &error);
8927 return Err(common::Error::JsonDecodeError(
8928 encoded.to_string(),
8929 error,
8930 ));
8931 }
8932 }
8933 };
8934
8935 dlg.finished(true);
8936 return Ok(response);
8937 }
8938 }
8939 }
8940 }
8941
8942 ///
8943 /// Sets the *request* property to the given value.
8944 ///
8945 /// Even though the property as already been set when instantiating this call,
8946 /// we provide this method for API completeness.
8947 pub fn request(
8948 mut self,
8949 new_value: ApigatewaySetIamPolicyRequest,
8950 ) -> ProjectLocationGatewaySetIamPolicyCall<'a, C> {
8951 self._request = new_value;
8952 self
8953 }
8954 /// 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.
8955 ///
8956 /// Sets the *resource* path property to the given value.
8957 ///
8958 /// Even though the property as already been set when instantiating this call,
8959 /// we provide this method for API completeness.
8960 pub fn resource(mut self, new_value: &str) -> ProjectLocationGatewaySetIamPolicyCall<'a, C> {
8961 self._resource = new_value.to_string();
8962 self
8963 }
8964 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8965 /// while executing the actual API request.
8966 ///
8967 /// ````text
8968 /// It should be used to handle progress information, and to implement a certain level of resilience.
8969 /// ````
8970 ///
8971 /// Sets the *delegate* property to the given value.
8972 pub fn delegate(
8973 mut self,
8974 new_value: &'a mut dyn common::Delegate,
8975 ) -> ProjectLocationGatewaySetIamPolicyCall<'a, C> {
8976 self._delegate = Some(new_value);
8977 self
8978 }
8979
8980 /// Set any additional parameter of the query string used in the request.
8981 /// It should be used to set parameters which are not yet available through their own
8982 /// setters.
8983 ///
8984 /// Please note that this method must not be used to set any of the known parameters
8985 /// which have their own setter method. If done anyway, the request will fail.
8986 ///
8987 /// # Additional Parameters
8988 ///
8989 /// * *$.xgafv* (query-string) - V1 error format.
8990 /// * *access_token* (query-string) - OAuth access token.
8991 /// * *alt* (query-string) - Data format for response.
8992 /// * *callback* (query-string) - JSONP
8993 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8994 /// * *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.
8995 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8996 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8997 /// * *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.
8998 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8999 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9000 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGatewaySetIamPolicyCall<'a, C>
9001 where
9002 T: AsRef<str>,
9003 {
9004 self._additional_params
9005 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9006 self
9007 }
9008
9009 /// Identifies the authorization scope for the method you are building.
9010 ///
9011 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9012 /// [`Scope::CloudPlatform`].
9013 ///
9014 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9015 /// tokens for more than one scope.
9016 ///
9017 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9018 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9019 /// sufficient, a read-write scope will do as well.
9020 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGatewaySetIamPolicyCall<'a, C>
9021 where
9022 St: AsRef<str>,
9023 {
9024 self._scopes.insert(String::from(scope.as_ref()));
9025 self
9026 }
9027 /// Identifies the authorization scope(s) for the method you are building.
9028 ///
9029 /// See [`Self::add_scope()`] for details.
9030 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGatewaySetIamPolicyCall<'a, C>
9031 where
9032 I: IntoIterator<Item = St>,
9033 St: AsRef<str>,
9034 {
9035 self._scopes
9036 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9037 self
9038 }
9039
9040 /// Removes all scopes, and no default scope will be used either.
9041 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9042 /// for details).
9043 pub fn clear_scopes(mut self) -> ProjectLocationGatewaySetIamPolicyCall<'a, C> {
9044 self._scopes.clear();
9045 self
9046 }
9047}
9048
9049/// 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.
9050///
9051/// A builder for the *locations.gateways.testIamPermissions* method supported by a *project* resource.
9052/// It is not used directly, but through a [`ProjectMethods`] instance.
9053///
9054/// # Example
9055///
9056/// Instantiate a resource method builder
9057///
9058/// ```test_harness,no_run
9059/// # extern crate hyper;
9060/// # extern crate hyper_rustls;
9061/// # extern crate google_apigateway1 as apigateway1;
9062/// use apigateway1::api::ApigatewayTestIamPermissionsRequest;
9063/// # async fn dox() {
9064/// # use apigateway1::{Apigateway, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9065///
9066/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9067/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9068/// # .with_native_roots()
9069/// # .unwrap()
9070/// # .https_only()
9071/// # .enable_http2()
9072/// # .build();
9073///
9074/// # let executor = hyper_util::rt::TokioExecutor::new();
9075/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9076/// # secret,
9077/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9078/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9079/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9080/// # ),
9081/// # ).build().await.unwrap();
9082///
9083/// # let client = hyper_util::client::legacy::Client::builder(
9084/// # hyper_util::rt::TokioExecutor::new()
9085/// # )
9086/// # .build(
9087/// # hyper_rustls::HttpsConnectorBuilder::new()
9088/// # .with_native_roots()
9089/// # .unwrap()
9090/// # .https_or_http()
9091/// # .enable_http2()
9092/// # .build()
9093/// # );
9094/// # let mut hub = Apigateway::new(client, auth);
9095/// // As the method needs a request, you would usually fill it with the desired information
9096/// // into the respective structure. Some of the parts shown here might not be applicable !
9097/// // Values shown here are possibly random and not representative !
9098/// let mut req = ApigatewayTestIamPermissionsRequest::default();
9099///
9100/// // You can configure optional parameters by calling the respective setters at will, and
9101/// // execute the final call using `doit()`.
9102/// // Values shown here are possibly random and not representative !
9103/// let result = hub.projects().locations_gateways_test_iam_permissions(req, "resource")
9104/// .doit().await;
9105/// # }
9106/// ```
9107pub struct ProjectLocationGatewayTestIamPermissionCall<'a, C>
9108where
9109 C: 'a,
9110{
9111 hub: &'a Apigateway<C>,
9112 _request: ApigatewayTestIamPermissionsRequest,
9113 _resource: String,
9114 _delegate: Option<&'a mut dyn common::Delegate>,
9115 _additional_params: HashMap<String, String>,
9116 _scopes: BTreeSet<String>,
9117}
9118
9119impl<'a, C> common::CallBuilder for ProjectLocationGatewayTestIamPermissionCall<'a, C> {}
9120
9121impl<'a, C> ProjectLocationGatewayTestIamPermissionCall<'a, C>
9122where
9123 C: common::Connector,
9124{
9125 /// Perform the operation you have build so far.
9126 pub async fn doit(
9127 mut self,
9128 ) -> common::Result<(common::Response, ApigatewayTestIamPermissionsResponse)> {
9129 use std::borrow::Cow;
9130 use std::io::{Read, Seek};
9131
9132 use common::{url::Params, ToParts};
9133 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9134
9135 let mut dd = common::DefaultDelegate;
9136 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9137 dlg.begin(common::MethodInfo {
9138 id: "apigateway.projects.locations.gateways.testIamPermissions",
9139 http_method: hyper::Method::POST,
9140 });
9141
9142 for &field in ["alt", "resource"].iter() {
9143 if self._additional_params.contains_key(field) {
9144 dlg.finished(false);
9145 return Err(common::Error::FieldClash(field));
9146 }
9147 }
9148
9149 let mut params = Params::with_capacity(4 + self._additional_params.len());
9150 params.push("resource", self._resource);
9151
9152 params.extend(self._additional_params.iter());
9153
9154 params.push("alt", "json");
9155 let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
9156 if self._scopes.is_empty() {
9157 self._scopes
9158 .insert(Scope::CloudPlatform.as_ref().to_string());
9159 }
9160
9161 #[allow(clippy::single_element_loop)]
9162 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
9163 url = params.uri_replacement(url, param_name, find_this, true);
9164 }
9165 {
9166 let to_remove = ["resource"];
9167 params.remove_params(&to_remove);
9168 }
9169
9170 let url = params.parse_with_url(&url);
9171
9172 let mut json_mime_type = mime::APPLICATION_JSON;
9173 let mut request_value_reader = {
9174 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9175 common::remove_json_null_values(&mut value);
9176 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9177 serde_json::to_writer(&mut dst, &value).unwrap();
9178 dst
9179 };
9180 let request_size = request_value_reader
9181 .seek(std::io::SeekFrom::End(0))
9182 .unwrap();
9183 request_value_reader
9184 .seek(std::io::SeekFrom::Start(0))
9185 .unwrap();
9186
9187 loop {
9188 let token = match self
9189 .hub
9190 .auth
9191 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9192 .await
9193 {
9194 Ok(token) => token,
9195 Err(e) => match dlg.token(e) {
9196 Ok(token) => token,
9197 Err(e) => {
9198 dlg.finished(false);
9199 return Err(common::Error::MissingToken(e));
9200 }
9201 },
9202 };
9203 request_value_reader
9204 .seek(std::io::SeekFrom::Start(0))
9205 .unwrap();
9206 let mut req_result = {
9207 let client = &self.hub.client;
9208 dlg.pre_request();
9209 let mut req_builder = hyper::Request::builder()
9210 .method(hyper::Method::POST)
9211 .uri(url.as_str())
9212 .header(USER_AGENT, self.hub._user_agent.clone());
9213
9214 if let Some(token) = token.as_ref() {
9215 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9216 }
9217
9218 let request = req_builder
9219 .header(CONTENT_TYPE, json_mime_type.to_string())
9220 .header(CONTENT_LENGTH, request_size as u64)
9221 .body(common::to_body(
9222 request_value_reader.get_ref().clone().into(),
9223 ));
9224
9225 client.request(request.unwrap()).await
9226 };
9227
9228 match req_result {
9229 Err(err) => {
9230 if let common::Retry::After(d) = dlg.http_error(&err) {
9231 sleep(d).await;
9232 continue;
9233 }
9234 dlg.finished(false);
9235 return Err(common::Error::HttpError(err));
9236 }
9237 Ok(res) => {
9238 let (mut parts, body) = res.into_parts();
9239 let mut body = common::Body::new(body);
9240 if !parts.status.is_success() {
9241 let bytes = common::to_bytes(body).await.unwrap_or_default();
9242 let error = serde_json::from_str(&common::to_string(&bytes));
9243 let response = common::to_response(parts, bytes.into());
9244
9245 if let common::Retry::After(d) =
9246 dlg.http_failure(&response, error.as_ref().ok())
9247 {
9248 sleep(d).await;
9249 continue;
9250 }
9251
9252 dlg.finished(false);
9253
9254 return Err(match error {
9255 Ok(value) => common::Error::BadRequest(value),
9256 _ => common::Error::Failure(response),
9257 });
9258 }
9259 let response = {
9260 let bytes = common::to_bytes(body).await.unwrap_or_default();
9261 let encoded = common::to_string(&bytes);
9262 match serde_json::from_str(&encoded) {
9263 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9264 Err(error) => {
9265 dlg.response_json_decode_error(&encoded, &error);
9266 return Err(common::Error::JsonDecodeError(
9267 encoded.to_string(),
9268 error,
9269 ));
9270 }
9271 }
9272 };
9273
9274 dlg.finished(true);
9275 return Ok(response);
9276 }
9277 }
9278 }
9279 }
9280
9281 ///
9282 /// Sets the *request* property to the given value.
9283 ///
9284 /// Even though the property as already been set when instantiating this call,
9285 /// we provide this method for API completeness.
9286 pub fn request(
9287 mut self,
9288 new_value: ApigatewayTestIamPermissionsRequest,
9289 ) -> ProjectLocationGatewayTestIamPermissionCall<'a, C> {
9290 self._request = new_value;
9291 self
9292 }
9293 /// 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.
9294 ///
9295 /// Sets the *resource* path property to the given value.
9296 ///
9297 /// Even though the property as already been set when instantiating this call,
9298 /// we provide this method for API completeness.
9299 pub fn resource(
9300 mut self,
9301 new_value: &str,
9302 ) -> ProjectLocationGatewayTestIamPermissionCall<'a, C> {
9303 self._resource = new_value.to_string();
9304 self
9305 }
9306 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9307 /// while executing the actual API request.
9308 ///
9309 /// ````text
9310 /// It should be used to handle progress information, and to implement a certain level of resilience.
9311 /// ````
9312 ///
9313 /// Sets the *delegate* property to the given value.
9314 pub fn delegate(
9315 mut self,
9316 new_value: &'a mut dyn common::Delegate,
9317 ) -> ProjectLocationGatewayTestIamPermissionCall<'a, C> {
9318 self._delegate = Some(new_value);
9319 self
9320 }
9321
9322 /// Set any additional parameter of the query string used in the request.
9323 /// It should be used to set parameters which are not yet available through their own
9324 /// setters.
9325 ///
9326 /// Please note that this method must not be used to set any of the known parameters
9327 /// which have their own setter method. If done anyway, the request will fail.
9328 ///
9329 /// # Additional Parameters
9330 ///
9331 /// * *$.xgafv* (query-string) - V1 error format.
9332 /// * *access_token* (query-string) - OAuth access token.
9333 /// * *alt* (query-string) - Data format for response.
9334 /// * *callback* (query-string) - JSONP
9335 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9336 /// * *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.
9337 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9338 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9339 /// * *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.
9340 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9341 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9342 pub fn param<T>(
9343 mut self,
9344 name: T,
9345 value: T,
9346 ) -> ProjectLocationGatewayTestIamPermissionCall<'a, C>
9347 where
9348 T: AsRef<str>,
9349 {
9350 self._additional_params
9351 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9352 self
9353 }
9354
9355 /// Identifies the authorization scope for the method you are building.
9356 ///
9357 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9358 /// [`Scope::CloudPlatform`].
9359 ///
9360 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9361 /// tokens for more than one scope.
9362 ///
9363 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9364 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9365 /// sufficient, a read-write scope will do as well.
9366 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGatewayTestIamPermissionCall<'a, C>
9367 where
9368 St: AsRef<str>,
9369 {
9370 self._scopes.insert(String::from(scope.as_ref()));
9371 self
9372 }
9373 /// Identifies the authorization scope(s) for the method you are building.
9374 ///
9375 /// See [`Self::add_scope()`] for details.
9376 pub fn add_scopes<I, St>(
9377 mut self,
9378 scopes: I,
9379 ) -> ProjectLocationGatewayTestIamPermissionCall<'a, C>
9380 where
9381 I: IntoIterator<Item = St>,
9382 St: AsRef<str>,
9383 {
9384 self._scopes
9385 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9386 self
9387 }
9388
9389 /// Removes all scopes, and no default scope will be used either.
9390 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9391 /// for details).
9392 pub fn clear_scopes(mut self) -> ProjectLocationGatewayTestIamPermissionCall<'a, C> {
9393 self._scopes.clear();
9394 self
9395 }
9396}
9397
9398/// 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`.
9399///
9400/// A builder for the *locations.operations.cancel* method supported by a *project* resource.
9401/// It is not used directly, but through a [`ProjectMethods`] instance.
9402///
9403/// # Example
9404///
9405/// Instantiate a resource method builder
9406///
9407/// ```test_harness,no_run
9408/// # extern crate hyper;
9409/// # extern crate hyper_rustls;
9410/// # extern crate google_apigateway1 as apigateway1;
9411/// use apigateway1::api::ApigatewayCancelOperationRequest;
9412/// # async fn dox() {
9413/// # use apigateway1::{Apigateway, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9414///
9415/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9416/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9417/// # .with_native_roots()
9418/// # .unwrap()
9419/// # .https_only()
9420/// # .enable_http2()
9421/// # .build();
9422///
9423/// # let executor = hyper_util::rt::TokioExecutor::new();
9424/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9425/// # secret,
9426/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9427/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9428/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9429/// # ),
9430/// # ).build().await.unwrap();
9431///
9432/// # let client = hyper_util::client::legacy::Client::builder(
9433/// # hyper_util::rt::TokioExecutor::new()
9434/// # )
9435/// # .build(
9436/// # hyper_rustls::HttpsConnectorBuilder::new()
9437/// # .with_native_roots()
9438/// # .unwrap()
9439/// # .https_or_http()
9440/// # .enable_http2()
9441/// # .build()
9442/// # );
9443/// # let mut hub = Apigateway::new(client, auth);
9444/// // As the method needs a request, you would usually fill it with the desired information
9445/// // into the respective structure. Some of the parts shown here might not be applicable !
9446/// // Values shown here are possibly random and not representative !
9447/// let mut req = ApigatewayCancelOperationRequest::default();
9448///
9449/// // You can configure optional parameters by calling the respective setters at will, and
9450/// // execute the final call using `doit()`.
9451/// // Values shown here are possibly random and not representative !
9452/// let result = hub.projects().locations_operations_cancel(req, "name")
9453/// .doit().await;
9454/// # }
9455/// ```
9456pub struct ProjectLocationOperationCancelCall<'a, C>
9457where
9458 C: 'a,
9459{
9460 hub: &'a Apigateway<C>,
9461 _request: ApigatewayCancelOperationRequest,
9462 _name: String,
9463 _delegate: Option<&'a mut dyn common::Delegate>,
9464 _additional_params: HashMap<String, String>,
9465 _scopes: BTreeSet<String>,
9466}
9467
9468impl<'a, C> common::CallBuilder for ProjectLocationOperationCancelCall<'a, C> {}
9469
9470impl<'a, C> ProjectLocationOperationCancelCall<'a, C>
9471where
9472 C: common::Connector,
9473{
9474 /// Perform the operation you have build so far.
9475 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
9476 use std::borrow::Cow;
9477 use std::io::{Read, Seek};
9478
9479 use common::{url::Params, ToParts};
9480 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9481
9482 let mut dd = common::DefaultDelegate;
9483 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9484 dlg.begin(common::MethodInfo {
9485 id: "apigateway.projects.locations.operations.cancel",
9486 http_method: hyper::Method::POST,
9487 });
9488
9489 for &field in ["alt", "name"].iter() {
9490 if self._additional_params.contains_key(field) {
9491 dlg.finished(false);
9492 return Err(common::Error::FieldClash(field));
9493 }
9494 }
9495
9496 let mut params = Params::with_capacity(4 + self._additional_params.len());
9497 params.push("name", self._name);
9498
9499 params.extend(self._additional_params.iter());
9500
9501 params.push("alt", "json");
9502 let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
9503 if self._scopes.is_empty() {
9504 self._scopes
9505 .insert(Scope::CloudPlatform.as_ref().to_string());
9506 }
9507
9508 #[allow(clippy::single_element_loop)]
9509 for &(find_this, param_name) in [("{+name}", "name")].iter() {
9510 url = params.uri_replacement(url, param_name, find_this, true);
9511 }
9512 {
9513 let to_remove = ["name"];
9514 params.remove_params(&to_remove);
9515 }
9516
9517 let url = params.parse_with_url(&url);
9518
9519 let mut json_mime_type = mime::APPLICATION_JSON;
9520 let mut request_value_reader = {
9521 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9522 common::remove_json_null_values(&mut value);
9523 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9524 serde_json::to_writer(&mut dst, &value).unwrap();
9525 dst
9526 };
9527 let request_size = request_value_reader
9528 .seek(std::io::SeekFrom::End(0))
9529 .unwrap();
9530 request_value_reader
9531 .seek(std::io::SeekFrom::Start(0))
9532 .unwrap();
9533
9534 loop {
9535 let token = match self
9536 .hub
9537 .auth
9538 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9539 .await
9540 {
9541 Ok(token) => token,
9542 Err(e) => match dlg.token(e) {
9543 Ok(token) => token,
9544 Err(e) => {
9545 dlg.finished(false);
9546 return Err(common::Error::MissingToken(e));
9547 }
9548 },
9549 };
9550 request_value_reader
9551 .seek(std::io::SeekFrom::Start(0))
9552 .unwrap();
9553 let mut req_result = {
9554 let client = &self.hub.client;
9555 dlg.pre_request();
9556 let mut req_builder = hyper::Request::builder()
9557 .method(hyper::Method::POST)
9558 .uri(url.as_str())
9559 .header(USER_AGENT, self.hub._user_agent.clone());
9560
9561 if let Some(token) = token.as_ref() {
9562 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9563 }
9564
9565 let request = req_builder
9566 .header(CONTENT_TYPE, json_mime_type.to_string())
9567 .header(CONTENT_LENGTH, request_size as u64)
9568 .body(common::to_body(
9569 request_value_reader.get_ref().clone().into(),
9570 ));
9571
9572 client.request(request.unwrap()).await
9573 };
9574
9575 match req_result {
9576 Err(err) => {
9577 if let common::Retry::After(d) = dlg.http_error(&err) {
9578 sleep(d).await;
9579 continue;
9580 }
9581 dlg.finished(false);
9582 return Err(common::Error::HttpError(err));
9583 }
9584 Ok(res) => {
9585 let (mut parts, body) = res.into_parts();
9586 let mut body = common::Body::new(body);
9587 if !parts.status.is_success() {
9588 let bytes = common::to_bytes(body).await.unwrap_or_default();
9589 let error = serde_json::from_str(&common::to_string(&bytes));
9590 let response = common::to_response(parts, bytes.into());
9591
9592 if let common::Retry::After(d) =
9593 dlg.http_failure(&response, error.as_ref().ok())
9594 {
9595 sleep(d).await;
9596 continue;
9597 }
9598
9599 dlg.finished(false);
9600
9601 return Err(match error {
9602 Ok(value) => common::Error::BadRequest(value),
9603 _ => common::Error::Failure(response),
9604 });
9605 }
9606 let response = {
9607 let bytes = common::to_bytes(body).await.unwrap_or_default();
9608 let encoded = common::to_string(&bytes);
9609 match serde_json::from_str(&encoded) {
9610 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9611 Err(error) => {
9612 dlg.response_json_decode_error(&encoded, &error);
9613 return Err(common::Error::JsonDecodeError(
9614 encoded.to_string(),
9615 error,
9616 ));
9617 }
9618 }
9619 };
9620
9621 dlg.finished(true);
9622 return Ok(response);
9623 }
9624 }
9625 }
9626 }
9627
9628 ///
9629 /// Sets the *request* property to the given value.
9630 ///
9631 /// Even though the property as already been set when instantiating this call,
9632 /// we provide this method for API completeness.
9633 pub fn request(
9634 mut self,
9635 new_value: ApigatewayCancelOperationRequest,
9636 ) -> ProjectLocationOperationCancelCall<'a, C> {
9637 self._request = new_value;
9638 self
9639 }
9640 /// The name of the operation resource to be cancelled.
9641 ///
9642 /// Sets the *name* path property to the given value.
9643 ///
9644 /// Even though the property as already been set when instantiating this call,
9645 /// we provide this method for API completeness.
9646 pub fn name(mut self, new_value: &str) -> ProjectLocationOperationCancelCall<'a, C> {
9647 self._name = new_value.to_string();
9648 self
9649 }
9650 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9651 /// while executing the actual API request.
9652 ///
9653 /// ````text
9654 /// It should be used to handle progress information, and to implement a certain level of resilience.
9655 /// ````
9656 ///
9657 /// Sets the *delegate* property to the given value.
9658 pub fn delegate(
9659 mut self,
9660 new_value: &'a mut dyn common::Delegate,
9661 ) -> ProjectLocationOperationCancelCall<'a, C> {
9662 self._delegate = Some(new_value);
9663 self
9664 }
9665
9666 /// Set any additional parameter of the query string used in the request.
9667 /// It should be used to set parameters which are not yet available through their own
9668 /// setters.
9669 ///
9670 /// Please note that this method must not be used to set any of the known parameters
9671 /// which have their own setter method. If done anyway, the request will fail.
9672 ///
9673 /// # Additional Parameters
9674 ///
9675 /// * *$.xgafv* (query-string) - V1 error format.
9676 /// * *access_token* (query-string) - OAuth access token.
9677 /// * *alt* (query-string) - Data format for response.
9678 /// * *callback* (query-string) - JSONP
9679 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9680 /// * *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.
9681 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9682 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9683 /// * *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.
9684 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9685 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9686 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationCancelCall<'a, C>
9687 where
9688 T: AsRef<str>,
9689 {
9690 self._additional_params
9691 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9692 self
9693 }
9694
9695 /// Identifies the authorization scope for the method you are building.
9696 ///
9697 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9698 /// [`Scope::CloudPlatform`].
9699 ///
9700 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9701 /// tokens for more than one scope.
9702 ///
9703 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9704 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9705 /// sufficient, a read-write scope will do as well.
9706 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationCancelCall<'a, C>
9707 where
9708 St: AsRef<str>,
9709 {
9710 self._scopes.insert(String::from(scope.as_ref()));
9711 self
9712 }
9713 /// Identifies the authorization scope(s) for the method you are building.
9714 ///
9715 /// See [`Self::add_scope()`] for details.
9716 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationCancelCall<'a, C>
9717 where
9718 I: IntoIterator<Item = St>,
9719 St: AsRef<str>,
9720 {
9721 self._scopes
9722 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9723 self
9724 }
9725
9726 /// Removes all scopes, and no default scope will be used either.
9727 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9728 /// for details).
9729 pub fn clear_scopes(mut self) -> ProjectLocationOperationCancelCall<'a, C> {
9730 self._scopes.clear();
9731 self
9732 }
9733}
9734
9735/// 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`.
9736///
9737/// A builder for the *locations.operations.delete* method supported by a *project* resource.
9738/// It is not used directly, but through a [`ProjectMethods`] instance.
9739///
9740/// # Example
9741///
9742/// Instantiate a resource method builder
9743///
9744/// ```test_harness,no_run
9745/// # extern crate hyper;
9746/// # extern crate hyper_rustls;
9747/// # extern crate google_apigateway1 as apigateway1;
9748/// # async fn dox() {
9749/// # use apigateway1::{Apigateway, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9750///
9751/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9752/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9753/// # .with_native_roots()
9754/// # .unwrap()
9755/// # .https_only()
9756/// # .enable_http2()
9757/// # .build();
9758///
9759/// # let executor = hyper_util::rt::TokioExecutor::new();
9760/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9761/// # secret,
9762/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9763/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9764/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9765/// # ),
9766/// # ).build().await.unwrap();
9767///
9768/// # let client = hyper_util::client::legacy::Client::builder(
9769/// # hyper_util::rt::TokioExecutor::new()
9770/// # )
9771/// # .build(
9772/// # hyper_rustls::HttpsConnectorBuilder::new()
9773/// # .with_native_roots()
9774/// # .unwrap()
9775/// # .https_or_http()
9776/// # .enable_http2()
9777/// # .build()
9778/// # );
9779/// # let mut hub = Apigateway::new(client, auth);
9780/// // You can configure optional parameters by calling the respective setters at will, and
9781/// // execute the final call using `doit()`.
9782/// // Values shown here are possibly random and not representative !
9783/// let result = hub.projects().locations_operations_delete("name")
9784/// .doit().await;
9785/// # }
9786/// ```
9787pub struct ProjectLocationOperationDeleteCall<'a, C>
9788where
9789 C: 'a,
9790{
9791 hub: &'a Apigateway<C>,
9792 _name: String,
9793 _delegate: Option<&'a mut dyn common::Delegate>,
9794 _additional_params: HashMap<String, String>,
9795 _scopes: BTreeSet<String>,
9796}
9797
9798impl<'a, C> common::CallBuilder for ProjectLocationOperationDeleteCall<'a, C> {}
9799
9800impl<'a, C> ProjectLocationOperationDeleteCall<'a, C>
9801where
9802 C: common::Connector,
9803{
9804 /// Perform the operation you have build so far.
9805 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
9806 use std::borrow::Cow;
9807 use std::io::{Read, Seek};
9808
9809 use common::{url::Params, ToParts};
9810 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9811
9812 let mut dd = common::DefaultDelegate;
9813 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9814 dlg.begin(common::MethodInfo {
9815 id: "apigateway.projects.locations.operations.delete",
9816 http_method: hyper::Method::DELETE,
9817 });
9818
9819 for &field in ["alt", "name"].iter() {
9820 if self._additional_params.contains_key(field) {
9821 dlg.finished(false);
9822 return Err(common::Error::FieldClash(field));
9823 }
9824 }
9825
9826 let mut params = Params::with_capacity(3 + self._additional_params.len());
9827 params.push("name", self._name);
9828
9829 params.extend(self._additional_params.iter());
9830
9831 params.push("alt", "json");
9832 let mut url = self.hub._base_url.clone() + "v1/{+name}";
9833 if self._scopes.is_empty() {
9834 self._scopes
9835 .insert(Scope::CloudPlatform.as_ref().to_string());
9836 }
9837
9838 #[allow(clippy::single_element_loop)]
9839 for &(find_this, param_name) in [("{+name}", "name")].iter() {
9840 url = params.uri_replacement(url, param_name, find_this, true);
9841 }
9842 {
9843 let to_remove = ["name"];
9844 params.remove_params(&to_remove);
9845 }
9846
9847 let url = params.parse_with_url(&url);
9848
9849 loop {
9850 let token = match self
9851 .hub
9852 .auth
9853 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9854 .await
9855 {
9856 Ok(token) => token,
9857 Err(e) => match dlg.token(e) {
9858 Ok(token) => token,
9859 Err(e) => {
9860 dlg.finished(false);
9861 return Err(common::Error::MissingToken(e));
9862 }
9863 },
9864 };
9865 let mut req_result = {
9866 let client = &self.hub.client;
9867 dlg.pre_request();
9868 let mut req_builder = hyper::Request::builder()
9869 .method(hyper::Method::DELETE)
9870 .uri(url.as_str())
9871 .header(USER_AGENT, self.hub._user_agent.clone());
9872
9873 if let Some(token) = token.as_ref() {
9874 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9875 }
9876
9877 let request = req_builder
9878 .header(CONTENT_LENGTH, 0_u64)
9879 .body(common::to_body::<String>(None));
9880
9881 client.request(request.unwrap()).await
9882 };
9883
9884 match req_result {
9885 Err(err) => {
9886 if let common::Retry::After(d) = dlg.http_error(&err) {
9887 sleep(d).await;
9888 continue;
9889 }
9890 dlg.finished(false);
9891 return Err(common::Error::HttpError(err));
9892 }
9893 Ok(res) => {
9894 let (mut parts, body) = res.into_parts();
9895 let mut body = common::Body::new(body);
9896 if !parts.status.is_success() {
9897 let bytes = common::to_bytes(body).await.unwrap_or_default();
9898 let error = serde_json::from_str(&common::to_string(&bytes));
9899 let response = common::to_response(parts, bytes.into());
9900
9901 if let common::Retry::After(d) =
9902 dlg.http_failure(&response, error.as_ref().ok())
9903 {
9904 sleep(d).await;
9905 continue;
9906 }
9907
9908 dlg.finished(false);
9909
9910 return Err(match error {
9911 Ok(value) => common::Error::BadRequest(value),
9912 _ => common::Error::Failure(response),
9913 });
9914 }
9915 let response = {
9916 let bytes = common::to_bytes(body).await.unwrap_or_default();
9917 let encoded = common::to_string(&bytes);
9918 match serde_json::from_str(&encoded) {
9919 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9920 Err(error) => {
9921 dlg.response_json_decode_error(&encoded, &error);
9922 return Err(common::Error::JsonDecodeError(
9923 encoded.to_string(),
9924 error,
9925 ));
9926 }
9927 }
9928 };
9929
9930 dlg.finished(true);
9931 return Ok(response);
9932 }
9933 }
9934 }
9935 }
9936
9937 /// The name of the operation resource to be deleted.
9938 ///
9939 /// Sets the *name* path property to the given value.
9940 ///
9941 /// Even though the property as already been set when instantiating this call,
9942 /// we provide this method for API completeness.
9943 pub fn name(mut self, new_value: &str) -> ProjectLocationOperationDeleteCall<'a, C> {
9944 self._name = new_value.to_string();
9945 self
9946 }
9947 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9948 /// while executing the actual API request.
9949 ///
9950 /// ````text
9951 /// It should be used to handle progress information, and to implement a certain level of resilience.
9952 /// ````
9953 ///
9954 /// Sets the *delegate* property to the given value.
9955 pub fn delegate(
9956 mut self,
9957 new_value: &'a mut dyn common::Delegate,
9958 ) -> ProjectLocationOperationDeleteCall<'a, C> {
9959 self._delegate = Some(new_value);
9960 self
9961 }
9962
9963 /// Set any additional parameter of the query string used in the request.
9964 /// It should be used to set parameters which are not yet available through their own
9965 /// setters.
9966 ///
9967 /// Please note that this method must not be used to set any of the known parameters
9968 /// which have their own setter method. If done anyway, the request will fail.
9969 ///
9970 /// # Additional Parameters
9971 ///
9972 /// * *$.xgafv* (query-string) - V1 error format.
9973 /// * *access_token* (query-string) - OAuth access token.
9974 /// * *alt* (query-string) - Data format for response.
9975 /// * *callback* (query-string) - JSONP
9976 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9977 /// * *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.
9978 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9979 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9980 /// * *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.
9981 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9982 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9983 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationDeleteCall<'a, C>
9984 where
9985 T: AsRef<str>,
9986 {
9987 self._additional_params
9988 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9989 self
9990 }
9991
9992 /// Identifies the authorization scope for the method you are building.
9993 ///
9994 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9995 /// [`Scope::CloudPlatform`].
9996 ///
9997 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9998 /// tokens for more than one scope.
9999 ///
10000 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10001 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10002 /// sufficient, a read-write scope will do as well.
10003 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationDeleteCall<'a, C>
10004 where
10005 St: AsRef<str>,
10006 {
10007 self._scopes.insert(String::from(scope.as_ref()));
10008 self
10009 }
10010 /// Identifies the authorization scope(s) for the method you are building.
10011 ///
10012 /// See [`Self::add_scope()`] for details.
10013 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationDeleteCall<'a, C>
10014 where
10015 I: IntoIterator<Item = St>,
10016 St: AsRef<str>,
10017 {
10018 self._scopes
10019 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10020 self
10021 }
10022
10023 /// Removes all scopes, and no default scope will be used either.
10024 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10025 /// for details).
10026 pub fn clear_scopes(mut self) -> ProjectLocationOperationDeleteCall<'a, C> {
10027 self._scopes.clear();
10028 self
10029 }
10030}
10031
10032/// 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.
10033///
10034/// A builder for the *locations.operations.get* method supported by a *project* resource.
10035/// It is not used directly, but through a [`ProjectMethods`] instance.
10036///
10037/// # Example
10038///
10039/// Instantiate a resource method builder
10040///
10041/// ```test_harness,no_run
10042/// # extern crate hyper;
10043/// # extern crate hyper_rustls;
10044/// # extern crate google_apigateway1 as apigateway1;
10045/// # async fn dox() {
10046/// # use apigateway1::{Apigateway, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10047///
10048/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10049/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10050/// # .with_native_roots()
10051/// # .unwrap()
10052/// # .https_only()
10053/// # .enable_http2()
10054/// # .build();
10055///
10056/// # let executor = hyper_util::rt::TokioExecutor::new();
10057/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10058/// # secret,
10059/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10060/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10061/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10062/// # ),
10063/// # ).build().await.unwrap();
10064///
10065/// # let client = hyper_util::client::legacy::Client::builder(
10066/// # hyper_util::rt::TokioExecutor::new()
10067/// # )
10068/// # .build(
10069/// # hyper_rustls::HttpsConnectorBuilder::new()
10070/// # .with_native_roots()
10071/// # .unwrap()
10072/// # .https_or_http()
10073/// # .enable_http2()
10074/// # .build()
10075/// # );
10076/// # let mut hub = Apigateway::new(client, auth);
10077/// // You can configure optional parameters by calling the respective setters at will, and
10078/// // execute the final call using `doit()`.
10079/// // Values shown here are possibly random and not representative !
10080/// let result = hub.projects().locations_operations_get("name")
10081/// .doit().await;
10082/// # }
10083/// ```
10084pub struct ProjectLocationOperationGetCall<'a, C>
10085where
10086 C: 'a,
10087{
10088 hub: &'a Apigateway<C>,
10089 _name: String,
10090 _delegate: Option<&'a mut dyn common::Delegate>,
10091 _additional_params: HashMap<String, String>,
10092 _scopes: BTreeSet<String>,
10093}
10094
10095impl<'a, C> common::CallBuilder for ProjectLocationOperationGetCall<'a, C> {}
10096
10097impl<'a, C> ProjectLocationOperationGetCall<'a, C>
10098where
10099 C: common::Connector,
10100{
10101 /// Perform the operation you have build so far.
10102 pub async fn doit(mut self) -> common::Result<(common::Response, ApigatewayOperation)> {
10103 use std::borrow::Cow;
10104 use std::io::{Read, Seek};
10105
10106 use common::{url::Params, ToParts};
10107 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10108
10109 let mut dd = common::DefaultDelegate;
10110 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10111 dlg.begin(common::MethodInfo {
10112 id: "apigateway.projects.locations.operations.get",
10113 http_method: hyper::Method::GET,
10114 });
10115
10116 for &field in ["alt", "name"].iter() {
10117 if self._additional_params.contains_key(field) {
10118 dlg.finished(false);
10119 return Err(common::Error::FieldClash(field));
10120 }
10121 }
10122
10123 let mut params = Params::with_capacity(3 + self._additional_params.len());
10124 params.push("name", self._name);
10125
10126 params.extend(self._additional_params.iter());
10127
10128 params.push("alt", "json");
10129 let mut url = self.hub._base_url.clone() + "v1/{+name}";
10130 if self._scopes.is_empty() {
10131 self._scopes
10132 .insert(Scope::CloudPlatform.as_ref().to_string());
10133 }
10134
10135 #[allow(clippy::single_element_loop)]
10136 for &(find_this, param_name) in [("{+name}", "name")].iter() {
10137 url = params.uri_replacement(url, param_name, find_this, true);
10138 }
10139 {
10140 let to_remove = ["name"];
10141 params.remove_params(&to_remove);
10142 }
10143
10144 let url = params.parse_with_url(&url);
10145
10146 loop {
10147 let token = match self
10148 .hub
10149 .auth
10150 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10151 .await
10152 {
10153 Ok(token) => token,
10154 Err(e) => match dlg.token(e) {
10155 Ok(token) => token,
10156 Err(e) => {
10157 dlg.finished(false);
10158 return Err(common::Error::MissingToken(e));
10159 }
10160 },
10161 };
10162 let mut req_result = {
10163 let client = &self.hub.client;
10164 dlg.pre_request();
10165 let mut req_builder = hyper::Request::builder()
10166 .method(hyper::Method::GET)
10167 .uri(url.as_str())
10168 .header(USER_AGENT, self.hub._user_agent.clone());
10169
10170 if let Some(token) = token.as_ref() {
10171 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10172 }
10173
10174 let request = req_builder
10175 .header(CONTENT_LENGTH, 0_u64)
10176 .body(common::to_body::<String>(None));
10177
10178 client.request(request.unwrap()).await
10179 };
10180
10181 match req_result {
10182 Err(err) => {
10183 if let common::Retry::After(d) = dlg.http_error(&err) {
10184 sleep(d).await;
10185 continue;
10186 }
10187 dlg.finished(false);
10188 return Err(common::Error::HttpError(err));
10189 }
10190 Ok(res) => {
10191 let (mut parts, body) = res.into_parts();
10192 let mut body = common::Body::new(body);
10193 if !parts.status.is_success() {
10194 let bytes = common::to_bytes(body).await.unwrap_or_default();
10195 let error = serde_json::from_str(&common::to_string(&bytes));
10196 let response = common::to_response(parts, bytes.into());
10197
10198 if let common::Retry::After(d) =
10199 dlg.http_failure(&response, error.as_ref().ok())
10200 {
10201 sleep(d).await;
10202 continue;
10203 }
10204
10205 dlg.finished(false);
10206
10207 return Err(match error {
10208 Ok(value) => common::Error::BadRequest(value),
10209 _ => common::Error::Failure(response),
10210 });
10211 }
10212 let response = {
10213 let bytes = common::to_bytes(body).await.unwrap_or_default();
10214 let encoded = common::to_string(&bytes);
10215 match serde_json::from_str(&encoded) {
10216 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10217 Err(error) => {
10218 dlg.response_json_decode_error(&encoded, &error);
10219 return Err(common::Error::JsonDecodeError(
10220 encoded.to_string(),
10221 error,
10222 ));
10223 }
10224 }
10225 };
10226
10227 dlg.finished(true);
10228 return Ok(response);
10229 }
10230 }
10231 }
10232 }
10233
10234 /// The name of the operation resource.
10235 ///
10236 /// Sets the *name* path property to the given value.
10237 ///
10238 /// Even though the property as already been set when instantiating this call,
10239 /// we provide this method for API completeness.
10240 pub fn name(mut self, new_value: &str) -> ProjectLocationOperationGetCall<'a, C> {
10241 self._name = new_value.to_string();
10242 self
10243 }
10244 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10245 /// while executing the actual API request.
10246 ///
10247 /// ````text
10248 /// It should be used to handle progress information, and to implement a certain level of resilience.
10249 /// ````
10250 ///
10251 /// Sets the *delegate* property to the given value.
10252 pub fn delegate(
10253 mut self,
10254 new_value: &'a mut dyn common::Delegate,
10255 ) -> ProjectLocationOperationGetCall<'a, C> {
10256 self._delegate = Some(new_value);
10257 self
10258 }
10259
10260 /// Set any additional parameter of the query string used in the request.
10261 /// It should be used to set parameters which are not yet available through their own
10262 /// setters.
10263 ///
10264 /// Please note that this method must not be used to set any of the known parameters
10265 /// which have their own setter method. If done anyway, the request will fail.
10266 ///
10267 /// # Additional Parameters
10268 ///
10269 /// * *$.xgafv* (query-string) - V1 error format.
10270 /// * *access_token* (query-string) - OAuth access token.
10271 /// * *alt* (query-string) - Data format for response.
10272 /// * *callback* (query-string) - JSONP
10273 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10274 /// * *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.
10275 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10276 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10277 /// * *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.
10278 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10279 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10280 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationGetCall<'a, C>
10281 where
10282 T: AsRef<str>,
10283 {
10284 self._additional_params
10285 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10286 self
10287 }
10288
10289 /// Identifies the authorization scope for the method you are building.
10290 ///
10291 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10292 /// [`Scope::CloudPlatform`].
10293 ///
10294 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10295 /// tokens for more than one scope.
10296 ///
10297 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10298 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10299 /// sufficient, a read-write scope will do as well.
10300 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationGetCall<'a, C>
10301 where
10302 St: AsRef<str>,
10303 {
10304 self._scopes.insert(String::from(scope.as_ref()));
10305 self
10306 }
10307 /// Identifies the authorization scope(s) for the method you are building.
10308 ///
10309 /// See [`Self::add_scope()`] for details.
10310 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationGetCall<'a, C>
10311 where
10312 I: IntoIterator<Item = St>,
10313 St: AsRef<str>,
10314 {
10315 self._scopes
10316 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10317 self
10318 }
10319
10320 /// Removes all scopes, and no default scope will be used either.
10321 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10322 /// for details).
10323 pub fn clear_scopes(mut self) -> ProjectLocationOperationGetCall<'a, C> {
10324 self._scopes.clear();
10325 self
10326 }
10327}
10328
10329/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
10330///
10331/// A builder for the *locations.operations.list* method supported by a *project* resource.
10332/// It is not used directly, but through a [`ProjectMethods`] instance.
10333///
10334/// # Example
10335///
10336/// Instantiate a resource method builder
10337///
10338/// ```test_harness,no_run
10339/// # extern crate hyper;
10340/// # extern crate hyper_rustls;
10341/// # extern crate google_apigateway1 as apigateway1;
10342/// # async fn dox() {
10343/// # use apigateway1::{Apigateway, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10344///
10345/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10346/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10347/// # .with_native_roots()
10348/// # .unwrap()
10349/// # .https_only()
10350/// # .enable_http2()
10351/// # .build();
10352///
10353/// # let executor = hyper_util::rt::TokioExecutor::new();
10354/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10355/// # secret,
10356/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10357/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10358/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10359/// # ),
10360/// # ).build().await.unwrap();
10361///
10362/// # let client = hyper_util::client::legacy::Client::builder(
10363/// # hyper_util::rt::TokioExecutor::new()
10364/// # )
10365/// # .build(
10366/// # hyper_rustls::HttpsConnectorBuilder::new()
10367/// # .with_native_roots()
10368/// # .unwrap()
10369/// # .https_or_http()
10370/// # .enable_http2()
10371/// # .build()
10372/// # );
10373/// # let mut hub = Apigateway::new(client, auth);
10374/// // You can configure optional parameters by calling the respective setters at will, and
10375/// // execute the final call using `doit()`.
10376/// // Values shown here are possibly random and not representative !
10377/// let result = hub.projects().locations_operations_list("name")
10378/// .return_partial_success(false)
10379/// .page_token("diam")
10380/// .page_size(-49)
10381/// .filter("et")
10382/// .doit().await;
10383/// # }
10384/// ```
10385pub struct ProjectLocationOperationListCall<'a, C>
10386where
10387 C: 'a,
10388{
10389 hub: &'a Apigateway<C>,
10390 _name: String,
10391 _return_partial_success: Option<bool>,
10392 _page_token: Option<String>,
10393 _page_size: Option<i32>,
10394 _filter: Option<String>,
10395 _delegate: Option<&'a mut dyn common::Delegate>,
10396 _additional_params: HashMap<String, String>,
10397 _scopes: BTreeSet<String>,
10398}
10399
10400impl<'a, C> common::CallBuilder for ProjectLocationOperationListCall<'a, C> {}
10401
10402impl<'a, C> ProjectLocationOperationListCall<'a, C>
10403where
10404 C: common::Connector,
10405{
10406 /// Perform the operation you have build so far.
10407 pub async fn doit(
10408 mut self,
10409 ) -> common::Result<(common::Response, ApigatewayListOperationsResponse)> {
10410 use std::borrow::Cow;
10411 use std::io::{Read, Seek};
10412
10413 use common::{url::Params, ToParts};
10414 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10415
10416 let mut dd = common::DefaultDelegate;
10417 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10418 dlg.begin(common::MethodInfo {
10419 id: "apigateway.projects.locations.operations.list",
10420 http_method: hyper::Method::GET,
10421 });
10422
10423 for &field in [
10424 "alt",
10425 "name",
10426 "returnPartialSuccess",
10427 "pageToken",
10428 "pageSize",
10429 "filter",
10430 ]
10431 .iter()
10432 {
10433 if self._additional_params.contains_key(field) {
10434 dlg.finished(false);
10435 return Err(common::Error::FieldClash(field));
10436 }
10437 }
10438
10439 let mut params = Params::with_capacity(7 + self._additional_params.len());
10440 params.push("name", self._name);
10441 if let Some(value) = self._return_partial_success.as_ref() {
10442 params.push("returnPartialSuccess", value.to_string());
10443 }
10444 if let Some(value) = self._page_token.as_ref() {
10445 params.push("pageToken", value);
10446 }
10447 if let Some(value) = self._page_size.as_ref() {
10448 params.push("pageSize", value.to_string());
10449 }
10450 if let Some(value) = self._filter.as_ref() {
10451 params.push("filter", value);
10452 }
10453
10454 params.extend(self._additional_params.iter());
10455
10456 params.push("alt", "json");
10457 let mut url = self.hub._base_url.clone() + "v1/{+name}/operations";
10458 if self._scopes.is_empty() {
10459 self._scopes
10460 .insert(Scope::CloudPlatform.as_ref().to_string());
10461 }
10462
10463 #[allow(clippy::single_element_loop)]
10464 for &(find_this, param_name) in [("{+name}", "name")].iter() {
10465 url = params.uri_replacement(url, param_name, find_this, true);
10466 }
10467 {
10468 let to_remove = ["name"];
10469 params.remove_params(&to_remove);
10470 }
10471
10472 let url = params.parse_with_url(&url);
10473
10474 loop {
10475 let token = match self
10476 .hub
10477 .auth
10478 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10479 .await
10480 {
10481 Ok(token) => token,
10482 Err(e) => match dlg.token(e) {
10483 Ok(token) => token,
10484 Err(e) => {
10485 dlg.finished(false);
10486 return Err(common::Error::MissingToken(e));
10487 }
10488 },
10489 };
10490 let mut req_result = {
10491 let client = &self.hub.client;
10492 dlg.pre_request();
10493 let mut req_builder = hyper::Request::builder()
10494 .method(hyper::Method::GET)
10495 .uri(url.as_str())
10496 .header(USER_AGENT, self.hub._user_agent.clone());
10497
10498 if let Some(token) = token.as_ref() {
10499 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10500 }
10501
10502 let request = req_builder
10503 .header(CONTENT_LENGTH, 0_u64)
10504 .body(common::to_body::<String>(None));
10505
10506 client.request(request.unwrap()).await
10507 };
10508
10509 match req_result {
10510 Err(err) => {
10511 if let common::Retry::After(d) = dlg.http_error(&err) {
10512 sleep(d).await;
10513 continue;
10514 }
10515 dlg.finished(false);
10516 return Err(common::Error::HttpError(err));
10517 }
10518 Ok(res) => {
10519 let (mut parts, body) = res.into_parts();
10520 let mut body = common::Body::new(body);
10521 if !parts.status.is_success() {
10522 let bytes = common::to_bytes(body).await.unwrap_or_default();
10523 let error = serde_json::from_str(&common::to_string(&bytes));
10524 let response = common::to_response(parts, bytes.into());
10525
10526 if let common::Retry::After(d) =
10527 dlg.http_failure(&response, error.as_ref().ok())
10528 {
10529 sleep(d).await;
10530 continue;
10531 }
10532
10533 dlg.finished(false);
10534
10535 return Err(match error {
10536 Ok(value) => common::Error::BadRequest(value),
10537 _ => common::Error::Failure(response),
10538 });
10539 }
10540 let response = {
10541 let bytes = common::to_bytes(body).await.unwrap_or_default();
10542 let encoded = common::to_string(&bytes);
10543 match serde_json::from_str(&encoded) {
10544 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10545 Err(error) => {
10546 dlg.response_json_decode_error(&encoded, &error);
10547 return Err(common::Error::JsonDecodeError(
10548 encoded.to_string(),
10549 error,
10550 ));
10551 }
10552 }
10553 };
10554
10555 dlg.finished(true);
10556 return Ok(response);
10557 }
10558 }
10559 }
10560 }
10561
10562 /// The name of the operation's parent resource.
10563 ///
10564 /// Sets the *name* path property to the given value.
10565 ///
10566 /// Even though the property as already been set when instantiating this call,
10567 /// we provide this method for API completeness.
10568 pub fn name(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
10569 self._name = new_value.to_string();
10570 self
10571 }
10572 /// 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.
10573 ///
10574 /// Sets the *return partial success* query property to the given value.
10575 pub fn return_partial_success(
10576 mut self,
10577 new_value: bool,
10578 ) -> ProjectLocationOperationListCall<'a, C> {
10579 self._return_partial_success = Some(new_value);
10580 self
10581 }
10582 /// The standard list page token.
10583 ///
10584 /// Sets the *page token* query property to the given value.
10585 pub fn page_token(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
10586 self._page_token = Some(new_value.to_string());
10587 self
10588 }
10589 /// The standard list page size.
10590 ///
10591 /// Sets the *page size* query property to the given value.
10592 pub fn page_size(mut self, new_value: i32) -> ProjectLocationOperationListCall<'a, C> {
10593 self._page_size = Some(new_value);
10594 self
10595 }
10596 /// The standard list filter.
10597 ///
10598 /// Sets the *filter* query property to the given value.
10599 pub fn filter(mut self, new_value: &str) -> ProjectLocationOperationListCall<'a, C> {
10600 self._filter = Some(new_value.to_string());
10601 self
10602 }
10603 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10604 /// while executing the actual API request.
10605 ///
10606 /// ````text
10607 /// It should be used to handle progress information, and to implement a certain level of resilience.
10608 /// ````
10609 ///
10610 /// Sets the *delegate* property to the given value.
10611 pub fn delegate(
10612 mut self,
10613 new_value: &'a mut dyn common::Delegate,
10614 ) -> ProjectLocationOperationListCall<'a, C> {
10615 self._delegate = Some(new_value);
10616 self
10617 }
10618
10619 /// Set any additional parameter of the query string used in the request.
10620 /// It should be used to set parameters which are not yet available through their own
10621 /// setters.
10622 ///
10623 /// Please note that this method must not be used to set any of the known parameters
10624 /// which have their own setter method. If done anyway, the request will fail.
10625 ///
10626 /// # Additional Parameters
10627 ///
10628 /// * *$.xgafv* (query-string) - V1 error format.
10629 /// * *access_token* (query-string) - OAuth access token.
10630 /// * *alt* (query-string) - Data format for response.
10631 /// * *callback* (query-string) - JSONP
10632 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10633 /// * *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.
10634 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10635 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10636 /// * *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.
10637 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10638 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10639 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationListCall<'a, C>
10640 where
10641 T: AsRef<str>,
10642 {
10643 self._additional_params
10644 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10645 self
10646 }
10647
10648 /// Identifies the authorization scope for the method you are building.
10649 ///
10650 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10651 /// [`Scope::CloudPlatform`].
10652 ///
10653 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10654 /// tokens for more than one scope.
10655 ///
10656 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10657 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10658 /// sufficient, a read-write scope will do as well.
10659 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationListCall<'a, C>
10660 where
10661 St: AsRef<str>,
10662 {
10663 self._scopes.insert(String::from(scope.as_ref()));
10664 self
10665 }
10666 /// Identifies the authorization scope(s) for the method you are building.
10667 ///
10668 /// See [`Self::add_scope()`] for details.
10669 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationListCall<'a, C>
10670 where
10671 I: IntoIterator<Item = St>,
10672 St: AsRef<str>,
10673 {
10674 self._scopes
10675 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10676 self
10677 }
10678
10679 /// Removes all scopes, and no default scope will be used either.
10680 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10681 /// for details).
10682 pub fn clear_scopes(mut self) -> ProjectLocationOperationListCall<'a, C> {
10683 self._scopes.clear();
10684 self
10685 }
10686}
10687
10688/// Gets information about a location.
10689///
10690/// A builder for the *locations.get* method supported by a *project* resource.
10691/// It is not used directly, but through a [`ProjectMethods`] instance.
10692///
10693/// # Example
10694///
10695/// Instantiate a resource method builder
10696///
10697/// ```test_harness,no_run
10698/// # extern crate hyper;
10699/// # extern crate hyper_rustls;
10700/// # extern crate google_apigateway1 as apigateway1;
10701/// # async fn dox() {
10702/// # use apigateway1::{Apigateway, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10703///
10704/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10705/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10706/// # .with_native_roots()
10707/// # .unwrap()
10708/// # .https_only()
10709/// # .enable_http2()
10710/// # .build();
10711///
10712/// # let executor = hyper_util::rt::TokioExecutor::new();
10713/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10714/// # secret,
10715/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10716/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10717/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10718/// # ),
10719/// # ).build().await.unwrap();
10720///
10721/// # let client = hyper_util::client::legacy::Client::builder(
10722/// # hyper_util::rt::TokioExecutor::new()
10723/// # )
10724/// # .build(
10725/// # hyper_rustls::HttpsConnectorBuilder::new()
10726/// # .with_native_roots()
10727/// # .unwrap()
10728/// # .https_or_http()
10729/// # .enable_http2()
10730/// # .build()
10731/// # );
10732/// # let mut hub = Apigateway::new(client, auth);
10733/// // You can configure optional parameters by calling the respective setters at will, and
10734/// // execute the final call using `doit()`.
10735/// // Values shown here are possibly random and not representative !
10736/// let result = hub.projects().locations_get("name")
10737/// .doit().await;
10738/// # }
10739/// ```
10740pub struct ProjectLocationGetCall<'a, C>
10741where
10742 C: 'a,
10743{
10744 hub: &'a Apigateway<C>,
10745 _name: String,
10746 _delegate: Option<&'a mut dyn common::Delegate>,
10747 _additional_params: HashMap<String, String>,
10748 _scopes: BTreeSet<String>,
10749}
10750
10751impl<'a, C> common::CallBuilder for ProjectLocationGetCall<'a, C> {}
10752
10753impl<'a, C> ProjectLocationGetCall<'a, C>
10754where
10755 C: common::Connector,
10756{
10757 /// Perform the operation you have build so far.
10758 pub async fn doit(mut self) -> common::Result<(common::Response, ApigatewayLocation)> {
10759 use std::borrow::Cow;
10760 use std::io::{Read, Seek};
10761
10762 use common::{url::Params, ToParts};
10763 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10764
10765 let mut dd = common::DefaultDelegate;
10766 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10767 dlg.begin(common::MethodInfo {
10768 id: "apigateway.projects.locations.get",
10769 http_method: hyper::Method::GET,
10770 });
10771
10772 for &field in ["alt", "name"].iter() {
10773 if self._additional_params.contains_key(field) {
10774 dlg.finished(false);
10775 return Err(common::Error::FieldClash(field));
10776 }
10777 }
10778
10779 let mut params = Params::with_capacity(3 + self._additional_params.len());
10780 params.push("name", self._name);
10781
10782 params.extend(self._additional_params.iter());
10783
10784 params.push("alt", "json");
10785 let mut url = self.hub._base_url.clone() + "v1/{+name}";
10786 if self._scopes.is_empty() {
10787 self._scopes
10788 .insert(Scope::CloudPlatform.as_ref().to_string());
10789 }
10790
10791 #[allow(clippy::single_element_loop)]
10792 for &(find_this, param_name) in [("{+name}", "name")].iter() {
10793 url = params.uri_replacement(url, param_name, find_this, true);
10794 }
10795 {
10796 let to_remove = ["name"];
10797 params.remove_params(&to_remove);
10798 }
10799
10800 let url = params.parse_with_url(&url);
10801
10802 loop {
10803 let token = match self
10804 .hub
10805 .auth
10806 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10807 .await
10808 {
10809 Ok(token) => token,
10810 Err(e) => match dlg.token(e) {
10811 Ok(token) => token,
10812 Err(e) => {
10813 dlg.finished(false);
10814 return Err(common::Error::MissingToken(e));
10815 }
10816 },
10817 };
10818 let mut req_result = {
10819 let client = &self.hub.client;
10820 dlg.pre_request();
10821 let mut req_builder = hyper::Request::builder()
10822 .method(hyper::Method::GET)
10823 .uri(url.as_str())
10824 .header(USER_AGENT, self.hub._user_agent.clone());
10825
10826 if let Some(token) = token.as_ref() {
10827 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10828 }
10829
10830 let request = req_builder
10831 .header(CONTENT_LENGTH, 0_u64)
10832 .body(common::to_body::<String>(None));
10833
10834 client.request(request.unwrap()).await
10835 };
10836
10837 match req_result {
10838 Err(err) => {
10839 if let common::Retry::After(d) = dlg.http_error(&err) {
10840 sleep(d).await;
10841 continue;
10842 }
10843 dlg.finished(false);
10844 return Err(common::Error::HttpError(err));
10845 }
10846 Ok(res) => {
10847 let (mut parts, body) = res.into_parts();
10848 let mut body = common::Body::new(body);
10849 if !parts.status.is_success() {
10850 let bytes = common::to_bytes(body).await.unwrap_or_default();
10851 let error = serde_json::from_str(&common::to_string(&bytes));
10852 let response = common::to_response(parts, bytes.into());
10853
10854 if let common::Retry::After(d) =
10855 dlg.http_failure(&response, error.as_ref().ok())
10856 {
10857 sleep(d).await;
10858 continue;
10859 }
10860
10861 dlg.finished(false);
10862
10863 return Err(match error {
10864 Ok(value) => common::Error::BadRequest(value),
10865 _ => common::Error::Failure(response),
10866 });
10867 }
10868 let response = {
10869 let bytes = common::to_bytes(body).await.unwrap_or_default();
10870 let encoded = common::to_string(&bytes);
10871 match serde_json::from_str(&encoded) {
10872 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10873 Err(error) => {
10874 dlg.response_json_decode_error(&encoded, &error);
10875 return Err(common::Error::JsonDecodeError(
10876 encoded.to_string(),
10877 error,
10878 ));
10879 }
10880 }
10881 };
10882
10883 dlg.finished(true);
10884 return Ok(response);
10885 }
10886 }
10887 }
10888 }
10889
10890 /// Resource name for the location.
10891 ///
10892 /// Sets the *name* path property to the given value.
10893 ///
10894 /// Even though the property as already been set when instantiating this call,
10895 /// we provide this method for API completeness.
10896 pub fn name(mut self, new_value: &str) -> ProjectLocationGetCall<'a, C> {
10897 self._name = new_value.to_string();
10898 self
10899 }
10900 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10901 /// while executing the actual API request.
10902 ///
10903 /// ````text
10904 /// It should be used to handle progress information, and to implement a certain level of resilience.
10905 /// ````
10906 ///
10907 /// Sets the *delegate* property to the given value.
10908 pub fn delegate(
10909 mut self,
10910 new_value: &'a mut dyn common::Delegate,
10911 ) -> ProjectLocationGetCall<'a, C> {
10912 self._delegate = Some(new_value);
10913 self
10914 }
10915
10916 /// Set any additional parameter of the query string used in the request.
10917 /// It should be used to set parameters which are not yet available through their own
10918 /// setters.
10919 ///
10920 /// Please note that this method must not be used to set any of the known parameters
10921 /// which have their own setter method. If done anyway, the request will fail.
10922 ///
10923 /// # Additional Parameters
10924 ///
10925 /// * *$.xgafv* (query-string) - V1 error format.
10926 /// * *access_token* (query-string) - OAuth access token.
10927 /// * *alt* (query-string) - Data format for response.
10928 /// * *callback* (query-string) - JSONP
10929 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10930 /// * *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.
10931 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10932 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10933 /// * *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.
10934 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10935 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10936 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGetCall<'a, C>
10937 where
10938 T: AsRef<str>,
10939 {
10940 self._additional_params
10941 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10942 self
10943 }
10944
10945 /// Identifies the authorization scope for the method you are building.
10946 ///
10947 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10948 /// [`Scope::CloudPlatform`].
10949 ///
10950 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10951 /// tokens for more than one scope.
10952 ///
10953 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10954 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10955 /// sufficient, a read-write scope will do as well.
10956 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGetCall<'a, C>
10957 where
10958 St: AsRef<str>,
10959 {
10960 self._scopes.insert(String::from(scope.as_ref()));
10961 self
10962 }
10963 /// Identifies the authorization scope(s) for the method you are building.
10964 ///
10965 /// See [`Self::add_scope()`] for details.
10966 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGetCall<'a, C>
10967 where
10968 I: IntoIterator<Item = St>,
10969 St: AsRef<str>,
10970 {
10971 self._scopes
10972 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10973 self
10974 }
10975
10976 /// Removes all scopes, and no default scope will be used either.
10977 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10978 /// for details).
10979 pub fn clear_scopes(mut self) -> ProjectLocationGetCall<'a, C> {
10980 self._scopes.clear();
10981 self
10982 }
10983}
10984
10985/// Lists information about the supported locations for this service.
10986///
10987/// A builder for the *locations.list* method supported by a *project* resource.
10988/// It is not used directly, but through a [`ProjectMethods`] instance.
10989///
10990/// # Example
10991///
10992/// Instantiate a resource method builder
10993///
10994/// ```test_harness,no_run
10995/// # extern crate hyper;
10996/// # extern crate hyper_rustls;
10997/// # extern crate google_apigateway1 as apigateway1;
10998/// # async fn dox() {
10999/// # use apigateway1::{Apigateway, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11000///
11001/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11002/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11003/// # .with_native_roots()
11004/// # .unwrap()
11005/// # .https_only()
11006/// # .enable_http2()
11007/// # .build();
11008///
11009/// # let executor = hyper_util::rt::TokioExecutor::new();
11010/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11011/// # secret,
11012/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11013/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11014/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11015/// # ),
11016/// # ).build().await.unwrap();
11017///
11018/// # let client = hyper_util::client::legacy::Client::builder(
11019/// # hyper_util::rt::TokioExecutor::new()
11020/// # )
11021/// # .build(
11022/// # hyper_rustls::HttpsConnectorBuilder::new()
11023/// # .with_native_roots()
11024/// # .unwrap()
11025/// # .https_or_http()
11026/// # .enable_http2()
11027/// # .build()
11028/// # );
11029/// # let mut hub = Apigateway::new(client, auth);
11030/// // You can configure optional parameters by calling the respective setters at will, and
11031/// // execute the final call using `doit()`.
11032/// // Values shown here are possibly random and not representative !
11033/// let result = hub.projects().locations_list("name")
11034/// .page_token("Stet")
11035/// .page_size(-99)
11036/// .filter("duo")
11037/// .add_extra_location_types("vero")
11038/// .doit().await;
11039/// # }
11040/// ```
11041pub struct ProjectLocationListCall<'a, C>
11042where
11043 C: 'a,
11044{
11045 hub: &'a Apigateway<C>,
11046 _name: String,
11047 _page_token: Option<String>,
11048 _page_size: Option<i32>,
11049 _filter: Option<String>,
11050 _extra_location_types: Vec<String>,
11051 _delegate: Option<&'a mut dyn common::Delegate>,
11052 _additional_params: HashMap<String, String>,
11053 _scopes: BTreeSet<String>,
11054}
11055
11056impl<'a, C> common::CallBuilder for ProjectLocationListCall<'a, C> {}
11057
11058impl<'a, C> ProjectLocationListCall<'a, C>
11059where
11060 C: common::Connector,
11061{
11062 /// Perform the operation you have build so far.
11063 pub async fn doit(
11064 mut self,
11065 ) -> common::Result<(common::Response, ApigatewayListLocationsResponse)> {
11066 use std::borrow::Cow;
11067 use std::io::{Read, Seek};
11068
11069 use common::{url::Params, ToParts};
11070 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11071
11072 let mut dd = common::DefaultDelegate;
11073 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11074 dlg.begin(common::MethodInfo {
11075 id: "apigateway.projects.locations.list",
11076 http_method: hyper::Method::GET,
11077 });
11078
11079 for &field in [
11080 "alt",
11081 "name",
11082 "pageToken",
11083 "pageSize",
11084 "filter",
11085 "extraLocationTypes",
11086 ]
11087 .iter()
11088 {
11089 if self._additional_params.contains_key(field) {
11090 dlg.finished(false);
11091 return Err(common::Error::FieldClash(field));
11092 }
11093 }
11094
11095 let mut params = Params::with_capacity(7 + self._additional_params.len());
11096 params.push("name", self._name);
11097 if let Some(value) = self._page_token.as_ref() {
11098 params.push("pageToken", value);
11099 }
11100 if let Some(value) = self._page_size.as_ref() {
11101 params.push("pageSize", value.to_string());
11102 }
11103 if let Some(value) = self._filter.as_ref() {
11104 params.push("filter", value);
11105 }
11106 if !self._extra_location_types.is_empty() {
11107 for f in self._extra_location_types.iter() {
11108 params.push("extraLocationTypes", f);
11109 }
11110 }
11111
11112 params.extend(self._additional_params.iter());
11113
11114 params.push("alt", "json");
11115 let mut url = self.hub._base_url.clone() + "v1/{+name}/locations";
11116 if self._scopes.is_empty() {
11117 self._scopes
11118 .insert(Scope::CloudPlatform.as_ref().to_string());
11119 }
11120
11121 #[allow(clippy::single_element_loop)]
11122 for &(find_this, param_name) in [("{+name}", "name")].iter() {
11123 url = params.uri_replacement(url, param_name, find_this, true);
11124 }
11125 {
11126 let to_remove = ["name"];
11127 params.remove_params(&to_remove);
11128 }
11129
11130 let url = params.parse_with_url(&url);
11131
11132 loop {
11133 let token = match self
11134 .hub
11135 .auth
11136 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11137 .await
11138 {
11139 Ok(token) => token,
11140 Err(e) => match dlg.token(e) {
11141 Ok(token) => token,
11142 Err(e) => {
11143 dlg.finished(false);
11144 return Err(common::Error::MissingToken(e));
11145 }
11146 },
11147 };
11148 let mut req_result = {
11149 let client = &self.hub.client;
11150 dlg.pre_request();
11151 let mut req_builder = hyper::Request::builder()
11152 .method(hyper::Method::GET)
11153 .uri(url.as_str())
11154 .header(USER_AGENT, self.hub._user_agent.clone());
11155
11156 if let Some(token) = token.as_ref() {
11157 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11158 }
11159
11160 let request = req_builder
11161 .header(CONTENT_LENGTH, 0_u64)
11162 .body(common::to_body::<String>(None));
11163
11164 client.request(request.unwrap()).await
11165 };
11166
11167 match req_result {
11168 Err(err) => {
11169 if let common::Retry::After(d) = dlg.http_error(&err) {
11170 sleep(d).await;
11171 continue;
11172 }
11173 dlg.finished(false);
11174 return Err(common::Error::HttpError(err));
11175 }
11176 Ok(res) => {
11177 let (mut parts, body) = res.into_parts();
11178 let mut body = common::Body::new(body);
11179 if !parts.status.is_success() {
11180 let bytes = common::to_bytes(body).await.unwrap_or_default();
11181 let error = serde_json::from_str(&common::to_string(&bytes));
11182 let response = common::to_response(parts, bytes.into());
11183
11184 if let common::Retry::After(d) =
11185 dlg.http_failure(&response, error.as_ref().ok())
11186 {
11187 sleep(d).await;
11188 continue;
11189 }
11190
11191 dlg.finished(false);
11192
11193 return Err(match error {
11194 Ok(value) => common::Error::BadRequest(value),
11195 _ => common::Error::Failure(response),
11196 });
11197 }
11198 let response = {
11199 let bytes = common::to_bytes(body).await.unwrap_or_default();
11200 let encoded = common::to_string(&bytes);
11201 match serde_json::from_str(&encoded) {
11202 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11203 Err(error) => {
11204 dlg.response_json_decode_error(&encoded, &error);
11205 return Err(common::Error::JsonDecodeError(
11206 encoded.to_string(),
11207 error,
11208 ));
11209 }
11210 }
11211 };
11212
11213 dlg.finished(true);
11214 return Ok(response);
11215 }
11216 }
11217 }
11218 }
11219
11220 /// The resource that owns the locations collection, if applicable.
11221 ///
11222 /// Sets the *name* path property to the given value.
11223 ///
11224 /// Even though the property as already been set when instantiating this call,
11225 /// we provide this method for API completeness.
11226 pub fn name(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
11227 self._name = new_value.to_string();
11228 self
11229 }
11230 /// A page token received from the `next_page_token` field in the response. Send that page token to receive the subsequent page.
11231 ///
11232 /// Sets the *page token* query property to the given value.
11233 pub fn page_token(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
11234 self._page_token = Some(new_value.to_string());
11235 self
11236 }
11237 /// The maximum number of results to return. If not set, the service selects a default.
11238 ///
11239 /// Sets the *page size* query property to the given value.
11240 pub fn page_size(mut self, new_value: i32) -> ProjectLocationListCall<'a, C> {
11241 self._page_size = Some(new_value);
11242 self
11243 }
11244 /// 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).
11245 ///
11246 /// Sets the *filter* query property to the given value.
11247 pub fn filter(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
11248 self._filter = Some(new_value.to_string());
11249 self
11250 }
11251 /// Optional. Do not use this field. It is unsupported and is ignored unless explicitly documented otherwise. This is primarily for internal usage.
11252 ///
11253 /// Append the given value to the *extra location types* query property.
11254 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
11255 pub fn add_extra_location_types(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
11256 self._extra_location_types.push(new_value.to_string());
11257 self
11258 }
11259 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11260 /// while executing the actual API request.
11261 ///
11262 /// ````text
11263 /// It should be used to handle progress information, and to implement a certain level of resilience.
11264 /// ````
11265 ///
11266 /// Sets the *delegate* property to the given value.
11267 pub fn delegate(
11268 mut self,
11269 new_value: &'a mut dyn common::Delegate,
11270 ) -> ProjectLocationListCall<'a, C> {
11271 self._delegate = Some(new_value);
11272 self
11273 }
11274
11275 /// Set any additional parameter of the query string used in the request.
11276 /// It should be used to set parameters which are not yet available through their own
11277 /// setters.
11278 ///
11279 /// Please note that this method must not be used to set any of the known parameters
11280 /// which have their own setter method. If done anyway, the request will fail.
11281 ///
11282 /// # Additional Parameters
11283 ///
11284 /// * *$.xgafv* (query-string) - V1 error format.
11285 /// * *access_token* (query-string) - OAuth access token.
11286 /// * *alt* (query-string) - Data format for response.
11287 /// * *callback* (query-string) - JSONP
11288 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11289 /// * *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.
11290 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11291 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11292 /// * *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.
11293 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11294 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11295 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationListCall<'a, C>
11296 where
11297 T: AsRef<str>,
11298 {
11299 self._additional_params
11300 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11301 self
11302 }
11303
11304 /// Identifies the authorization scope for the method you are building.
11305 ///
11306 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11307 /// [`Scope::CloudPlatform`].
11308 ///
11309 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11310 /// tokens for more than one scope.
11311 ///
11312 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11313 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11314 /// sufficient, a read-write scope will do as well.
11315 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationListCall<'a, C>
11316 where
11317 St: AsRef<str>,
11318 {
11319 self._scopes.insert(String::from(scope.as_ref()));
11320 self
11321 }
11322 /// Identifies the authorization scope(s) for the method you are building.
11323 ///
11324 /// See [`Self::add_scope()`] for details.
11325 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationListCall<'a, C>
11326 where
11327 I: IntoIterator<Item = St>,
11328 St: AsRef<str>,
11329 {
11330 self._scopes
11331 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11332 self
11333 }
11334
11335 /// Removes all scopes, and no default scope will be used either.
11336 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11337 /// for details).
11338 pub fn clear_scopes(mut self) -> ProjectLocationListCall<'a, C> {
11339 self._scopes.clear();
11340 self
11341 }
11342}