google_cloudfunctions1/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 CloudFunctions 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_cloudfunctions1 as cloudfunctions1;
49/// use cloudfunctions1::{Result, Error};
50/// # async fn dox() {
51/// use cloudfunctions1::{CloudFunctions, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
52///
53/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
54/// // `client_secret`, among other things.
55/// let secret: yup_oauth2::ApplicationSecret = Default::default();
56/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
57/// // unless you replace `None` with the desired Flow.
58/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
59/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
60/// // retrieve them from storage.
61/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
62/// .with_native_roots()
63/// .unwrap()
64/// .https_only()
65/// .enable_http2()
66/// .build();
67///
68/// let executor = hyper_util::rt::TokioExecutor::new();
69/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
70/// secret,
71/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
72/// yup_oauth2::client::CustomHyperClientBuilder::from(
73/// hyper_util::client::legacy::Client::builder(executor).build(connector),
74/// ),
75/// ).build().await.unwrap();
76///
77/// let client = hyper_util::client::legacy::Client::builder(
78/// hyper_util::rt::TokioExecutor::new()
79/// )
80/// .build(
81/// hyper_rustls::HttpsConnectorBuilder::new()
82/// .with_native_roots()
83/// .unwrap()
84/// .https_or_http()
85/// .enable_http2()
86/// .build()
87/// );
88/// let mut hub = CloudFunctions::new(client, auth);
89/// // You can configure optional parameters by calling the respective setters at will, and
90/// // execute the final call using `doit()`.
91/// // Values shown here are possibly random and not representative !
92/// let result = hub.operations().list()
93/// .return_partial_success(true)
94/// .page_token("gubergren")
95/// .page_size(-75)
96/// .name("dolor")
97/// .filter("ea")
98/// .doit().await;
99///
100/// match result {
101/// Err(e) => match e {
102/// // The Error enum provides details about what exactly happened.
103/// // You can also just use its `Debug`, `Display` or `Error` traits
104/// Error::HttpError(_)
105/// |Error::Io(_)
106/// |Error::MissingAPIKey
107/// |Error::MissingToken(_)
108/// |Error::Cancelled
109/// |Error::UploadSizeLimitExceeded(_, _)
110/// |Error::Failure(_)
111/// |Error::BadRequest(_)
112/// |Error::FieldClash(_)
113/// |Error::JsonDecodeError(_, _) => println!("{}", e),
114/// },
115/// Ok(res) => println!("Success: {:?}", res),
116/// }
117/// # }
118/// ```
119#[derive(Clone)]
120pub struct CloudFunctions<C> {
121 pub client: common::Client<C>,
122 pub auth: Box<dyn common::GetToken>,
123 _user_agent: String,
124 _base_url: String,
125 _root_url: String,
126}
127
128impl<C> common::Hub for CloudFunctions<C> {}
129
130impl<'a, C> CloudFunctions<C> {
131 pub fn new<A: 'static + common::GetToken>(
132 client: common::Client<C>,
133 auth: A,
134 ) -> CloudFunctions<C> {
135 CloudFunctions {
136 client,
137 auth: Box::new(auth),
138 _user_agent: "google-api-rust-client/7.0.0".to_string(),
139 _base_url: "https://cloudfunctions.googleapis.com/".to_string(),
140 _root_url: "https://cloudfunctions.googleapis.com/".to_string(),
141 }
142 }
143
144 pub fn operations(&'a self) -> OperationMethods<'a, C> {
145 OperationMethods { hub: self }
146 }
147 pub fn projects(&'a self) -> ProjectMethods<'a, C> {
148 ProjectMethods { hub: self }
149 }
150
151 /// Set the user-agent header field to use in all requests to the server.
152 /// It defaults to `google-api-rust-client/7.0.0`.
153 ///
154 /// Returns the previously set user-agent.
155 pub fn user_agent(&mut self, agent_name: String) -> String {
156 std::mem::replace(&mut self._user_agent, agent_name)
157 }
158
159 /// Set the base url to use in all requests to the server.
160 /// It defaults to `https://cloudfunctions.googleapis.com/`.
161 ///
162 /// Returns the previously set base url.
163 pub fn base_url(&mut self, new_base_url: String) -> String {
164 std::mem::replace(&mut self._base_url, new_base_url)
165 }
166
167 /// Set the root url to use in all requests to the server.
168 /// It defaults to `https://cloudfunctions.googleapis.com/`.
169 ///
170 /// Returns the previously set root url.
171 pub fn root_url(&mut self, new_root_url: String) -> String {
172 std::mem::replace(&mut self._root_url, new_root_url)
173 }
174}
175
176// ############
177// SCHEMAS ###
178// ##########
179/// Specifies the audit configuration for a service. The configuration determines which permission types are logged, and what identities, if any, are exempted from logging. An AuditConfig must have one or more AuditLogConfigs. If there are AuditConfigs for both `allServices` and a specific service, the union of the two AuditConfigs is used for that service: the log_types specified in each AuditConfig are enabled, and the exempted_members in each AuditLogConfig are exempted. Example Policy with multiple AuditConfigs: { "audit_configs": [ { "service": "allServices", "audit_log_configs": [ { "log_type": "DATA_READ", "exempted_members": [ "user:jose@example.com" ] }, { "log_type": "DATA_WRITE" }, { "log_type": "ADMIN_READ" } ] }, { "service": "sampleservice.googleapis.com", "audit_log_configs": [ { "log_type": "DATA_READ" }, { "log_type": "DATA_WRITE", "exempted_members": [ "user:aliya@example.com" ] } ] } ] } For sampleservice, this policy enables DATA_READ, DATA_WRITE and ADMIN_READ logging. It also exempts `jose@example.com` from DATA_READ logging, and `aliya@example.com` from DATA_WRITE logging.
180///
181/// This type is not used in any activity, and only used as *part* of another schema.
182///
183#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
184#[serde_with::serde_as]
185#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
186pub struct AuditConfig {
187 /// The configuration for logging of each type of permission.
188 #[serde(rename = "auditLogConfigs")]
189 pub audit_log_configs: Option<Vec<AuditLogConfig>>,
190 /// Specifies a service that will be enabled for audit logging. For example, `storage.googleapis.com`, `cloudsql.googleapis.com`. `allServices` is a special value that covers all services.
191 pub service: Option<String>,
192}
193
194impl common::Part for AuditConfig {}
195
196/// Provides the configuration for logging a type of permissions. Example: { "audit_log_configs": [ { "log_type": "DATA_READ", "exempted_members": [ "user:jose@example.com" ] }, { "log_type": "DATA_WRITE" } ] } This enables 'DATA_READ' and 'DATA_WRITE' logging, while exempting jose@example.com from DATA_READ logging.
197///
198/// This type is not used in any activity, and only used as *part* of another schema.
199///
200#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
201#[serde_with::serde_as]
202#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
203pub struct AuditLogConfig {
204 /// Specifies the identities that do not cause logging for this type of permission. Follows the same format of Binding.members.
205 #[serde(rename = "exemptedMembers")]
206 pub exempted_members: Option<Vec<String>>,
207 /// The log type that this config enables.
208 #[serde(rename = "logType")]
209 pub log_type: Option<String>,
210}
211
212impl common::Part for AuditLogConfig {}
213
214/// Security patches are applied automatically to the runtime without requiring the function to be redeployed.
215///
216/// This type is not used in any activity, and only used as *part* of another schema.
217///
218#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
219#[serde_with::serde_as]
220#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
221pub struct AutomaticUpdatePolicy {
222 _never_set: Option<bool>,
223}
224
225impl common::Part for AutomaticUpdatePolicy {}
226
227/// Associates `members`, or principals, with a `role`.
228///
229/// This type is not used in any activity, and only used as *part* of another schema.
230///
231#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
232#[serde_with::serde_as]
233#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
234pub struct Binding {
235 /// 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).
236 pub condition: Option<Expr>,
237 /// 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`.
238 pub members: Option<Vec<String>>,
239 /// 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).
240 pub role: Option<String>,
241}
242
243impl common::Part for Binding {}
244
245/// Request for the `CallFunction` method.
246///
247/// # Activities
248///
249/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
250/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
251///
252/// * [locations functions call projects](ProjectLocationFunctionCallCall) (request)
253#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
254#[serde_with::serde_as]
255#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
256pub struct CallFunctionRequest {
257 /// Required. Input to be passed to the function.
258 pub data: Option<String>,
259}
260
261impl common::RequestValue for CallFunctionRequest {}
262
263/// Response of `CallFunction` method.
264///
265/// # Activities
266///
267/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
268/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
269///
270/// * [locations functions call projects](ProjectLocationFunctionCallCall) (response)
271#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
272#[serde_with::serde_as]
273#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
274pub struct CallFunctionResponse {
275 /// Either system or user-function generated error. Set if execution was not successful.
276 pub error: Option<String>,
277 /// Execution id of function invocation.
278 #[serde(rename = "executionId")]
279 pub execution_id: Option<String>,
280 /// Result populated for successful execution of synchronous function. Will not be populated if function does not return a result through context.
281 pub result: Option<String>,
282}
283
284impl common::ResponseResult for CallFunctionResponse {}
285
286/// Describes a Cloud Function that contains user computation executed in response to an event. It encapsulate function and triggers configurations.
287///
288/// # Activities
289///
290/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
291/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
292///
293/// * [locations functions create projects](ProjectLocationFunctionCreateCall) (request)
294/// * [locations functions get projects](ProjectLocationFunctionGetCall) (response)
295/// * [locations functions patch projects](ProjectLocationFunctionPatchCall) (request)
296#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
297#[serde_with::serde_as]
298#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
299pub struct CloudFunction {
300 /// no description provided
301 #[serde(rename = "automaticUpdatePolicy")]
302 pub automatic_update_policy: Option<AutomaticUpdatePolicy>,
303 /// The amount of memory in MB available for a function. Defaults to 256MB.
304 #[serde(rename = "availableMemoryMb")]
305 pub available_memory_mb: Option<i32>,
306 /// Build environment variables that shall be available during build time.
307 #[serde(rename = "buildEnvironmentVariables")]
308 pub build_environment_variables: Option<HashMap<String, String>>,
309 /// Output only. The Cloud Build ID of the latest successful deployment of the function.
310 #[serde(rename = "buildId")]
311 pub build_id: Option<String>,
312 /// Output only. The Cloud Build Name of the function deployment. `projects//locations//builds/`.
313 #[serde(rename = "buildName")]
314 pub build_name: Option<String>,
315 /// A service account the user provides for use with Cloud Build. The format of this field is `projects/{projectId}/serviceAccounts/{serviceAccountEmail}`.
316 #[serde(rename = "buildServiceAccount")]
317 pub build_service_account: Option<String>,
318 /// Name of the Cloud Build Custom Worker Pool that should be used to build the function. The format of this field is `projects/{project}/locations/{region}/workerPools/{workerPool}` where `{project}` and `{region}` are the project id and region respectively where the worker pool is defined and `{workerPool}` is the short name of the worker pool. If the project id is not the same as the function, then the Cloud Functions Service Agent (`service-@gcf-admin-robot.iam.gserviceaccount.com`) must be granted the role Cloud Build Custom Workers Builder (`roles/cloudbuild.customworkers.builder`) in the project.
319 #[serde(rename = "buildWorkerPool")]
320 pub build_worker_pool: Option<String>,
321 /// User-provided description of a function.
322 pub description: Option<String>,
323 /// Docker Registry to use for this deployment. Deprecated: as of March 2025, `CONTAINER_REGISTRY` option is no longer available in response to Container Registry's deprecation: https://cloud.google.com/artifact-registry/docs/transition/transition-from-gcr Please use Artifact Registry instead, which is the default choice. If unspecified, it defaults to `ARTIFACT_REGISTRY`. If `docker_repository` field is specified, this field should either be left unspecified or set to `ARTIFACT_REGISTRY`.
324 #[serde(rename = "dockerRegistry")]
325 pub docker_registry: Option<String>,
326 /// User-managed repository created in Artifact Registry to which the function's Docker image will be pushed after it is built by Cloud Build. May optionally be encrypted with a customer-managed encryption key (CMEK). If unspecified and `docker_registry` is not explicitly set to `CONTAINER_REGISTRY`, GCF will create and use a default Artifact Registry repository named 'gcf-artifacts' in the region. It must match the pattern `projects/{project}/locations/{location}/repositories/{repository}`. Cross-project repositories are not supported. Cross-location repositories are not supported. Repository format must be 'DOCKER'.
327 #[serde(rename = "dockerRepository")]
328 pub docker_repository: Option<String>,
329 /// The name of the function (as defined in source code) that will be executed. Defaults to the resource name suffix (ID of the function), if not specified.
330 #[serde(rename = "entryPoint")]
331 pub entry_point: Option<String>,
332 /// Environment variables that shall be available during function execution.
333 #[serde(rename = "environmentVariables")]
334 pub environment_variables: Option<HashMap<String, String>>,
335 /// A source that fires events in response to a condition in another service.
336 #[serde(rename = "eventTrigger")]
337 pub event_trigger: Option<EventTrigger>,
338 /// An HTTPS endpoint type of source that can be triggered via URL.
339 #[serde(rename = "httpsTrigger")]
340 pub https_trigger: Option<HttpsTrigger>,
341 /// The ingress settings for the function, controlling what traffic can reach it.
342 #[serde(rename = "ingressSettings")]
343 pub ingress_settings: Option<String>,
344 /// Resource name of a KMS crypto key (managed by the user) used to encrypt/decrypt function resources. It must match the pattern `projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`. If specified, you must also provide an artifact registry repository using the `docker_repository` field that was created with the same KMS crypto key. The following service accounts need to be granted the role 'Cloud KMS CryptoKey Encrypter/Decrypter (roles/cloudkms.cryptoKeyEncrypterDecrypter)' on the Key/KeyRing/Project/Organization (least access preferred). 1. Google Cloud Functions service account (service-{project_number}@gcf-admin-robot.iam.gserviceaccount.com) - Required to protect the function's image. 2. Google Storage service account (service-{project_number}@gs-project-accounts.iam.gserviceaccount.com) - Required to protect the function's source code. If this service account does not exist, deploying a function without a KMS key or retrieving the service agent name provisions it. For more information, see https://cloud.google.com/storage/docs/projects#service-agents and https://cloud.google.com/storage/docs/getting-service-agent#gsutil. Google Cloud Functions delegates access to service agents to protect function resources in internal projects that are not accessible by the end user.
345 #[serde(rename = "kmsKeyName")]
346 pub kms_key_name: Option<String>,
347 /// Labels associated with this Cloud Function.
348 pub labels: Option<HashMap<String, String>>,
349 /// The limit on the maximum number of function instances that may coexist at a given time. In some cases, such as rapid traffic surges, Cloud Functions may, for a short period of time, create more instances than the specified max instances limit. If your function cannot tolerate this temporary behavior, you may want to factor in a safety margin and set a lower max instances value than your function can tolerate. See the [Max Instances](https://cloud.google.com/functions/docs/max-instances) Guide for more details.
350 #[serde(rename = "maxInstances")]
351 pub max_instances: Option<i32>,
352 /// A lower bound for the number function instances that may coexist at a given time.
353 #[serde(rename = "minInstances")]
354 pub min_instances: Option<i32>,
355 /// A user-defined name of the function. Function names must be unique globally and match pattern `projects/*/locations/*/functions/*`
356 pub name: Option<String>,
357 /// Deprecated: use vpc_connector
358 pub network: Option<String>,
359 /// no description provided
360 #[serde(rename = "onDeployUpdatePolicy")]
361 pub on_deploy_update_policy: Option<OnDeployUpdatePolicy>,
362 /// The runtime in which to run the function. Required when deploying a new function, optional when updating an existing function. For a complete list of possible choices, see the [`gcloud` command reference](https://cloud.google.com/sdk/gcloud/reference/functions/deploy#--runtime).
363 pub runtime: Option<String>,
364 /// Output only.
365 #[serde(rename = "satisfiesPzi")]
366 pub satisfies_pzi: Option<bool>,
367 /// Output only.
368 #[serde(rename = "satisfiesPzs")]
369 pub satisfies_pzs: Option<bool>,
370 /// Secret environment variables configuration.
371 #[serde(rename = "secretEnvironmentVariables")]
372 pub secret_environment_variables: Option<Vec<SecretEnvVar>>,
373 /// Secret volumes configuration.
374 #[serde(rename = "secretVolumes")]
375 pub secret_volumes: Option<Vec<SecretVolume>>,
376 /// The email of the function's service account. If empty, defaults to `{project_id}@appspot.gserviceaccount.com`.
377 #[serde(rename = "serviceAccountEmail")]
378 pub service_account_email: Option<String>,
379 /// The Google Cloud Storage URL, starting with `gs://`, pointing to the zip archive which contains the function.
380 #[serde(rename = "sourceArchiveUrl")]
381 pub source_archive_url: Option<String>,
382 /// **Beta Feature** The source repository where a function is hosted.
383 #[serde(rename = "sourceRepository")]
384 pub source_repository: Option<SourceRepository>,
385 /// Input only. An identifier for Firebase function sources. Disclaimer: This field is only supported for Firebase function deployments.
386 #[serde(rename = "sourceToken")]
387 pub source_token: Option<String>,
388 /// The Google Cloud Storage signed URL used for source uploading, generated by calling [google.cloud.functions.v1.GenerateUploadUrl]. The signature is validated on write methods (Create, Update) The signature is stripped from the Function object on read methods (Get, List)
389 #[serde(rename = "sourceUploadUrl")]
390 pub source_upload_url: Option<String>,
391 /// Output only. Status of the function deployment.
392 pub status: Option<String>,
393 /// The function execution timeout. Execution is considered failed and can be terminated if the function is not completed at the end of the timeout period. Defaults to 60 seconds.
394 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
395 pub timeout: Option<chrono::Duration>,
396 /// Output only. The last update timestamp of a Cloud Function.
397 #[serde(rename = "updateTime")]
398 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
399 /// Output only. The version identifier of the Cloud Function. Each deployment attempt results in a new version of a function being created.
400 #[serde(rename = "versionId")]
401 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
402 pub version_id: Option<i64>,
403 /// The VPC Network Connector that this cloud function can connect to. It can be either the fully-qualified URI, or the short name of the network connector resource. The format of this field is `projects/*/locations/*/connectors/*` This field is mutually exclusive with `network` field and will eventually replace it. See [the VPC documentation](https://cloud.google.com/compute/docs/vpc) for more information on connecting Cloud projects.
404 #[serde(rename = "vpcConnector")]
405 pub vpc_connector: Option<String>,
406 /// The egress settings for the connector, controlling what traffic is diverted through it.
407 #[serde(rename = "vpcConnectorEgressSettings")]
408 pub vpc_connector_egress_settings: Option<String>,
409}
410
411impl common::RequestValue for CloudFunction {}
412impl common::ResponseResult for CloudFunction {}
413
414/// Describes EventTrigger, used to request events be sent from another service.
415///
416/// This type is not used in any activity, and only used as *part* of another schema.
417///
418#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
419#[serde_with::serde_as]
420#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
421pub struct EventTrigger {
422 /// Required. The type of event to observe. For example: `providers/cloud.storage/eventTypes/object.change` and `providers/cloud.pubsub/eventTypes/topic.publish`. Event types match pattern `providers/*/eventTypes/*.*`. The pattern contains: 1. namespace: For example, `cloud.storage` and `google.firebase.analytics`. 2. resource type: The type of resource on which event occurs. For example, the Google Cloud Storage API includes the type `object`. 3. action: The action that generates the event. For example, action for a Google Cloud Storage Object is 'change'. These parts are lower case.
423 #[serde(rename = "eventType")]
424 pub event_type: Option<String>,
425 /// Specifies policy for failed executions.
426 #[serde(rename = "failurePolicy")]
427 pub failure_policy: Option<FailurePolicy>,
428 /// Required. The resource(s) from which to observe events, for example, `projects/_/buckets/myBucket`. Not all syntactically correct values are accepted by all services. For example: 1. The authorization model must support it. Google Cloud Functions only allows EventTriggers to be deployed that observe resources in the same project as the `CloudFunction`. 2. The resource type must match the pattern expected for an `event_type`. For example, an `EventTrigger` that has an `event_type` of "google.pubsub.topic.publish" should have a resource that matches Google Cloud Pub/Sub topics. Additionally, some services may support short names when creating an `EventTrigger`. These will always be returned in the normalized "long" format. See each *service's* documentation for supported formats.
429 pub resource: Option<String>,
430 /// The hostname of the service that should be observed. If no string is provided, the default service implementing the API will be used. For example, `storage.googleapis.com` is the default for all event types in the `google.storage` namespace.
431 pub service: Option<String>,
432}
433
434impl common::Part for EventTrigger {}
435
436/// 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.
437///
438/// This type is not used in any activity, and only used as *part* of another schema.
439///
440#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
441#[serde_with::serde_as]
442#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
443pub struct Expr {
444 /// Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.
445 pub description: Option<String>,
446 /// Textual representation of an expression in Common Expression Language syntax.
447 pub expression: Option<String>,
448 /// Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.
449 pub location: Option<String>,
450 /// 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.
451 pub title: Option<String>,
452}
453
454impl common::Part for Expr {}
455
456/// Describes the policy in case of function's execution failure. If empty, then defaults to ignoring failures (i.e. not retrying them).
457///
458/// This type is not used in any activity, and only used as *part* of another schema.
459///
460#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
461#[serde_with::serde_as]
462#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
463pub struct FailurePolicy {
464 /// If specified, then the function will be retried in case of a failure.
465 pub retry: Option<Retry>,
466}
467
468impl common::Part for FailurePolicy {}
469
470/// Request of `GenerateDownloadUrl` method.
471///
472/// # Activities
473///
474/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
475/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
476///
477/// * [locations functions generate download url projects](ProjectLocationFunctionGenerateDownloadUrlCall) (request)
478#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
479#[serde_with::serde_as]
480#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
481pub struct GenerateDownloadUrlRequest {
482 /// The optional version of function. If not set, default, current version is used.
483 #[serde(rename = "versionId")]
484 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
485 pub version_id: Option<u64>,
486}
487
488impl common::RequestValue for GenerateDownloadUrlRequest {}
489
490/// Response of `GenerateDownloadUrl` method.
491///
492/// # Activities
493///
494/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
495/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
496///
497/// * [locations functions generate download url projects](ProjectLocationFunctionGenerateDownloadUrlCall) (response)
498#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
499#[serde_with::serde_as]
500#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
501pub struct GenerateDownloadUrlResponse {
502 /// The generated Google Cloud Storage signed URL that should be used for function source code download.
503 #[serde(rename = "downloadUrl")]
504 pub download_url: Option<String>,
505}
506
507impl common::ResponseResult for GenerateDownloadUrlResponse {}
508
509/// Request of `GenerateSourceUploadUrl` method.
510///
511/// # Activities
512///
513/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
514/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
515///
516/// * [locations functions generate upload url projects](ProjectLocationFunctionGenerateUploadUrlCall) (request)
517#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
518#[serde_with::serde_as]
519#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
520pub struct GenerateUploadUrlRequest {
521 /// Resource name of a KMS crypto key (managed by the user) used to encrypt/decrypt function source code objects in intermediate Cloud Storage buckets. When you generate an upload url and upload your source code, it gets copied to an intermediate Cloud Storage bucket. The source code is then copied to a versioned directory in the sources bucket in the consumer project during the function deployment. It must match the pattern `projects/{project}/locations/{location}/keyRings/{key_ring}/cryptoKeys/{crypto_key}`. The Google Cloud Functions service account (service-{project_number}@gcf-admin-robot.iam.gserviceaccount.com) must be granted the role 'Cloud KMS CryptoKey Encrypter/Decrypter (roles/cloudkms.cryptoKeyEncrypterDecrypter)' on the Key/KeyRing/Project/Organization (least access preferred). GCF will delegate access to the Google Storage service account in the internal project.
522 #[serde(rename = "kmsKeyName")]
523 pub kms_key_name: Option<String>,
524}
525
526impl common::RequestValue for GenerateUploadUrlRequest {}
527
528/// Response of `GenerateSourceUploadUrl` method.
529///
530/// # Activities
531///
532/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
533/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
534///
535/// * [locations functions generate upload url projects](ProjectLocationFunctionGenerateUploadUrlCall) (response)
536#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
537#[serde_with::serde_as]
538#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
539pub struct GenerateUploadUrlResponse {
540 /// The generated Google Cloud Storage signed URL that should be used for a function source code upload. The uploaded file should be a zip archive which contains a function.
541 #[serde(rename = "uploadUrl")]
542 pub upload_url: Option<String>,
543}
544
545impl common::ResponseResult for GenerateUploadUrlResponse {}
546
547/// Describes HttpsTrigger, could be used to connect web hooks to function.
548///
549/// This type is not used in any activity, and only used as *part* of another schema.
550///
551#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
552#[serde_with::serde_as]
553#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
554pub struct HttpsTrigger {
555 /// The security level for the function.
556 #[serde(rename = "securityLevel")]
557 pub security_level: Option<String>,
558 /// Output only. The deployed url for the function.
559 pub url: Option<String>,
560}
561
562impl common::Part for HttpsTrigger {}
563
564/// Response for the `ListFunctions` method.
565///
566/// # Activities
567///
568/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
569/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
570///
571/// * [locations functions list projects](ProjectLocationFunctionListCall) (response)
572#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
573#[serde_with::serde_as]
574#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
575pub struct ListFunctionsResponse {
576 /// The functions that match the request.
577 pub functions: Option<Vec<CloudFunction>>,
578 /// If not empty, indicates that there may be more functions that match the request; this value should be passed in a new google.cloud.functions.v1.ListFunctionsRequest to get more functions.
579 #[serde(rename = "nextPageToken")]
580 pub next_page_token: Option<String>,
581 /// Locations that could not be reached. The response does not include any functions from these locations.
582 pub unreachable: Option<Vec<String>>,
583}
584
585impl common::ResponseResult for ListFunctionsResponse {}
586
587/// The response message for Locations.ListLocations.
588///
589/// # Activities
590///
591/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
592/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
593///
594/// * [locations list projects](ProjectLocationListCall) (response)
595#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
596#[serde_with::serde_as]
597#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
598pub struct ListLocationsResponse {
599 /// A list of locations that matches the specified filter in the request.
600 pub locations: Option<Vec<Location>>,
601 /// The standard List next-page token.
602 #[serde(rename = "nextPageToken")]
603 pub next_page_token: Option<String>,
604}
605
606impl common::ResponseResult for ListLocationsResponse {}
607
608/// The response message for Operations.ListOperations.
609///
610/// # Activities
611///
612/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
613/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
614///
615/// * [list operations](OperationListCall) (response)
616#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
617#[serde_with::serde_as]
618#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
619pub struct ListOperationsResponse {
620 /// The standard List next-page token.
621 #[serde(rename = "nextPageToken")]
622 pub next_page_token: Option<String>,
623 /// A list of operations that matches the specified filter in the request.
624 pub operations: Option<Vec<Operation>>,
625 /// 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.
626 pub unreachable: Option<Vec<String>>,
627}
628
629impl common::ResponseResult for ListOperationsResponse {}
630
631/// A resource that represents a Google Cloud location.
632///
633/// This type is not used in any activity, and only used as *part* of another schema.
634///
635#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
636#[serde_with::serde_as]
637#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
638pub struct Location {
639 /// The friendly name for this location, typically a nearby city name. For example, "Tokyo".
640 #[serde(rename = "displayName")]
641 pub display_name: Option<String>,
642 /// Cross-service attributes for the location. For example {"cloud.googleapis.com/region": "us-east1"}
643 pub labels: Option<HashMap<String, String>>,
644 /// The canonical id for this location. For example: `"us-east1"`.
645 #[serde(rename = "locationId")]
646 pub location_id: Option<String>,
647 /// Service-specific metadata. For example the available capacity at the given location.
648 pub metadata: Option<HashMap<String, serde_json::Value>>,
649 /// Resource name for the location, which may vary between implementations. For example: `"projects/example-project/locations/us-east1"`
650 pub name: Option<String>,
651}
652
653impl common::Part for Location {}
654
655/// Security patches are only applied when a function is redeployed.
656///
657/// This type is not used in any activity, and only used as *part* of another schema.
658///
659#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
660#[serde_with::serde_as]
661#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
662pub struct OnDeployUpdatePolicy {
663 /// Output only. Contains the runtime version which was used during latest function deployment.
664 #[serde(rename = "runtimeVersion")]
665 pub runtime_version: Option<String>,
666}
667
668impl common::Part for OnDeployUpdatePolicy {}
669
670/// This resource represents a long-running operation that is the result of a network API call.
671///
672/// # Activities
673///
674/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
675/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
676///
677/// * [get operations](OperationGetCall) (response)
678/// * [list operations](OperationListCall) (none)
679/// * [locations functions create projects](ProjectLocationFunctionCreateCall) (response)
680/// * [locations functions delete projects](ProjectLocationFunctionDeleteCall) (response)
681/// * [locations functions patch projects](ProjectLocationFunctionPatchCall) (response)
682#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
683#[serde_with::serde_as]
684#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
685pub struct Operation {
686 /// 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.
687 pub done: Option<bool>,
688 /// The error result of the operation in case of failure or cancellation.
689 pub error: Option<Status>,
690 /// 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.
691 pub metadata: Option<HashMap<String, serde_json::Value>>,
692 /// 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}`.
693 pub name: Option<String>,
694 /// 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`.
695 pub response: Option<HashMap<String, serde_json::Value>>,
696}
697
698impl common::Resource for Operation {}
699impl common::ResponseResult for Operation {}
700
701/// 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/).
702///
703/// # Activities
704///
705/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
706/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
707///
708/// * [locations functions get iam policy projects](ProjectLocationFunctionGetIamPolicyCall) (response)
709/// * [locations functions set iam policy projects](ProjectLocationFunctionSetIamPolicyCall) (response)
710#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
711#[serde_with::serde_as]
712#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
713pub struct Policy {
714 /// Specifies cloud audit logging configuration for this policy.
715 #[serde(rename = "auditConfigs")]
716 pub audit_configs: Option<Vec<AuditConfig>>,
717 /// 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`.
718 pub bindings: Option<Vec<Binding>>,
719 /// `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.
720 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
721 pub etag: Option<Vec<u8>>,
722 /// 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).
723 pub version: Option<i32>,
724}
725
726impl common::ResponseResult for Policy {}
727
728/// Describes the retry policy in case of function's execution failure. A function execution will be retried on any failure. A failed execution will be retried up to 7 days with an exponential backoff (capped at 10 seconds). Retried execution is charged as any other execution.
729///
730/// This type is not used in any activity, and only used as *part* of another schema.
731///
732#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
733#[serde_with::serde_as]
734#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
735pub struct Retry {
736 _never_set: Option<bool>,
737}
738
739impl common::Part for Retry {}
740
741/// Configuration for a secret environment variable. It has the information necessary to fetch the secret value from secret manager and expose it as an environment variable.
742///
743/// This type is not used in any activity, and only used as *part* of another schema.
744///
745#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
746#[serde_with::serde_as]
747#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
748pub struct SecretEnvVar {
749 /// Name of the environment variable.
750 pub key: Option<String>,
751 /// Project identifier (preferably project number but can also be the project ID) of the project that contains the secret. If not set, it will be populated with the function's project assuming that the secret exists in the same project as of the function.
752 #[serde(rename = "projectId")]
753 pub project_id: Option<String>,
754 /// Name of the secret in secret manager (not the full resource name).
755 pub secret: Option<String>,
756 /// Version of the secret (version number or the string 'latest'). It is recommended to use a numeric version for secret environment variables as any updates to the secret value is not reflected until new instances start.
757 pub version: Option<String>,
758}
759
760impl common::Part for SecretEnvVar {}
761
762/// Configuration for a single version.
763///
764/// This type is not used in any activity, and only used as *part* of another schema.
765///
766#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
767#[serde_with::serde_as]
768#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
769pub struct SecretVersion {
770 /// Relative path of the file under the mount path where the secret value for this version will be fetched and made available. For example, setting the mount_path as '/etc/secrets' and path as `/secret_foo` would mount the secret value file at `/etc/secrets/secret_foo`.
771 pub path: Option<String>,
772 /// Version of the secret (version number or the string 'latest'). It is preferable to use `latest` version with secret volumes as secret value changes are reflected immediately.
773 pub version: Option<String>,
774}
775
776impl common::Part for SecretVersion {}
777
778/// Configuration for a secret volume. It has the information necessary to fetch the secret value from secret manager and make it available as files mounted at the requested paths within the application container. Secret value is not a part of the configuration. Every filesystem read operation performs a lookup in secret manager to retrieve the secret value.
779///
780/// This type is not used in any activity, and only used as *part* of another schema.
781///
782#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
783#[serde_with::serde_as]
784#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
785pub struct SecretVolume {
786 /// The path within the container to mount the secret volume. For example, setting the mount_path as `/etc/secrets` would mount the secret value files under the `/etc/secrets` directory. This directory will also be completely shadowed and unavailable to mount any other secrets. Recommended mount paths: /etc/secrets Restricted mount paths: /cloudsql, /dev/log, /pod, /proc, /var/log
787 #[serde(rename = "mountPath")]
788 pub mount_path: Option<String>,
789 /// Project identifier (preferrably project number but can also be the project ID) of the project that contains the secret. If not set, it will be populated with the function's project assuming that the secret exists in the same project as of the function.
790 #[serde(rename = "projectId")]
791 pub project_id: Option<String>,
792 /// Name of the secret in secret manager (not the full resource name).
793 pub secret: Option<String>,
794 /// List of secret versions to mount for this secret. If empty, the `latest` version of the secret will be made available in a file named after the secret under the mount point.
795 pub versions: Option<Vec<SecretVersion>>,
796}
797
798impl common::Part for SecretVolume {}
799
800/// Request message for `SetIamPolicy` method.
801///
802/// # Activities
803///
804/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
805/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
806///
807/// * [locations functions set iam policy projects](ProjectLocationFunctionSetIamPolicyCall) (request)
808#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
809#[serde_with::serde_as]
810#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
811pub struct SetIamPolicyRequest {
812 /// 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.
813 pub policy: Option<Policy>,
814 /// 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"`
815 #[serde(rename = "updateMask")]
816 pub update_mask: Option<common::FieldMask>,
817}
818
819impl common::RequestValue for SetIamPolicyRequest {}
820
821/// Describes SourceRepository, used to represent parameters related to source repository where a function is hosted.
822///
823/// This type is not used in any activity, and only used as *part* of another schema.
824///
825#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
826#[serde_with::serde_as]
827#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
828pub struct SourceRepository {
829 /// Output only. The URL pointing to the hosted repository where the function were defined at the time of deployment. It always points to a specific commit in the format described above.
830 #[serde(rename = "deployedUrl")]
831 pub deployed_url: Option<String>,
832 /// The URL pointing to the hosted repository where the function is defined. There are supported Cloud Source Repository URLs in the following formats: To refer to a specific commit: `https://source.developers.google.com/projects/*/repos/*/revisions/*/paths/*` To refer to a moveable alias (branch): `https://source.developers.google.com/projects/*/repos/*/moveable-aliases/*/paths/*` In particular, to refer to HEAD use `master` moveable alias. To refer to a specific fixed alias (tag): `https://source.developers.google.com/projects/*/repos/*/fixed-aliases/*/paths/*` You may omit `paths/*` if you want to use the main directory. The function response may add an empty `/paths/` to the URL.
833 pub url: Option<String>,
834}
835
836impl common::Part for SourceRepository {}
837
838/// 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).
839///
840/// This type is not used in any activity, and only used as *part* of another schema.
841///
842#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
843#[serde_with::serde_as]
844#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
845pub struct Status {
846 /// The status code, which should be an enum value of google.rpc.Code.
847 pub code: Option<i32>,
848 /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
849 pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
850 /// 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.
851 pub message: Option<String>,
852}
853
854impl common::Part for Status {}
855
856/// Request message for `TestIamPermissions` method.
857///
858/// # Activities
859///
860/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
861/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
862///
863/// * [locations functions test iam permissions projects](ProjectLocationFunctionTestIamPermissionCall) (request)
864#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
865#[serde_with::serde_as]
866#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
867pub struct TestIamPermissionsRequest {
868 /// 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).
869 pub permissions: Option<Vec<String>>,
870}
871
872impl common::RequestValue for TestIamPermissionsRequest {}
873
874/// Response message for `TestIamPermissions` method.
875///
876/// # Activities
877///
878/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
879/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
880///
881/// * [locations functions test iam permissions projects](ProjectLocationFunctionTestIamPermissionCall) (response)
882#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
883#[serde_with::serde_as]
884#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
885pub struct TestIamPermissionsResponse {
886 /// A subset of `TestPermissionsRequest.permissions` that the caller is allowed.
887 pub permissions: Option<Vec<String>>,
888}
889
890impl common::ResponseResult for TestIamPermissionsResponse {}
891
892// ###################
893// MethodBuilders ###
894// #################
895
896/// A builder providing access to all methods supported on *operation* resources.
897/// It is not used directly, but through the [`CloudFunctions`] hub.
898///
899/// # Example
900///
901/// Instantiate a resource builder
902///
903/// ```test_harness,no_run
904/// extern crate hyper;
905/// extern crate hyper_rustls;
906/// extern crate google_cloudfunctions1 as cloudfunctions1;
907///
908/// # async fn dox() {
909/// use cloudfunctions1::{CloudFunctions, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
910///
911/// let secret: yup_oauth2::ApplicationSecret = Default::default();
912/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
913/// .with_native_roots()
914/// .unwrap()
915/// .https_only()
916/// .enable_http2()
917/// .build();
918///
919/// let executor = hyper_util::rt::TokioExecutor::new();
920/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
921/// secret,
922/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
923/// yup_oauth2::client::CustomHyperClientBuilder::from(
924/// hyper_util::client::legacy::Client::builder(executor).build(connector),
925/// ),
926/// ).build().await.unwrap();
927///
928/// let client = hyper_util::client::legacy::Client::builder(
929/// hyper_util::rt::TokioExecutor::new()
930/// )
931/// .build(
932/// hyper_rustls::HttpsConnectorBuilder::new()
933/// .with_native_roots()
934/// .unwrap()
935/// .https_or_http()
936/// .enable_http2()
937/// .build()
938/// );
939/// let mut hub = CloudFunctions::new(client, auth);
940/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
941/// // like `get(...)` and `list(...)`
942/// // to build up your call.
943/// let rb = hub.operations();
944/// # }
945/// ```
946pub struct OperationMethods<'a, C>
947where
948 C: 'a,
949{
950 hub: &'a CloudFunctions<C>,
951}
952
953impl<'a, C> common::MethodsBuilder for OperationMethods<'a, C> {}
954
955impl<'a, C> OperationMethods<'a, C> {
956 /// Create a builder to help you perform the following task:
957 ///
958 /// 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.
959 ///
960 /// # Arguments
961 ///
962 /// * `name` - The name of the operation resource.
963 pub fn get(&self, name: &str) -> OperationGetCall<'a, C> {
964 OperationGetCall {
965 hub: self.hub,
966 _name: name.to_string(),
967 _delegate: Default::default(),
968 _additional_params: Default::default(),
969 _scopes: Default::default(),
970 }
971 }
972
973 /// Create a builder to help you perform the following task:
974 ///
975 /// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
976 pub fn list(&self) -> OperationListCall<'a, C> {
977 OperationListCall {
978 hub: self.hub,
979 _return_partial_success: Default::default(),
980 _page_token: Default::default(),
981 _page_size: Default::default(),
982 _name: Default::default(),
983 _filter: Default::default(),
984 _delegate: Default::default(),
985 _additional_params: Default::default(),
986 _scopes: Default::default(),
987 }
988 }
989}
990
991/// A builder providing access to all methods supported on *project* resources.
992/// It is not used directly, but through the [`CloudFunctions`] hub.
993///
994/// # Example
995///
996/// Instantiate a resource builder
997///
998/// ```test_harness,no_run
999/// extern crate hyper;
1000/// extern crate hyper_rustls;
1001/// extern crate google_cloudfunctions1 as cloudfunctions1;
1002///
1003/// # async fn dox() {
1004/// use cloudfunctions1::{CloudFunctions, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1005///
1006/// let secret: yup_oauth2::ApplicationSecret = Default::default();
1007/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
1008/// .with_native_roots()
1009/// .unwrap()
1010/// .https_only()
1011/// .enable_http2()
1012/// .build();
1013///
1014/// let executor = hyper_util::rt::TokioExecutor::new();
1015/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1016/// secret,
1017/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1018/// yup_oauth2::client::CustomHyperClientBuilder::from(
1019/// hyper_util::client::legacy::Client::builder(executor).build(connector),
1020/// ),
1021/// ).build().await.unwrap();
1022///
1023/// let client = hyper_util::client::legacy::Client::builder(
1024/// hyper_util::rt::TokioExecutor::new()
1025/// )
1026/// .build(
1027/// hyper_rustls::HttpsConnectorBuilder::new()
1028/// .with_native_roots()
1029/// .unwrap()
1030/// .https_or_http()
1031/// .enable_http2()
1032/// .build()
1033/// );
1034/// let mut hub = CloudFunctions::new(client, auth);
1035/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
1036/// // like `locations_functions_call(...)`, `locations_functions_create(...)`, `locations_functions_delete(...)`, `locations_functions_generate_download_url(...)`, `locations_functions_generate_upload_url(...)`, `locations_functions_get(...)`, `locations_functions_get_iam_policy(...)`, `locations_functions_list(...)`, `locations_functions_patch(...)`, `locations_functions_set_iam_policy(...)`, `locations_functions_test_iam_permissions(...)` and `locations_list(...)`
1037/// // to build up your call.
1038/// let rb = hub.projects();
1039/// # }
1040/// ```
1041pub struct ProjectMethods<'a, C>
1042where
1043 C: 'a,
1044{
1045 hub: &'a CloudFunctions<C>,
1046}
1047
1048impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
1049
1050impl<'a, C> ProjectMethods<'a, C> {
1051 /// Create a builder to help you perform the following task:
1052 ///
1053 /// Synchronously invokes a deployed Cloud Function. To be used for testing purposes as very limited traffic is allowed. For more information on the actual limits, refer to [Rate Limits](https://cloud.google.com/functions/quotas#rate_limits).
1054 ///
1055 /// # Arguments
1056 ///
1057 /// * `request` - No description provided.
1058 /// * `name` - Required. The name of the function to be called.
1059 pub fn locations_functions_call(
1060 &self,
1061 request: CallFunctionRequest,
1062 name: &str,
1063 ) -> ProjectLocationFunctionCallCall<'a, C> {
1064 ProjectLocationFunctionCallCall {
1065 hub: self.hub,
1066 _request: request,
1067 _name: name.to_string(),
1068 _delegate: Default::default(),
1069 _additional_params: Default::default(),
1070 _scopes: Default::default(),
1071 }
1072 }
1073
1074 /// Create a builder to help you perform the following task:
1075 ///
1076 /// Creates a new function. If a function with the given name already exists in the specified project, the long running operation will return `ALREADY_EXISTS` error.
1077 ///
1078 /// # Arguments
1079 ///
1080 /// * `request` - No description provided.
1081 /// * `location` - Required. The project and location in which the function should be created, specified in the format `projects/*/locations/*`
1082 pub fn locations_functions_create(
1083 &self,
1084 request: CloudFunction,
1085 location: &str,
1086 ) -> ProjectLocationFunctionCreateCall<'a, C> {
1087 ProjectLocationFunctionCreateCall {
1088 hub: self.hub,
1089 _request: request,
1090 _location: location.to_string(),
1091 _delegate: Default::default(),
1092 _additional_params: Default::default(),
1093 _scopes: Default::default(),
1094 }
1095 }
1096
1097 /// Create a builder to help you perform the following task:
1098 ///
1099 /// Deletes a function with the given name from the specified project. If the given function is used by some trigger, the trigger will be updated to remove this function.
1100 ///
1101 /// # Arguments
1102 ///
1103 /// * `name` - Required. The name of the function which should be deleted.
1104 pub fn locations_functions_delete(
1105 &self,
1106 name: &str,
1107 ) -> ProjectLocationFunctionDeleteCall<'a, C> {
1108 ProjectLocationFunctionDeleteCall {
1109 hub: self.hub,
1110 _name: name.to_string(),
1111 _delegate: Default::default(),
1112 _additional_params: Default::default(),
1113 _scopes: Default::default(),
1114 }
1115 }
1116
1117 /// Create a builder to help you perform the following task:
1118 ///
1119 /// Returns a signed URL for downloading deployed function source code. The URL is only valid for a limited period and should be used within minutes after generation. For more information about the signed URL usage see: https://cloud.google.com/storage/docs/access-control/signed-urls
1120 ///
1121 /// # Arguments
1122 ///
1123 /// * `request` - No description provided.
1124 /// * `name` - The name of function for which source code Google Cloud Storage signed URL should be generated.
1125 pub fn locations_functions_generate_download_url(
1126 &self,
1127 request: GenerateDownloadUrlRequest,
1128 name: &str,
1129 ) -> ProjectLocationFunctionGenerateDownloadUrlCall<'a, C> {
1130 ProjectLocationFunctionGenerateDownloadUrlCall {
1131 hub: self.hub,
1132 _request: request,
1133 _name: name.to_string(),
1134 _delegate: Default::default(),
1135 _additional_params: Default::default(),
1136 _scopes: Default::default(),
1137 }
1138 }
1139
1140 /// Create a builder to help you perform the following task:
1141 ///
1142 /// Returns a signed URL for uploading a function source code. For more information about the signed URL usage see: https://cloud.google.com/storage/docs/access-control/signed-urls. Once the function source code upload is complete, the used signed URL should be provided in CreateFunction or UpdateFunction request as a reference to the function source code. When uploading source code to the generated signed URL, please follow these restrictions: * Source file type should be a zip file. * Source file size should not exceed 100MB limit. * No credentials should be attached - the signed URLs provide access to the target bucket using internal service identity; if credentials were attached, the identity from the credentials would be used, but that identity does not have permissions to upload files to the URL. When making a HTTP PUT request, these two headers need to be specified: * `content-type: application/zip` * `x-goog-content-length-range: 0,104857600` And this header SHOULD NOT be specified: * `Authorization: Bearer YOUR_TOKEN`
1143 ///
1144 /// # Arguments
1145 ///
1146 /// * `request` - No description provided.
1147 /// * `parent` - The project and location in which the Google Cloud Storage signed URL should be generated, specified in the format `projects/*/locations/*`.
1148 pub fn locations_functions_generate_upload_url(
1149 &self,
1150 request: GenerateUploadUrlRequest,
1151 parent: &str,
1152 ) -> ProjectLocationFunctionGenerateUploadUrlCall<'a, C> {
1153 ProjectLocationFunctionGenerateUploadUrlCall {
1154 hub: self.hub,
1155 _request: request,
1156 _parent: parent.to_string(),
1157 _delegate: Default::default(),
1158 _additional_params: Default::default(),
1159 _scopes: Default::default(),
1160 }
1161 }
1162
1163 /// Create a builder to help you perform the following task:
1164 ///
1165 /// Returns a function with the given name from the requested project.
1166 ///
1167 /// # Arguments
1168 ///
1169 /// * `name` - Required. The name of the function which details should be obtained.
1170 pub fn locations_functions_get(&self, name: &str) -> ProjectLocationFunctionGetCall<'a, C> {
1171 ProjectLocationFunctionGetCall {
1172 hub: self.hub,
1173 _name: name.to_string(),
1174 _version_id: Default::default(),
1175 _delegate: Default::default(),
1176 _additional_params: Default::default(),
1177 _scopes: Default::default(),
1178 }
1179 }
1180
1181 /// Create a builder to help you perform the following task:
1182 ///
1183 /// Gets the IAM access control policy for a function. Returns an empty policy if the function exists and does not have a policy set.
1184 ///
1185 /// # Arguments
1186 ///
1187 /// * `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.
1188 pub fn locations_functions_get_iam_policy(
1189 &self,
1190 resource: &str,
1191 ) -> ProjectLocationFunctionGetIamPolicyCall<'a, C> {
1192 ProjectLocationFunctionGetIamPolicyCall {
1193 hub: self.hub,
1194 _resource: resource.to_string(),
1195 _options_requested_policy_version: Default::default(),
1196 _delegate: Default::default(),
1197 _additional_params: Default::default(),
1198 _scopes: Default::default(),
1199 }
1200 }
1201
1202 /// Create a builder to help you perform the following task:
1203 ///
1204 /// Returns a list of functions that belong to the requested project.
1205 ///
1206 /// # Arguments
1207 ///
1208 /// * `parent` - The project and location from which the function should be listed, specified in the format `projects/*/locations/*` If you want to list functions in all locations, use "-" in place of a location. When listing functions in all locations, if one or more location(s) are unreachable, the response will contain functions from all reachable locations along with the names of any unreachable locations.
1209 pub fn locations_functions_list(&self, parent: &str) -> ProjectLocationFunctionListCall<'a, C> {
1210 ProjectLocationFunctionListCall {
1211 hub: self.hub,
1212 _parent: parent.to_string(),
1213 _page_token: Default::default(),
1214 _page_size: Default::default(),
1215 _delegate: Default::default(),
1216 _additional_params: Default::default(),
1217 _scopes: Default::default(),
1218 }
1219 }
1220
1221 /// Create a builder to help you perform the following task:
1222 ///
1223 /// Updates existing function.
1224 ///
1225 /// # Arguments
1226 ///
1227 /// * `request` - No description provided.
1228 /// * `name` - A user-defined name of the function. Function names must be unique globally and match pattern `projects/*/locations/*/functions/*`
1229 pub fn locations_functions_patch(
1230 &self,
1231 request: CloudFunction,
1232 name: &str,
1233 ) -> ProjectLocationFunctionPatchCall<'a, C> {
1234 ProjectLocationFunctionPatchCall {
1235 hub: self.hub,
1236 _request: request,
1237 _name: name.to_string(),
1238 _update_mask: Default::default(),
1239 _delegate: Default::default(),
1240 _additional_params: Default::default(),
1241 _scopes: Default::default(),
1242 }
1243 }
1244
1245 /// Create a builder to help you perform the following task:
1246 ///
1247 /// Sets the IAM access control policy on the specified function. Replaces any existing policy.
1248 ///
1249 /// # Arguments
1250 ///
1251 /// * `request` - No description provided.
1252 /// * `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.
1253 pub fn locations_functions_set_iam_policy(
1254 &self,
1255 request: SetIamPolicyRequest,
1256 resource: &str,
1257 ) -> ProjectLocationFunctionSetIamPolicyCall<'a, C> {
1258 ProjectLocationFunctionSetIamPolicyCall {
1259 hub: self.hub,
1260 _request: request,
1261 _resource: resource.to_string(),
1262 _delegate: Default::default(),
1263 _additional_params: Default::default(),
1264 _scopes: Default::default(),
1265 }
1266 }
1267
1268 /// Create a builder to help you perform the following task:
1269 ///
1270 /// Tests the specified permissions against the IAM access control policy for a function. If the function does not exist, this will return an empty set of permissions, not a NOT_FOUND error.
1271 ///
1272 /// # Arguments
1273 ///
1274 /// * `request` - No description provided.
1275 /// * `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.
1276 pub fn locations_functions_test_iam_permissions(
1277 &self,
1278 request: TestIamPermissionsRequest,
1279 resource: &str,
1280 ) -> ProjectLocationFunctionTestIamPermissionCall<'a, C> {
1281 ProjectLocationFunctionTestIamPermissionCall {
1282 hub: self.hub,
1283 _request: request,
1284 _resource: resource.to_string(),
1285 _delegate: Default::default(),
1286 _additional_params: Default::default(),
1287 _scopes: Default::default(),
1288 }
1289 }
1290
1291 /// Create a builder to help you perform the following task:
1292 ///
1293 /// Lists information about the supported locations for this service.
1294 ///
1295 /// # Arguments
1296 ///
1297 /// * `name` - The resource that owns the locations collection, if applicable.
1298 pub fn locations_list(&self, name: &str) -> ProjectLocationListCall<'a, C> {
1299 ProjectLocationListCall {
1300 hub: self.hub,
1301 _name: name.to_string(),
1302 _page_token: Default::default(),
1303 _page_size: Default::default(),
1304 _filter: Default::default(),
1305 _extra_location_types: Default::default(),
1306 _delegate: Default::default(),
1307 _additional_params: Default::default(),
1308 _scopes: Default::default(),
1309 }
1310 }
1311}
1312
1313// ###################
1314// CallBuilders ###
1315// #################
1316
1317/// 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.
1318///
1319/// A builder for the *get* method supported by a *operation* resource.
1320/// It is not used directly, but through a [`OperationMethods`] instance.
1321///
1322/// # Example
1323///
1324/// Instantiate a resource method builder
1325///
1326/// ```test_harness,no_run
1327/// # extern crate hyper;
1328/// # extern crate hyper_rustls;
1329/// # extern crate google_cloudfunctions1 as cloudfunctions1;
1330/// # async fn dox() {
1331/// # use cloudfunctions1::{CloudFunctions, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1332///
1333/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1334/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1335/// # .with_native_roots()
1336/// # .unwrap()
1337/// # .https_only()
1338/// # .enable_http2()
1339/// # .build();
1340///
1341/// # let executor = hyper_util::rt::TokioExecutor::new();
1342/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1343/// # secret,
1344/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1345/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1346/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1347/// # ),
1348/// # ).build().await.unwrap();
1349///
1350/// # let client = hyper_util::client::legacy::Client::builder(
1351/// # hyper_util::rt::TokioExecutor::new()
1352/// # )
1353/// # .build(
1354/// # hyper_rustls::HttpsConnectorBuilder::new()
1355/// # .with_native_roots()
1356/// # .unwrap()
1357/// # .https_or_http()
1358/// # .enable_http2()
1359/// # .build()
1360/// # );
1361/// # let mut hub = CloudFunctions::new(client, auth);
1362/// // You can configure optional parameters by calling the respective setters at will, and
1363/// // execute the final call using `doit()`.
1364/// // Values shown here are possibly random and not representative !
1365/// let result = hub.operations().get("name")
1366/// .doit().await;
1367/// # }
1368/// ```
1369pub struct OperationGetCall<'a, C>
1370where
1371 C: 'a,
1372{
1373 hub: &'a CloudFunctions<C>,
1374 _name: String,
1375 _delegate: Option<&'a mut dyn common::Delegate>,
1376 _additional_params: HashMap<String, String>,
1377 _scopes: BTreeSet<String>,
1378}
1379
1380impl<'a, C> common::CallBuilder for OperationGetCall<'a, C> {}
1381
1382impl<'a, C> OperationGetCall<'a, C>
1383where
1384 C: common::Connector,
1385{
1386 /// Perform the operation you have build so far.
1387 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
1388 use std::borrow::Cow;
1389 use std::io::{Read, Seek};
1390
1391 use common::{url::Params, ToParts};
1392 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1393
1394 let mut dd = common::DefaultDelegate;
1395 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1396 dlg.begin(common::MethodInfo {
1397 id: "cloudfunctions.operations.get",
1398 http_method: hyper::Method::GET,
1399 });
1400
1401 for &field in ["alt", "name"].iter() {
1402 if self._additional_params.contains_key(field) {
1403 dlg.finished(false);
1404 return Err(common::Error::FieldClash(field));
1405 }
1406 }
1407
1408 let mut params = Params::with_capacity(3 + self._additional_params.len());
1409 params.push("name", self._name);
1410
1411 params.extend(self._additional_params.iter());
1412
1413 params.push("alt", "json");
1414 let mut url = self.hub._base_url.clone() + "v1/{+name}";
1415 if self._scopes.is_empty() {
1416 self._scopes
1417 .insert(Scope::CloudPlatform.as_ref().to_string());
1418 }
1419
1420 #[allow(clippy::single_element_loop)]
1421 for &(find_this, param_name) in [("{+name}", "name")].iter() {
1422 url = params.uri_replacement(url, param_name, find_this, true);
1423 }
1424 {
1425 let to_remove = ["name"];
1426 params.remove_params(&to_remove);
1427 }
1428
1429 let url = params.parse_with_url(&url);
1430
1431 loop {
1432 let token = match self
1433 .hub
1434 .auth
1435 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1436 .await
1437 {
1438 Ok(token) => token,
1439 Err(e) => match dlg.token(e) {
1440 Ok(token) => token,
1441 Err(e) => {
1442 dlg.finished(false);
1443 return Err(common::Error::MissingToken(e));
1444 }
1445 },
1446 };
1447 let mut req_result = {
1448 let client = &self.hub.client;
1449 dlg.pre_request();
1450 let mut req_builder = hyper::Request::builder()
1451 .method(hyper::Method::GET)
1452 .uri(url.as_str())
1453 .header(USER_AGENT, self.hub._user_agent.clone());
1454
1455 if let Some(token) = token.as_ref() {
1456 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1457 }
1458
1459 let request = req_builder
1460 .header(CONTENT_LENGTH, 0_u64)
1461 .body(common::to_body::<String>(None));
1462
1463 client.request(request.unwrap()).await
1464 };
1465
1466 match req_result {
1467 Err(err) => {
1468 if let common::Retry::After(d) = dlg.http_error(&err) {
1469 sleep(d).await;
1470 continue;
1471 }
1472 dlg.finished(false);
1473 return Err(common::Error::HttpError(err));
1474 }
1475 Ok(res) => {
1476 let (mut parts, body) = res.into_parts();
1477 let mut body = common::Body::new(body);
1478 if !parts.status.is_success() {
1479 let bytes = common::to_bytes(body).await.unwrap_or_default();
1480 let error = serde_json::from_str(&common::to_string(&bytes));
1481 let response = common::to_response(parts, bytes.into());
1482
1483 if let common::Retry::After(d) =
1484 dlg.http_failure(&response, error.as_ref().ok())
1485 {
1486 sleep(d).await;
1487 continue;
1488 }
1489
1490 dlg.finished(false);
1491
1492 return Err(match error {
1493 Ok(value) => common::Error::BadRequest(value),
1494 _ => common::Error::Failure(response),
1495 });
1496 }
1497 let response = {
1498 let bytes = common::to_bytes(body).await.unwrap_or_default();
1499 let encoded = common::to_string(&bytes);
1500 match serde_json::from_str(&encoded) {
1501 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1502 Err(error) => {
1503 dlg.response_json_decode_error(&encoded, &error);
1504 return Err(common::Error::JsonDecodeError(
1505 encoded.to_string(),
1506 error,
1507 ));
1508 }
1509 }
1510 };
1511
1512 dlg.finished(true);
1513 return Ok(response);
1514 }
1515 }
1516 }
1517 }
1518
1519 /// The name of the operation resource.
1520 ///
1521 /// Sets the *name* path property to the given value.
1522 ///
1523 /// Even though the property as already been set when instantiating this call,
1524 /// we provide this method for API completeness.
1525 pub fn name(mut self, new_value: &str) -> OperationGetCall<'a, C> {
1526 self._name = new_value.to_string();
1527 self
1528 }
1529 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1530 /// while executing the actual API request.
1531 ///
1532 /// ````text
1533 /// It should be used to handle progress information, and to implement a certain level of resilience.
1534 /// ````
1535 ///
1536 /// Sets the *delegate* property to the given value.
1537 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> OperationGetCall<'a, C> {
1538 self._delegate = Some(new_value);
1539 self
1540 }
1541
1542 /// Set any additional parameter of the query string used in the request.
1543 /// It should be used to set parameters which are not yet available through their own
1544 /// setters.
1545 ///
1546 /// Please note that this method must not be used to set any of the known parameters
1547 /// which have their own setter method. If done anyway, the request will fail.
1548 ///
1549 /// # Additional Parameters
1550 ///
1551 /// * *$.xgafv* (query-string) - V1 error format.
1552 /// * *access_token* (query-string) - OAuth access token.
1553 /// * *alt* (query-string) - Data format for response.
1554 /// * *callback* (query-string) - JSONP
1555 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1556 /// * *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.
1557 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1558 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1559 /// * *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.
1560 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1561 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1562 pub fn param<T>(mut self, name: T, value: T) -> OperationGetCall<'a, C>
1563 where
1564 T: AsRef<str>,
1565 {
1566 self._additional_params
1567 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1568 self
1569 }
1570
1571 /// Identifies the authorization scope for the method you are building.
1572 ///
1573 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1574 /// [`Scope::CloudPlatform`].
1575 ///
1576 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1577 /// tokens for more than one scope.
1578 ///
1579 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1580 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1581 /// sufficient, a read-write scope will do as well.
1582 pub fn add_scope<St>(mut self, scope: St) -> OperationGetCall<'a, C>
1583 where
1584 St: AsRef<str>,
1585 {
1586 self._scopes.insert(String::from(scope.as_ref()));
1587 self
1588 }
1589 /// Identifies the authorization scope(s) for the method you are building.
1590 ///
1591 /// See [`Self::add_scope()`] for details.
1592 pub fn add_scopes<I, St>(mut self, scopes: I) -> OperationGetCall<'a, C>
1593 where
1594 I: IntoIterator<Item = St>,
1595 St: AsRef<str>,
1596 {
1597 self._scopes
1598 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1599 self
1600 }
1601
1602 /// Removes all scopes, and no default scope will be used either.
1603 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1604 /// for details).
1605 pub fn clear_scopes(mut self) -> OperationGetCall<'a, C> {
1606 self._scopes.clear();
1607 self
1608 }
1609}
1610
1611/// Lists operations that match the specified filter in the request. If the server doesn't support this method, it returns `UNIMPLEMENTED`.
1612///
1613/// A builder for the *list* method supported by a *operation* resource.
1614/// It is not used directly, but through a [`OperationMethods`] instance.
1615///
1616/// # Example
1617///
1618/// Instantiate a resource method builder
1619///
1620/// ```test_harness,no_run
1621/// # extern crate hyper;
1622/// # extern crate hyper_rustls;
1623/// # extern crate google_cloudfunctions1 as cloudfunctions1;
1624/// # async fn dox() {
1625/// # use cloudfunctions1::{CloudFunctions, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1626///
1627/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1628/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1629/// # .with_native_roots()
1630/// # .unwrap()
1631/// # .https_only()
1632/// # .enable_http2()
1633/// # .build();
1634///
1635/// # let executor = hyper_util::rt::TokioExecutor::new();
1636/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1637/// # secret,
1638/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1639/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1640/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1641/// # ),
1642/// # ).build().await.unwrap();
1643///
1644/// # let client = hyper_util::client::legacy::Client::builder(
1645/// # hyper_util::rt::TokioExecutor::new()
1646/// # )
1647/// # .build(
1648/// # hyper_rustls::HttpsConnectorBuilder::new()
1649/// # .with_native_roots()
1650/// # .unwrap()
1651/// # .https_or_http()
1652/// # .enable_http2()
1653/// # .build()
1654/// # );
1655/// # let mut hub = CloudFunctions::new(client, auth);
1656/// // You can configure optional parameters by calling the respective setters at will, and
1657/// // execute the final call using `doit()`.
1658/// // Values shown here are possibly random and not representative !
1659/// let result = hub.operations().list()
1660/// .return_partial_success(false)
1661/// .page_token("amet")
1662/// .page_size(-20)
1663/// .name("ipsum")
1664/// .filter("sed")
1665/// .doit().await;
1666/// # }
1667/// ```
1668pub struct OperationListCall<'a, C>
1669where
1670 C: 'a,
1671{
1672 hub: &'a CloudFunctions<C>,
1673 _return_partial_success: Option<bool>,
1674 _page_token: Option<String>,
1675 _page_size: Option<i32>,
1676 _name: Option<String>,
1677 _filter: Option<String>,
1678 _delegate: Option<&'a mut dyn common::Delegate>,
1679 _additional_params: HashMap<String, String>,
1680 _scopes: BTreeSet<String>,
1681}
1682
1683impl<'a, C> common::CallBuilder for OperationListCall<'a, C> {}
1684
1685impl<'a, C> OperationListCall<'a, C>
1686where
1687 C: common::Connector,
1688{
1689 /// Perform the operation you have build so far.
1690 pub async fn doit(mut self) -> common::Result<(common::Response, ListOperationsResponse)> {
1691 use std::borrow::Cow;
1692 use std::io::{Read, Seek};
1693
1694 use common::{url::Params, ToParts};
1695 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1696
1697 let mut dd = common::DefaultDelegate;
1698 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1699 dlg.begin(common::MethodInfo {
1700 id: "cloudfunctions.operations.list",
1701 http_method: hyper::Method::GET,
1702 });
1703
1704 for &field in [
1705 "alt",
1706 "returnPartialSuccess",
1707 "pageToken",
1708 "pageSize",
1709 "name",
1710 "filter",
1711 ]
1712 .iter()
1713 {
1714 if self._additional_params.contains_key(field) {
1715 dlg.finished(false);
1716 return Err(common::Error::FieldClash(field));
1717 }
1718 }
1719
1720 let mut params = Params::with_capacity(7 + self._additional_params.len());
1721 if let Some(value) = self._return_partial_success.as_ref() {
1722 params.push("returnPartialSuccess", value.to_string());
1723 }
1724 if let Some(value) = self._page_token.as_ref() {
1725 params.push("pageToken", value);
1726 }
1727 if let Some(value) = self._page_size.as_ref() {
1728 params.push("pageSize", value.to_string());
1729 }
1730 if let Some(value) = self._name.as_ref() {
1731 params.push("name", value);
1732 }
1733 if let Some(value) = self._filter.as_ref() {
1734 params.push("filter", value);
1735 }
1736
1737 params.extend(self._additional_params.iter());
1738
1739 params.push("alt", "json");
1740 let mut url = self.hub._base_url.clone() + "v1/operations";
1741 if self._scopes.is_empty() {
1742 self._scopes
1743 .insert(Scope::CloudPlatform.as_ref().to_string());
1744 }
1745
1746 let url = params.parse_with_url(&url);
1747
1748 loop {
1749 let token = match self
1750 .hub
1751 .auth
1752 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1753 .await
1754 {
1755 Ok(token) => token,
1756 Err(e) => match dlg.token(e) {
1757 Ok(token) => token,
1758 Err(e) => {
1759 dlg.finished(false);
1760 return Err(common::Error::MissingToken(e));
1761 }
1762 },
1763 };
1764 let mut req_result = {
1765 let client = &self.hub.client;
1766 dlg.pre_request();
1767 let mut req_builder = hyper::Request::builder()
1768 .method(hyper::Method::GET)
1769 .uri(url.as_str())
1770 .header(USER_AGENT, self.hub._user_agent.clone());
1771
1772 if let Some(token) = token.as_ref() {
1773 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1774 }
1775
1776 let request = req_builder
1777 .header(CONTENT_LENGTH, 0_u64)
1778 .body(common::to_body::<String>(None));
1779
1780 client.request(request.unwrap()).await
1781 };
1782
1783 match req_result {
1784 Err(err) => {
1785 if let common::Retry::After(d) = dlg.http_error(&err) {
1786 sleep(d).await;
1787 continue;
1788 }
1789 dlg.finished(false);
1790 return Err(common::Error::HttpError(err));
1791 }
1792 Ok(res) => {
1793 let (mut parts, body) = res.into_parts();
1794 let mut body = common::Body::new(body);
1795 if !parts.status.is_success() {
1796 let bytes = common::to_bytes(body).await.unwrap_or_default();
1797 let error = serde_json::from_str(&common::to_string(&bytes));
1798 let response = common::to_response(parts, bytes.into());
1799
1800 if let common::Retry::After(d) =
1801 dlg.http_failure(&response, error.as_ref().ok())
1802 {
1803 sleep(d).await;
1804 continue;
1805 }
1806
1807 dlg.finished(false);
1808
1809 return Err(match error {
1810 Ok(value) => common::Error::BadRequest(value),
1811 _ => common::Error::Failure(response),
1812 });
1813 }
1814 let response = {
1815 let bytes = common::to_bytes(body).await.unwrap_or_default();
1816 let encoded = common::to_string(&bytes);
1817 match serde_json::from_str(&encoded) {
1818 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1819 Err(error) => {
1820 dlg.response_json_decode_error(&encoded, &error);
1821 return Err(common::Error::JsonDecodeError(
1822 encoded.to_string(),
1823 error,
1824 ));
1825 }
1826 }
1827 };
1828
1829 dlg.finished(true);
1830 return Ok(response);
1831 }
1832 }
1833 }
1834 }
1835
1836 /// 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.
1837 ///
1838 /// Sets the *return partial success* query property to the given value.
1839 pub fn return_partial_success(mut self, new_value: bool) -> OperationListCall<'a, C> {
1840 self._return_partial_success = Some(new_value);
1841 self
1842 }
1843 /// The standard list page token.
1844 ///
1845 /// Sets the *page token* query property to the given value.
1846 pub fn page_token(mut self, new_value: &str) -> OperationListCall<'a, C> {
1847 self._page_token = Some(new_value.to_string());
1848 self
1849 }
1850 /// The standard list page size.
1851 ///
1852 /// Sets the *page size* query property to the given value.
1853 pub fn page_size(mut self, new_value: i32) -> OperationListCall<'a, C> {
1854 self._page_size = Some(new_value);
1855 self
1856 }
1857 /// The name of the operation's parent resource.
1858 ///
1859 /// Sets the *name* query property to the given value.
1860 pub fn name(mut self, new_value: &str) -> OperationListCall<'a, C> {
1861 self._name = Some(new_value.to_string());
1862 self
1863 }
1864 /// The standard list filter.
1865 ///
1866 /// Sets the *filter* query property to the given value.
1867 pub fn filter(mut self, new_value: &str) -> OperationListCall<'a, C> {
1868 self._filter = Some(new_value.to_string());
1869 self
1870 }
1871 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1872 /// while executing the actual API request.
1873 ///
1874 /// ````text
1875 /// It should be used to handle progress information, and to implement a certain level of resilience.
1876 /// ````
1877 ///
1878 /// Sets the *delegate* property to the given value.
1879 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> OperationListCall<'a, C> {
1880 self._delegate = Some(new_value);
1881 self
1882 }
1883
1884 /// Set any additional parameter of the query string used in the request.
1885 /// It should be used to set parameters which are not yet available through their own
1886 /// setters.
1887 ///
1888 /// Please note that this method must not be used to set any of the known parameters
1889 /// which have their own setter method. If done anyway, the request will fail.
1890 ///
1891 /// # Additional Parameters
1892 ///
1893 /// * *$.xgafv* (query-string) - V1 error format.
1894 /// * *access_token* (query-string) - OAuth access token.
1895 /// * *alt* (query-string) - Data format for response.
1896 /// * *callback* (query-string) - JSONP
1897 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1898 /// * *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.
1899 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1900 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1901 /// * *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.
1902 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1903 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1904 pub fn param<T>(mut self, name: T, value: T) -> OperationListCall<'a, C>
1905 where
1906 T: AsRef<str>,
1907 {
1908 self._additional_params
1909 .insert(name.as_ref().to_string(), value.as_ref().to_string());
1910 self
1911 }
1912
1913 /// Identifies the authorization scope for the method you are building.
1914 ///
1915 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1916 /// [`Scope::CloudPlatform`].
1917 ///
1918 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1919 /// tokens for more than one scope.
1920 ///
1921 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1922 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1923 /// sufficient, a read-write scope will do as well.
1924 pub fn add_scope<St>(mut self, scope: St) -> OperationListCall<'a, C>
1925 where
1926 St: AsRef<str>,
1927 {
1928 self._scopes.insert(String::from(scope.as_ref()));
1929 self
1930 }
1931 /// Identifies the authorization scope(s) for the method you are building.
1932 ///
1933 /// See [`Self::add_scope()`] for details.
1934 pub fn add_scopes<I, St>(mut self, scopes: I) -> OperationListCall<'a, C>
1935 where
1936 I: IntoIterator<Item = St>,
1937 St: AsRef<str>,
1938 {
1939 self._scopes
1940 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1941 self
1942 }
1943
1944 /// Removes all scopes, and no default scope will be used either.
1945 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1946 /// for details).
1947 pub fn clear_scopes(mut self) -> OperationListCall<'a, C> {
1948 self._scopes.clear();
1949 self
1950 }
1951}
1952
1953/// Synchronously invokes a deployed Cloud Function. To be used for testing purposes as very limited traffic is allowed. For more information on the actual limits, refer to [Rate Limits](https://cloud.google.com/functions/quotas#rate_limits).
1954///
1955/// A builder for the *locations.functions.call* method supported by a *project* resource.
1956/// It is not used directly, but through a [`ProjectMethods`] instance.
1957///
1958/// # Example
1959///
1960/// Instantiate a resource method builder
1961///
1962/// ```test_harness,no_run
1963/// # extern crate hyper;
1964/// # extern crate hyper_rustls;
1965/// # extern crate google_cloudfunctions1 as cloudfunctions1;
1966/// use cloudfunctions1::api::CallFunctionRequest;
1967/// # async fn dox() {
1968/// # use cloudfunctions1::{CloudFunctions, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1969///
1970/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1971/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1972/// # .with_native_roots()
1973/// # .unwrap()
1974/// # .https_only()
1975/// # .enable_http2()
1976/// # .build();
1977///
1978/// # let executor = hyper_util::rt::TokioExecutor::new();
1979/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1980/// # secret,
1981/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1982/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1983/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1984/// # ),
1985/// # ).build().await.unwrap();
1986///
1987/// # let client = hyper_util::client::legacy::Client::builder(
1988/// # hyper_util::rt::TokioExecutor::new()
1989/// # )
1990/// # .build(
1991/// # hyper_rustls::HttpsConnectorBuilder::new()
1992/// # .with_native_roots()
1993/// # .unwrap()
1994/// # .https_or_http()
1995/// # .enable_http2()
1996/// # .build()
1997/// # );
1998/// # let mut hub = CloudFunctions::new(client, auth);
1999/// // As the method needs a request, you would usually fill it with the desired information
2000/// // into the respective structure. Some of the parts shown here might not be applicable !
2001/// // Values shown here are possibly random and not representative !
2002/// let mut req = CallFunctionRequest::default();
2003///
2004/// // You can configure optional parameters by calling the respective setters at will, and
2005/// // execute the final call using `doit()`.
2006/// // Values shown here are possibly random and not representative !
2007/// let result = hub.projects().locations_functions_call(req, "name")
2008/// .doit().await;
2009/// # }
2010/// ```
2011pub struct ProjectLocationFunctionCallCall<'a, C>
2012where
2013 C: 'a,
2014{
2015 hub: &'a CloudFunctions<C>,
2016 _request: CallFunctionRequest,
2017 _name: String,
2018 _delegate: Option<&'a mut dyn common::Delegate>,
2019 _additional_params: HashMap<String, String>,
2020 _scopes: BTreeSet<String>,
2021}
2022
2023impl<'a, C> common::CallBuilder for ProjectLocationFunctionCallCall<'a, C> {}
2024
2025impl<'a, C> ProjectLocationFunctionCallCall<'a, C>
2026where
2027 C: common::Connector,
2028{
2029 /// Perform the operation you have build so far.
2030 pub async fn doit(mut self) -> common::Result<(common::Response, CallFunctionResponse)> {
2031 use std::borrow::Cow;
2032 use std::io::{Read, Seek};
2033
2034 use common::{url::Params, ToParts};
2035 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2036
2037 let mut dd = common::DefaultDelegate;
2038 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2039 dlg.begin(common::MethodInfo {
2040 id: "cloudfunctions.projects.locations.functions.call",
2041 http_method: hyper::Method::POST,
2042 });
2043
2044 for &field in ["alt", "name"].iter() {
2045 if self._additional_params.contains_key(field) {
2046 dlg.finished(false);
2047 return Err(common::Error::FieldClash(field));
2048 }
2049 }
2050
2051 let mut params = Params::with_capacity(4 + self._additional_params.len());
2052 params.push("name", self._name);
2053
2054 params.extend(self._additional_params.iter());
2055
2056 params.push("alt", "json");
2057 let mut url = self.hub._base_url.clone() + "v1/{+name}:call";
2058 if self._scopes.is_empty() {
2059 self._scopes
2060 .insert(Scope::CloudPlatform.as_ref().to_string());
2061 }
2062
2063 #[allow(clippy::single_element_loop)]
2064 for &(find_this, param_name) in [("{+name}", "name")].iter() {
2065 url = params.uri_replacement(url, param_name, find_this, true);
2066 }
2067 {
2068 let to_remove = ["name"];
2069 params.remove_params(&to_remove);
2070 }
2071
2072 let url = params.parse_with_url(&url);
2073
2074 let mut json_mime_type = mime::APPLICATION_JSON;
2075 let mut request_value_reader = {
2076 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2077 common::remove_json_null_values(&mut value);
2078 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2079 serde_json::to_writer(&mut dst, &value).unwrap();
2080 dst
2081 };
2082 let request_size = request_value_reader
2083 .seek(std::io::SeekFrom::End(0))
2084 .unwrap();
2085 request_value_reader
2086 .seek(std::io::SeekFrom::Start(0))
2087 .unwrap();
2088
2089 loop {
2090 let token = match self
2091 .hub
2092 .auth
2093 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2094 .await
2095 {
2096 Ok(token) => token,
2097 Err(e) => match dlg.token(e) {
2098 Ok(token) => token,
2099 Err(e) => {
2100 dlg.finished(false);
2101 return Err(common::Error::MissingToken(e));
2102 }
2103 },
2104 };
2105 request_value_reader
2106 .seek(std::io::SeekFrom::Start(0))
2107 .unwrap();
2108 let mut req_result = {
2109 let client = &self.hub.client;
2110 dlg.pre_request();
2111 let mut req_builder = hyper::Request::builder()
2112 .method(hyper::Method::POST)
2113 .uri(url.as_str())
2114 .header(USER_AGENT, self.hub._user_agent.clone());
2115
2116 if let Some(token) = token.as_ref() {
2117 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2118 }
2119
2120 let request = req_builder
2121 .header(CONTENT_TYPE, json_mime_type.to_string())
2122 .header(CONTENT_LENGTH, request_size as u64)
2123 .body(common::to_body(
2124 request_value_reader.get_ref().clone().into(),
2125 ));
2126
2127 client.request(request.unwrap()).await
2128 };
2129
2130 match req_result {
2131 Err(err) => {
2132 if let common::Retry::After(d) = dlg.http_error(&err) {
2133 sleep(d).await;
2134 continue;
2135 }
2136 dlg.finished(false);
2137 return Err(common::Error::HttpError(err));
2138 }
2139 Ok(res) => {
2140 let (mut parts, body) = res.into_parts();
2141 let mut body = common::Body::new(body);
2142 if !parts.status.is_success() {
2143 let bytes = common::to_bytes(body).await.unwrap_or_default();
2144 let error = serde_json::from_str(&common::to_string(&bytes));
2145 let response = common::to_response(parts, bytes.into());
2146
2147 if let common::Retry::After(d) =
2148 dlg.http_failure(&response, error.as_ref().ok())
2149 {
2150 sleep(d).await;
2151 continue;
2152 }
2153
2154 dlg.finished(false);
2155
2156 return Err(match error {
2157 Ok(value) => common::Error::BadRequest(value),
2158 _ => common::Error::Failure(response),
2159 });
2160 }
2161 let response = {
2162 let bytes = common::to_bytes(body).await.unwrap_or_default();
2163 let encoded = common::to_string(&bytes);
2164 match serde_json::from_str(&encoded) {
2165 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2166 Err(error) => {
2167 dlg.response_json_decode_error(&encoded, &error);
2168 return Err(common::Error::JsonDecodeError(
2169 encoded.to_string(),
2170 error,
2171 ));
2172 }
2173 }
2174 };
2175
2176 dlg.finished(true);
2177 return Ok(response);
2178 }
2179 }
2180 }
2181 }
2182
2183 ///
2184 /// Sets the *request* property to the given value.
2185 ///
2186 /// Even though the property as already been set when instantiating this call,
2187 /// we provide this method for API completeness.
2188 pub fn request(
2189 mut self,
2190 new_value: CallFunctionRequest,
2191 ) -> ProjectLocationFunctionCallCall<'a, C> {
2192 self._request = new_value;
2193 self
2194 }
2195 /// Required. The name of the function to be called.
2196 ///
2197 /// Sets the *name* path property to the given value.
2198 ///
2199 /// Even though the property as already been set when instantiating this call,
2200 /// we provide this method for API completeness.
2201 pub fn name(mut self, new_value: &str) -> ProjectLocationFunctionCallCall<'a, C> {
2202 self._name = new_value.to_string();
2203 self
2204 }
2205 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2206 /// while executing the actual API request.
2207 ///
2208 /// ````text
2209 /// It should be used to handle progress information, and to implement a certain level of resilience.
2210 /// ````
2211 ///
2212 /// Sets the *delegate* property to the given value.
2213 pub fn delegate(
2214 mut self,
2215 new_value: &'a mut dyn common::Delegate,
2216 ) -> ProjectLocationFunctionCallCall<'a, C> {
2217 self._delegate = Some(new_value);
2218 self
2219 }
2220
2221 /// Set any additional parameter of the query string used in the request.
2222 /// It should be used to set parameters which are not yet available through their own
2223 /// setters.
2224 ///
2225 /// Please note that this method must not be used to set any of the known parameters
2226 /// which have their own setter method. If done anyway, the request will fail.
2227 ///
2228 /// # Additional Parameters
2229 ///
2230 /// * *$.xgafv* (query-string) - V1 error format.
2231 /// * *access_token* (query-string) - OAuth access token.
2232 /// * *alt* (query-string) - Data format for response.
2233 /// * *callback* (query-string) - JSONP
2234 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2235 /// * *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.
2236 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2237 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2238 /// * *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.
2239 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2240 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2241 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationFunctionCallCall<'a, C>
2242 where
2243 T: AsRef<str>,
2244 {
2245 self._additional_params
2246 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2247 self
2248 }
2249
2250 /// Identifies the authorization scope for the method you are building.
2251 ///
2252 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2253 /// [`Scope::CloudPlatform`].
2254 ///
2255 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2256 /// tokens for more than one scope.
2257 ///
2258 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2259 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2260 /// sufficient, a read-write scope will do as well.
2261 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationFunctionCallCall<'a, C>
2262 where
2263 St: AsRef<str>,
2264 {
2265 self._scopes.insert(String::from(scope.as_ref()));
2266 self
2267 }
2268 /// Identifies the authorization scope(s) for the method you are building.
2269 ///
2270 /// See [`Self::add_scope()`] for details.
2271 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationFunctionCallCall<'a, C>
2272 where
2273 I: IntoIterator<Item = St>,
2274 St: AsRef<str>,
2275 {
2276 self._scopes
2277 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2278 self
2279 }
2280
2281 /// Removes all scopes, and no default scope will be used either.
2282 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2283 /// for details).
2284 pub fn clear_scopes(mut self) -> ProjectLocationFunctionCallCall<'a, C> {
2285 self._scopes.clear();
2286 self
2287 }
2288}
2289
2290/// Creates a new function. If a function with the given name already exists in the specified project, the long running operation will return `ALREADY_EXISTS` error.
2291///
2292/// A builder for the *locations.functions.create* method supported by a *project* resource.
2293/// It is not used directly, but through a [`ProjectMethods`] instance.
2294///
2295/// # Example
2296///
2297/// Instantiate a resource method builder
2298///
2299/// ```test_harness,no_run
2300/// # extern crate hyper;
2301/// # extern crate hyper_rustls;
2302/// # extern crate google_cloudfunctions1 as cloudfunctions1;
2303/// use cloudfunctions1::api::CloudFunction;
2304/// # async fn dox() {
2305/// # use cloudfunctions1::{CloudFunctions, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2306///
2307/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2308/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2309/// # .with_native_roots()
2310/// # .unwrap()
2311/// # .https_only()
2312/// # .enable_http2()
2313/// # .build();
2314///
2315/// # let executor = hyper_util::rt::TokioExecutor::new();
2316/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2317/// # secret,
2318/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2319/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2320/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2321/// # ),
2322/// # ).build().await.unwrap();
2323///
2324/// # let client = hyper_util::client::legacy::Client::builder(
2325/// # hyper_util::rt::TokioExecutor::new()
2326/// # )
2327/// # .build(
2328/// # hyper_rustls::HttpsConnectorBuilder::new()
2329/// # .with_native_roots()
2330/// # .unwrap()
2331/// # .https_or_http()
2332/// # .enable_http2()
2333/// # .build()
2334/// # );
2335/// # let mut hub = CloudFunctions::new(client, auth);
2336/// // As the method needs a request, you would usually fill it with the desired information
2337/// // into the respective structure. Some of the parts shown here might not be applicable !
2338/// // Values shown here are possibly random and not representative !
2339/// let mut req = CloudFunction::default();
2340///
2341/// // You can configure optional parameters by calling the respective setters at will, and
2342/// // execute the final call using `doit()`.
2343/// // Values shown here are possibly random and not representative !
2344/// let result = hub.projects().locations_functions_create(req, "location")
2345/// .doit().await;
2346/// # }
2347/// ```
2348pub struct ProjectLocationFunctionCreateCall<'a, C>
2349where
2350 C: 'a,
2351{
2352 hub: &'a CloudFunctions<C>,
2353 _request: CloudFunction,
2354 _location: String,
2355 _delegate: Option<&'a mut dyn common::Delegate>,
2356 _additional_params: HashMap<String, String>,
2357 _scopes: BTreeSet<String>,
2358}
2359
2360impl<'a, C> common::CallBuilder for ProjectLocationFunctionCreateCall<'a, C> {}
2361
2362impl<'a, C> ProjectLocationFunctionCreateCall<'a, C>
2363where
2364 C: common::Connector,
2365{
2366 /// Perform the operation you have build so far.
2367 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
2368 use std::borrow::Cow;
2369 use std::io::{Read, Seek};
2370
2371 use common::{url::Params, ToParts};
2372 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2373
2374 let mut dd = common::DefaultDelegate;
2375 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2376 dlg.begin(common::MethodInfo {
2377 id: "cloudfunctions.projects.locations.functions.create",
2378 http_method: hyper::Method::POST,
2379 });
2380
2381 for &field in ["alt", "location"].iter() {
2382 if self._additional_params.contains_key(field) {
2383 dlg.finished(false);
2384 return Err(common::Error::FieldClash(field));
2385 }
2386 }
2387
2388 let mut params = Params::with_capacity(4 + self._additional_params.len());
2389 params.push("location", self._location);
2390
2391 params.extend(self._additional_params.iter());
2392
2393 params.push("alt", "json");
2394 let mut url = self.hub._base_url.clone() + "v1/{+location}/functions";
2395 if self._scopes.is_empty() {
2396 self._scopes
2397 .insert(Scope::CloudPlatform.as_ref().to_string());
2398 }
2399
2400 #[allow(clippy::single_element_loop)]
2401 for &(find_this, param_name) in [("{+location}", "location")].iter() {
2402 url = params.uri_replacement(url, param_name, find_this, true);
2403 }
2404 {
2405 let to_remove = ["location"];
2406 params.remove_params(&to_remove);
2407 }
2408
2409 let url = params.parse_with_url(&url);
2410
2411 let mut json_mime_type = mime::APPLICATION_JSON;
2412 let mut request_value_reader = {
2413 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2414 common::remove_json_null_values(&mut value);
2415 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2416 serde_json::to_writer(&mut dst, &value).unwrap();
2417 dst
2418 };
2419 let request_size = request_value_reader
2420 .seek(std::io::SeekFrom::End(0))
2421 .unwrap();
2422 request_value_reader
2423 .seek(std::io::SeekFrom::Start(0))
2424 .unwrap();
2425
2426 loop {
2427 let token = match self
2428 .hub
2429 .auth
2430 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2431 .await
2432 {
2433 Ok(token) => token,
2434 Err(e) => match dlg.token(e) {
2435 Ok(token) => token,
2436 Err(e) => {
2437 dlg.finished(false);
2438 return Err(common::Error::MissingToken(e));
2439 }
2440 },
2441 };
2442 request_value_reader
2443 .seek(std::io::SeekFrom::Start(0))
2444 .unwrap();
2445 let mut req_result = {
2446 let client = &self.hub.client;
2447 dlg.pre_request();
2448 let mut req_builder = hyper::Request::builder()
2449 .method(hyper::Method::POST)
2450 .uri(url.as_str())
2451 .header(USER_AGENT, self.hub._user_agent.clone());
2452
2453 if let Some(token) = token.as_ref() {
2454 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2455 }
2456
2457 let request = req_builder
2458 .header(CONTENT_TYPE, json_mime_type.to_string())
2459 .header(CONTENT_LENGTH, request_size as u64)
2460 .body(common::to_body(
2461 request_value_reader.get_ref().clone().into(),
2462 ));
2463
2464 client.request(request.unwrap()).await
2465 };
2466
2467 match req_result {
2468 Err(err) => {
2469 if let common::Retry::After(d) = dlg.http_error(&err) {
2470 sleep(d).await;
2471 continue;
2472 }
2473 dlg.finished(false);
2474 return Err(common::Error::HttpError(err));
2475 }
2476 Ok(res) => {
2477 let (mut parts, body) = res.into_parts();
2478 let mut body = common::Body::new(body);
2479 if !parts.status.is_success() {
2480 let bytes = common::to_bytes(body).await.unwrap_or_default();
2481 let error = serde_json::from_str(&common::to_string(&bytes));
2482 let response = common::to_response(parts, bytes.into());
2483
2484 if let common::Retry::After(d) =
2485 dlg.http_failure(&response, error.as_ref().ok())
2486 {
2487 sleep(d).await;
2488 continue;
2489 }
2490
2491 dlg.finished(false);
2492
2493 return Err(match error {
2494 Ok(value) => common::Error::BadRequest(value),
2495 _ => common::Error::Failure(response),
2496 });
2497 }
2498 let response = {
2499 let bytes = common::to_bytes(body).await.unwrap_or_default();
2500 let encoded = common::to_string(&bytes);
2501 match serde_json::from_str(&encoded) {
2502 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2503 Err(error) => {
2504 dlg.response_json_decode_error(&encoded, &error);
2505 return Err(common::Error::JsonDecodeError(
2506 encoded.to_string(),
2507 error,
2508 ));
2509 }
2510 }
2511 };
2512
2513 dlg.finished(true);
2514 return Ok(response);
2515 }
2516 }
2517 }
2518 }
2519
2520 ///
2521 /// Sets the *request* property to the given value.
2522 ///
2523 /// Even though the property as already been set when instantiating this call,
2524 /// we provide this method for API completeness.
2525 pub fn request(mut self, new_value: CloudFunction) -> ProjectLocationFunctionCreateCall<'a, C> {
2526 self._request = new_value;
2527 self
2528 }
2529 /// Required. The project and location in which the function should be created, specified in the format `projects/*/locations/*`
2530 ///
2531 /// Sets the *location* path property to the given value.
2532 ///
2533 /// Even though the property as already been set when instantiating this call,
2534 /// we provide this method for API completeness.
2535 pub fn location(mut self, new_value: &str) -> ProjectLocationFunctionCreateCall<'a, C> {
2536 self._location = new_value.to_string();
2537 self
2538 }
2539 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2540 /// while executing the actual API request.
2541 ///
2542 /// ````text
2543 /// It should be used to handle progress information, and to implement a certain level of resilience.
2544 /// ````
2545 ///
2546 /// Sets the *delegate* property to the given value.
2547 pub fn delegate(
2548 mut self,
2549 new_value: &'a mut dyn common::Delegate,
2550 ) -> ProjectLocationFunctionCreateCall<'a, C> {
2551 self._delegate = Some(new_value);
2552 self
2553 }
2554
2555 /// Set any additional parameter of the query string used in the request.
2556 /// It should be used to set parameters which are not yet available through their own
2557 /// setters.
2558 ///
2559 /// Please note that this method must not be used to set any of the known parameters
2560 /// which have their own setter method. If done anyway, the request will fail.
2561 ///
2562 /// # Additional Parameters
2563 ///
2564 /// * *$.xgafv* (query-string) - V1 error format.
2565 /// * *access_token* (query-string) - OAuth access token.
2566 /// * *alt* (query-string) - Data format for response.
2567 /// * *callback* (query-string) - JSONP
2568 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2569 /// * *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.
2570 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2571 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2572 /// * *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.
2573 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2574 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2575 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationFunctionCreateCall<'a, C>
2576 where
2577 T: AsRef<str>,
2578 {
2579 self._additional_params
2580 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2581 self
2582 }
2583
2584 /// Identifies the authorization scope for the method you are building.
2585 ///
2586 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2587 /// [`Scope::CloudPlatform`].
2588 ///
2589 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2590 /// tokens for more than one scope.
2591 ///
2592 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2593 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2594 /// sufficient, a read-write scope will do as well.
2595 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationFunctionCreateCall<'a, C>
2596 where
2597 St: AsRef<str>,
2598 {
2599 self._scopes.insert(String::from(scope.as_ref()));
2600 self
2601 }
2602 /// Identifies the authorization scope(s) for the method you are building.
2603 ///
2604 /// See [`Self::add_scope()`] for details.
2605 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationFunctionCreateCall<'a, C>
2606 where
2607 I: IntoIterator<Item = St>,
2608 St: AsRef<str>,
2609 {
2610 self._scopes
2611 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2612 self
2613 }
2614
2615 /// Removes all scopes, and no default scope will be used either.
2616 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2617 /// for details).
2618 pub fn clear_scopes(mut self) -> ProjectLocationFunctionCreateCall<'a, C> {
2619 self._scopes.clear();
2620 self
2621 }
2622}
2623
2624/// Deletes a function with the given name from the specified project. If the given function is used by some trigger, the trigger will be updated to remove this function.
2625///
2626/// A builder for the *locations.functions.delete* method supported by a *project* resource.
2627/// It is not used directly, but through a [`ProjectMethods`] instance.
2628///
2629/// # Example
2630///
2631/// Instantiate a resource method builder
2632///
2633/// ```test_harness,no_run
2634/// # extern crate hyper;
2635/// # extern crate hyper_rustls;
2636/// # extern crate google_cloudfunctions1 as cloudfunctions1;
2637/// # async fn dox() {
2638/// # use cloudfunctions1::{CloudFunctions, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2639///
2640/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2641/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2642/// # .with_native_roots()
2643/// # .unwrap()
2644/// # .https_only()
2645/// # .enable_http2()
2646/// # .build();
2647///
2648/// # let executor = hyper_util::rt::TokioExecutor::new();
2649/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2650/// # secret,
2651/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2652/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2653/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2654/// # ),
2655/// # ).build().await.unwrap();
2656///
2657/// # let client = hyper_util::client::legacy::Client::builder(
2658/// # hyper_util::rt::TokioExecutor::new()
2659/// # )
2660/// # .build(
2661/// # hyper_rustls::HttpsConnectorBuilder::new()
2662/// # .with_native_roots()
2663/// # .unwrap()
2664/// # .https_or_http()
2665/// # .enable_http2()
2666/// # .build()
2667/// # );
2668/// # let mut hub = CloudFunctions::new(client, auth);
2669/// // You can configure optional parameters by calling the respective setters at will, and
2670/// // execute the final call using `doit()`.
2671/// // Values shown here are possibly random and not representative !
2672/// let result = hub.projects().locations_functions_delete("name")
2673/// .doit().await;
2674/// # }
2675/// ```
2676pub struct ProjectLocationFunctionDeleteCall<'a, C>
2677where
2678 C: 'a,
2679{
2680 hub: &'a CloudFunctions<C>,
2681 _name: String,
2682 _delegate: Option<&'a mut dyn common::Delegate>,
2683 _additional_params: HashMap<String, String>,
2684 _scopes: BTreeSet<String>,
2685}
2686
2687impl<'a, C> common::CallBuilder for ProjectLocationFunctionDeleteCall<'a, C> {}
2688
2689impl<'a, C> ProjectLocationFunctionDeleteCall<'a, C>
2690where
2691 C: common::Connector,
2692{
2693 /// Perform the operation you have build so far.
2694 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
2695 use std::borrow::Cow;
2696 use std::io::{Read, Seek};
2697
2698 use common::{url::Params, ToParts};
2699 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2700
2701 let mut dd = common::DefaultDelegate;
2702 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2703 dlg.begin(common::MethodInfo {
2704 id: "cloudfunctions.projects.locations.functions.delete",
2705 http_method: hyper::Method::DELETE,
2706 });
2707
2708 for &field in ["alt", "name"].iter() {
2709 if self._additional_params.contains_key(field) {
2710 dlg.finished(false);
2711 return Err(common::Error::FieldClash(field));
2712 }
2713 }
2714
2715 let mut params = Params::with_capacity(3 + self._additional_params.len());
2716 params.push("name", self._name);
2717
2718 params.extend(self._additional_params.iter());
2719
2720 params.push("alt", "json");
2721 let mut url = self.hub._base_url.clone() + "v1/{+name}";
2722 if self._scopes.is_empty() {
2723 self._scopes
2724 .insert(Scope::CloudPlatform.as_ref().to_string());
2725 }
2726
2727 #[allow(clippy::single_element_loop)]
2728 for &(find_this, param_name) in [("{+name}", "name")].iter() {
2729 url = params.uri_replacement(url, param_name, find_this, true);
2730 }
2731 {
2732 let to_remove = ["name"];
2733 params.remove_params(&to_remove);
2734 }
2735
2736 let url = params.parse_with_url(&url);
2737
2738 loop {
2739 let token = match self
2740 .hub
2741 .auth
2742 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2743 .await
2744 {
2745 Ok(token) => token,
2746 Err(e) => match dlg.token(e) {
2747 Ok(token) => token,
2748 Err(e) => {
2749 dlg.finished(false);
2750 return Err(common::Error::MissingToken(e));
2751 }
2752 },
2753 };
2754 let mut req_result = {
2755 let client = &self.hub.client;
2756 dlg.pre_request();
2757 let mut req_builder = hyper::Request::builder()
2758 .method(hyper::Method::DELETE)
2759 .uri(url.as_str())
2760 .header(USER_AGENT, self.hub._user_agent.clone());
2761
2762 if let Some(token) = token.as_ref() {
2763 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2764 }
2765
2766 let request = req_builder
2767 .header(CONTENT_LENGTH, 0_u64)
2768 .body(common::to_body::<String>(None));
2769
2770 client.request(request.unwrap()).await
2771 };
2772
2773 match req_result {
2774 Err(err) => {
2775 if let common::Retry::After(d) = dlg.http_error(&err) {
2776 sleep(d).await;
2777 continue;
2778 }
2779 dlg.finished(false);
2780 return Err(common::Error::HttpError(err));
2781 }
2782 Ok(res) => {
2783 let (mut parts, body) = res.into_parts();
2784 let mut body = common::Body::new(body);
2785 if !parts.status.is_success() {
2786 let bytes = common::to_bytes(body).await.unwrap_or_default();
2787 let error = serde_json::from_str(&common::to_string(&bytes));
2788 let response = common::to_response(parts, bytes.into());
2789
2790 if let common::Retry::After(d) =
2791 dlg.http_failure(&response, error.as_ref().ok())
2792 {
2793 sleep(d).await;
2794 continue;
2795 }
2796
2797 dlg.finished(false);
2798
2799 return Err(match error {
2800 Ok(value) => common::Error::BadRequest(value),
2801 _ => common::Error::Failure(response),
2802 });
2803 }
2804 let response = {
2805 let bytes = common::to_bytes(body).await.unwrap_or_default();
2806 let encoded = common::to_string(&bytes);
2807 match serde_json::from_str(&encoded) {
2808 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2809 Err(error) => {
2810 dlg.response_json_decode_error(&encoded, &error);
2811 return Err(common::Error::JsonDecodeError(
2812 encoded.to_string(),
2813 error,
2814 ));
2815 }
2816 }
2817 };
2818
2819 dlg.finished(true);
2820 return Ok(response);
2821 }
2822 }
2823 }
2824 }
2825
2826 /// Required. The name of the function which should be deleted.
2827 ///
2828 /// Sets the *name* path property to the given value.
2829 ///
2830 /// Even though the property as already been set when instantiating this call,
2831 /// we provide this method for API completeness.
2832 pub fn name(mut self, new_value: &str) -> ProjectLocationFunctionDeleteCall<'a, C> {
2833 self._name = new_value.to_string();
2834 self
2835 }
2836 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2837 /// while executing the actual API request.
2838 ///
2839 /// ````text
2840 /// It should be used to handle progress information, and to implement a certain level of resilience.
2841 /// ````
2842 ///
2843 /// Sets the *delegate* property to the given value.
2844 pub fn delegate(
2845 mut self,
2846 new_value: &'a mut dyn common::Delegate,
2847 ) -> ProjectLocationFunctionDeleteCall<'a, C> {
2848 self._delegate = Some(new_value);
2849 self
2850 }
2851
2852 /// Set any additional parameter of the query string used in the request.
2853 /// It should be used to set parameters which are not yet available through their own
2854 /// setters.
2855 ///
2856 /// Please note that this method must not be used to set any of the known parameters
2857 /// which have their own setter method. If done anyway, the request will fail.
2858 ///
2859 /// # Additional Parameters
2860 ///
2861 /// * *$.xgafv* (query-string) - V1 error format.
2862 /// * *access_token* (query-string) - OAuth access token.
2863 /// * *alt* (query-string) - Data format for response.
2864 /// * *callback* (query-string) - JSONP
2865 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2866 /// * *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.
2867 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2868 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2869 /// * *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.
2870 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2871 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2872 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationFunctionDeleteCall<'a, C>
2873 where
2874 T: AsRef<str>,
2875 {
2876 self._additional_params
2877 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2878 self
2879 }
2880
2881 /// Identifies the authorization scope for the method you are building.
2882 ///
2883 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2884 /// [`Scope::CloudPlatform`].
2885 ///
2886 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2887 /// tokens for more than one scope.
2888 ///
2889 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2890 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2891 /// sufficient, a read-write scope will do as well.
2892 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationFunctionDeleteCall<'a, C>
2893 where
2894 St: AsRef<str>,
2895 {
2896 self._scopes.insert(String::from(scope.as_ref()));
2897 self
2898 }
2899 /// Identifies the authorization scope(s) for the method you are building.
2900 ///
2901 /// See [`Self::add_scope()`] for details.
2902 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationFunctionDeleteCall<'a, C>
2903 where
2904 I: IntoIterator<Item = St>,
2905 St: AsRef<str>,
2906 {
2907 self._scopes
2908 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2909 self
2910 }
2911
2912 /// Removes all scopes, and no default scope will be used either.
2913 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2914 /// for details).
2915 pub fn clear_scopes(mut self) -> ProjectLocationFunctionDeleteCall<'a, C> {
2916 self._scopes.clear();
2917 self
2918 }
2919}
2920
2921/// Returns a signed URL for downloading deployed function source code. The URL is only valid for a limited period and should be used within minutes after generation. For more information about the signed URL usage see: https://cloud.google.com/storage/docs/access-control/signed-urls
2922///
2923/// A builder for the *locations.functions.generateDownloadUrl* method supported by a *project* resource.
2924/// It is not used directly, but through a [`ProjectMethods`] instance.
2925///
2926/// # Example
2927///
2928/// Instantiate a resource method builder
2929///
2930/// ```test_harness,no_run
2931/// # extern crate hyper;
2932/// # extern crate hyper_rustls;
2933/// # extern crate google_cloudfunctions1 as cloudfunctions1;
2934/// use cloudfunctions1::api::GenerateDownloadUrlRequest;
2935/// # async fn dox() {
2936/// # use cloudfunctions1::{CloudFunctions, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2937///
2938/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2939/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2940/// # .with_native_roots()
2941/// # .unwrap()
2942/// # .https_only()
2943/// # .enable_http2()
2944/// # .build();
2945///
2946/// # let executor = hyper_util::rt::TokioExecutor::new();
2947/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2948/// # secret,
2949/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2950/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2951/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2952/// # ),
2953/// # ).build().await.unwrap();
2954///
2955/// # let client = hyper_util::client::legacy::Client::builder(
2956/// # hyper_util::rt::TokioExecutor::new()
2957/// # )
2958/// # .build(
2959/// # hyper_rustls::HttpsConnectorBuilder::new()
2960/// # .with_native_roots()
2961/// # .unwrap()
2962/// # .https_or_http()
2963/// # .enable_http2()
2964/// # .build()
2965/// # );
2966/// # let mut hub = CloudFunctions::new(client, auth);
2967/// // As the method needs a request, you would usually fill it with the desired information
2968/// // into the respective structure. Some of the parts shown here might not be applicable !
2969/// // Values shown here are possibly random and not representative !
2970/// let mut req = GenerateDownloadUrlRequest::default();
2971///
2972/// // You can configure optional parameters by calling the respective setters at will, and
2973/// // execute the final call using `doit()`.
2974/// // Values shown here are possibly random and not representative !
2975/// let result = hub.projects().locations_functions_generate_download_url(req, "name")
2976/// .doit().await;
2977/// # }
2978/// ```
2979pub struct ProjectLocationFunctionGenerateDownloadUrlCall<'a, C>
2980where
2981 C: 'a,
2982{
2983 hub: &'a CloudFunctions<C>,
2984 _request: GenerateDownloadUrlRequest,
2985 _name: String,
2986 _delegate: Option<&'a mut dyn common::Delegate>,
2987 _additional_params: HashMap<String, String>,
2988 _scopes: BTreeSet<String>,
2989}
2990
2991impl<'a, C> common::CallBuilder for ProjectLocationFunctionGenerateDownloadUrlCall<'a, C> {}
2992
2993impl<'a, C> ProjectLocationFunctionGenerateDownloadUrlCall<'a, C>
2994where
2995 C: common::Connector,
2996{
2997 /// Perform the operation you have build so far.
2998 pub async fn doit(mut self) -> common::Result<(common::Response, GenerateDownloadUrlResponse)> {
2999 use std::borrow::Cow;
3000 use std::io::{Read, Seek};
3001
3002 use common::{url::Params, ToParts};
3003 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3004
3005 let mut dd = common::DefaultDelegate;
3006 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3007 dlg.begin(common::MethodInfo {
3008 id: "cloudfunctions.projects.locations.functions.generateDownloadUrl",
3009 http_method: hyper::Method::POST,
3010 });
3011
3012 for &field in ["alt", "name"].iter() {
3013 if self._additional_params.contains_key(field) {
3014 dlg.finished(false);
3015 return Err(common::Error::FieldClash(field));
3016 }
3017 }
3018
3019 let mut params = Params::with_capacity(4 + self._additional_params.len());
3020 params.push("name", self._name);
3021
3022 params.extend(self._additional_params.iter());
3023
3024 params.push("alt", "json");
3025 let mut url = self.hub._base_url.clone() + "v1/{+name}:generateDownloadUrl";
3026 if self._scopes.is_empty() {
3027 self._scopes
3028 .insert(Scope::CloudPlatform.as_ref().to_string());
3029 }
3030
3031 #[allow(clippy::single_element_loop)]
3032 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3033 url = params.uri_replacement(url, param_name, find_this, true);
3034 }
3035 {
3036 let to_remove = ["name"];
3037 params.remove_params(&to_remove);
3038 }
3039
3040 let url = params.parse_with_url(&url);
3041
3042 let mut json_mime_type = mime::APPLICATION_JSON;
3043 let mut request_value_reader = {
3044 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3045 common::remove_json_null_values(&mut value);
3046 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3047 serde_json::to_writer(&mut dst, &value).unwrap();
3048 dst
3049 };
3050 let request_size = request_value_reader
3051 .seek(std::io::SeekFrom::End(0))
3052 .unwrap();
3053 request_value_reader
3054 .seek(std::io::SeekFrom::Start(0))
3055 .unwrap();
3056
3057 loop {
3058 let token = match self
3059 .hub
3060 .auth
3061 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3062 .await
3063 {
3064 Ok(token) => token,
3065 Err(e) => match dlg.token(e) {
3066 Ok(token) => token,
3067 Err(e) => {
3068 dlg.finished(false);
3069 return Err(common::Error::MissingToken(e));
3070 }
3071 },
3072 };
3073 request_value_reader
3074 .seek(std::io::SeekFrom::Start(0))
3075 .unwrap();
3076 let mut req_result = {
3077 let client = &self.hub.client;
3078 dlg.pre_request();
3079 let mut req_builder = hyper::Request::builder()
3080 .method(hyper::Method::POST)
3081 .uri(url.as_str())
3082 .header(USER_AGENT, self.hub._user_agent.clone());
3083
3084 if let Some(token) = token.as_ref() {
3085 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3086 }
3087
3088 let request = req_builder
3089 .header(CONTENT_TYPE, json_mime_type.to_string())
3090 .header(CONTENT_LENGTH, request_size as u64)
3091 .body(common::to_body(
3092 request_value_reader.get_ref().clone().into(),
3093 ));
3094
3095 client.request(request.unwrap()).await
3096 };
3097
3098 match req_result {
3099 Err(err) => {
3100 if let common::Retry::After(d) = dlg.http_error(&err) {
3101 sleep(d).await;
3102 continue;
3103 }
3104 dlg.finished(false);
3105 return Err(common::Error::HttpError(err));
3106 }
3107 Ok(res) => {
3108 let (mut parts, body) = res.into_parts();
3109 let mut body = common::Body::new(body);
3110 if !parts.status.is_success() {
3111 let bytes = common::to_bytes(body).await.unwrap_or_default();
3112 let error = serde_json::from_str(&common::to_string(&bytes));
3113 let response = common::to_response(parts, bytes.into());
3114
3115 if let common::Retry::After(d) =
3116 dlg.http_failure(&response, error.as_ref().ok())
3117 {
3118 sleep(d).await;
3119 continue;
3120 }
3121
3122 dlg.finished(false);
3123
3124 return Err(match error {
3125 Ok(value) => common::Error::BadRequest(value),
3126 _ => common::Error::Failure(response),
3127 });
3128 }
3129 let response = {
3130 let bytes = common::to_bytes(body).await.unwrap_or_default();
3131 let encoded = common::to_string(&bytes);
3132 match serde_json::from_str(&encoded) {
3133 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3134 Err(error) => {
3135 dlg.response_json_decode_error(&encoded, &error);
3136 return Err(common::Error::JsonDecodeError(
3137 encoded.to_string(),
3138 error,
3139 ));
3140 }
3141 }
3142 };
3143
3144 dlg.finished(true);
3145 return Ok(response);
3146 }
3147 }
3148 }
3149 }
3150
3151 ///
3152 /// Sets the *request* property to the given value.
3153 ///
3154 /// Even though the property as already been set when instantiating this call,
3155 /// we provide this method for API completeness.
3156 pub fn request(
3157 mut self,
3158 new_value: GenerateDownloadUrlRequest,
3159 ) -> ProjectLocationFunctionGenerateDownloadUrlCall<'a, C> {
3160 self._request = new_value;
3161 self
3162 }
3163 /// The name of function for which source code Google Cloud Storage signed URL should be generated.
3164 ///
3165 /// Sets the *name* path property to the given value.
3166 ///
3167 /// Even though the property as already been set when instantiating this call,
3168 /// we provide this method for API completeness.
3169 pub fn name(
3170 mut self,
3171 new_value: &str,
3172 ) -> ProjectLocationFunctionGenerateDownloadUrlCall<'a, C> {
3173 self._name = new_value.to_string();
3174 self
3175 }
3176 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3177 /// while executing the actual API request.
3178 ///
3179 /// ````text
3180 /// It should be used to handle progress information, and to implement a certain level of resilience.
3181 /// ````
3182 ///
3183 /// Sets the *delegate* property to the given value.
3184 pub fn delegate(
3185 mut self,
3186 new_value: &'a mut dyn common::Delegate,
3187 ) -> ProjectLocationFunctionGenerateDownloadUrlCall<'a, C> {
3188 self._delegate = Some(new_value);
3189 self
3190 }
3191
3192 /// Set any additional parameter of the query string used in the request.
3193 /// It should be used to set parameters which are not yet available through their own
3194 /// setters.
3195 ///
3196 /// Please note that this method must not be used to set any of the known parameters
3197 /// which have their own setter method. If done anyway, the request will fail.
3198 ///
3199 /// # Additional Parameters
3200 ///
3201 /// * *$.xgafv* (query-string) - V1 error format.
3202 /// * *access_token* (query-string) - OAuth access token.
3203 /// * *alt* (query-string) - Data format for response.
3204 /// * *callback* (query-string) - JSONP
3205 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3206 /// * *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.
3207 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3208 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3209 /// * *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.
3210 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3211 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3212 pub fn param<T>(
3213 mut self,
3214 name: T,
3215 value: T,
3216 ) -> ProjectLocationFunctionGenerateDownloadUrlCall<'a, C>
3217 where
3218 T: AsRef<str>,
3219 {
3220 self._additional_params
3221 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3222 self
3223 }
3224
3225 /// Identifies the authorization scope for the method you are building.
3226 ///
3227 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3228 /// [`Scope::CloudPlatform`].
3229 ///
3230 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3231 /// tokens for more than one scope.
3232 ///
3233 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3234 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3235 /// sufficient, a read-write scope will do as well.
3236 pub fn add_scope<St>(
3237 mut self,
3238 scope: St,
3239 ) -> ProjectLocationFunctionGenerateDownloadUrlCall<'a, C>
3240 where
3241 St: AsRef<str>,
3242 {
3243 self._scopes.insert(String::from(scope.as_ref()));
3244 self
3245 }
3246 /// Identifies the authorization scope(s) for the method you are building.
3247 ///
3248 /// See [`Self::add_scope()`] for details.
3249 pub fn add_scopes<I, St>(
3250 mut self,
3251 scopes: I,
3252 ) -> ProjectLocationFunctionGenerateDownloadUrlCall<'a, C>
3253 where
3254 I: IntoIterator<Item = St>,
3255 St: AsRef<str>,
3256 {
3257 self._scopes
3258 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3259 self
3260 }
3261
3262 /// Removes all scopes, and no default scope will be used either.
3263 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3264 /// for details).
3265 pub fn clear_scopes(mut self) -> ProjectLocationFunctionGenerateDownloadUrlCall<'a, C> {
3266 self._scopes.clear();
3267 self
3268 }
3269}
3270
3271/// Returns a signed URL for uploading a function source code. For more information about the signed URL usage see: https://cloud.google.com/storage/docs/access-control/signed-urls. Once the function source code upload is complete, the used signed URL should be provided in CreateFunction or UpdateFunction request as a reference to the function source code. When uploading source code to the generated signed URL, please follow these restrictions: * Source file type should be a zip file. * Source file size should not exceed 100MB limit. * No credentials should be attached - the signed URLs provide access to the target bucket using internal service identity; if credentials were attached, the identity from the credentials would be used, but that identity does not have permissions to upload files to the URL. When making a HTTP PUT request, these two headers need to be specified: * `content-type: application/zip` * `x-goog-content-length-range: 0,104857600` And this header SHOULD NOT be specified: * `Authorization: Bearer YOUR_TOKEN`
3272///
3273/// A builder for the *locations.functions.generateUploadUrl* method supported by a *project* resource.
3274/// It is not used directly, but through a [`ProjectMethods`] instance.
3275///
3276/// # Example
3277///
3278/// Instantiate a resource method builder
3279///
3280/// ```test_harness,no_run
3281/// # extern crate hyper;
3282/// # extern crate hyper_rustls;
3283/// # extern crate google_cloudfunctions1 as cloudfunctions1;
3284/// use cloudfunctions1::api::GenerateUploadUrlRequest;
3285/// # async fn dox() {
3286/// # use cloudfunctions1::{CloudFunctions, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3287///
3288/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3289/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3290/// # .with_native_roots()
3291/// # .unwrap()
3292/// # .https_only()
3293/// # .enable_http2()
3294/// # .build();
3295///
3296/// # let executor = hyper_util::rt::TokioExecutor::new();
3297/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3298/// # secret,
3299/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3300/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3301/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3302/// # ),
3303/// # ).build().await.unwrap();
3304///
3305/// # let client = hyper_util::client::legacy::Client::builder(
3306/// # hyper_util::rt::TokioExecutor::new()
3307/// # )
3308/// # .build(
3309/// # hyper_rustls::HttpsConnectorBuilder::new()
3310/// # .with_native_roots()
3311/// # .unwrap()
3312/// # .https_or_http()
3313/// # .enable_http2()
3314/// # .build()
3315/// # );
3316/// # let mut hub = CloudFunctions::new(client, auth);
3317/// // As the method needs a request, you would usually fill it with the desired information
3318/// // into the respective structure. Some of the parts shown here might not be applicable !
3319/// // Values shown here are possibly random and not representative !
3320/// let mut req = GenerateUploadUrlRequest::default();
3321///
3322/// // You can configure optional parameters by calling the respective setters at will, and
3323/// // execute the final call using `doit()`.
3324/// // Values shown here are possibly random and not representative !
3325/// let result = hub.projects().locations_functions_generate_upload_url(req, "parent")
3326/// .doit().await;
3327/// # }
3328/// ```
3329pub struct ProjectLocationFunctionGenerateUploadUrlCall<'a, C>
3330where
3331 C: 'a,
3332{
3333 hub: &'a CloudFunctions<C>,
3334 _request: GenerateUploadUrlRequest,
3335 _parent: String,
3336 _delegate: Option<&'a mut dyn common::Delegate>,
3337 _additional_params: HashMap<String, String>,
3338 _scopes: BTreeSet<String>,
3339}
3340
3341impl<'a, C> common::CallBuilder for ProjectLocationFunctionGenerateUploadUrlCall<'a, C> {}
3342
3343impl<'a, C> ProjectLocationFunctionGenerateUploadUrlCall<'a, C>
3344where
3345 C: common::Connector,
3346{
3347 /// Perform the operation you have build so far.
3348 pub async fn doit(mut self) -> common::Result<(common::Response, GenerateUploadUrlResponse)> {
3349 use std::borrow::Cow;
3350 use std::io::{Read, Seek};
3351
3352 use common::{url::Params, ToParts};
3353 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3354
3355 let mut dd = common::DefaultDelegate;
3356 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3357 dlg.begin(common::MethodInfo {
3358 id: "cloudfunctions.projects.locations.functions.generateUploadUrl",
3359 http_method: hyper::Method::POST,
3360 });
3361
3362 for &field in ["alt", "parent"].iter() {
3363 if self._additional_params.contains_key(field) {
3364 dlg.finished(false);
3365 return Err(common::Error::FieldClash(field));
3366 }
3367 }
3368
3369 let mut params = Params::with_capacity(4 + self._additional_params.len());
3370 params.push("parent", self._parent);
3371
3372 params.extend(self._additional_params.iter());
3373
3374 params.push("alt", "json");
3375 let mut url = self.hub._base_url.clone() + "v1/{+parent}/functions:generateUploadUrl";
3376 if self._scopes.is_empty() {
3377 self._scopes
3378 .insert(Scope::CloudPlatform.as_ref().to_string());
3379 }
3380
3381 #[allow(clippy::single_element_loop)]
3382 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
3383 url = params.uri_replacement(url, param_name, find_this, true);
3384 }
3385 {
3386 let to_remove = ["parent"];
3387 params.remove_params(&to_remove);
3388 }
3389
3390 let url = params.parse_with_url(&url);
3391
3392 let mut json_mime_type = mime::APPLICATION_JSON;
3393 let mut request_value_reader = {
3394 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3395 common::remove_json_null_values(&mut value);
3396 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3397 serde_json::to_writer(&mut dst, &value).unwrap();
3398 dst
3399 };
3400 let request_size = request_value_reader
3401 .seek(std::io::SeekFrom::End(0))
3402 .unwrap();
3403 request_value_reader
3404 .seek(std::io::SeekFrom::Start(0))
3405 .unwrap();
3406
3407 loop {
3408 let token = match self
3409 .hub
3410 .auth
3411 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3412 .await
3413 {
3414 Ok(token) => token,
3415 Err(e) => match dlg.token(e) {
3416 Ok(token) => token,
3417 Err(e) => {
3418 dlg.finished(false);
3419 return Err(common::Error::MissingToken(e));
3420 }
3421 },
3422 };
3423 request_value_reader
3424 .seek(std::io::SeekFrom::Start(0))
3425 .unwrap();
3426 let mut req_result = {
3427 let client = &self.hub.client;
3428 dlg.pre_request();
3429 let mut req_builder = hyper::Request::builder()
3430 .method(hyper::Method::POST)
3431 .uri(url.as_str())
3432 .header(USER_AGENT, self.hub._user_agent.clone());
3433
3434 if let Some(token) = token.as_ref() {
3435 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3436 }
3437
3438 let request = req_builder
3439 .header(CONTENT_TYPE, json_mime_type.to_string())
3440 .header(CONTENT_LENGTH, request_size as u64)
3441 .body(common::to_body(
3442 request_value_reader.get_ref().clone().into(),
3443 ));
3444
3445 client.request(request.unwrap()).await
3446 };
3447
3448 match req_result {
3449 Err(err) => {
3450 if let common::Retry::After(d) = dlg.http_error(&err) {
3451 sleep(d).await;
3452 continue;
3453 }
3454 dlg.finished(false);
3455 return Err(common::Error::HttpError(err));
3456 }
3457 Ok(res) => {
3458 let (mut parts, body) = res.into_parts();
3459 let mut body = common::Body::new(body);
3460 if !parts.status.is_success() {
3461 let bytes = common::to_bytes(body).await.unwrap_or_default();
3462 let error = serde_json::from_str(&common::to_string(&bytes));
3463 let response = common::to_response(parts, bytes.into());
3464
3465 if let common::Retry::After(d) =
3466 dlg.http_failure(&response, error.as_ref().ok())
3467 {
3468 sleep(d).await;
3469 continue;
3470 }
3471
3472 dlg.finished(false);
3473
3474 return Err(match error {
3475 Ok(value) => common::Error::BadRequest(value),
3476 _ => common::Error::Failure(response),
3477 });
3478 }
3479 let response = {
3480 let bytes = common::to_bytes(body).await.unwrap_or_default();
3481 let encoded = common::to_string(&bytes);
3482 match serde_json::from_str(&encoded) {
3483 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3484 Err(error) => {
3485 dlg.response_json_decode_error(&encoded, &error);
3486 return Err(common::Error::JsonDecodeError(
3487 encoded.to_string(),
3488 error,
3489 ));
3490 }
3491 }
3492 };
3493
3494 dlg.finished(true);
3495 return Ok(response);
3496 }
3497 }
3498 }
3499 }
3500
3501 ///
3502 /// Sets the *request* property to the given value.
3503 ///
3504 /// Even though the property as already been set when instantiating this call,
3505 /// we provide this method for API completeness.
3506 pub fn request(
3507 mut self,
3508 new_value: GenerateUploadUrlRequest,
3509 ) -> ProjectLocationFunctionGenerateUploadUrlCall<'a, C> {
3510 self._request = new_value;
3511 self
3512 }
3513 /// The project and location in which the Google Cloud Storage signed URL should be generated, specified in the format `projects/*/locations/*`.
3514 ///
3515 /// Sets the *parent* path property to the given value.
3516 ///
3517 /// Even though the property as already been set when instantiating this call,
3518 /// we provide this method for API completeness.
3519 pub fn parent(
3520 mut self,
3521 new_value: &str,
3522 ) -> ProjectLocationFunctionGenerateUploadUrlCall<'a, C> {
3523 self._parent = new_value.to_string();
3524 self
3525 }
3526 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3527 /// while executing the actual API request.
3528 ///
3529 /// ````text
3530 /// It should be used to handle progress information, and to implement a certain level of resilience.
3531 /// ````
3532 ///
3533 /// Sets the *delegate* property to the given value.
3534 pub fn delegate(
3535 mut self,
3536 new_value: &'a mut dyn common::Delegate,
3537 ) -> ProjectLocationFunctionGenerateUploadUrlCall<'a, C> {
3538 self._delegate = Some(new_value);
3539 self
3540 }
3541
3542 /// Set any additional parameter of the query string used in the request.
3543 /// It should be used to set parameters which are not yet available through their own
3544 /// setters.
3545 ///
3546 /// Please note that this method must not be used to set any of the known parameters
3547 /// which have their own setter method. If done anyway, the request will fail.
3548 ///
3549 /// # Additional Parameters
3550 ///
3551 /// * *$.xgafv* (query-string) - V1 error format.
3552 /// * *access_token* (query-string) - OAuth access token.
3553 /// * *alt* (query-string) - Data format for response.
3554 /// * *callback* (query-string) - JSONP
3555 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3556 /// * *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.
3557 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3558 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3559 /// * *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.
3560 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3561 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3562 pub fn param<T>(
3563 mut self,
3564 name: T,
3565 value: T,
3566 ) -> ProjectLocationFunctionGenerateUploadUrlCall<'a, C>
3567 where
3568 T: AsRef<str>,
3569 {
3570 self._additional_params
3571 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3572 self
3573 }
3574
3575 /// Identifies the authorization scope for the method you are building.
3576 ///
3577 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3578 /// [`Scope::CloudPlatform`].
3579 ///
3580 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3581 /// tokens for more than one scope.
3582 ///
3583 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3584 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3585 /// sufficient, a read-write scope will do as well.
3586 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationFunctionGenerateUploadUrlCall<'a, C>
3587 where
3588 St: AsRef<str>,
3589 {
3590 self._scopes.insert(String::from(scope.as_ref()));
3591 self
3592 }
3593 /// Identifies the authorization scope(s) for the method you are building.
3594 ///
3595 /// See [`Self::add_scope()`] for details.
3596 pub fn add_scopes<I, St>(
3597 mut self,
3598 scopes: I,
3599 ) -> ProjectLocationFunctionGenerateUploadUrlCall<'a, C>
3600 where
3601 I: IntoIterator<Item = St>,
3602 St: AsRef<str>,
3603 {
3604 self._scopes
3605 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3606 self
3607 }
3608
3609 /// Removes all scopes, and no default scope will be used either.
3610 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3611 /// for details).
3612 pub fn clear_scopes(mut self) -> ProjectLocationFunctionGenerateUploadUrlCall<'a, C> {
3613 self._scopes.clear();
3614 self
3615 }
3616}
3617
3618/// Returns a function with the given name from the requested project.
3619///
3620/// A builder for the *locations.functions.get* method supported by a *project* resource.
3621/// It is not used directly, but through a [`ProjectMethods`] instance.
3622///
3623/// # Example
3624///
3625/// Instantiate a resource method builder
3626///
3627/// ```test_harness,no_run
3628/// # extern crate hyper;
3629/// # extern crate hyper_rustls;
3630/// # extern crate google_cloudfunctions1 as cloudfunctions1;
3631/// # async fn dox() {
3632/// # use cloudfunctions1::{CloudFunctions, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3633///
3634/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3635/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3636/// # .with_native_roots()
3637/// # .unwrap()
3638/// # .https_only()
3639/// # .enable_http2()
3640/// # .build();
3641///
3642/// # let executor = hyper_util::rt::TokioExecutor::new();
3643/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3644/// # secret,
3645/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3646/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3647/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3648/// # ),
3649/// # ).build().await.unwrap();
3650///
3651/// # let client = hyper_util::client::legacy::Client::builder(
3652/// # hyper_util::rt::TokioExecutor::new()
3653/// # )
3654/// # .build(
3655/// # hyper_rustls::HttpsConnectorBuilder::new()
3656/// # .with_native_roots()
3657/// # .unwrap()
3658/// # .https_or_http()
3659/// # .enable_http2()
3660/// # .build()
3661/// # );
3662/// # let mut hub = CloudFunctions::new(client, auth);
3663/// // You can configure optional parameters by calling the respective setters at will, and
3664/// // execute the final call using `doit()`.
3665/// // Values shown here are possibly random and not representative !
3666/// let result = hub.projects().locations_functions_get("name")
3667/// .version_id(-7)
3668/// .doit().await;
3669/// # }
3670/// ```
3671pub struct ProjectLocationFunctionGetCall<'a, C>
3672where
3673 C: 'a,
3674{
3675 hub: &'a CloudFunctions<C>,
3676 _name: String,
3677 _version_id: Option<i64>,
3678 _delegate: Option<&'a mut dyn common::Delegate>,
3679 _additional_params: HashMap<String, String>,
3680 _scopes: BTreeSet<String>,
3681}
3682
3683impl<'a, C> common::CallBuilder for ProjectLocationFunctionGetCall<'a, C> {}
3684
3685impl<'a, C> ProjectLocationFunctionGetCall<'a, C>
3686where
3687 C: common::Connector,
3688{
3689 /// Perform the operation you have build so far.
3690 pub async fn doit(mut self) -> common::Result<(common::Response, CloudFunction)> {
3691 use std::borrow::Cow;
3692 use std::io::{Read, Seek};
3693
3694 use common::{url::Params, ToParts};
3695 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3696
3697 let mut dd = common::DefaultDelegate;
3698 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3699 dlg.begin(common::MethodInfo {
3700 id: "cloudfunctions.projects.locations.functions.get",
3701 http_method: hyper::Method::GET,
3702 });
3703
3704 for &field in ["alt", "name", "versionId"].iter() {
3705 if self._additional_params.contains_key(field) {
3706 dlg.finished(false);
3707 return Err(common::Error::FieldClash(field));
3708 }
3709 }
3710
3711 let mut params = Params::with_capacity(4 + self._additional_params.len());
3712 params.push("name", self._name);
3713 if let Some(value) = self._version_id.as_ref() {
3714 params.push("versionId", value.to_string());
3715 }
3716
3717 params.extend(self._additional_params.iter());
3718
3719 params.push("alt", "json");
3720 let mut url = self.hub._base_url.clone() + "v1/{+name}";
3721 if self._scopes.is_empty() {
3722 self._scopes
3723 .insert(Scope::CloudPlatform.as_ref().to_string());
3724 }
3725
3726 #[allow(clippy::single_element_loop)]
3727 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3728 url = params.uri_replacement(url, param_name, find_this, true);
3729 }
3730 {
3731 let to_remove = ["name"];
3732 params.remove_params(&to_remove);
3733 }
3734
3735 let url = params.parse_with_url(&url);
3736
3737 loop {
3738 let token = match self
3739 .hub
3740 .auth
3741 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3742 .await
3743 {
3744 Ok(token) => token,
3745 Err(e) => match dlg.token(e) {
3746 Ok(token) => token,
3747 Err(e) => {
3748 dlg.finished(false);
3749 return Err(common::Error::MissingToken(e));
3750 }
3751 },
3752 };
3753 let mut req_result = {
3754 let client = &self.hub.client;
3755 dlg.pre_request();
3756 let mut req_builder = hyper::Request::builder()
3757 .method(hyper::Method::GET)
3758 .uri(url.as_str())
3759 .header(USER_AGENT, self.hub._user_agent.clone());
3760
3761 if let Some(token) = token.as_ref() {
3762 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3763 }
3764
3765 let request = req_builder
3766 .header(CONTENT_LENGTH, 0_u64)
3767 .body(common::to_body::<String>(None));
3768
3769 client.request(request.unwrap()).await
3770 };
3771
3772 match req_result {
3773 Err(err) => {
3774 if let common::Retry::After(d) = dlg.http_error(&err) {
3775 sleep(d).await;
3776 continue;
3777 }
3778 dlg.finished(false);
3779 return Err(common::Error::HttpError(err));
3780 }
3781 Ok(res) => {
3782 let (mut parts, body) = res.into_parts();
3783 let mut body = common::Body::new(body);
3784 if !parts.status.is_success() {
3785 let bytes = common::to_bytes(body).await.unwrap_or_default();
3786 let error = serde_json::from_str(&common::to_string(&bytes));
3787 let response = common::to_response(parts, bytes.into());
3788
3789 if let common::Retry::After(d) =
3790 dlg.http_failure(&response, error.as_ref().ok())
3791 {
3792 sleep(d).await;
3793 continue;
3794 }
3795
3796 dlg.finished(false);
3797
3798 return Err(match error {
3799 Ok(value) => common::Error::BadRequest(value),
3800 _ => common::Error::Failure(response),
3801 });
3802 }
3803 let response = {
3804 let bytes = common::to_bytes(body).await.unwrap_or_default();
3805 let encoded = common::to_string(&bytes);
3806 match serde_json::from_str(&encoded) {
3807 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3808 Err(error) => {
3809 dlg.response_json_decode_error(&encoded, &error);
3810 return Err(common::Error::JsonDecodeError(
3811 encoded.to_string(),
3812 error,
3813 ));
3814 }
3815 }
3816 };
3817
3818 dlg.finished(true);
3819 return Ok(response);
3820 }
3821 }
3822 }
3823 }
3824
3825 /// Required. The name of the function which details should be obtained.
3826 ///
3827 /// Sets the *name* path property to the given value.
3828 ///
3829 /// Even though the property as already been set when instantiating this call,
3830 /// we provide this method for API completeness.
3831 pub fn name(mut self, new_value: &str) -> ProjectLocationFunctionGetCall<'a, C> {
3832 self._name = new_value.to_string();
3833 self
3834 }
3835 /// Optional. The optional version of the function whose details should be obtained. The version of a 1st Gen function is an integer that starts from 1 and gets incremented on redeployments. Each deployment creates a config version of the underlying function. GCF may keep historical configs for old versions. This field can be specified to fetch the historical configs. Leave it blank or set to 0 to get the latest version of the function.
3836 ///
3837 /// Sets the *version id* query property to the given value.
3838 pub fn version_id(mut self, new_value: i64) -> ProjectLocationFunctionGetCall<'a, C> {
3839 self._version_id = Some(new_value);
3840 self
3841 }
3842 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3843 /// while executing the actual API request.
3844 ///
3845 /// ````text
3846 /// It should be used to handle progress information, and to implement a certain level of resilience.
3847 /// ````
3848 ///
3849 /// Sets the *delegate* property to the given value.
3850 pub fn delegate(
3851 mut self,
3852 new_value: &'a mut dyn common::Delegate,
3853 ) -> ProjectLocationFunctionGetCall<'a, C> {
3854 self._delegate = Some(new_value);
3855 self
3856 }
3857
3858 /// Set any additional parameter of the query string used in the request.
3859 /// It should be used to set parameters which are not yet available through their own
3860 /// setters.
3861 ///
3862 /// Please note that this method must not be used to set any of the known parameters
3863 /// which have their own setter method. If done anyway, the request will fail.
3864 ///
3865 /// # Additional Parameters
3866 ///
3867 /// * *$.xgafv* (query-string) - V1 error format.
3868 /// * *access_token* (query-string) - OAuth access token.
3869 /// * *alt* (query-string) - Data format for response.
3870 /// * *callback* (query-string) - JSONP
3871 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3872 /// * *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.
3873 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3874 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3875 /// * *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.
3876 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3877 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3878 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationFunctionGetCall<'a, C>
3879 where
3880 T: AsRef<str>,
3881 {
3882 self._additional_params
3883 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3884 self
3885 }
3886
3887 /// Identifies the authorization scope for the method you are building.
3888 ///
3889 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3890 /// [`Scope::CloudPlatform`].
3891 ///
3892 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3893 /// tokens for more than one scope.
3894 ///
3895 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3896 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3897 /// sufficient, a read-write scope will do as well.
3898 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationFunctionGetCall<'a, C>
3899 where
3900 St: AsRef<str>,
3901 {
3902 self._scopes.insert(String::from(scope.as_ref()));
3903 self
3904 }
3905 /// Identifies the authorization scope(s) for the method you are building.
3906 ///
3907 /// See [`Self::add_scope()`] for details.
3908 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationFunctionGetCall<'a, C>
3909 where
3910 I: IntoIterator<Item = St>,
3911 St: AsRef<str>,
3912 {
3913 self._scopes
3914 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3915 self
3916 }
3917
3918 /// Removes all scopes, and no default scope will be used either.
3919 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3920 /// for details).
3921 pub fn clear_scopes(mut self) -> ProjectLocationFunctionGetCall<'a, C> {
3922 self._scopes.clear();
3923 self
3924 }
3925}
3926
3927/// Gets the IAM access control policy for a function. Returns an empty policy if the function exists and does not have a policy set.
3928///
3929/// A builder for the *locations.functions.getIamPolicy* method supported by a *project* resource.
3930/// It is not used directly, but through a [`ProjectMethods`] instance.
3931///
3932/// # Example
3933///
3934/// Instantiate a resource method builder
3935///
3936/// ```test_harness,no_run
3937/// # extern crate hyper;
3938/// # extern crate hyper_rustls;
3939/// # extern crate google_cloudfunctions1 as cloudfunctions1;
3940/// # async fn dox() {
3941/// # use cloudfunctions1::{CloudFunctions, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3942///
3943/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3944/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3945/// # .with_native_roots()
3946/// # .unwrap()
3947/// # .https_only()
3948/// # .enable_http2()
3949/// # .build();
3950///
3951/// # let executor = hyper_util::rt::TokioExecutor::new();
3952/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3953/// # secret,
3954/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3955/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3956/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3957/// # ),
3958/// # ).build().await.unwrap();
3959///
3960/// # let client = hyper_util::client::legacy::Client::builder(
3961/// # hyper_util::rt::TokioExecutor::new()
3962/// # )
3963/// # .build(
3964/// # hyper_rustls::HttpsConnectorBuilder::new()
3965/// # .with_native_roots()
3966/// # .unwrap()
3967/// # .https_or_http()
3968/// # .enable_http2()
3969/// # .build()
3970/// # );
3971/// # let mut hub = CloudFunctions::new(client, auth);
3972/// // You can configure optional parameters by calling the respective setters at will, and
3973/// // execute the final call using `doit()`.
3974/// // Values shown here are possibly random and not representative !
3975/// let result = hub.projects().locations_functions_get_iam_policy("resource")
3976/// .options_requested_policy_version(-17)
3977/// .doit().await;
3978/// # }
3979/// ```
3980pub struct ProjectLocationFunctionGetIamPolicyCall<'a, C>
3981where
3982 C: 'a,
3983{
3984 hub: &'a CloudFunctions<C>,
3985 _resource: String,
3986 _options_requested_policy_version: Option<i32>,
3987 _delegate: Option<&'a mut dyn common::Delegate>,
3988 _additional_params: HashMap<String, String>,
3989 _scopes: BTreeSet<String>,
3990}
3991
3992impl<'a, C> common::CallBuilder for ProjectLocationFunctionGetIamPolicyCall<'a, C> {}
3993
3994impl<'a, C> ProjectLocationFunctionGetIamPolicyCall<'a, C>
3995where
3996 C: common::Connector,
3997{
3998 /// Perform the operation you have build so far.
3999 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
4000 use std::borrow::Cow;
4001 use std::io::{Read, Seek};
4002
4003 use common::{url::Params, ToParts};
4004 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4005
4006 let mut dd = common::DefaultDelegate;
4007 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4008 dlg.begin(common::MethodInfo {
4009 id: "cloudfunctions.projects.locations.functions.getIamPolicy",
4010 http_method: hyper::Method::GET,
4011 });
4012
4013 for &field in ["alt", "resource", "options.requestedPolicyVersion"].iter() {
4014 if self._additional_params.contains_key(field) {
4015 dlg.finished(false);
4016 return Err(common::Error::FieldClash(field));
4017 }
4018 }
4019
4020 let mut params = Params::with_capacity(4 + self._additional_params.len());
4021 params.push("resource", self._resource);
4022 if let Some(value) = self._options_requested_policy_version.as_ref() {
4023 params.push("options.requestedPolicyVersion", value.to_string());
4024 }
4025
4026 params.extend(self._additional_params.iter());
4027
4028 params.push("alt", "json");
4029 let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
4030 if self._scopes.is_empty() {
4031 self._scopes
4032 .insert(Scope::CloudPlatform.as_ref().to_string());
4033 }
4034
4035 #[allow(clippy::single_element_loop)]
4036 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
4037 url = params.uri_replacement(url, param_name, find_this, true);
4038 }
4039 {
4040 let to_remove = ["resource"];
4041 params.remove_params(&to_remove);
4042 }
4043
4044 let url = params.parse_with_url(&url);
4045
4046 loop {
4047 let token = match self
4048 .hub
4049 .auth
4050 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4051 .await
4052 {
4053 Ok(token) => token,
4054 Err(e) => match dlg.token(e) {
4055 Ok(token) => token,
4056 Err(e) => {
4057 dlg.finished(false);
4058 return Err(common::Error::MissingToken(e));
4059 }
4060 },
4061 };
4062 let mut req_result = {
4063 let client = &self.hub.client;
4064 dlg.pre_request();
4065 let mut req_builder = hyper::Request::builder()
4066 .method(hyper::Method::GET)
4067 .uri(url.as_str())
4068 .header(USER_AGENT, self.hub._user_agent.clone());
4069
4070 if let Some(token) = token.as_ref() {
4071 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4072 }
4073
4074 let request = req_builder
4075 .header(CONTENT_LENGTH, 0_u64)
4076 .body(common::to_body::<String>(None));
4077
4078 client.request(request.unwrap()).await
4079 };
4080
4081 match req_result {
4082 Err(err) => {
4083 if let common::Retry::After(d) = dlg.http_error(&err) {
4084 sleep(d).await;
4085 continue;
4086 }
4087 dlg.finished(false);
4088 return Err(common::Error::HttpError(err));
4089 }
4090 Ok(res) => {
4091 let (mut parts, body) = res.into_parts();
4092 let mut body = common::Body::new(body);
4093 if !parts.status.is_success() {
4094 let bytes = common::to_bytes(body).await.unwrap_or_default();
4095 let error = serde_json::from_str(&common::to_string(&bytes));
4096 let response = common::to_response(parts, bytes.into());
4097
4098 if let common::Retry::After(d) =
4099 dlg.http_failure(&response, error.as_ref().ok())
4100 {
4101 sleep(d).await;
4102 continue;
4103 }
4104
4105 dlg.finished(false);
4106
4107 return Err(match error {
4108 Ok(value) => common::Error::BadRequest(value),
4109 _ => common::Error::Failure(response),
4110 });
4111 }
4112 let response = {
4113 let bytes = common::to_bytes(body).await.unwrap_or_default();
4114 let encoded = common::to_string(&bytes);
4115 match serde_json::from_str(&encoded) {
4116 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4117 Err(error) => {
4118 dlg.response_json_decode_error(&encoded, &error);
4119 return Err(common::Error::JsonDecodeError(
4120 encoded.to_string(),
4121 error,
4122 ));
4123 }
4124 }
4125 };
4126
4127 dlg.finished(true);
4128 return Ok(response);
4129 }
4130 }
4131 }
4132 }
4133
4134 /// 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.
4135 ///
4136 /// Sets the *resource* path property to the given value.
4137 ///
4138 /// Even though the property as already been set when instantiating this call,
4139 /// we provide this method for API completeness.
4140 pub fn resource(mut self, new_value: &str) -> ProjectLocationFunctionGetIamPolicyCall<'a, C> {
4141 self._resource = new_value.to_string();
4142 self
4143 }
4144 /// 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).
4145 ///
4146 /// Sets the *options.requested policy version* query property to the given value.
4147 pub fn options_requested_policy_version(
4148 mut self,
4149 new_value: i32,
4150 ) -> ProjectLocationFunctionGetIamPolicyCall<'a, C> {
4151 self._options_requested_policy_version = Some(new_value);
4152 self
4153 }
4154 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4155 /// while executing the actual API request.
4156 ///
4157 /// ````text
4158 /// It should be used to handle progress information, and to implement a certain level of resilience.
4159 /// ````
4160 ///
4161 /// Sets the *delegate* property to the given value.
4162 pub fn delegate(
4163 mut self,
4164 new_value: &'a mut dyn common::Delegate,
4165 ) -> ProjectLocationFunctionGetIamPolicyCall<'a, C> {
4166 self._delegate = Some(new_value);
4167 self
4168 }
4169
4170 /// Set any additional parameter of the query string used in the request.
4171 /// It should be used to set parameters which are not yet available through their own
4172 /// setters.
4173 ///
4174 /// Please note that this method must not be used to set any of the known parameters
4175 /// which have their own setter method. If done anyway, the request will fail.
4176 ///
4177 /// # Additional Parameters
4178 ///
4179 /// * *$.xgafv* (query-string) - V1 error format.
4180 /// * *access_token* (query-string) - OAuth access token.
4181 /// * *alt* (query-string) - Data format for response.
4182 /// * *callback* (query-string) - JSONP
4183 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4184 /// * *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.
4185 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4186 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4187 /// * *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.
4188 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4189 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4190 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationFunctionGetIamPolicyCall<'a, C>
4191 where
4192 T: AsRef<str>,
4193 {
4194 self._additional_params
4195 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4196 self
4197 }
4198
4199 /// Identifies the authorization scope for the method you are building.
4200 ///
4201 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4202 /// [`Scope::CloudPlatform`].
4203 ///
4204 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4205 /// tokens for more than one scope.
4206 ///
4207 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4208 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4209 /// sufficient, a read-write scope will do as well.
4210 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationFunctionGetIamPolicyCall<'a, C>
4211 where
4212 St: AsRef<str>,
4213 {
4214 self._scopes.insert(String::from(scope.as_ref()));
4215 self
4216 }
4217 /// Identifies the authorization scope(s) for the method you are building.
4218 ///
4219 /// See [`Self::add_scope()`] for details.
4220 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationFunctionGetIamPolicyCall<'a, C>
4221 where
4222 I: IntoIterator<Item = St>,
4223 St: AsRef<str>,
4224 {
4225 self._scopes
4226 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4227 self
4228 }
4229
4230 /// Removes all scopes, and no default scope will be used either.
4231 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4232 /// for details).
4233 pub fn clear_scopes(mut self) -> ProjectLocationFunctionGetIamPolicyCall<'a, C> {
4234 self._scopes.clear();
4235 self
4236 }
4237}
4238
4239/// Returns a list of functions that belong to the requested project.
4240///
4241/// A builder for the *locations.functions.list* method supported by a *project* resource.
4242/// It is not used directly, but through a [`ProjectMethods`] instance.
4243///
4244/// # Example
4245///
4246/// Instantiate a resource method builder
4247///
4248/// ```test_harness,no_run
4249/// # extern crate hyper;
4250/// # extern crate hyper_rustls;
4251/// # extern crate google_cloudfunctions1 as cloudfunctions1;
4252/// # async fn dox() {
4253/// # use cloudfunctions1::{CloudFunctions, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4254///
4255/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4256/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4257/// # .with_native_roots()
4258/// # .unwrap()
4259/// # .https_only()
4260/// # .enable_http2()
4261/// # .build();
4262///
4263/// # let executor = hyper_util::rt::TokioExecutor::new();
4264/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4265/// # secret,
4266/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4267/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4268/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4269/// # ),
4270/// # ).build().await.unwrap();
4271///
4272/// # let client = hyper_util::client::legacy::Client::builder(
4273/// # hyper_util::rt::TokioExecutor::new()
4274/// # )
4275/// # .build(
4276/// # hyper_rustls::HttpsConnectorBuilder::new()
4277/// # .with_native_roots()
4278/// # .unwrap()
4279/// # .https_or_http()
4280/// # .enable_http2()
4281/// # .build()
4282/// # );
4283/// # let mut hub = CloudFunctions::new(client, auth);
4284/// // You can configure optional parameters by calling the respective setters at will, and
4285/// // execute the final call using `doit()`.
4286/// // Values shown here are possibly random and not representative !
4287/// let result = hub.projects().locations_functions_list("parent")
4288/// .page_token("Lorem")
4289/// .page_size(-25)
4290/// .doit().await;
4291/// # }
4292/// ```
4293pub struct ProjectLocationFunctionListCall<'a, C>
4294where
4295 C: 'a,
4296{
4297 hub: &'a CloudFunctions<C>,
4298 _parent: String,
4299 _page_token: Option<String>,
4300 _page_size: Option<i32>,
4301 _delegate: Option<&'a mut dyn common::Delegate>,
4302 _additional_params: HashMap<String, String>,
4303 _scopes: BTreeSet<String>,
4304}
4305
4306impl<'a, C> common::CallBuilder for ProjectLocationFunctionListCall<'a, C> {}
4307
4308impl<'a, C> ProjectLocationFunctionListCall<'a, C>
4309where
4310 C: common::Connector,
4311{
4312 /// Perform the operation you have build so far.
4313 pub async fn doit(mut self) -> common::Result<(common::Response, ListFunctionsResponse)> {
4314 use std::borrow::Cow;
4315 use std::io::{Read, Seek};
4316
4317 use common::{url::Params, ToParts};
4318 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4319
4320 let mut dd = common::DefaultDelegate;
4321 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4322 dlg.begin(common::MethodInfo {
4323 id: "cloudfunctions.projects.locations.functions.list",
4324 http_method: hyper::Method::GET,
4325 });
4326
4327 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
4328 if self._additional_params.contains_key(field) {
4329 dlg.finished(false);
4330 return Err(common::Error::FieldClash(field));
4331 }
4332 }
4333
4334 let mut params = Params::with_capacity(5 + self._additional_params.len());
4335 params.push("parent", self._parent);
4336 if let Some(value) = self._page_token.as_ref() {
4337 params.push("pageToken", value);
4338 }
4339 if let Some(value) = self._page_size.as_ref() {
4340 params.push("pageSize", value.to_string());
4341 }
4342
4343 params.extend(self._additional_params.iter());
4344
4345 params.push("alt", "json");
4346 let mut url = self.hub._base_url.clone() + "v1/{+parent}/functions";
4347 if self._scopes.is_empty() {
4348 self._scopes
4349 .insert(Scope::CloudPlatform.as_ref().to_string());
4350 }
4351
4352 #[allow(clippy::single_element_loop)]
4353 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4354 url = params.uri_replacement(url, param_name, find_this, true);
4355 }
4356 {
4357 let to_remove = ["parent"];
4358 params.remove_params(&to_remove);
4359 }
4360
4361 let url = params.parse_with_url(&url);
4362
4363 loop {
4364 let token = match self
4365 .hub
4366 .auth
4367 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4368 .await
4369 {
4370 Ok(token) => token,
4371 Err(e) => match dlg.token(e) {
4372 Ok(token) => token,
4373 Err(e) => {
4374 dlg.finished(false);
4375 return Err(common::Error::MissingToken(e));
4376 }
4377 },
4378 };
4379 let mut req_result = {
4380 let client = &self.hub.client;
4381 dlg.pre_request();
4382 let mut req_builder = hyper::Request::builder()
4383 .method(hyper::Method::GET)
4384 .uri(url.as_str())
4385 .header(USER_AGENT, self.hub._user_agent.clone());
4386
4387 if let Some(token) = token.as_ref() {
4388 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4389 }
4390
4391 let request = req_builder
4392 .header(CONTENT_LENGTH, 0_u64)
4393 .body(common::to_body::<String>(None));
4394
4395 client.request(request.unwrap()).await
4396 };
4397
4398 match req_result {
4399 Err(err) => {
4400 if let common::Retry::After(d) = dlg.http_error(&err) {
4401 sleep(d).await;
4402 continue;
4403 }
4404 dlg.finished(false);
4405 return Err(common::Error::HttpError(err));
4406 }
4407 Ok(res) => {
4408 let (mut parts, body) = res.into_parts();
4409 let mut body = common::Body::new(body);
4410 if !parts.status.is_success() {
4411 let bytes = common::to_bytes(body).await.unwrap_or_default();
4412 let error = serde_json::from_str(&common::to_string(&bytes));
4413 let response = common::to_response(parts, bytes.into());
4414
4415 if let common::Retry::After(d) =
4416 dlg.http_failure(&response, error.as_ref().ok())
4417 {
4418 sleep(d).await;
4419 continue;
4420 }
4421
4422 dlg.finished(false);
4423
4424 return Err(match error {
4425 Ok(value) => common::Error::BadRequest(value),
4426 _ => common::Error::Failure(response),
4427 });
4428 }
4429 let response = {
4430 let bytes = common::to_bytes(body).await.unwrap_or_default();
4431 let encoded = common::to_string(&bytes);
4432 match serde_json::from_str(&encoded) {
4433 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4434 Err(error) => {
4435 dlg.response_json_decode_error(&encoded, &error);
4436 return Err(common::Error::JsonDecodeError(
4437 encoded.to_string(),
4438 error,
4439 ));
4440 }
4441 }
4442 };
4443
4444 dlg.finished(true);
4445 return Ok(response);
4446 }
4447 }
4448 }
4449 }
4450
4451 /// The project and location from which the function should be listed, specified in the format `projects/*/locations/*` If you want to list functions in all locations, use "-" in place of a location. When listing functions in all locations, if one or more location(s) are unreachable, the response will contain functions from all reachable locations along with the names of any unreachable locations.
4452 ///
4453 /// Sets the *parent* path property to the given value.
4454 ///
4455 /// Even though the property as already been set when instantiating this call,
4456 /// we provide this method for API completeness.
4457 pub fn parent(mut self, new_value: &str) -> ProjectLocationFunctionListCall<'a, C> {
4458 self._parent = new_value.to_string();
4459 self
4460 }
4461 /// The value returned by the last `ListFunctionsResponse`; indicates that this is a continuation of a prior `ListFunctions` call, and that the system should return the next page of data.
4462 ///
4463 /// Sets the *page token* query property to the given value.
4464 pub fn page_token(mut self, new_value: &str) -> ProjectLocationFunctionListCall<'a, C> {
4465 self._page_token = Some(new_value.to_string());
4466 self
4467 }
4468 /// Maximum number of functions to return per call.
4469 ///
4470 /// Sets the *page size* query property to the given value.
4471 pub fn page_size(mut self, new_value: i32) -> ProjectLocationFunctionListCall<'a, C> {
4472 self._page_size = Some(new_value);
4473 self
4474 }
4475 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4476 /// while executing the actual API request.
4477 ///
4478 /// ````text
4479 /// It should be used to handle progress information, and to implement a certain level of resilience.
4480 /// ````
4481 ///
4482 /// Sets the *delegate* property to the given value.
4483 pub fn delegate(
4484 mut self,
4485 new_value: &'a mut dyn common::Delegate,
4486 ) -> ProjectLocationFunctionListCall<'a, C> {
4487 self._delegate = Some(new_value);
4488 self
4489 }
4490
4491 /// Set any additional parameter of the query string used in the request.
4492 /// It should be used to set parameters which are not yet available through their own
4493 /// setters.
4494 ///
4495 /// Please note that this method must not be used to set any of the known parameters
4496 /// which have their own setter method. If done anyway, the request will fail.
4497 ///
4498 /// # Additional Parameters
4499 ///
4500 /// * *$.xgafv* (query-string) - V1 error format.
4501 /// * *access_token* (query-string) - OAuth access token.
4502 /// * *alt* (query-string) - Data format for response.
4503 /// * *callback* (query-string) - JSONP
4504 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4505 /// * *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.
4506 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4507 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4508 /// * *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.
4509 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4510 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4511 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationFunctionListCall<'a, C>
4512 where
4513 T: AsRef<str>,
4514 {
4515 self._additional_params
4516 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4517 self
4518 }
4519
4520 /// Identifies the authorization scope for the method you are building.
4521 ///
4522 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4523 /// [`Scope::CloudPlatform`].
4524 ///
4525 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4526 /// tokens for more than one scope.
4527 ///
4528 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4529 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4530 /// sufficient, a read-write scope will do as well.
4531 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationFunctionListCall<'a, C>
4532 where
4533 St: AsRef<str>,
4534 {
4535 self._scopes.insert(String::from(scope.as_ref()));
4536 self
4537 }
4538 /// Identifies the authorization scope(s) for the method you are building.
4539 ///
4540 /// See [`Self::add_scope()`] for details.
4541 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationFunctionListCall<'a, C>
4542 where
4543 I: IntoIterator<Item = St>,
4544 St: AsRef<str>,
4545 {
4546 self._scopes
4547 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4548 self
4549 }
4550
4551 /// Removes all scopes, and no default scope will be used either.
4552 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4553 /// for details).
4554 pub fn clear_scopes(mut self) -> ProjectLocationFunctionListCall<'a, C> {
4555 self._scopes.clear();
4556 self
4557 }
4558}
4559
4560/// Updates existing function.
4561///
4562/// A builder for the *locations.functions.patch* method supported by a *project* resource.
4563/// It is not used directly, but through a [`ProjectMethods`] instance.
4564///
4565/// # Example
4566///
4567/// Instantiate a resource method builder
4568///
4569/// ```test_harness,no_run
4570/// # extern crate hyper;
4571/// # extern crate hyper_rustls;
4572/// # extern crate google_cloudfunctions1 as cloudfunctions1;
4573/// use cloudfunctions1::api::CloudFunction;
4574/// # async fn dox() {
4575/// # use cloudfunctions1::{CloudFunctions, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4576///
4577/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4578/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4579/// # .with_native_roots()
4580/// # .unwrap()
4581/// # .https_only()
4582/// # .enable_http2()
4583/// # .build();
4584///
4585/// # let executor = hyper_util::rt::TokioExecutor::new();
4586/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4587/// # secret,
4588/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4589/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4590/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4591/// # ),
4592/// # ).build().await.unwrap();
4593///
4594/// # let client = hyper_util::client::legacy::Client::builder(
4595/// # hyper_util::rt::TokioExecutor::new()
4596/// # )
4597/// # .build(
4598/// # hyper_rustls::HttpsConnectorBuilder::new()
4599/// # .with_native_roots()
4600/// # .unwrap()
4601/// # .https_or_http()
4602/// # .enable_http2()
4603/// # .build()
4604/// # );
4605/// # let mut hub = CloudFunctions::new(client, auth);
4606/// // As the method needs a request, you would usually fill it with the desired information
4607/// // into the respective structure. Some of the parts shown here might not be applicable !
4608/// // Values shown here are possibly random and not representative !
4609/// let mut req = CloudFunction::default();
4610///
4611/// // You can configure optional parameters by calling the respective setters at will, and
4612/// // execute the final call using `doit()`.
4613/// // Values shown here are possibly random and not representative !
4614/// let result = hub.projects().locations_functions_patch(req, "name")
4615/// .update_mask(FieldMask::new::<&str>(&[]))
4616/// .doit().await;
4617/// # }
4618/// ```
4619pub struct ProjectLocationFunctionPatchCall<'a, C>
4620where
4621 C: 'a,
4622{
4623 hub: &'a CloudFunctions<C>,
4624 _request: CloudFunction,
4625 _name: String,
4626 _update_mask: Option<common::FieldMask>,
4627 _delegate: Option<&'a mut dyn common::Delegate>,
4628 _additional_params: HashMap<String, String>,
4629 _scopes: BTreeSet<String>,
4630}
4631
4632impl<'a, C> common::CallBuilder for ProjectLocationFunctionPatchCall<'a, C> {}
4633
4634impl<'a, C> ProjectLocationFunctionPatchCall<'a, C>
4635where
4636 C: common::Connector,
4637{
4638 /// Perform the operation you have build so far.
4639 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
4640 use std::borrow::Cow;
4641 use std::io::{Read, Seek};
4642
4643 use common::{url::Params, ToParts};
4644 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4645
4646 let mut dd = common::DefaultDelegate;
4647 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4648 dlg.begin(common::MethodInfo {
4649 id: "cloudfunctions.projects.locations.functions.patch",
4650 http_method: hyper::Method::PATCH,
4651 });
4652
4653 for &field in ["alt", "name", "updateMask"].iter() {
4654 if self._additional_params.contains_key(field) {
4655 dlg.finished(false);
4656 return Err(common::Error::FieldClash(field));
4657 }
4658 }
4659
4660 let mut params = Params::with_capacity(5 + self._additional_params.len());
4661 params.push("name", self._name);
4662 if let Some(value) = self._update_mask.as_ref() {
4663 params.push("updateMask", value.to_string());
4664 }
4665
4666 params.extend(self._additional_params.iter());
4667
4668 params.push("alt", "json");
4669 let mut url = self.hub._base_url.clone() + "v1/{+name}";
4670 if self._scopes.is_empty() {
4671 self._scopes
4672 .insert(Scope::CloudPlatform.as_ref().to_string());
4673 }
4674
4675 #[allow(clippy::single_element_loop)]
4676 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4677 url = params.uri_replacement(url, param_name, find_this, true);
4678 }
4679 {
4680 let to_remove = ["name"];
4681 params.remove_params(&to_remove);
4682 }
4683
4684 let url = params.parse_with_url(&url);
4685
4686 let mut json_mime_type = mime::APPLICATION_JSON;
4687 let mut request_value_reader = {
4688 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4689 common::remove_json_null_values(&mut value);
4690 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4691 serde_json::to_writer(&mut dst, &value).unwrap();
4692 dst
4693 };
4694 let request_size = request_value_reader
4695 .seek(std::io::SeekFrom::End(0))
4696 .unwrap();
4697 request_value_reader
4698 .seek(std::io::SeekFrom::Start(0))
4699 .unwrap();
4700
4701 loop {
4702 let token = match self
4703 .hub
4704 .auth
4705 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4706 .await
4707 {
4708 Ok(token) => token,
4709 Err(e) => match dlg.token(e) {
4710 Ok(token) => token,
4711 Err(e) => {
4712 dlg.finished(false);
4713 return Err(common::Error::MissingToken(e));
4714 }
4715 },
4716 };
4717 request_value_reader
4718 .seek(std::io::SeekFrom::Start(0))
4719 .unwrap();
4720 let mut req_result = {
4721 let client = &self.hub.client;
4722 dlg.pre_request();
4723 let mut req_builder = hyper::Request::builder()
4724 .method(hyper::Method::PATCH)
4725 .uri(url.as_str())
4726 .header(USER_AGENT, self.hub._user_agent.clone());
4727
4728 if let Some(token) = token.as_ref() {
4729 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4730 }
4731
4732 let request = req_builder
4733 .header(CONTENT_TYPE, json_mime_type.to_string())
4734 .header(CONTENT_LENGTH, request_size as u64)
4735 .body(common::to_body(
4736 request_value_reader.get_ref().clone().into(),
4737 ));
4738
4739 client.request(request.unwrap()).await
4740 };
4741
4742 match req_result {
4743 Err(err) => {
4744 if let common::Retry::After(d) = dlg.http_error(&err) {
4745 sleep(d).await;
4746 continue;
4747 }
4748 dlg.finished(false);
4749 return Err(common::Error::HttpError(err));
4750 }
4751 Ok(res) => {
4752 let (mut parts, body) = res.into_parts();
4753 let mut body = common::Body::new(body);
4754 if !parts.status.is_success() {
4755 let bytes = common::to_bytes(body).await.unwrap_or_default();
4756 let error = serde_json::from_str(&common::to_string(&bytes));
4757 let response = common::to_response(parts, bytes.into());
4758
4759 if let common::Retry::After(d) =
4760 dlg.http_failure(&response, error.as_ref().ok())
4761 {
4762 sleep(d).await;
4763 continue;
4764 }
4765
4766 dlg.finished(false);
4767
4768 return Err(match error {
4769 Ok(value) => common::Error::BadRequest(value),
4770 _ => common::Error::Failure(response),
4771 });
4772 }
4773 let response = {
4774 let bytes = common::to_bytes(body).await.unwrap_or_default();
4775 let encoded = common::to_string(&bytes);
4776 match serde_json::from_str(&encoded) {
4777 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4778 Err(error) => {
4779 dlg.response_json_decode_error(&encoded, &error);
4780 return Err(common::Error::JsonDecodeError(
4781 encoded.to_string(),
4782 error,
4783 ));
4784 }
4785 }
4786 };
4787
4788 dlg.finished(true);
4789 return Ok(response);
4790 }
4791 }
4792 }
4793 }
4794
4795 ///
4796 /// Sets the *request* property to the given value.
4797 ///
4798 /// Even though the property as already been set when instantiating this call,
4799 /// we provide this method for API completeness.
4800 pub fn request(mut self, new_value: CloudFunction) -> ProjectLocationFunctionPatchCall<'a, C> {
4801 self._request = new_value;
4802 self
4803 }
4804 /// A user-defined name of the function. Function names must be unique globally and match pattern `projects/*/locations/*/functions/*`
4805 ///
4806 /// Sets the *name* path property to the given value.
4807 ///
4808 /// Even though the property as already been set when instantiating this call,
4809 /// we provide this method for API completeness.
4810 pub fn name(mut self, new_value: &str) -> ProjectLocationFunctionPatchCall<'a, C> {
4811 self._name = new_value.to_string();
4812 self
4813 }
4814 /// Required. The list of fields in `CloudFunction` that have to be updated.
4815 ///
4816 /// Sets the *update mask* query property to the given value.
4817 pub fn update_mask(
4818 mut self,
4819 new_value: common::FieldMask,
4820 ) -> ProjectLocationFunctionPatchCall<'a, C> {
4821 self._update_mask = Some(new_value);
4822 self
4823 }
4824 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4825 /// while executing the actual API request.
4826 ///
4827 /// ````text
4828 /// It should be used to handle progress information, and to implement a certain level of resilience.
4829 /// ````
4830 ///
4831 /// Sets the *delegate* property to the given value.
4832 pub fn delegate(
4833 mut self,
4834 new_value: &'a mut dyn common::Delegate,
4835 ) -> ProjectLocationFunctionPatchCall<'a, C> {
4836 self._delegate = Some(new_value);
4837 self
4838 }
4839
4840 /// Set any additional parameter of the query string used in the request.
4841 /// It should be used to set parameters which are not yet available through their own
4842 /// setters.
4843 ///
4844 /// Please note that this method must not be used to set any of the known parameters
4845 /// which have their own setter method. If done anyway, the request will fail.
4846 ///
4847 /// # Additional Parameters
4848 ///
4849 /// * *$.xgafv* (query-string) - V1 error format.
4850 /// * *access_token* (query-string) - OAuth access token.
4851 /// * *alt* (query-string) - Data format for response.
4852 /// * *callback* (query-string) - JSONP
4853 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4854 /// * *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.
4855 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4856 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4857 /// * *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.
4858 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4859 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4860 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationFunctionPatchCall<'a, C>
4861 where
4862 T: AsRef<str>,
4863 {
4864 self._additional_params
4865 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4866 self
4867 }
4868
4869 /// Identifies the authorization scope for the method you are building.
4870 ///
4871 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4872 /// [`Scope::CloudPlatform`].
4873 ///
4874 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4875 /// tokens for more than one scope.
4876 ///
4877 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4878 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4879 /// sufficient, a read-write scope will do as well.
4880 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationFunctionPatchCall<'a, C>
4881 where
4882 St: AsRef<str>,
4883 {
4884 self._scopes.insert(String::from(scope.as_ref()));
4885 self
4886 }
4887 /// Identifies the authorization scope(s) for the method you are building.
4888 ///
4889 /// See [`Self::add_scope()`] for details.
4890 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationFunctionPatchCall<'a, C>
4891 where
4892 I: IntoIterator<Item = St>,
4893 St: AsRef<str>,
4894 {
4895 self._scopes
4896 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4897 self
4898 }
4899
4900 /// Removes all scopes, and no default scope will be used either.
4901 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4902 /// for details).
4903 pub fn clear_scopes(mut self) -> ProjectLocationFunctionPatchCall<'a, C> {
4904 self._scopes.clear();
4905 self
4906 }
4907}
4908
4909/// Sets the IAM access control policy on the specified function. Replaces any existing policy.
4910///
4911/// A builder for the *locations.functions.setIamPolicy* method supported by a *project* resource.
4912/// It is not used directly, but through a [`ProjectMethods`] instance.
4913///
4914/// # Example
4915///
4916/// Instantiate a resource method builder
4917///
4918/// ```test_harness,no_run
4919/// # extern crate hyper;
4920/// # extern crate hyper_rustls;
4921/// # extern crate google_cloudfunctions1 as cloudfunctions1;
4922/// use cloudfunctions1::api::SetIamPolicyRequest;
4923/// # async fn dox() {
4924/// # use cloudfunctions1::{CloudFunctions, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4925///
4926/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4927/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4928/// # .with_native_roots()
4929/// # .unwrap()
4930/// # .https_only()
4931/// # .enable_http2()
4932/// # .build();
4933///
4934/// # let executor = hyper_util::rt::TokioExecutor::new();
4935/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4936/// # secret,
4937/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4938/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4939/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4940/// # ),
4941/// # ).build().await.unwrap();
4942///
4943/// # let client = hyper_util::client::legacy::Client::builder(
4944/// # hyper_util::rt::TokioExecutor::new()
4945/// # )
4946/// # .build(
4947/// # hyper_rustls::HttpsConnectorBuilder::new()
4948/// # .with_native_roots()
4949/// # .unwrap()
4950/// # .https_or_http()
4951/// # .enable_http2()
4952/// # .build()
4953/// # );
4954/// # let mut hub = CloudFunctions::new(client, auth);
4955/// // As the method needs a request, you would usually fill it with the desired information
4956/// // into the respective structure. Some of the parts shown here might not be applicable !
4957/// // Values shown here are possibly random and not representative !
4958/// let mut req = SetIamPolicyRequest::default();
4959///
4960/// // You can configure optional parameters by calling the respective setters at will, and
4961/// // execute the final call using `doit()`.
4962/// // Values shown here are possibly random and not representative !
4963/// let result = hub.projects().locations_functions_set_iam_policy(req, "resource")
4964/// .doit().await;
4965/// # }
4966/// ```
4967pub struct ProjectLocationFunctionSetIamPolicyCall<'a, C>
4968where
4969 C: 'a,
4970{
4971 hub: &'a CloudFunctions<C>,
4972 _request: SetIamPolicyRequest,
4973 _resource: String,
4974 _delegate: Option<&'a mut dyn common::Delegate>,
4975 _additional_params: HashMap<String, String>,
4976 _scopes: BTreeSet<String>,
4977}
4978
4979impl<'a, C> common::CallBuilder for ProjectLocationFunctionSetIamPolicyCall<'a, C> {}
4980
4981impl<'a, C> ProjectLocationFunctionSetIamPolicyCall<'a, C>
4982where
4983 C: common::Connector,
4984{
4985 /// Perform the operation you have build so far.
4986 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
4987 use std::borrow::Cow;
4988 use std::io::{Read, Seek};
4989
4990 use common::{url::Params, ToParts};
4991 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4992
4993 let mut dd = common::DefaultDelegate;
4994 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4995 dlg.begin(common::MethodInfo {
4996 id: "cloudfunctions.projects.locations.functions.setIamPolicy",
4997 http_method: hyper::Method::POST,
4998 });
4999
5000 for &field in ["alt", "resource"].iter() {
5001 if self._additional_params.contains_key(field) {
5002 dlg.finished(false);
5003 return Err(common::Error::FieldClash(field));
5004 }
5005 }
5006
5007 let mut params = Params::with_capacity(4 + self._additional_params.len());
5008 params.push("resource", self._resource);
5009
5010 params.extend(self._additional_params.iter());
5011
5012 params.push("alt", "json");
5013 let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
5014 if self._scopes.is_empty() {
5015 self._scopes
5016 .insert(Scope::CloudPlatform.as_ref().to_string());
5017 }
5018
5019 #[allow(clippy::single_element_loop)]
5020 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
5021 url = params.uri_replacement(url, param_name, find_this, true);
5022 }
5023 {
5024 let to_remove = ["resource"];
5025 params.remove_params(&to_remove);
5026 }
5027
5028 let url = params.parse_with_url(&url);
5029
5030 let mut json_mime_type = mime::APPLICATION_JSON;
5031 let mut request_value_reader = {
5032 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5033 common::remove_json_null_values(&mut value);
5034 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5035 serde_json::to_writer(&mut dst, &value).unwrap();
5036 dst
5037 };
5038 let request_size = request_value_reader
5039 .seek(std::io::SeekFrom::End(0))
5040 .unwrap();
5041 request_value_reader
5042 .seek(std::io::SeekFrom::Start(0))
5043 .unwrap();
5044
5045 loop {
5046 let token = match self
5047 .hub
5048 .auth
5049 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5050 .await
5051 {
5052 Ok(token) => token,
5053 Err(e) => match dlg.token(e) {
5054 Ok(token) => token,
5055 Err(e) => {
5056 dlg.finished(false);
5057 return Err(common::Error::MissingToken(e));
5058 }
5059 },
5060 };
5061 request_value_reader
5062 .seek(std::io::SeekFrom::Start(0))
5063 .unwrap();
5064 let mut req_result = {
5065 let client = &self.hub.client;
5066 dlg.pre_request();
5067 let mut req_builder = hyper::Request::builder()
5068 .method(hyper::Method::POST)
5069 .uri(url.as_str())
5070 .header(USER_AGENT, self.hub._user_agent.clone());
5071
5072 if let Some(token) = token.as_ref() {
5073 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5074 }
5075
5076 let request = req_builder
5077 .header(CONTENT_TYPE, json_mime_type.to_string())
5078 .header(CONTENT_LENGTH, request_size as u64)
5079 .body(common::to_body(
5080 request_value_reader.get_ref().clone().into(),
5081 ));
5082
5083 client.request(request.unwrap()).await
5084 };
5085
5086 match req_result {
5087 Err(err) => {
5088 if let common::Retry::After(d) = dlg.http_error(&err) {
5089 sleep(d).await;
5090 continue;
5091 }
5092 dlg.finished(false);
5093 return Err(common::Error::HttpError(err));
5094 }
5095 Ok(res) => {
5096 let (mut parts, body) = res.into_parts();
5097 let mut body = common::Body::new(body);
5098 if !parts.status.is_success() {
5099 let bytes = common::to_bytes(body).await.unwrap_or_default();
5100 let error = serde_json::from_str(&common::to_string(&bytes));
5101 let response = common::to_response(parts, bytes.into());
5102
5103 if let common::Retry::After(d) =
5104 dlg.http_failure(&response, error.as_ref().ok())
5105 {
5106 sleep(d).await;
5107 continue;
5108 }
5109
5110 dlg.finished(false);
5111
5112 return Err(match error {
5113 Ok(value) => common::Error::BadRequest(value),
5114 _ => common::Error::Failure(response),
5115 });
5116 }
5117 let response = {
5118 let bytes = common::to_bytes(body).await.unwrap_or_default();
5119 let encoded = common::to_string(&bytes);
5120 match serde_json::from_str(&encoded) {
5121 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5122 Err(error) => {
5123 dlg.response_json_decode_error(&encoded, &error);
5124 return Err(common::Error::JsonDecodeError(
5125 encoded.to_string(),
5126 error,
5127 ));
5128 }
5129 }
5130 };
5131
5132 dlg.finished(true);
5133 return Ok(response);
5134 }
5135 }
5136 }
5137 }
5138
5139 ///
5140 /// Sets the *request* property to the given value.
5141 ///
5142 /// Even though the property as already been set when instantiating this call,
5143 /// we provide this method for API completeness.
5144 pub fn request(
5145 mut self,
5146 new_value: SetIamPolicyRequest,
5147 ) -> ProjectLocationFunctionSetIamPolicyCall<'a, C> {
5148 self._request = new_value;
5149 self
5150 }
5151 /// 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.
5152 ///
5153 /// Sets the *resource* path property to the given value.
5154 ///
5155 /// Even though the property as already been set when instantiating this call,
5156 /// we provide this method for API completeness.
5157 pub fn resource(mut self, new_value: &str) -> ProjectLocationFunctionSetIamPolicyCall<'a, C> {
5158 self._resource = new_value.to_string();
5159 self
5160 }
5161 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5162 /// while executing the actual API request.
5163 ///
5164 /// ````text
5165 /// It should be used to handle progress information, and to implement a certain level of resilience.
5166 /// ````
5167 ///
5168 /// Sets the *delegate* property to the given value.
5169 pub fn delegate(
5170 mut self,
5171 new_value: &'a mut dyn common::Delegate,
5172 ) -> ProjectLocationFunctionSetIamPolicyCall<'a, C> {
5173 self._delegate = Some(new_value);
5174 self
5175 }
5176
5177 /// Set any additional parameter of the query string used in the request.
5178 /// It should be used to set parameters which are not yet available through their own
5179 /// setters.
5180 ///
5181 /// Please note that this method must not be used to set any of the known parameters
5182 /// which have their own setter method. If done anyway, the request will fail.
5183 ///
5184 /// # Additional Parameters
5185 ///
5186 /// * *$.xgafv* (query-string) - V1 error format.
5187 /// * *access_token* (query-string) - OAuth access token.
5188 /// * *alt* (query-string) - Data format for response.
5189 /// * *callback* (query-string) - JSONP
5190 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5191 /// * *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.
5192 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5193 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5194 /// * *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.
5195 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5196 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5197 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationFunctionSetIamPolicyCall<'a, C>
5198 where
5199 T: AsRef<str>,
5200 {
5201 self._additional_params
5202 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5203 self
5204 }
5205
5206 /// Identifies the authorization scope for the method you are building.
5207 ///
5208 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5209 /// [`Scope::CloudPlatform`].
5210 ///
5211 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5212 /// tokens for more than one scope.
5213 ///
5214 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5215 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5216 /// sufficient, a read-write scope will do as well.
5217 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationFunctionSetIamPolicyCall<'a, C>
5218 where
5219 St: AsRef<str>,
5220 {
5221 self._scopes.insert(String::from(scope.as_ref()));
5222 self
5223 }
5224 /// Identifies the authorization scope(s) for the method you are building.
5225 ///
5226 /// See [`Self::add_scope()`] for details.
5227 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationFunctionSetIamPolicyCall<'a, C>
5228 where
5229 I: IntoIterator<Item = St>,
5230 St: AsRef<str>,
5231 {
5232 self._scopes
5233 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5234 self
5235 }
5236
5237 /// Removes all scopes, and no default scope will be used either.
5238 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5239 /// for details).
5240 pub fn clear_scopes(mut self) -> ProjectLocationFunctionSetIamPolicyCall<'a, C> {
5241 self._scopes.clear();
5242 self
5243 }
5244}
5245
5246/// Tests the specified permissions against the IAM access control policy for a function. If the function does not exist, this will return an empty set of permissions, not a NOT_FOUND error.
5247///
5248/// A builder for the *locations.functions.testIamPermissions* method supported by a *project* resource.
5249/// It is not used directly, but through a [`ProjectMethods`] instance.
5250///
5251/// # Example
5252///
5253/// Instantiate a resource method builder
5254///
5255/// ```test_harness,no_run
5256/// # extern crate hyper;
5257/// # extern crate hyper_rustls;
5258/// # extern crate google_cloudfunctions1 as cloudfunctions1;
5259/// use cloudfunctions1::api::TestIamPermissionsRequest;
5260/// # async fn dox() {
5261/// # use cloudfunctions1::{CloudFunctions, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5262///
5263/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5264/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5265/// # .with_native_roots()
5266/// # .unwrap()
5267/// # .https_only()
5268/// # .enable_http2()
5269/// # .build();
5270///
5271/// # let executor = hyper_util::rt::TokioExecutor::new();
5272/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5273/// # secret,
5274/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5275/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5276/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5277/// # ),
5278/// # ).build().await.unwrap();
5279///
5280/// # let client = hyper_util::client::legacy::Client::builder(
5281/// # hyper_util::rt::TokioExecutor::new()
5282/// # )
5283/// # .build(
5284/// # hyper_rustls::HttpsConnectorBuilder::new()
5285/// # .with_native_roots()
5286/// # .unwrap()
5287/// # .https_or_http()
5288/// # .enable_http2()
5289/// # .build()
5290/// # );
5291/// # let mut hub = CloudFunctions::new(client, auth);
5292/// // As the method needs a request, you would usually fill it with the desired information
5293/// // into the respective structure. Some of the parts shown here might not be applicable !
5294/// // Values shown here are possibly random and not representative !
5295/// let mut req = TestIamPermissionsRequest::default();
5296///
5297/// // You can configure optional parameters by calling the respective setters at will, and
5298/// // execute the final call using `doit()`.
5299/// // Values shown here are possibly random and not representative !
5300/// let result = hub.projects().locations_functions_test_iam_permissions(req, "resource")
5301/// .doit().await;
5302/// # }
5303/// ```
5304pub struct ProjectLocationFunctionTestIamPermissionCall<'a, C>
5305where
5306 C: 'a,
5307{
5308 hub: &'a CloudFunctions<C>,
5309 _request: TestIamPermissionsRequest,
5310 _resource: String,
5311 _delegate: Option<&'a mut dyn common::Delegate>,
5312 _additional_params: HashMap<String, String>,
5313 _scopes: BTreeSet<String>,
5314}
5315
5316impl<'a, C> common::CallBuilder for ProjectLocationFunctionTestIamPermissionCall<'a, C> {}
5317
5318impl<'a, C> ProjectLocationFunctionTestIamPermissionCall<'a, C>
5319where
5320 C: common::Connector,
5321{
5322 /// Perform the operation you have build so far.
5323 pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
5324 use std::borrow::Cow;
5325 use std::io::{Read, Seek};
5326
5327 use common::{url::Params, ToParts};
5328 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5329
5330 let mut dd = common::DefaultDelegate;
5331 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5332 dlg.begin(common::MethodInfo {
5333 id: "cloudfunctions.projects.locations.functions.testIamPermissions",
5334 http_method: hyper::Method::POST,
5335 });
5336
5337 for &field in ["alt", "resource"].iter() {
5338 if self._additional_params.contains_key(field) {
5339 dlg.finished(false);
5340 return Err(common::Error::FieldClash(field));
5341 }
5342 }
5343
5344 let mut params = Params::with_capacity(4 + self._additional_params.len());
5345 params.push("resource", self._resource);
5346
5347 params.extend(self._additional_params.iter());
5348
5349 params.push("alt", "json");
5350 let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
5351 if self._scopes.is_empty() {
5352 self._scopes
5353 .insert(Scope::CloudPlatform.as_ref().to_string());
5354 }
5355
5356 #[allow(clippy::single_element_loop)]
5357 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
5358 url = params.uri_replacement(url, param_name, find_this, true);
5359 }
5360 {
5361 let to_remove = ["resource"];
5362 params.remove_params(&to_remove);
5363 }
5364
5365 let url = params.parse_with_url(&url);
5366
5367 let mut json_mime_type = mime::APPLICATION_JSON;
5368 let mut request_value_reader = {
5369 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5370 common::remove_json_null_values(&mut value);
5371 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5372 serde_json::to_writer(&mut dst, &value).unwrap();
5373 dst
5374 };
5375 let request_size = request_value_reader
5376 .seek(std::io::SeekFrom::End(0))
5377 .unwrap();
5378 request_value_reader
5379 .seek(std::io::SeekFrom::Start(0))
5380 .unwrap();
5381
5382 loop {
5383 let token = match self
5384 .hub
5385 .auth
5386 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5387 .await
5388 {
5389 Ok(token) => token,
5390 Err(e) => match dlg.token(e) {
5391 Ok(token) => token,
5392 Err(e) => {
5393 dlg.finished(false);
5394 return Err(common::Error::MissingToken(e));
5395 }
5396 },
5397 };
5398 request_value_reader
5399 .seek(std::io::SeekFrom::Start(0))
5400 .unwrap();
5401 let mut req_result = {
5402 let client = &self.hub.client;
5403 dlg.pre_request();
5404 let mut req_builder = hyper::Request::builder()
5405 .method(hyper::Method::POST)
5406 .uri(url.as_str())
5407 .header(USER_AGENT, self.hub._user_agent.clone());
5408
5409 if let Some(token) = token.as_ref() {
5410 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5411 }
5412
5413 let request = req_builder
5414 .header(CONTENT_TYPE, json_mime_type.to_string())
5415 .header(CONTENT_LENGTH, request_size as u64)
5416 .body(common::to_body(
5417 request_value_reader.get_ref().clone().into(),
5418 ));
5419
5420 client.request(request.unwrap()).await
5421 };
5422
5423 match req_result {
5424 Err(err) => {
5425 if let common::Retry::After(d) = dlg.http_error(&err) {
5426 sleep(d).await;
5427 continue;
5428 }
5429 dlg.finished(false);
5430 return Err(common::Error::HttpError(err));
5431 }
5432 Ok(res) => {
5433 let (mut parts, body) = res.into_parts();
5434 let mut body = common::Body::new(body);
5435 if !parts.status.is_success() {
5436 let bytes = common::to_bytes(body).await.unwrap_or_default();
5437 let error = serde_json::from_str(&common::to_string(&bytes));
5438 let response = common::to_response(parts, bytes.into());
5439
5440 if let common::Retry::After(d) =
5441 dlg.http_failure(&response, error.as_ref().ok())
5442 {
5443 sleep(d).await;
5444 continue;
5445 }
5446
5447 dlg.finished(false);
5448
5449 return Err(match error {
5450 Ok(value) => common::Error::BadRequest(value),
5451 _ => common::Error::Failure(response),
5452 });
5453 }
5454 let response = {
5455 let bytes = common::to_bytes(body).await.unwrap_or_default();
5456 let encoded = common::to_string(&bytes);
5457 match serde_json::from_str(&encoded) {
5458 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5459 Err(error) => {
5460 dlg.response_json_decode_error(&encoded, &error);
5461 return Err(common::Error::JsonDecodeError(
5462 encoded.to_string(),
5463 error,
5464 ));
5465 }
5466 }
5467 };
5468
5469 dlg.finished(true);
5470 return Ok(response);
5471 }
5472 }
5473 }
5474 }
5475
5476 ///
5477 /// Sets the *request* property to the given value.
5478 ///
5479 /// Even though the property as already been set when instantiating this call,
5480 /// we provide this method for API completeness.
5481 pub fn request(
5482 mut self,
5483 new_value: TestIamPermissionsRequest,
5484 ) -> ProjectLocationFunctionTestIamPermissionCall<'a, C> {
5485 self._request = new_value;
5486 self
5487 }
5488 /// 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.
5489 ///
5490 /// Sets the *resource* path property to the given value.
5491 ///
5492 /// Even though the property as already been set when instantiating this call,
5493 /// we provide this method for API completeness.
5494 pub fn resource(
5495 mut self,
5496 new_value: &str,
5497 ) -> ProjectLocationFunctionTestIamPermissionCall<'a, C> {
5498 self._resource = new_value.to_string();
5499 self
5500 }
5501 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5502 /// while executing the actual API request.
5503 ///
5504 /// ````text
5505 /// It should be used to handle progress information, and to implement a certain level of resilience.
5506 /// ````
5507 ///
5508 /// Sets the *delegate* property to the given value.
5509 pub fn delegate(
5510 mut self,
5511 new_value: &'a mut dyn common::Delegate,
5512 ) -> ProjectLocationFunctionTestIamPermissionCall<'a, C> {
5513 self._delegate = Some(new_value);
5514 self
5515 }
5516
5517 /// Set any additional parameter of the query string used in the request.
5518 /// It should be used to set parameters which are not yet available through their own
5519 /// setters.
5520 ///
5521 /// Please note that this method must not be used to set any of the known parameters
5522 /// which have their own setter method. If done anyway, the request will fail.
5523 ///
5524 /// # Additional Parameters
5525 ///
5526 /// * *$.xgafv* (query-string) - V1 error format.
5527 /// * *access_token* (query-string) - OAuth access token.
5528 /// * *alt* (query-string) - Data format for response.
5529 /// * *callback* (query-string) - JSONP
5530 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5531 /// * *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.
5532 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5533 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5534 /// * *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.
5535 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5536 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5537 pub fn param<T>(
5538 mut self,
5539 name: T,
5540 value: T,
5541 ) -> ProjectLocationFunctionTestIamPermissionCall<'a, C>
5542 where
5543 T: AsRef<str>,
5544 {
5545 self._additional_params
5546 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5547 self
5548 }
5549
5550 /// Identifies the authorization scope for the method you are building.
5551 ///
5552 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5553 /// [`Scope::CloudPlatform`].
5554 ///
5555 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5556 /// tokens for more than one scope.
5557 ///
5558 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5559 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5560 /// sufficient, a read-write scope will do as well.
5561 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationFunctionTestIamPermissionCall<'a, C>
5562 where
5563 St: AsRef<str>,
5564 {
5565 self._scopes.insert(String::from(scope.as_ref()));
5566 self
5567 }
5568 /// Identifies the authorization scope(s) for the method you are building.
5569 ///
5570 /// See [`Self::add_scope()`] for details.
5571 pub fn add_scopes<I, St>(
5572 mut self,
5573 scopes: I,
5574 ) -> ProjectLocationFunctionTestIamPermissionCall<'a, C>
5575 where
5576 I: IntoIterator<Item = St>,
5577 St: AsRef<str>,
5578 {
5579 self._scopes
5580 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5581 self
5582 }
5583
5584 /// Removes all scopes, and no default scope will be used either.
5585 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5586 /// for details).
5587 pub fn clear_scopes(mut self) -> ProjectLocationFunctionTestIamPermissionCall<'a, C> {
5588 self._scopes.clear();
5589 self
5590 }
5591}
5592
5593/// Lists information about the supported locations for this service.
5594///
5595/// A builder for the *locations.list* method supported by a *project* resource.
5596/// It is not used directly, but through a [`ProjectMethods`] instance.
5597///
5598/// # Example
5599///
5600/// Instantiate a resource method builder
5601///
5602/// ```test_harness,no_run
5603/// # extern crate hyper;
5604/// # extern crate hyper_rustls;
5605/// # extern crate google_cloudfunctions1 as cloudfunctions1;
5606/// # async fn dox() {
5607/// # use cloudfunctions1::{CloudFunctions, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5608///
5609/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5610/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5611/// # .with_native_roots()
5612/// # .unwrap()
5613/// # .https_only()
5614/// # .enable_http2()
5615/// # .build();
5616///
5617/// # let executor = hyper_util::rt::TokioExecutor::new();
5618/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5619/// # secret,
5620/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5621/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5622/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5623/// # ),
5624/// # ).build().await.unwrap();
5625///
5626/// # let client = hyper_util::client::legacy::Client::builder(
5627/// # hyper_util::rt::TokioExecutor::new()
5628/// # )
5629/// # .build(
5630/// # hyper_rustls::HttpsConnectorBuilder::new()
5631/// # .with_native_roots()
5632/// # .unwrap()
5633/// # .https_or_http()
5634/// # .enable_http2()
5635/// # .build()
5636/// # );
5637/// # let mut hub = CloudFunctions::new(client, auth);
5638/// // You can configure optional parameters by calling the respective setters at will, and
5639/// // execute the final call using `doit()`.
5640/// // Values shown here are possibly random and not representative !
5641/// let result = hub.projects().locations_list("name")
5642/// .page_token("no")
5643/// .page_size(-15)
5644/// .filter("kasd")
5645/// .add_extra_location_types("et")
5646/// .doit().await;
5647/// # }
5648/// ```
5649pub struct ProjectLocationListCall<'a, C>
5650where
5651 C: 'a,
5652{
5653 hub: &'a CloudFunctions<C>,
5654 _name: String,
5655 _page_token: Option<String>,
5656 _page_size: Option<i32>,
5657 _filter: Option<String>,
5658 _extra_location_types: Vec<String>,
5659 _delegate: Option<&'a mut dyn common::Delegate>,
5660 _additional_params: HashMap<String, String>,
5661 _scopes: BTreeSet<String>,
5662}
5663
5664impl<'a, C> common::CallBuilder for ProjectLocationListCall<'a, C> {}
5665
5666impl<'a, C> ProjectLocationListCall<'a, C>
5667where
5668 C: common::Connector,
5669{
5670 /// Perform the operation you have build so far.
5671 pub async fn doit(mut self) -> common::Result<(common::Response, ListLocationsResponse)> {
5672 use std::borrow::Cow;
5673 use std::io::{Read, Seek};
5674
5675 use common::{url::Params, ToParts};
5676 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5677
5678 let mut dd = common::DefaultDelegate;
5679 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5680 dlg.begin(common::MethodInfo {
5681 id: "cloudfunctions.projects.locations.list",
5682 http_method: hyper::Method::GET,
5683 });
5684
5685 for &field in [
5686 "alt",
5687 "name",
5688 "pageToken",
5689 "pageSize",
5690 "filter",
5691 "extraLocationTypes",
5692 ]
5693 .iter()
5694 {
5695 if self._additional_params.contains_key(field) {
5696 dlg.finished(false);
5697 return Err(common::Error::FieldClash(field));
5698 }
5699 }
5700
5701 let mut params = Params::with_capacity(7 + self._additional_params.len());
5702 params.push("name", self._name);
5703 if let Some(value) = self._page_token.as_ref() {
5704 params.push("pageToken", value);
5705 }
5706 if let Some(value) = self._page_size.as_ref() {
5707 params.push("pageSize", value.to_string());
5708 }
5709 if let Some(value) = self._filter.as_ref() {
5710 params.push("filter", value);
5711 }
5712 if !self._extra_location_types.is_empty() {
5713 for f in self._extra_location_types.iter() {
5714 params.push("extraLocationTypes", f);
5715 }
5716 }
5717
5718 params.extend(self._additional_params.iter());
5719
5720 params.push("alt", "json");
5721 let mut url = self.hub._base_url.clone() + "v1/{+name}/locations";
5722 if self._scopes.is_empty() {
5723 self._scopes
5724 .insert(Scope::CloudPlatform.as_ref().to_string());
5725 }
5726
5727 #[allow(clippy::single_element_loop)]
5728 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5729 url = params.uri_replacement(url, param_name, find_this, true);
5730 }
5731 {
5732 let to_remove = ["name"];
5733 params.remove_params(&to_remove);
5734 }
5735
5736 let url = params.parse_with_url(&url);
5737
5738 loop {
5739 let token = match self
5740 .hub
5741 .auth
5742 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5743 .await
5744 {
5745 Ok(token) => token,
5746 Err(e) => match dlg.token(e) {
5747 Ok(token) => token,
5748 Err(e) => {
5749 dlg.finished(false);
5750 return Err(common::Error::MissingToken(e));
5751 }
5752 },
5753 };
5754 let mut req_result = {
5755 let client = &self.hub.client;
5756 dlg.pre_request();
5757 let mut req_builder = hyper::Request::builder()
5758 .method(hyper::Method::GET)
5759 .uri(url.as_str())
5760 .header(USER_AGENT, self.hub._user_agent.clone());
5761
5762 if let Some(token) = token.as_ref() {
5763 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5764 }
5765
5766 let request = req_builder
5767 .header(CONTENT_LENGTH, 0_u64)
5768 .body(common::to_body::<String>(None));
5769
5770 client.request(request.unwrap()).await
5771 };
5772
5773 match req_result {
5774 Err(err) => {
5775 if let common::Retry::After(d) = dlg.http_error(&err) {
5776 sleep(d).await;
5777 continue;
5778 }
5779 dlg.finished(false);
5780 return Err(common::Error::HttpError(err));
5781 }
5782 Ok(res) => {
5783 let (mut parts, body) = res.into_parts();
5784 let mut body = common::Body::new(body);
5785 if !parts.status.is_success() {
5786 let bytes = common::to_bytes(body).await.unwrap_or_default();
5787 let error = serde_json::from_str(&common::to_string(&bytes));
5788 let response = common::to_response(parts, bytes.into());
5789
5790 if let common::Retry::After(d) =
5791 dlg.http_failure(&response, error.as_ref().ok())
5792 {
5793 sleep(d).await;
5794 continue;
5795 }
5796
5797 dlg.finished(false);
5798
5799 return Err(match error {
5800 Ok(value) => common::Error::BadRequest(value),
5801 _ => common::Error::Failure(response),
5802 });
5803 }
5804 let response = {
5805 let bytes = common::to_bytes(body).await.unwrap_or_default();
5806 let encoded = common::to_string(&bytes);
5807 match serde_json::from_str(&encoded) {
5808 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5809 Err(error) => {
5810 dlg.response_json_decode_error(&encoded, &error);
5811 return Err(common::Error::JsonDecodeError(
5812 encoded.to_string(),
5813 error,
5814 ));
5815 }
5816 }
5817 };
5818
5819 dlg.finished(true);
5820 return Ok(response);
5821 }
5822 }
5823 }
5824 }
5825
5826 /// The resource that owns the locations collection, if applicable.
5827 ///
5828 /// Sets the *name* path property to the given value.
5829 ///
5830 /// Even though the property as already been set when instantiating this call,
5831 /// we provide this method for API completeness.
5832 pub fn name(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
5833 self._name = new_value.to_string();
5834 self
5835 }
5836 /// A page token received from the `next_page_token` field in the response. Send that page token to receive the subsequent page.
5837 ///
5838 /// Sets the *page token* query property to the given value.
5839 pub fn page_token(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
5840 self._page_token = Some(new_value.to_string());
5841 self
5842 }
5843 /// The maximum number of results to return. If not set, the service selects a default.
5844 ///
5845 /// Sets the *page size* query property to the given value.
5846 pub fn page_size(mut self, new_value: i32) -> ProjectLocationListCall<'a, C> {
5847 self._page_size = Some(new_value);
5848 self
5849 }
5850 /// 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).
5851 ///
5852 /// Sets the *filter* query property to the given value.
5853 pub fn filter(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
5854 self._filter = Some(new_value.to_string());
5855 self
5856 }
5857 /// Optional. Do not use this field. It is unsupported and is ignored unless explicitly documented otherwise. This is primarily for internal usage.
5858 ///
5859 /// Append the given value to the *extra location types* query property.
5860 /// Each appended value will retain its original ordering and be '/'-separated in the URL's parameters.
5861 pub fn add_extra_location_types(mut self, new_value: &str) -> ProjectLocationListCall<'a, C> {
5862 self._extra_location_types.push(new_value.to_string());
5863 self
5864 }
5865 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5866 /// while executing the actual API request.
5867 ///
5868 /// ````text
5869 /// It should be used to handle progress information, and to implement a certain level of resilience.
5870 /// ````
5871 ///
5872 /// Sets the *delegate* property to the given value.
5873 pub fn delegate(
5874 mut self,
5875 new_value: &'a mut dyn common::Delegate,
5876 ) -> ProjectLocationListCall<'a, C> {
5877 self._delegate = Some(new_value);
5878 self
5879 }
5880
5881 /// Set any additional parameter of the query string used in the request.
5882 /// It should be used to set parameters which are not yet available through their own
5883 /// setters.
5884 ///
5885 /// Please note that this method must not be used to set any of the known parameters
5886 /// which have their own setter method. If done anyway, the request will fail.
5887 ///
5888 /// # Additional Parameters
5889 ///
5890 /// * *$.xgafv* (query-string) - V1 error format.
5891 /// * *access_token* (query-string) - OAuth access token.
5892 /// * *alt* (query-string) - Data format for response.
5893 /// * *callback* (query-string) - JSONP
5894 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5895 /// * *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.
5896 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5897 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5898 /// * *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.
5899 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5900 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5901 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationListCall<'a, C>
5902 where
5903 T: AsRef<str>,
5904 {
5905 self._additional_params
5906 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5907 self
5908 }
5909
5910 /// Identifies the authorization scope for the method you are building.
5911 ///
5912 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5913 /// [`Scope::CloudPlatform`].
5914 ///
5915 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5916 /// tokens for more than one scope.
5917 ///
5918 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5919 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5920 /// sufficient, a read-write scope will do as well.
5921 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationListCall<'a, C>
5922 where
5923 St: AsRef<str>,
5924 {
5925 self._scopes.insert(String::from(scope.as_ref()));
5926 self
5927 }
5928 /// Identifies the authorization scope(s) for the method you are building.
5929 ///
5930 /// See [`Self::add_scope()`] for details.
5931 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationListCall<'a, C>
5932 where
5933 I: IntoIterator<Item = St>,
5934 St: AsRef<str>,
5935 {
5936 self._scopes
5937 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5938 self
5939 }
5940
5941 /// Removes all scopes, and no default scope will be used either.
5942 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5943 /// for details).
5944 pub fn clear_scopes(mut self) -> ProjectLocationListCall<'a, C> {
5945 self._scopes.clear();
5946 self
5947 }
5948}