google_sourcerepo1/
api.rs

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