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