google_bigqueryconnection1_beta1/
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    /// View and manage your data in Google BigQuery and see the email address for your Google Account
17    Bigquery,
18
19    /// See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
20    CloudPlatform,
21}
22
23impl AsRef<str> for Scope {
24    fn as_ref(&self) -> &str {
25        match *self {
26            Scope::Bigquery => "https://www.googleapis.com/auth/bigquery",
27            Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
28        }
29    }
30}
31
32#[allow(clippy::derivable_impls)]
33impl Default for Scope {
34    fn default() -> Scope {
35        Scope::Bigquery
36    }
37}
38
39// ########
40// HUB ###
41// ######
42
43/// Central instance to access all BigQueryConnectionService related resource activities
44///
45/// # Examples
46///
47/// Instantiate a new hub
48///
49/// ```test_harness,no_run
50/// extern crate hyper;
51/// extern crate hyper_rustls;
52/// extern crate google_bigqueryconnection1_beta1 as bigqueryconnection1_beta1;
53/// use bigqueryconnection1_beta1::api::Connection;
54/// use bigqueryconnection1_beta1::{Result, Error};
55/// # async fn dox() {
56/// use bigqueryconnection1_beta1::{BigQueryConnectionService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
57///
58/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
59/// // `client_secret`, among other things.
60/// let secret: yup_oauth2::ApplicationSecret = Default::default();
61/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
62/// // unless you replace  `None` with the desired Flow.
63/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
64/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
65/// // retrieve them from storage.
66/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
67///     .with_native_roots()
68///     .unwrap()
69///     .https_only()
70///     .enable_http2()
71///     .build();
72///
73/// let executor = hyper_util::rt::TokioExecutor::new();
74/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
75///     secret,
76///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
77///     yup_oauth2::client::CustomHyperClientBuilder::from(
78///         hyper_util::client::legacy::Client::builder(executor).build(connector),
79///     ),
80/// ).build().await.unwrap();
81///
82/// let client = hyper_util::client::legacy::Client::builder(
83///     hyper_util::rt::TokioExecutor::new()
84/// )
85/// .build(
86///     hyper_rustls::HttpsConnectorBuilder::new()
87///         .with_native_roots()
88///         .unwrap()
89///         .https_or_http()
90///         .enable_http2()
91///         .build()
92/// );
93/// let mut hub = BigQueryConnectionService::new(client, auth);
94/// // As the method needs a request, you would usually fill it with the desired information
95/// // into the respective structure. Some of the parts shown here might not be applicable !
96/// // Values shown here are possibly random and not representative !
97/// let mut req = Connection::default();
98///
99/// // You can configure optional parameters by calling the respective setters at will, and
100/// // execute the final call using `doit()`.
101/// // Values shown here are possibly random and not representative !
102/// let result = hub.projects().locations_connections_create(req, "parent")
103///              .connection_id("At")
104///              .doit().await;
105///
106/// match result {
107///     Err(e) => match e {
108///         // The Error enum provides details about what exactly happened.
109///         // You can also just use its `Debug`, `Display` or `Error` traits
110///          Error::HttpError(_)
111///         |Error::Io(_)
112///         |Error::MissingAPIKey
113///         |Error::MissingToken(_)
114///         |Error::Cancelled
115///         |Error::UploadSizeLimitExceeded(_, _)
116///         |Error::Failure(_)
117///         |Error::BadRequest(_)
118///         |Error::FieldClash(_)
119///         |Error::JsonDecodeError(_, _) => println!("{}", e),
120///     },
121///     Ok(res) => println!("Success: {:?}", res),
122/// }
123/// # }
124/// ```
125#[derive(Clone)]
126pub struct BigQueryConnectionService<C> {
127    pub client: common::Client<C>,
128    pub auth: Box<dyn common::GetToken>,
129    _user_agent: String,
130    _base_url: String,
131    _root_url: String,
132}
133
134impl<C> common::Hub for BigQueryConnectionService<C> {}
135
136impl<'a, C> BigQueryConnectionService<C> {
137    pub fn new<A: 'static + common::GetToken>(
138        client: common::Client<C>,
139        auth: A,
140    ) -> BigQueryConnectionService<C> {
141        BigQueryConnectionService {
142            client,
143            auth: Box::new(auth),
144            _user_agent: "google-api-rust-client/7.0.0".to_string(),
145            _base_url: "https://bigqueryconnection.googleapis.com/".to_string(),
146            _root_url: "https://bigqueryconnection.googleapis.com/".to_string(),
147        }
148    }
149
150    pub fn projects(&'a self) -> ProjectMethods<'a, C> {
151        ProjectMethods { hub: self }
152    }
153
154    /// Set the user-agent header field to use in all requests to the server.
155    /// It defaults to `google-api-rust-client/7.0.0`.
156    ///
157    /// Returns the previously set user-agent.
158    pub fn user_agent(&mut self, agent_name: String) -> String {
159        std::mem::replace(&mut self._user_agent, agent_name)
160    }
161
162    /// Set the base url to use in all requests to the server.
163    /// It defaults to `https://bigqueryconnection.googleapis.com/`.
164    ///
165    /// Returns the previously set base url.
166    pub fn base_url(&mut self, new_base_url: String) -> String {
167        std::mem::replace(&mut self._base_url, new_base_url)
168    }
169
170    /// Set the root url to use in all requests to the server.
171    /// It defaults to `https://bigqueryconnection.googleapis.com/`.
172    ///
173    /// Returns the previously set root url.
174    pub fn root_url(&mut self, new_root_url: String) -> String {
175        std::mem::replace(&mut self._root_url, new_root_url)
176    }
177}
178
179// ############
180// SCHEMAS ###
181// ##########
182/// 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.
183///
184/// This type is not used in any activity, and only used as *part* of another schema.
185///
186#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
187#[serde_with::serde_as]
188#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
189pub struct AuditConfig {
190    /// The configuration for logging of each type of permission.
191    #[serde(rename = "auditLogConfigs")]
192    pub audit_log_configs: Option<Vec<AuditLogConfig>>,
193    /// 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.
194    pub service: Option<String>,
195}
196
197impl common::Part for AuditConfig {}
198
199/// 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.
200///
201/// This type is not used in any activity, and only used as *part* of another schema.
202///
203#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
204#[serde_with::serde_as]
205#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
206pub struct AuditLogConfig {
207    /// Specifies the identities that do not cause logging for this type of permission. Follows the same format of Binding.members.
208    #[serde(rename = "exemptedMembers")]
209    pub exempted_members: Option<Vec<String>>,
210    /// The log type that this config enables.
211    #[serde(rename = "logType")]
212    pub log_type: Option<String>,
213}
214
215impl common::Part for AuditLogConfig {}
216
217/// Associates `members`, or principals, with a `role`.
218///
219/// This type is not used in any activity, and only used as *part* of another schema.
220///
221#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
222#[serde_with::serde_as]
223#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
224pub struct Binding {
225    /// 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).
226    pub condition: Option<Expr>,
227    /// 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`.
228    pub members: Option<Vec<String>>,
229    /// 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).
230    pub role: Option<String>,
231}
232
233impl common::Part for Binding {}
234
235/// Credential info for the Cloud SQL.
236///
237/// This type is not used in any activity, and only used as *part* of another schema.
238///
239#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
240#[serde_with::serde_as]
241#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
242pub struct CloudSqlCredential {
243    /// The password for the credential.
244    pub password: Option<String>,
245    /// The username for the credential.
246    pub username: Option<String>,
247}
248
249impl common::Part for CloudSqlCredential {}
250
251/// Connection properties specific to the Cloud SQL.
252///
253/// This type is not used in any activity, and only used as *part* of another schema.
254///
255#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
256#[serde_with::serde_as]
257#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
258pub struct CloudSqlProperties {
259    /// Input only. Cloud SQL credential.
260    pub credential: Option<CloudSqlCredential>,
261    /// Database name.
262    pub database: Option<String>,
263    /// Cloud SQL instance ID in the form `project:location:instance`.
264    #[serde(rename = "instanceId")]
265    pub instance_id: Option<String>,
266    /// Output only. The account ID of the service used for the purpose of this connection. When the connection is used in the context of an operation in BigQuery, this service account will serve as the identity being used for connecting to the CloudSQL instance specified in this connection.
267    #[serde(rename = "serviceAccountId")]
268    pub service_account_id: Option<String>,
269    /// Type of the Cloud SQL database.
270    #[serde(rename = "type")]
271    pub type_: Option<String>,
272}
273
274impl common::Part for CloudSqlProperties {}
275
276/// Configuration parameters to establish connection with an external data source, except the credential attributes.
277///
278/// # Activities
279///
280/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
281/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
282///
283/// * [locations connections create projects](ProjectLocationConnectionCreateCall) (request|response)
284/// * [locations connections get projects](ProjectLocationConnectionGetCall) (response)
285/// * [locations connections patch projects](ProjectLocationConnectionPatchCall) (request|response)
286#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
287#[serde_with::serde_as]
288#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
289pub struct Connection {
290    /// Cloud SQL properties.
291    #[serde(rename = "cloudSql")]
292    pub cloud_sql: Option<CloudSqlProperties>,
293    /// Output only. The creation timestamp of the connection.
294    #[serde(rename = "creationTime")]
295    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
296    pub creation_time: Option<i64>,
297    /// User provided description.
298    pub description: Option<String>,
299    /// User provided display name for the connection.
300    #[serde(rename = "friendlyName")]
301    pub friendly_name: Option<String>,
302    /// Output only. True, if credential is configured for this connection.
303    #[serde(rename = "hasCredential")]
304    pub has_credential: Option<bool>,
305    /// Output only. The last update timestamp of the connection.
306    #[serde(rename = "lastModifiedTime")]
307    #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
308    pub last_modified_time: Option<i64>,
309    /// The resource name of the connection in the form of: `projects/{project_id}/locations/{location_id}/connections/{connection_id}`
310    pub name: Option<String>,
311}
312
313impl common::RequestValue for Connection {}
314impl common::ResponseResult for Connection {}
315
316/// Credential to use with a connection.
317///
318/// # Activities
319///
320/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
321/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
322///
323/// * [locations connections update credential projects](ProjectLocationConnectionUpdateCredentialCall) (request)
324#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
325#[serde_with::serde_as]
326#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
327pub struct ConnectionCredential {
328    /// Credential for Cloud SQL database.
329    #[serde(rename = "cloudSql")]
330    pub cloud_sql: Option<CloudSqlCredential>,
331}
332
333impl common::RequestValue for ConnectionCredential {}
334
335/// A generic empty message that you can re-use to avoid defining duplicated empty messages in your APIs. A typical example is to use it as the request or the response type of an API method. For instance: service Foo { rpc Bar(google.protobuf.Empty) returns (google.protobuf.Empty); }
336///
337/// # Activities
338///
339/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
340/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
341///
342/// * [locations connections delete projects](ProjectLocationConnectionDeleteCall) (response)
343/// * [locations connections update credential projects](ProjectLocationConnectionUpdateCredentialCall) (response)
344#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
345#[serde_with::serde_as]
346#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
347pub struct Empty {
348    _never_set: Option<bool>,
349}
350
351impl common::ResponseResult for Empty {}
352
353/// 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.
354///
355/// This type is not used in any activity, and only used as *part* of another schema.
356///
357#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
358#[serde_with::serde_as]
359#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
360pub struct Expr {
361    /// Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.
362    pub description: Option<String>,
363    /// Textual representation of an expression in Common Expression Language syntax.
364    pub expression: Option<String>,
365    /// Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.
366    pub location: Option<String>,
367    /// 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.
368    pub title: Option<String>,
369}
370
371impl common::Part for Expr {}
372
373/// Request message for `GetIamPolicy` method.
374///
375/// # Activities
376///
377/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
378/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
379///
380/// * [locations connections get iam policy projects](ProjectLocationConnectionGetIamPolicyCall) (request)
381#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
382#[serde_with::serde_as]
383#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
384pub struct GetIamPolicyRequest {
385    /// OPTIONAL: A `GetPolicyOptions` object for specifying options to `GetIamPolicy`.
386    pub options: Option<GetPolicyOptions>,
387}
388
389impl common::RequestValue for GetIamPolicyRequest {}
390
391/// Encapsulates settings provided to GetIamPolicy.
392///
393/// This type is not used in any activity, and only used as *part* of another schema.
394///
395#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
396#[serde_with::serde_as]
397#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
398pub struct GetPolicyOptions {
399    /// 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).
400    #[serde(rename = "requestedPolicyVersion")]
401    pub requested_policy_version: Option<i32>,
402}
403
404impl common::Part for GetPolicyOptions {}
405
406/// The response for ConnectionService.ListConnections.
407///
408/// # Activities
409///
410/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
411/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
412///
413/// * [locations connections list projects](ProjectLocationConnectionListCall) (response)
414#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
415#[serde_with::serde_as]
416#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
417pub struct ListConnectionsResponse {
418    /// List of connections.
419    pub connections: Option<Vec<Connection>>,
420    /// Next page token.
421    #[serde(rename = "nextPageToken")]
422    pub next_page_token: Option<String>,
423}
424
425impl common::ResponseResult for ListConnectionsResponse {}
426
427/// 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/).
428///
429/// # Activities
430///
431/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
432/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
433///
434/// * [locations connections get iam policy projects](ProjectLocationConnectionGetIamPolicyCall) (response)
435/// * [locations connections set iam policy projects](ProjectLocationConnectionSetIamPolicyCall) (response)
436#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
437#[serde_with::serde_as]
438#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
439pub struct Policy {
440    /// Specifies cloud audit logging configuration for this policy.
441    #[serde(rename = "auditConfigs")]
442    pub audit_configs: Option<Vec<AuditConfig>>,
443    /// 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`.
444    pub bindings: Option<Vec<Binding>>,
445    /// `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.
446    #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
447    pub etag: Option<Vec<u8>>,
448    /// 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).
449    pub version: Option<i32>,
450}
451
452impl common::ResponseResult for Policy {}
453
454/// Request message for `SetIamPolicy` method.
455///
456/// # Activities
457///
458/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
459/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
460///
461/// * [locations connections set iam policy projects](ProjectLocationConnectionSetIamPolicyCall) (request)
462#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
463#[serde_with::serde_as]
464#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
465pub struct SetIamPolicyRequest {
466    /// 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.
467    pub policy: Option<Policy>,
468    /// 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"`
469    #[serde(rename = "updateMask")]
470    pub update_mask: Option<common::FieldMask>,
471}
472
473impl common::RequestValue for SetIamPolicyRequest {}
474
475/// Request message for `TestIamPermissions` method.
476///
477/// # Activities
478///
479/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
480/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
481///
482/// * [locations connections test iam permissions projects](ProjectLocationConnectionTestIamPermissionCall) (request)
483#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
484#[serde_with::serde_as]
485#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
486pub struct TestIamPermissionsRequest {
487    /// 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).
488    pub permissions: Option<Vec<String>>,
489}
490
491impl common::RequestValue for TestIamPermissionsRequest {}
492
493/// Response message for `TestIamPermissions` method.
494///
495/// # Activities
496///
497/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
498/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
499///
500/// * [locations connections test iam permissions projects](ProjectLocationConnectionTestIamPermissionCall) (response)
501#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
502#[serde_with::serde_as]
503#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
504pub struct TestIamPermissionsResponse {
505    /// A subset of `TestPermissionsRequest.permissions` that the caller is allowed.
506    pub permissions: Option<Vec<String>>,
507}
508
509impl common::ResponseResult for TestIamPermissionsResponse {}
510
511// ###################
512// MethodBuilders ###
513// #################
514
515/// A builder providing access to all methods supported on *project* resources.
516/// It is not used directly, but through the [`BigQueryConnectionService`] hub.
517///
518/// # Example
519///
520/// Instantiate a resource builder
521///
522/// ```test_harness,no_run
523/// extern crate hyper;
524/// extern crate hyper_rustls;
525/// extern crate google_bigqueryconnection1_beta1 as bigqueryconnection1_beta1;
526///
527/// # async fn dox() {
528/// use bigqueryconnection1_beta1::{BigQueryConnectionService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
529///
530/// let secret: yup_oauth2::ApplicationSecret = Default::default();
531/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
532///     .with_native_roots()
533///     .unwrap()
534///     .https_only()
535///     .enable_http2()
536///     .build();
537///
538/// let executor = hyper_util::rt::TokioExecutor::new();
539/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
540///     secret,
541///     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
542///     yup_oauth2::client::CustomHyperClientBuilder::from(
543///         hyper_util::client::legacy::Client::builder(executor).build(connector),
544///     ),
545/// ).build().await.unwrap();
546///
547/// let client = hyper_util::client::legacy::Client::builder(
548///     hyper_util::rt::TokioExecutor::new()
549/// )
550/// .build(
551///     hyper_rustls::HttpsConnectorBuilder::new()
552///         .with_native_roots()
553///         .unwrap()
554///         .https_or_http()
555///         .enable_http2()
556///         .build()
557/// );
558/// let mut hub = BigQueryConnectionService::new(client, auth);
559/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
560/// // like `locations_connections_create(...)`, `locations_connections_delete(...)`, `locations_connections_get(...)`, `locations_connections_get_iam_policy(...)`, `locations_connections_list(...)`, `locations_connections_patch(...)`, `locations_connections_set_iam_policy(...)`, `locations_connections_test_iam_permissions(...)` and `locations_connections_update_credential(...)`
561/// // to build up your call.
562/// let rb = hub.projects();
563/// # }
564/// ```
565pub struct ProjectMethods<'a, C>
566where
567    C: 'a,
568{
569    hub: &'a BigQueryConnectionService<C>,
570}
571
572impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
573
574impl<'a, C> ProjectMethods<'a, C> {
575    /// Create a builder to help you perform the following task:
576    ///
577    /// Creates a new connection.
578    ///
579    /// # Arguments
580    ///
581    /// * `request` - No description provided.
582    /// * `parent` - Required. Parent resource name. Must be in the format `projects/{project_id}/locations/{location_id}`
583    pub fn locations_connections_create(
584        &self,
585        request: Connection,
586        parent: &str,
587    ) -> ProjectLocationConnectionCreateCall<'a, C> {
588        ProjectLocationConnectionCreateCall {
589            hub: self.hub,
590            _request: request,
591            _parent: parent.to_string(),
592            _connection_id: Default::default(),
593            _delegate: Default::default(),
594            _additional_params: Default::default(),
595            _scopes: Default::default(),
596        }
597    }
598
599    /// Create a builder to help you perform the following task:
600    ///
601    /// Deletes connection and associated credential.
602    ///
603    /// # Arguments
604    ///
605    /// * `name` - Required. Name of the deleted connection, for example: `projects/{project_id}/locations/{location_id}/connections/{connection_id}`
606    pub fn locations_connections_delete(
607        &self,
608        name: &str,
609    ) -> ProjectLocationConnectionDeleteCall<'a, C> {
610        ProjectLocationConnectionDeleteCall {
611            hub: self.hub,
612            _name: name.to_string(),
613            _delegate: Default::default(),
614            _additional_params: Default::default(),
615            _scopes: Default::default(),
616        }
617    }
618
619    /// Create a builder to help you perform the following task:
620    ///
621    /// Returns specified connection.
622    ///
623    /// # Arguments
624    ///
625    /// * `name` - Required. Name of the requested connection, for example: `projects/{project_id}/locations/{location_id}/connections/{connection_id}`
626    pub fn locations_connections_get(&self, name: &str) -> ProjectLocationConnectionGetCall<'a, C> {
627        ProjectLocationConnectionGetCall {
628            hub: self.hub,
629            _name: name.to_string(),
630            _delegate: Default::default(),
631            _additional_params: Default::default(),
632            _scopes: Default::default(),
633        }
634    }
635
636    /// Create a builder to help you perform the following task:
637    ///
638    /// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
639    ///
640    /// # Arguments
641    ///
642    /// * `request` - No description provided.
643    /// * `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.
644    pub fn locations_connections_get_iam_policy(
645        &self,
646        request: GetIamPolicyRequest,
647        resource: &str,
648    ) -> ProjectLocationConnectionGetIamPolicyCall<'a, C> {
649        ProjectLocationConnectionGetIamPolicyCall {
650            hub: self.hub,
651            _request: request,
652            _resource: resource.to_string(),
653            _delegate: Default::default(),
654            _additional_params: Default::default(),
655            _scopes: Default::default(),
656        }
657    }
658
659    /// Create a builder to help you perform the following task:
660    ///
661    /// Returns a list of connections in the given project.
662    ///
663    /// # Arguments
664    ///
665    /// * `parent` - Required. Parent resource name. Must be in the form: `projects/{project_id}/locations/{location_id}`
666    pub fn locations_connections_list(
667        &self,
668        parent: &str,
669    ) -> ProjectLocationConnectionListCall<'a, C> {
670        ProjectLocationConnectionListCall {
671            hub: self.hub,
672            _parent: parent.to_string(),
673            _page_token: Default::default(),
674            _max_results: Default::default(),
675            _delegate: Default::default(),
676            _additional_params: Default::default(),
677            _scopes: Default::default(),
678        }
679    }
680
681    /// Create a builder to help you perform the following task:
682    ///
683    /// Updates the specified connection. For security reasons, also resets credential if connection properties are in the update field mask.
684    ///
685    /// # Arguments
686    ///
687    /// * `request` - No description provided.
688    /// * `name` - Required. Name of the connection to update, for example: `projects/{project_id}/locations/{location_id}/connections/{connection_id}`
689    pub fn locations_connections_patch(
690        &self,
691        request: Connection,
692        name: &str,
693    ) -> ProjectLocationConnectionPatchCall<'a, C> {
694        ProjectLocationConnectionPatchCall {
695            hub: self.hub,
696            _request: request,
697            _name: name.to_string(),
698            _update_mask: Default::default(),
699            _delegate: Default::default(),
700            _additional_params: Default::default(),
701            _scopes: Default::default(),
702        }
703    }
704
705    /// Create a builder to help you perform the following task:
706    ///
707    /// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
708    ///
709    /// # Arguments
710    ///
711    /// * `request` - No description provided.
712    /// * `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.
713    pub fn locations_connections_set_iam_policy(
714        &self,
715        request: SetIamPolicyRequest,
716        resource: &str,
717    ) -> ProjectLocationConnectionSetIamPolicyCall<'a, C> {
718        ProjectLocationConnectionSetIamPolicyCall {
719            hub: self.hub,
720            _request: request,
721            _resource: resource.to_string(),
722            _delegate: Default::default(),
723            _additional_params: Default::default(),
724            _scopes: Default::default(),
725        }
726    }
727
728    /// Create a builder to help you perform the following task:
729    ///
730    /// Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
731    ///
732    /// # Arguments
733    ///
734    /// * `request` - No description provided.
735    /// * `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.
736    pub fn locations_connections_test_iam_permissions(
737        &self,
738        request: TestIamPermissionsRequest,
739        resource: &str,
740    ) -> ProjectLocationConnectionTestIamPermissionCall<'a, C> {
741        ProjectLocationConnectionTestIamPermissionCall {
742            hub: self.hub,
743            _request: request,
744            _resource: resource.to_string(),
745            _delegate: Default::default(),
746            _additional_params: Default::default(),
747            _scopes: Default::default(),
748        }
749    }
750
751    /// Create a builder to help you perform the following task:
752    ///
753    /// Sets the credential for the specified connection.
754    ///
755    /// # Arguments
756    ///
757    /// * `request` - No description provided.
758    /// * `name` - Required. Name of the connection, for example: `projects/{project_id}/locations/{location_id}/connections/{connection_id}/credential`
759    pub fn locations_connections_update_credential(
760        &self,
761        request: ConnectionCredential,
762        name: &str,
763    ) -> ProjectLocationConnectionUpdateCredentialCall<'a, C> {
764        ProjectLocationConnectionUpdateCredentialCall {
765            hub: self.hub,
766            _request: request,
767            _name: name.to_string(),
768            _delegate: Default::default(),
769            _additional_params: Default::default(),
770            _scopes: Default::default(),
771        }
772    }
773}
774
775// ###################
776// CallBuilders   ###
777// #################
778
779/// Creates a new connection.
780///
781/// A builder for the *locations.connections.create* method supported by a *project* resource.
782/// It is not used directly, but through a [`ProjectMethods`] instance.
783///
784/// # Example
785///
786/// Instantiate a resource method builder
787///
788/// ```test_harness,no_run
789/// # extern crate hyper;
790/// # extern crate hyper_rustls;
791/// # extern crate google_bigqueryconnection1_beta1 as bigqueryconnection1_beta1;
792/// use bigqueryconnection1_beta1::api::Connection;
793/// # async fn dox() {
794/// # use bigqueryconnection1_beta1::{BigQueryConnectionService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
795///
796/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
797/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
798/// #     .with_native_roots()
799/// #     .unwrap()
800/// #     .https_only()
801/// #     .enable_http2()
802/// #     .build();
803///
804/// # let executor = hyper_util::rt::TokioExecutor::new();
805/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
806/// #     secret,
807/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
808/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
809/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
810/// #     ),
811/// # ).build().await.unwrap();
812///
813/// # let client = hyper_util::client::legacy::Client::builder(
814/// #     hyper_util::rt::TokioExecutor::new()
815/// # )
816/// # .build(
817/// #     hyper_rustls::HttpsConnectorBuilder::new()
818/// #         .with_native_roots()
819/// #         .unwrap()
820/// #         .https_or_http()
821/// #         .enable_http2()
822/// #         .build()
823/// # );
824/// # let mut hub = BigQueryConnectionService::new(client, auth);
825/// // As the method needs a request, you would usually fill it with the desired information
826/// // into the respective structure. Some of the parts shown here might not be applicable !
827/// // Values shown here are possibly random and not representative !
828/// let mut req = Connection::default();
829///
830/// // You can configure optional parameters by calling the respective setters at will, and
831/// // execute the final call using `doit()`.
832/// // Values shown here are possibly random and not representative !
833/// let result = hub.projects().locations_connections_create(req, "parent")
834///              .connection_id("sed")
835///              .doit().await;
836/// # }
837/// ```
838pub struct ProjectLocationConnectionCreateCall<'a, C>
839where
840    C: 'a,
841{
842    hub: &'a BigQueryConnectionService<C>,
843    _request: Connection,
844    _parent: String,
845    _connection_id: Option<String>,
846    _delegate: Option<&'a mut dyn common::Delegate>,
847    _additional_params: HashMap<String, String>,
848    _scopes: BTreeSet<String>,
849}
850
851impl<'a, C> common::CallBuilder for ProjectLocationConnectionCreateCall<'a, C> {}
852
853impl<'a, C> ProjectLocationConnectionCreateCall<'a, C>
854where
855    C: common::Connector,
856{
857    /// Perform the operation you have build so far.
858    pub async fn doit(mut self) -> common::Result<(common::Response, Connection)> {
859        use std::borrow::Cow;
860        use std::io::{Read, Seek};
861
862        use common::{url::Params, ToParts};
863        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
864
865        let mut dd = common::DefaultDelegate;
866        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
867        dlg.begin(common::MethodInfo {
868            id: "bigqueryconnection.projects.locations.connections.create",
869            http_method: hyper::Method::POST,
870        });
871
872        for &field in ["alt", "parent", "connectionId"].iter() {
873            if self._additional_params.contains_key(field) {
874                dlg.finished(false);
875                return Err(common::Error::FieldClash(field));
876            }
877        }
878
879        let mut params = Params::with_capacity(5 + self._additional_params.len());
880        params.push("parent", self._parent);
881        if let Some(value) = self._connection_id.as_ref() {
882            params.push("connectionId", value);
883        }
884
885        params.extend(self._additional_params.iter());
886
887        params.push("alt", "json");
888        let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/connections";
889        if self._scopes.is_empty() {
890            self._scopes
891                .insert(Scope::CloudPlatform.as_ref().to_string());
892        }
893
894        #[allow(clippy::single_element_loop)]
895        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
896            url = params.uri_replacement(url, param_name, find_this, true);
897        }
898        {
899            let to_remove = ["parent"];
900            params.remove_params(&to_remove);
901        }
902
903        let url = params.parse_with_url(&url);
904
905        let mut json_mime_type = mime::APPLICATION_JSON;
906        let mut request_value_reader = {
907            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
908            common::remove_json_null_values(&mut value);
909            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
910            serde_json::to_writer(&mut dst, &value).unwrap();
911            dst
912        };
913        let request_size = request_value_reader
914            .seek(std::io::SeekFrom::End(0))
915            .unwrap();
916        request_value_reader
917            .seek(std::io::SeekFrom::Start(0))
918            .unwrap();
919
920        loop {
921            let token = match self
922                .hub
923                .auth
924                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
925                .await
926            {
927                Ok(token) => token,
928                Err(e) => match dlg.token(e) {
929                    Ok(token) => token,
930                    Err(e) => {
931                        dlg.finished(false);
932                        return Err(common::Error::MissingToken(e));
933                    }
934                },
935            };
936            request_value_reader
937                .seek(std::io::SeekFrom::Start(0))
938                .unwrap();
939            let mut req_result = {
940                let client = &self.hub.client;
941                dlg.pre_request();
942                let mut req_builder = hyper::Request::builder()
943                    .method(hyper::Method::POST)
944                    .uri(url.as_str())
945                    .header(USER_AGENT, self.hub._user_agent.clone());
946
947                if let Some(token) = token.as_ref() {
948                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
949                }
950
951                let request = req_builder
952                    .header(CONTENT_TYPE, json_mime_type.to_string())
953                    .header(CONTENT_LENGTH, request_size as u64)
954                    .body(common::to_body(
955                        request_value_reader.get_ref().clone().into(),
956                    ));
957
958                client.request(request.unwrap()).await
959            };
960
961            match req_result {
962                Err(err) => {
963                    if let common::Retry::After(d) = dlg.http_error(&err) {
964                        sleep(d).await;
965                        continue;
966                    }
967                    dlg.finished(false);
968                    return Err(common::Error::HttpError(err));
969                }
970                Ok(res) => {
971                    let (mut parts, body) = res.into_parts();
972                    let mut body = common::Body::new(body);
973                    if !parts.status.is_success() {
974                        let bytes = common::to_bytes(body).await.unwrap_or_default();
975                        let error = serde_json::from_str(&common::to_string(&bytes));
976                        let response = common::to_response(parts, bytes.into());
977
978                        if let common::Retry::After(d) =
979                            dlg.http_failure(&response, error.as_ref().ok())
980                        {
981                            sleep(d).await;
982                            continue;
983                        }
984
985                        dlg.finished(false);
986
987                        return Err(match error {
988                            Ok(value) => common::Error::BadRequest(value),
989                            _ => common::Error::Failure(response),
990                        });
991                    }
992                    let response = {
993                        let bytes = common::to_bytes(body).await.unwrap_or_default();
994                        let encoded = common::to_string(&bytes);
995                        match serde_json::from_str(&encoded) {
996                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
997                            Err(error) => {
998                                dlg.response_json_decode_error(&encoded, &error);
999                                return Err(common::Error::JsonDecodeError(
1000                                    encoded.to_string(),
1001                                    error,
1002                                ));
1003                            }
1004                        }
1005                    };
1006
1007                    dlg.finished(true);
1008                    return Ok(response);
1009                }
1010            }
1011        }
1012    }
1013
1014    ///
1015    /// Sets the *request* property to the given value.
1016    ///
1017    /// Even though the property as already been set when instantiating this call,
1018    /// we provide this method for API completeness.
1019    pub fn request(mut self, new_value: Connection) -> ProjectLocationConnectionCreateCall<'a, C> {
1020        self._request = new_value;
1021        self
1022    }
1023    /// Required. Parent resource name. Must be in the format `projects/{project_id}/locations/{location_id}`
1024    ///
1025    /// Sets the *parent* path property to the given value.
1026    ///
1027    /// Even though the property as already been set when instantiating this call,
1028    /// we provide this method for API completeness.
1029    pub fn parent(mut self, new_value: &str) -> ProjectLocationConnectionCreateCall<'a, C> {
1030        self._parent = new_value.to_string();
1031        self
1032    }
1033    /// Optional. Connection id that should be assigned to the created connection.
1034    ///
1035    /// Sets the *connection id* query property to the given value.
1036    pub fn connection_id(mut self, new_value: &str) -> ProjectLocationConnectionCreateCall<'a, C> {
1037        self._connection_id = Some(new_value.to_string());
1038        self
1039    }
1040    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1041    /// while executing the actual API request.
1042    ///
1043    /// ````text
1044    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1045    /// ````
1046    ///
1047    /// Sets the *delegate* property to the given value.
1048    pub fn delegate(
1049        mut self,
1050        new_value: &'a mut dyn common::Delegate,
1051    ) -> ProjectLocationConnectionCreateCall<'a, C> {
1052        self._delegate = Some(new_value);
1053        self
1054    }
1055
1056    /// Set any additional parameter of the query string used in the request.
1057    /// It should be used to set parameters which are not yet available through their own
1058    /// setters.
1059    ///
1060    /// Please note that this method must not be used to set any of the known parameters
1061    /// which have their own setter method. If done anyway, the request will fail.
1062    ///
1063    /// # Additional Parameters
1064    ///
1065    /// * *$.xgafv* (query-string) - V1 error format.
1066    /// * *access_token* (query-string) - OAuth access token.
1067    /// * *alt* (query-string) - Data format for response.
1068    /// * *callback* (query-string) - JSONP
1069    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1070    /// * *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.
1071    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1072    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1073    /// * *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.
1074    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1075    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1076    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationConnectionCreateCall<'a, C>
1077    where
1078        T: AsRef<str>,
1079    {
1080        self._additional_params
1081            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1082        self
1083    }
1084
1085    /// Identifies the authorization scope for the method you are building.
1086    ///
1087    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1088    /// [`Scope::CloudPlatform`].
1089    ///
1090    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1091    /// tokens for more than one scope.
1092    ///
1093    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1094    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1095    /// sufficient, a read-write scope will do as well.
1096    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationConnectionCreateCall<'a, C>
1097    where
1098        St: AsRef<str>,
1099    {
1100        self._scopes.insert(String::from(scope.as_ref()));
1101        self
1102    }
1103    /// Identifies the authorization scope(s) for the method you are building.
1104    ///
1105    /// See [`Self::add_scope()`] for details.
1106    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationConnectionCreateCall<'a, C>
1107    where
1108        I: IntoIterator<Item = St>,
1109        St: AsRef<str>,
1110    {
1111        self._scopes
1112            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1113        self
1114    }
1115
1116    /// Removes all scopes, and no default scope will be used either.
1117    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1118    /// for details).
1119    pub fn clear_scopes(mut self) -> ProjectLocationConnectionCreateCall<'a, C> {
1120        self._scopes.clear();
1121        self
1122    }
1123}
1124
1125/// Deletes connection and associated credential.
1126///
1127/// A builder for the *locations.connections.delete* method supported by a *project* resource.
1128/// It is not used directly, but through a [`ProjectMethods`] instance.
1129///
1130/// # Example
1131///
1132/// Instantiate a resource method builder
1133///
1134/// ```test_harness,no_run
1135/// # extern crate hyper;
1136/// # extern crate hyper_rustls;
1137/// # extern crate google_bigqueryconnection1_beta1 as bigqueryconnection1_beta1;
1138/// # async fn dox() {
1139/// # use bigqueryconnection1_beta1::{BigQueryConnectionService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1140///
1141/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1142/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1143/// #     .with_native_roots()
1144/// #     .unwrap()
1145/// #     .https_only()
1146/// #     .enable_http2()
1147/// #     .build();
1148///
1149/// # let executor = hyper_util::rt::TokioExecutor::new();
1150/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1151/// #     secret,
1152/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1153/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1154/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1155/// #     ),
1156/// # ).build().await.unwrap();
1157///
1158/// # let client = hyper_util::client::legacy::Client::builder(
1159/// #     hyper_util::rt::TokioExecutor::new()
1160/// # )
1161/// # .build(
1162/// #     hyper_rustls::HttpsConnectorBuilder::new()
1163/// #         .with_native_roots()
1164/// #         .unwrap()
1165/// #         .https_or_http()
1166/// #         .enable_http2()
1167/// #         .build()
1168/// # );
1169/// # let mut hub = BigQueryConnectionService::new(client, auth);
1170/// // You can configure optional parameters by calling the respective setters at will, and
1171/// // execute the final call using `doit()`.
1172/// // Values shown here are possibly random and not representative !
1173/// let result = hub.projects().locations_connections_delete("name")
1174///              .doit().await;
1175/// # }
1176/// ```
1177pub struct ProjectLocationConnectionDeleteCall<'a, C>
1178where
1179    C: 'a,
1180{
1181    hub: &'a BigQueryConnectionService<C>,
1182    _name: String,
1183    _delegate: Option<&'a mut dyn common::Delegate>,
1184    _additional_params: HashMap<String, String>,
1185    _scopes: BTreeSet<String>,
1186}
1187
1188impl<'a, C> common::CallBuilder for ProjectLocationConnectionDeleteCall<'a, C> {}
1189
1190impl<'a, C> ProjectLocationConnectionDeleteCall<'a, C>
1191where
1192    C: common::Connector,
1193{
1194    /// Perform the operation you have build so far.
1195    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
1196        use std::borrow::Cow;
1197        use std::io::{Read, Seek};
1198
1199        use common::{url::Params, ToParts};
1200        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1201
1202        let mut dd = common::DefaultDelegate;
1203        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1204        dlg.begin(common::MethodInfo {
1205            id: "bigqueryconnection.projects.locations.connections.delete",
1206            http_method: hyper::Method::DELETE,
1207        });
1208
1209        for &field in ["alt", "name"].iter() {
1210            if self._additional_params.contains_key(field) {
1211                dlg.finished(false);
1212                return Err(common::Error::FieldClash(field));
1213            }
1214        }
1215
1216        let mut params = Params::with_capacity(3 + self._additional_params.len());
1217        params.push("name", self._name);
1218
1219        params.extend(self._additional_params.iter());
1220
1221        params.push("alt", "json");
1222        let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
1223        if self._scopes.is_empty() {
1224            self._scopes
1225                .insert(Scope::CloudPlatform.as_ref().to_string());
1226        }
1227
1228        #[allow(clippy::single_element_loop)]
1229        for &(find_this, param_name) in [("{+name}", "name")].iter() {
1230            url = params.uri_replacement(url, param_name, find_this, true);
1231        }
1232        {
1233            let to_remove = ["name"];
1234            params.remove_params(&to_remove);
1235        }
1236
1237        let url = params.parse_with_url(&url);
1238
1239        loop {
1240            let token = match self
1241                .hub
1242                .auth
1243                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1244                .await
1245            {
1246                Ok(token) => token,
1247                Err(e) => match dlg.token(e) {
1248                    Ok(token) => token,
1249                    Err(e) => {
1250                        dlg.finished(false);
1251                        return Err(common::Error::MissingToken(e));
1252                    }
1253                },
1254            };
1255            let mut req_result = {
1256                let client = &self.hub.client;
1257                dlg.pre_request();
1258                let mut req_builder = hyper::Request::builder()
1259                    .method(hyper::Method::DELETE)
1260                    .uri(url.as_str())
1261                    .header(USER_AGENT, self.hub._user_agent.clone());
1262
1263                if let Some(token) = token.as_ref() {
1264                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1265                }
1266
1267                let request = req_builder
1268                    .header(CONTENT_LENGTH, 0_u64)
1269                    .body(common::to_body::<String>(None));
1270
1271                client.request(request.unwrap()).await
1272            };
1273
1274            match req_result {
1275                Err(err) => {
1276                    if let common::Retry::After(d) = dlg.http_error(&err) {
1277                        sleep(d).await;
1278                        continue;
1279                    }
1280                    dlg.finished(false);
1281                    return Err(common::Error::HttpError(err));
1282                }
1283                Ok(res) => {
1284                    let (mut parts, body) = res.into_parts();
1285                    let mut body = common::Body::new(body);
1286                    if !parts.status.is_success() {
1287                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1288                        let error = serde_json::from_str(&common::to_string(&bytes));
1289                        let response = common::to_response(parts, bytes.into());
1290
1291                        if let common::Retry::After(d) =
1292                            dlg.http_failure(&response, error.as_ref().ok())
1293                        {
1294                            sleep(d).await;
1295                            continue;
1296                        }
1297
1298                        dlg.finished(false);
1299
1300                        return Err(match error {
1301                            Ok(value) => common::Error::BadRequest(value),
1302                            _ => common::Error::Failure(response),
1303                        });
1304                    }
1305                    let response = {
1306                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1307                        let encoded = common::to_string(&bytes);
1308                        match serde_json::from_str(&encoded) {
1309                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1310                            Err(error) => {
1311                                dlg.response_json_decode_error(&encoded, &error);
1312                                return Err(common::Error::JsonDecodeError(
1313                                    encoded.to_string(),
1314                                    error,
1315                                ));
1316                            }
1317                        }
1318                    };
1319
1320                    dlg.finished(true);
1321                    return Ok(response);
1322                }
1323            }
1324        }
1325    }
1326
1327    /// Required. Name of the deleted connection, for example: `projects/{project_id}/locations/{location_id}/connections/{connection_id}`
1328    ///
1329    /// Sets the *name* path property to the given value.
1330    ///
1331    /// Even though the property as already been set when instantiating this call,
1332    /// we provide this method for API completeness.
1333    pub fn name(mut self, new_value: &str) -> ProjectLocationConnectionDeleteCall<'a, C> {
1334        self._name = new_value.to_string();
1335        self
1336    }
1337    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1338    /// while executing the actual API request.
1339    ///
1340    /// ````text
1341    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1342    /// ````
1343    ///
1344    /// Sets the *delegate* property to the given value.
1345    pub fn delegate(
1346        mut self,
1347        new_value: &'a mut dyn common::Delegate,
1348    ) -> ProjectLocationConnectionDeleteCall<'a, C> {
1349        self._delegate = Some(new_value);
1350        self
1351    }
1352
1353    /// Set any additional parameter of the query string used in the request.
1354    /// It should be used to set parameters which are not yet available through their own
1355    /// setters.
1356    ///
1357    /// Please note that this method must not be used to set any of the known parameters
1358    /// which have their own setter method. If done anyway, the request will fail.
1359    ///
1360    /// # Additional Parameters
1361    ///
1362    /// * *$.xgafv* (query-string) - V1 error format.
1363    /// * *access_token* (query-string) - OAuth access token.
1364    /// * *alt* (query-string) - Data format for response.
1365    /// * *callback* (query-string) - JSONP
1366    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1367    /// * *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.
1368    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1369    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1370    /// * *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.
1371    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1372    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1373    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationConnectionDeleteCall<'a, C>
1374    where
1375        T: AsRef<str>,
1376    {
1377        self._additional_params
1378            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1379        self
1380    }
1381
1382    /// Identifies the authorization scope for the method you are building.
1383    ///
1384    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1385    /// [`Scope::CloudPlatform`].
1386    ///
1387    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1388    /// tokens for more than one scope.
1389    ///
1390    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1391    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1392    /// sufficient, a read-write scope will do as well.
1393    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationConnectionDeleteCall<'a, C>
1394    where
1395        St: AsRef<str>,
1396    {
1397        self._scopes.insert(String::from(scope.as_ref()));
1398        self
1399    }
1400    /// Identifies the authorization scope(s) for the method you are building.
1401    ///
1402    /// See [`Self::add_scope()`] for details.
1403    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationConnectionDeleteCall<'a, C>
1404    where
1405        I: IntoIterator<Item = St>,
1406        St: AsRef<str>,
1407    {
1408        self._scopes
1409            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1410        self
1411    }
1412
1413    /// Removes all scopes, and no default scope will be used either.
1414    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1415    /// for details).
1416    pub fn clear_scopes(mut self) -> ProjectLocationConnectionDeleteCall<'a, C> {
1417        self._scopes.clear();
1418        self
1419    }
1420}
1421
1422/// Returns specified connection.
1423///
1424/// A builder for the *locations.connections.get* method supported by a *project* resource.
1425/// It is not used directly, but through a [`ProjectMethods`] instance.
1426///
1427/// # Example
1428///
1429/// Instantiate a resource method builder
1430///
1431/// ```test_harness,no_run
1432/// # extern crate hyper;
1433/// # extern crate hyper_rustls;
1434/// # extern crate google_bigqueryconnection1_beta1 as bigqueryconnection1_beta1;
1435/// # async fn dox() {
1436/// # use bigqueryconnection1_beta1::{BigQueryConnectionService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1437///
1438/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1439/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1440/// #     .with_native_roots()
1441/// #     .unwrap()
1442/// #     .https_only()
1443/// #     .enable_http2()
1444/// #     .build();
1445///
1446/// # let executor = hyper_util::rt::TokioExecutor::new();
1447/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1448/// #     secret,
1449/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1450/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1451/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1452/// #     ),
1453/// # ).build().await.unwrap();
1454///
1455/// # let client = hyper_util::client::legacy::Client::builder(
1456/// #     hyper_util::rt::TokioExecutor::new()
1457/// # )
1458/// # .build(
1459/// #     hyper_rustls::HttpsConnectorBuilder::new()
1460/// #         .with_native_roots()
1461/// #         .unwrap()
1462/// #         .https_or_http()
1463/// #         .enable_http2()
1464/// #         .build()
1465/// # );
1466/// # let mut hub = BigQueryConnectionService::new(client, auth);
1467/// // You can configure optional parameters by calling the respective setters at will, and
1468/// // execute the final call using `doit()`.
1469/// // Values shown here are possibly random and not representative !
1470/// let result = hub.projects().locations_connections_get("name")
1471///              .doit().await;
1472/// # }
1473/// ```
1474pub struct ProjectLocationConnectionGetCall<'a, C>
1475where
1476    C: 'a,
1477{
1478    hub: &'a BigQueryConnectionService<C>,
1479    _name: String,
1480    _delegate: Option<&'a mut dyn common::Delegate>,
1481    _additional_params: HashMap<String, String>,
1482    _scopes: BTreeSet<String>,
1483}
1484
1485impl<'a, C> common::CallBuilder for ProjectLocationConnectionGetCall<'a, C> {}
1486
1487impl<'a, C> ProjectLocationConnectionGetCall<'a, C>
1488where
1489    C: common::Connector,
1490{
1491    /// Perform the operation you have build so far.
1492    pub async fn doit(mut self) -> common::Result<(common::Response, Connection)> {
1493        use std::borrow::Cow;
1494        use std::io::{Read, Seek};
1495
1496        use common::{url::Params, ToParts};
1497        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1498
1499        let mut dd = common::DefaultDelegate;
1500        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1501        dlg.begin(common::MethodInfo {
1502            id: "bigqueryconnection.projects.locations.connections.get",
1503            http_method: hyper::Method::GET,
1504        });
1505
1506        for &field in ["alt", "name"].iter() {
1507            if self._additional_params.contains_key(field) {
1508                dlg.finished(false);
1509                return Err(common::Error::FieldClash(field));
1510            }
1511        }
1512
1513        let mut params = Params::with_capacity(3 + self._additional_params.len());
1514        params.push("name", self._name);
1515
1516        params.extend(self._additional_params.iter());
1517
1518        params.push("alt", "json");
1519        let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
1520        if self._scopes.is_empty() {
1521            self._scopes
1522                .insert(Scope::CloudPlatform.as_ref().to_string());
1523        }
1524
1525        #[allow(clippy::single_element_loop)]
1526        for &(find_this, param_name) in [("{+name}", "name")].iter() {
1527            url = params.uri_replacement(url, param_name, find_this, true);
1528        }
1529        {
1530            let to_remove = ["name"];
1531            params.remove_params(&to_remove);
1532        }
1533
1534        let url = params.parse_with_url(&url);
1535
1536        loop {
1537            let token = match self
1538                .hub
1539                .auth
1540                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1541                .await
1542            {
1543                Ok(token) => token,
1544                Err(e) => match dlg.token(e) {
1545                    Ok(token) => token,
1546                    Err(e) => {
1547                        dlg.finished(false);
1548                        return Err(common::Error::MissingToken(e));
1549                    }
1550                },
1551            };
1552            let mut req_result = {
1553                let client = &self.hub.client;
1554                dlg.pre_request();
1555                let mut req_builder = hyper::Request::builder()
1556                    .method(hyper::Method::GET)
1557                    .uri(url.as_str())
1558                    .header(USER_AGENT, self.hub._user_agent.clone());
1559
1560                if let Some(token) = token.as_ref() {
1561                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1562                }
1563
1564                let request = req_builder
1565                    .header(CONTENT_LENGTH, 0_u64)
1566                    .body(common::to_body::<String>(None));
1567
1568                client.request(request.unwrap()).await
1569            };
1570
1571            match req_result {
1572                Err(err) => {
1573                    if let common::Retry::After(d) = dlg.http_error(&err) {
1574                        sleep(d).await;
1575                        continue;
1576                    }
1577                    dlg.finished(false);
1578                    return Err(common::Error::HttpError(err));
1579                }
1580                Ok(res) => {
1581                    let (mut parts, body) = res.into_parts();
1582                    let mut body = common::Body::new(body);
1583                    if !parts.status.is_success() {
1584                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1585                        let error = serde_json::from_str(&common::to_string(&bytes));
1586                        let response = common::to_response(parts, bytes.into());
1587
1588                        if let common::Retry::After(d) =
1589                            dlg.http_failure(&response, error.as_ref().ok())
1590                        {
1591                            sleep(d).await;
1592                            continue;
1593                        }
1594
1595                        dlg.finished(false);
1596
1597                        return Err(match error {
1598                            Ok(value) => common::Error::BadRequest(value),
1599                            _ => common::Error::Failure(response),
1600                        });
1601                    }
1602                    let response = {
1603                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1604                        let encoded = common::to_string(&bytes);
1605                        match serde_json::from_str(&encoded) {
1606                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1607                            Err(error) => {
1608                                dlg.response_json_decode_error(&encoded, &error);
1609                                return Err(common::Error::JsonDecodeError(
1610                                    encoded.to_string(),
1611                                    error,
1612                                ));
1613                            }
1614                        }
1615                    };
1616
1617                    dlg.finished(true);
1618                    return Ok(response);
1619                }
1620            }
1621        }
1622    }
1623
1624    /// Required. Name of the requested connection, for example: `projects/{project_id}/locations/{location_id}/connections/{connection_id}`
1625    ///
1626    /// Sets the *name* path property to the given value.
1627    ///
1628    /// Even though the property as already been set when instantiating this call,
1629    /// we provide this method for API completeness.
1630    pub fn name(mut self, new_value: &str) -> ProjectLocationConnectionGetCall<'a, C> {
1631        self._name = new_value.to_string();
1632        self
1633    }
1634    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1635    /// while executing the actual API request.
1636    ///
1637    /// ````text
1638    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1639    /// ````
1640    ///
1641    /// Sets the *delegate* property to the given value.
1642    pub fn delegate(
1643        mut self,
1644        new_value: &'a mut dyn common::Delegate,
1645    ) -> ProjectLocationConnectionGetCall<'a, C> {
1646        self._delegate = Some(new_value);
1647        self
1648    }
1649
1650    /// Set any additional parameter of the query string used in the request.
1651    /// It should be used to set parameters which are not yet available through their own
1652    /// setters.
1653    ///
1654    /// Please note that this method must not be used to set any of the known parameters
1655    /// which have their own setter method. If done anyway, the request will fail.
1656    ///
1657    /// # Additional Parameters
1658    ///
1659    /// * *$.xgafv* (query-string) - V1 error format.
1660    /// * *access_token* (query-string) - OAuth access token.
1661    /// * *alt* (query-string) - Data format for response.
1662    /// * *callback* (query-string) - JSONP
1663    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1664    /// * *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.
1665    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1666    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1667    /// * *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.
1668    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1669    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1670    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationConnectionGetCall<'a, C>
1671    where
1672        T: AsRef<str>,
1673    {
1674        self._additional_params
1675            .insert(name.as_ref().to_string(), value.as_ref().to_string());
1676        self
1677    }
1678
1679    /// Identifies the authorization scope for the method you are building.
1680    ///
1681    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1682    /// [`Scope::CloudPlatform`].
1683    ///
1684    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1685    /// tokens for more than one scope.
1686    ///
1687    /// Usually there is more than one suitable scope to authorize an operation, some of which may
1688    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1689    /// sufficient, a read-write scope will do as well.
1690    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationConnectionGetCall<'a, C>
1691    where
1692        St: AsRef<str>,
1693    {
1694        self._scopes.insert(String::from(scope.as_ref()));
1695        self
1696    }
1697    /// Identifies the authorization scope(s) for the method you are building.
1698    ///
1699    /// See [`Self::add_scope()`] for details.
1700    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationConnectionGetCall<'a, C>
1701    where
1702        I: IntoIterator<Item = St>,
1703        St: AsRef<str>,
1704    {
1705        self._scopes
1706            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1707        self
1708    }
1709
1710    /// Removes all scopes, and no default scope will be used either.
1711    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1712    /// for details).
1713    pub fn clear_scopes(mut self) -> ProjectLocationConnectionGetCall<'a, C> {
1714        self._scopes.clear();
1715        self
1716    }
1717}
1718
1719/// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
1720///
1721/// A builder for the *locations.connections.getIamPolicy* method supported by a *project* resource.
1722/// It is not used directly, but through a [`ProjectMethods`] instance.
1723///
1724/// # Example
1725///
1726/// Instantiate a resource method builder
1727///
1728/// ```test_harness,no_run
1729/// # extern crate hyper;
1730/// # extern crate hyper_rustls;
1731/// # extern crate google_bigqueryconnection1_beta1 as bigqueryconnection1_beta1;
1732/// use bigqueryconnection1_beta1::api::GetIamPolicyRequest;
1733/// # async fn dox() {
1734/// # use bigqueryconnection1_beta1::{BigQueryConnectionService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1735///
1736/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1737/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1738/// #     .with_native_roots()
1739/// #     .unwrap()
1740/// #     .https_only()
1741/// #     .enable_http2()
1742/// #     .build();
1743///
1744/// # let executor = hyper_util::rt::TokioExecutor::new();
1745/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1746/// #     secret,
1747/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1748/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
1749/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
1750/// #     ),
1751/// # ).build().await.unwrap();
1752///
1753/// # let client = hyper_util::client::legacy::Client::builder(
1754/// #     hyper_util::rt::TokioExecutor::new()
1755/// # )
1756/// # .build(
1757/// #     hyper_rustls::HttpsConnectorBuilder::new()
1758/// #         .with_native_roots()
1759/// #         .unwrap()
1760/// #         .https_or_http()
1761/// #         .enable_http2()
1762/// #         .build()
1763/// # );
1764/// # let mut hub = BigQueryConnectionService::new(client, auth);
1765/// // As the method needs a request, you would usually fill it with the desired information
1766/// // into the respective structure. Some of the parts shown here might not be applicable !
1767/// // Values shown here are possibly random and not representative !
1768/// let mut req = GetIamPolicyRequest::default();
1769///
1770/// // You can configure optional parameters by calling the respective setters at will, and
1771/// // execute the final call using `doit()`.
1772/// // Values shown here are possibly random and not representative !
1773/// let result = hub.projects().locations_connections_get_iam_policy(req, "resource")
1774///              .doit().await;
1775/// # }
1776/// ```
1777pub struct ProjectLocationConnectionGetIamPolicyCall<'a, C>
1778where
1779    C: 'a,
1780{
1781    hub: &'a BigQueryConnectionService<C>,
1782    _request: GetIamPolicyRequest,
1783    _resource: String,
1784    _delegate: Option<&'a mut dyn common::Delegate>,
1785    _additional_params: HashMap<String, String>,
1786    _scopes: BTreeSet<String>,
1787}
1788
1789impl<'a, C> common::CallBuilder for ProjectLocationConnectionGetIamPolicyCall<'a, C> {}
1790
1791impl<'a, C> ProjectLocationConnectionGetIamPolicyCall<'a, C>
1792where
1793    C: common::Connector,
1794{
1795    /// Perform the operation you have build so far.
1796    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
1797        use std::borrow::Cow;
1798        use std::io::{Read, Seek};
1799
1800        use common::{url::Params, ToParts};
1801        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1802
1803        let mut dd = common::DefaultDelegate;
1804        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1805        dlg.begin(common::MethodInfo {
1806            id: "bigqueryconnection.projects.locations.connections.getIamPolicy",
1807            http_method: hyper::Method::POST,
1808        });
1809
1810        for &field in ["alt", "resource"].iter() {
1811            if self._additional_params.contains_key(field) {
1812                dlg.finished(false);
1813                return Err(common::Error::FieldClash(field));
1814            }
1815        }
1816
1817        let mut params = Params::with_capacity(4 + self._additional_params.len());
1818        params.push("resource", self._resource);
1819
1820        params.extend(self._additional_params.iter());
1821
1822        params.push("alt", "json");
1823        let mut url = self.hub._base_url.clone() + "v1beta1/{+resource}:getIamPolicy";
1824        if self._scopes.is_empty() {
1825            self._scopes
1826                .insert(Scope::CloudPlatform.as_ref().to_string());
1827        }
1828
1829        #[allow(clippy::single_element_loop)]
1830        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
1831            url = params.uri_replacement(url, param_name, find_this, true);
1832        }
1833        {
1834            let to_remove = ["resource"];
1835            params.remove_params(&to_remove);
1836        }
1837
1838        let url = params.parse_with_url(&url);
1839
1840        let mut json_mime_type = mime::APPLICATION_JSON;
1841        let mut request_value_reader = {
1842            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1843            common::remove_json_null_values(&mut value);
1844            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1845            serde_json::to_writer(&mut dst, &value).unwrap();
1846            dst
1847        };
1848        let request_size = request_value_reader
1849            .seek(std::io::SeekFrom::End(0))
1850            .unwrap();
1851        request_value_reader
1852            .seek(std::io::SeekFrom::Start(0))
1853            .unwrap();
1854
1855        loop {
1856            let token = match self
1857                .hub
1858                .auth
1859                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1860                .await
1861            {
1862                Ok(token) => token,
1863                Err(e) => match dlg.token(e) {
1864                    Ok(token) => token,
1865                    Err(e) => {
1866                        dlg.finished(false);
1867                        return Err(common::Error::MissingToken(e));
1868                    }
1869                },
1870            };
1871            request_value_reader
1872                .seek(std::io::SeekFrom::Start(0))
1873                .unwrap();
1874            let mut req_result = {
1875                let client = &self.hub.client;
1876                dlg.pre_request();
1877                let mut req_builder = hyper::Request::builder()
1878                    .method(hyper::Method::POST)
1879                    .uri(url.as_str())
1880                    .header(USER_AGENT, self.hub._user_agent.clone());
1881
1882                if let Some(token) = token.as_ref() {
1883                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1884                }
1885
1886                let request = req_builder
1887                    .header(CONTENT_TYPE, json_mime_type.to_string())
1888                    .header(CONTENT_LENGTH, request_size as u64)
1889                    .body(common::to_body(
1890                        request_value_reader.get_ref().clone().into(),
1891                    ));
1892
1893                client.request(request.unwrap()).await
1894            };
1895
1896            match req_result {
1897                Err(err) => {
1898                    if let common::Retry::After(d) = dlg.http_error(&err) {
1899                        sleep(d).await;
1900                        continue;
1901                    }
1902                    dlg.finished(false);
1903                    return Err(common::Error::HttpError(err));
1904                }
1905                Ok(res) => {
1906                    let (mut parts, body) = res.into_parts();
1907                    let mut body = common::Body::new(body);
1908                    if !parts.status.is_success() {
1909                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1910                        let error = serde_json::from_str(&common::to_string(&bytes));
1911                        let response = common::to_response(parts, bytes.into());
1912
1913                        if let common::Retry::After(d) =
1914                            dlg.http_failure(&response, error.as_ref().ok())
1915                        {
1916                            sleep(d).await;
1917                            continue;
1918                        }
1919
1920                        dlg.finished(false);
1921
1922                        return Err(match error {
1923                            Ok(value) => common::Error::BadRequest(value),
1924                            _ => common::Error::Failure(response),
1925                        });
1926                    }
1927                    let response = {
1928                        let bytes = common::to_bytes(body).await.unwrap_or_default();
1929                        let encoded = common::to_string(&bytes);
1930                        match serde_json::from_str(&encoded) {
1931                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1932                            Err(error) => {
1933                                dlg.response_json_decode_error(&encoded, &error);
1934                                return Err(common::Error::JsonDecodeError(
1935                                    encoded.to_string(),
1936                                    error,
1937                                ));
1938                            }
1939                        }
1940                    };
1941
1942                    dlg.finished(true);
1943                    return Ok(response);
1944                }
1945            }
1946        }
1947    }
1948
1949    ///
1950    /// Sets the *request* property to the given value.
1951    ///
1952    /// Even though the property as already been set when instantiating this call,
1953    /// we provide this method for API completeness.
1954    pub fn request(
1955        mut self,
1956        new_value: GetIamPolicyRequest,
1957    ) -> ProjectLocationConnectionGetIamPolicyCall<'a, C> {
1958        self._request = new_value;
1959        self
1960    }
1961    /// 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.
1962    ///
1963    /// Sets the *resource* path property to the given value.
1964    ///
1965    /// Even though the property as already been set when instantiating this call,
1966    /// we provide this method for API completeness.
1967    pub fn resource(mut self, new_value: &str) -> ProjectLocationConnectionGetIamPolicyCall<'a, C> {
1968        self._resource = new_value.to_string();
1969        self
1970    }
1971    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1972    /// while executing the actual API request.
1973    ///
1974    /// ````text
1975    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
1976    /// ````
1977    ///
1978    /// Sets the *delegate* property to the given value.
1979    pub fn delegate(
1980        mut self,
1981        new_value: &'a mut dyn common::Delegate,
1982    ) -> ProjectLocationConnectionGetIamPolicyCall<'a, C> {
1983        self._delegate = Some(new_value);
1984        self
1985    }
1986
1987    /// Set any additional parameter of the query string used in the request.
1988    /// It should be used to set parameters which are not yet available through their own
1989    /// setters.
1990    ///
1991    /// Please note that this method must not be used to set any of the known parameters
1992    /// which have their own setter method. If done anyway, the request will fail.
1993    ///
1994    /// # Additional Parameters
1995    ///
1996    /// * *$.xgafv* (query-string) - V1 error format.
1997    /// * *access_token* (query-string) - OAuth access token.
1998    /// * *alt* (query-string) - Data format for response.
1999    /// * *callback* (query-string) - JSONP
2000    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2001    /// * *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.
2002    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2003    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2004    /// * *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.
2005    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2006    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2007    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationConnectionGetIamPolicyCall<'a, C>
2008    where
2009        T: AsRef<str>,
2010    {
2011        self._additional_params
2012            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2013        self
2014    }
2015
2016    /// Identifies the authorization scope for the method you are building.
2017    ///
2018    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2019    /// [`Scope::CloudPlatform`].
2020    ///
2021    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2022    /// tokens for more than one scope.
2023    ///
2024    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2025    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2026    /// sufficient, a read-write scope will do as well.
2027    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationConnectionGetIamPolicyCall<'a, C>
2028    where
2029        St: AsRef<str>,
2030    {
2031        self._scopes.insert(String::from(scope.as_ref()));
2032        self
2033    }
2034    /// Identifies the authorization scope(s) for the method you are building.
2035    ///
2036    /// See [`Self::add_scope()`] for details.
2037    pub fn add_scopes<I, St>(
2038        mut self,
2039        scopes: I,
2040    ) -> ProjectLocationConnectionGetIamPolicyCall<'a, C>
2041    where
2042        I: IntoIterator<Item = St>,
2043        St: AsRef<str>,
2044    {
2045        self._scopes
2046            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2047        self
2048    }
2049
2050    /// Removes all scopes, and no default scope will be used either.
2051    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2052    /// for details).
2053    pub fn clear_scopes(mut self) -> ProjectLocationConnectionGetIamPolicyCall<'a, C> {
2054        self._scopes.clear();
2055        self
2056    }
2057}
2058
2059/// Returns a list of connections in the given project.
2060///
2061/// A builder for the *locations.connections.list* method supported by a *project* resource.
2062/// It is not used directly, but through a [`ProjectMethods`] instance.
2063///
2064/// # Example
2065///
2066/// Instantiate a resource method builder
2067///
2068/// ```test_harness,no_run
2069/// # extern crate hyper;
2070/// # extern crate hyper_rustls;
2071/// # extern crate google_bigqueryconnection1_beta1 as bigqueryconnection1_beta1;
2072/// # async fn dox() {
2073/// # use bigqueryconnection1_beta1::{BigQueryConnectionService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2074///
2075/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2076/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2077/// #     .with_native_roots()
2078/// #     .unwrap()
2079/// #     .https_only()
2080/// #     .enable_http2()
2081/// #     .build();
2082///
2083/// # let executor = hyper_util::rt::TokioExecutor::new();
2084/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2085/// #     secret,
2086/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2087/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2088/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2089/// #     ),
2090/// # ).build().await.unwrap();
2091///
2092/// # let client = hyper_util::client::legacy::Client::builder(
2093/// #     hyper_util::rt::TokioExecutor::new()
2094/// # )
2095/// # .build(
2096/// #     hyper_rustls::HttpsConnectorBuilder::new()
2097/// #         .with_native_roots()
2098/// #         .unwrap()
2099/// #         .https_or_http()
2100/// #         .enable_http2()
2101/// #         .build()
2102/// # );
2103/// # let mut hub = BigQueryConnectionService::new(client, auth);
2104/// // You can configure optional parameters by calling the respective setters at will, and
2105/// // execute the final call using `doit()`.
2106/// // Values shown here are possibly random and not representative !
2107/// let result = hub.projects().locations_connections_list("parent")
2108///              .page_token("ipsum")
2109///              .max_results(39)
2110///              .doit().await;
2111/// # }
2112/// ```
2113pub struct ProjectLocationConnectionListCall<'a, C>
2114where
2115    C: 'a,
2116{
2117    hub: &'a BigQueryConnectionService<C>,
2118    _parent: String,
2119    _page_token: Option<String>,
2120    _max_results: Option<u32>,
2121    _delegate: Option<&'a mut dyn common::Delegate>,
2122    _additional_params: HashMap<String, String>,
2123    _scopes: BTreeSet<String>,
2124}
2125
2126impl<'a, C> common::CallBuilder for ProjectLocationConnectionListCall<'a, C> {}
2127
2128impl<'a, C> ProjectLocationConnectionListCall<'a, C>
2129where
2130    C: common::Connector,
2131{
2132    /// Perform the operation you have build so far.
2133    pub async fn doit(mut self) -> common::Result<(common::Response, ListConnectionsResponse)> {
2134        use std::borrow::Cow;
2135        use std::io::{Read, Seek};
2136
2137        use common::{url::Params, ToParts};
2138        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2139
2140        let mut dd = common::DefaultDelegate;
2141        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2142        dlg.begin(common::MethodInfo {
2143            id: "bigqueryconnection.projects.locations.connections.list",
2144            http_method: hyper::Method::GET,
2145        });
2146
2147        for &field in ["alt", "parent", "pageToken", "maxResults"].iter() {
2148            if self._additional_params.contains_key(field) {
2149                dlg.finished(false);
2150                return Err(common::Error::FieldClash(field));
2151            }
2152        }
2153
2154        let mut params = Params::with_capacity(5 + self._additional_params.len());
2155        params.push("parent", self._parent);
2156        if let Some(value) = self._page_token.as_ref() {
2157            params.push("pageToken", value);
2158        }
2159        if let Some(value) = self._max_results.as_ref() {
2160            params.push("maxResults", value.to_string());
2161        }
2162
2163        params.extend(self._additional_params.iter());
2164
2165        params.push("alt", "json");
2166        let mut url = self.hub._base_url.clone() + "v1beta1/{+parent}/connections";
2167        if self._scopes.is_empty() {
2168            self._scopes
2169                .insert(Scope::CloudPlatform.as_ref().to_string());
2170        }
2171
2172        #[allow(clippy::single_element_loop)]
2173        for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
2174            url = params.uri_replacement(url, param_name, find_this, true);
2175        }
2176        {
2177            let to_remove = ["parent"];
2178            params.remove_params(&to_remove);
2179        }
2180
2181        let url = params.parse_with_url(&url);
2182
2183        loop {
2184            let token = match self
2185                .hub
2186                .auth
2187                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2188                .await
2189            {
2190                Ok(token) => token,
2191                Err(e) => match dlg.token(e) {
2192                    Ok(token) => token,
2193                    Err(e) => {
2194                        dlg.finished(false);
2195                        return Err(common::Error::MissingToken(e));
2196                    }
2197                },
2198            };
2199            let mut req_result = {
2200                let client = &self.hub.client;
2201                dlg.pre_request();
2202                let mut req_builder = hyper::Request::builder()
2203                    .method(hyper::Method::GET)
2204                    .uri(url.as_str())
2205                    .header(USER_AGENT, self.hub._user_agent.clone());
2206
2207                if let Some(token) = token.as_ref() {
2208                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2209                }
2210
2211                let request = req_builder
2212                    .header(CONTENT_LENGTH, 0_u64)
2213                    .body(common::to_body::<String>(None));
2214
2215                client.request(request.unwrap()).await
2216            };
2217
2218            match req_result {
2219                Err(err) => {
2220                    if let common::Retry::After(d) = dlg.http_error(&err) {
2221                        sleep(d).await;
2222                        continue;
2223                    }
2224                    dlg.finished(false);
2225                    return Err(common::Error::HttpError(err));
2226                }
2227                Ok(res) => {
2228                    let (mut parts, body) = res.into_parts();
2229                    let mut body = common::Body::new(body);
2230                    if !parts.status.is_success() {
2231                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2232                        let error = serde_json::from_str(&common::to_string(&bytes));
2233                        let response = common::to_response(parts, bytes.into());
2234
2235                        if let common::Retry::After(d) =
2236                            dlg.http_failure(&response, error.as_ref().ok())
2237                        {
2238                            sleep(d).await;
2239                            continue;
2240                        }
2241
2242                        dlg.finished(false);
2243
2244                        return Err(match error {
2245                            Ok(value) => common::Error::BadRequest(value),
2246                            _ => common::Error::Failure(response),
2247                        });
2248                    }
2249                    let response = {
2250                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2251                        let encoded = common::to_string(&bytes);
2252                        match serde_json::from_str(&encoded) {
2253                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2254                            Err(error) => {
2255                                dlg.response_json_decode_error(&encoded, &error);
2256                                return Err(common::Error::JsonDecodeError(
2257                                    encoded.to_string(),
2258                                    error,
2259                                ));
2260                            }
2261                        }
2262                    };
2263
2264                    dlg.finished(true);
2265                    return Ok(response);
2266                }
2267            }
2268        }
2269    }
2270
2271    /// Required. Parent resource name. Must be in the form: `projects/{project_id}/locations/{location_id}`
2272    ///
2273    /// Sets the *parent* path property to the given value.
2274    ///
2275    /// Even though the property as already been set when instantiating this call,
2276    /// we provide this method for API completeness.
2277    pub fn parent(mut self, new_value: &str) -> ProjectLocationConnectionListCall<'a, C> {
2278        self._parent = new_value.to_string();
2279        self
2280    }
2281    /// Page token.
2282    ///
2283    /// Sets the *page token* query property to the given value.
2284    pub fn page_token(mut self, new_value: &str) -> ProjectLocationConnectionListCall<'a, C> {
2285        self._page_token = Some(new_value.to_string());
2286        self
2287    }
2288    /// Required. Maximum number of results per page.
2289    ///
2290    /// Sets the *max results* query property to the given value.
2291    pub fn max_results(mut self, new_value: u32) -> ProjectLocationConnectionListCall<'a, C> {
2292        self._max_results = Some(new_value);
2293        self
2294    }
2295    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2296    /// while executing the actual API request.
2297    ///
2298    /// ````text
2299    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2300    /// ````
2301    ///
2302    /// Sets the *delegate* property to the given value.
2303    pub fn delegate(
2304        mut self,
2305        new_value: &'a mut dyn common::Delegate,
2306    ) -> ProjectLocationConnectionListCall<'a, C> {
2307        self._delegate = Some(new_value);
2308        self
2309    }
2310
2311    /// Set any additional parameter of the query string used in the request.
2312    /// It should be used to set parameters which are not yet available through their own
2313    /// setters.
2314    ///
2315    /// Please note that this method must not be used to set any of the known parameters
2316    /// which have their own setter method. If done anyway, the request will fail.
2317    ///
2318    /// # Additional Parameters
2319    ///
2320    /// * *$.xgafv* (query-string) - V1 error format.
2321    /// * *access_token* (query-string) - OAuth access token.
2322    /// * *alt* (query-string) - Data format for response.
2323    /// * *callback* (query-string) - JSONP
2324    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2325    /// * *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.
2326    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2327    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2328    /// * *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.
2329    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2330    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2331    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationConnectionListCall<'a, C>
2332    where
2333        T: AsRef<str>,
2334    {
2335        self._additional_params
2336            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2337        self
2338    }
2339
2340    /// Identifies the authorization scope for the method you are building.
2341    ///
2342    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2343    /// [`Scope::CloudPlatform`].
2344    ///
2345    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2346    /// tokens for more than one scope.
2347    ///
2348    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2349    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2350    /// sufficient, a read-write scope will do as well.
2351    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationConnectionListCall<'a, C>
2352    where
2353        St: AsRef<str>,
2354    {
2355        self._scopes.insert(String::from(scope.as_ref()));
2356        self
2357    }
2358    /// Identifies the authorization scope(s) for the method you are building.
2359    ///
2360    /// See [`Self::add_scope()`] for details.
2361    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationConnectionListCall<'a, C>
2362    where
2363        I: IntoIterator<Item = St>,
2364        St: AsRef<str>,
2365    {
2366        self._scopes
2367            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2368        self
2369    }
2370
2371    /// Removes all scopes, and no default scope will be used either.
2372    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2373    /// for details).
2374    pub fn clear_scopes(mut self) -> ProjectLocationConnectionListCall<'a, C> {
2375        self._scopes.clear();
2376        self
2377    }
2378}
2379
2380/// Updates the specified connection. For security reasons, also resets credential if connection properties are in the update field mask.
2381///
2382/// A builder for the *locations.connections.patch* method supported by a *project* resource.
2383/// It is not used directly, but through a [`ProjectMethods`] instance.
2384///
2385/// # Example
2386///
2387/// Instantiate a resource method builder
2388///
2389/// ```test_harness,no_run
2390/// # extern crate hyper;
2391/// # extern crate hyper_rustls;
2392/// # extern crate google_bigqueryconnection1_beta1 as bigqueryconnection1_beta1;
2393/// use bigqueryconnection1_beta1::api::Connection;
2394/// # async fn dox() {
2395/// # use bigqueryconnection1_beta1::{BigQueryConnectionService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2396///
2397/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2398/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2399/// #     .with_native_roots()
2400/// #     .unwrap()
2401/// #     .https_only()
2402/// #     .enable_http2()
2403/// #     .build();
2404///
2405/// # let executor = hyper_util::rt::TokioExecutor::new();
2406/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2407/// #     secret,
2408/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2409/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2410/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2411/// #     ),
2412/// # ).build().await.unwrap();
2413///
2414/// # let client = hyper_util::client::legacy::Client::builder(
2415/// #     hyper_util::rt::TokioExecutor::new()
2416/// # )
2417/// # .build(
2418/// #     hyper_rustls::HttpsConnectorBuilder::new()
2419/// #         .with_native_roots()
2420/// #         .unwrap()
2421/// #         .https_or_http()
2422/// #         .enable_http2()
2423/// #         .build()
2424/// # );
2425/// # let mut hub = BigQueryConnectionService::new(client, auth);
2426/// // As the method needs a request, you would usually fill it with the desired information
2427/// // into the respective structure. Some of the parts shown here might not be applicable !
2428/// // Values shown here are possibly random and not representative !
2429/// let mut req = Connection::default();
2430///
2431/// // You can configure optional parameters by calling the respective setters at will, and
2432/// // execute the final call using `doit()`.
2433/// // Values shown here are possibly random and not representative !
2434/// let result = hub.projects().locations_connections_patch(req, "name")
2435///              .update_mask(FieldMask::new::<&str>(&[]))
2436///              .doit().await;
2437/// # }
2438/// ```
2439pub struct ProjectLocationConnectionPatchCall<'a, C>
2440where
2441    C: 'a,
2442{
2443    hub: &'a BigQueryConnectionService<C>,
2444    _request: Connection,
2445    _name: String,
2446    _update_mask: Option<common::FieldMask>,
2447    _delegate: Option<&'a mut dyn common::Delegate>,
2448    _additional_params: HashMap<String, String>,
2449    _scopes: BTreeSet<String>,
2450}
2451
2452impl<'a, C> common::CallBuilder for ProjectLocationConnectionPatchCall<'a, C> {}
2453
2454impl<'a, C> ProjectLocationConnectionPatchCall<'a, C>
2455where
2456    C: common::Connector,
2457{
2458    /// Perform the operation you have build so far.
2459    pub async fn doit(mut self) -> common::Result<(common::Response, Connection)> {
2460        use std::borrow::Cow;
2461        use std::io::{Read, Seek};
2462
2463        use common::{url::Params, ToParts};
2464        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2465
2466        let mut dd = common::DefaultDelegate;
2467        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2468        dlg.begin(common::MethodInfo {
2469            id: "bigqueryconnection.projects.locations.connections.patch",
2470            http_method: hyper::Method::PATCH,
2471        });
2472
2473        for &field in ["alt", "name", "updateMask"].iter() {
2474            if self._additional_params.contains_key(field) {
2475                dlg.finished(false);
2476                return Err(common::Error::FieldClash(field));
2477            }
2478        }
2479
2480        let mut params = Params::with_capacity(5 + self._additional_params.len());
2481        params.push("name", self._name);
2482        if let Some(value) = self._update_mask.as_ref() {
2483            params.push("updateMask", value.to_string());
2484        }
2485
2486        params.extend(self._additional_params.iter());
2487
2488        params.push("alt", "json");
2489        let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
2490        if self._scopes.is_empty() {
2491            self._scopes
2492                .insert(Scope::CloudPlatform.as_ref().to_string());
2493        }
2494
2495        #[allow(clippy::single_element_loop)]
2496        for &(find_this, param_name) in [("{+name}", "name")].iter() {
2497            url = params.uri_replacement(url, param_name, find_this, true);
2498        }
2499        {
2500            let to_remove = ["name"];
2501            params.remove_params(&to_remove);
2502        }
2503
2504        let url = params.parse_with_url(&url);
2505
2506        let mut json_mime_type = mime::APPLICATION_JSON;
2507        let mut request_value_reader = {
2508            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2509            common::remove_json_null_values(&mut value);
2510            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2511            serde_json::to_writer(&mut dst, &value).unwrap();
2512            dst
2513        };
2514        let request_size = request_value_reader
2515            .seek(std::io::SeekFrom::End(0))
2516            .unwrap();
2517        request_value_reader
2518            .seek(std::io::SeekFrom::Start(0))
2519            .unwrap();
2520
2521        loop {
2522            let token = match self
2523                .hub
2524                .auth
2525                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2526                .await
2527            {
2528                Ok(token) => token,
2529                Err(e) => match dlg.token(e) {
2530                    Ok(token) => token,
2531                    Err(e) => {
2532                        dlg.finished(false);
2533                        return Err(common::Error::MissingToken(e));
2534                    }
2535                },
2536            };
2537            request_value_reader
2538                .seek(std::io::SeekFrom::Start(0))
2539                .unwrap();
2540            let mut req_result = {
2541                let client = &self.hub.client;
2542                dlg.pre_request();
2543                let mut req_builder = hyper::Request::builder()
2544                    .method(hyper::Method::PATCH)
2545                    .uri(url.as_str())
2546                    .header(USER_AGENT, self.hub._user_agent.clone());
2547
2548                if let Some(token) = token.as_ref() {
2549                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2550                }
2551
2552                let request = req_builder
2553                    .header(CONTENT_TYPE, json_mime_type.to_string())
2554                    .header(CONTENT_LENGTH, request_size as u64)
2555                    .body(common::to_body(
2556                        request_value_reader.get_ref().clone().into(),
2557                    ));
2558
2559                client.request(request.unwrap()).await
2560            };
2561
2562            match req_result {
2563                Err(err) => {
2564                    if let common::Retry::After(d) = dlg.http_error(&err) {
2565                        sleep(d).await;
2566                        continue;
2567                    }
2568                    dlg.finished(false);
2569                    return Err(common::Error::HttpError(err));
2570                }
2571                Ok(res) => {
2572                    let (mut parts, body) = res.into_parts();
2573                    let mut body = common::Body::new(body);
2574                    if !parts.status.is_success() {
2575                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2576                        let error = serde_json::from_str(&common::to_string(&bytes));
2577                        let response = common::to_response(parts, bytes.into());
2578
2579                        if let common::Retry::After(d) =
2580                            dlg.http_failure(&response, error.as_ref().ok())
2581                        {
2582                            sleep(d).await;
2583                            continue;
2584                        }
2585
2586                        dlg.finished(false);
2587
2588                        return Err(match error {
2589                            Ok(value) => common::Error::BadRequest(value),
2590                            _ => common::Error::Failure(response),
2591                        });
2592                    }
2593                    let response = {
2594                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2595                        let encoded = common::to_string(&bytes);
2596                        match serde_json::from_str(&encoded) {
2597                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2598                            Err(error) => {
2599                                dlg.response_json_decode_error(&encoded, &error);
2600                                return Err(common::Error::JsonDecodeError(
2601                                    encoded.to_string(),
2602                                    error,
2603                                ));
2604                            }
2605                        }
2606                    };
2607
2608                    dlg.finished(true);
2609                    return Ok(response);
2610                }
2611            }
2612        }
2613    }
2614
2615    ///
2616    /// Sets the *request* property to the given value.
2617    ///
2618    /// Even though the property as already been set when instantiating this call,
2619    /// we provide this method for API completeness.
2620    pub fn request(mut self, new_value: Connection) -> ProjectLocationConnectionPatchCall<'a, C> {
2621        self._request = new_value;
2622        self
2623    }
2624    /// Required. Name of the connection to update, for example: `projects/{project_id}/locations/{location_id}/connections/{connection_id}`
2625    ///
2626    /// Sets the *name* path property to the given value.
2627    ///
2628    /// Even though the property as already been set when instantiating this call,
2629    /// we provide this method for API completeness.
2630    pub fn name(mut self, new_value: &str) -> ProjectLocationConnectionPatchCall<'a, C> {
2631        self._name = new_value.to_string();
2632        self
2633    }
2634    /// Required. Update mask for the connection fields to be updated.
2635    ///
2636    /// Sets the *update mask* query property to the given value.
2637    pub fn update_mask(
2638        mut self,
2639        new_value: common::FieldMask,
2640    ) -> ProjectLocationConnectionPatchCall<'a, C> {
2641        self._update_mask = Some(new_value);
2642        self
2643    }
2644    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2645    /// while executing the actual API request.
2646    ///
2647    /// ````text
2648    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2649    /// ````
2650    ///
2651    /// Sets the *delegate* property to the given value.
2652    pub fn delegate(
2653        mut self,
2654        new_value: &'a mut dyn common::Delegate,
2655    ) -> ProjectLocationConnectionPatchCall<'a, C> {
2656        self._delegate = Some(new_value);
2657        self
2658    }
2659
2660    /// Set any additional parameter of the query string used in the request.
2661    /// It should be used to set parameters which are not yet available through their own
2662    /// setters.
2663    ///
2664    /// Please note that this method must not be used to set any of the known parameters
2665    /// which have their own setter method. If done anyway, the request will fail.
2666    ///
2667    /// # Additional Parameters
2668    ///
2669    /// * *$.xgafv* (query-string) - V1 error format.
2670    /// * *access_token* (query-string) - OAuth access token.
2671    /// * *alt* (query-string) - Data format for response.
2672    /// * *callback* (query-string) - JSONP
2673    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2674    /// * *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.
2675    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2676    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2677    /// * *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.
2678    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2679    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2680    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationConnectionPatchCall<'a, C>
2681    where
2682        T: AsRef<str>,
2683    {
2684        self._additional_params
2685            .insert(name.as_ref().to_string(), value.as_ref().to_string());
2686        self
2687    }
2688
2689    /// Identifies the authorization scope for the method you are building.
2690    ///
2691    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2692    /// [`Scope::CloudPlatform`].
2693    ///
2694    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2695    /// tokens for more than one scope.
2696    ///
2697    /// Usually there is more than one suitable scope to authorize an operation, some of which may
2698    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2699    /// sufficient, a read-write scope will do as well.
2700    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationConnectionPatchCall<'a, C>
2701    where
2702        St: AsRef<str>,
2703    {
2704        self._scopes.insert(String::from(scope.as_ref()));
2705        self
2706    }
2707    /// Identifies the authorization scope(s) for the method you are building.
2708    ///
2709    /// See [`Self::add_scope()`] for details.
2710    pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationConnectionPatchCall<'a, C>
2711    where
2712        I: IntoIterator<Item = St>,
2713        St: AsRef<str>,
2714    {
2715        self._scopes
2716            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2717        self
2718    }
2719
2720    /// Removes all scopes, and no default scope will be used either.
2721    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2722    /// for details).
2723    pub fn clear_scopes(mut self) -> ProjectLocationConnectionPatchCall<'a, C> {
2724        self._scopes.clear();
2725        self
2726    }
2727}
2728
2729/// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
2730///
2731/// A builder for the *locations.connections.setIamPolicy* method supported by a *project* resource.
2732/// It is not used directly, but through a [`ProjectMethods`] instance.
2733///
2734/// # Example
2735///
2736/// Instantiate a resource method builder
2737///
2738/// ```test_harness,no_run
2739/// # extern crate hyper;
2740/// # extern crate hyper_rustls;
2741/// # extern crate google_bigqueryconnection1_beta1 as bigqueryconnection1_beta1;
2742/// use bigqueryconnection1_beta1::api::SetIamPolicyRequest;
2743/// # async fn dox() {
2744/// # use bigqueryconnection1_beta1::{BigQueryConnectionService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2745///
2746/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2747/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2748/// #     .with_native_roots()
2749/// #     .unwrap()
2750/// #     .https_only()
2751/// #     .enable_http2()
2752/// #     .build();
2753///
2754/// # let executor = hyper_util::rt::TokioExecutor::new();
2755/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2756/// #     secret,
2757/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2758/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
2759/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
2760/// #     ),
2761/// # ).build().await.unwrap();
2762///
2763/// # let client = hyper_util::client::legacy::Client::builder(
2764/// #     hyper_util::rt::TokioExecutor::new()
2765/// # )
2766/// # .build(
2767/// #     hyper_rustls::HttpsConnectorBuilder::new()
2768/// #         .with_native_roots()
2769/// #         .unwrap()
2770/// #         .https_or_http()
2771/// #         .enable_http2()
2772/// #         .build()
2773/// # );
2774/// # let mut hub = BigQueryConnectionService::new(client, auth);
2775/// // As the method needs a request, you would usually fill it with the desired information
2776/// // into the respective structure. Some of the parts shown here might not be applicable !
2777/// // Values shown here are possibly random and not representative !
2778/// let mut req = SetIamPolicyRequest::default();
2779///
2780/// // You can configure optional parameters by calling the respective setters at will, and
2781/// // execute the final call using `doit()`.
2782/// // Values shown here are possibly random and not representative !
2783/// let result = hub.projects().locations_connections_set_iam_policy(req, "resource")
2784///              .doit().await;
2785/// # }
2786/// ```
2787pub struct ProjectLocationConnectionSetIamPolicyCall<'a, C>
2788where
2789    C: 'a,
2790{
2791    hub: &'a BigQueryConnectionService<C>,
2792    _request: SetIamPolicyRequest,
2793    _resource: String,
2794    _delegate: Option<&'a mut dyn common::Delegate>,
2795    _additional_params: HashMap<String, String>,
2796    _scopes: BTreeSet<String>,
2797}
2798
2799impl<'a, C> common::CallBuilder for ProjectLocationConnectionSetIamPolicyCall<'a, C> {}
2800
2801impl<'a, C> ProjectLocationConnectionSetIamPolicyCall<'a, C>
2802where
2803    C: common::Connector,
2804{
2805    /// Perform the operation you have build so far.
2806    pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
2807        use std::borrow::Cow;
2808        use std::io::{Read, Seek};
2809
2810        use common::{url::Params, ToParts};
2811        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2812
2813        let mut dd = common::DefaultDelegate;
2814        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2815        dlg.begin(common::MethodInfo {
2816            id: "bigqueryconnection.projects.locations.connections.setIamPolicy",
2817            http_method: hyper::Method::POST,
2818        });
2819
2820        for &field in ["alt", "resource"].iter() {
2821            if self._additional_params.contains_key(field) {
2822                dlg.finished(false);
2823                return Err(common::Error::FieldClash(field));
2824            }
2825        }
2826
2827        let mut params = Params::with_capacity(4 + self._additional_params.len());
2828        params.push("resource", self._resource);
2829
2830        params.extend(self._additional_params.iter());
2831
2832        params.push("alt", "json");
2833        let mut url = self.hub._base_url.clone() + "v1beta1/{+resource}:setIamPolicy";
2834        if self._scopes.is_empty() {
2835            self._scopes
2836                .insert(Scope::CloudPlatform.as_ref().to_string());
2837        }
2838
2839        #[allow(clippy::single_element_loop)]
2840        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
2841            url = params.uri_replacement(url, param_name, find_this, true);
2842        }
2843        {
2844            let to_remove = ["resource"];
2845            params.remove_params(&to_remove);
2846        }
2847
2848        let url = params.parse_with_url(&url);
2849
2850        let mut json_mime_type = mime::APPLICATION_JSON;
2851        let mut request_value_reader = {
2852            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
2853            common::remove_json_null_values(&mut value);
2854            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
2855            serde_json::to_writer(&mut dst, &value).unwrap();
2856            dst
2857        };
2858        let request_size = request_value_reader
2859            .seek(std::io::SeekFrom::End(0))
2860            .unwrap();
2861        request_value_reader
2862            .seek(std::io::SeekFrom::Start(0))
2863            .unwrap();
2864
2865        loop {
2866            let token = match self
2867                .hub
2868                .auth
2869                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2870                .await
2871            {
2872                Ok(token) => token,
2873                Err(e) => match dlg.token(e) {
2874                    Ok(token) => token,
2875                    Err(e) => {
2876                        dlg.finished(false);
2877                        return Err(common::Error::MissingToken(e));
2878                    }
2879                },
2880            };
2881            request_value_reader
2882                .seek(std::io::SeekFrom::Start(0))
2883                .unwrap();
2884            let mut req_result = {
2885                let client = &self.hub.client;
2886                dlg.pre_request();
2887                let mut req_builder = hyper::Request::builder()
2888                    .method(hyper::Method::POST)
2889                    .uri(url.as_str())
2890                    .header(USER_AGENT, self.hub._user_agent.clone());
2891
2892                if let Some(token) = token.as_ref() {
2893                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2894                }
2895
2896                let request = req_builder
2897                    .header(CONTENT_TYPE, json_mime_type.to_string())
2898                    .header(CONTENT_LENGTH, request_size as u64)
2899                    .body(common::to_body(
2900                        request_value_reader.get_ref().clone().into(),
2901                    ));
2902
2903                client.request(request.unwrap()).await
2904            };
2905
2906            match req_result {
2907                Err(err) => {
2908                    if let common::Retry::After(d) = dlg.http_error(&err) {
2909                        sleep(d).await;
2910                        continue;
2911                    }
2912                    dlg.finished(false);
2913                    return Err(common::Error::HttpError(err));
2914                }
2915                Ok(res) => {
2916                    let (mut parts, body) = res.into_parts();
2917                    let mut body = common::Body::new(body);
2918                    if !parts.status.is_success() {
2919                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2920                        let error = serde_json::from_str(&common::to_string(&bytes));
2921                        let response = common::to_response(parts, bytes.into());
2922
2923                        if let common::Retry::After(d) =
2924                            dlg.http_failure(&response, error.as_ref().ok())
2925                        {
2926                            sleep(d).await;
2927                            continue;
2928                        }
2929
2930                        dlg.finished(false);
2931
2932                        return Err(match error {
2933                            Ok(value) => common::Error::BadRequest(value),
2934                            _ => common::Error::Failure(response),
2935                        });
2936                    }
2937                    let response = {
2938                        let bytes = common::to_bytes(body).await.unwrap_or_default();
2939                        let encoded = common::to_string(&bytes);
2940                        match serde_json::from_str(&encoded) {
2941                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2942                            Err(error) => {
2943                                dlg.response_json_decode_error(&encoded, &error);
2944                                return Err(common::Error::JsonDecodeError(
2945                                    encoded.to_string(),
2946                                    error,
2947                                ));
2948                            }
2949                        }
2950                    };
2951
2952                    dlg.finished(true);
2953                    return Ok(response);
2954                }
2955            }
2956        }
2957    }
2958
2959    ///
2960    /// Sets the *request* property to the given value.
2961    ///
2962    /// Even though the property as already been set when instantiating this call,
2963    /// we provide this method for API completeness.
2964    pub fn request(
2965        mut self,
2966        new_value: SetIamPolicyRequest,
2967    ) -> ProjectLocationConnectionSetIamPolicyCall<'a, C> {
2968        self._request = new_value;
2969        self
2970    }
2971    /// 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.
2972    ///
2973    /// Sets the *resource* path property to the given value.
2974    ///
2975    /// Even though the property as already been set when instantiating this call,
2976    /// we provide this method for API completeness.
2977    pub fn resource(mut self, new_value: &str) -> ProjectLocationConnectionSetIamPolicyCall<'a, C> {
2978        self._resource = new_value.to_string();
2979        self
2980    }
2981    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2982    /// while executing the actual API request.
2983    ///
2984    /// ````text
2985    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
2986    /// ````
2987    ///
2988    /// Sets the *delegate* property to the given value.
2989    pub fn delegate(
2990        mut self,
2991        new_value: &'a mut dyn common::Delegate,
2992    ) -> ProjectLocationConnectionSetIamPolicyCall<'a, C> {
2993        self._delegate = Some(new_value);
2994        self
2995    }
2996
2997    /// Set any additional parameter of the query string used in the request.
2998    /// It should be used to set parameters which are not yet available through their own
2999    /// setters.
3000    ///
3001    /// Please note that this method must not be used to set any of the known parameters
3002    /// which have their own setter method. If done anyway, the request will fail.
3003    ///
3004    /// # Additional Parameters
3005    ///
3006    /// * *$.xgafv* (query-string) - V1 error format.
3007    /// * *access_token* (query-string) - OAuth access token.
3008    /// * *alt* (query-string) - Data format for response.
3009    /// * *callback* (query-string) - JSONP
3010    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3011    /// * *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.
3012    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3013    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3014    /// * *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.
3015    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3016    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3017    pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationConnectionSetIamPolicyCall<'a, C>
3018    where
3019        T: AsRef<str>,
3020    {
3021        self._additional_params
3022            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3023        self
3024    }
3025
3026    /// Identifies the authorization scope for the method you are building.
3027    ///
3028    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3029    /// [`Scope::CloudPlatform`].
3030    ///
3031    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3032    /// tokens for more than one scope.
3033    ///
3034    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3035    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3036    /// sufficient, a read-write scope will do as well.
3037    pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationConnectionSetIamPolicyCall<'a, C>
3038    where
3039        St: AsRef<str>,
3040    {
3041        self._scopes.insert(String::from(scope.as_ref()));
3042        self
3043    }
3044    /// Identifies the authorization scope(s) for the method you are building.
3045    ///
3046    /// See [`Self::add_scope()`] for details.
3047    pub fn add_scopes<I, St>(
3048        mut self,
3049        scopes: I,
3050    ) -> ProjectLocationConnectionSetIamPolicyCall<'a, C>
3051    where
3052        I: IntoIterator<Item = St>,
3053        St: AsRef<str>,
3054    {
3055        self._scopes
3056            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3057        self
3058    }
3059
3060    /// Removes all scopes, and no default scope will be used either.
3061    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3062    /// for details).
3063    pub fn clear_scopes(mut self) -> ProjectLocationConnectionSetIamPolicyCall<'a, C> {
3064        self._scopes.clear();
3065        self
3066    }
3067}
3068
3069/// Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
3070///
3071/// A builder for the *locations.connections.testIamPermissions* method supported by a *project* resource.
3072/// It is not used directly, but through a [`ProjectMethods`] instance.
3073///
3074/// # Example
3075///
3076/// Instantiate a resource method builder
3077///
3078/// ```test_harness,no_run
3079/// # extern crate hyper;
3080/// # extern crate hyper_rustls;
3081/// # extern crate google_bigqueryconnection1_beta1 as bigqueryconnection1_beta1;
3082/// use bigqueryconnection1_beta1::api::TestIamPermissionsRequest;
3083/// # async fn dox() {
3084/// # use bigqueryconnection1_beta1::{BigQueryConnectionService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3085///
3086/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3087/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3088/// #     .with_native_roots()
3089/// #     .unwrap()
3090/// #     .https_only()
3091/// #     .enable_http2()
3092/// #     .build();
3093///
3094/// # let executor = hyper_util::rt::TokioExecutor::new();
3095/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3096/// #     secret,
3097/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3098/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3099/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3100/// #     ),
3101/// # ).build().await.unwrap();
3102///
3103/// # let client = hyper_util::client::legacy::Client::builder(
3104/// #     hyper_util::rt::TokioExecutor::new()
3105/// # )
3106/// # .build(
3107/// #     hyper_rustls::HttpsConnectorBuilder::new()
3108/// #         .with_native_roots()
3109/// #         .unwrap()
3110/// #         .https_or_http()
3111/// #         .enable_http2()
3112/// #         .build()
3113/// # );
3114/// # let mut hub = BigQueryConnectionService::new(client, auth);
3115/// // As the method needs a request, you would usually fill it with the desired information
3116/// // into the respective structure. Some of the parts shown here might not be applicable !
3117/// // Values shown here are possibly random and not representative !
3118/// let mut req = TestIamPermissionsRequest::default();
3119///
3120/// // You can configure optional parameters by calling the respective setters at will, and
3121/// // execute the final call using `doit()`.
3122/// // Values shown here are possibly random and not representative !
3123/// let result = hub.projects().locations_connections_test_iam_permissions(req, "resource")
3124///              .doit().await;
3125/// # }
3126/// ```
3127pub struct ProjectLocationConnectionTestIamPermissionCall<'a, C>
3128where
3129    C: 'a,
3130{
3131    hub: &'a BigQueryConnectionService<C>,
3132    _request: TestIamPermissionsRequest,
3133    _resource: String,
3134    _delegate: Option<&'a mut dyn common::Delegate>,
3135    _additional_params: HashMap<String, String>,
3136    _scopes: BTreeSet<String>,
3137}
3138
3139impl<'a, C> common::CallBuilder for ProjectLocationConnectionTestIamPermissionCall<'a, C> {}
3140
3141impl<'a, C> ProjectLocationConnectionTestIamPermissionCall<'a, C>
3142where
3143    C: common::Connector,
3144{
3145    /// Perform the operation you have build so far.
3146    pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
3147        use std::borrow::Cow;
3148        use std::io::{Read, Seek};
3149
3150        use common::{url::Params, ToParts};
3151        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3152
3153        let mut dd = common::DefaultDelegate;
3154        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3155        dlg.begin(common::MethodInfo {
3156            id: "bigqueryconnection.projects.locations.connections.testIamPermissions",
3157            http_method: hyper::Method::POST,
3158        });
3159
3160        for &field in ["alt", "resource"].iter() {
3161            if self._additional_params.contains_key(field) {
3162                dlg.finished(false);
3163                return Err(common::Error::FieldClash(field));
3164            }
3165        }
3166
3167        let mut params = Params::with_capacity(4 + self._additional_params.len());
3168        params.push("resource", self._resource);
3169
3170        params.extend(self._additional_params.iter());
3171
3172        params.push("alt", "json");
3173        let mut url = self.hub._base_url.clone() + "v1beta1/{+resource}:testIamPermissions";
3174        if self._scopes.is_empty() {
3175            self._scopes
3176                .insert(Scope::CloudPlatform.as_ref().to_string());
3177        }
3178
3179        #[allow(clippy::single_element_loop)]
3180        for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
3181            url = params.uri_replacement(url, param_name, find_this, true);
3182        }
3183        {
3184            let to_remove = ["resource"];
3185            params.remove_params(&to_remove);
3186        }
3187
3188        let url = params.parse_with_url(&url);
3189
3190        let mut json_mime_type = mime::APPLICATION_JSON;
3191        let mut request_value_reader = {
3192            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3193            common::remove_json_null_values(&mut value);
3194            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3195            serde_json::to_writer(&mut dst, &value).unwrap();
3196            dst
3197        };
3198        let request_size = request_value_reader
3199            .seek(std::io::SeekFrom::End(0))
3200            .unwrap();
3201        request_value_reader
3202            .seek(std::io::SeekFrom::Start(0))
3203            .unwrap();
3204
3205        loop {
3206            let token = match self
3207                .hub
3208                .auth
3209                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3210                .await
3211            {
3212                Ok(token) => token,
3213                Err(e) => match dlg.token(e) {
3214                    Ok(token) => token,
3215                    Err(e) => {
3216                        dlg.finished(false);
3217                        return Err(common::Error::MissingToken(e));
3218                    }
3219                },
3220            };
3221            request_value_reader
3222                .seek(std::io::SeekFrom::Start(0))
3223                .unwrap();
3224            let mut req_result = {
3225                let client = &self.hub.client;
3226                dlg.pre_request();
3227                let mut req_builder = hyper::Request::builder()
3228                    .method(hyper::Method::POST)
3229                    .uri(url.as_str())
3230                    .header(USER_AGENT, self.hub._user_agent.clone());
3231
3232                if let Some(token) = token.as_ref() {
3233                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3234                }
3235
3236                let request = req_builder
3237                    .header(CONTENT_TYPE, json_mime_type.to_string())
3238                    .header(CONTENT_LENGTH, request_size as u64)
3239                    .body(common::to_body(
3240                        request_value_reader.get_ref().clone().into(),
3241                    ));
3242
3243                client.request(request.unwrap()).await
3244            };
3245
3246            match req_result {
3247                Err(err) => {
3248                    if let common::Retry::After(d) = dlg.http_error(&err) {
3249                        sleep(d).await;
3250                        continue;
3251                    }
3252                    dlg.finished(false);
3253                    return Err(common::Error::HttpError(err));
3254                }
3255                Ok(res) => {
3256                    let (mut parts, body) = res.into_parts();
3257                    let mut body = common::Body::new(body);
3258                    if !parts.status.is_success() {
3259                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3260                        let error = serde_json::from_str(&common::to_string(&bytes));
3261                        let response = common::to_response(parts, bytes.into());
3262
3263                        if let common::Retry::After(d) =
3264                            dlg.http_failure(&response, error.as_ref().ok())
3265                        {
3266                            sleep(d).await;
3267                            continue;
3268                        }
3269
3270                        dlg.finished(false);
3271
3272                        return Err(match error {
3273                            Ok(value) => common::Error::BadRequest(value),
3274                            _ => common::Error::Failure(response),
3275                        });
3276                    }
3277                    let response = {
3278                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3279                        let encoded = common::to_string(&bytes);
3280                        match serde_json::from_str(&encoded) {
3281                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3282                            Err(error) => {
3283                                dlg.response_json_decode_error(&encoded, &error);
3284                                return Err(common::Error::JsonDecodeError(
3285                                    encoded.to_string(),
3286                                    error,
3287                                ));
3288                            }
3289                        }
3290                    };
3291
3292                    dlg.finished(true);
3293                    return Ok(response);
3294                }
3295            }
3296        }
3297    }
3298
3299    ///
3300    /// Sets the *request* property to the given value.
3301    ///
3302    /// Even though the property as already been set when instantiating this call,
3303    /// we provide this method for API completeness.
3304    pub fn request(
3305        mut self,
3306        new_value: TestIamPermissionsRequest,
3307    ) -> ProjectLocationConnectionTestIamPermissionCall<'a, C> {
3308        self._request = new_value;
3309        self
3310    }
3311    /// 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.
3312    ///
3313    /// Sets the *resource* path property to the given value.
3314    ///
3315    /// Even though the property as already been set when instantiating this call,
3316    /// we provide this method for API completeness.
3317    pub fn resource(
3318        mut self,
3319        new_value: &str,
3320    ) -> ProjectLocationConnectionTestIamPermissionCall<'a, C> {
3321        self._resource = new_value.to_string();
3322        self
3323    }
3324    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3325    /// while executing the actual API request.
3326    ///
3327    /// ````text
3328    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3329    /// ````
3330    ///
3331    /// Sets the *delegate* property to the given value.
3332    pub fn delegate(
3333        mut self,
3334        new_value: &'a mut dyn common::Delegate,
3335    ) -> ProjectLocationConnectionTestIamPermissionCall<'a, C> {
3336        self._delegate = Some(new_value);
3337        self
3338    }
3339
3340    /// Set any additional parameter of the query string used in the request.
3341    /// It should be used to set parameters which are not yet available through their own
3342    /// setters.
3343    ///
3344    /// Please note that this method must not be used to set any of the known parameters
3345    /// which have their own setter method. If done anyway, the request will fail.
3346    ///
3347    /// # Additional Parameters
3348    ///
3349    /// * *$.xgafv* (query-string) - V1 error format.
3350    /// * *access_token* (query-string) - OAuth access token.
3351    /// * *alt* (query-string) - Data format for response.
3352    /// * *callback* (query-string) - JSONP
3353    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3354    /// * *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.
3355    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3356    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3357    /// * *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.
3358    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3359    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3360    pub fn param<T>(
3361        mut self,
3362        name: T,
3363        value: T,
3364    ) -> ProjectLocationConnectionTestIamPermissionCall<'a, C>
3365    where
3366        T: AsRef<str>,
3367    {
3368        self._additional_params
3369            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3370        self
3371    }
3372
3373    /// Identifies the authorization scope for the method you are building.
3374    ///
3375    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3376    /// [`Scope::CloudPlatform`].
3377    ///
3378    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3379    /// tokens for more than one scope.
3380    ///
3381    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3382    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3383    /// sufficient, a read-write scope will do as well.
3384    pub fn add_scope<St>(
3385        mut self,
3386        scope: St,
3387    ) -> ProjectLocationConnectionTestIamPermissionCall<'a, C>
3388    where
3389        St: AsRef<str>,
3390    {
3391        self._scopes.insert(String::from(scope.as_ref()));
3392        self
3393    }
3394    /// Identifies the authorization scope(s) for the method you are building.
3395    ///
3396    /// See [`Self::add_scope()`] for details.
3397    pub fn add_scopes<I, St>(
3398        mut self,
3399        scopes: I,
3400    ) -> ProjectLocationConnectionTestIamPermissionCall<'a, C>
3401    where
3402        I: IntoIterator<Item = St>,
3403        St: AsRef<str>,
3404    {
3405        self._scopes
3406            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3407        self
3408    }
3409
3410    /// Removes all scopes, and no default scope will be used either.
3411    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3412    /// for details).
3413    pub fn clear_scopes(mut self) -> ProjectLocationConnectionTestIamPermissionCall<'a, C> {
3414        self._scopes.clear();
3415        self
3416    }
3417}
3418
3419/// Sets the credential for the specified connection.
3420///
3421/// A builder for the *locations.connections.updateCredential* method supported by a *project* resource.
3422/// It is not used directly, but through a [`ProjectMethods`] instance.
3423///
3424/// # Example
3425///
3426/// Instantiate a resource method builder
3427///
3428/// ```test_harness,no_run
3429/// # extern crate hyper;
3430/// # extern crate hyper_rustls;
3431/// # extern crate google_bigqueryconnection1_beta1 as bigqueryconnection1_beta1;
3432/// use bigqueryconnection1_beta1::api::ConnectionCredential;
3433/// # async fn dox() {
3434/// # use bigqueryconnection1_beta1::{BigQueryConnectionService, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3435///
3436/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3437/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3438/// #     .with_native_roots()
3439/// #     .unwrap()
3440/// #     .https_only()
3441/// #     .enable_http2()
3442/// #     .build();
3443///
3444/// # let executor = hyper_util::rt::TokioExecutor::new();
3445/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3446/// #     secret,
3447/// #     yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3448/// #     yup_oauth2::client::CustomHyperClientBuilder::from(
3449/// #         hyper_util::client::legacy::Client::builder(executor).build(connector),
3450/// #     ),
3451/// # ).build().await.unwrap();
3452///
3453/// # let client = hyper_util::client::legacy::Client::builder(
3454/// #     hyper_util::rt::TokioExecutor::new()
3455/// # )
3456/// # .build(
3457/// #     hyper_rustls::HttpsConnectorBuilder::new()
3458/// #         .with_native_roots()
3459/// #         .unwrap()
3460/// #         .https_or_http()
3461/// #         .enable_http2()
3462/// #         .build()
3463/// # );
3464/// # let mut hub = BigQueryConnectionService::new(client, auth);
3465/// // As the method needs a request, you would usually fill it with the desired information
3466/// // into the respective structure. Some of the parts shown here might not be applicable !
3467/// // Values shown here are possibly random and not representative !
3468/// let mut req = ConnectionCredential::default();
3469///
3470/// // You can configure optional parameters by calling the respective setters at will, and
3471/// // execute the final call using `doit()`.
3472/// // Values shown here are possibly random and not representative !
3473/// let result = hub.projects().locations_connections_update_credential(req, "name")
3474///              .doit().await;
3475/// # }
3476/// ```
3477pub struct ProjectLocationConnectionUpdateCredentialCall<'a, C>
3478where
3479    C: 'a,
3480{
3481    hub: &'a BigQueryConnectionService<C>,
3482    _request: ConnectionCredential,
3483    _name: String,
3484    _delegate: Option<&'a mut dyn common::Delegate>,
3485    _additional_params: HashMap<String, String>,
3486    _scopes: BTreeSet<String>,
3487}
3488
3489impl<'a, C> common::CallBuilder for ProjectLocationConnectionUpdateCredentialCall<'a, C> {}
3490
3491impl<'a, C> ProjectLocationConnectionUpdateCredentialCall<'a, C>
3492where
3493    C: common::Connector,
3494{
3495    /// Perform the operation you have build so far.
3496    pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
3497        use std::borrow::Cow;
3498        use std::io::{Read, Seek};
3499
3500        use common::{url::Params, ToParts};
3501        use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3502
3503        let mut dd = common::DefaultDelegate;
3504        let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3505        dlg.begin(common::MethodInfo {
3506            id: "bigqueryconnection.projects.locations.connections.updateCredential",
3507            http_method: hyper::Method::PATCH,
3508        });
3509
3510        for &field in ["alt", "name"].iter() {
3511            if self._additional_params.contains_key(field) {
3512                dlg.finished(false);
3513                return Err(common::Error::FieldClash(field));
3514            }
3515        }
3516
3517        let mut params = Params::with_capacity(4 + self._additional_params.len());
3518        params.push("name", self._name);
3519
3520        params.extend(self._additional_params.iter());
3521
3522        params.push("alt", "json");
3523        let mut url = self.hub._base_url.clone() + "v1beta1/{+name}";
3524        if self._scopes.is_empty() {
3525            self._scopes
3526                .insert(Scope::CloudPlatform.as_ref().to_string());
3527        }
3528
3529        #[allow(clippy::single_element_loop)]
3530        for &(find_this, param_name) in [("{+name}", "name")].iter() {
3531            url = params.uri_replacement(url, param_name, find_this, true);
3532        }
3533        {
3534            let to_remove = ["name"];
3535            params.remove_params(&to_remove);
3536        }
3537
3538        let url = params.parse_with_url(&url);
3539
3540        let mut json_mime_type = mime::APPLICATION_JSON;
3541        let mut request_value_reader = {
3542            let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3543            common::remove_json_null_values(&mut value);
3544            let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3545            serde_json::to_writer(&mut dst, &value).unwrap();
3546            dst
3547        };
3548        let request_size = request_value_reader
3549            .seek(std::io::SeekFrom::End(0))
3550            .unwrap();
3551        request_value_reader
3552            .seek(std::io::SeekFrom::Start(0))
3553            .unwrap();
3554
3555        loop {
3556            let token = match self
3557                .hub
3558                .auth
3559                .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3560                .await
3561            {
3562                Ok(token) => token,
3563                Err(e) => match dlg.token(e) {
3564                    Ok(token) => token,
3565                    Err(e) => {
3566                        dlg.finished(false);
3567                        return Err(common::Error::MissingToken(e));
3568                    }
3569                },
3570            };
3571            request_value_reader
3572                .seek(std::io::SeekFrom::Start(0))
3573                .unwrap();
3574            let mut req_result = {
3575                let client = &self.hub.client;
3576                dlg.pre_request();
3577                let mut req_builder = hyper::Request::builder()
3578                    .method(hyper::Method::PATCH)
3579                    .uri(url.as_str())
3580                    .header(USER_AGENT, self.hub._user_agent.clone());
3581
3582                if let Some(token) = token.as_ref() {
3583                    req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3584                }
3585
3586                let request = req_builder
3587                    .header(CONTENT_TYPE, json_mime_type.to_string())
3588                    .header(CONTENT_LENGTH, request_size as u64)
3589                    .body(common::to_body(
3590                        request_value_reader.get_ref().clone().into(),
3591                    ));
3592
3593                client.request(request.unwrap()).await
3594            };
3595
3596            match req_result {
3597                Err(err) => {
3598                    if let common::Retry::After(d) = dlg.http_error(&err) {
3599                        sleep(d).await;
3600                        continue;
3601                    }
3602                    dlg.finished(false);
3603                    return Err(common::Error::HttpError(err));
3604                }
3605                Ok(res) => {
3606                    let (mut parts, body) = res.into_parts();
3607                    let mut body = common::Body::new(body);
3608                    if !parts.status.is_success() {
3609                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3610                        let error = serde_json::from_str(&common::to_string(&bytes));
3611                        let response = common::to_response(parts, bytes.into());
3612
3613                        if let common::Retry::After(d) =
3614                            dlg.http_failure(&response, error.as_ref().ok())
3615                        {
3616                            sleep(d).await;
3617                            continue;
3618                        }
3619
3620                        dlg.finished(false);
3621
3622                        return Err(match error {
3623                            Ok(value) => common::Error::BadRequest(value),
3624                            _ => common::Error::Failure(response),
3625                        });
3626                    }
3627                    let response = {
3628                        let bytes = common::to_bytes(body).await.unwrap_or_default();
3629                        let encoded = common::to_string(&bytes);
3630                        match serde_json::from_str(&encoded) {
3631                            Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3632                            Err(error) => {
3633                                dlg.response_json_decode_error(&encoded, &error);
3634                                return Err(common::Error::JsonDecodeError(
3635                                    encoded.to_string(),
3636                                    error,
3637                                ));
3638                            }
3639                        }
3640                    };
3641
3642                    dlg.finished(true);
3643                    return Ok(response);
3644                }
3645            }
3646        }
3647    }
3648
3649    ///
3650    /// Sets the *request* property to the given value.
3651    ///
3652    /// Even though the property as already been set when instantiating this call,
3653    /// we provide this method for API completeness.
3654    pub fn request(
3655        mut self,
3656        new_value: ConnectionCredential,
3657    ) -> ProjectLocationConnectionUpdateCredentialCall<'a, C> {
3658        self._request = new_value;
3659        self
3660    }
3661    /// Required. Name of the connection, for example: `projects/{project_id}/locations/{location_id}/connections/{connection_id}/credential`
3662    ///
3663    /// Sets the *name* path property to the given value.
3664    ///
3665    /// Even though the property as already been set when instantiating this call,
3666    /// we provide this method for API completeness.
3667    pub fn name(mut self, new_value: &str) -> ProjectLocationConnectionUpdateCredentialCall<'a, C> {
3668        self._name = new_value.to_string();
3669        self
3670    }
3671    /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3672    /// while executing the actual API request.
3673    ///
3674    /// ````text
3675    ///                   It should be used to handle progress information, and to implement a certain level of resilience.
3676    /// ````
3677    ///
3678    /// Sets the *delegate* property to the given value.
3679    pub fn delegate(
3680        mut self,
3681        new_value: &'a mut dyn common::Delegate,
3682    ) -> ProjectLocationConnectionUpdateCredentialCall<'a, C> {
3683        self._delegate = Some(new_value);
3684        self
3685    }
3686
3687    /// Set any additional parameter of the query string used in the request.
3688    /// It should be used to set parameters which are not yet available through their own
3689    /// setters.
3690    ///
3691    /// Please note that this method must not be used to set any of the known parameters
3692    /// which have their own setter method. If done anyway, the request will fail.
3693    ///
3694    /// # Additional Parameters
3695    ///
3696    /// * *$.xgafv* (query-string) - V1 error format.
3697    /// * *access_token* (query-string) - OAuth access token.
3698    /// * *alt* (query-string) - Data format for response.
3699    /// * *callback* (query-string) - JSONP
3700    /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3701    /// * *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.
3702    /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3703    /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3704    /// * *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.
3705    /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3706    /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3707    pub fn param<T>(
3708        mut self,
3709        name: T,
3710        value: T,
3711    ) -> ProjectLocationConnectionUpdateCredentialCall<'a, C>
3712    where
3713        T: AsRef<str>,
3714    {
3715        self._additional_params
3716            .insert(name.as_ref().to_string(), value.as_ref().to_string());
3717        self
3718    }
3719
3720    /// Identifies the authorization scope for the method you are building.
3721    ///
3722    /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3723    /// [`Scope::CloudPlatform`].
3724    ///
3725    /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3726    /// tokens for more than one scope.
3727    ///
3728    /// Usually there is more than one suitable scope to authorize an operation, some of which may
3729    /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3730    /// sufficient, a read-write scope will do as well.
3731    pub fn add_scope<St>(
3732        mut self,
3733        scope: St,
3734    ) -> ProjectLocationConnectionUpdateCredentialCall<'a, C>
3735    where
3736        St: AsRef<str>,
3737    {
3738        self._scopes.insert(String::from(scope.as_ref()));
3739        self
3740    }
3741    /// Identifies the authorization scope(s) for the method you are building.
3742    ///
3743    /// See [`Self::add_scope()`] for details.
3744    pub fn add_scopes<I, St>(
3745        mut self,
3746        scopes: I,
3747    ) -> ProjectLocationConnectionUpdateCredentialCall<'a, C>
3748    where
3749        I: IntoIterator<Item = St>,
3750        St: AsRef<str>,
3751    {
3752        self._scopes
3753            .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3754        self
3755    }
3756
3757    /// Removes all scopes, and no default scope will be used either.
3758    /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3759    /// for details).
3760    pub fn clear_scopes(mut self) -> ProjectLocationConnectionUpdateCredentialCall<'a, C> {
3761        self._scopes.clear();
3762        self
3763    }
3764}