google_cloudbuild1/api.rs
1#![allow(clippy::ptr_arg)]
2
3use std::collections::{BTreeSet, HashMap};
4
5use tokio::time::sleep;
6
7// ##############
8// UTILITIES ###
9// ############
10
11/// Identifies the an OAuth2 authorization scope.
12/// A scope is needed when requesting an
13/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
14#[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)]
15pub enum Scope {
16 /// See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
17 CloudPlatform,
18}
19
20impl AsRef<str> for Scope {
21 fn as_ref(&self) -> &str {
22 match *self {
23 Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
24 }
25 }
26}
27
28#[allow(clippy::derivable_impls)]
29impl Default for Scope {
30 fn default() -> Scope {
31 Scope::CloudPlatform
32 }
33}
34
35// ########
36// HUB ###
37// ######
38
39/// Central instance to access all CloudBuild related resource activities
40///
41/// # Examples
42///
43/// Instantiate a new hub
44///
45/// ```test_harness,no_run
46/// extern crate hyper;
47/// extern crate hyper_rustls;
48/// extern crate google_cloudbuild1 as cloudbuild1;
49/// use cloudbuild1::api::GitHubEnterpriseConfig;
50/// use cloudbuild1::{Result, Error};
51/// # async fn dox() {
52/// use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
53///
54/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
55/// // `client_secret`, among other things.
56/// let secret: yup_oauth2::ApplicationSecret = Default::default();
57/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
58/// // unless you replace `None` with the desired Flow.
59/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
60/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
61/// // retrieve them from storage.
62/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
63/// secret,
64/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
65/// ).build().await.unwrap();
66///
67/// let client = hyper_util::client::legacy::Client::builder(
68/// hyper_util::rt::TokioExecutor::new()
69/// )
70/// .build(
71/// hyper_rustls::HttpsConnectorBuilder::new()
72/// .with_native_roots()
73/// .unwrap()
74/// .https_or_http()
75/// .enable_http1()
76/// .build()
77/// );
78/// let mut hub = CloudBuild::new(client, auth);
79/// // As the method needs a request, you would usually fill it with the desired information
80/// // into the respective structure. Some of the parts shown here might not be applicable !
81/// // Values shown here are possibly random and not representative !
82/// let mut req = GitHubEnterpriseConfig::default();
83///
84/// // You can configure optional parameters by calling the respective setters at will, and
85/// // execute the final call using `doit()`.
86/// // Values shown here are possibly random and not representative !
87/// let result = hub.projects().github_enterprise_configs_create(req, "parent")
88/// .project_id("sed")
89/// .ghe_config_id("amet.")
90/// .doit().await;
91///
92/// match result {
93/// Err(e) => match e {
94/// // The Error enum provides details about what exactly happened.
95/// // You can also just use its `Debug`, `Display` or `Error` traits
96/// Error::HttpError(_)
97/// |Error::Io(_)
98/// |Error::MissingAPIKey
99/// |Error::MissingToken(_)
100/// |Error::Cancelled
101/// |Error::UploadSizeLimitExceeded(_, _)
102/// |Error::Failure(_)
103/// |Error::BadRequest(_)
104/// |Error::FieldClash(_)
105/// |Error::JsonDecodeError(_, _) => println!("{}", e),
106/// },
107/// Ok(res) => println!("Success: {:?}", res),
108/// }
109/// # }
110/// ```
111#[derive(Clone)]
112pub struct CloudBuild<C> {
113 pub client: common::Client<C>,
114 pub auth: Box<dyn common::GetToken>,
115 _user_agent: String,
116 _base_url: String,
117 _root_url: String,
118}
119
120impl<C> common::Hub for CloudBuild<C> {}
121
122impl<'a, C> CloudBuild<C> {
123 pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> CloudBuild<C> {
124 CloudBuild {
125 client,
126 auth: Box::new(auth),
127 _user_agent: "google-api-rust-client/6.0.0".to_string(),
128 _base_url: "https://cloudbuild.googleapis.com/".to_string(),
129 _root_url: "https://cloudbuild.googleapis.com/".to_string(),
130 }
131 }
132
133 pub fn github_dot_com_webhook(&'a self) -> GithubDotComWebhookMethods<'a, C> {
134 GithubDotComWebhookMethods { hub: self }
135 }
136 pub fn locations(&'a self) -> LocationMethods<'a, C> {
137 LocationMethods { hub: self }
138 }
139 pub fn methods(&'a self) -> MethodMethods<'a, C> {
140 MethodMethods { hub: self }
141 }
142 pub fn operations(&'a self) -> OperationMethods<'a, C> {
143 OperationMethods { hub: self }
144 }
145 pub fn projects(&'a self) -> ProjectMethods<'a, C> {
146 ProjectMethods { hub: self }
147 }
148
149 /// Set the user-agent header field to use in all requests to the server.
150 /// It defaults to `google-api-rust-client/6.0.0`.
151 ///
152 /// Returns the previously set user-agent.
153 pub fn user_agent(&mut self, agent_name: String) -> String {
154 std::mem::replace(&mut self._user_agent, agent_name)
155 }
156
157 /// Set the base url to use in all requests to the server.
158 /// It defaults to `https://cloudbuild.googleapis.com/`.
159 ///
160 /// Returns the previously set base url.
161 pub fn base_url(&mut self, new_base_url: String) -> String {
162 std::mem::replace(&mut self._base_url, new_base_url)
163 }
164
165 /// Set the root url to use in all requests to the server.
166 /// It defaults to `https://cloudbuild.googleapis.com/`.
167 ///
168 /// Returns the previously set root url.
169 pub fn root_url(&mut self, new_root_url: String) -> String {
170 std::mem::replace(&mut self._root_url, new_root_url)
171 }
172}
173
174// ############
175// SCHEMAS ###
176// ##########
177/// ApprovalConfig describes configuration for manual approval of a build.
178///
179/// This type is not used in any activity, and only used as *part* of another schema.
180///
181#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
182#[serde_with::serde_as]
183#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
184pub struct ApprovalConfig {
185 /// Whether or not approval is needed. If this is set on a build, it will become pending when created, and will need to be explicitly approved to start.
186 #[serde(rename = "approvalRequired")]
187 pub approval_required: Option<bool>,
188}
189
190impl common::Part for ApprovalConfig {}
191
192/// ApprovalResult describes the decision and associated metadata of a manual approval of a build.
193///
194/// This type is not used in any activity, and only used as *part* of another schema.
195///
196#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
197#[serde_with::serde_as]
198#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
199pub struct ApprovalResult {
200 /// Output only. The time when the approval decision was made.
201 #[serde(rename = "approvalTime")]
202 pub approval_time: Option<chrono::DateTime<chrono::offset::Utc>>,
203 /// Output only. Email of the user that called the ApproveBuild API to approve or reject a build at the time that the API was called.
204 #[serde(rename = "approverAccount")]
205 pub approver_account: Option<String>,
206 /// Optional. An optional comment for this manual approval result.
207 pub comment: Option<String>,
208 /// Required. The decision of this manual approval.
209 pub decision: Option<String>,
210 /// Optional. An optional URL tied to this manual approval result. This field is essentially the same as comment, except that it will be rendered by the UI differently. An example use case is a link to an external job that approved this Build.
211 pub url: Option<String>,
212}
213
214impl common::Part for ApprovalResult {}
215
216/// Request to approve or reject a pending build.
217///
218/// # Activities
219///
220/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
221/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
222///
223/// * [builds approve projects](ProjectBuildApproveCall) (request)
224/// * [locations builds approve projects](ProjectLocationBuildApproveCall) (request)
225#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
226#[serde_with::serde_as]
227#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
228pub struct ApproveBuildRequest {
229 /// Approval decision and metadata.
230 #[serde(rename = "approvalResult")]
231 pub approval_result: Option<ApprovalResult>,
232}
233
234impl common::RequestValue for ApproveBuildRequest {}
235
236/// Files in the workspace to upload to Cloud Storage upon successful completion of all build steps.
237///
238/// This type is not used in any activity, and only used as *part* of another schema.
239///
240#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
241#[serde_with::serde_as]
242#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
243pub struct ArtifactObjects {
244 /// Cloud Storage bucket and optional object path, in the form "gs://bucket/path/to/somewhere/". (see [Bucket Name Requirements](https://cloud.google.com/storage/docs/bucket-naming#requirements)). Files in the workspace matching any path pattern will be uploaded to Cloud Storage with this location as a prefix.
245 pub location: Option<String>,
246 /// Path globs used to match files in the build's workspace.
247 pub paths: Option<Vec<String>>,
248 /// Output only. Stores timing information for pushing all artifact objects.
249 pub timing: Option<TimeSpan>,
250}
251
252impl common::Part for ArtifactObjects {}
253
254/// Artifacts produced by a build that should be uploaded upon successful completion of all build steps.
255///
256/// This type is not used in any activity, and only used as *part* of another schema.
257///
258#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
259#[serde_with::serde_as]
260#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
261pub struct Artifacts {
262 /// A list of images to be pushed upon the successful completion of all build steps. The images will be pushed using the builder service account's credentials. The digests of the pushed images will be stored in the Build resource's results field. If any of the images fail to be pushed, the build is marked FAILURE.
263 pub images: Option<Vec<String>>,
264 /// A list of Maven artifacts to be uploaded to Artifact Registry upon successful completion of all build steps. Artifacts in the workspace matching specified paths globs will be uploaded to the specified Artifact Registry repository using the builder service account's credentials. If any artifacts fail to be pushed, the build is marked FAILURE.
265 #[serde(rename = "mavenArtifacts")]
266 pub maven_artifacts: Option<Vec<MavenArtifact>>,
267 /// A list of npm packages to be uploaded to Artifact Registry upon successful completion of all build steps. Npm packages in the specified paths will be uploaded to the specified Artifact Registry repository using the builder service account's credentials. If any packages fail to be pushed, the build is marked FAILURE.
268 #[serde(rename = "npmPackages")]
269 pub npm_packages: Option<Vec<NpmPackage>>,
270 /// A list of objects to be uploaded to Cloud Storage upon successful completion of all build steps. Files in the workspace matching specified paths globs will be uploaded to the specified Cloud Storage location using the builder service account's credentials. The location and generation of the uploaded objects will be stored in the Build resource's results field. If any objects fail to be pushed, the build is marked FAILURE.
271 pub objects: Option<ArtifactObjects>,
272 /// A list of Python packages to be uploaded to Artifact Registry upon successful completion of all build steps. The build service account credentials will be used to perform the upload. If any objects fail to be pushed, the build is marked FAILURE.
273 #[serde(rename = "pythonPackages")]
274 pub python_packages: Option<Vec<PythonPackage>>,
275}
276
277impl common::Part for Artifacts {}
278
279/// RPC request object accepted by BatchCreateBitbucketServerConnectedRepositories RPC method.
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/// * [locations bitbucket server configs connected repositories batch create projects](ProjectLocationBitbucketServerConfigConnectedRepositoryBatchCreateCall) (request)
287#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
288#[serde_with::serde_as]
289#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
290pub struct BatchCreateBitbucketServerConnectedRepositoriesRequest {
291 /// Required. Requests to connect Bitbucket Server repositories.
292 pub requests: Option<Vec<CreateBitbucketServerConnectedRepositoryRequest>>,
293}
294
295impl common::RequestValue for BatchCreateBitbucketServerConnectedRepositoriesRequest {}
296
297/// RPC request object accepted by BatchCreateGitLabConnectedRepositories RPC method.
298///
299/// # Activities
300///
301/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
302/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
303///
304/// * [locations git lab configs connected repositories batch create projects](ProjectLocationGitLabConfigConnectedRepositoryBatchCreateCall) (request)
305#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
306#[serde_with::serde_as]
307#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
308pub struct BatchCreateGitLabConnectedRepositoriesRequest {
309 /// Required. Requests to connect GitLab repositories.
310 pub requests: Option<Vec<CreateGitLabConnectedRepositoryRequest>>,
311}
312
313impl common::RequestValue for BatchCreateGitLabConnectedRepositoriesRequest {}
314
315/// BitbucketServerConfig represents the configuration for a Bitbucket Server.
316///
317/// # Activities
318///
319/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
320/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
321///
322/// * [locations bitbucket server configs create projects](ProjectLocationBitbucketServerConfigCreateCall) (request)
323/// * [locations bitbucket server configs get projects](ProjectLocationBitbucketServerConfigGetCall) (response)
324/// * [locations bitbucket server configs patch projects](ProjectLocationBitbucketServerConfigPatchCall) (request)
325#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
326#[serde_with::serde_as]
327#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
328pub struct BitbucketServerConfig {
329 /// Required. Immutable. API Key that will be attached to webhook. Once this field has been set, it cannot be changed. If you need to change it, please create another BitbucketServerConfig.
330 #[serde(rename = "apiKey")]
331 pub api_key: Option<String>,
332 /// Output only. Connected Bitbucket Server repositories for this config.
333 #[serde(rename = "connectedRepositories")]
334 pub connected_repositories: Option<Vec<BitbucketServerRepositoryId>>,
335 /// Time when the config was created.
336 #[serde(rename = "createTime")]
337 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
338 /// Required. Immutable. The URI of the Bitbucket Server host. Once this field has been set, it cannot be changed. If you need to change it, please create another BitbucketServerConfig.
339 #[serde(rename = "hostUri")]
340 pub host_uri: Option<String>,
341 /// The resource name for the config.
342 pub name: Option<String>,
343 /// Optional. The network to be used when reaching out to the Bitbucket Server instance. The VPC network must be enabled for private service connection. This should be set if the Bitbucket Server instance is hosted on-premises and not reachable by public internet. If this field is left empty, no network peering will occur and calls to the Bitbucket Server instance will be made over the public internet. Must be in the format `projects/{project}/global/networks/{network}`, where {project} is a project number or id and {network} is the name of a VPC network in the project.
344 #[serde(rename = "peeredNetwork")]
345 pub peered_network: Option<String>,
346 /// Immutable. IP range within the peered network. This is specified in CIDR notation with a slash and the subnet prefix size. You can optionally specify an IP address before the subnet prefix value. e.g. `192.168.0.0/29` would specify an IP range starting at 192.168.0.0 with a 29 bit prefix size. `/16` would specify a prefix size of 16 bits, with an automatically determined IP within the peered VPC. If unspecified, a value of `/24` will be used. The field only has an effect if peered_network is set.
347 #[serde(rename = "peeredNetworkIpRange")]
348 pub peered_network_ip_range: Option<String>,
349 /// Required. Secret Manager secrets needed by the config.
350 pub secrets: Option<BitbucketServerSecrets>,
351 /// Optional. SSL certificate to use for requests to Bitbucket Server. The format should be PEM format but the extension can be one of .pem, .cer, or .crt.
352 #[serde(rename = "sslCa")]
353 pub ssl_ca: Option<String>,
354 /// Username of the account Cloud Build will use on Bitbucket Server.
355 pub username: Option<String>,
356 /// Output only. UUID included in webhook requests. The UUID is used to look up the corresponding config.
357 #[serde(rename = "webhookKey")]
358 pub webhook_key: Option<String>,
359}
360
361impl common::RequestValue for BitbucketServerConfig {}
362impl common::ResponseResult for BitbucketServerConfig {}
363
364/// / BitbucketServerConnectedRepository represents a connected Bitbucket Server / repository.
365///
366/// This type is not used in any activity, and only used as *part* of another schema.
367///
368#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
369#[serde_with::serde_as]
370#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
371pub struct BitbucketServerConnectedRepository {
372 /// The name of the `BitbucketServerConfig` that added connected repository. Format: `projects/{project}/locations/{location}/bitbucketServerConfigs/{config}`
373 pub parent: Option<String>,
374 /// The Bitbucket Server repositories to connect.
375 pub repo: Option<BitbucketServerRepositoryId>,
376 /// Output only. The status of the repo connection request.
377 pub status: Option<Status>,
378}
379
380impl common::Part for BitbucketServerConnectedRepository {}
381
382/// BitbucketServerRepository represents a repository hosted on a Bitbucket Server.
383///
384/// This type is not used in any activity, and only used as *part* of another schema.
385///
386#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
387#[serde_with::serde_as]
388#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
389pub struct BitbucketServerRepository {
390 /// Link to the browse repo page on the Bitbucket Server instance.
391 #[serde(rename = "browseUri")]
392 pub browse_uri: Option<String>,
393 /// Description of the repository.
394 pub description: Option<String>,
395 /// Display name of the repository.
396 #[serde(rename = "displayName")]
397 pub display_name: Option<String>,
398 /// The resource name of the repository.
399 pub name: Option<String>,
400 /// Identifier for a repository hosted on a Bitbucket Server.
401 #[serde(rename = "repoId")]
402 pub repo_id: Option<BitbucketServerRepositoryId>,
403}
404
405impl common::Part for BitbucketServerRepository {}
406
407/// BitbucketServerRepositoryId identifies a specific repository hosted on a Bitbucket Server.
408///
409/// This type is not used in any activity, and only used as *part* of another schema.
410///
411#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
412#[serde_with::serde_as]
413#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
414pub struct BitbucketServerRepositoryId {
415 /// Required. Identifier for the project storing the repository.
416 #[serde(rename = "projectKey")]
417 pub project_key: Option<String>,
418 /// Required. Identifier for the repository.
419 #[serde(rename = "repoSlug")]
420 pub repo_slug: Option<String>,
421 /// Output only. The ID of the webhook that was created for receiving events from this repo. We only create and manage a single webhook for each repo.
422 #[serde(rename = "webhookId")]
423 pub webhook_id: Option<i32>,
424}
425
426impl common::Part for BitbucketServerRepositoryId {}
427
428/// BitbucketServerSecrets represents the secrets in Secret Manager for a Bitbucket Server.
429///
430/// This type is not used in any activity, and only used as *part* of another schema.
431///
432#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
433#[serde_with::serde_as]
434#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
435pub struct BitbucketServerSecrets {
436 /// Required. The resource name for the admin access token's secret version.
437 #[serde(rename = "adminAccessTokenVersionName")]
438 pub admin_access_token_version_name: Option<String>,
439 /// Required. The resource name for the read access token's secret version.
440 #[serde(rename = "readAccessTokenVersionName")]
441 pub read_access_token_version_name: Option<String>,
442 /// Required. Immutable. The resource name for the webhook secret's secret version. Once this field has been set, it cannot be changed. If you need to change it, please create another BitbucketServerConfig.
443 #[serde(rename = "webhookSecretVersionName")]
444 pub webhook_secret_version_name: Option<String>,
445}
446
447impl common::Part for BitbucketServerSecrets {}
448
449/// BitbucketServerTriggerConfig describes the configuration of a trigger that creates a build whenever a Bitbucket Server event is received.
450///
451/// This type is not used in any activity, and only used as *part* of another schema.
452///
453#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
454#[serde_with::serde_as]
455#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
456pub struct BitbucketServerTriggerConfig {
457 /// Output only. The BitbucketServerConfig specified in the bitbucket_server_config_resource field.
458 #[serde(rename = "bitbucketServerConfig")]
459 pub bitbucket_server_config: Option<BitbucketServerConfig>,
460 /// Required. The Bitbucket server config resource that this trigger config maps to.
461 #[serde(rename = "bitbucketServerConfigResource")]
462 pub bitbucket_server_config_resource: Option<String>,
463 /// Required. Key of the project that the repo is in. For example: The key for https://mybitbucket.server/projects/TEST/repos/test-repo is "TEST".
464 #[serde(rename = "projectKey")]
465 pub project_key: Option<String>,
466 /// Filter to match changes in pull requests.
467 #[serde(rename = "pullRequest")]
468 pub pull_request: Option<PullRequestFilter>,
469 /// Filter to match changes in refs like branches, tags.
470 pub push: Option<PushFilter>,
471 /// Required. Slug of the repository. A repository slug is a URL-friendly version of a repository name, automatically generated by Bitbucket for use in the URL. For example, if the repository name is 'test repo', in the URL it would become 'test-repo' as in https://mybitbucket.server/projects/TEST/repos/test-repo.
472 #[serde(rename = "repoSlug")]
473 pub repo_slug: Option<String>,
474}
475
476impl common::Part for BitbucketServerTriggerConfig {}
477
478/// A build resource in the Cloud Build API. At a high level, a `Build` describes where to find source code, how to build it (for example, the builder image to run on the source), and where to store the built artifacts. Fields can include the following variables, which will be expanded when the build is created: - $PROJECT_ID: the project ID of the build. - $PROJECT_NUMBER: the project number of the build. - $LOCATION: the location/region of the build. - $BUILD_ID: the autogenerated ID of the build. - $REPO_NAME: the source repository name specified by RepoSource. - $BRANCH_NAME: the branch name specified by RepoSource. - $TAG_NAME: the tag name specified by RepoSource. - $REVISION_ID or $COMMIT_SHA: the commit SHA specified by RepoSource or resolved from the specified branch or tag. - $SHORT_SHA: first 7 characters of $REVISION_ID or $COMMIT_SHA.
479///
480/// # Activities
481///
482/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
483/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
484///
485/// * [builds cancel projects](ProjectBuildCancelCall) (response)
486/// * [builds create projects](ProjectBuildCreateCall) (request)
487/// * [builds get projects](ProjectBuildGetCall) (response)
488/// * [locations builds cancel projects](ProjectLocationBuildCancelCall) (response)
489/// * [locations builds create projects](ProjectLocationBuildCreateCall) (request)
490/// * [locations builds get projects](ProjectLocationBuildGetCall) (response)
491#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
492#[serde_with::serde_as]
493#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
494pub struct Build {
495 /// Output only. Describes this build's approval configuration, status, and result.
496 pub approval: Option<BuildApproval>,
497 /// Artifacts produced by the build that should be uploaded upon successful completion of all build steps.
498 pub artifacts: Option<Artifacts>,
499 /// Secrets and secret environment variables.
500 #[serde(rename = "availableSecrets")]
501 pub available_secrets: Option<Secrets>,
502 /// Output only. The ID of the `BuildTrigger` that triggered this build, if it was triggered automatically.
503 #[serde(rename = "buildTriggerId")]
504 pub build_trigger_id: Option<String>,
505 /// Output only. Time at which the request to create the build was received.
506 #[serde(rename = "createTime")]
507 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
508 /// Output only. Contains information about the build when status=FAILURE.
509 #[serde(rename = "failureInfo")]
510 pub failure_info: Option<FailureInfo>,
511 /// Output only. Time at which execution of the build was finished. The difference between finish_time and start_time is the duration of the build's execution.
512 #[serde(rename = "finishTime")]
513 pub finish_time: Option<chrono::DateTime<chrono::offset::Utc>>,
514 /// Optional. Configuration for git operations.
515 #[serde(rename = "gitConfig")]
516 pub git_config: Option<GitConfig>,
517 /// Output only. Unique identifier of the build.
518 pub id: Option<String>,
519 /// A list of images to be pushed upon the successful completion of all build steps. The images are pushed using the builder service account's credentials. The digests of the pushed images will be stored in the `Build` resource's results field. If any of the images fail to be pushed, the build status is marked `FAILURE`.
520 pub images: Option<Vec<String>>,
521 /// Output only. URL to logs for this build in Google Cloud Console.
522 #[serde(rename = "logUrl")]
523 pub log_url: Option<String>,
524 /// Cloud Storage bucket where logs should be written (see [Bucket Name Requirements](https://cloud.google.com/storage/docs/bucket-naming#requirements)). Logs file names will be of the format `${logs_bucket}/log-${build_id}.txt`.
525 #[serde(rename = "logsBucket")]
526 pub logs_bucket: Option<String>,
527 /// Output only. The 'Build' name with format: `projects/{project}/locations/{location}/builds/{build}`, where {build} is a unique identifier generated by the service.
528 pub name: Option<String>,
529 /// Special options for this build.
530 pub options: Option<BuildOptions>,
531 /// Output only. ID of the project.
532 #[serde(rename = "projectId")]
533 pub project_id: Option<String>,
534 /// TTL in queue for this build. If provided and the build is enqueued longer than this value, the build will expire and the build status will be `EXPIRED`. The TTL starts ticking from create_time.
535 #[serde(rename = "queueTtl")]
536 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
537 pub queue_ttl: Option<chrono::Duration>,
538 /// Output only. Results of the build.
539 pub results: Option<Results>,
540 /// Secrets to decrypt using Cloud Key Management Service. Note: Secret Manager is the recommended technique for managing sensitive data with Cloud Build. Use `available_secrets` to configure builds to access secrets from Secret Manager. For instructions, see: https://cloud.google.com/cloud-build/docs/securing-builds/use-secrets
541 pub secrets: Option<Vec<Secret>>,
542 /// IAM service account whose credentials will be used at build runtime. Must be of the format `projects/{PROJECT_ID}/serviceAccounts/{ACCOUNT}`. ACCOUNT can be email address or uniqueId of the service account.
543 #[serde(rename = "serviceAccount")]
544 pub service_account: Option<String>,
545 /// Optional. The location of the source files to build.
546 pub source: Option<Source>,
547 /// Output only. A permanent fixed identifier for source.
548 #[serde(rename = "sourceProvenance")]
549 pub source_provenance: Option<SourceProvenance>,
550 /// Output only. Time at which execution of the build was started.
551 #[serde(rename = "startTime")]
552 pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
553 /// Output only. Status of the build.
554 pub status: Option<String>,
555 /// Output only. Customer-readable message about the current status.
556 #[serde(rename = "statusDetail")]
557 pub status_detail: Option<String>,
558 /// Required. The operations to be performed on the workspace.
559 pub steps: Option<Vec<BuildStep>>,
560 /// Substitutions data for `Build` resource.
561 pub substitutions: Option<HashMap<String, String>>,
562 /// Tags for annotation of a `Build`. These are not docker tags.
563 pub tags: Option<Vec<String>>,
564 /// Amount of time that this build should be allowed to run, to second granularity. If this amount of time elapses, work on the build will cease and the build status will be `TIMEOUT`. `timeout` starts ticking from `startTime`. Default time is 60 minutes.
565 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
566 pub timeout: Option<chrono::Duration>,
567 /// Output only. Stores timing information for phases of the build. Valid keys are: * BUILD: time to execute all build steps. * PUSH: time to push all artifacts including docker images and non docker artifacts. * FETCHSOURCE: time to fetch source. * SETUPBUILD: time to set up build. If the build does not specify source or images, these keys will not be included.
568 pub timing: Option<HashMap<String, TimeSpan>>,
569 /// Output only. Non-fatal problems encountered during the execution of the build.
570 pub warnings: Option<Vec<Warning>>,
571}
572
573impl common::RequestValue for Build {}
574impl common::ResponseResult for Build {}
575
576/// BuildApproval describes a build's approval configuration, state, and result.
577///
578/// This type is not used in any activity, and only used as *part* of another schema.
579///
580#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
581#[serde_with::serde_as]
582#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
583pub struct BuildApproval {
584 /// Output only. Configuration for manual approval of this build.
585 pub config: Option<ApprovalConfig>,
586 /// Output only. Result of manual approval for this Build.
587 pub result: Option<ApprovalResult>,
588 /// Output only. The state of this build's approval.
589 pub state: Option<String>,
590}
591
592impl common::Part for BuildApproval {}
593
594/// Optional arguments to enable specific features of builds.
595///
596/// This type is not used in any activity, and only used as *part* of another schema.
597///
598#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
599#[serde_with::serde_as]
600#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
601pub struct BuildOptions {
602 /// Option to include built-in and custom substitutions as env variables for all build steps.
603 #[serde(rename = "automapSubstitutions")]
604 pub automap_substitutions: Option<bool>,
605 /// Optional. Option to specify how default logs buckets are setup.
606 #[serde(rename = "defaultLogsBucketBehavior")]
607 pub default_logs_bucket_behavior: Option<String>,
608 /// Requested disk size for the VM that runs the build. Note that this is *NOT* "disk free"; some of the space will be used by the operating system and build utilities. Also note that this is the minimum disk size that will be allocated for the build -- the build may run with a larger disk than requested. At present, the maximum disk size is 4000GB; builds that request more than the maximum are rejected with an error.
609 #[serde(rename = "diskSizeGb")]
610 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
611 pub disk_size_gb: Option<i64>,
612 /// Option to specify whether or not to apply bash style string operations to the substitutions. NOTE: this is always enabled for triggered builds and cannot be overridden in the build configuration file.
613 #[serde(rename = "dynamicSubstitutions")]
614 pub dynamic_substitutions: Option<bool>,
615 /// A list of global environment variable definitions that will exist for all build steps in this build. If a variable is defined in both globally and in a build step, the variable will use the build step value. The elements are of the form "KEY=VALUE" for the environment variable "KEY" being given the value "VALUE".
616 pub env: Option<Vec<String>>,
617 /// Option to define build log streaming behavior to Cloud Storage.
618 #[serde(rename = "logStreamingOption")]
619 pub log_streaming_option: Option<String>,
620 /// Option to specify the logging mode, which determines if and where build logs are stored.
621 pub logging: Option<String>,
622 /// Compute Engine machine type on which to run the build.
623 #[serde(rename = "machineType")]
624 pub machine_type: Option<String>,
625 /// Optional. Specification for execution on a `WorkerPool`. See [running builds in a private pool](https://cloud.google.com/build/docs/private-pools/run-builds-in-private-pool) for more information.
626 pub pool: Option<PoolOption>,
627 /// Requested verifiability options.
628 #[serde(rename = "requestedVerifyOption")]
629 pub requested_verify_option: Option<String>,
630 /// A list of global environment variables, which are encrypted using a Cloud Key Management Service crypto key. These values must be specified in the build's `Secret`. These variables will be available to all build steps in this build.
631 #[serde(rename = "secretEnv")]
632 pub secret_env: Option<Vec<String>>,
633 /// Requested hash for SourceProvenance.
634 #[serde(rename = "sourceProvenanceHash")]
635 pub source_provenance_hash: Option<Vec<String>>,
636 /// Option to specify behavior when there is an error in the substitution checks. NOTE: this is always set to ALLOW_LOOSE for triggered builds and cannot be overridden in the build configuration file.
637 #[serde(rename = "substitutionOption")]
638 pub substitution_option: Option<String>,
639 /// Global list of volumes to mount for ALL build steps Each volume is created as an empty volume prior to starting the build process. Upon completion of the build, volumes and their contents are discarded. Global volume names and paths cannot conflict with the volumes defined a build step. Using a global volume in a build with only one step is not valid as it is indicative of a build request with an incorrect configuration.
640 pub volumes: Option<Vec<Volume>>,
641 /// This field deprecated; please use `pool.name` instead.
642 #[serde(rename = "workerPool")]
643 pub worker_pool: Option<String>,
644}
645
646impl common::Part for BuildOptions {}
647
648/// A step in the build pipeline.
649///
650/// This type is not used in any activity, and only used as *part* of another schema.
651///
652#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
653#[serde_with::serde_as]
654#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
655pub struct BuildStep {
656 /// Allow this build step to fail without failing the entire build if and only if the exit code is one of the specified codes. If allow_failure is also specified, this field will take precedence.
657 #[serde(rename = "allowExitCodes")]
658 pub allow_exit_codes: Option<Vec<i32>>,
659 /// Allow this build step to fail without failing the entire build. If false, the entire build will fail if this step fails. Otherwise, the build will succeed, but this step will still have a failure status. Error information will be reported in the failure_detail field.
660 #[serde(rename = "allowFailure")]
661 pub allow_failure: Option<bool>,
662 /// A list of arguments that will be presented to the step when it is started. If the image used to run the step's container has an entrypoint, the `args` are used as arguments to that entrypoint. If the image does not define an entrypoint, the first element in args is used as the entrypoint, and the remainder will be used as arguments.
663 pub args: Option<Vec<String>>,
664 /// Option to include built-in and custom substitutions as env variables for this build step. This option will override the global option in BuildOption.
665 #[serde(rename = "automapSubstitutions")]
666 pub automap_substitutions: Option<bool>,
667 /// Working directory to use when running this step's container. If this value is a relative path, it is relative to the build's working directory. If this value is absolute, it may be outside the build's working directory, in which case the contents of the path may not be persisted across build step executions, unless a `volume` for that path is specified. If the build specifies a `RepoSource` with `dir` and a step with a `dir`, which specifies an absolute path, the `RepoSource` `dir` is ignored for the step's execution.
668 pub dir: Option<String>,
669 /// Entrypoint to be used instead of the build step image's default entrypoint. If unset, the image's default entrypoint is used.
670 pub entrypoint: Option<String>,
671 /// A list of environment variable definitions to be used when running a step. The elements are of the form "KEY=VALUE" for the environment variable "KEY" being given the value "VALUE".
672 pub env: Option<Vec<String>>,
673 /// Output only. Return code from running the step.
674 #[serde(rename = "exitCode")]
675 pub exit_code: Option<i32>,
676 /// Unique identifier for this build step, used in `wait_for` to reference this build step as a dependency.
677 pub id: Option<String>,
678 /// Required. The name of the container image that will run this particular build step. If the image is available in the host's Docker daemon's cache, it will be run directly. If not, the host will attempt to pull the image first, using the builder service account's credentials if necessary. The Docker daemon's cache will already have the latest versions of all of the officially supported build steps ([https://github.com/GoogleCloudPlatform/cloud-builders](https://github.com/GoogleCloudPlatform/cloud-builders)). The Docker daemon will also have cached many of the layers for some popular images, like "ubuntu", "debian", but they will be refreshed at the time you attempt to use them. If you built an image in a previous build step, it will be stored in the host's Docker daemon's cache and is available to use as the name for a later build step.
679 pub name: Option<String>,
680 /// Output only. Stores timing information for pulling this build step's builder image only.
681 #[serde(rename = "pullTiming")]
682 pub pull_timing: Option<TimeSpan>,
683 /// A shell script to be executed in the step. When script is provided, the user cannot specify the entrypoint or args.
684 pub script: Option<String>,
685 /// A list of environment variables which are encrypted using a Cloud Key Management Service crypto key. These values must be specified in the build's `Secret`.
686 #[serde(rename = "secretEnv")]
687 pub secret_env: Option<Vec<String>>,
688 /// Output only. Status of the build step. At this time, build step status is only updated on build completion; step status is not updated in real-time as the build progresses.
689 pub status: Option<String>,
690 /// Time limit for executing this build step. If not defined, the step has no time limit and will be allowed to continue to run until either it completes or the build itself times out.
691 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
692 pub timeout: Option<chrono::Duration>,
693 /// Output only. Stores timing information for executing this build step.
694 pub timing: Option<TimeSpan>,
695 /// List of volumes to mount into the build step. Each volume is created as an empty volume prior to execution of the build step. Upon completion of the build, volumes and their contents are discarded. Using a named volume in only one step is not valid as it is indicative of a build request with an incorrect configuration.
696 pub volumes: Option<Vec<Volume>>,
697 /// The ID(s) of the step(s) that this build step depends on. This build step will not start until all the build steps in `wait_for` have completed successfully. If `wait_for` is empty, this build step will start when all previous build steps in the `Build.Steps` list have completed successfully.
698 #[serde(rename = "waitFor")]
699 pub wait_for: Option<Vec<String>>,
700}
701
702impl common::Part for BuildStep {}
703
704/// Configuration for an automated build in response to source repository changes.
705///
706/// # Activities
707///
708/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
709/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
710///
711/// * [locations triggers create projects](ProjectLocationTriggerCreateCall) (request|response)
712/// * [locations triggers get projects](ProjectLocationTriggerGetCall) (response)
713/// * [locations triggers patch projects](ProjectLocationTriggerPatchCall) (request|response)
714/// * [triggers create projects](ProjectTriggerCreateCall) (request|response)
715/// * [triggers get projects](ProjectTriggerGetCall) (response)
716/// * [triggers patch projects](ProjectTriggerPatchCall) (request|response)
717#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
718#[serde_with::serde_as]
719#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
720pub struct BuildTrigger {
721 /// Configuration for manual approval to start a build invocation of this BuildTrigger.
722 #[serde(rename = "approvalConfig")]
723 pub approval_config: Option<ApprovalConfig>,
724 /// Autodetect build configuration. The following precedence is used (case insensitive): 1. cloudbuild.yaml 2. cloudbuild.yml 3. cloudbuild.json 4. Dockerfile Currently only available for GitHub App Triggers.
725 pub autodetect: Option<bool>,
726 /// BitbucketServerTriggerConfig describes the configuration of a trigger that creates a build whenever a Bitbucket Server event is received.
727 #[serde(rename = "bitbucketServerTriggerConfig")]
728 pub bitbucket_server_trigger_config: Option<BitbucketServerTriggerConfig>,
729 /// Contents of the build template.
730 pub build: Option<Build>,
731 /// Output only. Time when the trigger was created.
732 #[serde(rename = "createTime")]
733 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
734 /// Human-readable description of this trigger.
735 pub description: Option<String>,
736 /// If true, the trigger will never automatically execute a build.
737 pub disabled: Option<bool>,
738 /// EventType allows the user to explicitly set the type of event to which this BuildTrigger should respond. This field will be validated against the rest of the configuration if it is set.
739 #[serde(rename = "eventType")]
740 pub event_type: Option<String>,
741 /// Path, from the source root, to the build configuration file (i.e. cloudbuild.yaml).
742 pub filename: Option<String>,
743 /// A Common Expression Language string.
744 pub filter: Option<String>,
745 /// The file source describing the local or remote Build template.
746 #[serde(rename = "gitFileSource")]
747 pub git_file_source: Option<GitFileSource>,
748 /// GitHubEventsConfig describes the configuration of a trigger that creates a build whenever a GitHub event is received. Mutually exclusive with `trigger_template`.
749 pub github: Option<GitHubEventsConfig>,
750 /// GitLabEnterpriseEventsConfig describes the configuration of a trigger that creates a build whenever a GitLab Enterprise event is received.
751 #[serde(rename = "gitlabEnterpriseEventsConfig")]
752 pub gitlab_enterprise_events_config: Option<GitLabEventsConfig>,
753 /// Output only. Unique identifier of the trigger.
754 pub id: Option<String>,
755 /// ignored_files and included_files are file glob matches using https://golang.org/pkg/path/filepath/#Match extended with support for "**". If ignored_files and changed files are both empty, then they are not used to determine whether or not to trigger a build. If ignored_files is not empty, then we ignore any files that match any of the ignored_file globs. If the change has no files that are outside of the ignored_files globs, then we do not trigger a build.
756 #[serde(rename = "ignoredFiles")]
757 pub ignored_files: Option<Vec<String>>,
758 /// If set to INCLUDE_BUILD_LOGS_WITH_STATUS, log url will be shown on GitHub page when build status is final. Setting this field to INCLUDE_BUILD_LOGS_WITH_STATUS for non GitHub triggers results in INVALID_ARGUMENT error.
759 #[serde(rename = "includeBuildLogs")]
760 pub include_build_logs: Option<String>,
761 /// If any of the files altered in the commit pass the ignored_files filter and included_files is empty, then as far as this filter is concerned, we should trigger the build. If any of the files altered in the commit pass the ignored_files filter and included_files is not empty, then we make sure that at least one of those files matches a included_files glob. If not, then we do not trigger a build.
762 #[serde(rename = "includedFiles")]
763 pub included_files: Option<Vec<String>>,
764 /// User-assigned name of the trigger. Must be unique within the project. Trigger names must meet the following requirements: + They must contain only alphanumeric characters and dashes. + They can be 1-64 characters long. + They must begin and end with an alphanumeric character.
765 pub name: Option<String>,
766 /// PubsubConfig describes the configuration of a trigger that creates a build whenever a Pub/Sub message is published.
767 #[serde(rename = "pubsubConfig")]
768 pub pubsub_config: Option<PubsubConfig>,
769 /// The configuration of a trigger that creates a build whenever an event from Repo API is received.
770 #[serde(rename = "repositoryEventConfig")]
771 pub repository_event_config: Option<RepositoryEventConfig>,
772 /// The `Trigger` name with format: `projects/{project}/locations/{location}/triggers/{trigger}`, where {trigger} is a unique identifier generated by the service.
773 #[serde(rename = "resourceName")]
774 pub resource_name: Option<String>,
775 /// The service account used for all user-controlled operations including UpdateBuildTrigger, RunBuildTrigger, CreateBuild, and CancelBuild. If no service account is set, then the standard Cloud Build service account ([PROJECT_NUM]@system.gserviceaccount.com) will be used instead. Format: `projects/{PROJECT_ID}/serviceAccounts/{ACCOUNT_ID_OR_EMAIL}`
776 #[serde(rename = "serviceAccount")]
777 pub service_account: Option<String>,
778 /// The repo and ref of the repository from which to build. This field is used only for those triggers that do not respond to SCM events. Triggers that respond to such events build source at whatever commit caused the event. This field is currently only used by Webhook, Pub/Sub, Manual, and Cron triggers.
779 #[serde(rename = "sourceToBuild")]
780 pub source_to_build: Option<GitRepoSource>,
781 /// Substitutions for Build resource. The keys must match the following regular expression: `^_[A-Z0-9_]+$`.
782 pub substitutions: Option<HashMap<String, String>>,
783 /// Tags for annotation of a `BuildTrigger`
784 pub tags: Option<Vec<String>>,
785 /// Template describing the types of source changes to trigger a build. Branch and tag names in trigger templates are interpreted as regular expressions. Any branch or tag change that matches that regular expression will trigger a build. Mutually exclusive with `github`.
786 #[serde(rename = "triggerTemplate")]
787 pub trigger_template: Option<RepoSource>,
788 /// WebhookConfig describes the configuration of a trigger that creates a build whenever a webhook is sent to a trigger's webhook URL.
789 #[serde(rename = "webhookConfig")]
790 pub webhook_config: Option<WebhookConfig>,
791}
792
793impl common::RequestValue for BuildTrigger {}
794impl common::ResponseResult for BuildTrigger {}
795
796/// An image built by the pipeline.
797///
798/// This type is not used in any activity, and only used as *part* of another schema.
799///
800#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
801#[serde_with::serde_as]
802#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
803pub struct BuiltImage {
804 /// Docker Registry 2.0 digest.
805 pub digest: Option<String>,
806 /// Name used to push the container image to Google Container Registry, as presented to `docker push`.
807 pub name: Option<String>,
808 /// Output only. Stores timing information for pushing the specified image.
809 #[serde(rename = "pushTiming")]
810 pub push_timing: Option<TimeSpan>,
811}
812
813impl common::Part for BuiltImage {}
814
815/// Request to cancel an ongoing build.
816///
817/// # Activities
818///
819/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
820/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
821///
822/// * [builds cancel projects](ProjectBuildCancelCall) (request)
823/// * [locations builds cancel projects](ProjectLocationBuildCancelCall) (request)
824#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
825#[serde_with::serde_as]
826#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
827pub struct CancelBuildRequest {
828 /// Required. ID of the build.
829 pub id: Option<String>,
830 /// The name of the `Build` to cancel. Format: `projects/{project}/locations/{location}/builds/{build}`
831 pub name: Option<String>,
832 /// Required. ID of the project.
833 #[serde(rename = "projectId")]
834 pub project_id: Option<String>,
835}
836
837impl common::RequestValue for CancelBuildRequest {}
838
839/// The request message for Operations.CancelOperation.
840///
841/// # Activities
842///
843/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
844/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
845///
846/// * [cancel operations](OperationCancelCall) (request)
847/// * [locations operations cancel projects](ProjectLocationOperationCancelCall) (request)
848#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
849#[serde_with::serde_as]
850#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
851pub struct CancelOperationRequest {
852 _never_set: Option<bool>,
853}
854
855impl common::RequestValue for CancelOperationRequest {}
856
857/// Location of the source in a 2nd-gen Google Cloud Build repository resource.
858///
859/// This type is not used in any activity, and only used as *part* of another schema.
860///
861#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
862#[serde_with::serde_as]
863#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
864pub struct ConnectedRepository {
865 /// Optional. Directory, relative to the source root, in which to run the build.
866 pub dir: Option<String>,
867 /// Required. Name of the Google Cloud Build repository, formatted as `projects/*/locations/*/connections/*/repositories/*`.
868 pub repository: Option<String>,
869 /// Required. The revision to fetch from the Git repository such as a branch, a tag, a commit SHA, or any Git ref.
870 pub revision: Option<String>,
871}
872
873impl common::Part for ConnectedRepository {}
874
875/// Request to connect a repository from a connected Bitbucket Server host.
876///
877/// This type is not used in any activity, and only used as *part* of another schema.
878///
879#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
880#[serde_with::serde_as]
881#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
882pub struct CreateBitbucketServerConnectedRepositoryRequest {
883 /// Required. The Bitbucket Server repository to connect.
884 #[serde(rename = "bitbucketServerConnectedRepository")]
885 pub bitbucket_server_connected_repository: Option<BitbucketServerConnectedRepository>,
886 /// Required. The name of the `BitbucketServerConfig` that added connected repository. Format: `projects/{project}/locations/{location}/bitbucketServerConfigs/{config}`
887 pub parent: Option<String>,
888}
889
890impl common::Part for CreateBitbucketServerConnectedRepositoryRequest {}
891
892/// Request to connect a repository from a connected GitLab host.
893///
894/// This type is not used in any activity, and only used as *part* of another schema.
895///
896#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
897#[serde_with::serde_as]
898#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
899pub struct CreateGitLabConnectedRepositoryRequest {
900 /// Required. The GitLab repository to connect.
901 #[serde(rename = "gitlabConnectedRepository")]
902 pub gitlab_connected_repository: Option<GitLabConnectedRepository>,
903 /// Required. The name of the `GitLabConfig` that adds connected repository. Format: `projects/{project}/locations/{location}/gitLabConfigs/{config}`
904 pub parent: Option<String>,
905}
906
907impl common::Part for CreateGitLabConnectedRepositoryRequest {}
908
909/// The default service account used for `Builds`.
910///
911/// # Activities
912///
913/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
914/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
915///
916/// * [locations get default service account projects](ProjectLocationGetDefaultServiceAccountCall) (response)
917#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
918#[serde_with::serde_as]
919#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
920pub struct DefaultServiceAccount {
921 /// Identifier. Format: `projects/{project}/locations/{location}/defaultServiceAccount
922 pub name: Option<String>,
923 /// Output only. The email address of the service account identity that will be used for a build by default. This is returned in the format `projects/{project}/serviceAccounts/{service_account}` where `{service_account}` could be the legacy Cloud Build SA, in the format [PROJECT_NUMBER]@cloudbuild.gserviceaccount.com or the Compute SA, in the format [PROJECT_NUMBER]-compute@developer.gserviceaccount.com. If no service account will be used by default, this will be empty.
924 #[serde(rename = "serviceAccountEmail")]
925 pub service_account_email: Option<String>,
926}
927
928impl common::ResponseResult for DefaultServiceAccount {}
929
930/// This config defines the location of a source through Developer Connect.
931///
932/// This type is not used in any activity, and only used as *part* of another schema.
933///
934#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
935#[serde_with::serde_as]
936#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
937pub struct DeveloperConnectConfig {
938 /// Required. Directory, relative to the source root, in which to run the build.
939 pub dir: Option<String>,
940 /// Required. The Developer Connect Git repository link, formatted as `projects/*/locations/*/connections/*/gitRepositoryLink/*`.
941 #[serde(rename = "gitRepositoryLink")]
942 pub git_repository_link: Option<String>,
943 /// Required. The revision to fetch from the Git repository such as a branch, a tag, a commit SHA, or any Git ref.
944 pub revision: Option<String>,
945}
946
947impl common::Part for DeveloperConnectConfig {}
948
949/// 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); }
950///
951/// # Activities
952///
953/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
954/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
955///
956/// * [receive github dot com webhook](GithubDotComWebhookReceiveCall) (response)
957/// * [regional webhook locations](LocationRegionalWebhookCall) (response)
958/// * [cancel operations](OperationCancelCall) (response)
959/// * [locations bitbucket server configs remove bitbucket server connected repository projects](ProjectLocationBitbucketServerConfigRemoveBitbucketServerConnectedRepositoryCall) (response)
960/// * [locations git lab configs remove git lab connected repository projects](ProjectLocationGitLabConfigRemoveGitLabConnectedRepositoryCall) (response)
961/// * [locations operations cancel projects](ProjectLocationOperationCancelCall) (response)
962/// * [locations triggers delete projects](ProjectLocationTriggerDeleteCall) (response)
963/// * [triggers delete projects](ProjectTriggerDeleteCall) (response)
964/// * [webhook](MethodWebhookCall) (response)
965#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
966#[serde_with::serde_as]
967#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
968pub struct Empty {
969 _never_set: Option<bool>,
970}
971
972impl common::ResponseResult for Empty {}
973
974/// A fatal problem encountered during the execution of the build.
975///
976/// This type is not used in any activity, and only used as *part* of another schema.
977///
978#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
979#[serde_with::serde_as]
980#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
981pub struct FailureInfo {
982 /// Explains the failure issue in more detail using hard-coded text.
983 pub detail: Option<String>,
984 /// The name of the failure.
985 #[serde(rename = "type")]
986 pub type_: Option<String>,
987}
988
989impl common::Part for FailureInfo {}
990
991/// Container message for hashes of byte content of files, used in SourceProvenance messages to verify integrity of source input to the build.
992///
993/// This type is not used in any activity, and only used as *part* of another schema.
994///
995#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
996#[serde_with::serde_as]
997#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
998pub struct FileHashes {
999 /// Collection of file hashes.
1000 #[serde(rename = "fileHash")]
1001 pub file_hash: Option<Vec<Hash>>,
1002}
1003
1004impl common::Part for FileHashes {}
1005
1006/// Represents a storage location in Cloud Storage
1007///
1008/// This type is not used in any activity, and only used as *part* of another schema.
1009///
1010#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1011#[serde_with::serde_as]
1012#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1013pub struct GCSLocation {
1014 /// Cloud Storage bucket. See https://cloud.google.com/storage/docs/naming#requirements
1015 pub bucket: Option<String>,
1016 /// Cloud Storage generation for the object. If the generation is omitted, the latest generation will be used.
1017 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1018 pub generation: Option<i64>,
1019 /// Cloud Storage object. See https://cloud.google.com/storage/docs/naming#objectnames
1020 pub object: Option<String>,
1021}
1022
1023impl common::Part for GCSLocation {}
1024
1025/// GitConfig is a configuration for git operations.
1026///
1027/// This type is not used in any activity, and only used as *part* of another schema.
1028///
1029#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1030#[serde_with::serde_as]
1031#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1032pub struct GitConfig {
1033 /// Configuration for HTTP related git operations.
1034 pub http: Option<HttpConfig>,
1035}
1036
1037impl common::Part for GitConfig {}
1038
1039/// GitFileSource describes a file within a (possibly remote) code repository.
1040///
1041/// This type is not used in any activity, and only used as *part* of another schema.
1042///
1043#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1044#[serde_with::serde_as]
1045#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1046pub struct GitFileSource {
1047 /// The full resource name of the bitbucket server config. Format: `projects/{project}/locations/{location}/bitbucketServerConfigs/{id}`.
1048 #[serde(rename = "bitbucketServerConfig")]
1049 pub bitbucket_server_config: Option<String>,
1050 /// The full resource name of the github enterprise config. Format: `projects/{project}/locations/{location}/githubEnterpriseConfigs/{id}`. `projects/{project}/githubEnterpriseConfigs/{id}`.
1051 #[serde(rename = "githubEnterpriseConfig")]
1052 pub github_enterprise_config: Option<String>,
1053 /// The path of the file, with the repo root as the root of the path.
1054 pub path: Option<String>,
1055 /// See RepoType above.
1056 #[serde(rename = "repoType")]
1057 pub repo_type: Option<String>,
1058 /// The fully qualified resource name of the Repos API repository. Either URI or repository can be specified. If unspecified, the repo from which the trigger invocation originated is assumed to be the repo from which to read the specified path.
1059 pub repository: Option<String>,
1060 /// The branch, tag, arbitrary ref, or SHA version of the repo to use when resolving the filename (optional). This field respects the same syntax/resolution as described here: https://git-scm.com/docs/gitrevisions If unspecified, the revision from which the trigger invocation originated is assumed to be the revision from which to read the specified path.
1061 pub revision: Option<String>,
1062 /// The URI of the repo. Either uri or repository can be specified. If unspecified, the repo from which the trigger invocation originated is assumed to be the repo from which to read the specified path.
1063 pub uri: Option<String>,
1064}
1065
1066impl common::Part for GitFileSource {}
1067
1068/// GitHubEnterpriseConfig represents a configuration for a GitHub Enterprise server.
1069///
1070/// # Activities
1071///
1072/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1073/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1074///
1075/// * [github enterprise configs create projects](ProjectGithubEnterpriseConfigCreateCall) (request)
1076/// * [github enterprise configs get projects](ProjectGithubEnterpriseConfigGetCall) (response)
1077/// * [github enterprise configs patch projects](ProjectGithubEnterpriseConfigPatchCall) (request)
1078/// * [locations github enterprise configs create projects](ProjectLocationGithubEnterpriseConfigCreateCall) (request)
1079/// * [locations github enterprise configs get projects](ProjectLocationGithubEnterpriseConfigGetCall) (response)
1080/// * [locations github enterprise configs patch projects](ProjectLocationGithubEnterpriseConfigPatchCall) (request)
1081#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1082#[serde_with::serde_as]
1083#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1084pub struct GitHubEnterpriseConfig {
1085 /// Required. The GitHub app id of the Cloud Build app on the GitHub Enterprise server.
1086 #[serde(rename = "appId")]
1087 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1088 pub app_id: Option<i64>,
1089 /// Output only. Time when the installation was associated with the project.
1090 #[serde(rename = "createTime")]
1091 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1092 /// Optional. Name to display for this config.
1093 #[serde(rename = "displayName")]
1094 pub display_name: Option<String>,
1095 /// The URL of the github enterprise host the configuration is for.
1096 #[serde(rename = "hostUrl")]
1097 pub host_url: Option<String>,
1098 /// The full resource name for the GitHubEnterpriseConfig For example: "projects/{$project_id}/locations/{$location_id}/githubEnterpriseConfigs/{$config_id}"
1099 pub name: Option<String>,
1100 /// Optional. The network to be used when reaching out to the GitHub Enterprise server. The VPC network must be enabled for private service connection. This should be set if the GitHub Enterprise server is hosted on-premises and not reachable by public internet. If this field is left empty, no network peering will occur and calls to the GitHub Enterprise server will be made over the public internet. Must be in the format `projects/{project}/global/networks/{network}`, where {project} is a project number or id and {network} is the name of a VPC network in the project.
1101 #[serde(rename = "peeredNetwork")]
1102 pub peered_network: Option<String>,
1103 /// Optional. Names of secrets in Secret Manager.
1104 pub secrets: Option<GitHubEnterpriseSecrets>,
1105 /// Optional. SSL certificate to use for requests to GitHub Enterprise.
1106 #[serde(rename = "sslCa")]
1107 pub ssl_ca: Option<String>,
1108 /// The key that should be attached to webhook calls to the ReceiveWebhook endpoint.
1109 #[serde(rename = "webhookKey")]
1110 pub webhook_key: Option<String>,
1111}
1112
1113impl common::RequestValue for GitHubEnterpriseConfig {}
1114impl common::ResponseResult for GitHubEnterpriseConfig {}
1115
1116/// GitHubEnterpriseSecrets represents the names of all necessary secrets in Secret Manager for a GitHub Enterprise server. Format is: projects//secrets/.
1117///
1118/// This type is not used in any activity, and only used as *part* of another schema.
1119///
1120#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1121#[serde_with::serde_as]
1122#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1123pub struct GitHubEnterpriseSecrets {
1124 /// The resource name for the OAuth client ID secret in Secret Manager.
1125 #[serde(rename = "oauthClientIdName")]
1126 pub oauth_client_id_name: Option<String>,
1127 /// The resource name for the OAuth client ID secret version in Secret Manager.
1128 #[serde(rename = "oauthClientIdVersionName")]
1129 pub oauth_client_id_version_name: Option<String>,
1130 /// The resource name for the OAuth secret in Secret Manager.
1131 #[serde(rename = "oauthSecretName")]
1132 pub oauth_secret_name: Option<String>,
1133 /// The resource name for the OAuth secret secret version in Secret Manager.
1134 #[serde(rename = "oauthSecretVersionName")]
1135 pub oauth_secret_version_name: Option<String>,
1136 /// The resource name for the private key secret.
1137 #[serde(rename = "privateKeyName")]
1138 pub private_key_name: Option<String>,
1139 /// The resource name for the private key secret version.
1140 #[serde(rename = "privateKeyVersionName")]
1141 pub private_key_version_name: Option<String>,
1142 /// The resource name for the webhook secret in Secret Manager.
1143 #[serde(rename = "webhookSecretName")]
1144 pub webhook_secret_name: Option<String>,
1145 /// The resource name for the webhook secret secret version in Secret Manager.
1146 #[serde(rename = "webhookSecretVersionName")]
1147 pub webhook_secret_version_name: Option<String>,
1148}
1149
1150impl common::Part for GitHubEnterpriseSecrets {}
1151
1152/// GitHubEventsConfig describes the configuration of a trigger that creates a build whenever a GitHub event is received.
1153///
1154/// This type is not used in any activity, and only used as *part* of another schema.
1155///
1156#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1157#[serde_with::serde_as]
1158#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1159pub struct GitHubEventsConfig {
1160 /// The resource name of the github enterprise config that should be applied to this installation. For example: "projects/{$project_id}/locations/{$location_id}/githubEnterpriseConfigs/{$config_id}"
1161 #[serde(rename = "enterpriseConfigResourceName")]
1162 pub enterprise_config_resource_name: Option<String>,
1163 /// The installationID that emits the GitHub event.
1164 #[serde(rename = "installationId")]
1165 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1166 pub installation_id: Option<i64>,
1167 /// Name of the repository. For example: The name for https://github.com/googlecloudplatform/cloud-builders is "cloud-builders".
1168 pub name: Option<String>,
1169 /// Owner of the repository. For example: The owner for https://github.com/googlecloudplatform/cloud-builders is "googlecloudplatform".
1170 pub owner: Option<String>,
1171 /// filter to match changes in pull requests.
1172 #[serde(rename = "pullRequest")]
1173 pub pull_request: Option<PullRequestFilter>,
1174 /// filter to match changes in refs like branches, tags.
1175 pub push: Option<PushFilter>,
1176}
1177
1178impl common::Part for GitHubEventsConfig {}
1179
1180/// GitLabConfig represents the configuration for a GitLab integration.
1181///
1182/// # Activities
1183///
1184/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1185/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1186///
1187/// * [locations git lab configs create projects](ProjectLocationGitLabConfigCreateCall) (request)
1188/// * [locations git lab configs get projects](ProjectLocationGitLabConfigGetCall) (response)
1189/// * [locations git lab configs patch projects](ProjectLocationGitLabConfigPatchCall) (request)
1190#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1191#[serde_with::serde_as]
1192#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1193pub struct GitLabConfig {
1194 /// Connected GitLab.com or GitLabEnterprise repositories for this config.
1195 #[serde(rename = "connectedRepositories")]
1196 pub connected_repositories: Option<Vec<GitLabRepositoryId>>,
1197 /// Output only. Time when the config was created.
1198 #[serde(rename = "createTime")]
1199 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1200 /// Optional. GitLabEnterprise config.
1201 #[serde(rename = "enterpriseConfig")]
1202 pub enterprise_config: Option<GitLabEnterpriseConfig>,
1203 /// The resource name for the config.
1204 pub name: Option<String>,
1205 /// Required. Secret Manager secrets needed by the config.
1206 pub secrets: Option<GitLabSecrets>,
1207 /// Username of the GitLab.com or GitLab Enterprise account Cloud Build will use.
1208 pub username: Option<String>,
1209 /// Output only. UUID included in webhook requests. The UUID is used to look up the corresponding config.
1210 #[serde(rename = "webhookKey")]
1211 pub webhook_key: Option<String>,
1212}
1213
1214impl common::RequestValue for GitLabConfig {}
1215impl common::ResponseResult for GitLabConfig {}
1216
1217/// GitLabConnectedRepository represents a GitLab connected repository request response.
1218///
1219/// This type is not used in any activity, and only used as *part* of another schema.
1220///
1221#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1222#[serde_with::serde_as]
1223#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1224pub struct GitLabConnectedRepository {
1225 /// The name of the `GitLabConfig` that added connected repository. Format: `projects/{project}/locations/{location}/gitLabConfigs/{config}`
1226 pub parent: Option<String>,
1227 /// The GitLab repositories to connect.
1228 pub repo: Option<GitLabRepositoryId>,
1229 /// Output only. The status of the repo connection request.
1230 pub status: Option<Status>,
1231}
1232
1233impl common::Part for GitLabConnectedRepository {}
1234
1235/// GitLabEnterpriseConfig represents the configuration for a GitLabEnterprise integration.
1236///
1237/// This type is not used in any activity, and only used as *part* of another schema.
1238///
1239#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1240#[serde_with::serde_as]
1241#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1242pub struct GitLabEnterpriseConfig {
1243 /// Immutable. The URI of the GitlabEnterprise host.
1244 #[serde(rename = "hostUri")]
1245 pub host_uri: Option<String>,
1246 /// The Service Directory configuration to be used when reaching out to the GitLab Enterprise instance.
1247 #[serde(rename = "serviceDirectoryConfig")]
1248 pub service_directory_config: Option<ServiceDirectoryConfig>,
1249 /// The SSL certificate to use in requests to GitLab Enterprise instances.
1250 #[serde(rename = "sslCa")]
1251 pub ssl_ca: Option<String>,
1252}
1253
1254impl common::Part for GitLabEnterpriseConfig {}
1255
1256/// GitLabEventsConfig describes the configuration of a trigger that creates a build whenever a GitLab event is received.
1257///
1258/// This type is not used in any activity, and only used as *part* of another schema.
1259///
1260#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1261#[serde_with::serde_as]
1262#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1263pub struct GitLabEventsConfig {
1264 /// Output only. The GitLabConfig specified in the gitlab_config_resource field.
1265 #[serde(rename = "gitlabConfig")]
1266 pub gitlab_config: Option<GitLabConfig>,
1267 /// The GitLab config resource that this trigger config maps to.
1268 #[serde(rename = "gitlabConfigResource")]
1269 pub gitlab_config_resource: Option<String>,
1270 /// Namespace of the GitLab project.
1271 #[serde(rename = "projectNamespace")]
1272 pub project_namespace: Option<String>,
1273 /// Filter to match changes in pull requests.
1274 #[serde(rename = "pullRequest")]
1275 pub pull_request: Option<PullRequestFilter>,
1276 /// Filter to match changes in refs like branches, tags.
1277 pub push: Option<PushFilter>,
1278}
1279
1280impl common::Part for GitLabEventsConfig {}
1281
1282/// Proto Representing a GitLabRepository
1283///
1284/// This type is not used in any activity, and only used as *part* of another schema.
1285///
1286#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1287#[serde_with::serde_as]
1288#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1289pub struct GitLabRepository {
1290 /// Link to the browse repo page on the GitLab instance
1291 #[serde(rename = "browseUri")]
1292 pub browse_uri: Option<String>,
1293 /// Description of the repository
1294 pub description: Option<String>,
1295 /// Display name of the repository
1296 #[serde(rename = "displayName")]
1297 pub display_name: Option<String>,
1298 /// The resource name of the repository
1299 pub name: Option<String>,
1300 /// Identifier for a repository
1301 #[serde(rename = "repositoryId")]
1302 pub repository_id: Option<GitLabRepositoryId>,
1303}
1304
1305impl common::Part for GitLabRepository {}
1306
1307/// GitLabRepositoryId identifies a specific repository hosted on GitLab.com or GitLabEnterprise
1308///
1309/// This type is not used in any activity, and only used as *part* of another schema.
1310///
1311#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1312#[serde_with::serde_as]
1313#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1314pub struct GitLabRepositoryId {
1315 /// Required. Identifier for the repository. example: "namespace/project-slug", namespace is usually the username or group ID
1316 pub id: Option<String>,
1317 /// Output only. The ID of the webhook that was created for receiving events from this repo. We only create and manage a single webhook for each repo.
1318 #[serde(rename = "webhookId")]
1319 pub webhook_id: Option<i32>,
1320}
1321
1322impl common::Part for GitLabRepositoryId {}
1323
1324/// GitLabSecrets represents the secrets in Secret Manager for a GitLab integration.
1325///
1326/// This type is not used in any activity, and only used as *part* of another schema.
1327///
1328#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1329#[serde_with::serde_as]
1330#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1331pub struct GitLabSecrets {
1332 /// Required. The resource name for the api access token’s secret version
1333 #[serde(rename = "apiAccessTokenVersion")]
1334 pub api_access_token_version: Option<String>,
1335 /// Required. Immutable. API Key that will be attached to webhook requests from GitLab to Cloud Build.
1336 #[serde(rename = "apiKeyVersion")]
1337 pub api_key_version: Option<String>,
1338 /// Required. The resource name for the read access token’s secret version
1339 #[serde(rename = "readAccessTokenVersion")]
1340 pub read_access_token_version: Option<String>,
1341 /// Required. Immutable. The resource name for the webhook secret’s secret version. Once this field has been set, it cannot be changed. If you need to change it, please create another GitLabConfig.
1342 #[serde(rename = "webhookSecretVersion")]
1343 pub webhook_secret_version: Option<String>,
1344}
1345
1346impl common::Part for GitLabSecrets {}
1347
1348/// GitRepoSource describes a repo and ref of a code repository.
1349///
1350/// This type is not used in any activity, and only used as *part* of another schema.
1351///
1352#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1353#[serde_with::serde_as]
1354#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1355pub struct GitRepoSource {
1356 /// The full resource name of the bitbucket server config. Format: `projects/{project}/locations/{location}/bitbucketServerConfigs/{id}`.
1357 #[serde(rename = "bitbucketServerConfig")]
1358 pub bitbucket_server_config: Option<String>,
1359 /// The full resource name of the github enterprise config. Format: `projects/{project}/locations/{location}/githubEnterpriseConfigs/{id}`. `projects/{project}/githubEnterpriseConfigs/{id}`.
1360 #[serde(rename = "githubEnterpriseConfig")]
1361 pub github_enterprise_config: Option<String>,
1362 /// The branch or tag to use. Must start with "refs/" (required).
1363 #[serde(rename = "ref")]
1364 pub ref_: Option<String>,
1365 /// See RepoType below.
1366 #[serde(rename = "repoType")]
1367 pub repo_type: Option<String>,
1368 /// The connected repository resource name, in the format `projects/*/locations/*/connections/*/repositories/*`. Either `uri` or `repository` can be specified and is required.
1369 pub repository: Option<String>,
1370 /// The URI of the repo (e.g. https://github.com/user/repo.git). Either `uri` or `repository` can be specified and is required.
1371 pub uri: Option<String>,
1372}
1373
1374impl common::Part for GitRepoSource {}
1375
1376/// Location of the source in any accessible Git repository.
1377///
1378/// This type is not used in any activity, and only used as *part* of another schema.
1379///
1380#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1381#[serde_with::serde_as]
1382#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1383pub struct GitSource {
1384 /// Optional. Directory, relative to the source root, in which to run the build. This must be a relative path. If a step's `dir` is specified and is an absolute path, this value is ignored for that step's execution.
1385 pub dir: Option<String>,
1386 /// Optional. The revision to fetch from the Git repository such as a branch, a tag, a commit SHA, or any Git ref. Cloud Build uses `git fetch` to fetch the revision from the Git repository; therefore make sure that the string you provide for `revision` is parsable by the command. For information on string values accepted by `git fetch`, see https://git-scm.com/docs/gitrevisions#_specifying_revisions. For information on `git fetch`, see https://git-scm.com/docs/git-fetch.
1387 pub revision: Option<String>,
1388 /// Required. Location of the Git repo to build. This will be used as a `git remote`, see https://git-scm.com/docs/git-remote.
1389 pub url: Option<String>,
1390}
1391
1392impl common::Part for GitSource {}
1393
1394/// Container message for hash values.
1395///
1396/// This type is not used in any activity, and only used as *part* of another schema.
1397///
1398#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1399#[serde_with::serde_as]
1400#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1401pub struct Hash {
1402 /// The type of hash that was performed.
1403 #[serde(rename = "type")]
1404 pub type_: Option<String>,
1405 /// The hash value.
1406 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1407 pub value: Option<Vec<u8>>,
1408}
1409
1410impl common::Part for Hash {}
1411
1412/// Message that represents an arbitrary HTTP body. It should only be used for payload formats that can’t be represented as JSON, such as raw binary or an HTML page. This message can be used both in streaming and non-streaming API methods in the request as well as the response. It can be used as a top-level request field, which is convenient if one wants to extract parameters from either the URL or HTTP template into the request fields and also want access to the raw HTTP body. Example: message GetResourceRequest { // A unique request id. string request_id = 1; // The raw HTTP body is bound to this field. google.api.HttpBody http_body = 2; } service ResourceService { rpc GetResource(GetResourceRequest) returns (google.api.HttpBody); rpc UpdateResource(google.api.HttpBody) returns (google.protobuf.Empty); } Example with streaming methods: service CaldavService { rpc GetCalendar(stream google.api.HttpBody) returns (stream google.api.HttpBody); rpc UpdateCalendar(stream google.api.HttpBody) returns (stream google.api.HttpBody); } Use of this type only changes how the request and response bodies are handled, all other features will continue to work unchanged.
1413///
1414/// # Activities
1415///
1416/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1417/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1418///
1419/// * [receive github dot com webhook](GithubDotComWebhookReceiveCall) (request)
1420/// * [regional webhook locations](LocationRegionalWebhookCall) (request)
1421/// * [locations triggers webhook projects](ProjectLocationTriggerWebhookCall) (request)
1422/// * [triggers webhook projects](ProjectTriggerWebhookCall) (request)
1423/// * [webhook](MethodWebhookCall) (request)
1424#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1425#[serde_with::serde_as]
1426#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1427pub struct HttpBody {
1428 /// The HTTP Content-Type header value specifying the content type of the body.
1429 #[serde(rename = "contentType")]
1430 pub content_type: Option<String>,
1431 /// The HTTP request/response body as raw binary.
1432 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1433 pub data: Option<Vec<u8>>,
1434 /// Application specific response metadata. Must be set in the first response for streaming APIs.
1435 pub extensions: Option<Vec<HashMap<String, serde_json::Value>>>,
1436}
1437
1438impl common::RequestValue for HttpBody {}
1439
1440/// HttpConfig is a configuration for HTTP related git operations.
1441///
1442/// This type is not used in any activity, and only used as *part* of another schema.
1443///
1444#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1445#[serde_with::serde_as]
1446#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1447pub struct HttpConfig {
1448 /// SecretVersion resource of the HTTP proxy URL. The proxy URL should be in format protocol://@]proxyhost[:port].
1449 #[serde(rename = "proxySecretVersionName")]
1450 pub proxy_secret_version_name: Option<String>,
1451 /// Optional. Cloud Storage object storing the certificate to use with the HTTP proxy.
1452 #[serde(rename = "proxySslCaInfo")]
1453 pub proxy_ssl_ca_info: Option<GCSLocation>,
1454}
1455
1456impl common::Part for HttpConfig {}
1457
1458/// Pairs a set of secret environment variables mapped to encrypted values with the Cloud KMS key to use to decrypt the value.
1459///
1460/// This type is not used in any activity, and only used as *part* of another schema.
1461///
1462#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1463#[serde_with::serde_as]
1464#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1465pub struct InlineSecret {
1466 /// Map of environment variable name to its encrypted value. Secret environment variables must be unique across all of a build's secrets, and must be used by at least one build step. Values can be at most 64 KB in size. There can be at most 100 secret values across all of a build's secrets.
1467 #[serde(rename = "envMap")]
1468 #[serde_as(as = "Option<HashMap<_, common::serde::standard_base64::Wrapper>>")]
1469 pub env_map: Option<HashMap<String, Vec<u8>>>,
1470 /// Resource name of Cloud KMS crypto key to decrypt the encrypted value. In format: projects/*/locations/*/keyRings/*/cryptoKeys/*
1471 #[serde(rename = "kmsKeyName")]
1472 pub kms_key_name: Option<String>,
1473}
1474
1475impl common::Part for InlineSecret {}
1476
1477/// RPC response object returned by ListBitbucketServerConfigs RPC method.
1478///
1479/// # Activities
1480///
1481/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1482/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1483///
1484/// * [locations bitbucket server configs list projects](ProjectLocationBitbucketServerConfigListCall) (response)
1485#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1486#[serde_with::serde_as]
1487#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1488pub struct ListBitbucketServerConfigsResponse {
1489 /// A list of BitbucketServerConfigs
1490 #[serde(rename = "bitbucketServerConfigs")]
1491 pub bitbucket_server_configs: Option<Vec<BitbucketServerConfig>>,
1492 /// A token that can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
1493 #[serde(rename = "nextPageToken")]
1494 pub next_page_token: Option<String>,
1495}
1496
1497impl common::ResponseResult for ListBitbucketServerConfigsResponse {}
1498
1499/// RPC response object returned by the ListBitbucketServerRepositories RPC method.
1500///
1501/// # Activities
1502///
1503/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1504/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1505///
1506/// * [locations bitbucket server configs repos list projects](ProjectLocationBitbucketServerConfigRepoListCall) (response)
1507#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1508#[serde_with::serde_as]
1509#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1510pub struct ListBitbucketServerRepositoriesResponse {
1511 /// List of Bitbucket Server repositories.
1512 #[serde(rename = "bitbucketServerRepositories")]
1513 pub bitbucket_server_repositories: Option<Vec<BitbucketServerRepository>>,
1514 /// A token that can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
1515 #[serde(rename = "nextPageToken")]
1516 pub next_page_token: Option<String>,
1517}
1518
1519impl common::ResponseResult for ListBitbucketServerRepositoriesResponse {}
1520
1521/// Response containing existing `BuildTriggers`.
1522///
1523/// # Activities
1524///
1525/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1526/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1527///
1528/// * [locations triggers list projects](ProjectLocationTriggerListCall) (response)
1529/// * [triggers list projects](ProjectTriggerListCall) (response)
1530#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1531#[serde_with::serde_as]
1532#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1533pub struct ListBuildTriggersResponse {
1534 /// Token to receive the next page of results.
1535 #[serde(rename = "nextPageToken")]
1536 pub next_page_token: Option<String>,
1537 /// `BuildTriggers` for the project, sorted by `create_time` descending.
1538 pub triggers: Option<Vec<BuildTrigger>>,
1539}
1540
1541impl common::ResponseResult for ListBuildTriggersResponse {}
1542
1543/// Response including listed builds.
1544///
1545/// # Activities
1546///
1547/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1548/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1549///
1550/// * [builds list projects](ProjectBuildListCall) (response)
1551/// * [locations builds list projects](ProjectLocationBuildListCall) (response)
1552#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1553#[serde_with::serde_as]
1554#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1555pub struct ListBuildsResponse {
1556 /// Builds will be sorted by `create_time`, descending.
1557 pub builds: Option<Vec<Build>>,
1558 /// Token to receive the next page of results. This will be absent if the end of the response list has been reached.
1559 #[serde(rename = "nextPageToken")]
1560 pub next_page_token: Option<String>,
1561}
1562
1563impl common::ResponseResult for ListBuildsResponse {}
1564
1565/// RPC response object returned by ListGitLabConfigs RPC method.
1566///
1567/// # Activities
1568///
1569/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1570/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1571///
1572/// * [locations git lab configs list projects](ProjectLocationGitLabConfigListCall) (response)
1573#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1574#[serde_with::serde_as]
1575#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1576pub struct ListGitLabConfigsResponse {
1577 /// A list of GitLabConfigs
1578 #[serde(rename = "gitlabConfigs")]
1579 pub gitlab_configs: Option<Vec<GitLabConfig>>,
1580 /// A token that can be sent as `page_token` to retrieve the next page If this field is omitted, there are no subsequent pages.
1581 #[serde(rename = "nextPageToken")]
1582 pub next_page_token: Option<String>,
1583}
1584
1585impl common::ResponseResult for ListGitLabConfigsResponse {}
1586
1587/// RPC response object returned by the ListGitLabRepositories RPC method.
1588///
1589/// # Activities
1590///
1591/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1592/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1593///
1594/// * [locations git lab configs repos list projects](ProjectLocationGitLabConfigRepoListCall) (response)
1595#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1596#[serde_with::serde_as]
1597#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1598pub struct ListGitLabRepositoriesResponse {
1599 /// List of GitLab repositories
1600 #[serde(rename = "gitlabRepositories")]
1601 pub gitlab_repositories: Option<Vec<GitLabRepository>>,
1602 /// A token that can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
1603 #[serde(rename = "nextPageToken")]
1604 pub next_page_token: Option<String>,
1605}
1606
1607impl common::ResponseResult for ListGitLabRepositoriesResponse {}
1608
1609/// RPC response object returned by ListGithubEnterpriseConfigs RPC method.
1610///
1611/// # Activities
1612///
1613/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1614/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1615///
1616/// * [github enterprise configs list projects](ProjectGithubEnterpriseConfigListCall) (response)
1617/// * [locations github enterprise configs list projects](ProjectLocationGithubEnterpriseConfigListCall) (response)
1618#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1619#[serde_with::serde_as]
1620#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1621pub struct ListGithubEnterpriseConfigsResponse {
1622 /// A list of GitHubEnterpriseConfigs
1623 pub configs: Option<Vec<GitHubEnterpriseConfig>>,
1624}
1625
1626impl common::ResponseResult for ListGithubEnterpriseConfigsResponse {}
1627
1628/// Response containing existing `WorkerPools`.
1629///
1630/// # Activities
1631///
1632/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1633/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1634///
1635/// * [locations worker pools list projects](ProjectLocationWorkerPoolListCall) (response)
1636#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1637#[serde_with::serde_as]
1638#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1639pub struct ListWorkerPoolsResponse {
1640 /// Continuation token used to page through large result sets. Provide this value in a subsequent ListWorkerPoolsRequest to return the next page of results.
1641 #[serde(rename = "nextPageToken")]
1642 pub next_page_token: Option<String>,
1643 /// `WorkerPools` for the specified project.
1644 #[serde(rename = "workerPools")]
1645 pub worker_pools: Option<Vec<WorkerPool>>,
1646}
1647
1648impl common::ResponseResult for ListWorkerPoolsResponse {}
1649
1650/// A Maven artifact to upload to Artifact Registry upon successful completion of all build steps.
1651///
1652/// This type is not used in any activity, and only used as *part* of another schema.
1653///
1654#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1655#[serde_with::serde_as]
1656#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1657pub struct MavenArtifact {
1658 /// Maven `artifactId` value used when uploading the artifact to Artifact Registry.
1659 #[serde(rename = "artifactId")]
1660 pub artifact_id: Option<String>,
1661 /// Maven `groupId` value used when uploading the artifact to Artifact Registry.
1662 #[serde(rename = "groupId")]
1663 pub group_id: Option<String>,
1664 /// Path to an artifact in the build's workspace to be uploaded to Artifact Registry. This can be either an absolute path, e.g. /workspace/my-app/target/my-app-1.0.SNAPSHOT.jar or a relative path from /workspace, e.g. my-app/target/my-app-1.0.SNAPSHOT.jar.
1665 pub path: Option<String>,
1666 /// Artifact Registry repository, in the form "https://$REGION-maven.pkg.dev/$PROJECT/$REPOSITORY" Artifact in the workspace specified by path will be uploaded to Artifact Registry with this location as a prefix.
1667 pub repository: Option<String>,
1668 /// Maven `version` value used when uploading the artifact to Artifact Registry.
1669 pub version: Option<String>,
1670}
1671
1672impl common::Part for MavenArtifact {}
1673
1674/// Defines the network configuration for the pool.
1675///
1676/// This type is not used in any activity, and only used as *part* of another schema.
1677///
1678#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1679#[serde_with::serde_as]
1680#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1681pub struct NetworkConfig {
1682 /// Option to configure network egress for the workers.
1683 #[serde(rename = "egressOption")]
1684 pub egress_option: Option<String>,
1685 /// Required. Immutable. The network definition that the workers are peered to. If this section is left empty, the workers will be peered to `WorkerPool.project_id` on the service producer network. Must be in the format `projects/{project}/global/networks/{network}`, where `{project}` is a project number, such as `12345`, and `{network}` is the name of a VPC network in the project. See [Understanding network configuration options](https://cloud.google.com/build/docs/private-pools/set-up-private-pool-environment)
1686 #[serde(rename = "peeredNetwork")]
1687 pub peered_network: Option<String>,
1688 /// Immutable. Subnet IP range within the peered network. This is specified in CIDR notation with a slash and the subnet prefix size. You can optionally specify an IP address before the subnet prefix value. e.g. `192.168.0.0/29` would specify an IP range starting at 192.168.0.0 with a prefix size of 29 bits. `/16` would specify a prefix size of 16 bits, with an automatically determined IP within the peered VPC. If unspecified, a value of `/24` will be used.
1689 #[serde(rename = "peeredNetworkIpRange")]
1690 pub peered_network_ip_range: Option<String>,
1691}
1692
1693impl common::Part for NetworkConfig {}
1694
1695/// Npm package to upload to Artifact Registry upon successful completion of all build steps.
1696///
1697/// This type is not used in any activity, and only used as *part* of another schema.
1698///
1699#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1700#[serde_with::serde_as]
1701#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1702pub struct NpmPackage {
1703 /// Path to the package.json. e.g. workspace/path/to/package
1704 #[serde(rename = "packagePath")]
1705 pub package_path: Option<String>,
1706 /// Artifact Registry repository, in the form "https://$REGION-npm.pkg.dev/$PROJECT/$REPOSITORY" Npm package in the workspace specified by path will be zipped and uploaded to Artifact Registry with this location as a prefix.
1707 pub repository: Option<String>,
1708}
1709
1710impl common::Part for NpmPackage {}
1711
1712/// This resource represents a long-running operation that is the result of a network API call.
1713///
1714/// # Activities
1715///
1716/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1717/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1718///
1719/// * [cancel operations](OperationCancelCall) (none)
1720/// * [get operations](OperationGetCall) (response)
1721/// * [builds approve projects](ProjectBuildApproveCall) (response)
1722/// * [builds create projects](ProjectBuildCreateCall) (response)
1723/// * [builds retry projects](ProjectBuildRetryCall) (response)
1724/// * [github enterprise configs create projects](ProjectGithubEnterpriseConfigCreateCall) (response)
1725/// * [github enterprise configs delete projects](ProjectGithubEnterpriseConfigDeleteCall) (response)
1726/// * [github enterprise configs patch projects](ProjectGithubEnterpriseConfigPatchCall) (response)
1727/// * [locations bitbucket server configs connected repositories batch create projects](ProjectLocationBitbucketServerConfigConnectedRepositoryBatchCreateCall) (response)
1728/// * [locations bitbucket server configs create projects](ProjectLocationBitbucketServerConfigCreateCall) (response)
1729/// * [locations bitbucket server configs delete projects](ProjectLocationBitbucketServerConfigDeleteCall) (response)
1730/// * [locations bitbucket server configs patch projects](ProjectLocationBitbucketServerConfigPatchCall) (response)
1731/// * [locations builds approve projects](ProjectLocationBuildApproveCall) (response)
1732/// * [locations builds create projects](ProjectLocationBuildCreateCall) (response)
1733/// * [locations builds retry projects](ProjectLocationBuildRetryCall) (response)
1734/// * [locations git lab configs connected repositories batch create projects](ProjectLocationGitLabConfigConnectedRepositoryBatchCreateCall) (response)
1735/// * [locations git lab configs create projects](ProjectLocationGitLabConfigCreateCall) (response)
1736/// * [locations git lab configs delete projects](ProjectLocationGitLabConfigDeleteCall) (response)
1737/// * [locations git lab configs patch projects](ProjectLocationGitLabConfigPatchCall) (response)
1738/// * [locations github enterprise configs create projects](ProjectLocationGithubEnterpriseConfigCreateCall) (response)
1739/// * [locations github enterprise configs delete projects](ProjectLocationGithubEnterpriseConfigDeleteCall) (response)
1740/// * [locations github enterprise configs patch projects](ProjectLocationGithubEnterpriseConfigPatchCall) (response)
1741/// * [locations operations get projects](ProjectLocationOperationGetCall) (response)
1742/// * [locations triggers run projects](ProjectLocationTriggerRunCall) (response)
1743/// * [locations worker pools create projects](ProjectLocationWorkerPoolCreateCall) (response)
1744/// * [locations worker pools delete projects](ProjectLocationWorkerPoolDeleteCall) (response)
1745/// * [locations worker pools patch projects](ProjectLocationWorkerPoolPatchCall) (response)
1746/// * [triggers run projects](ProjectTriggerRunCall) (response)
1747#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1748#[serde_with::serde_as]
1749#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1750pub struct Operation {
1751 /// 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.
1752 pub done: Option<bool>,
1753 /// The error result of the operation in case of failure or cancellation.
1754 pub error: Option<Status>,
1755 /// 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.
1756 pub metadata: Option<HashMap<String, serde_json::Value>>,
1757 /// 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}`.
1758 pub name: Option<String>,
1759 /// 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`.
1760 pub response: Option<HashMap<String, serde_json::Value>>,
1761}
1762
1763impl common::Resource for Operation {}
1764impl common::ResponseResult for Operation {}
1765
1766/// Details about how a build should be executed on a `WorkerPool`. See [running builds in a private pool](https://cloud.google.com/build/docs/private-pools/run-builds-in-private-pool) for more information.
1767///
1768/// This type is not used in any activity, and only used as *part* of another schema.
1769///
1770#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1771#[serde_with::serde_as]
1772#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1773pub struct PoolOption {
1774 /// The `WorkerPool` resource to execute the build on. You must have `cloudbuild.workerpools.use` on the project hosting the WorkerPool. Format projects/{project}/locations/{location}/workerPools/{workerPoolId}
1775 pub name: Option<String>,
1776}
1777
1778impl common::Part for PoolOption {}
1779
1780/// Configuration for a V1 `PrivatePool`.
1781///
1782/// This type is not used in any activity, and only used as *part* of another schema.
1783///
1784#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1785#[serde_with::serde_as]
1786#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1787pub struct PrivatePoolV1Config {
1788 /// Network configuration for the pool.
1789 #[serde(rename = "networkConfig")]
1790 pub network_config: Option<NetworkConfig>,
1791 /// Machine configuration for the workers in the pool.
1792 #[serde(rename = "workerConfig")]
1793 pub worker_config: Option<WorkerConfig>,
1794}
1795
1796impl common::Part for PrivatePoolV1Config {}
1797
1798/// PubsubConfig describes the configuration of a trigger that creates a build whenever a Pub/Sub message is published.
1799///
1800/// This type is not used in any activity, and only used as *part* of another schema.
1801///
1802#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1803#[serde_with::serde_as]
1804#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1805pub struct PubsubConfig {
1806 /// Service account that will make the push request.
1807 #[serde(rename = "serviceAccountEmail")]
1808 pub service_account_email: Option<String>,
1809 /// Potential issues with the underlying Pub/Sub subscription configuration. Only populated on get requests.
1810 pub state: Option<String>,
1811 /// Output only. Name of the subscription. Format is `projects/{project}/subscriptions/{subscription}`.
1812 pub subscription: Option<String>,
1813 /// Optional. The name of the topic from which this subscription is receiving messages. Format is `projects/{project}/topics/{topic}`.
1814 pub topic: Option<String>,
1815}
1816
1817impl common::Part for PubsubConfig {}
1818
1819/// PullRequestFilter contains filter properties for matching GitHub Pull Requests.
1820///
1821/// This type is not used in any activity, and only used as *part* of another schema.
1822///
1823#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1824#[serde_with::serde_as]
1825#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1826pub struct PullRequestFilter {
1827 /// Regex of branches to match. The syntax of the regular expressions accepted is the syntax accepted by RE2 and described at https://github.com/google/re2/wiki/Syntax
1828 pub branch: Option<String>,
1829 /// If CommentControl is enabled, depending on the setting, builds may not fire until a repository writer comments `/gcbrun` on a pull request or `/gcbrun` is in the pull request description. Only PR comments that contain `/gcbrun` will trigger builds. If CommentControl is set to disabled, comments with `/gcbrun` from a user with repository write permission or above will still trigger builds to run.
1830 #[serde(rename = "commentControl")]
1831 pub comment_control: Option<String>,
1832 /// If true, branches that do NOT match the git_ref will trigger a build.
1833 #[serde(rename = "invertRegex")]
1834 pub invert_regex: Option<bool>,
1835}
1836
1837impl common::Part for PullRequestFilter {}
1838
1839/// Push contains filter properties for matching GitHub git pushes.
1840///
1841/// This type is not used in any activity, and only used as *part* of another schema.
1842///
1843#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1844#[serde_with::serde_as]
1845#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1846pub struct PushFilter {
1847 /// Regexes matching branches to build. The syntax of the regular expressions accepted is the syntax accepted by RE2 and described at https://github.com/google/re2/wiki/Syntax
1848 pub branch: Option<String>,
1849 /// When true, only trigger a build if the revision regex does NOT match the git_ref regex.
1850 #[serde(rename = "invertRegex")]
1851 pub invert_regex: Option<bool>,
1852 /// Regexes matching tags to build. The syntax of the regular expressions accepted is the syntax accepted by RE2 and described at https://github.com/google/re2/wiki/Syntax
1853 pub tag: Option<String>,
1854}
1855
1856impl common::Part for PushFilter {}
1857
1858/// Python package to upload to Artifact Registry upon successful completion of all build steps. A package can encapsulate multiple objects to be uploaded to a single repository.
1859///
1860/// This type is not used in any activity, and only used as *part* of another schema.
1861///
1862#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1863#[serde_with::serde_as]
1864#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1865pub struct PythonPackage {
1866 /// Path globs used to match files in the build's workspace. For Python/ Twine, this is usually `dist/*`, and sometimes additionally an `.asc` file.
1867 pub paths: Option<Vec<String>>,
1868 /// Artifact Registry repository, in the form "https://$REGION-python.pkg.dev/$PROJECT/$REPOSITORY" Files in the workspace matching any path pattern will be uploaded to Artifact Registry with this location as a prefix.
1869 pub repository: Option<String>,
1870}
1871
1872impl common::Part for PythonPackage {}
1873
1874/// ReceiveTriggerWebhookResponse \[Experimental\] is the response object for the ReceiveTriggerWebhook method.
1875///
1876/// # Activities
1877///
1878/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1879/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1880///
1881/// * [locations triggers webhook projects](ProjectLocationTriggerWebhookCall) (response)
1882/// * [triggers webhook projects](ProjectTriggerWebhookCall) (response)
1883#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1884#[serde_with::serde_as]
1885#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1886pub struct ReceiveTriggerWebhookResponse {
1887 _never_set: Option<bool>,
1888}
1889
1890impl common::ResponseResult for ReceiveTriggerWebhookResponse {}
1891
1892/// RPC request object accepted by RemoveBitbucketServerConnectedRepository RPC method.
1893///
1894/// # Activities
1895///
1896/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1897/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1898///
1899/// * [locations bitbucket server configs remove bitbucket server connected repository projects](ProjectLocationBitbucketServerConfigRemoveBitbucketServerConnectedRepositoryCall) (request)
1900#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1901#[serde_with::serde_as]
1902#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1903pub struct RemoveBitbucketServerConnectedRepositoryRequest {
1904 /// The connected repository to remove.
1905 #[serde(rename = "connectedRepository")]
1906 pub connected_repository: Option<BitbucketServerRepositoryId>,
1907}
1908
1909impl common::RequestValue for RemoveBitbucketServerConnectedRepositoryRequest {}
1910
1911/// RPC request object accepted by RemoveGitLabConnectedRepository RPC method.
1912///
1913/// # Activities
1914///
1915/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1916/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1917///
1918/// * [locations git lab configs remove git lab connected repository projects](ProjectLocationGitLabConfigRemoveGitLabConnectedRepositoryCall) (request)
1919#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1920#[serde_with::serde_as]
1921#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1922pub struct RemoveGitLabConnectedRepositoryRequest {
1923 /// The connected repository to remove.
1924 #[serde(rename = "connectedRepository")]
1925 pub connected_repository: Option<GitLabRepositoryId>,
1926}
1927
1928impl common::RequestValue for RemoveGitLabConnectedRepositoryRequest {}
1929
1930/// Location of the source in a Google Cloud Source Repository.
1931///
1932/// # Activities
1933///
1934/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1935/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1936///
1937/// * [triggers run projects](ProjectTriggerRunCall) (request)
1938#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1939#[serde_with::serde_as]
1940#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1941pub struct RepoSource {
1942 /// Regex matching branches to build. The syntax of the regular expressions accepted is the syntax accepted by RE2 and described at https://github.com/google/re2/wiki/Syntax
1943 #[serde(rename = "branchName")]
1944 pub branch_name: Option<String>,
1945 /// Explicit commit SHA to build.
1946 #[serde(rename = "commitSha")]
1947 pub commit_sha: Option<String>,
1948 /// Optional. Directory, relative to the source root, in which to run the build. This must be a relative path. If a step's `dir` is specified and is an absolute path, this value is ignored for that step's execution.
1949 pub dir: Option<String>,
1950 /// Optional. Only trigger a build if the revision regex does NOT match the revision regex.
1951 #[serde(rename = "invertRegex")]
1952 pub invert_regex: Option<bool>,
1953 /// Optional. ID of the project that owns the Cloud Source Repository. If omitted, the project ID requesting the build is assumed.
1954 #[serde(rename = "projectId")]
1955 pub project_id: Option<String>,
1956 /// Required. Name of the Cloud Source Repository.
1957 #[serde(rename = "repoName")]
1958 pub repo_name: Option<String>,
1959 /// Optional. Substitutions to use in a triggered build. Should only be used with RunBuildTrigger
1960 pub substitutions: Option<HashMap<String, String>>,
1961 /// Regex matching tags to build. The syntax of the regular expressions accepted is the syntax accepted by RE2 and described at https://github.com/google/re2/wiki/Syntax
1962 #[serde(rename = "tagName")]
1963 pub tag_name: Option<String>,
1964}
1965
1966impl common::RequestValue for RepoSource {}
1967
1968/// The configuration of a trigger that creates a build whenever an event from Repo API is received.
1969///
1970/// This type is not used in any activity, and only used as *part* of another schema.
1971///
1972#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1973#[serde_with::serde_as]
1974#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1975pub struct RepositoryEventConfig {
1976 /// Filter to match changes in pull requests.
1977 #[serde(rename = "pullRequest")]
1978 pub pull_request: Option<PullRequestFilter>,
1979 /// Filter to match changes in refs like branches, tags.
1980 pub push: Option<PushFilter>,
1981 /// The resource name of the Repo API resource.
1982 pub repository: Option<String>,
1983 /// Output only. The type of the SCM vendor the repository points to.
1984 #[serde(rename = "repositoryType")]
1985 pub repository_type: Option<String>,
1986}
1987
1988impl common::Part for RepositoryEventConfig {}
1989
1990/// Artifacts created by the build pipeline.
1991///
1992/// This type is not used in any activity, and only used as *part* of another schema.
1993///
1994#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1995#[serde_with::serde_as]
1996#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1997pub struct Results {
1998 /// Path to the artifact manifest for non-container artifacts uploaded to Cloud Storage. Only populated when artifacts are uploaded to Cloud Storage.
1999 #[serde(rename = "artifactManifest")]
2000 pub artifact_manifest: Option<String>,
2001 /// Time to push all non-container artifacts to Cloud Storage.
2002 #[serde(rename = "artifactTiming")]
2003 pub artifact_timing: Option<TimeSpan>,
2004 /// List of build step digests, in the order corresponding to build step indices.
2005 #[serde(rename = "buildStepImages")]
2006 pub build_step_images: Option<Vec<String>>,
2007 /// List of build step outputs, produced by builder images, in the order corresponding to build step indices. [Cloud Builders](https://cloud.google.com/cloud-build/docs/cloud-builders) can produce this output by writing to `$BUILDER_OUTPUT/output`. Only the first 50KB of data is stored. Note that the `$BUILDER_OUTPUT` variable is read-only and can't be substituted.
2008 #[serde(rename = "buildStepOutputs")]
2009 #[serde_as(as = "Option<Vec<common::serde::standard_base64::Wrapper>>")]
2010 pub build_step_outputs: Option<Vec<Vec<u8>>>,
2011 /// Container images that were built as a part of the build.
2012 pub images: Option<Vec<BuiltImage>>,
2013 /// Maven artifacts uploaded to Artifact Registry at the end of the build.
2014 #[serde(rename = "mavenArtifacts")]
2015 pub maven_artifacts: Option<Vec<UploadedMavenArtifact>>,
2016 /// Npm packages uploaded to Artifact Registry at the end of the build.
2017 #[serde(rename = "npmPackages")]
2018 pub npm_packages: Option<Vec<UploadedNpmPackage>>,
2019 /// Number of non-container artifacts uploaded to Cloud Storage. Only populated when artifacts are uploaded to Cloud Storage.
2020 #[serde(rename = "numArtifacts")]
2021 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2022 pub num_artifacts: Option<i64>,
2023 /// Python artifacts uploaded to Artifact Registry at the end of the build.
2024 #[serde(rename = "pythonPackages")]
2025 pub python_packages: Option<Vec<UploadedPythonPackage>>,
2026}
2027
2028impl common::Part for Results {}
2029
2030/// Specifies a build to retry.
2031///
2032/// # Activities
2033///
2034/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2035/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2036///
2037/// * [builds retry projects](ProjectBuildRetryCall) (request)
2038/// * [locations builds retry projects](ProjectLocationBuildRetryCall) (request)
2039#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2040#[serde_with::serde_as]
2041#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2042pub struct RetryBuildRequest {
2043 /// Required. Build ID of the original build.
2044 pub id: Option<String>,
2045 /// The name of the `Build` to retry. Format: `projects/{project}/locations/{location}/builds/{build}`
2046 pub name: Option<String>,
2047 /// Required. ID of the project.
2048 #[serde(rename = "projectId")]
2049 pub project_id: Option<String>,
2050}
2051
2052impl common::RequestValue for RetryBuildRequest {}
2053
2054/// Specifies a build trigger to run and the source to use.
2055///
2056/// # Activities
2057///
2058/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2059/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2060///
2061/// * [locations triggers run projects](ProjectLocationTriggerRunCall) (request)
2062#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2063#[serde_with::serde_as]
2064#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2065pub struct RunBuildTriggerRequest {
2066 /// Required. ID of the project.
2067 #[serde(rename = "projectId")]
2068 pub project_id: Option<String>,
2069 /// Source to build against this trigger. Branch and tag names cannot consist of regular expressions.
2070 pub source: Option<RepoSource>,
2071 /// Required. ID of the trigger.
2072 #[serde(rename = "triggerId")]
2073 pub trigger_id: Option<String>,
2074}
2075
2076impl common::RequestValue for RunBuildTriggerRequest {}
2077
2078/// Pairs a set of secret environment variables containing encrypted values with the Cloud KMS key to use to decrypt the value. Note: Use `kmsKeyName` with `available_secrets` instead of using `kmsKeyName` with `secret`. For instructions see: https://cloud.google.com/cloud-build/docs/securing-builds/use-encrypted-credentials.
2079///
2080/// This type is not used in any activity, and only used as *part* of another schema.
2081///
2082#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2083#[serde_with::serde_as]
2084#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2085pub struct Secret {
2086 /// Cloud KMS key name to use to decrypt these envs.
2087 #[serde(rename = "kmsKeyName")]
2088 pub kms_key_name: Option<String>,
2089 /// Map of environment variable name to its encrypted value. Secret environment variables must be unique across all of a build's secrets, and must be used by at least one build step. Values can be at most 64 KB in size. There can be at most 100 secret values across all of a build's secrets.
2090 #[serde(rename = "secretEnv")]
2091 #[serde_as(as = "Option<HashMap<_, common::serde::standard_base64::Wrapper>>")]
2092 pub secret_env: Option<HashMap<String, Vec<u8>>>,
2093}
2094
2095impl common::Part for Secret {}
2096
2097/// Pairs a secret environment variable with a SecretVersion in Secret Manager.
2098///
2099/// This type is not used in any activity, and only used as *part* of another schema.
2100///
2101#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2102#[serde_with::serde_as]
2103#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2104pub struct SecretManagerSecret {
2105 /// Environment variable name to associate with the secret. Secret environment variables must be unique across all of a build's secrets, and must be used by at least one build step.
2106 pub env: Option<String>,
2107 /// Resource name of the SecretVersion. In format: projects/*/secrets/*/versions/*
2108 #[serde(rename = "versionName")]
2109 pub version_name: Option<String>,
2110}
2111
2112impl common::Part for SecretManagerSecret {}
2113
2114/// Secrets and secret environment variables.
2115///
2116/// This type is not used in any activity, and only used as *part* of another schema.
2117///
2118#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2119#[serde_with::serde_as]
2120#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2121pub struct Secrets {
2122 /// Secrets encrypted with KMS key and the associated secret environment variable.
2123 pub inline: Option<Vec<InlineSecret>>,
2124 /// Secrets in Secret Manager and associated secret environment variable.
2125 #[serde(rename = "secretManager")]
2126 pub secret_manager: Option<Vec<SecretManagerSecret>>,
2127}
2128
2129impl common::Part for Secrets {}
2130
2131/// ServiceDirectoryConfig represents Service Directory configuration for a SCM host connection.
2132///
2133/// This type is not used in any activity, and only used as *part* of another schema.
2134///
2135#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2136#[serde_with::serde_as]
2137#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2138pub struct ServiceDirectoryConfig {
2139 /// The Service Directory service name. Format: projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}.
2140 pub service: Option<String>,
2141}
2142
2143impl common::Part for ServiceDirectoryConfig {}
2144
2145/// Location of the source in a supported storage service.
2146///
2147/// This type is not used in any activity, and only used as *part* of another schema.
2148///
2149#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2150#[serde_with::serde_as]
2151#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2152pub struct Source {
2153 /// Optional. If provided, get the source from this 2nd-gen Google Cloud Build repository resource.
2154 #[serde(rename = "connectedRepository")]
2155 pub connected_repository: Option<ConnectedRepository>,
2156 /// If provided, get the source from this Developer Connect config.
2157 #[serde(rename = "developerConnectConfig")]
2158 pub developer_connect_config: Option<DeveloperConnectConfig>,
2159 /// If provided, get the source from this Git repository.
2160 #[serde(rename = "gitSource")]
2161 pub git_source: Option<GitSource>,
2162 /// If provided, get the source from this location in a Cloud Source Repository.
2163 #[serde(rename = "repoSource")]
2164 pub repo_source: Option<RepoSource>,
2165 /// If provided, get the source from this location in Cloud Storage.
2166 #[serde(rename = "storageSource")]
2167 pub storage_source: Option<StorageSource>,
2168 /// If provided, get the source from this manifest in Cloud Storage. This feature is in Preview; see description [here](https://github.com/GoogleCloudPlatform/cloud-builders/tree/master/gcs-fetcher).
2169 #[serde(rename = "storageSourceManifest")]
2170 pub storage_source_manifest: Option<StorageSourceManifest>,
2171}
2172
2173impl common::Part for Source {}
2174
2175/// Provenance of the source. Ways to find the original source, or verify that some source was used for this build.
2176///
2177/// This type is not used in any activity, and only used as *part* of another schema.
2178///
2179#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2180#[serde_with::serde_as]
2181#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2182pub struct SourceProvenance {
2183 /// Output only. Hash(es) of the build source, which can be used to verify that the original source integrity was maintained in the build. Note that `FileHashes` will only be populated if `BuildOptions` has requested a `SourceProvenanceHash`. The keys to this map are file paths used as build source and the values contain the hash values for those files. If the build source came in a single package such as a gzipped tarfile (`.tar.gz`), the `FileHash` will be for the single path to that file.
2184 #[serde(rename = "fileHashes")]
2185 pub file_hashes: Option<HashMap<String, FileHashes>>,
2186 /// Output only. A copy of the build's `source.connected_repository`, if exists, with any revisions resolved.
2187 #[serde(rename = "resolvedConnectedRepository")]
2188 pub resolved_connected_repository: Option<ConnectedRepository>,
2189 /// Output only. A copy of the build's `source.git_source`, if exists, with any revisions resolved.
2190 #[serde(rename = "resolvedGitSource")]
2191 pub resolved_git_source: Option<GitSource>,
2192 /// A copy of the build's `source.repo_source`, if exists, with any revisions resolved.
2193 #[serde(rename = "resolvedRepoSource")]
2194 pub resolved_repo_source: Option<RepoSource>,
2195 /// A copy of the build's `source.storage_source`, if exists, with any generations resolved.
2196 #[serde(rename = "resolvedStorageSource")]
2197 pub resolved_storage_source: Option<StorageSource>,
2198 /// A copy of the build's `source.storage_source_manifest`, if exists, with any revisions resolved. This feature is in Preview.
2199 #[serde(rename = "resolvedStorageSourceManifest")]
2200 pub resolved_storage_source_manifest: Option<StorageSourceManifest>,
2201}
2202
2203impl common::Part for SourceProvenance {}
2204
2205/// 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).
2206///
2207/// This type is not used in any activity, and only used as *part* of another schema.
2208///
2209#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2210#[serde_with::serde_as]
2211#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2212pub struct Status {
2213 /// The status code, which should be an enum value of google.rpc.Code.
2214 pub code: Option<i32>,
2215 /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
2216 pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
2217 /// 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.
2218 pub message: Option<String>,
2219}
2220
2221impl common::Part for Status {}
2222
2223/// Location of the source in an archive file in Cloud Storage.
2224///
2225/// This type is not used in any activity, and only used as *part* of another schema.
2226///
2227#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2228#[serde_with::serde_as]
2229#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2230pub struct StorageSource {
2231 /// Cloud Storage bucket containing the source (see [Bucket Name Requirements](https://cloud.google.com/storage/docs/bucket-naming#requirements)).
2232 pub bucket: Option<String>,
2233 /// Optional. Cloud Storage generation for the object. If the generation is omitted, the latest generation will be used.
2234 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2235 pub generation: Option<i64>,
2236 /// Required. Cloud Storage object containing the source. This object must be a zipped (`.zip`) or gzipped archive file (`.tar.gz`) containing source to build.
2237 pub object: Option<String>,
2238 /// Optional. Option to specify the tool to fetch the source file for the build.
2239 #[serde(rename = "sourceFetcher")]
2240 pub source_fetcher: Option<String>,
2241}
2242
2243impl common::Part for StorageSource {}
2244
2245/// Location of the source manifest in Cloud Storage. This feature is in Preview; see description [here](https://github.com/GoogleCloudPlatform/cloud-builders/tree/master/gcs-fetcher).
2246///
2247/// This type is not used in any activity, and only used as *part* of another schema.
2248///
2249#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2250#[serde_with::serde_as]
2251#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2252pub struct StorageSourceManifest {
2253 /// Required. Cloud Storage bucket containing the source manifest (see [Bucket Name Requirements](https://cloud.google.com/storage/docs/bucket-naming#requirements)).
2254 pub bucket: Option<String>,
2255 /// Cloud Storage generation for the object. If the generation is omitted, the latest generation will be used.
2256 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2257 pub generation: Option<i64>,
2258 /// Required. Cloud Storage object containing the source manifest. This object must be a JSON file.
2259 pub object: Option<String>,
2260}
2261
2262impl common::Part for StorageSourceManifest {}
2263
2264/// Start and end times for a build execution phase.
2265///
2266/// This type is not used in any activity, and only used as *part* of another schema.
2267///
2268#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2269#[serde_with::serde_as]
2270#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2271pub struct TimeSpan {
2272 /// End of time span.
2273 #[serde(rename = "endTime")]
2274 pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2275 /// Start of time span.
2276 #[serde(rename = "startTime")]
2277 pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2278}
2279
2280impl common::Part for TimeSpan {}
2281
2282/// A Maven artifact uploaded using the MavenArtifact directive.
2283///
2284/// This type is not used in any activity, and only used as *part* of another schema.
2285///
2286#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2287#[serde_with::serde_as]
2288#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2289pub struct UploadedMavenArtifact {
2290 /// Hash types and values of the Maven Artifact.
2291 #[serde(rename = "fileHashes")]
2292 pub file_hashes: Option<FileHashes>,
2293 /// Output only. Stores timing information for pushing the specified artifact.
2294 #[serde(rename = "pushTiming")]
2295 pub push_timing: Option<TimeSpan>,
2296 /// URI of the uploaded artifact.
2297 pub uri: Option<String>,
2298}
2299
2300impl common::Part for UploadedMavenArtifact {}
2301
2302/// An npm package uploaded to Artifact Registry using the NpmPackage directive.
2303///
2304/// This type is not used in any activity, and only used as *part* of another schema.
2305///
2306#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2307#[serde_with::serde_as]
2308#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2309pub struct UploadedNpmPackage {
2310 /// Hash types and values of the npm package.
2311 #[serde(rename = "fileHashes")]
2312 pub file_hashes: Option<FileHashes>,
2313 /// Output only. Stores timing information for pushing the specified artifact.
2314 #[serde(rename = "pushTiming")]
2315 pub push_timing: Option<TimeSpan>,
2316 /// URI of the uploaded npm package.
2317 pub uri: Option<String>,
2318}
2319
2320impl common::Part for UploadedNpmPackage {}
2321
2322/// Artifact uploaded using the PythonPackage directive.
2323///
2324/// This type is not used in any activity, and only used as *part* of another schema.
2325///
2326#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2327#[serde_with::serde_as]
2328#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2329pub struct UploadedPythonPackage {
2330 /// Hash types and values of the Python Artifact.
2331 #[serde(rename = "fileHashes")]
2332 pub file_hashes: Option<FileHashes>,
2333 /// Output only. Stores timing information for pushing the specified artifact.
2334 #[serde(rename = "pushTiming")]
2335 pub push_timing: Option<TimeSpan>,
2336 /// URI of the uploaded artifact.
2337 pub uri: Option<String>,
2338}
2339
2340impl common::Part for UploadedPythonPackage {}
2341
2342/// Volume describes a Docker container volume which is mounted into build steps in order to persist files across build step execution.
2343///
2344/// This type is not used in any activity, and only used as *part* of another schema.
2345///
2346#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2347#[serde_with::serde_as]
2348#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2349pub struct Volume {
2350 /// Name of the volume to mount. Volume names must be unique per build step and must be valid names for Docker volumes. Each named volume must be used by at least two build steps.
2351 pub name: Option<String>,
2352 /// Path at which to mount the volume. Paths must be absolute and cannot conflict with other volume paths on the same build step or with certain reserved volume paths.
2353 pub path: Option<String>,
2354}
2355
2356impl common::Part for Volume {}
2357
2358/// A non-fatal problem encountered during the execution of the build.
2359///
2360/// This type is not used in any activity, and only used as *part* of another schema.
2361///
2362#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2363#[serde_with::serde_as]
2364#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2365pub struct Warning {
2366 /// The priority for this warning.
2367 pub priority: Option<String>,
2368 /// Explanation of the warning generated.
2369 pub text: Option<String>,
2370}
2371
2372impl common::Part for Warning {}
2373
2374/// WebhookConfig describes the configuration of a trigger that creates a build whenever a webhook is sent to a trigger's webhook URL.
2375///
2376/// This type is not used in any activity, and only used as *part* of another schema.
2377///
2378#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2379#[serde_with::serde_as]
2380#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2381pub struct WebhookConfig {
2382 /// Required. Resource name for the secret required as a URL parameter.
2383 pub secret: Option<String>,
2384 /// Potential issues with the underlying Pub/Sub subscription configuration. Only populated on get requests.
2385 pub state: Option<String>,
2386}
2387
2388impl common::Part for WebhookConfig {}
2389
2390/// Defines the configuration to be used for creating workers in the pool.
2391///
2392/// This type is not used in any activity, and only used as *part* of another schema.
2393///
2394#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2395#[serde_with::serde_as]
2396#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2397pub struct WorkerConfig {
2398 /// Size of the disk attached to the worker, in GB. See [Worker pool config file](https://cloud.google.com/build/docs/private-pools/worker-pool-config-file-schema). Specify a value of up to 2000. If `0` is specified, Cloud Build will use a standard disk size.
2399 #[serde(rename = "diskSizeGb")]
2400 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2401 pub disk_size_gb: Option<i64>,
2402 /// Optional. Machine type of a worker, such as `e2-medium`. See [Worker pool config file](https://cloud.google.com/build/docs/private-pools/worker-pool-config-file-schema). If left blank, Cloud Build will use a sensible default.
2403 #[serde(rename = "machineType")]
2404 pub machine_type: Option<String>,
2405}
2406
2407impl common::Part for WorkerConfig {}
2408
2409/// Configuration for a `WorkerPool`. Cloud Build owns and maintains a pool of workers for general use and have no access to a project’s private network. By default, builds submitted to Cloud Build will use a worker from this pool. If your build needs access to resources on a private network, create and use a `WorkerPool` to run your builds. Private `WorkerPool`s give your builds access to any single VPC network that you administer, including any on-prem resources connected to that VPC network. For an overview of private pools, see [Private pools overview](https://cloud.google.com/build/docs/private-pools/private-pools-overview).
2410///
2411/// # Activities
2412///
2413/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2414/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2415///
2416/// * [locations worker pools create projects](ProjectLocationWorkerPoolCreateCall) (request)
2417/// * [locations worker pools get projects](ProjectLocationWorkerPoolGetCall) (response)
2418/// * [locations worker pools patch projects](ProjectLocationWorkerPoolPatchCall) (request)
2419#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2420#[serde_with::serde_as]
2421#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2422pub struct WorkerPool {
2423 /// User specified annotations. See https://google.aip.dev/128#annotations for more details such as format and size limitations.
2424 pub annotations: Option<HashMap<String, String>>,
2425 /// Output only. Time at which the request to create the `WorkerPool` was received.
2426 #[serde(rename = "createTime")]
2427 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2428 /// Output only. Time at which the request to delete the `WorkerPool` was received.
2429 #[serde(rename = "deleteTime")]
2430 pub delete_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2431 /// A user-specified, human-readable name for the `WorkerPool`. If provided, this value must be 1-63 characters.
2432 #[serde(rename = "displayName")]
2433 pub display_name: Option<String>,
2434 /// Output only. Checksum computed by the server. May be sent on update and delete requests to ensure that the client has an up-to-date value before proceeding.
2435 pub etag: Option<String>,
2436 /// Output only. The resource name of the `WorkerPool`, with format `projects/{project}/locations/{location}/workerPools/{worker_pool}`. The value of `{worker_pool}` is provided by `worker_pool_id` in `CreateWorkerPool` request and the value of `{location}` is determined by the endpoint accessed.
2437 pub name: Option<String>,
2438 /// Legacy Private Pool configuration.
2439 #[serde(rename = "privatePoolV1Config")]
2440 pub private_pool_v1_config: Option<PrivatePoolV1Config>,
2441 /// Output only. `WorkerPool` state.
2442 pub state: Option<String>,
2443 /// Output only. A unique identifier for the `WorkerPool`.
2444 pub uid: Option<String>,
2445 /// Output only. Time at which the request to update the `WorkerPool` was received.
2446 #[serde(rename = "updateTime")]
2447 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2448}
2449
2450impl common::RequestValue for WorkerPool {}
2451impl common::ResponseResult for WorkerPool {}
2452
2453// ###################
2454// MethodBuilders ###
2455// #################
2456
2457/// A builder providing access to all methods supported on *githubDotComWebhook* resources.
2458/// It is not used directly, but through the [`CloudBuild`] hub.
2459///
2460/// # Example
2461///
2462/// Instantiate a resource builder
2463///
2464/// ```test_harness,no_run
2465/// extern crate hyper;
2466/// extern crate hyper_rustls;
2467/// extern crate google_cloudbuild1 as cloudbuild1;
2468///
2469/// # async fn dox() {
2470/// use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2471///
2472/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2473/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2474/// secret,
2475/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2476/// ).build().await.unwrap();
2477///
2478/// let client = hyper_util::client::legacy::Client::builder(
2479/// hyper_util::rt::TokioExecutor::new()
2480/// )
2481/// .build(
2482/// hyper_rustls::HttpsConnectorBuilder::new()
2483/// .with_native_roots()
2484/// .unwrap()
2485/// .https_or_http()
2486/// .enable_http1()
2487/// .build()
2488/// );
2489/// let mut hub = CloudBuild::new(client, auth);
2490/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2491/// // like `receive(...)`
2492/// // to build up your call.
2493/// let rb = hub.github_dot_com_webhook();
2494/// # }
2495/// ```
2496pub struct GithubDotComWebhookMethods<'a, C>
2497where
2498 C: 'a,
2499{
2500 hub: &'a CloudBuild<C>,
2501}
2502
2503impl<'a, C> common::MethodsBuilder for GithubDotComWebhookMethods<'a, C> {}
2504
2505impl<'a, C> GithubDotComWebhookMethods<'a, C> {
2506 /// Create a builder to help you perform the following task:
2507 ///
2508 /// ReceiveGitHubDotComWebhook is called when the API receives a github.com webhook.
2509 ///
2510 /// # Arguments
2511 ///
2512 /// * `request` - No description provided.
2513 pub fn receive(&self, request: HttpBody) -> GithubDotComWebhookReceiveCall<'a, C> {
2514 GithubDotComWebhookReceiveCall {
2515 hub: self.hub,
2516 _request: request,
2517 _webhook_key: Default::default(),
2518 _delegate: Default::default(),
2519 _additional_params: Default::default(),
2520 }
2521 }
2522}
2523
2524/// A builder providing access to all methods supported on *location* resources.
2525/// It is not used directly, but through the [`CloudBuild`] hub.
2526///
2527/// # Example
2528///
2529/// Instantiate a resource builder
2530///
2531/// ```test_harness,no_run
2532/// extern crate hyper;
2533/// extern crate hyper_rustls;
2534/// extern crate google_cloudbuild1 as cloudbuild1;
2535///
2536/// # async fn dox() {
2537/// use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2538///
2539/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2540/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2541/// secret,
2542/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2543/// ).build().await.unwrap();
2544///
2545/// let client = hyper_util::client::legacy::Client::builder(
2546/// hyper_util::rt::TokioExecutor::new()
2547/// )
2548/// .build(
2549/// hyper_rustls::HttpsConnectorBuilder::new()
2550/// .with_native_roots()
2551/// .unwrap()
2552/// .https_or_http()
2553/// .enable_http1()
2554/// .build()
2555/// );
2556/// let mut hub = CloudBuild::new(client, auth);
2557/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2558/// // like `regional_webhook(...)`
2559/// // to build up your call.
2560/// let rb = hub.locations();
2561/// # }
2562/// ```
2563pub struct LocationMethods<'a, C>
2564where
2565 C: 'a,
2566{
2567 hub: &'a CloudBuild<C>,
2568}
2569
2570impl<'a, C> common::MethodsBuilder for LocationMethods<'a, C> {}
2571
2572impl<'a, C> LocationMethods<'a, C> {
2573 /// Create a builder to help you perform the following task:
2574 ///
2575 /// ReceiveRegionalWebhook is called when the API receives a regional GitHub webhook.
2576 ///
2577 /// # Arguments
2578 ///
2579 /// * `request` - No description provided.
2580 /// * `location` - Required. The location where the webhook should be sent.
2581 pub fn regional_webhook(
2582 &self,
2583 request: HttpBody,
2584 location: &str,
2585 ) -> LocationRegionalWebhookCall<'a, C> {
2586 LocationRegionalWebhookCall {
2587 hub: self.hub,
2588 _request: request,
2589 _location: location.to_string(),
2590 _webhook_key: Default::default(),
2591 _delegate: Default::default(),
2592 _additional_params: Default::default(),
2593 }
2594 }
2595}
2596
2597/// A builder providing access to all methods supported on *operation* resources.
2598/// It is not used directly, but through the [`CloudBuild`] hub.
2599///
2600/// # Example
2601///
2602/// Instantiate a resource builder
2603///
2604/// ```test_harness,no_run
2605/// extern crate hyper;
2606/// extern crate hyper_rustls;
2607/// extern crate google_cloudbuild1 as cloudbuild1;
2608///
2609/// # async fn dox() {
2610/// use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2611///
2612/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2613/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2614/// secret,
2615/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2616/// ).build().await.unwrap();
2617///
2618/// let client = hyper_util::client::legacy::Client::builder(
2619/// hyper_util::rt::TokioExecutor::new()
2620/// )
2621/// .build(
2622/// hyper_rustls::HttpsConnectorBuilder::new()
2623/// .with_native_roots()
2624/// .unwrap()
2625/// .https_or_http()
2626/// .enable_http1()
2627/// .build()
2628/// );
2629/// let mut hub = CloudBuild::new(client, auth);
2630/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2631/// // like `cancel(...)` and `get(...)`
2632/// // to build up your call.
2633/// let rb = hub.operations();
2634/// # }
2635/// ```
2636pub struct OperationMethods<'a, C>
2637where
2638 C: 'a,
2639{
2640 hub: &'a CloudBuild<C>,
2641}
2642
2643impl<'a, C> common::MethodsBuilder for OperationMethods<'a, C> {}
2644
2645impl<'a, C> OperationMethods<'a, C> {
2646 /// Create a builder to help you perform the following task:
2647 ///
2648 /// Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of 1, corresponding to `Code.CANCELLED`.
2649 ///
2650 /// # Arguments
2651 ///
2652 /// * `request` - No description provided.
2653 /// * `name` - The name of the operation resource to be cancelled.
2654 pub fn cancel(
2655 &self,
2656 request: CancelOperationRequest,
2657 name: &str,
2658 ) -> OperationCancelCall<'a, C> {
2659 OperationCancelCall {
2660 hub: self.hub,
2661 _request: request,
2662 _name: name.to_string(),
2663 _delegate: Default::default(),
2664 _additional_params: Default::default(),
2665 _scopes: Default::default(),
2666 }
2667 }
2668
2669 /// Create a builder to help you perform the following task:
2670 ///
2671 /// Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
2672 ///
2673 /// # Arguments
2674 ///
2675 /// * `name` - The name of the operation resource.
2676 pub fn get(&self, name: &str) -> OperationGetCall<'a, C> {
2677 OperationGetCall {
2678 hub: self.hub,
2679 _name: name.to_string(),
2680 _delegate: Default::default(),
2681 _additional_params: Default::default(),
2682 _scopes: Default::default(),
2683 }
2684 }
2685}
2686
2687/// A builder providing access to all methods supported on *project* resources.
2688/// It is not used directly, but through the [`CloudBuild`] hub.
2689///
2690/// # Example
2691///
2692/// Instantiate a resource builder
2693///
2694/// ```test_harness,no_run
2695/// extern crate hyper;
2696/// extern crate hyper_rustls;
2697/// extern crate google_cloudbuild1 as cloudbuild1;
2698///
2699/// # async fn dox() {
2700/// use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2701///
2702/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2703/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
2704/// secret,
2705/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2706/// ).build().await.unwrap();
2707///
2708/// let client = hyper_util::client::legacy::Client::builder(
2709/// hyper_util::rt::TokioExecutor::new()
2710/// )
2711/// .build(
2712/// hyper_rustls::HttpsConnectorBuilder::new()
2713/// .with_native_roots()
2714/// .unwrap()
2715/// .https_or_http()
2716/// .enable_http1()
2717/// .build()
2718/// );
2719/// let mut hub = CloudBuild::new(client, auth);
2720/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2721/// // like `builds_approve(...)`, `builds_cancel(...)`, `builds_create(...)`, `builds_get(...)`, `builds_list(...)`, `builds_retry(...)`, `github_enterprise_configs_create(...)`, `github_enterprise_configs_delete(...)`, `github_enterprise_configs_get(...)`, `github_enterprise_configs_list(...)`, `github_enterprise_configs_patch(...)`, `locations_bitbucket_server_configs_connected_repositories_batch_create(...)`, `locations_bitbucket_server_configs_create(...)`, `locations_bitbucket_server_configs_delete(...)`, `locations_bitbucket_server_configs_get(...)`, `locations_bitbucket_server_configs_list(...)`, `locations_bitbucket_server_configs_patch(...)`, `locations_bitbucket_server_configs_remove_bitbucket_server_connected_repository(...)`, `locations_bitbucket_server_configs_repos_list(...)`, `locations_builds_approve(...)`, `locations_builds_cancel(...)`, `locations_builds_create(...)`, `locations_builds_get(...)`, `locations_builds_list(...)`, `locations_builds_retry(...)`, `locations_get_default_service_account(...)`, `locations_git_lab_configs_connected_repositories_batch_create(...)`, `locations_git_lab_configs_create(...)`, `locations_git_lab_configs_delete(...)`, `locations_git_lab_configs_get(...)`, `locations_git_lab_configs_list(...)`, `locations_git_lab_configs_patch(...)`, `locations_git_lab_configs_remove_git_lab_connected_repository(...)`, `locations_git_lab_configs_repos_list(...)`, `locations_github_enterprise_configs_create(...)`, `locations_github_enterprise_configs_delete(...)`, `locations_github_enterprise_configs_get(...)`, `locations_github_enterprise_configs_list(...)`, `locations_github_enterprise_configs_patch(...)`, `locations_operations_cancel(...)`, `locations_operations_get(...)`, `locations_triggers_create(...)`, `locations_triggers_delete(...)`, `locations_triggers_get(...)`, `locations_triggers_list(...)`, `locations_triggers_patch(...)`, `locations_triggers_run(...)`, `locations_triggers_webhook(...)`, `locations_worker_pools_create(...)`, `locations_worker_pools_delete(...)`, `locations_worker_pools_get(...)`, `locations_worker_pools_list(...)`, `locations_worker_pools_patch(...)`, `triggers_create(...)`, `triggers_delete(...)`, `triggers_get(...)`, `triggers_list(...)`, `triggers_patch(...)`, `triggers_run(...)` and `triggers_webhook(...)`
2722/// // to build up your call.
2723/// let rb = hub.projects();
2724/// # }
2725/// ```
2726pub struct ProjectMethods<'a, C>
2727where
2728 C: 'a,
2729{
2730 hub: &'a CloudBuild<C>,
2731}
2732
2733impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
2734
2735impl<'a, C> ProjectMethods<'a, C> {
2736 /// Create a builder to help you perform the following task:
2737 ///
2738 /// Approves or rejects a pending build. If approved, the returned LRO will be analogous to the LRO returned from a CreateBuild call. If rejected, the returned LRO will be immediately done.
2739 ///
2740 /// # Arguments
2741 ///
2742 /// * `request` - No description provided.
2743 /// * `name` - Required. Name of the target build. For example: "projects/{$project_id}/builds/{$build_id}"
2744 pub fn builds_approve(
2745 &self,
2746 request: ApproveBuildRequest,
2747 name: &str,
2748 ) -> ProjectBuildApproveCall<'a, C> {
2749 ProjectBuildApproveCall {
2750 hub: self.hub,
2751 _request: request,
2752 _name: name.to_string(),
2753 _delegate: Default::default(),
2754 _additional_params: Default::default(),
2755 _scopes: Default::default(),
2756 }
2757 }
2758
2759 /// Create a builder to help you perform the following task:
2760 ///
2761 /// Cancels a build in progress.
2762 ///
2763 /// # Arguments
2764 ///
2765 /// * `request` - No description provided.
2766 /// * `projectId` - Required. ID of the project.
2767 /// * `id` - Required. ID of the build.
2768 pub fn builds_cancel(
2769 &self,
2770 request: CancelBuildRequest,
2771 project_id: &str,
2772 id: &str,
2773 ) -> ProjectBuildCancelCall<'a, C> {
2774 ProjectBuildCancelCall {
2775 hub: self.hub,
2776 _request: request,
2777 _project_id: project_id.to_string(),
2778 _id: id.to_string(),
2779 _delegate: Default::default(),
2780 _additional_params: Default::default(),
2781 _scopes: Default::default(),
2782 }
2783 }
2784
2785 /// Create a builder to help you perform the following task:
2786 ///
2787 /// Starts a build with the specified configuration. This method returns a long-running `Operation`, which includes the build ID. Pass the build ID to `GetBuild` to determine the build status (such as `SUCCESS` or `FAILURE`).
2788 ///
2789 /// # Arguments
2790 ///
2791 /// * `request` - No description provided.
2792 /// * `projectId` - Required. ID of the project.
2793 pub fn builds_create(&self, request: Build, project_id: &str) -> ProjectBuildCreateCall<'a, C> {
2794 ProjectBuildCreateCall {
2795 hub: self.hub,
2796 _request: request,
2797 _project_id: project_id.to_string(),
2798 _parent: Default::default(),
2799 _delegate: Default::default(),
2800 _additional_params: Default::default(),
2801 _scopes: Default::default(),
2802 }
2803 }
2804
2805 /// Create a builder to help you perform the following task:
2806 ///
2807 /// Returns information about a previously requested build. The `Build` that is returned includes its status (such as `SUCCESS`, `FAILURE`, or `WORKING`), and timing information.
2808 ///
2809 /// # Arguments
2810 ///
2811 /// * `projectId` - Required. ID of the project.
2812 /// * `id` - Required. ID of the build.
2813 pub fn builds_get(&self, project_id: &str, id: &str) -> ProjectBuildGetCall<'a, C> {
2814 ProjectBuildGetCall {
2815 hub: self.hub,
2816 _project_id: project_id.to_string(),
2817 _id: id.to_string(),
2818 _name: Default::default(),
2819 _delegate: Default::default(),
2820 _additional_params: Default::default(),
2821 _scopes: Default::default(),
2822 }
2823 }
2824
2825 /// Create a builder to help you perform the following task:
2826 ///
2827 /// Lists previously requested builds. Previously requested builds may still be in-progress, or may have finished successfully or unsuccessfully.
2828 ///
2829 /// # Arguments
2830 ///
2831 /// * `projectId` - Required. ID of the project.
2832 pub fn builds_list(&self, project_id: &str) -> ProjectBuildListCall<'a, C> {
2833 ProjectBuildListCall {
2834 hub: self.hub,
2835 _project_id: project_id.to_string(),
2836 _parent: Default::default(),
2837 _page_token: Default::default(),
2838 _page_size: Default::default(),
2839 _filter: Default::default(),
2840 _delegate: Default::default(),
2841 _additional_params: Default::default(),
2842 _scopes: Default::default(),
2843 }
2844 }
2845
2846 /// Create a builder to help you perform the following task:
2847 ///
2848 /// Creates a new build based on the specified build. This method creates a new build using the original build request, which may or may not result in an identical build. For triggered builds: * Triggered builds resolve to a precise revision; therefore a retry of a triggered build will result in a build that uses the same revision. For non-triggered builds that specify `RepoSource`: * If the original build built from the tip of a branch, the retried build will build from the tip of that branch, which may not be the same revision as the original build. * If the original build specified a commit sha or revision ID, the retried build will use the identical source. For builds that specify `StorageSource`: * If the original build pulled source from Cloud Storage without specifying the generation of the object, the new build will use the current object, which may be different from the original build source. * If the original build pulled source from Cloud Storage and specified the generation of the object, the new build will attempt to use the same object, which may or may not be available depending on the bucket's lifecycle management settings.
2849 ///
2850 /// # Arguments
2851 ///
2852 /// * `request` - No description provided.
2853 /// * `projectId` - Required. ID of the project.
2854 /// * `id` - Required. Build ID of the original build.
2855 pub fn builds_retry(
2856 &self,
2857 request: RetryBuildRequest,
2858 project_id: &str,
2859 id: &str,
2860 ) -> ProjectBuildRetryCall<'a, C> {
2861 ProjectBuildRetryCall {
2862 hub: self.hub,
2863 _request: request,
2864 _project_id: project_id.to_string(),
2865 _id: id.to_string(),
2866 _delegate: Default::default(),
2867 _additional_params: Default::default(),
2868 _scopes: Default::default(),
2869 }
2870 }
2871
2872 /// Create a builder to help you perform the following task:
2873 ///
2874 /// Create an association between a GCP project and a GitHub Enterprise server.
2875 ///
2876 /// # Arguments
2877 ///
2878 /// * `request` - No description provided.
2879 /// * `parent` - Required. Name of the parent project. For example: projects/{$project_number} or projects/{$project_id}
2880 pub fn github_enterprise_configs_create(
2881 &self,
2882 request: GitHubEnterpriseConfig,
2883 parent: &str,
2884 ) -> ProjectGithubEnterpriseConfigCreateCall<'a, C> {
2885 ProjectGithubEnterpriseConfigCreateCall {
2886 hub: self.hub,
2887 _request: request,
2888 _parent: parent.to_string(),
2889 _project_id: Default::default(),
2890 _ghe_config_id: Default::default(),
2891 _delegate: Default::default(),
2892 _additional_params: Default::default(),
2893 _scopes: Default::default(),
2894 }
2895 }
2896
2897 /// Create a builder to help you perform the following task:
2898 ///
2899 /// Delete an association between a GCP project and a GitHub Enterprise server.
2900 ///
2901 /// # Arguments
2902 ///
2903 /// * `name` - This field should contain the name of the enterprise config resource. For example: "projects/{$project_id}/locations/{$location_id}/githubEnterpriseConfigs/{$config_id}"
2904 pub fn github_enterprise_configs_delete(
2905 &self,
2906 name: &str,
2907 ) -> ProjectGithubEnterpriseConfigDeleteCall<'a, C> {
2908 ProjectGithubEnterpriseConfigDeleteCall {
2909 hub: self.hub,
2910 _name: name.to_string(),
2911 _project_id: Default::default(),
2912 _config_id: Default::default(),
2913 _delegate: Default::default(),
2914 _additional_params: Default::default(),
2915 _scopes: Default::default(),
2916 }
2917 }
2918
2919 /// Create a builder to help you perform the following task:
2920 ///
2921 /// Retrieve a GitHubEnterpriseConfig.
2922 ///
2923 /// # Arguments
2924 ///
2925 /// * `name` - This field should contain the name of the enterprise config resource. For example: "projects/{$project_id}/locations/{$location_id}/githubEnterpriseConfigs/{$config_id}"
2926 pub fn github_enterprise_configs_get(
2927 &self,
2928 name: &str,
2929 ) -> ProjectGithubEnterpriseConfigGetCall<'a, C> {
2930 ProjectGithubEnterpriseConfigGetCall {
2931 hub: self.hub,
2932 _name: name.to_string(),
2933 _project_id: Default::default(),
2934 _config_id: Default::default(),
2935 _delegate: Default::default(),
2936 _additional_params: Default::default(),
2937 _scopes: Default::default(),
2938 }
2939 }
2940
2941 /// Create a builder to help you perform the following task:
2942 ///
2943 /// List all GitHubEnterpriseConfigs for a given project.
2944 ///
2945 /// # Arguments
2946 ///
2947 /// * `parent` - Name of the parent project. For example: projects/{$project_number} or projects/{$project_id}
2948 pub fn github_enterprise_configs_list(
2949 &self,
2950 parent: &str,
2951 ) -> ProjectGithubEnterpriseConfigListCall<'a, C> {
2952 ProjectGithubEnterpriseConfigListCall {
2953 hub: self.hub,
2954 _parent: parent.to_string(),
2955 _project_id: Default::default(),
2956 _delegate: Default::default(),
2957 _additional_params: Default::default(),
2958 _scopes: Default::default(),
2959 }
2960 }
2961
2962 /// Create a builder to help you perform the following task:
2963 ///
2964 /// Update an association between a GCP project and a GitHub Enterprise server.
2965 ///
2966 /// # Arguments
2967 ///
2968 /// * `request` - No description provided.
2969 /// * `name` - The full resource name for the GitHubEnterpriseConfig For example: "projects/{$project_id}/locations/{$location_id}/githubEnterpriseConfigs/{$config_id}"
2970 pub fn github_enterprise_configs_patch(
2971 &self,
2972 request: GitHubEnterpriseConfig,
2973 name: &str,
2974 ) -> ProjectGithubEnterpriseConfigPatchCall<'a, C> {
2975 ProjectGithubEnterpriseConfigPatchCall {
2976 hub: self.hub,
2977 _request: request,
2978 _name: name.to_string(),
2979 _update_mask: Default::default(),
2980 _delegate: Default::default(),
2981 _additional_params: Default::default(),
2982 _scopes: Default::default(),
2983 }
2984 }
2985
2986 /// Create a builder to help you perform the following task:
2987 ///
2988 /// Batch connecting Bitbucket Server repositories to Cloud Build.
2989 ///
2990 /// # Arguments
2991 ///
2992 /// * `request` - No description provided.
2993 /// * `parent` - The name of the `BitbucketServerConfig` that added connected repository. Format: `projects/{project}/locations/{location}/bitbucketServerConfigs/{config}`
2994 pub fn locations_bitbucket_server_configs_connected_repositories_batch_create(
2995 &self,
2996 request: BatchCreateBitbucketServerConnectedRepositoriesRequest,
2997 parent: &str,
2998 ) -> ProjectLocationBitbucketServerConfigConnectedRepositoryBatchCreateCall<'a, C> {
2999 ProjectLocationBitbucketServerConfigConnectedRepositoryBatchCreateCall {
3000 hub: self.hub,
3001 _request: request,
3002 _parent: parent.to_string(),
3003 _delegate: Default::default(),
3004 _additional_params: Default::default(),
3005 _scopes: Default::default(),
3006 }
3007 }
3008
3009 /// Create a builder to help you perform the following task:
3010 ///
3011 /// List all repositories for a given `BitbucketServerConfig`. This API is experimental.
3012 ///
3013 /// # Arguments
3014 ///
3015 /// * `parent` - Required. Name of the parent resource.
3016 pub fn locations_bitbucket_server_configs_repos_list(
3017 &self,
3018 parent: &str,
3019 ) -> ProjectLocationBitbucketServerConfigRepoListCall<'a, C> {
3020 ProjectLocationBitbucketServerConfigRepoListCall {
3021 hub: self.hub,
3022 _parent: parent.to_string(),
3023 _page_token: Default::default(),
3024 _page_size: Default::default(),
3025 _delegate: Default::default(),
3026 _additional_params: Default::default(),
3027 _scopes: Default::default(),
3028 }
3029 }
3030
3031 /// Create a builder to help you perform the following task:
3032 ///
3033 /// Creates a new `BitbucketServerConfig`. This API is experimental.
3034 ///
3035 /// # Arguments
3036 ///
3037 /// * `request` - No description provided.
3038 /// * `parent` - Required. Name of the parent resource.
3039 pub fn locations_bitbucket_server_configs_create(
3040 &self,
3041 request: BitbucketServerConfig,
3042 parent: &str,
3043 ) -> ProjectLocationBitbucketServerConfigCreateCall<'a, C> {
3044 ProjectLocationBitbucketServerConfigCreateCall {
3045 hub: self.hub,
3046 _request: request,
3047 _parent: parent.to_string(),
3048 _bitbucket_server_config_id: Default::default(),
3049 _delegate: Default::default(),
3050 _additional_params: Default::default(),
3051 _scopes: Default::default(),
3052 }
3053 }
3054
3055 /// Create a builder to help you perform the following task:
3056 ///
3057 /// Delete a `BitbucketServerConfig`. This API is experimental.
3058 ///
3059 /// # Arguments
3060 ///
3061 /// * `name` - Required. The config resource name.
3062 pub fn locations_bitbucket_server_configs_delete(
3063 &self,
3064 name: &str,
3065 ) -> ProjectLocationBitbucketServerConfigDeleteCall<'a, C> {
3066 ProjectLocationBitbucketServerConfigDeleteCall {
3067 hub: self.hub,
3068 _name: name.to_string(),
3069 _delegate: Default::default(),
3070 _additional_params: Default::default(),
3071 _scopes: Default::default(),
3072 }
3073 }
3074
3075 /// Create a builder to help you perform the following task:
3076 ///
3077 /// Retrieve a `BitbucketServerConfig`. This API is experimental.
3078 ///
3079 /// # Arguments
3080 ///
3081 /// * `name` - Required. The config resource name.
3082 pub fn locations_bitbucket_server_configs_get(
3083 &self,
3084 name: &str,
3085 ) -> ProjectLocationBitbucketServerConfigGetCall<'a, C> {
3086 ProjectLocationBitbucketServerConfigGetCall {
3087 hub: self.hub,
3088 _name: name.to_string(),
3089 _delegate: Default::default(),
3090 _additional_params: Default::default(),
3091 _scopes: Default::default(),
3092 }
3093 }
3094
3095 /// Create a builder to help you perform the following task:
3096 ///
3097 /// List all `BitbucketServerConfigs` for a given project. This API is experimental.
3098 ///
3099 /// # Arguments
3100 ///
3101 /// * `parent` - Required. Name of the parent resource.
3102 pub fn locations_bitbucket_server_configs_list(
3103 &self,
3104 parent: &str,
3105 ) -> ProjectLocationBitbucketServerConfigListCall<'a, C> {
3106 ProjectLocationBitbucketServerConfigListCall {
3107 hub: self.hub,
3108 _parent: parent.to_string(),
3109 _page_token: Default::default(),
3110 _page_size: Default::default(),
3111 _delegate: Default::default(),
3112 _additional_params: Default::default(),
3113 _scopes: Default::default(),
3114 }
3115 }
3116
3117 /// Create a builder to help you perform the following task:
3118 ///
3119 /// Updates an existing `BitbucketServerConfig`. This API is experimental.
3120 ///
3121 /// # Arguments
3122 ///
3123 /// * `request` - No description provided.
3124 /// * `name` - The resource name for the config.
3125 pub fn locations_bitbucket_server_configs_patch(
3126 &self,
3127 request: BitbucketServerConfig,
3128 name: &str,
3129 ) -> ProjectLocationBitbucketServerConfigPatchCall<'a, C> {
3130 ProjectLocationBitbucketServerConfigPatchCall {
3131 hub: self.hub,
3132 _request: request,
3133 _name: name.to_string(),
3134 _update_mask: Default::default(),
3135 _delegate: Default::default(),
3136 _additional_params: Default::default(),
3137 _scopes: Default::default(),
3138 }
3139 }
3140
3141 /// Create a builder to help you perform the following task:
3142 ///
3143 /// Remove a Bitbucket Server repository from a given BitbucketServerConfig's connected repositories. This API is experimental.
3144 ///
3145 /// # Arguments
3146 ///
3147 /// * `request` - No description provided.
3148 /// * `config` - Required. The name of the `BitbucketServerConfig` to remove a connected repository. Format: `projects/{project}/locations/{location}/bitbucketServerConfigs/{config}`
3149 pub fn locations_bitbucket_server_configs_remove_bitbucket_server_connected_repository(
3150 &self,
3151 request: RemoveBitbucketServerConnectedRepositoryRequest,
3152 config: &str,
3153 ) -> ProjectLocationBitbucketServerConfigRemoveBitbucketServerConnectedRepositoryCall<'a, C>
3154 {
3155 ProjectLocationBitbucketServerConfigRemoveBitbucketServerConnectedRepositoryCall {
3156 hub: self.hub,
3157 _request: request,
3158 _config: config.to_string(),
3159 _delegate: Default::default(),
3160 _additional_params: Default::default(),
3161 _scopes: Default::default(),
3162 }
3163 }
3164
3165 /// Create a builder to help you perform the following task:
3166 ///
3167 /// Approves or rejects a pending build. If approved, the returned LRO will be analogous to the LRO returned from a CreateBuild call. If rejected, the returned LRO will be immediately done.
3168 ///
3169 /// # Arguments
3170 ///
3171 /// * `request` - No description provided.
3172 /// * `name` - Required. Name of the target build. For example: "projects/{$project_id}/builds/{$build_id}"
3173 pub fn locations_builds_approve(
3174 &self,
3175 request: ApproveBuildRequest,
3176 name: &str,
3177 ) -> ProjectLocationBuildApproveCall<'a, C> {
3178 ProjectLocationBuildApproveCall {
3179 hub: self.hub,
3180 _request: request,
3181 _name: name.to_string(),
3182 _delegate: Default::default(),
3183 _additional_params: Default::default(),
3184 _scopes: Default::default(),
3185 }
3186 }
3187
3188 /// Create a builder to help you perform the following task:
3189 ///
3190 /// Cancels a build in progress.
3191 ///
3192 /// # Arguments
3193 ///
3194 /// * `request` - No description provided.
3195 /// * `name` - The name of the `Build` to cancel. Format: `projects/{project}/locations/{location}/builds/{build}`
3196 pub fn locations_builds_cancel(
3197 &self,
3198 request: CancelBuildRequest,
3199 name: &str,
3200 ) -> ProjectLocationBuildCancelCall<'a, C> {
3201 ProjectLocationBuildCancelCall {
3202 hub: self.hub,
3203 _request: request,
3204 _name: name.to_string(),
3205 _delegate: Default::default(),
3206 _additional_params: Default::default(),
3207 _scopes: Default::default(),
3208 }
3209 }
3210
3211 /// Create a builder to help you perform the following task:
3212 ///
3213 /// Starts a build with the specified configuration. This method returns a long-running `Operation`, which includes the build ID. Pass the build ID to `GetBuild` to determine the build status (such as `SUCCESS` or `FAILURE`).
3214 ///
3215 /// # Arguments
3216 ///
3217 /// * `request` - No description provided.
3218 /// * `parent` - The parent resource where this build will be created. Format: `projects/{project}/locations/{location}`
3219 pub fn locations_builds_create(
3220 &self,
3221 request: Build,
3222 parent: &str,
3223 ) -> ProjectLocationBuildCreateCall<'a, C> {
3224 ProjectLocationBuildCreateCall {
3225 hub: self.hub,
3226 _request: request,
3227 _parent: parent.to_string(),
3228 _project_id: Default::default(),
3229 _delegate: Default::default(),
3230 _additional_params: Default::default(),
3231 _scopes: Default::default(),
3232 }
3233 }
3234
3235 /// Create a builder to help you perform the following task:
3236 ///
3237 /// Returns information about a previously requested build. The `Build` that is returned includes its status (such as `SUCCESS`, `FAILURE`, or `WORKING`), and timing information.
3238 ///
3239 /// # Arguments
3240 ///
3241 /// * `name` - The name of the `Build` to retrieve. Format: `projects/{project}/locations/{location}/builds/{build}`
3242 pub fn locations_builds_get(&self, name: &str) -> ProjectLocationBuildGetCall<'a, C> {
3243 ProjectLocationBuildGetCall {
3244 hub: self.hub,
3245 _name: name.to_string(),
3246 _project_id: Default::default(),
3247 _id: Default::default(),
3248 _delegate: Default::default(),
3249 _additional_params: Default::default(),
3250 _scopes: Default::default(),
3251 }
3252 }
3253
3254 /// Create a builder to help you perform the following task:
3255 ///
3256 /// Lists previously requested builds. Previously requested builds may still be in-progress, or may have finished successfully or unsuccessfully.
3257 ///
3258 /// # Arguments
3259 ///
3260 /// * `parent` - The parent of the collection of `Builds`. Format: `projects/{project}/locations/{location}`
3261 pub fn locations_builds_list(&self, parent: &str) -> ProjectLocationBuildListCall<'a, C> {
3262 ProjectLocationBuildListCall {
3263 hub: self.hub,
3264 _parent: parent.to_string(),
3265 _project_id: Default::default(),
3266 _page_token: Default::default(),
3267 _page_size: Default::default(),
3268 _filter: Default::default(),
3269 _delegate: Default::default(),
3270 _additional_params: Default::default(),
3271 _scopes: Default::default(),
3272 }
3273 }
3274
3275 /// Create a builder to help you perform the following task:
3276 ///
3277 /// Creates a new build based on the specified build. This method creates a new build using the original build request, which may or may not result in an identical build. For triggered builds: * Triggered builds resolve to a precise revision; therefore a retry of a triggered build will result in a build that uses the same revision. For non-triggered builds that specify `RepoSource`: * If the original build built from the tip of a branch, the retried build will build from the tip of that branch, which may not be the same revision as the original build. * If the original build specified a commit sha or revision ID, the retried build will use the identical source. For builds that specify `StorageSource`: * If the original build pulled source from Cloud Storage without specifying the generation of the object, the new build will use the current object, which may be different from the original build source. * If the original build pulled source from Cloud Storage and specified the generation of the object, the new build will attempt to use the same object, which may or may not be available depending on the bucket's lifecycle management settings.
3278 ///
3279 /// # Arguments
3280 ///
3281 /// * `request` - No description provided.
3282 /// * `name` - The name of the `Build` to retry. Format: `projects/{project}/locations/{location}/builds/{build}`
3283 pub fn locations_builds_retry(
3284 &self,
3285 request: RetryBuildRequest,
3286 name: &str,
3287 ) -> ProjectLocationBuildRetryCall<'a, C> {
3288 ProjectLocationBuildRetryCall {
3289 hub: self.hub,
3290 _request: request,
3291 _name: name.to_string(),
3292 _delegate: Default::default(),
3293 _additional_params: Default::default(),
3294 _scopes: Default::default(),
3295 }
3296 }
3297
3298 /// Create a builder to help you perform the following task:
3299 ///
3300 /// Batch connecting GitLab repositories to Cloud Build. This API is experimental.
3301 ///
3302 /// # Arguments
3303 ///
3304 /// * `request` - No description provided.
3305 /// * `parent` - The name of the `GitLabConfig` that adds connected repositories. Format: `projects/{project}/locations/{location}/gitLabConfigs/{config}`
3306 pub fn locations_git_lab_configs_connected_repositories_batch_create(
3307 &self,
3308 request: BatchCreateGitLabConnectedRepositoriesRequest,
3309 parent: &str,
3310 ) -> ProjectLocationGitLabConfigConnectedRepositoryBatchCreateCall<'a, C> {
3311 ProjectLocationGitLabConfigConnectedRepositoryBatchCreateCall {
3312 hub: self.hub,
3313 _request: request,
3314 _parent: parent.to_string(),
3315 _delegate: Default::default(),
3316 _additional_params: Default::default(),
3317 _scopes: Default::default(),
3318 }
3319 }
3320
3321 /// Create a builder to help you perform the following task:
3322 ///
3323 /// List all repositories for a given `GitLabConfig`. This API is experimental
3324 ///
3325 /// # Arguments
3326 ///
3327 /// * `parent` - Required. Name of the parent resource.
3328 pub fn locations_git_lab_configs_repos_list(
3329 &self,
3330 parent: &str,
3331 ) -> ProjectLocationGitLabConfigRepoListCall<'a, C> {
3332 ProjectLocationGitLabConfigRepoListCall {
3333 hub: self.hub,
3334 _parent: parent.to_string(),
3335 _page_token: Default::default(),
3336 _page_size: Default::default(),
3337 _delegate: Default::default(),
3338 _additional_params: Default::default(),
3339 _scopes: Default::default(),
3340 }
3341 }
3342
3343 /// Create a builder to help you perform the following task:
3344 ///
3345 /// Creates a new `GitLabConfig`. This API is experimental
3346 ///
3347 /// # Arguments
3348 ///
3349 /// * `request` - No description provided.
3350 /// * `parent` - Required. Name of the parent resource.
3351 pub fn locations_git_lab_configs_create(
3352 &self,
3353 request: GitLabConfig,
3354 parent: &str,
3355 ) -> ProjectLocationGitLabConfigCreateCall<'a, C> {
3356 ProjectLocationGitLabConfigCreateCall {
3357 hub: self.hub,
3358 _request: request,
3359 _parent: parent.to_string(),
3360 _gitlab_config_id: Default::default(),
3361 _delegate: Default::default(),
3362 _additional_params: Default::default(),
3363 _scopes: Default::default(),
3364 }
3365 }
3366
3367 /// Create a builder to help you perform the following task:
3368 ///
3369 /// Delete a `GitLabConfig`. This API is experimental
3370 ///
3371 /// # Arguments
3372 ///
3373 /// * `name` - Required. The config resource name.
3374 pub fn locations_git_lab_configs_delete(
3375 &self,
3376 name: &str,
3377 ) -> ProjectLocationGitLabConfigDeleteCall<'a, C> {
3378 ProjectLocationGitLabConfigDeleteCall {
3379 hub: self.hub,
3380 _name: name.to_string(),
3381 _delegate: Default::default(),
3382 _additional_params: Default::default(),
3383 _scopes: Default::default(),
3384 }
3385 }
3386
3387 /// Create a builder to help you perform the following task:
3388 ///
3389 /// Retrieves a `GitLabConfig`. This API is experimental
3390 ///
3391 /// # Arguments
3392 ///
3393 /// * `name` - Required. The config resource name.
3394 pub fn locations_git_lab_configs_get(
3395 &self,
3396 name: &str,
3397 ) -> ProjectLocationGitLabConfigGetCall<'a, C> {
3398 ProjectLocationGitLabConfigGetCall {
3399 hub: self.hub,
3400 _name: name.to_string(),
3401 _delegate: Default::default(),
3402 _additional_params: Default::default(),
3403 _scopes: Default::default(),
3404 }
3405 }
3406
3407 /// Create a builder to help you perform the following task:
3408 ///
3409 /// List all `GitLabConfigs` for a given project. This API is experimental
3410 ///
3411 /// # Arguments
3412 ///
3413 /// * `parent` - Required. Name of the parent resource
3414 pub fn locations_git_lab_configs_list(
3415 &self,
3416 parent: &str,
3417 ) -> ProjectLocationGitLabConfigListCall<'a, C> {
3418 ProjectLocationGitLabConfigListCall {
3419 hub: self.hub,
3420 _parent: parent.to_string(),
3421 _page_token: Default::default(),
3422 _page_size: Default::default(),
3423 _delegate: Default::default(),
3424 _additional_params: Default::default(),
3425 _scopes: Default::default(),
3426 }
3427 }
3428
3429 /// Create a builder to help you perform the following task:
3430 ///
3431 /// Updates an existing `GitLabConfig`. This API is experimental
3432 ///
3433 /// # Arguments
3434 ///
3435 /// * `request` - No description provided.
3436 /// * `name` - The resource name for the config.
3437 pub fn locations_git_lab_configs_patch(
3438 &self,
3439 request: GitLabConfig,
3440 name: &str,
3441 ) -> ProjectLocationGitLabConfigPatchCall<'a, C> {
3442 ProjectLocationGitLabConfigPatchCall {
3443 hub: self.hub,
3444 _request: request,
3445 _name: name.to_string(),
3446 _update_mask: Default::default(),
3447 _delegate: Default::default(),
3448 _additional_params: Default::default(),
3449 _scopes: Default::default(),
3450 }
3451 }
3452
3453 /// Create a builder to help you perform the following task:
3454 ///
3455 /// Remove a GitLab repository from a given GitLabConfig's connected repositories. This API is experimental.
3456 ///
3457 /// # Arguments
3458 ///
3459 /// * `request` - No description provided.
3460 /// * `config` - Required. The name of the `GitLabConfig` to remove a connected repository. Format: `projects/{project}/locations/{location}/gitLabConfigs/{config}`
3461 pub fn locations_git_lab_configs_remove_git_lab_connected_repository(
3462 &self,
3463 request: RemoveGitLabConnectedRepositoryRequest,
3464 config: &str,
3465 ) -> ProjectLocationGitLabConfigRemoveGitLabConnectedRepositoryCall<'a, C> {
3466 ProjectLocationGitLabConfigRemoveGitLabConnectedRepositoryCall {
3467 hub: self.hub,
3468 _request: request,
3469 _config: config.to_string(),
3470 _delegate: Default::default(),
3471 _additional_params: Default::default(),
3472 _scopes: Default::default(),
3473 }
3474 }
3475
3476 /// Create a builder to help you perform the following task:
3477 ///
3478 /// Create an association between a GCP project and a GitHub Enterprise server.
3479 ///
3480 /// # Arguments
3481 ///
3482 /// * `request` - No description provided.
3483 /// * `parent` - Required. Name of the parent project. For example: projects/{$project_number} or projects/{$project_id}
3484 pub fn locations_github_enterprise_configs_create(
3485 &self,
3486 request: GitHubEnterpriseConfig,
3487 parent: &str,
3488 ) -> ProjectLocationGithubEnterpriseConfigCreateCall<'a, C> {
3489 ProjectLocationGithubEnterpriseConfigCreateCall {
3490 hub: self.hub,
3491 _request: request,
3492 _parent: parent.to_string(),
3493 _project_id: Default::default(),
3494 _ghe_config_id: Default::default(),
3495 _delegate: Default::default(),
3496 _additional_params: Default::default(),
3497 _scopes: Default::default(),
3498 }
3499 }
3500
3501 /// Create a builder to help you perform the following task:
3502 ///
3503 /// Delete an association between a GCP project and a GitHub Enterprise server.
3504 ///
3505 /// # Arguments
3506 ///
3507 /// * `name` - This field should contain the name of the enterprise config resource. For example: "projects/{$project_id}/locations/{$location_id}/githubEnterpriseConfigs/{$config_id}"
3508 pub fn locations_github_enterprise_configs_delete(
3509 &self,
3510 name: &str,
3511 ) -> ProjectLocationGithubEnterpriseConfigDeleteCall<'a, C> {
3512 ProjectLocationGithubEnterpriseConfigDeleteCall {
3513 hub: self.hub,
3514 _name: name.to_string(),
3515 _project_id: Default::default(),
3516 _config_id: Default::default(),
3517 _delegate: Default::default(),
3518 _additional_params: Default::default(),
3519 _scopes: Default::default(),
3520 }
3521 }
3522
3523 /// Create a builder to help you perform the following task:
3524 ///
3525 /// Retrieve a GitHubEnterpriseConfig.
3526 ///
3527 /// # Arguments
3528 ///
3529 /// * `name` - This field should contain the name of the enterprise config resource. For example: "projects/{$project_id}/locations/{$location_id}/githubEnterpriseConfigs/{$config_id}"
3530 pub fn locations_github_enterprise_configs_get(
3531 &self,
3532 name: &str,
3533 ) -> ProjectLocationGithubEnterpriseConfigGetCall<'a, C> {
3534 ProjectLocationGithubEnterpriseConfigGetCall {
3535 hub: self.hub,
3536 _name: name.to_string(),
3537 _project_id: Default::default(),
3538 _config_id: Default::default(),
3539 _delegate: Default::default(),
3540 _additional_params: Default::default(),
3541 _scopes: Default::default(),
3542 }
3543 }
3544
3545 /// Create a builder to help you perform the following task:
3546 ///
3547 /// List all GitHubEnterpriseConfigs for a given project.
3548 ///
3549 /// # Arguments
3550 ///
3551 /// * `parent` - Name of the parent project. For example: projects/{$project_number} or projects/{$project_id}
3552 pub fn locations_github_enterprise_configs_list(
3553 &self,
3554 parent: &str,
3555 ) -> ProjectLocationGithubEnterpriseConfigListCall<'a, C> {
3556 ProjectLocationGithubEnterpriseConfigListCall {
3557 hub: self.hub,
3558 _parent: parent.to_string(),
3559 _project_id: Default::default(),
3560 _delegate: Default::default(),
3561 _additional_params: Default::default(),
3562 _scopes: Default::default(),
3563 }
3564 }
3565
3566 /// Create a builder to help you perform the following task:
3567 ///
3568 /// Update an association between a GCP project and a GitHub Enterprise server.
3569 ///
3570 /// # Arguments
3571 ///
3572 /// * `request` - No description provided.
3573 /// * `name` - The full resource name for the GitHubEnterpriseConfig For example: "projects/{$project_id}/locations/{$location_id}/githubEnterpriseConfigs/{$config_id}"
3574 pub fn locations_github_enterprise_configs_patch(
3575 &self,
3576 request: GitHubEnterpriseConfig,
3577 name: &str,
3578 ) -> ProjectLocationGithubEnterpriseConfigPatchCall<'a, C> {
3579 ProjectLocationGithubEnterpriseConfigPatchCall {
3580 hub: self.hub,
3581 _request: request,
3582 _name: name.to_string(),
3583 _update_mask: Default::default(),
3584 _delegate: Default::default(),
3585 _additional_params: Default::default(),
3586 _scopes: Default::default(),
3587 }
3588 }
3589
3590 /// Create a builder to help you perform the following task:
3591 ///
3592 /// Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of 1, corresponding to `Code.CANCELLED`.
3593 ///
3594 /// # Arguments
3595 ///
3596 /// * `request` - No description provided.
3597 /// * `name` - The name of the operation resource to be cancelled.
3598 pub fn locations_operations_cancel(
3599 &self,
3600 request: CancelOperationRequest,
3601 name: &str,
3602 ) -> ProjectLocationOperationCancelCall<'a, C> {
3603 ProjectLocationOperationCancelCall {
3604 hub: self.hub,
3605 _request: request,
3606 _name: name.to_string(),
3607 _delegate: Default::default(),
3608 _additional_params: Default::default(),
3609 _scopes: Default::default(),
3610 }
3611 }
3612
3613 /// Create a builder to help you perform the following task:
3614 ///
3615 /// Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
3616 ///
3617 /// # Arguments
3618 ///
3619 /// * `name` - The name of the operation resource.
3620 pub fn locations_operations_get(&self, name: &str) -> ProjectLocationOperationGetCall<'a, C> {
3621 ProjectLocationOperationGetCall {
3622 hub: self.hub,
3623 _name: name.to_string(),
3624 _delegate: Default::default(),
3625 _additional_params: Default::default(),
3626 _scopes: Default::default(),
3627 }
3628 }
3629
3630 /// Create a builder to help you perform the following task:
3631 ///
3632 /// Creates a new `BuildTrigger`.
3633 ///
3634 /// # Arguments
3635 ///
3636 /// * `request` - No description provided.
3637 /// * `parent` - The parent resource where this trigger will be created. Format: `projects/{project}/locations/{location}`
3638 pub fn locations_triggers_create(
3639 &self,
3640 request: BuildTrigger,
3641 parent: &str,
3642 ) -> ProjectLocationTriggerCreateCall<'a, C> {
3643 ProjectLocationTriggerCreateCall {
3644 hub: self.hub,
3645 _request: request,
3646 _parent: parent.to_string(),
3647 _project_id: Default::default(),
3648 _delegate: Default::default(),
3649 _additional_params: Default::default(),
3650 _scopes: Default::default(),
3651 }
3652 }
3653
3654 /// Create a builder to help you perform the following task:
3655 ///
3656 /// Deletes a `BuildTrigger` by its project ID and trigger ID.
3657 ///
3658 /// # Arguments
3659 ///
3660 /// * `name` - The name of the `Trigger` to delete. Format: `projects/{project}/locations/{location}/triggers/{trigger}`
3661 pub fn locations_triggers_delete(&self, name: &str) -> ProjectLocationTriggerDeleteCall<'a, C> {
3662 ProjectLocationTriggerDeleteCall {
3663 hub: self.hub,
3664 _name: name.to_string(),
3665 _trigger_id: Default::default(),
3666 _project_id: Default::default(),
3667 _delegate: Default::default(),
3668 _additional_params: Default::default(),
3669 _scopes: Default::default(),
3670 }
3671 }
3672
3673 /// Create a builder to help you perform the following task:
3674 ///
3675 /// Returns information about a `BuildTrigger`.
3676 ///
3677 /// # Arguments
3678 ///
3679 /// * `name` - The name of the `Trigger` to retrieve. Format: `projects/{project}/locations/{location}/triggers/{trigger}`
3680 pub fn locations_triggers_get(&self, name: &str) -> ProjectLocationTriggerGetCall<'a, C> {
3681 ProjectLocationTriggerGetCall {
3682 hub: self.hub,
3683 _name: name.to_string(),
3684 _trigger_id: Default::default(),
3685 _project_id: Default::default(),
3686 _delegate: Default::default(),
3687 _additional_params: Default::default(),
3688 _scopes: Default::default(),
3689 }
3690 }
3691
3692 /// Create a builder to help you perform the following task:
3693 ///
3694 /// Lists existing `BuildTrigger`s.
3695 ///
3696 /// # Arguments
3697 ///
3698 /// * `parent` - The parent of the collection of `Triggers`. Format: `projects/{project}/locations/{location}`
3699 pub fn locations_triggers_list(&self, parent: &str) -> ProjectLocationTriggerListCall<'a, C> {
3700 ProjectLocationTriggerListCall {
3701 hub: self.hub,
3702 _parent: parent.to_string(),
3703 _project_id: Default::default(),
3704 _page_token: Default::default(),
3705 _page_size: Default::default(),
3706 _delegate: Default::default(),
3707 _additional_params: Default::default(),
3708 _scopes: Default::default(),
3709 }
3710 }
3711
3712 /// Create a builder to help you perform the following task:
3713 ///
3714 /// Updates a `BuildTrigger` by its project ID and trigger ID.
3715 ///
3716 /// # Arguments
3717 ///
3718 /// * `request` - No description provided.
3719 /// * `resourceName` - The `Trigger` name with format: `projects/{project}/locations/{location}/triggers/{trigger}`, where {trigger} is a unique identifier generated by the service.
3720 pub fn locations_triggers_patch(
3721 &self,
3722 request: BuildTrigger,
3723 resource_name: &str,
3724 ) -> ProjectLocationTriggerPatchCall<'a, C> {
3725 ProjectLocationTriggerPatchCall {
3726 hub: self.hub,
3727 _request: request,
3728 _resource_name: resource_name.to_string(),
3729 _update_mask: Default::default(),
3730 _trigger_id: Default::default(),
3731 _project_id: Default::default(),
3732 _delegate: Default::default(),
3733 _additional_params: Default::default(),
3734 _scopes: Default::default(),
3735 }
3736 }
3737
3738 /// Create a builder to help you perform the following task:
3739 ///
3740 /// Runs a `BuildTrigger` at a particular source revision. To run a regional or global trigger, use the POST request that includes the location endpoint in the path (ex. v1/projects/{projectId}/locations/{region}/triggers/{triggerId}:run). The POST request that does not include the location endpoint in the path can only be used when running global triggers.
3741 ///
3742 /// # Arguments
3743 ///
3744 /// * `request` - No description provided.
3745 /// * `name` - The name of the `Trigger` to run. Format: `projects/{project}/locations/{location}/triggers/{trigger}`
3746 pub fn locations_triggers_run(
3747 &self,
3748 request: RunBuildTriggerRequest,
3749 name: &str,
3750 ) -> ProjectLocationTriggerRunCall<'a, C> {
3751 ProjectLocationTriggerRunCall {
3752 hub: self.hub,
3753 _request: request,
3754 _name: name.to_string(),
3755 _delegate: Default::default(),
3756 _additional_params: Default::default(),
3757 _scopes: Default::default(),
3758 }
3759 }
3760
3761 /// Create a builder to help you perform the following task:
3762 ///
3763 /// ReceiveTriggerWebhook [Experimental] is called when the API receives a webhook request targeted at a specific trigger.
3764 ///
3765 /// # Arguments
3766 ///
3767 /// * `request` - No description provided.
3768 /// * `name` - The name of the `ReceiveTriggerWebhook` to retrieve. Format: `projects/{project}/locations/{location}/triggers/{trigger}`
3769 pub fn locations_triggers_webhook(
3770 &self,
3771 request: HttpBody,
3772 name: &str,
3773 ) -> ProjectLocationTriggerWebhookCall<'a, C> {
3774 ProjectLocationTriggerWebhookCall {
3775 hub: self.hub,
3776 _request: request,
3777 _name: name.to_string(),
3778 _trigger: Default::default(),
3779 _secret: Default::default(),
3780 _project_id: Default::default(),
3781 _delegate: Default::default(),
3782 _additional_params: Default::default(),
3783 }
3784 }
3785
3786 /// Create a builder to help you perform the following task:
3787 ///
3788 /// Creates a `WorkerPool`.
3789 ///
3790 /// # Arguments
3791 ///
3792 /// * `request` - No description provided.
3793 /// * `parent` - Required. The parent resource where this worker pool will be created. Format: `projects/{project}/locations/{location}`.
3794 pub fn locations_worker_pools_create(
3795 &self,
3796 request: WorkerPool,
3797 parent: &str,
3798 ) -> ProjectLocationWorkerPoolCreateCall<'a, C> {
3799 ProjectLocationWorkerPoolCreateCall {
3800 hub: self.hub,
3801 _request: request,
3802 _parent: parent.to_string(),
3803 _worker_pool_id: Default::default(),
3804 _validate_only: Default::default(),
3805 _delegate: Default::default(),
3806 _additional_params: Default::default(),
3807 _scopes: Default::default(),
3808 }
3809 }
3810
3811 /// Create a builder to help you perform the following task:
3812 ///
3813 /// Deletes a `WorkerPool`.
3814 ///
3815 /// # Arguments
3816 ///
3817 /// * `name` - Required. The name of the `WorkerPool` to delete. Format: `projects/{project}/locations/{location}/workerPools/{workerPool}`.
3818 pub fn locations_worker_pools_delete(
3819 &self,
3820 name: &str,
3821 ) -> ProjectLocationWorkerPoolDeleteCall<'a, C> {
3822 ProjectLocationWorkerPoolDeleteCall {
3823 hub: self.hub,
3824 _name: name.to_string(),
3825 _validate_only: Default::default(),
3826 _etag: Default::default(),
3827 _allow_missing: Default::default(),
3828 _delegate: Default::default(),
3829 _additional_params: Default::default(),
3830 _scopes: Default::default(),
3831 }
3832 }
3833
3834 /// Create a builder to help you perform the following task:
3835 ///
3836 /// Returns details of a `WorkerPool`.
3837 ///
3838 /// # Arguments
3839 ///
3840 /// * `name` - Required. The name of the `WorkerPool` to retrieve. Format: `projects/{project}/locations/{location}/workerPools/{workerPool}`.
3841 pub fn locations_worker_pools_get(
3842 &self,
3843 name: &str,
3844 ) -> ProjectLocationWorkerPoolGetCall<'a, C> {
3845 ProjectLocationWorkerPoolGetCall {
3846 hub: self.hub,
3847 _name: name.to_string(),
3848 _delegate: Default::default(),
3849 _additional_params: Default::default(),
3850 _scopes: Default::default(),
3851 }
3852 }
3853
3854 /// Create a builder to help you perform the following task:
3855 ///
3856 /// Lists `WorkerPool`s.
3857 ///
3858 /// # Arguments
3859 ///
3860 /// * `parent` - Required. The parent of the collection of `WorkerPools`. Format: `projects/{project}/locations/{location}`.
3861 pub fn locations_worker_pools_list(
3862 &self,
3863 parent: &str,
3864 ) -> ProjectLocationWorkerPoolListCall<'a, C> {
3865 ProjectLocationWorkerPoolListCall {
3866 hub: self.hub,
3867 _parent: parent.to_string(),
3868 _page_token: Default::default(),
3869 _page_size: Default::default(),
3870 _delegate: Default::default(),
3871 _additional_params: Default::default(),
3872 _scopes: Default::default(),
3873 }
3874 }
3875
3876 /// Create a builder to help you perform the following task:
3877 ///
3878 /// Updates a `WorkerPool`.
3879 ///
3880 /// # Arguments
3881 ///
3882 /// * `request` - No description provided.
3883 /// * `name` - Output only. The resource name of the `WorkerPool`, with format `projects/{project}/locations/{location}/workerPools/{worker_pool}`. The value of `{worker_pool}` is provided by `worker_pool_id` in `CreateWorkerPool` request and the value of `{location}` is determined by the endpoint accessed.
3884 pub fn locations_worker_pools_patch(
3885 &self,
3886 request: WorkerPool,
3887 name: &str,
3888 ) -> ProjectLocationWorkerPoolPatchCall<'a, C> {
3889 ProjectLocationWorkerPoolPatchCall {
3890 hub: self.hub,
3891 _request: request,
3892 _name: name.to_string(),
3893 _validate_only: Default::default(),
3894 _update_mask: Default::default(),
3895 _delegate: Default::default(),
3896 _additional_params: Default::default(),
3897 _scopes: Default::default(),
3898 }
3899 }
3900
3901 /// Create a builder to help you perform the following task:
3902 ///
3903 /// Returns the `DefaultServiceAccount` used by the project.
3904 ///
3905 /// # Arguments
3906 ///
3907 /// * `name` - Required. The name of the `DefaultServiceAccount` to retrieve. Format: `projects/{project}/locations/{location}/defaultServiceAccount`
3908 pub fn locations_get_default_service_account(
3909 &self,
3910 name: &str,
3911 ) -> ProjectLocationGetDefaultServiceAccountCall<'a, C> {
3912 ProjectLocationGetDefaultServiceAccountCall {
3913 hub: self.hub,
3914 _name: name.to_string(),
3915 _delegate: Default::default(),
3916 _additional_params: Default::default(),
3917 _scopes: Default::default(),
3918 }
3919 }
3920
3921 /// Create a builder to help you perform the following task:
3922 ///
3923 /// Creates a new `BuildTrigger`.
3924 ///
3925 /// # Arguments
3926 ///
3927 /// * `request` - No description provided.
3928 /// * `projectId` - Required. ID of the project for which to configure automatic builds.
3929 pub fn triggers_create(
3930 &self,
3931 request: BuildTrigger,
3932 project_id: &str,
3933 ) -> ProjectTriggerCreateCall<'a, C> {
3934 ProjectTriggerCreateCall {
3935 hub: self.hub,
3936 _request: request,
3937 _project_id: project_id.to_string(),
3938 _parent: Default::default(),
3939 _delegate: Default::default(),
3940 _additional_params: Default::default(),
3941 _scopes: Default::default(),
3942 }
3943 }
3944
3945 /// Create a builder to help you perform the following task:
3946 ///
3947 /// Deletes a `BuildTrigger` by its project ID and trigger ID.
3948 ///
3949 /// # Arguments
3950 ///
3951 /// * `projectId` - Required. ID of the project that owns the trigger.
3952 /// * `triggerId` - Required. ID of the `BuildTrigger` to delete.
3953 pub fn triggers_delete(
3954 &self,
3955 project_id: &str,
3956 trigger_id: &str,
3957 ) -> ProjectTriggerDeleteCall<'a, C> {
3958 ProjectTriggerDeleteCall {
3959 hub: self.hub,
3960 _project_id: project_id.to_string(),
3961 _trigger_id: trigger_id.to_string(),
3962 _name: Default::default(),
3963 _delegate: Default::default(),
3964 _additional_params: Default::default(),
3965 _scopes: Default::default(),
3966 }
3967 }
3968
3969 /// Create a builder to help you perform the following task:
3970 ///
3971 /// Returns information about a `BuildTrigger`.
3972 ///
3973 /// # Arguments
3974 ///
3975 /// * `projectId` - Required. ID of the project that owns the trigger.
3976 /// * `triggerId` - Required. Identifier (`id` or `name`) of the `BuildTrigger` to get.
3977 pub fn triggers_get(&self, project_id: &str, trigger_id: &str) -> ProjectTriggerGetCall<'a, C> {
3978 ProjectTriggerGetCall {
3979 hub: self.hub,
3980 _project_id: project_id.to_string(),
3981 _trigger_id: trigger_id.to_string(),
3982 _name: Default::default(),
3983 _delegate: Default::default(),
3984 _additional_params: Default::default(),
3985 _scopes: Default::default(),
3986 }
3987 }
3988
3989 /// Create a builder to help you perform the following task:
3990 ///
3991 /// Lists existing `BuildTrigger`s.
3992 ///
3993 /// # Arguments
3994 ///
3995 /// * `projectId` - Required. ID of the project for which to list BuildTriggers.
3996 pub fn triggers_list(&self, project_id: &str) -> ProjectTriggerListCall<'a, C> {
3997 ProjectTriggerListCall {
3998 hub: self.hub,
3999 _project_id: project_id.to_string(),
4000 _parent: Default::default(),
4001 _page_token: Default::default(),
4002 _page_size: Default::default(),
4003 _delegate: Default::default(),
4004 _additional_params: Default::default(),
4005 _scopes: Default::default(),
4006 }
4007 }
4008
4009 /// Create a builder to help you perform the following task:
4010 ///
4011 /// Updates a `BuildTrigger` by its project ID and trigger ID.
4012 ///
4013 /// # Arguments
4014 ///
4015 /// * `request` - No description provided.
4016 /// * `projectId` - Required. ID of the project that owns the trigger.
4017 /// * `triggerId` - Required. ID of the `BuildTrigger` to update.
4018 pub fn triggers_patch(
4019 &self,
4020 request: BuildTrigger,
4021 project_id: &str,
4022 trigger_id: &str,
4023 ) -> ProjectTriggerPatchCall<'a, C> {
4024 ProjectTriggerPatchCall {
4025 hub: self.hub,
4026 _request: request,
4027 _project_id: project_id.to_string(),
4028 _trigger_id: trigger_id.to_string(),
4029 _update_mask: Default::default(),
4030 _delegate: Default::default(),
4031 _additional_params: Default::default(),
4032 _scopes: Default::default(),
4033 }
4034 }
4035
4036 /// Create a builder to help you perform the following task:
4037 ///
4038 /// Runs a `BuildTrigger` at a particular source revision. To run a regional or global trigger, use the POST request that includes the location endpoint in the path (ex. v1/projects/{projectId}/locations/{region}/triggers/{triggerId}:run). The POST request that does not include the location endpoint in the path can only be used when running global triggers.
4039 ///
4040 /// # Arguments
4041 ///
4042 /// * `request` - No description provided.
4043 /// * `projectId` - Required. ID of the project.
4044 /// * `triggerId` - Required. ID of the trigger.
4045 pub fn triggers_run(
4046 &self,
4047 request: RepoSource,
4048 project_id: &str,
4049 trigger_id: &str,
4050 ) -> ProjectTriggerRunCall<'a, C> {
4051 ProjectTriggerRunCall {
4052 hub: self.hub,
4053 _request: request,
4054 _project_id: project_id.to_string(),
4055 _trigger_id: trigger_id.to_string(),
4056 _name: Default::default(),
4057 _delegate: Default::default(),
4058 _additional_params: Default::default(),
4059 _scopes: Default::default(),
4060 }
4061 }
4062
4063 /// Create a builder to help you perform the following task:
4064 ///
4065 /// ReceiveTriggerWebhook [Experimental] is called when the API receives a webhook request targeted at a specific trigger.
4066 ///
4067 /// # Arguments
4068 ///
4069 /// * `request` - No description provided.
4070 /// * `projectId` - Project in which the specified trigger lives
4071 /// * `trigger` - Name of the trigger to run the payload against
4072 pub fn triggers_webhook(
4073 &self,
4074 request: HttpBody,
4075 project_id: &str,
4076 trigger: &str,
4077 ) -> ProjectTriggerWebhookCall<'a, C> {
4078 ProjectTriggerWebhookCall {
4079 hub: self.hub,
4080 _request: request,
4081 _project_id: project_id.to_string(),
4082 _trigger: trigger.to_string(),
4083 _secret: Default::default(),
4084 _name: Default::default(),
4085 _delegate: Default::default(),
4086 _additional_params: Default::default(),
4087 }
4088 }
4089}
4090
4091/// A builder providing access to all free methods, which are not associated with a particular resource.
4092/// It is not used directly, but through the [`CloudBuild`] hub.
4093///
4094/// # Example
4095///
4096/// Instantiate a resource builder
4097///
4098/// ```test_harness,no_run
4099/// extern crate hyper;
4100/// extern crate hyper_rustls;
4101/// extern crate google_cloudbuild1 as cloudbuild1;
4102///
4103/// # async fn dox() {
4104/// use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4105///
4106/// let secret: yup_oauth2::ApplicationSecret = Default::default();
4107/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4108/// secret,
4109/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4110/// ).build().await.unwrap();
4111///
4112/// let client = hyper_util::client::legacy::Client::builder(
4113/// hyper_util::rt::TokioExecutor::new()
4114/// )
4115/// .build(
4116/// hyper_rustls::HttpsConnectorBuilder::new()
4117/// .with_native_roots()
4118/// .unwrap()
4119/// .https_or_http()
4120/// .enable_http1()
4121/// .build()
4122/// );
4123/// let mut hub = CloudBuild::new(client, auth);
4124/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
4125/// // like `webhook(...)`
4126/// // to build up your call.
4127/// let rb = hub.methods();
4128/// # }
4129/// ```
4130pub struct MethodMethods<'a, C>
4131where
4132 C: 'a,
4133{
4134 hub: &'a CloudBuild<C>,
4135}
4136
4137impl<'a, C> common::MethodsBuilder for MethodMethods<'a, C> {}
4138
4139impl<'a, C> MethodMethods<'a, C> {
4140 /// Create a builder to help you perform the following task:
4141 ///
4142 /// ReceiveWebhook is called when the API receives a GitHub webhook.
4143 ///
4144 /// # Arguments
4145 ///
4146 /// * `request` - No description provided.
4147 pub fn webhook(&self, request: HttpBody) -> MethodWebhookCall<'a, C> {
4148 MethodWebhookCall {
4149 hub: self.hub,
4150 _request: request,
4151 _webhook_key: Default::default(),
4152 _delegate: Default::default(),
4153 _additional_params: Default::default(),
4154 }
4155 }
4156}
4157
4158// ###################
4159// CallBuilders ###
4160// #################
4161
4162/// ReceiveGitHubDotComWebhook is called when the API receives a github.com webhook.
4163///
4164/// A builder for the *receive* method supported by a *githubDotComWebhook* resource.
4165/// It is not used directly, but through a [`GithubDotComWebhookMethods`] instance.
4166///
4167/// # Example
4168///
4169/// Instantiate a resource method builder
4170///
4171/// ```test_harness,no_run
4172/// # extern crate hyper;
4173/// # extern crate hyper_rustls;
4174/// # extern crate google_cloudbuild1 as cloudbuild1;
4175/// use cloudbuild1::api::HttpBody;
4176/// # async fn dox() {
4177/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4178///
4179/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4180/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4181/// # secret,
4182/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4183/// # ).build().await.unwrap();
4184///
4185/// # let client = hyper_util::client::legacy::Client::builder(
4186/// # hyper_util::rt::TokioExecutor::new()
4187/// # )
4188/// # .build(
4189/// # hyper_rustls::HttpsConnectorBuilder::new()
4190/// # .with_native_roots()
4191/// # .unwrap()
4192/// # .https_or_http()
4193/// # .enable_http1()
4194/// # .build()
4195/// # );
4196/// # let mut hub = CloudBuild::new(client, auth);
4197/// // As the method needs a request, you would usually fill it with the desired information
4198/// // into the respective structure. Some of the parts shown here might not be applicable !
4199/// // Values shown here are possibly random and not representative !
4200/// let mut req = HttpBody::default();
4201///
4202/// // You can configure optional parameters by calling the respective setters at will, and
4203/// // execute the final call using `doit()`.
4204/// // Values shown here are possibly random and not representative !
4205/// let result = hub.github_dot_com_webhook().receive(req)
4206/// .webhook_key("takimata")
4207/// .doit().await;
4208/// # }
4209/// ```
4210pub struct GithubDotComWebhookReceiveCall<'a, C>
4211where
4212 C: 'a,
4213{
4214 hub: &'a CloudBuild<C>,
4215 _request: HttpBody,
4216 _webhook_key: Option<String>,
4217 _delegate: Option<&'a mut dyn common::Delegate>,
4218 _additional_params: HashMap<String, String>,
4219}
4220
4221impl<'a, C> common::CallBuilder for GithubDotComWebhookReceiveCall<'a, C> {}
4222
4223impl<'a, C> GithubDotComWebhookReceiveCall<'a, C>
4224where
4225 C: common::Connector,
4226{
4227 /// Perform the operation you have build so far.
4228 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
4229 use std::borrow::Cow;
4230 use std::io::{Read, Seek};
4231
4232 use common::{url::Params, ToParts};
4233 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4234
4235 let mut dd = common::DefaultDelegate;
4236 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4237 dlg.begin(common::MethodInfo {
4238 id: "cloudbuild.githubDotComWebhook.receive",
4239 http_method: hyper::Method::POST,
4240 });
4241
4242 for &field in ["alt", "webhookKey"].iter() {
4243 if self._additional_params.contains_key(field) {
4244 dlg.finished(false);
4245 return Err(common::Error::FieldClash(field));
4246 }
4247 }
4248
4249 let mut params = Params::with_capacity(4 + self._additional_params.len());
4250 if let Some(value) = self._webhook_key.as_ref() {
4251 params.push("webhookKey", value);
4252 }
4253
4254 params.extend(self._additional_params.iter());
4255
4256 params.push("alt", "json");
4257 let mut url = self.hub._base_url.clone() + "v1/githubDotComWebhook:receive";
4258
4259 match dlg.api_key() {
4260 Some(value) => params.push("key", value),
4261 None => {
4262 dlg.finished(false);
4263 return Err(common::Error::MissingAPIKey);
4264 }
4265 }
4266
4267 let url = params.parse_with_url(&url);
4268
4269 let mut json_mime_type = mime::APPLICATION_JSON;
4270 let mut request_value_reader = {
4271 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4272 common::remove_json_null_values(&mut value);
4273 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4274 serde_json::to_writer(&mut dst, &value).unwrap();
4275 dst
4276 };
4277 let request_size = request_value_reader
4278 .seek(std::io::SeekFrom::End(0))
4279 .unwrap();
4280 request_value_reader
4281 .seek(std::io::SeekFrom::Start(0))
4282 .unwrap();
4283
4284 loop {
4285 request_value_reader
4286 .seek(std::io::SeekFrom::Start(0))
4287 .unwrap();
4288 let mut req_result = {
4289 let client = &self.hub.client;
4290 dlg.pre_request();
4291 let mut req_builder = hyper::Request::builder()
4292 .method(hyper::Method::POST)
4293 .uri(url.as_str())
4294 .header(USER_AGENT, self.hub._user_agent.clone());
4295
4296 let request = req_builder
4297 .header(CONTENT_TYPE, json_mime_type.to_string())
4298 .header(CONTENT_LENGTH, request_size as u64)
4299 .body(common::to_body(
4300 request_value_reader.get_ref().clone().into(),
4301 ));
4302
4303 client.request(request.unwrap()).await
4304 };
4305
4306 match req_result {
4307 Err(err) => {
4308 if let common::Retry::After(d) = dlg.http_error(&err) {
4309 sleep(d).await;
4310 continue;
4311 }
4312 dlg.finished(false);
4313 return Err(common::Error::HttpError(err));
4314 }
4315 Ok(res) => {
4316 let (mut parts, body) = res.into_parts();
4317 let mut body = common::Body::new(body);
4318 if !parts.status.is_success() {
4319 let bytes = common::to_bytes(body).await.unwrap_or_default();
4320 let error = serde_json::from_str(&common::to_string(&bytes));
4321 let response = common::to_response(parts, bytes.into());
4322
4323 if let common::Retry::After(d) =
4324 dlg.http_failure(&response, error.as_ref().ok())
4325 {
4326 sleep(d).await;
4327 continue;
4328 }
4329
4330 dlg.finished(false);
4331
4332 return Err(match error {
4333 Ok(value) => common::Error::BadRequest(value),
4334 _ => common::Error::Failure(response),
4335 });
4336 }
4337 let response = {
4338 let bytes = common::to_bytes(body).await.unwrap_or_default();
4339 let encoded = common::to_string(&bytes);
4340 match serde_json::from_str(&encoded) {
4341 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4342 Err(error) => {
4343 dlg.response_json_decode_error(&encoded, &error);
4344 return Err(common::Error::JsonDecodeError(
4345 encoded.to_string(),
4346 error,
4347 ));
4348 }
4349 }
4350 };
4351
4352 dlg.finished(true);
4353 return Ok(response);
4354 }
4355 }
4356 }
4357 }
4358
4359 ///
4360 /// Sets the *request* property to the given value.
4361 ///
4362 /// Even though the property as already been set when instantiating this call,
4363 /// we provide this method for API completeness.
4364 pub fn request(mut self, new_value: HttpBody) -> GithubDotComWebhookReceiveCall<'a, C> {
4365 self._request = new_value;
4366 self
4367 }
4368 /// For GitHub Enterprise webhooks, this key is used to associate the webhook request with the GitHubEnterpriseConfig to use for validation.
4369 ///
4370 /// Sets the *webhook key* query property to the given value.
4371 pub fn webhook_key(mut self, new_value: &str) -> GithubDotComWebhookReceiveCall<'a, C> {
4372 self._webhook_key = Some(new_value.to_string());
4373 self
4374 }
4375 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4376 /// while executing the actual API request.
4377 ///
4378 /// ````text
4379 /// It should be used to handle progress information, and to implement a certain level of resilience.
4380 /// ````
4381 ///
4382 /// Sets the *delegate* property to the given value.
4383 pub fn delegate(
4384 mut self,
4385 new_value: &'a mut dyn common::Delegate,
4386 ) -> GithubDotComWebhookReceiveCall<'a, C> {
4387 self._delegate = Some(new_value);
4388 self
4389 }
4390
4391 /// Set any additional parameter of the query string used in the request.
4392 /// It should be used to set parameters which are not yet available through their own
4393 /// setters.
4394 ///
4395 /// Please note that this method must not be used to set any of the known parameters
4396 /// which have their own setter method. If done anyway, the request will fail.
4397 ///
4398 /// # Additional Parameters
4399 ///
4400 /// * *$.xgafv* (query-string) - V1 error format.
4401 /// * *access_token* (query-string) - OAuth access token.
4402 /// * *alt* (query-string) - Data format for response.
4403 /// * *callback* (query-string) - JSONP
4404 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4405 /// * *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.
4406 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4407 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4408 /// * *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.
4409 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4410 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4411 pub fn param<T>(mut self, name: T, value: T) -> GithubDotComWebhookReceiveCall<'a, C>
4412 where
4413 T: AsRef<str>,
4414 {
4415 self._additional_params
4416 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4417 self
4418 }
4419}
4420
4421/// ReceiveRegionalWebhook is called when the API receives a regional GitHub webhook.
4422///
4423/// A builder for the *regionalWebhook* method supported by a *location* resource.
4424/// It is not used directly, but through a [`LocationMethods`] instance.
4425///
4426/// # Example
4427///
4428/// Instantiate a resource method builder
4429///
4430/// ```test_harness,no_run
4431/// # extern crate hyper;
4432/// # extern crate hyper_rustls;
4433/// # extern crate google_cloudbuild1 as cloudbuild1;
4434/// use cloudbuild1::api::HttpBody;
4435/// # async fn dox() {
4436/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4437///
4438/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4439/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4440/// # secret,
4441/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4442/// # ).build().await.unwrap();
4443///
4444/// # let client = hyper_util::client::legacy::Client::builder(
4445/// # hyper_util::rt::TokioExecutor::new()
4446/// # )
4447/// # .build(
4448/// # hyper_rustls::HttpsConnectorBuilder::new()
4449/// # .with_native_roots()
4450/// # .unwrap()
4451/// # .https_or_http()
4452/// # .enable_http1()
4453/// # .build()
4454/// # );
4455/// # let mut hub = CloudBuild::new(client, auth);
4456/// // As the method needs a request, you would usually fill it with the desired information
4457/// // into the respective structure. Some of the parts shown here might not be applicable !
4458/// // Values shown here are possibly random and not representative !
4459/// let mut req = HttpBody::default();
4460///
4461/// // You can configure optional parameters by calling the respective setters at will, and
4462/// // execute the final call using `doit()`.
4463/// // Values shown here are possibly random and not representative !
4464/// let result = hub.locations().regional_webhook(req, "location")
4465/// .webhook_key("duo")
4466/// .doit().await;
4467/// # }
4468/// ```
4469pub struct LocationRegionalWebhookCall<'a, C>
4470where
4471 C: 'a,
4472{
4473 hub: &'a CloudBuild<C>,
4474 _request: HttpBody,
4475 _location: String,
4476 _webhook_key: Option<String>,
4477 _delegate: Option<&'a mut dyn common::Delegate>,
4478 _additional_params: HashMap<String, String>,
4479}
4480
4481impl<'a, C> common::CallBuilder for LocationRegionalWebhookCall<'a, C> {}
4482
4483impl<'a, C> LocationRegionalWebhookCall<'a, C>
4484where
4485 C: common::Connector,
4486{
4487 /// Perform the operation you have build so far.
4488 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
4489 use std::borrow::Cow;
4490 use std::io::{Read, Seek};
4491
4492 use common::{url::Params, ToParts};
4493 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4494
4495 let mut dd = common::DefaultDelegate;
4496 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4497 dlg.begin(common::MethodInfo {
4498 id: "cloudbuild.locations.regionalWebhook",
4499 http_method: hyper::Method::POST,
4500 });
4501
4502 for &field in ["alt", "location", "webhookKey"].iter() {
4503 if self._additional_params.contains_key(field) {
4504 dlg.finished(false);
4505 return Err(common::Error::FieldClash(field));
4506 }
4507 }
4508
4509 let mut params = Params::with_capacity(5 + self._additional_params.len());
4510 params.push("location", self._location);
4511 if let Some(value) = self._webhook_key.as_ref() {
4512 params.push("webhookKey", value);
4513 }
4514
4515 params.extend(self._additional_params.iter());
4516
4517 params.push("alt", "json");
4518 let mut url = self.hub._base_url.clone() + "v1/{+location}/regionalWebhook";
4519
4520 match dlg.api_key() {
4521 Some(value) => params.push("key", value),
4522 None => {
4523 dlg.finished(false);
4524 return Err(common::Error::MissingAPIKey);
4525 }
4526 }
4527
4528 #[allow(clippy::single_element_loop)]
4529 for &(find_this, param_name) in [("{+location}", "location")].iter() {
4530 url = params.uri_replacement(url, param_name, find_this, true);
4531 }
4532 {
4533 let to_remove = ["location"];
4534 params.remove_params(&to_remove);
4535 }
4536
4537 let url = params.parse_with_url(&url);
4538
4539 let mut json_mime_type = mime::APPLICATION_JSON;
4540 let mut request_value_reader = {
4541 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4542 common::remove_json_null_values(&mut value);
4543 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4544 serde_json::to_writer(&mut dst, &value).unwrap();
4545 dst
4546 };
4547 let request_size = request_value_reader
4548 .seek(std::io::SeekFrom::End(0))
4549 .unwrap();
4550 request_value_reader
4551 .seek(std::io::SeekFrom::Start(0))
4552 .unwrap();
4553
4554 loop {
4555 request_value_reader
4556 .seek(std::io::SeekFrom::Start(0))
4557 .unwrap();
4558 let mut req_result = {
4559 let client = &self.hub.client;
4560 dlg.pre_request();
4561 let mut req_builder = hyper::Request::builder()
4562 .method(hyper::Method::POST)
4563 .uri(url.as_str())
4564 .header(USER_AGENT, self.hub._user_agent.clone());
4565
4566 let request = req_builder
4567 .header(CONTENT_TYPE, json_mime_type.to_string())
4568 .header(CONTENT_LENGTH, request_size as u64)
4569 .body(common::to_body(
4570 request_value_reader.get_ref().clone().into(),
4571 ));
4572
4573 client.request(request.unwrap()).await
4574 };
4575
4576 match req_result {
4577 Err(err) => {
4578 if let common::Retry::After(d) = dlg.http_error(&err) {
4579 sleep(d).await;
4580 continue;
4581 }
4582 dlg.finished(false);
4583 return Err(common::Error::HttpError(err));
4584 }
4585 Ok(res) => {
4586 let (mut parts, body) = res.into_parts();
4587 let mut body = common::Body::new(body);
4588 if !parts.status.is_success() {
4589 let bytes = common::to_bytes(body).await.unwrap_or_default();
4590 let error = serde_json::from_str(&common::to_string(&bytes));
4591 let response = common::to_response(parts, bytes.into());
4592
4593 if let common::Retry::After(d) =
4594 dlg.http_failure(&response, error.as_ref().ok())
4595 {
4596 sleep(d).await;
4597 continue;
4598 }
4599
4600 dlg.finished(false);
4601
4602 return Err(match error {
4603 Ok(value) => common::Error::BadRequest(value),
4604 _ => common::Error::Failure(response),
4605 });
4606 }
4607 let response = {
4608 let bytes = common::to_bytes(body).await.unwrap_or_default();
4609 let encoded = common::to_string(&bytes);
4610 match serde_json::from_str(&encoded) {
4611 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4612 Err(error) => {
4613 dlg.response_json_decode_error(&encoded, &error);
4614 return Err(common::Error::JsonDecodeError(
4615 encoded.to_string(),
4616 error,
4617 ));
4618 }
4619 }
4620 };
4621
4622 dlg.finished(true);
4623 return Ok(response);
4624 }
4625 }
4626 }
4627 }
4628
4629 ///
4630 /// Sets the *request* property to the given value.
4631 ///
4632 /// Even though the property as already been set when instantiating this call,
4633 /// we provide this method for API completeness.
4634 pub fn request(mut self, new_value: HttpBody) -> LocationRegionalWebhookCall<'a, C> {
4635 self._request = new_value;
4636 self
4637 }
4638 /// Required. The location where the webhook should be sent.
4639 ///
4640 /// Sets the *location* path property to the given value.
4641 ///
4642 /// Even though the property as already been set when instantiating this call,
4643 /// we provide this method for API completeness.
4644 pub fn location(mut self, new_value: &str) -> LocationRegionalWebhookCall<'a, C> {
4645 self._location = new_value.to_string();
4646 self
4647 }
4648 /// For GitHub Enterprise webhooks, this key is used to associate the webhook request with the GitHubEnterpriseConfig to use for validation.
4649 ///
4650 /// Sets the *webhook key* query property to the given value.
4651 pub fn webhook_key(mut self, new_value: &str) -> LocationRegionalWebhookCall<'a, C> {
4652 self._webhook_key = Some(new_value.to_string());
4653 self
4654 }
4655 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4656 /// while executing the actual API request.
4657 ///
4658 /// ````text
4659 /// It should be used to handle progress information, and to implement a certain level of resilience.
4660 /// ````
4661 ///
4662 /// Sets the *delegate* property to the given value.
4663 pub fn delegate(
4664 mut self,
4665 new_value: &'a mut dyn common::Delegate,
4666 ) -> LocationRegionalWebhookCall<'a, C> {
4667 self._delegate = Some(new_value);
4668 self
4669 }
4670
4671 /// Set any additional parameter of the query string used in the request.
4672 /// It should be used to set parameters which are not yet available through their own
4673 /// setters.
4674 ///
4675 /// Please note that this method must not be used to set any of the known parameters
4676 /// which have their own setter method. If done anyway, the request will fail.
4677 ///
4678 /// # Additional Parameters
4679 ///
4680 /// * *$.xgafv* (query-string) - V1 error format.
4681 /// * *access_token* (query-string) - OAuth access token.
4682 /// * *alt* (query-string) - Data format for response.
4683 /// * *callback* (query-string) - JSONP
4684 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4685 /// * *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.
4686 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4687 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4688 /// * *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.
4689 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4690 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4691 pub fn param<T>(mut self, name: T, value: T) -> LocationRegionalWebhookCall<'a, C>
4692 where
4693 T: AsRef<str>,
4694 {
4695 self._additional_params
4696 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4697 self
4698 }
4699}
4700
4701/// Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of 1, corresponding to `Code.CANCELLED`.
4702///
4703/// A builder for the *cancel* method supported by a *operation* resource.
4704/// It is not used directly, but through a [`OperationMethods`] instance.
4705///
4706/// # Example
4707///
4708/// Instantiate a resource method builder
4709///
4710/// ```test_harness,no_run
4711/// # extern crate hyper;
4712/// # extern crate hyper_rustls;
4713/// # extern crate google_cloudbuild1 as cloudbuild1;
4714/// use cloudbuild1::api::CancelOperationRequest;
4715/// # async fn dox() {
4716/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4717///
4718/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4719/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4720/// # secret,
4721/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4722/// # ).build().await.unwrap();
4723///
4724/// # let client = hyper_util::client::legacy::Client::builder(
4725/// # hyper_util::rt::TokioExecutor::new()
4726/// # )
4727/// # .build(
4728/// # hyper_rustls::HttpsConnectorBuilder::new()
4729/// # .with_native_roots()
4730/// # .unwrap()
4731/// # .https_or_http()
4732/// # .enable_http1()
4733/// # .build()
4734/// # );
4735/// # let mut hub = CloudBuild::new(client, auth);
4736/// // As the method needs a request, you would usually fill it with the desired information
4737/// // into the respective structure. Some of the parts shown here might not be applicable !
4738/// // Values shown here are possibly random and not representative !
4739/// let mut req = CancelOperationRequest::default();
4740///
4741/// // You can configure optional parameters by calling the respective setters at will, and
4742/// // execute the final call using `doit()`.
4743/// // Values shown here are possibly random and not representative !
4744/// let result = hub.operations().cancel(req, "name")
4745/// .doit().await;
4746/// # }
4747/// ```
4748pub struct OperationCancelCall<'a, C>
4749where
4750 C: 'a,
4751{
4752 hub: &'a CloudBuild<C>,
4753 _request: CancelOperationRequest,
4754 _name: String,
4755 _delegate: Option<&'a mut dyn common::Delegate>,
4756 _additional_params: HashMap<String, String>,
4757 _scopes: BTreeSet<String>,
4758}
4759
4760impl<'a, C> common::CallBuilder for OperationCancelCall<'a, C> {}
4761
4762impl<'a, C> OperationCancelCall<'a, C>
4763where
4764 C: common::Connector,
4765{
4766 /// Perform the operation you have build so far.
4767 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
4768 use std::borrow::Cow;
4769 use std::io::{Read, Seek};
4770
4771 use common::{url::Params, ToParts};
4772 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4773
4774 let mut dd = common::DefaultDelegate;
4775 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4776 dlg.begin(common::MethodInfo {
4777 id: "cloudbuild.operations.cancel",
4778 http_method: hyper::Method::POST,
4779 });
4780
4781 for &field in ["alt", "name"].iter() {
4782 if self._additional_params.contains_key(field) {
4783 dlg.finished(false);
4784 return Err(common::Error::FieldClash(field));
4785 }
4786 }
4787
4788 let mut params = Params::with_capacity(4 + self._additional_params.len());
4789 params.push("name", self._name);
4790
4791 params.extend(self._additional_params.iter());
4792
4793 params.push("alt", "json");
4794 let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
4795 if self._scopes.is_empty() {
4796 self._scopes
4797 .insert(Scope::CloudPlatform.as_ref().to_string());
4798 }
4799
4800 #[allow(clippy::single_element_loop)]
4801 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4802 url = params.uri_replacement(url, param_name, find_this, true);
4803 }
4804 {
4805 let to_remove = ["name"];
4806 params.remove_params(&to_remove);
4807 }
4808
4809 let url = params.parse_with_url(&url);
4810
4811 let mut json_mime_type = mime::APPLICATION_JSON;
4812 let mut request_value_reader = {
4813 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4814 common::remove_json_null_values(&mut value);
4815 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4816 serde_json::to_writer(&mut dst, &value).unwrap();
4817 dst
4818 };
4819 let request_size = request_value_reader
4820 .seek(std::io::SeekFrom::End(0))
4821 .unwrap();
4822 request_value_reader
4823 .seek(std::io::SeekFrom::Start(0))
4824 .unwrap();
4825
4826 loop {
4827 let token = match self
4828 .hub
4829 .auth
4830 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4831 .await
4832 {
4833 Ok(token) => token,
4834 Err(e) => match dlg.token(e) {
4835 Ok(token) => token,
4836 Err(e) => {
4837 dlg.finished(false);
4838 return Err(common::Error::MissingToken(e));
4839 }
4840 },
4841 };
4842 request_value_reader
4843 .seek(std::io::SeekFrom::Start(0))
4844 .unwrap();
4845 let mut req_result = {
4846 let client = &self.hub.client;
4847 dlg.pre_request();
4848 let mut req_builder = hyper::Request::builder()
4849 .method(hyper::Method::POST)
4850 .uri(url.as_str())
4851 .header(USER_AGENT, self.hub._user_agent.clone());
4852
4853 if let Some(token) = token.as_ref() {
4854 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4855 }
4856
4857 let request = req_builder
4858 .header(CONTENT_TYPE, json_mime_type.to_string())
4859 .header(CONTENT_LENGTH, request_size as u64)
4860 .body(common::to_body(
4861 request_value_reader.get_ref().clone().into(),
4862 ));
4863
4864 client.request(request.unwrap()).await
4865 };
4866
4867 match req_result {
4868 Err(err) => {
4869 if let common::Retry::After(d) = dlg.http_error(&err) {
4870 sleep(d).await;
4871 continue;
4872 }
4873 dlg.finished(false);
4874 return Err(common::Error::HttpError(err));
4875 }
4876 Ok(res) => {
4877 let (mut parts, body) = res.into_parts();
4878 let mut body = common::Body::new(body);
4879 if !parts.status.is_success() {
4880 let bytes = common::to_bytes(body).await.unwrap_or_default();
4881 let error = serde_json::from_str(&common::to_string(&bytes));
4882 let response = common::to_response(parts, bytes.into());
4883
4884 if let common::Retry::After(d) =
4885 dlg.http_failure(&response, error.as_ref().ok())
4886 {
4887 sleep(d).await;
4888 continue;
4889 }
4890
4891 dlg.finished(false);
4892
4893 return Err(match error {
4894 Ok(value) => common::Error::BadRequest(value),
4895 _ => common::Error::Failure(response),
4896 });
4897 }
4898 let response = {
4899 let bytes = common::to_bytes(body).await.unwrap_or_default();
4900 let encoded = common::to_string(&bytes);
4901 match serde_json::from_str(&encoded) {
4902 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4903 Err(error) => {
4904 dlg.response_json_decode_error(&encoded, &error);
4905 return Err(common::Error::JsonDecodeError(
4906 encoded.to_string(),
4907 error,
4908 ));
4909 }
4910 }
4911 };
4912
4913 dlg.finished(true);
4914 return Ok(response);
4915 }
4916 }
4917 }
4918 }
4919
4920 ///
4921 /// Sets the *request* property to the given value.
4922 ///
4923 /// Even though the property as already been set when instantiating this call,
4924 /// we provide this method for API completeness.
4925 pub fn request(mut self, new_value: CancelOperationRequest) -> OperationCancelCall<'a, C> {
4926 self._request = new_value;
4927 self
4928 }
4929 /// The name of the operation resource to be cancelled.
4930 ///
4931 /// Sets the *name* path property to the given value.
4932 ///
4933 /// Even though the property as already been set when instantiating this call,
4934 /// we provide this method for API completeness.
4935 pub fn name(mut self, new_value: &str) -> OperationCancelCall<'a, C> {
4936 self._name = new_value.to_string();
4937 self
4938 }
4939 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4940 /// while executing the actual API request.
4941 ///
4942 /// ````text
4943 /// It should be used to handle progress information, and to implement a certain level of resilience.
4944 /// ````
4945 ///
4946 /// Sets the *delegate* property to the given value.
4947 pub fn delegate(
4948 mut self,
4949 new_value: &'a mut dyn common::Delegate,
4950 ) -> OperationCancelCall<'a, C> {
4951 self._delegate = Some(new_value);
4952 self
4953 }
4954
4955 /// Set any additional parameter of the query string used in the request.
4956 /// It should be used to set parameters which are not yet available through their own
4957 /// setters.
4958 ///
4959 /// Please note that this method must not be used to set any of the known parameters
4960 /// which have their own setter method. If done anyway, the request will fail.
4961 ///
4962 /// # Additional Parameters
4963 ///
4964 /// * *$.xgafv* (query-string) - V1 error format.
4965 /// * *access_token* (query-string) - OAuth access token.
4966 /// * *alt* (query-string) - Data format for response.
4967 /// * *callback* (query-string) - JSONP
4968 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4969 /// * *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.
4970 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4971 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4972 /// * *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.
4973 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4974 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4975 pub fn param<T>(mut self, name: T, value: T) -> OperationCancelCall<'a, C>
4976 where
4977 T: AsRef<str>,
4978 {
4979 self._additional_params
4980 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4981 self
4982 }
4983
4984 /// Identifies the authorization scope for the method you are building.
4985 ///
4986 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4987 /// [`Scope::CloudPlatform`].
4988 ///
4989 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4990 /// tokens for more than one scope.
4991 ///
4992 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4993 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4994 /// sufficient, a read-write scope will do as well.
4995 pub fn add_scope<St>(mut self, scope: St) -> OperationCancelCall<'a, C>
4996 where
4997 St: AsRef<str>,
4998 {
4999 self._scopes.insert(String::from(scope.as_ref()));
5000 self
5001 }
5002 /// Identifies the authorization scope(s) for the method you are building.
5003 ///
5004 /// See [`Self::add_scope()`] for details.
5005 pub fn add_scopes<I, St>(mut self, scopes: I) -> OperationCancelCall<'a, C>
5006 where
5007 I: IntoIterator<Item = St>,
5008 St: AsRef<str>,
5009 {
5010 self._scopes
5011 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5012 self
5013 }
5014
5015 /// Removes all scopes, and no default scope will be used either.
5016 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5017 /// for details).
5018 pub fn clear_scopes(mut self) -> OperationCancelCall<'a, C> {
5019 self._scopes.clear();
5020 self
5021 }
5022}
5023
5024/// Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
5025///
5026/// A builder for the *get* method supported by a *operation* resource.
5027/// It is not used directly, but through a [`OperationMethods`] instance.
5028///
5029/// # Example
5030///
5031/// Instantiate a resource method builder
5032///
5033/// ```test_harness,no_run
5034/// # extern crate hyper;
5035/// # extern crate hyper_rustls;
5036/// # extern crate google_cloudbuild1 as cloudbuild1;
5037/// # async fn dox() {
5038/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5039///
5040/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5041/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5042/// # secret,
5043/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5044/// # ).build().await.unwrap();
5045///
5046/// # let client = hyper_util::client::legacy::Client::builder(
5047/// # hyper_util::rt::TokioExecutor::new()
5048/// # )
5049/// # .build(
5050/// # hyper_rustls::HttpsConnectorBuilder::new()
5051/// # .with_native_roots()
5052/// # .unwrap()
5053/// # .https_or_http()
5054/// # .enable_http1()
5055/// # .build()
5056/// # );
5057/// # let mut hub = CloudBuild::new(client, auth);
5058/// // You can configure optional parameters by calling the respective setters at will, and
5059/// // execute the final call using `doit()`.
5060/// // Values shown here are possibly random and not representative !
5061/// let result = hub.operations().get("name")
5062/// .doit().await;
5063/// # }
5064/// ```
5065pub struct OperationGetCall<'a, C>
5066where
5067 C: 'a,
5068{
5069 hub: &'a CloudBuild<C>,
5070 _name: String,
5071 _delegate: Option<&'a mut dyn common::Delegate>,
5072 _additional_params: HashMap<String, String>,
5073 _scopes: BTreeSet<String>,
5074}
5075
5076impl<'a, C> common::CallBuilder for OperationGetCall<'a, C> {}
5077
5078impl<'a, C> OperationGetCall<'a, C>
5079where
5080 C: common::Connector,
5081{
5082 /// Perform the operation you have build so far.
5083 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
5084 use std::borrow::Cow;
5085 use std::io::{Read, Seek};
5086
5087 use common::{url::Params, ToParts};
5088 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5089
5090 let mut dd = common::DefaultDelegate;
5091 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5092 dlg.begin(common::MethodInfo {
5093 id: "cloudbuild.operations.get",
5094 http_method: hyper::Method::GET,
5095 });
5096
5097 for &field in ["alt", "name"].iter() {
5098 if self._additional_params.contains_key(field) {
5099 dlg.finished(false);
5100 return Err(common::Error::FieldClash(field));
5101 }
5102 }
5103
5104 let mut params = Params::with_capacity(3 + self._additional_params.len());
5105 params.push("name", self._name);
5106
5107 params.extend(self._additional_params.iter());
5108
5109 params.push("alt", "json");
5110 let mut url = self.hub._base_url.clone() + "v1/{+name}";
5111 if self._scopes.is_empty() {
5112 self._scopes
5113 .insert(Scope::CloudPlatform.as_ref().to_string());
5114 }
5115
5116 #[allow(clippy::single_element_loop)]
5117 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5118 url = params.uri_replacement(url, param_name, find_this, true);
5119 }
5120 {
5121 let to_remove = ["name"];
5122 params.remove_params(&to_remove);
5123 }
5124
5125 let url = params.parse_with_url(&url);
5126
5127 loop {
5128 let token = match self
5129 .hub
5130 .auth
5131 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5132 .await
5133 {
5134 Ok(token) => token,
5135 Err(e) => match dlg.token(e) {
5136 Ok(token) => token,
5137 Err(e) => {
5138 dlg.finished(false);
5139 return Err(common::Error::MissingToken(e));
5140 }
5141 },
5142 };
5143 let mut req_result = {
5144 let client = &self.hub.client;
5145 dlg.pre_request();
5146 let mut req_builder = hyper::Request::builder()
5147 .method(hyper::Method::GET)
5148 .uri(url.as_str())
5149 .header(USER_AGENT, self.hub._user_agent.clone());
5150
5151 if let Some(token) = token.as_ref() {
5152 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5153 }
5154
5155 let request = req_builder
5156 .header(CONTENT_LENGTH, 0_u64)
5157 .body(common::to_body::<String>(None));
5158
5159 client.request(request.unwrap()).await
5160 };
5161
5162 match req_result {
5163 Err(err) => {
5164 if let common::Retry::After(d) = dlg.http_error(&err) {
5165 sleep(d).await;
5166 continue;
5167 }
5168 dlg.finished(false);
5169 return Err(common::Error::HttpError(err));
5170 }
5171 Ok(res) => {
5172 let (mut parts, body) = res.into_parts();
5173 let mut body = common::Body::new(body);
5174 if !parts.status.is_success() {
5175 let bytes = common::to_bytes(body).await.unwrap_or_default();
5176 let error = serde_json::from_str(&common::to_string(&bytes));
5177 let response = common::to_response(parts, bytes.into());
5178
5179 if let common::Retry::After(d) =
5180 dlg.http_failure(&response, error.as_ref().ok())
5181 {
5182 sleep(d).await;
5183 continue;
5184 }
5185
5186 dlg.finished(false);
5187
5188 return Err(match error {
5189 Ok(value) => common::Error::BadRequest(value),
5190 _ => common::Error::Failure(response),
5191 });
5192 }
5193 let response = {
5194 let bytes = common::to_bytes(body).await.unwrap_or_default();
5195 let encoded = common::to_string(&bytes);
5196 match serde_json::from_str(&encoded) {
5197 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5198 Err(error) => {
5199 dlg.response_json_decode_error(&encoded, &error);
5200 return Err(common::Error::JsonDecodeError(
5201 encoded.to_string(),
5202 error,
5203 ));
5204 }
5205 }
5206 };
5207
5208 dlg.finished(true);
5209 return Ok(response);
5210 }
5211 }
5212 }
5213 }
5214
5215 /// The name of the operation resource.
5216 ///
5217 /// Sets the *name* path property to the given value.
5218 ///
5219 /// Even though the property as already been set when instantiating this call,
5220 /// we provide this method for API completeness.
5221 pub fn name(mut self, new_value: &str) -> OperationGetCall<'a, C> {
5222 self._name = new_value.to_string();
5223 self
5224 }
5225 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5226 /// while executing the actual API request.
5227 ///
5228 /// ````text
5229 /// It should be used to handle progress information, and to implement a certain level of resilience.
5230 /// ````
5231 ///
5232 /// Sets the *delegate* property to the given value.
5233 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> OperationGetCall<'a, C> {
5234 self._delegate = Some(new_value);
5235 self
5236 }
5237
5238 /// Set any additional parameter of the query string used in the request.
5239 /// It should be used to set parameters which are not yet available through their own
5240 /// setters.
5241 ///
5242 /// Please note that this method must not be used to set any of the known parameters
5243 /// which have their own setter method. If done anyway, the request will fail.
5244 ///
5245 /// # Additional Parameters
5246 ///
5247 /// * *$.xgafv* (query-string) - V1 error format.
5248 /// * *access_token* (query-string) - OAuth access token.
5249 /// * *alt* (query-string) - Data format for response.
5250 /// * *callback* (query-string) - JSONP
5251 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5252 /// * *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.
5253 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5254 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5255 /// * *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.
5256 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5257 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5258 pub fn param<T>(mut self, name: T, value: T) -> OperationGetCall<'a, C>
5259 where
5260 T: AsRef<str>,
5261 {
5262 self._additional_params
5263 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5264 self
5265 }
5266
5267 /// Identifies the authorization scope for the method you are building.
5268 ///
5269 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5270 /// [`Scope::CloudPlatform`].
5271 ///
5272 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5273 /// tokens for more than one scope.
5274 ///
5275 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5276 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5277 /// sufficient, a read-write scope will do as well.
5278 pub fn add_scope<St>(mut self, scope: St) -> OperationGetCall<'a, C>
5279 where
5280 St: AsRef<str>,
5281 {
5282 self._scopes.insert(String::from(scope.as_ref()));
5283 self
5284 }
5285 /// Identifies the authorization scope(s) for the method you are building.
5286 ///
5287 /// See [`Self::add_scope()`] for details.
5288 pub fn add_scopes<I, St>(mut self, scopes: I) -> OperationGetCall<'a, C>
5289 where
5290 I: IntoIterator<Item = St>,
5291 St: AsRef<str>,
5292 {
5293 self._scopes
5294 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5295 self
5296 }
5297
5298 /// Removes all scopes, and no default scope will be used either.
5299 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5300 /// for details).
5301 pub fn clear_scopes(mut self) -> OperationGetCall<'a, C> {
5302 self._scopes.clear();
5303 self
5304 }
5305}
5306
5307/// Approves or rejects a pending build. If approved, the returned LRO will be analogous to the LRO returned from a CreateBuild call. If rejected, the returned LRO will be immediately done.
5308///
5309/// A builder for the *builds.approve* method supported by a *project* resource.
5310/// It is not used directly, but through a [`ProjectMethods`] instance.
5311///
5312/// # Example
5313///
5314/// Instantiate a resource method builder
5315///
5316/// ```test_harness,no_run
5317/// # extern crate hyper;
5318/// # extern crate hyper_rustls;
5319/// # extern crate google_cloudbuild1 as cloudbuild1;
5320/// use cloudbuild1::api::ApproveBuildRequest;
5321/// # async fn dox() {
5322/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5323///
5324/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5325/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5326/// # secret,
5327/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5328/// # ).build().await.unwrap();
5329///
5330/// # let client = hyper_util::client::legacy::Client::builder(
5331/// # hyper_util::rt::TokioExecutor::new()
5332/// # )
5333/// # .build(
5334/// # hyper_rustls::HttpsConnectorBuilder::new()
5335/// # .with_native_roots()
5336/// # .unwrap()
5337/// # .https_or_http()
5338/// # .enable_http1()
5339/// # .build()
5340/// # );
5341/// # let mut hub = CloudBuild::new(client, auth);
5342/// // As the method needs a request, you would usually fill it with the desired information
5343/// // into the respective structure. Some of the parts shown here might not be applicable !
5344/// // Values shown here are possibly random and not representative !
5345/// let mut req = ApproveBuildRequest::default();
5346///
5347/// // You can configure optional parameters by calling the respective setters at will, and
5348/// // execute the final call using `doit()`.
5349/// // Values shown here are possibly random and not representative !
5350/// let result = hub.projects().builds_approve(req, "name")
5351/// .doit().await;
5352/// # }
5353/// ```
5354pub struct ProjectBuildApproveCall<'a, C>
5355where
5356 C: 'a,
5357{
5358 hub: &'a CloudBuild<C>,
5359 _request: ApproveBuildRequest,
5360 _name: String,
5361 _delegate: Option<&'a mut dyn common::Delegate>,
5362 _additional_params: HashMap<String, String>,
5363 _scopes: BTreeSet<String>,
5364}
5365
5366impl<'a, C> common::CallBuilder for ProjectBuildApproveCall<'a, C> {}
5367
5368impl<'a, C> ProjectBuildApproveCall<'a, C>
5369where
5370 C: common::Connector,
5371{
5372 /// Perform the operation you have build so far.
5373 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
5374 use std::borrow::Cow;
5375 use std::io::{Read, Seek};
5376
5377 use common::{url::Params, ToParts};
5378 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5379
5380 let mut dd = common::DefaultDelegate;
5381 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5382 dlg.begin(common::MethodInfo {
5383 id: "cloudbuild.projects.builds.approve",
5384 http_method: hyper::Method::POST,
5385 });
5386
5387 for &field in ["alt", "name"].iter() {
5388 if self._additional_params.contains_key(field) {
5389 dlg.finished(false);
5390 return Err(common::Error::FieldClash(field));
5391 }
5392 }
5393
5394 let mut params = Params::with_capacity(4 + self._additional_params.len());
5395 params.push("name", self._name);
5396
5397 params.extend(self._additional_params.iter());
5398
5399 params.push("alt", "json");
5400 let mut url = self.hub._base_url.clone() + "v1/{+name}:approve";
5401 if self._scopes.is_empty() {
5402 self._scopes
5403 .insert(Scope::CloudPlatform.as_ref().to_string());
5404 }
5405
5406 #[allow(clippy::single_element_loop)]
5407 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5408 url = params.uri_replacement(url, param_name, find_this, true);
5409 }
5410 {
5411 let to_remove = ["name"];
5412 params.remove_params(&to_remove);
5413 }
5414
5415 let url = params.parse_with_url(&url);
5416
5417 let mut json_mime_type = mime::APPLICATION_JSON;
5418 let mut request_value_reader = {
5419 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5420 common::remove_json_null_values(&mut value);
5421 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5422 serde_json::to_writer(&mut dst, &value).unwrap();
5423 dst
5424 };
5425 let request_size = request_value_reader
5426 .seek(std::io::SeekFrom::End(0))
5427 .unwrap();
5428 request_value_reader
5429 .seek(std::io::SeekFrom::Start(0))
5430 .unwrap();
5431
5432 loop {
5433 let token = match self
5434 .hub
5435 .auth
5436 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5437 .await
5438 {
5439 Ok(token) => token,
5440 Err(e) => match dlg.token(e) {
5441 Ok(token) => token,
5442 Err(e) => {
5443 dlg.finished(false);
5444 return Err(common::Error::MissingToken(e));
5445 }
5446 },
5447 };
5448 request_value_reader
5449 .seek(std::io::SeekFrom::Start(0))
5450 .unwrap();
5451 let mut req_result = {
5452 let client = &self.hub.client;
5453 dlg.pre_request();
5454 let mut req_builder = hyper::Request::builder()
5455 .method(hyper::Method::POST)
5456 .uri(url.as_str())
5457 .header(USER_AGENT, self.hub._user_agent.clone());
5458
5459 if let Some(token) = token.as_ref() {
5460 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5461 }
5462
5463 let request = req_builder
5464 .header(CONTENT_TYPE, json_mime_type.to_string())
5465 .header(CONTENT_LENGTH, request_size as u64)
5466 .body(common::to_body(
5467 request_value_reader.get_ref().clone().into(),
5468 ));
5469
5470 client.request(request.unwrap()).await
5471 };
5472
5473 match req_result {
5474 Err(err) => {
5475 if let common::Retry::After(d) = dlg.http_error(&err) {
5476 sleep(d).await;
5477 continue;
5478 }
5479 dlg.finished(false);
5480 return Err(common::Error::HttpError(err));
5481 }
5482 Ok(res) => {
5483 let (mut parts, body) = res.into_parts();
5484 let mut body = common::Body::new(body);
5485 if !parts.status.is_success() {
5486 let bytes = common::to_bytes(body).await.unwrap_or_default();
5487 let error = serde_json::from_str(&common::to_string(&bytes));
5488 let response = common::to_response(parts, bytes.into());
5489
5490 if let common::Retry::After(d) =
5491 dlg.http_failure(&response, error.as_ref().ok())
5492 {
5493 sleep(d).await;
5494 continue;
5495 }
5496
5497 dlg.finished(false);
5498
5499 return Err(match error {
5500 Ok(value) => common::Error::BadRequest(value),
5501 _ => common::Error::Failure(response),
5502 });
5503 }
5504 let response = {
5505 let bytes = common::to_bytes(body).await.unwrap_or_default();
5506 let encoded = common::to_string(&bytes);
5507 match serde_json::from_str(&encoded) {
5508 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5509 Err(error) => {
5510 dlg.response_json_decode_error(&encoded, &error);
5511 return Err(common::Error::JsonDecodeError(
5512 encoded.to_string(),
5513 error,
5514 ));
5515 }
5516 }
5517 };
5518
5519 dlg.finished(true);
5520 return Ok(response);
5521 }
5522 }
5523 }
5524 }
5525
5526 ///
5527 /// Sets the *request* property to the given value.
5528 ///
5529 /// Even though the property as already been set when instantiating this call,
5530 /// we provide this method for API completeness.
5531 pub fn request(mut self, new_value: ApproveBuildRequest) -> ProjectBuildApproveCall<'a, C> {
5532 self._request = new_value;
5533 self
5534 }
5535 /// Required. Name of the target build. For example: "projects/{$project_id}/builds/{$build_id}"
5536 ///
5537 /// Sets the *name* path property to the given value.
5538 ///
5539 /// Even though the property as already been set when instantiating this call,
5540 /// we provide this method for API completeness.
5541 pub fn name(mut self, new_value: &str) -> ProjectBuildApproveCall<'a, C> {
5542 self._name = new_value.to_string();
5543 self
5544 }
5545 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5546 /// while executing the actual API request.
5547 ///
5548 /// ````text
5549 /// It should be used to handle progress information, and to implement a certain level of resilience.
5550 /// ````
5551 ///
5552 /// Sets the *delegate* property to the given value.
5553 pub fn delegate(
5554 mut self,
5555 new_value: &'a mut dyn common::Delegate,
5556 ) -> ProjectBuildApproveCall<'a, C> {
5557 self._delegate = Some(new_value);
5558 self
5559 }
5560
5561 /// Set any additional parameter of the query string used in the request.
5562 /// It should be used to set parameters which are not yet available through their own
5563 /// setters.
5564 ///
5565 /// Please note that this method must not be used to set any of the known parameters
5566 /// which have their own setter method. If done anyway, the request will fail.
5567 ///
5568 /// # Additional Parameters
5569 ///
5570 /// * *$.xgafv* (query-string) - V1 error format.
5571 /// * *access_token* (query-string) - OAuth access token.
5572 /// * *alt* (query-string) - Data format for response.
5573 /// * *callback* (query-string) - JSONP
5574 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5575 /// * *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.
5576 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5577 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5578 /// * *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.
5579 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5580 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5581 pub fn param<T>(mut self, name: T, value: T) -> ProjectBuildApproveCall<'a, C>
5582 where
5583 T: AsRef<str>,
5584 {
5585 self._additional_params
5586 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5587 self
5588 }
5589
5590 /// Identifies the authorization scope for the method you are building.
5591 ///
5592 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5593 /// [`Scope::CloudPlatform`].
5594 ///
5595 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5596 /// tokens for more than one scope.
5597 ///
5598 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5599 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5600 /// sufficient, a read-write scope will do as well.
5601 pub fn add_scope<St>(mut self, scope: St) -> ProjectBuildApproveCall<'a, C>
5602 where
5603 St: AsRef<str>,
5604 {
5605 self._scopes.insert(String::from(scope.as_ref()));
5606 self
5607 }
5608 /// Identifies the authorization scope(s) for the method you are building.
5609 ///
5610 /// See [`Self::add_scope()`] for details.
5611 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectBuildApproveCall<'a, C>
5612 where
5613 I: IntoIterator<Item = St>,
5614 St: AsRef<str>,
5615 {
5616 self._scopes
5617 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5618 self
5619 }
5620
5621 /// Removes all scopes, and no default scope will be used either.
5622 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5623 /// for details).
5624 pub fn clear_scopes(mut self) -> ProjectBuildApproveCall<'a, C> {
5625 self._scopes.clear();
5626 self
5627 }
5628}
5629
5630/// Cancels a build in progress.
5631///
5632/// A builder for the *builds.cancel* method supported by a *project* resource.
5633/// It is not used directly, but through a [`ProjectMethods`] instance.
5634///
5635/// # Example
5636///
5637/// Instantiate a resource method builder
5638///
5639/// ```test_harness,no_run
5640/// # extern crate hyper;
5641/// # extern crate hyper_rustls;
5642/// # extern crate google_cloudbuild1 as cloudbuild1;
5643/// use cloudbuild1::api::CancelBuildRequest;
5644/// # async fn dox() {
5645/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5646///
5647/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5648/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5649/// # secret,
5650/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5651/// # ).build().await.unwrap();
5652///
5653/// # let client = hyper_util::client::legacy::Client::builder(
5654/// # hyper_util::rt::TokioExecutor::new()
5655/// # )
5656/// # .build(
5657/// # hyper_rustls::HttpsConnectorBuilder::new()
5658/// # .with_native_roots()
5659/// # .unwrap()
5660/// # .https_or_http()
5661/// # .enable_http1()
5662/// # .build()
5663/// # );
5664/// # let mut hub = CloudBuild::new(client, auth);
5665/// // As the method needs a request, you would usually fill it with the desired information
5666/// // into the respective structure. Some of the parts shown here might not be applicable !
5667/// // Values shown here are possibly random and not representative !
5668/// let mut req = CancelBuildRequest::default();
5669///
5670/// // You can configure optional parameters by calling the respective setters at will, and
5671/// // execute the final call using `doit()`.
5672/// // Values shown here are possibly random and not representative !
5673/// let result = hub.projects().builds_cancel(req, "projectId", "id")
5674/// .doit().await;
5675/// # }
5676/// ```
5677pub struct ProjectBuildCancelCall<'a, C>
5678where
5679 C: 'a,
5680{
5681 hub: &'a CloudBuild<C>,
5682 _request: CancelBuildRequest,
5683 _project_id: String,
5684 _id: String,
5685 _delegate: Option<&'a mut dyn common::Delegate>,
5686 _additional_params: HashMap<String, String>,
5687 _scopes: BTreeSet<String>,
5688}
5689
5690impl<'a, C> common::CallBuilder for ProjectBuildCancelCall<'a, C> {}
5691
5692impl<'a, C> ProjectBuildCancelCall<'a, C>
5693where
5694 C: common::Connector,
5695{
5696 /// Perform the operation you have build so far.
5697 pub async fn doit(mut self) -> common::Result<(common::Response, Build)> {
5698 use std::borrow::Cow;
5699 use std::io::{Read, Seek};
5700
5701 use common::{url::Params, ToParts};
5702 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5703
5704 let mut dd = common::DefaultDelegate;
5705 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5706 dlg.begin(common::MethodInfo {
5707 id: "cloudbuild.projects.builds.cancel",
5708 http_method: hyper::Method::POST,
5709 });
5710
5711 for &field in ["alt", "projectId", "id"].iter() {
5712 if self._additional_params.contains_key(field) {
5713 dlg.finished(false);
5714 return Err(common::Error::FieldClash(field));
5715 }
5716 }
5717
5718 let mut params = Params::with_capacity(5 + self._additional_params.len());
5719 params.push("projectId", self._project_id);
5720 params.push("id", self._id);
5721
5722 params.extend(self._additional_params.iter());
5723
5724 params.push("alt", "json");
5725 let mut url = self.hub._base_url.clone() + "v1/projects/{projectId}/builds/{id}:cancel";
5726 if self._scopes.is_empty() {
5727 self._scopes
5728 .insert(Scope::CloudPlatform.as_ref().to_string());
5729 }
5730
5731 #[allow(clippy::single_element_loop)]
5732 for &(find_this, param_name) in [("{projectId}", "projectId"), ("{id}", "id")].iter() {
5733 url = params.uri_replacement(url, param_name, find_this, false);
5734 }
5735 {
5736 let to_remove = ["id", "projectId"];
5737 params.remove_params(&to_remove);
5738 }
5739
5740 let url = params.parse_with_url(&url);
5741
5742 let mut json_mime_type = mime::APPLICATION_JSON;
5743 let mut request_value_reader = {
5744 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5745 common::remove_json_null_values(&mut value);
5746 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5747 serde_json::to_writer(&mut dst, &value).unwrap();
5748 dst
5749 };
5750 let request_size = request_value_reader
5751 .seek(std::io::SeekFrom::End(0))
5752 .unwrap();
5753 request_value_reader
5754 .seek(std::io::SeekFrom::Start(0))
5755 .unwrap();
5756
5757 loop {
5758 let token = match self
5759 .hub
5760 .auth
5761 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5762 .await
5763 {
5764 Ok(token) => token,
5765 Err(e) => match dlg.token(e) {
5766 Ok(token) => token,
5767 Err(e) => {
5768 dlg.finished(false);
5769 return Err(common::Error::MissingToken(e));
5770 }
5771 },
5772 };
5773 request_value_reader
5774 .seek(std::io::SeekFrom::Start(0))
5775 .unwrap();
5776 let mut req_result = {
5777 let client = &self.hub.client;
5778 dlg.pre_request();
5779 let mut req_builder = hyper::Request::builder()
5780 .method(hyper::Method::POST)
5781 .uri(url.as_str())
5782 .header(USER_AGENT, self.hub._user_agent.clone());
5783
5784 if let Some(token) = token.as_ref() {
5785 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5786 }
5787
5788 let request = req_builder
5789 .header(CONTENT_TYPE, json_mime_type.to_string())
5790 .header(CONTENT_LENGTH, request_size as u64)
5791 .body(common::to_body(
5792 request_value_reader.get_ref().clone().into(),
5793 ));
5794
5795 client.request(request.unwrap()).await
5796 };
5797
5798 match req_result {
5799 Err(err) => {
5800 if let common::Retry::After(d) = dlg.http_error(&err) {
5801 sleep(d).await;
5802 continue;
5803 }
5804 dlg.finished(false);
5805 return Err(common::Error::HttpError(err));
5806 }
5807 Ok(res) => {
5808 let (mut parts, body) = res.into_parts();
5809 let mut body = common::Body::new(body);
5810 if !parts.status.is_success() {
5811 let bytes = common::to_bytes(body).await.unwrap_or_default();
5812 let error = serde_json::from_str(&common::to_string(&bytes));
5813 let response = common::to_response(parts, bytes.into());
5814
5815 if let common::Retry::After(d) =
5816 dlg.http_failure(&response, error.as_ref().ok())
5817 {
5818 sleep(d).await;
5819 continue;
5820 }
5821
5822 dlg.finished(false);
5823
5824 return Err(match error {
5825 Ok(value) => common::Error::BadRequest(value),
5826 _ => common::Error::Failure(response),
5827 });
5828 }
5829 let response = {
5830 let bytes = common::to_bytes(body).await.unwrap_or_default();
5831 let encoded = common::to_string(&bytes);
5832 match serde_json::from_str(&encoded) {
5833 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5834 Err(error) => {
5835 dlg.response_json_decode_error(&encoded, &error);
5836 return Err(common::Error::JsonDecodeError(
5837 encoded.to_string(),
5838 error,
5839 ));
5840 }
5841 }
5842 };
5843
5844 dlg.finished(true);
5845 return Ok(response);
5846 }
5847 }
5848 }
5849 }
5850
5851 ///
5852 /// Sets the *request* property to the given value.
5853 ///
5854 /// Even though the property as already been set when instantiating this call,
5855 /// we provide this method for API completeness.
5856 pub fn request(mut self, new_value: CancelBuildRequest) -> ProjectBuildCancelCall<'a, C> {
5857 self._request = new_value;
5858 self
5859 }
5860 /// Required. ID of the project.
5861 ///
5862 /// Sets the *project id* path property to the given value.
5863 ///
5864 /// Even though the property as already been set when instantiating this call,
5865 /// we provide this method for API completeness.
5866 pub fn project_id(mut self, new_value: &str) -> ProjectBuildCancelCall<'a, C> {
5867 self._project_id = new_value.to_string();
5868 self
5869 }
5870 /// Required. ID of the build.
5871 ///
5872 /// Sets the *id* path property to the given value.
5873 ///
5874 /// Even though the property as already been set when instantiating this call,
5875 /// we provide this method for API completeness.
5876 pub fn id(mut self, new_value: &str) -> ProjectBuildCancelCall<'a, C> {
5877 self._id = new_value.to_string();
5878 self
5879 }
5880 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5881 /// while executing the actual API request.
5882 ///
5883 /// ````text
5884 /// It should be used to handle progress information, and to implement a certain level of resilience.
5885 /// ````
5886 ///
5887 /// Sets the *delegate* property to the given value.
5888 pub fn delegate(
5889 mut self,
5890 new_value: &'a mut dyn common::Delegate,
5891 ) -> ProjectBuildCancelCall<'a, C> {
5892 self._delegate = Some(new_value);
5893 self
5894 }
5895
5896 /// Set any additional parameter of the query string used in the request.
5897 /// It should be used to set parameters which are not yet available through their own
5898 /// setters.
5899 ///
5900 /// Please note that this method must not be used to set any of the known parameters
5901 /// which have their own setter method. If done anyway, the request will fail.
5902 ///
5903 /// # Additional Parameters
5904 ///
5905 /// * *$.xgafv* (query-string) - V1 error format.
5906 /// * *access_token* (query-string) - OAuth access token.
5907 /// * *alt* (query-string) - Data format for response.
5908 /// * *callback* (query-string) - JSONP
5909 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5910 /// * *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.
5911 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5912 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5913 /// * *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.
5914 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5915 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5916 pub fn param<T>(mut self, name: T, value: T) -> ProjectBuildCancelCall<'a, C>
5917 where
5918 T: AsRef<str>,
5919 {
5920 self._additional_params
5921 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5922 self
5923 }
5924
5925 /// Identifies the authorization scope for the method you are building.
5926 ///
5927 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5928 /// [`Scope::CloudPlatform`].
5929 ///
5930 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5931 /// tokens for more than one scope.
5932 ///
5933 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5934 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5935 /// sufficient, a read-write scope will do as well.
5936 pub fn add_scope<St>(mut self, scope: St) -> ProjectBuildCancelCall<'a, C>
5937 where
5938 St: AsRef<str>,
5939 {
5940 self._scopes.insert(String::from(scope.as_ref()));
5941 self
5942 }
5943 /// Identifies the authorization scope(s) for the method you are building.
5944 ///
5945 /// See [`Self::add_scope()`] for details.
5946 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectBuildCancelCall<'a, C>
5947 where
5948 I: IntoIterator<Item = St>,
5949 St: AsRef<str>,
5950 {
5951 self._scopes
5952 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5953 self
5954 }
5955
5956 /// Removes all scopes, and no default scope will be used either.
5957 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5958 /// for details).
5959 pub fn clear_scopes(mut self) -> ProjectBuildCancelCall<'a, C> {
5960 self._scopes.clear();
5961 self
5962 }
5963}
5964
5965/// Starts a build with the specified configuration. This method returns a long-running `Operation`, which includes the build ID. Pass the build ID to `GetBuild` to determine the build status (such as `SUCCESS` or `FAILURE`).
5966///
5967/// A builder for the *builds.create* method supported by a *project* resource.
5968/// It is not used directly, but through a [`ProjectMethods`] instance.
5969///
5970/// # Example
5971///
5972/// Instantiate a resource method builder
5973///
5974/// ```test_harness,no_run
5975/// # extern crate hyper;
5976/// # extern crate hyper_rustls;
5977/// # extern crate google_cloudbuild1 as cloudbuild1;
5978/// use cloudbuild1::api::Build;
5979/// # async fn dox() {
5980/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5981///
5982/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5983/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5984/// # secret,
5985/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5986/// # ).build().await.unwrap();
5987///
5988/// # let client = hyper_util::client::legacy::Client::builder(
5989/// # hyper_util::rt::TokioExecutor::new()
5990/// # )
5991/// # .build(
5992/// # hyper_rustls::HttpsConnectorBuilder::new()
5993/// # .with_native_roots()
5994/// # .unwrap()
5995/// # .https_or_http()
5996/// # .enable_http1()
5997/// # .build()
5998/// # );
5999/// # let mut hub = CloudBuild::new(client, auth);
6000/// // As the method needs a request, you would usually fill it with the desired information
6001/// // into the respective structure. Some of the parts shown here might not be applicable !
6002/// // Values shown here are possibly random and not representative !
6003/// let mut req = Build::default();
6004///
6005/// // You can configure optional parameters by calling the respective setters at will, and
6006/// // execute the final call using `doit()`.
6007/// // Values shown here are possibly random and not representative !
6008/// let result = hub.projects().builds_create(req, "projectId")
6009/// .parent("ea")
6010/// .doit().await;
6011/// # }
6012/// ```
6013pub struct ProjectBuildCreateCall<'a, C>
6014where
6015 C: 'a,
6016{
6017 hub: &'a CloudBuild<C>,
6018 _request: Build,
6019 _project_id: String,
6020 _parent: Option<String>,
6021 _delegate: Option<&'a mut dyn common::Delegate>,
6022 _additional_params: HashMap<String, String>,
6023 _scopes: BTreeSet<String>,
6024}
6025
6026impl<'a, C> common::CallBuilder for ProjectBuildCreateCall<'a, C> {}
6027
6028impl<'a, C> ProjectBuildCreateCall<'a, C>
6029where
6030 C: common::Connector,
6031{
6032 /// Perform the operation you have build so far.
6033 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
6034 use std::borrow::Cow;
6035 use std::io::{Read, Seek};
6036
6037 use common::{url::Params, ToParts};
6038 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6039
6040 let mut dd = common::DefaultDelegate;
6041 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6042 dlg.begin(common::MethodInfo {
6043 id: "cloudbuild.projects.builds.create",
6044 http_method: hyper::Method::POST,
6045 });
6046
6047 for &field in ["alt", "projectId", "parent"].iter() {
6048 if self._additional_params.contains_key(field) {
6049 dlg.finished(false);
6050 return Err(common::Error::FieldClash(field));
6051 }
6052 }
6053
6054 let mut params = Params::with_capacity(5 + self._additional_params.len());
6055 params.push("projectId", self._project_id);
6056 if let Some(value) = self._parent.as_ref() {
6057 params.push("parent", value);
6058 }
6059
6060 params.extend(self._additional_params.iter());
6061
6062 params.push("alt", "json");
6063 let mut url = self.hub._base_url.clone() + "v1/projects/{projectId}/builds";
6064 if self._scopes.is_empty() {
6065 self._scopes
6066 .insert(Scope::CloudPlatform.as_ref().to_string());
6067 }
6068
6069 #[allow(clippy::single_element_loop)]
6070 for &(find_this, param_name) in [("{projectId}", "projectId")].iter() {
6071 url = params.uri_replacement(url, param_name, find_this, false);
6072 }
6073 {
6074 let to_remove = ["projectId"];
6075 params.remove_params(&to_remove);
6076 }
6077
6078 let url = params.parse_with_url(&url);
6079
6080 let mut json_mime_type = mime::APPLICATION_JSON;
6081 let mut request_value_reader = {
6082 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6083 common::remove_json_null_values(&mut value);
6084 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6085 serde_json::to_writer(&mut dst, &value).unwrap();
6086 dst
6087 };
6088 let request_size = request_value_reader
6089 .seek(std::io::SeekFrom::End(0))
6090 .unwrap();
6091 request_value_reader
6092 .seek(std::io::SeekFrom::Start(0))
6093 .unwrap();
6094
6095 loop {
6096 let token = match self
6097 .hub
6098 .auth
6099 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6100 .await
6101 {
6102 Ok(token) => token,
6103 Err(e) => match dlg.token(e) {
6104 Ok(token) => token,
6105 Err(e) => {
6106 dlg.finished(false);
6107 return Err(common::Error::MissingToken(e));
6108 }
6109 },
6110 };
6111 request_value_reader
6112 .seek(std::io::SeekFrom::Start(0))
6113 .unwrap();
6114 let mut req_result = {
6115 let client = &self.hub.client;
6116 dlg.pre_request();
6117 let mut req_builder = hyper::Request::builder()
6118 .method(hyper::Method::POST)
6119 .uri(url.as_str())
6120 .header(USER_AGENT, self.hub._user_agent.clone());
6121
6122 if let Some(token) = token.as_ref() {
6123 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6124 }
6125
6126 let request = req_builder
6127 .header(CONTENT_TYPE, json_mime_type.to_string())
6128 .header(CONTENT_LENGTH, request_size as u64)
6129 .body(common::to_body(
6130 request_value_reader.get_ref().clone().into(),
6131 ));
6132
6133 client.request(request.unwrap()).await
6134 };
6135
6136 match req_result {
6137 Err(err) => {
6138 if let common::Retry::After(d) = dlg.http_error(&err) {
6139 sleep(d).await;
6140 continue;
6141 }
6142 dlg.finished(false);
6143 return Err(common::Error::HttpError(err));
6144 }
6145 Ok(res) => {
6146 let (mut parts, body) = res.into_parts();
6147 let mut body = common::Body::new(body);
6148 if !parts.status.is_success() {
6149 let bytes = common::to_bytes(body).await.unwrap_or_default();
6150 let error = serde_json::from_str(&common::to_string(&bytes));
6151 let response = common::to_response(parts, bytes.into());
6152
6153 if let common::Retry::After(d) =
6154 dlg.http_failure(&response, error.as_ref().ok())
6155 {
6156 sleep(d).await;
6157 continue;
6158 }
6159
6160 dlg.finished(false);
6161
6162 return Err(match error {
6163 Ok(value) => common::Error::BadRequest(value),
6164 _ => common::Error::Failure(response),
6165 });
6166 }
6167 let response = {
6168 let bytes = common::to_bytes(body).await.unwrap_or_default();
6169 let encoded = common::to_string(&bytes);
6170 match serde_json::from_str(&encoded) {
6171 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6172 Err(error) => {
6173 dlg.response_json_decode_error(&encoded, &error);
6174 return Err(common::Error::JsonDecodeError(
6175 encoded.to_string(),
6176 error,
6177 ));
6178 }
6179 }
6180 };
6181
6182 dlg.finished(true);
6183 return Ok(response);
6184 }
6185 }
6186 }
6187 }
6188
6189 ///
6190 /// Sets the *request* property to the given value.
6191 ///
6192 /// Even though the property as already been set when instantiating this call,
6193 /// we provide this method for API completeness.
6194 pub fn request(mut self, new_value: Build) -> ProjectBuildCreateCall<'a, C> {
6195 self._request = new_value;
6196 self
6197 }
6198 /// Required. ID of the project.
6199 ///
6200 /// Sets the *project id* path property to the given value.
6201 ///
6202 /// Even though the property as already been set when instantiating this call,
6203 /// we provide this method for API completeness.
6204 pub fn project_id(mut self, new_value: &str) -> ProjectBuildCreateCall<'a, C> {
6205 self._project_id = new_value.to_string();
6206 self
6207 }
6208 /// The parent resource where this build will be created. Format: `projects/{project}/locations/{location}`
6209 ///
6210 /// Sets the *parent* query property to the given value.
6211 pub fn parent(mut self, new_value: &str) -> ProjectBuildCreateCall<'a, C> {
6212 self._parent = Some(new_value.to_string());
6213 self
6214 }
6215 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6216 /// while executing the actual API request.
6217 ///
6218 /// ````text
6219 /// It should be used to handle progress information, and to implement a certain level of resilience.
6220 /// ````
6221 ///
6222 /// Sets the *delegate* property to the given value.
6223 pub fn delegate(
6224 mut self,
6225 new_value: &'a mut dyn common::Delegate,
6226 ) -> ProjectBuildCreateCall<'a, C> {
6227 self._delegate = Some(new_value);
6228 self
6229 }
6230
6231 /// Set any additional parameter of the query string used in the request.
6232 /// It should be used to set parameters which are not yet available through their own
6233 /// setters.
6234 ///
6235 /// Please note that this method must not be used to set any of the known parameters
6236 /// which have their own setter method. If done anyway, the request will fail.
6237 ///
6238 /// # Additional Parameters
6239 ///
6240 /// * *$.xgafv* (query-string) - V1 error format.
6241 /// * *access_token* (query-string) - OAuth access token.
6242 /// * *alt* (query-string) - Data format for response.
6243 /// * *callback* (query-string) - JSONP
6244 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6245 /// * *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.
6246 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6247 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6248 /// * *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.
6249 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6250 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6251 pub fn param<T>(mut self, name: T, value: T) -> ProjectBuildCreateCall<'a, C>
6252 where
6253 T: AsRef<str>,
6254 {
6255 self._additional_params
6256 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6257 self
6258 }
6259
6260 /// Identifies the authorization scope for the method you are building.
6261 ///
6262 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6263 /// [`Scope::CloudPlatform`].
6264 ///
6265 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6266 /// tokens for more than one scope.
6267 ///
6268 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6269 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6270 /// sufficient, a read-write scope will do as well.
6271 pub fn add_scope<St>(mut self, scope: St) -> ProjectBuildCreateCall<'a, C>
6272 where
6273 St: AsRef<str>,
6274 {
6275 self._scopes.insert(String::from(scope.as_ref()));
6276 self
6277 }
6278 /// Identifies the authorization scope(s) for the method you are building.
6279 ///
6280 /// See [`Self::add_scope()`] for details.
6281 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectBuildCreateCall<'a, C>
6282 where
6283 I: IntoIterator<Item = St>,
6284 St: AsRef<str>,
6285 {
6286 self._scopes
6287 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6288 self
6289 }
6290
6291 /// Removes all scopes, and no default scope will be used either.
6292 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6293 /// for details).
6294 pub fn clear_scopes(mut self) -> ProjectBuildCreateCall<'a, C> {
6295 self._scopes.clear();
6296 self
6297 }
6298}
6299
6300/// Returns information about a previously requested build. The `Build` that is returned includes its status (such as `SUCCESS`, `FAILURE`, or `WORKING`), and timing information.
6301///
6302/// A builder for the *builds.get* method supported by a *project* resource.
6303/// It is not used directly, but through a [`ProjectMethods`] instance.
6304///
6305/// # Example
6306///
6307/// Instantiate a resource method builder
6308///
6309/// ```test_harness,no_run
6310/// # extern crate hyper;
6311/// # extern crate hyper_rustls;
6312/// # extern crate google_cloudbuild1 as cloudbuild1;
6313/// # async fn dox() {
6314/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6315///
6316/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6317/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6318/// # secret,
6319/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6320/// # ).build().await.unwrap();
6321///
6322/// # let client = hyper_util::client::legacy::Client::builder(
6323/// # hyper_util::rt::TokioExecutor::new()
6324/// # )
6325/// # .build(
6326/// # hyper_rustls::HttpsConnectorBuilder::new()
6327/// # .with_native_roots()
6328/// # .unwrap()
6329/// # .https_or_http()
6330/// # .enable_http1()
6331/// # .build()
6332/// # );
6333/// # let mut hub = CloudBuild::new(client, auth);
6334/// // You can configure optional parameters by calling the respective setters at will, and
6335/// // execute the final call using `doit()`.
6336/// // Values shown here are possibly random and not representative !
6337/// let result = hub.projects().builds_get("projectId", "id")
6338/// .name("amet")
6339/// .doit().await;
6340/// # }
6341/// ```
6342pub struct ProjectBuildGetCall<'a, C>
6343where
6344 C: 'a,
6345{
6346 hub: &'a CloudBuild<C>,
6347 _project_id: String,
6348 _id: String,
6349 _name: Option<String>,
6350 _delegate: Option<&'a mut dyn common::Delegate>,
6351 _additional_params: HashMap<String, String>,
6352 _scopes: BTreeSet<String>,
6353}
6354
6355impl<'a, C> common::CallBuilder for ProjectBuildGetCall<'a, C> {}
6356
6357impl<'a, C> ProjectBuildGetCall<'a, C>
6358where
6359 C: common::Connector,
6360{
6361 /// Perform the operation you have build so far.
6362 pub async fn doit(mut self) -> common::Result<(common::Response, Build)> {
6363 use std::borrow::Cow;
6364 use std::io::{Read, Seek};
6365
6366 use common::{url::Params, ToParts};
6367 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6368
6369 let mut dd = common::DefaultDelegate;
6370 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6371 dlg.begin(common::MethodInfo {
6372 id: "cloudbuild.projects.builds.get",
6373 http_method: hyper::Method::GET,
6374 });
6375
6376 for &field in ["alt", "projectId", "id", "name"].iter() {
6377 if self._additional_params.contains_key(field) {
6378 dlg.finished(false);
6379 return Err(common::Error::FieldClash(field));
6380 }
6381 }
6382
6383 let mut params = Params::with_capacity(5 + self._additional_params.len());
6384 params.push("projectId", self._project_id);
6385 params.push("id", self._id);
6386 if let Some(value) = self._name.as_ref() {
6387 params.push("name", value);
6388 }
6389
6390 params.extend(self._additional_params.iter());
6391
6392 params.push("alt", "json");
6393 let mut url = self.hub._base_url.clone() + "v1/projects/{projectId}/builds/{id}";
6394 if self._scopes.is_empty() {
6395 self._scopes
6396 .insert(Scope::CloudPlatform.as_ref().to_string());
6397 }
6398
6399 #[allow(clippy::single_element_loop)]
6400 for &(find_this, param_name) in [("{projectId}", "projectId"), ("{id}", "id")].iter() {
6401 url = params.uri_replacement(url, param_name, find_this, false);
6402 }
6403 {
6404 let to_remove = ["id", "projectId"];
6405 params.remove_params(&to_remove);
6406 }
6407
6408 let url = params.parse_with_url(&url);
6409
6410 loop {
6411 let token = match self
6412 .hub
6413 .auth
6414 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6415 .await
6416 {
6417 Ok(token) => token,
6418 Err(e) => match dlg.token(e) {
6419 Ok(token) => token,
6420 Err(e) => {
6421 dlg.finished(false);
6422 return Err(common::Error::MissingToken(e));
6423 }
6424 },
6425 };
6426 let mut req_result = {
6427 let client = &self.hub.client;
6428 dlg.pre_request();
6429 let mut req_builder = hyper::Request::builder()
6430 .method(hyper::Method::GET)
6431 .uri(url.as_str())
6432 .header(USER_AGENT, self.hub._user_agent.clone());
6433
6434 if let Some(token) = token.as_ref() {
6435 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6436 }
6437
6438 let request = req_builder
6439 .header(CONTENT_LENGTH, 0_u64)
6440 .body(common::to_body::<String>(None));
6441
6442 client.request(request.unwrap()).await
6443 };
6444
6445 match req_result {
6446 Err(err) => {
6447 if let common::Retry::After(d) = dlg.http_error(&err) {
6448 sleep(d).await;
6449 continue;
6450 }
6451 dlg.finished(false);
6452 return Err(common::Error::HttpError(err));
6453 }
6454 Ok(res) => {
6455 let (mut parts, body) = res.into_parts();
6456 let mut body = common::Body::new(body);
6457 if !parts.status.is_success() {
6458 let bytes = common::to_bytes(body).await.unwrap_or_default();
6459 let error = serde_json::from_str(&common::to_string(&bytes));
6460 let response = common::to_response(parts, bytes.into());
6461
6462 if let common::Retry::After(d) =
6463 dlg.http_failure(&response, error.as_ref().ok())
6464 {
6465 sleep(d).await;
6466 continue;
6467 }
6468
6469 dlg.finished(false);
6470
6471 return Err(match error {
6472 Ok(value) => common::Error::BadRequest(value),
6473 _ => common::Error::Failure(response),
6474 });
6475 }
6476 let response = {
6477 let bytes = common::to_bytes(body).await.unwrap_or_default();
6478 let encoded = common::to_string(&bytes);
6479 match serde_json::from_str(&encoded) {
6480 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6481 Err(error) => {
6482 dlg.response_json_decode_error(&encoded, &error);
6483 return Err(common::Error::JsonDecodeError(
6484 encoded.to_string(),
6485 error,
6486 ));
6487 }
6488 }
6489 };
6490
6491 dlg.finished(true);
6492 return Ok(response);
6493 }
6494 }
6495 }
6496 }
6497
6498 /// Required. ID of the project.
6499 ///
6500 /// Sets the *project id* path property to the given value.
6501 ///
6502 /// Even though the property as already been set when instantiating this call,
6503 /// we provide this method for API completeness.
6504 pub fn project_id(mut self, new_value: &str) -> ProjectBuildGetCall<'a, C> {
6505 self._project_id = new_value.to_string();
6506 self
6507 }
6508 /// Required. ID of the build.
6509 ///
6510 /// Sets the *id* path property to the given value.
6511 ///
6512 /// Even though the property as already been set when instantiating this call,
6513 /// we provide this method for API completeness.
6514 pub fn id(mut self, new_value: &str) -> ProjectBuildGetCall<'a, C> {
6515 self._id = new_value.to_string();
6516 self
6517 }
6518 /// The name of the `Build` to retrieve. Format: `projects/{project}/locations/{location}/builds/{build}`
6519 ///
6520 /// Sets the *name* query property to the given value.
6521 pub fn name(mut self, new_value: &str) -> ProjectBuildGetCall<'a, C> {
6522 self._name = Some(new_value.to_string());
6523 self
6524 }
6525 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6526 /// while executing the actual API request.
6527 ///
6528 /// ````text
6529 /// It should be used to handle progress information, and to implement a certain level of resilience.
6530 /// ````
6531 ///
6532 /// Sets the *delegate* property to the given value.
6533 pub fn delegate(
6534 mut self,
6535 new_value: &'a mut dyn common::Delegate,
6536 ) -> ProjectBuildGetCall<'a, C> {
6537 self._delegate = Some(new_value);
6538 self
6539 }
6540
6541 /// Set any additional parameter of the query string used in the request.
6542 /// It should be used to set parameters which are not yet available through their own
6543 /// setters.
6544 ///
6545 /// Please note that this method must not be used to set any of the known parameters
6546 /// which have their own setter method. If done anyway, the request will fail.
6547 ///
6548 /// # Additional Parameters
6549 ///
6550 /// * *$.xgafv* (query-string) - V1 error format.
6551 /// * *access_token* (query-string) - OAuth access token.
6552 /// * *alt* (query-string) - Data format for response.
6553 /// * *callback* (query-string) - JSONP
6554 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6555 /// * *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.
6556 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6557 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6558 /// * *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.
6559 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6560 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6561 pub fn param<T>(mut self, name: T, value: T) -> ProjectBuildGetCall<'a, C>
6562 where
6563 T: AsRef<str>,
6564 {
6565 self._additional_params
6566 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6567 self
6568 }
6569
6570 /// Identifies the authorization scope for the method you are building.
6571 ///
6572 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6573 /// [`Scope::CloudPlatform`].
6574 ///
6575 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6576 /// tokens for more than one scope.
6577 ///
6578 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6579 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6580 /// sufficient, a read-write scope will do as well.
6581 pub fn add_scope<St>(mut self, scope: St) -> ProjectBuildGetCall<'a, C>
6582 where
6583 St: AsRef<str>,
6584 {
6585 self._scopes.insert(String::from(scope.as_ref()));
6586 self
6587 }
6588 /// Identifies the authorization scope(s) for the method you are building.
6589 ///
6590 /// See [`Self::add_scope()`] for details.
6591 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectBuildGetCall<'a, C>
6592 where
6593 I: IntoIterator<Item = St>,
6594 St: AsRef<str>,
6595 {
6596 self._scopes
6597 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6598 self
6599 }
6600
6601 /// Removes all scopes, and no default scope will be used either.
6602 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6603 /// for details).
6604 pub fn clear_scopes(mut self) -> ProjectBuildGetCall<'a, C> {
6605 self._scopes.clear();
6606 self
6607 }
6608}
6609
6610/// Lists previously requested builds. Previously requested builds may still be in-progress, or may have finished successfully or unsuccessfully.
6611///
6612/// A builder for the *builds.list* method supported by a *project* resource.
6613/// It is not used directly, but through a [`ProjectMethods`] instance.
6614///
6615/// # Example
6616///
6617/// Instantiate a resource method builder
6618///
6619/// ```test_harness,no_run
6620/// # extern crate hyper;
6621/// # extern crate hyper_rustls;
6622/// # extern crate google_cloudbuild1 as cloudbuild1;
6623/// # async fn dox() {
6624/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6625///
6626/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6627/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6628/// # secret,
6629/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6630/// # ).build().await.unwrap();
6631///
6632/// # let client = hyper_util::client::legacy::Client::builder(
6633/// # hyper_util::rt::TokioExecutor::new()
6634/// # )
6635/// # .build(
6636/// # hyper_rustls::HttpsConnectorBuilder::new()
6637/// # .with_native_roots()
6638/// # .unwrap()
6639/// # .https_or_http()
6640/// # .enable_http1()
6641/// # .build()
6642/// # );
6643/// # let mut hub = CloudBuild::new(client, auth);
6644/// // You can configure optional parameters by calling the respective setters at will, and
6645/// // execute the final call using `doit()`.
6646/// // Values shown here are possibly random and not representative !
6647/// let result = hub.projects().builds_list("projectId")
6648/// .parent("ipsum")
6649/// .page_token("sed")
6650/// .page_size(-37)
6651/// .filter("gubergren")
6652/// .doit().await;
6653/// # }
6654/// ```
6655pub struct ProjectBuildListCall<'a, C>
6656where
6657 C: 'a,
6658{
6659 hub: &'a CloudBuild<C>,
6660 _project_id: String,
6661 _parent: Option<String>,
6662 _page_token: Option<String>,
6663 _page_size: Option<i32>,
6664 _filter: Option<String>,
6665 _delegate: Option<&'a mut dyn common::Delegate>,
6666 _additional_params: HashMap<String, String>,
6667 _scopes: BTreeSet<String>,
6668}
6669
6670impl<'a, C> common::CallBuilder for ProjectBuildListCall<'a, C> {}
6671
6672impl<'a, C> ProjectBuildListCall<'a, C>
6673where
6674 C: common::Connector,
6675{
6676 /// Perform the operation you have build so far.
6677 pub async fn doit(mut self) -> common::Result<(common::Response, ListBuildsResponse)> {
6678 use std::borrow::Cow;
6679 use std::io::{Read, Seek};
6680
6681 use common::{url::Params, ToParts};
6682 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6683
6684 let mut dd = common::DefaultDelegate;
6685 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6686 dlg.begin(common::MethodInfo {
6687 id: "cloudbuild.projects.builds.list",
6688 http_method: hyper::Method::GET,
6689 });
6690
6691 for &field in [
6692 "alt",
6693 "projectId",
6694 "parent",
6695 "pageToken",
6696 "pageSize",
6697 "filter",
6698 ]
6699 .iter()
6700 {
6701 if self._additional_params.contains_key(field) {
6702 dlg.finished(false);
6703 return Err(common::Error::FieldClash(field));
6704 }
6705 }
6706
6707 let mut params = Params::with_capacity(7 + self._additional_params.len());
6708 params.push("projectId", self._project_id);
6709 if let Some(value) = self._parent.as_ref() {
6710 params.push("parent", value);
6711 }
6712 if let Some(value) = self._page_token.as_ref() {
6713 params.push("pageToken", value);
6714 }
6715 if let Some(value) = self._page_size.as_ref() {
6716 params.push("pageSize", value.to_string());
6717 }
6718 if let Some(value) = self._filter.as_ref() {
6719 params.push("filter", value);
6720 }
6721
6722 params.extend(self._additional_params.iter());
6723
6724 params.push("alt", "json");
6725 let mut url = self.hub._base_url.clone() + "v1/projects/{projectId}/builds";
6726 if self._scopes.is_empty() {
6727 self._scopes
6728 .insert(Scope::CloudPlatform.as_ref().to_string());
6729 }
6730
6731 #[allow(clippy::single_element_loop)]
6732 for &(find_this, param_name) in [("{projectId}", "projectId")].iter() {
6733 url = params.uri_replacement(url, param_name, find_this, false);
6734 }
6735 {
6736 let to_remove = ["projectId"];
6737 params.remove_params(&to_remove);
6738 }
6739
6740 let url = params.parse_with_url(&url);
6741
6742 loop {
6743 let token = match self
6744 .hub
6745 .auth
6746 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6747 .await
6748 {
6749 Ok(token) => token,
6750 Err(e) => match dlg.token(e) {
6751 Ok(token) => token,
6752 Err(e) => {
6753 dlg.finished(false);
6754 return Err(common::Error::MissingToken(e));
6755 }
6756 },
6757 };
6758 let mut req_result = {
6759 let client = &self.hub.client;
6760 dlg.pre_request();
6761 let mut req_builder = hyper::Request::builder()
6762 .method(hyper::Method::GET)
6763 .uri(url.as_str())
6764 .header(USER_AGENT, self.hub._user_agent.clone());
6765
6766 if let Some(token) = token.as_ref() {
6767 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6768 }
6769
6770 let request = req_builder
6771 .header(CONTENT_LENGTH, 0_u64)
6772 .body(common::to_body::<String>(None));
6773
6774 client.request(request.unwrap()).await
6775 };
6776
6777 match req_result {
6778 Err(err) => {
6779 if let common::Retry::After(d) = dlg.http_error(&err) {
6780 sleep(d).await;
6781 continue;
6782 }
6783 dlg.finished(false);
6784 return Err(common::Error::HttpError(err));
6785 }
6786 Ok(res) => {
6787 let (mut parts, body) = res.into_parts();
6788 let mut body = common::Body::new(body);
6789 if !parts.status.is_success() {
6790 let bytes = common::to_bytes(body).await.unwrap_or_default();
6791 let error = serde_json::from_str(&common::to_string(&bytes));
6792 let response = common::to_response(parts, bytes.into());
6793
6794 if let common::Retry::After(d) =
6795 dlg.http_failure(&response, error.as_ref().ok())
6796 {
6797 sleep(d).await;
6798 continue;
6799 }
6800
6801 dlg.finished(false);
6802
6803 return Err(match error {
6804 Ok(value) => common::Error::BadRequest(value),
6805 _ => common::Error::Failure(response),
6806 });
6807 }
6808 let response = {
6809 let bytes = common::to_bytes(body).await.unwrap_or_default();
6810 let encoded = common::to_string(&bytes);
6811 match serde_json::from_str(&encoded) {
6812 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6813 Err(error) => {
6814 dlg.response_json_decode_error(&encoded, &error);
6815 return Err(common::Error::JsonDecodeError(
6816 encoded.to_string(),
6817 error,
6818 ));
6819 }
6820 }
6821 };
6822
6823 dlg.finished(true);
6824 return Ok(response);
6825 }
6826 }
6827 }
6828 }
6829
6830 /// Required. ID of the project.
6831 ///
6832 /// Sets the *project id* path property to the given value.
6833 ///
6834 /// Even though the property as already been set when instantiating this call,
6835 /// we provide this method for API completeness.
6836 pub fn project_id(mut self, new_value: &str) -> ProjectBuildListCall<'a, C> {
6837 self._project_id = new_value.to_string();
6838 self
6839 }
6840 /// The parent of the collection of `Builds`. Format: `projects/{project}/locations/{location}`
6841 ///
6842 /// Sets the *parent* query property to the given value.
6843 pub fn parent(mut self, new_value: &str) -> ProjectBuildListCall<'a, C> {
6844 self._parent = Some(new_value.to_string());
6845 self
6846 }
6847 /// The page token for the next page of Builds. If unspecified, the first page of results is returned. If the token is rejected for any reason, INVALID_ARGUMENT will be thrown. In this case, the token should be discarded, and pagination should be restarted from the first page of results. See https://google.aip.dev/158 for more.
6848 ///
6849 /// Sets the *page token* query property to the given value.
6850 pub fn page_token(mut self, new_value: &str) -> ProjectBuildListCall<'a, C> {
6851 self._page_token = Some(new_value.to_string());
6852 self
6853 }
6854 /// Number of results to return in the list.
6855 ///
6856 /// Sets the *page size* query property to the given value.
6857 pub fn page_size(mut self, new_value: i32) -> ProjectBuildListCall<'a, C> {
6858 self._page_size = Some(new_value);
6859 self
6860 }
6861 /// The raw filter text to constrain the results.
6862 ///
6863 /// Sets the *filter* query property to the given value.
6864 pub fn filter(mut self, new_value: &str) -> ProjectBuildListCall<'a, C> {
6865 self._filter = Some(new_value.to_string());
6866 self
6867 }
6868 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6869 /// while executing the actual API request.
6870 ///
6871 /// ````text
6872 /// It should be used to handle progress information, and to implement a certain level of resilience.
6873 /// ````
6874 ///
6875 /// Sets the *delegate* property to the given value.
6876 pub fn delegate(
6877 mut self,
6878 new_value: &'a mut dyn common::Delegate,
6879 ) -> ProjectBuildListCall<'a, C> {
6880 self._delegate = Some(new_value);
6881 self
6882 }
6883
6884 /// Set any additional parameter of the query string used in the request.
6885 /// It should be used to set parameters which are not yet available through their own
6886 /// setters.
6887 ///
6888 /// Please note that this method must not be used to set any of the known parameters
6889 /// which have their own setter method. If done anyway, the request will fail.
6890 ///
6891 /// # Additional Parameters
6892 ///
6893 /// * *$.xgafv* (query-string) - V1 error format.
6894 /// * *access_token* (query-string) - OAuth access token.
6895 /// * *alt* (query-string) - Data format for response.
6896 /// * *callback* (query-string) - JSONP
6897 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6898 /// * *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.
6899 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6900 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6901 /// * *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.
6902 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6903 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6904 pub fn param<T>(mut self, name: T, value: T) -> ProjectBuildListCall<'a, C>
6905 where
6906 T: AsRef<str>,
6907 {
6908 self._additional_params
6909 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6910 self
6911 }
6912
6913 /// Identifies the authorization scope for the method you are building.
6914 ///
6915 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6916 /// [`Scope::CloudPlatform`].
6917 ///
6918 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6919 /// tokens for more than one scope.
6920 ///
6921 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6922 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6923 /// sufficient, a read-write scope will do as well.
6924 pub fn add_scope<St>(mut self, scope: St) -> ProjectBuildListCall<'a, C>
6925 where
6926 St: AsRef<str>,
6927 {
6928 self._scopes.insert(String::from(scope.as_ref()));
6929 self
6930 }
6931 /// Identifies the authorization scope(s) for the method you are building.
6932 ///
6933 /// See [`Self::add_scope()`] for details.
6934 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectBuildListCall<'a, C>
6935 where
6936 I: IntoIterator<Item = St>,
6937 St: AsRef<str>,
6938 {
6939 self._scopes
6940 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6941 self
6942 }
6943
6944 /// Removes all scopes, and no default scope will be used either.
6945 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6946 /// for details).
6947 pub fn clear_scopes(mut self) -> ProjectBuildListCall<'a, C> {
6948 self._scopes.clear();
6949 self
6950 }
6951}
6952
6953/// Creates a new build based on the specified build. This method creates a new build using the original build request, which may or may not result in an identical build. For triggered builds: * Triggered builds resolve to a precise revision; therefore a retry of a triggered build will result in a build that uses the same revision. For non-triggered builds that specify `RepoSource`: * If the original build built from the tip of a branch, the retried build will build from the tip of that branch, which may not be the same revision as the original build. * If the original build specified a commit sha or revision ID, the retried build will use the identical source. For builds that specify `StorageSource`: * If the original build pulled source from Cloud Storage without specifying the generation of the object, the new build will use the current object, which may be different from the original build source. * If the original build pulled source from Cloud Storage and specified the generation of the object, the new build will attempt to use the same object, which may or may not be available depending on the bucket's lifecycle management settings.
6954///
6955/// A builder for the *builds.retry* method supported by a *project* resource.
6956/// It is not used directly, but through a [`ProjectMethods`] instance.
6957///
6958/// # Example
6959///
6960/// Instantiate a resource method builder
6961///
6962/// ```test_harness,no_run
6963/// # extern crate hyper;
6964/// # extern crate hyper_rustls;
6965/// # extern crate google_cloudbuild1 as cloudbuild1;
6966/// use cloudbuild1::api::RetryBuildRequest;
6967/// # async fn dox() {
6968/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6969///
6970/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6971/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6972/// # secret,
6973/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6974/// # ).build().await.unwrap();
6975///
6976/// # let client = hyper_util::client::legacy::Client::builder(
6977/// # hyper_util::rt::TokioExecutor::new()
6978/// # )
6979/// # .build(
6980/// # hyper_rustls::HttpsConnectorBuilder::new()
6981/// # .with_native_roots()
6982/// # .unwrap()
6983/// # .https_or_http()
6984/// # .enable_http1()
6985/// # .build()
6986/// # );
6987/// # let mut hub = CloudBuild::new(client, auth);
6988/// // As the method needs a request, you would usually fill it with the desired information
6989/// // into the respective structure. Some of the parts shown here might not be applicable !
6990/// // Values shown here are possibly random and not representative !
6991/// let mut req = RetryBuildRequest::default();
6992///
6993/// // You can configure optional parameters by calling the respective setters at will, and
6994/// // execute the final call using `doit()`.
6995/// // Values shown here are possibly random and not representative !
6996/// let result = hub.projects().builds_retry(req, "projectId", "id")
6997/// .doit().await;
6998/// # }
6999/// ```
7000pub struct ProjectBuildRetryCall<'a, C>
7001where
7002 C: 'a,
7003{
7004 hub: &'a CloudBuild<C>,
7005 _request: RetryBuildRequest,
7006 _project_id: String,
7007 _id: String,
7008 _delegate: Option<&'a mut dyn common::Delegate>,
7009 _additional_params: HashMap<String, String>,
7010 _scopes: BTreeSet<String>,
7011}
7012
7013impl<'a, C> common::CallBuilder for ProjectBuildRetryCall<'a, C> {}
7014
7015impl<'a, C> ProjectBuildRetryCall<'a, C>
7016where
7017 C: common::Connector,
7018{
7019 /// Perform the operation you have build so far.
7020 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
7021 use std::borrow::Cow;
7022 use std::io::{Read, Seek};
7023
7024 use common::{url::Params, ToParts};
7025 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7026
7027 let mut dd = common::DefaultDelegate;
7028 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7029 dlg.begin(common::MethodInfo {
7030 id: "cloudbuild.projects.builds.retry",
7031 http_method: hyper::Method::POST,
7032 });
7033
7034 for &field in ["alt", "projectId", "id"].iter() {
7035 if self._additional_params.contains_key(field) {
7036 dlg.finished(false);
7037 return Err(common::Error::FieldClash(field));
7038 }
7039 }
7040
7041 let mut params = Params::with_capacity(5 + self._additional_params.len());
7042 params.push("projectId", self._project_id);
7043 params.push("id", self._id);
7044
7045 params.extend(self._additional_params.iter());
7046
7047 params.push("alt", "json");
7048 let mut url = self.hub._base_url.clone() + "v1/projects/{projectId}/builds/{id}:retry";
7049 if self._scopes.is_empty() {
7050 self._scopes
7051 .insert(Scope::CloudPlatform.as_ref().to_string());
7052 }
7053
7054 #[allow(clippy::single_element_loop)]
7055 for &(find_this, param_name) in [("{projectId}", "projectId"), ("{id}", "id")].iter() {
7056 url = params.uri_replacement(url, param_name, find_this, false);
7057 }
7058 {
7059 let to_remove = ["id", "projectId"];
7060 params.remove_params(&to_remove);
7061 }
7062
7063 let url = params.parse_with_url(&url);
7064
7065 let mut json_mime_type = mime::APPLICATION_JSON;
7066 let mut request_value_reader = {
7067 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7068 common::remove_json_null_values(&mut value);
7069 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7070 serde_json::to_writer(&mut dst, &value).unwrap();
7071 dst
7072 };
7073 let request_size = request_value_reader
7074 .seek(std::io::SeekFrom::End(0))
7075 .unwrap();
7076 request_value_reader
7077 .seek(std::io::SeekFrom::Start(0))
7078 .unwrap();
7079
7080 loop {
7081 let token = match self
7082 .hub
7083 .auth
7084 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7085 .await
7086 {
7087 Ok(token) => token,
7088 Err(e) => match dlg.token(e) {
7089 Ok(token) => token,
7090 Err(e) => {
7091 dlg.finished(false);
7092 return Err(common::Error::MissingToken(e));
7093 }
7094 },
7095 };
7096 request_value_reader
7097 .seek(std::io::SeekFrom::Start(0))
7098 .unwrap();
7099 let mut req_result = {
7100 let client = &self.hub.client;
7101 dlg.pre_request();
7102 let mut req_builder = hyper::Request::builder()
7103 .method(hyper::Method::POST)
7104 .uri(url.as_str())
7105 .header(USER_AGENT, self.hub._user_agent.clone());
7106
7107 if let Some(token) = token.as_ref() {
7108 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7109 }
7110
7111 let request = req_builder
7112 .header(CONTENT_TYPE, json_mime_type.to_string())
7113 .header(CONTENT_LENGTH, request_size as u64)
7114 .body(common::to_body(
7115 request_value_reader.get_ref().clone().into(),
7116 ));
7117
7118 client.request(request.unwrap()).await
7119 };
7120
7121 match req_result {
7122 Err(err) => {
7123 if let common::Retry::After(d) = dlg.http_error(&err) {
7124 sleep(d).await;
7125 continue;
7126 }
7127 dlg.finished(false);
7128 return Err(common::Error::HttpError(err));
7129 }
7130 Ok(res) => {
7131 let (mut parts, body) = res.into_parts();
7132 let mut body = common::Body::new(body);
7133 if !parts.status.is_success() {
7134 let bytes = common::to_bytes(body).await.unwrap_or_default();
7135 let error = serde_json::from_str(&common::to_string(&bytes));
7136 let response = common::to_response(parts, bytes.into());
7137
7138 if let common::Retry::After(d) =
7139 dlg.http_failure(&response, error.as_ref().ok())
7140 {
7141 sleep(d).await;
7142 continue;
7143 }
7144
7145 dlg.finished(false);
7146
7147 return Err(match error {
7148 Ok(value) => common::Error::BadRequest(value),
7149 _ => common::Error::Failure(response),
7150 });
7151 }
7152 let response = {
7153 let bytes = common::to_bytes(body).await.unwrap_or_default();
7154 let encoded = common::to_string(&bytes);
7155 match serde_json::from_str(&encoded) {
7156 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7157 Err(error) => {
7158 dlg.response_json_decode_error(&encoded, &error);
7159 return Err(common::Error::JsonDecodeError(
7160 encoded.to_string(),
7161 error,
7162 ));
7163 }
7164 }
7165 };
7166
7167 dlg.finished(true);
7168 return Ok(response);
7169 }
7170 }
7171 }
7172 }
7173
7174 ///
7175 /// Sets the *request* property to the given value.
7176 ///
7177 /// Even though the property as already been set when instantiating this call,
7178 /// we provide this method for API completeness.
7179 pub fn request(mut self, new_value: RetryBuildRequest) -> ProjectBuildRetryCall<'a, C> {
7180 self._request = new_value;
7181 self
7182 }
7183 /// Required. ID of the project.
7184 ///
7185 /// Sets the *project id* path property to the given value.
7186 ///
7187 /// Even though the property as already been set when instantiating this call,
7188 /// we provide this method for API completeness.
7189 pub fn project_id(mut self, new_value: &str) -> ProjectBuildRetryCall<'a, C> {
7190 self._project_id = new_value.to_string();
7191 self
7192 }
7193 /// Required. Build ID of the original build.
7194 ///
7195 /// Sets the *id* path property to the given value.
7196 ///
7197 /// Even though the property as already been set when instantiating this call,
7198 /// we provide this method for API completeness.
7199 pub fn id(mut self, new_value: &str) -> ProjectBuildRetryCall<'a, C> {
7200 self._id = new_value.to_string();
7201 self
7202 }
7203 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7204 /// while executing the actual API request.
7205 ///
7206 /// ````text
7207 /// It should be used to handle progress information, and to implement a certain level of resilience.
7208 /// ````
7209 ///
7210 /// Sets the *delegate* property to the given value.
7211 pub fn delegate(
7212 mut self,
7213 new_value: &'a mut dyn common::Delegate,
7214 ) -> ProjectBuildRetryCall<'a, C> {
7215 self._delegate = Some(new_value);
7216 self
7217 }
7218
7219 /// Set any additional parameter of the query string used in the request.
7220 /// It should be used to set parameters which are not yet available through their own
7221 /// setters.
7222 ///
7223 /// Please note that this method must not be used to set any of the known parameters
7224 /// which have their own setter method. If done anyway, the request will fail.
7225 ///
7226 /// # Additional Parameters
7227 ///
7228 /// * *$.xgafv* (query-string) - V1 error format.
7229 /// * *access_token* (query-string) - OAuth access token.
7230 /// * *alt* (query-string) - Data format for response.
7231 /// * *callback* (query-string) - JSONP
7232 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7233 /// * *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.
7234 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7235 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7236 /// * *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.
7237 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7238 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7239 pub fn param<T>(mut self, name: T, value: T) -> ProjectBuildRetryCall<'a, C>
7240 where
7241 T: AsRef<str>,
7242 {
7243 self._additional_params
7244 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7245 self
7246 }
7247
7248 /// Identifies the authorization scope for the method you are building.
7249 ///
7250 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7251 /// [`Scope::CloudPlatform`].
7252 ///
7253 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7254 /// tokens for more than one scope.
7255 ///
7256 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7257 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7258 /// sufficient, a read-write scope will do as well.
7259 pub fn add_scope<St>(mut self, scope: St) -> ProjectBuildRetryCall<'a, C>
7260 where
7261 St: AsRef<str>,
7262 {
7263 self._scopes.insert(String::from(scope.as_ref()));
7264 self
7265 }
7266 /// Identifies the authorization scope(s) for the method you are building.
7267 ///
7268 /// See [`Self::add_scope()`] for details.
7269 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectBuildRetryCall<'a, C>
7270 where
7271 I: IntoIterator<Item = St>,
7272 St: AsRef<str>,
7273 {
7274 self._scopes
7275 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7276 self
7277 }
7278
7279 /// Removes all scopes, and no default scope will be used either.
7280 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7281 /// for details).
7282 pub fn clear_scopes(mut self) -> ProjectBuildRetryCall<'a, C> {
7283 self._scopes.clear();
7284 self
7285 }
7286}
7287
7288/// Create an association between a GCP project and a GitHub Enterprise server.
7289///
7290/// A builder for the *githubEnterpriseConfigs.create* method supported by a *project* resource.
7291/// It is not used directly, but through a [`ProjectMethods`] instance.
7292///
7293/// # Example
7294///
7295/// Instantiate a resource method builder
7296///
7297/// ```test_harness,no_run
7298/// # extern crate hyper;
7299/// # extern crate hyper_rustls;
7300/// # extern crate google_cloudbuild1 as cloudbuild1;
7301/// use cloudbuild1::api::GitHubEnterpriseConfig;
7302/// # async fn dox() {
7303/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7304///
7305/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7306/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7307/// # secret,
7308/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7309/// # ).build().await.unwrap();
7310///
7311/// # let client = hyper_util::client::legacy::Client::builder(
7312/// # hyper_util::rt::TokioExecutor::new()
7313/// # )
7314/// # .build(
7315/// # hyper_rustls::HttpsConnectorBuilder::new()
7316/// # .with_native_roots()
7317/// # .unwrap()
7318/// # .https_or_http()
7319/// # .enable_http1()
7320/// # .build()
7321/// # );
7322/// # let mut hub = CloudBuild::new(client, auth);
7323/// // As the method needs a request, you would usually fill it with the desired information
7324/// // into the respective structure. Some of the parts shown here might not be applicable !
7325/// // Values shown here are possibly random and not representative !
7326/// let mut req = GitHubEnterpriseConfig::default();
7327///
7328/// // You can configure optional parameters by calling the respective setters at will, and
7329/// // execute the final call using `doit()`.
7330/// // Values shown here are possibly random and not representative !
7331/// let result = hub.projects().github_enterprise_configs_create(req, "parent")
7332/// .project_id("ipsum")
7333/// .ghe_config_id("est")
7334/// .doit().await;
7335/// # }
7336/// ```
7337pub struct ProjectGithubEnterpriseConfigCreateCall<'a, C>
7338where
7339 C: 'a,
7340{
7341 hub: &'a CloudBuild<C>,
7342 _request: GitHubEnterpriseConfig,
7343 _parent: String,
7344 _project_id: Option<String>,
7345 _ghe_config_id: Option<String>,
7346 _delegate: Option<&'a mut dyn common::Delegate>,
7347 _additional_params: HashMap<String, String>,
7348 _scopes: BTreeSet<String>,
7349}
7350
7351impl<'a, C> common::CallBuilder for ProjectGithubEnterpriseConfigCreateCall<'a, C> {}
7352
7353impl<'a, C> ProjectGithubEnterpriseConfigCreateCall<'a, C>
7354where
7355 C: common::Connector,
7356{
7357 /// Perform the operation you have build so far.
7358 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
7359 use std::borrow::Cow;
7360 use std::io::{Read, Seek};
7361
7362 use common::{url::Params, ToParts};
7363 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7364
7365 let mut dd = common::DefaultDelegate;
7366 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7367 dlg.begin(common::MethodInfo {
7368 id: "cloudbuild.projects.githubEnterpriseConfigs.create",
7369 http_method: hyper::Method::POST,
7370 });
7371
7372 for &field in ["alt", "parent", "projectId", "gheConfigId"].iter() {
7373 if self._additional_params.contains_key(field) {
7374 dlg.finished(false);
7375 return Err(common::Error::FieldClash(field));
7376 }
7377 }
7378
7379 let mut params = Params::with_capacity(6 + self._additional_params.len());
7380 params.push("parent", self._parent);
7381 if let Some(value) = self._project_id.as_ref() {
7382 params.push("projectId", value);
7383 }
7384 if let Some(value) = self._ghe_config_id.as_ref() {
7385 params.push("gheConfigId", value);
7386 }
7387
7388 params.extend(self._additional_params.iter());
7389
7390 params.push("alt", "json");
7391 let mut url = self.hub._base_url.clone() + "v1/{+parent}/githubEnterpriseConfigs";
7392 if self._scopes.is_empty() {
7393 self._scopes
7394 .insert(Scope::CloudPlatform.as_ref().to_string());
7395 }
7396
7397 #[allow(clippy::single_element_loop)]
7398 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
7399 url = params.uri_replacement(url, param_name, find_this, true);
7400 }
7401 {
7402 let to_remove = ["parent"];
7403 params.remove_params(&to_remove);
7404 }
7405
7406 let url = params.parse_with_url(&url);
7407
7408 let mut json_mime_type = mime::APPLICATION_JSON;
7409 let mut request_value_reader = {
7410 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7411 common::remove_json_null_values(&mut value);
7412 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7413 serde_json::to_writer(&mut dst, &value).unwrap();
7414 dst
7415 };
7416 let request_size = request_value_reader
7417 .seek(std::io::SeekFrom::End(0))
7418 .unwrap();
7419 request_value_reader
7420 .seek(std::io::SeekFrom::Start(0))
7421 .unwrap();
7422
7423 loop {
7424 let token = match self
7425 .hub
7426 .auth
7427 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7428 .await
7429 {
7430 Ok(token) => token,
7431 Err(e) => match dlg.token(e) {
7432 Ok(token) => token,
7433 Err(e) => {
7434 dlg.finished(false);
7435 return Err(common::Error::MissingToken(e));
7436 }
7437 },
7438 };
7439 request_value_reader
7440 .seek(std::io::SeekFrom::Start(0))
7441 .unwrap();
7442 let mut req_result = {
7443 let client = &self.hub.client;
7444 dlg.pre_request();
7445 let mut req_builder = hyper::Request::builder()
7446 .method(hyper::Method::POST)
7447 .uri(url.as_str())
7448 .header(USER_AGENT, self.hub._user_agent.clone());
7449
7450 if let Some(token) = token.as_ref() {
7451 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7452 }
7453
7454 let request = req_builder
7455 .header(CONTENT_TYPE, json_mime_type.to_string())
7456 .header(CONTENT_LENGTH, request_size as u64)
7457 .body(common::to_body(
7458 request_value_reader.get_ref().clone().into(),
7459 ));
7460
7461 client.request(request.unwrap()).await
7462 };
7463
7464 match req_result {
7465 Err(err) => {
7466 if let common::Retry::After(d) = dlg.http_error(&err) {
7467 sleep(d).await;
7468 continue;
7469 }
7470 dlg.finished(false);
7471 return Err(common::Error::HttpError(err));
7472 }
7473 Ok(res) => {
7474 let (mut parts, body) = res.into_parts();
7475 let mut body = common::Body::new(body);
7476 if !parts.status.is_success() {
7477 let bytes = common::to_bytes(body).await.unwrap_or_default();
7478 let error = serde_json::from_str(&common::to_string(&bytes));
7479 let response = common::to_response(parts, bytes.into());
7480
7481 if let common::Retry::After(d) =
7482 dlg.http_failure(&response, error.as_ref().ok())
7483 {
7484 sleep(d).await;
7485 continue;
7486 }
7487
7488 dlg.finished(false);
7489
7490 return Err(match error {
7491 Ok(value) => common::Error::BadRequest(value),
7492 _ => common::Error::Failure(response),
7493 });
7494 }
7495 let response = {
7496 let bytes = common::to_bytes(body).await.unwrap_or_default();
7497 let encoded = common::to_string(&bytes);
7498 match serde_json::from_str(&encoded) {
7499 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7500 Err(error) => {
7501 dlg.response_json_decode_error(&encoded, &error);
7502 return Err(common::Error::JsonDecodeError(
7503 encoded.to_string(),
7504 error,
7505 ));
7506 }
7507 }
7508 };
7509
7510 dlg.finished(true);
7511 return Ok(response);
7512 }
7513 }
7514 }
7515 }
7516
7517 ///
7518 /// Sets the *request* property to the given value.
7519 ///
7520 /// Even though the property as already been set when instantiating this call,
7521 /// we provide this method for API completeness.
7522 pub fn request(
7523 mut self,
7524 new_value: GitHubEnterpriseConfig,
7525 ) -> ProjectGithubEnterpriseConfigCreateCall<'a, C> {
7526 self._request = new_value;
7527 self
7528 }
7529 /// Required. Name of the parent project. For example: projects/{$project_number} or projects/{$project_id}
7530 ///
7531 /// Sets the *parent* path property to the given value.
7532 ///
7533 /// Even though the property as already been set when instantiating this call,
7534 /// we provide this method for API completeness.
7535 pub fn parent(mut self, new_value: &str) -> ProjectGithubEnterpriseConfigCreateCall<'a, C> {
7536 self._parent = new_value.to_string();
7537 self
7538 }
7539 /// ID of the project.
7540 ///
7541 /// Sets the *project id* query property to the given value.
7542 pub fn project_id(mut self, new_value: &str) -> ProjectGithubEnterpriseConfigCreateCall<'a, C> {
7543 self._project_id = Some(new_value.to_string());
7544 self
7545 }
7546 /// Optional. The ID to use for the GithubEnterpriseConfig, which will become the final component of the GithubEnterpriseConfig's resource name. ghe_config_id must meet the following requirements: + They must contain only alphanumeric characters and dashes. + They can be 1-64 characters long. + They must begin and end with an alphanumeric character
7547 ///
7548 /// Sets the *ghe config id* query property to the given value.
7549 pub fn ghe_config_id(
7550 mut self,
7551 new_value: &str,
7552 ) -> ProjectGithubEnterpriseConfigCreateCall<'a, C> {
7553 self._ghe_config_id = Some(new_value.to_string());
7554 self
7555 }
7556 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7557 /// while executing the actual API request.
7558 ///
7559 /// ````text
7560 /// It should be used to handle progress information, and to implement a certain level of resilience.
7561 /// ````
7562 ///
7563 /// Sets the *delegate* property to the given value.
7564 pub fn delegate(
7565 mut self,
7566 new_value: &'a mut dyn common::Delegate,
7567 ) -> ProjectGithubEnterpriseConfigCreateCall<'a, C> {
7568 self._delegate = Some(new_value);
7569 self
7570 }
7571
7572 /// Set any additional parameter of the query string used in the request.
7573 /// It should be used to set parameters which are not yet available through their own
7574 /// setters.
7575 ///
7576 /// Please note that this method must not be used to set any of the known parameters
7577 /// which have their own setter method. If done anyway, the request will fail.
7578 ///
7579 /// # Additional Parameters
7580 ///
7581 /// * *$.xgafv* (query-string) - V1 error format.
7582 /// * *access_token* (query-string) - OAuth access token.
7583 /// * *alt* (query-string) - Data format for response.
7584 /// * *callback* (query-string) - JSONP
7585 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7586 /// * *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.
7587 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7588 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7589 /// * *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.
7590 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7591 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7592 pub fn param<T>(mut self, name: T, value: T) -> ProjectGithubEnterpriseConfigCreateCall<'a, C>
7593 where
7594 T: AsRef<str>,
7595 {
7596 self._additional_params
7597 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7598 self
7599 }
7600
7601 /// Identifies the authorization scope for the method you are building.
7602 ///
7603 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7604 /// [`Scope::CloudPlatform`].
7605 ///
7606 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7607 /// tokens for more than one scope.
7608 ///
7609 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7610 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7611 /// sufficient, a read-write scope will do as well.
7612 pub fn add_scope<St>(mut self, scope: St) -> ProjectGithubEnterpriseConfigCreateCall<'a, C>
7613 where
7614 St: AsRef<str>,
7615 {
7616 self._scopes.insert(String::from(scope.as_ref()));
7617 self
7618 }
7619 /// Identifies the authorization scope(s) for the method you are building.
7620 ///
7621 /// See [`Self::add_scope()`] for details.
7622 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectGithubEnterpriseConfigCreateCall<'a, C>
7623 where
7624 I: IntoIterator<Item = St>,
7625 St: AsRef<str>,
7626 {
7627 self._scopes
7628 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7629 self
7630 }
7631
7632 /// Removes all scopes, and no default scope will be used either.
7633 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7634 /// for details).
7635 pub fn clear_scopes(mut self) -> ProjectGithubEnterpriseConfigCreateCall<'a, C> {
7636 self._scopes.clear();
7637 self
7638 }
7639}
7640
7641/// Delete an association between a GCP project and a GitHub Enterprise server.
7642///
7643/// A builder for the *githubEnterpriseConfigs.delete* method supported by a *project* resource.
7644/// It is not used directly, but through a [`ProjectMethods`] instance.
7645///
7646/// # Example
7647///
7648/// Instantiate a resource method builder
7649///
7650/// ```test_harness,no_run
7651/// # extern crate hyper;
7652/// # extern crate hyper_rustls;
7653/// # extern crate google_cloudbuild1 as cloudbuild1;
7654/// # async fn dox() {
7655/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7656///
7657/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7658/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7659/// # secret,
7660/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7661/// # ).build().await.unwrap();
7662///
7663/// # let client = hyper_util::client::legacy::Client::builder(
7664/// # hyper_util::rt::TokioExecutor::new()
7665/// # )
7666/// # .build(
7667/// # hyper_rustls::HttpsConnectorBuilder::new()
7668/// # .with_native_roots()
7669/// # .unwrap()
7670/// # .https_or_http()
7671/// # .enable_http1()
7672/// # .build()
7673/// # );
7674/// # let mut hub = CloudBuild::new(client, auth);
7675/// // You can configure optional parameters by calling the respective setters at will, and
7676/// // execute the final call using `doit()`.
7677/// // Values shown here are possibly random and not representative !
7678/// let result = hub.projects().github_enterprise_configs_delete("name")
7679/// .project_id("ea")
7680/// .config_id("dolor")
7681/// .doit().await;
7682/// # }
7683/// ```
7684pub struct ProjectGithubEnterpriseConfigDeleteCall<'a, C>
7685where
7686 C: 'a,
7687{
7688 hub: &'a CloudBuild<C>,
7689 _name: String,
7690 _project_id: Option<String>,
7691 _config_id: Option<String>,
7692 _delegate: Option<&'a mut dyn common::Delegate>,
7693 _additional_params: HashMap<String, String>,
7694 _scopes: BTreeSet<String>,
7695}
7696
7697impl<'a, C> common::CallBuilder for ProjectGithubEnterpriseConfigDeleteCall<'a, C> {}
7698
7699impl<'a, C> ProjectGithubEnterpriseConfigDeleteCall<'a, C>
7700where
7701 C: common::Connector,
7702{
7703 /// Perform the operation you have build so far.
7704 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
7705 use std::borrow::Cow;
7706 use std::io::{Read, Seek};
7707
7708 use common::{url::Params, ToParts};
7709 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7710
7711 let mut dd = common::DefaultDelegate;
7712 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7713 dlg.begin(common::MethodInfo {
7714 id: "cloudbuild.projects.githubEnterpriseConfigs.delete",
7715 http_method: hyper::Method::DELETE,
7716 });
7717
7718 for &field in ["alt", "name", "projectId", "configId"].iter() {
7719 if self._additional_params.contains_key(field) {
7720 dlg.finished(false);
7721 return Err(common::Error::FieldClash(field));
7722 }
7723 }
7724
7725 let mut params = Params::with_capacity(5 + self._additional_params.len());
7726 params.push("name", self._name);
7727 if let Some(value) = self._project_id.as_ref() {
7728 params.push("projectId", value);
7729 }
7730 if let Some(value) = self._config_id.as_ref() {
7731 params.push("configId", value);
7732 }
7733
7734 params.extend(self._additional_params.iter());
7735
7736 params.push("alt", "json");
7737 let mut url = self.hub._base_url.clone() + "v1/{+name}";
7738 if self._scopes.is_empty() {
7739 self._scopes
7740 .insert(Scope::CloudPlatform.as_ref().to_string());
7741 }
7742
7743 #[allow(clippy::single_element_loop)]
7744 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7745 url = params.uri_replacement(url, param_name, find_this, true);
7746 }
7747 {
7748 let to_remove = ["name"];
7749 params.remove_params(&to_remove);
7750 }
7751
7752 let url = params.parse_with_url(&url);
7753
7754 loop {
7755 let token = match self
7756 .hub
7757 .auth
7758 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7759 .await
7760 {
7761 Ok(token) => token,
7762 Err(e) => match dlg.token(e) {
7763 Ok(token) => token,
7764 Err(e) => {
7765 dlg.finished(false);
7766 return Err(common::Error::MissingToken(e));
7767 }
7768 },
7769 };
7770 let mut req_result = {
7771 let client = &self.hub.client;
7772 dlg.pre_request();
7773 let mut req_builder = hyper::Request::builder()
7774 .method(hyper::Method::DELETE)
7775 .uri(url.as_str())
7776 .header(USER_AGENT, self.hub._user_agent.clone());
7777
7778 if let Some(token) = token.as_ref() {
7779 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7780 }
7781
7782 let request = req_builder
7783 .header(CONTENT_LENGTH, 0_u64)
7784 .body(common::to_body::<String>(None));
7785
7786 client.request(request.unwrap()).await
7787 };
7788
7789 match req_result {
7790 Err(err) => {
7791 if let common::Retry::After(d) = dlg.http_error(&err) {
7792 sleep(d).await;
7793 continue;
7794 }
7795 dlg.finished(false);
7796 return Err(common::Error::HttpError(err));
7797 }
7798 Ok(res) => {
7799 let (mut parts, body) = res.into_parts();
7800 let mut body = common::Body::new(body);
7801 if !parts.status.is_success() {
7802 let bytes = common::to_bytes(body).await.unwrap_or_default();
7803 let error = serde_json::from_str(&common::to_string(&bytes));
7804 let response = common::to_response(parts, bytes.into());
7805
7806 if let common::Retry::After(d) =
7807 dlg.http_failure(&response, error.as_ref().ok())
7808 {
7809 sleep(d).await;
7810 continue;
7811 }
7812
7813 dlg.finished(false);
7814
7815 return Err(match error {
7816 Ok(value) => common::Error::BadRequest(value),
7817 _ => common::Error::Failure(response),
7818 });
7819 }
7820 let response = {
7821 let bytes = common::to_bytes(body).await.unwrap_or_default();
7822 let encoded = common::to_string(&bytes);
7823 match serde_json::from_str(&encoded) {
7824 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7825 Err(error) => {
7826 dlg.response_json_decode_error(&encoded, &error);
7827 return Err(common::Error::JsonDecodeError(
7828 encoded.to_string(),
7829 error,
7830 ));
7831 }
7832 }
7833 };
7834
7835 dlg.finished(true);
7836 return Ok(response);
7837 }
7838 }
7839 }
7840 }
7841
7842 /// This field should contain the name of the enterprise config resource. For example: "projects/{$project_id}/locations/{$location_id}/githubEnterpriseConfigs/{$config_id}"
7843 ///
7844 /// Sets the *name* path property to the given value.
7845 ///
7846 /// Even though the property as already been set when instantiating this call,
7847 /// we provide this method for API completeness.
7848 pub fn name(mut self, new_value: &str) -> ProjectGithubEnterpriseConfigDeleteCall<'a, C> {
7849 self._name = new_value.to_string();
7850 self
7851 }
7852 /// ID of the project
7853 ///
7854 /// Sets the *project id* query property to the given value.
7855 pub fn project_id(mut self, new_value: &str) -> ProjectGithubEnterpriseConfigDeleteCall<'a, C> {
7856 self._project_id = Some(new_value.to_string());
7857 self
7858 }
7859 /// Unique identifier of the `GitHubEnterpriseConfig`
7860 ///
7861 /// Sets the *config id* query property to the given value.
7862 pub fn config_id(mut self, new_value: &str) -> ProjectGithubEnterpriseConfigDeleteCall<'a, C> {
7863 self._config_id = Some(new_value.to_string());
7864 self
7865 }
7866 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7867 /// while executing the actual API request.
7868 ///
7869 /// ````text
7870 /// It should be used to handle progress information, and to implement a certain level of resilience.
7871 /// ````
7872 ///
7873 /// Sets the *delegate* property to the given value.
7874 pub fn delegate(
7875 mut self,
7876 new_value: &'a mut dyn common::Delegate,
7877 ) -> ProjectGithubEnterpriseConfigDeleteCall<'a, C> {
7878 self._delegate = Some(new_value);
7879 self
7880 }
7881
7882 /// Set any additional parameter of the query string used in the request.
7883 /// It should be used to set parameters which are not yet available through their own
7884 /// setters.
7885 ///
7886 /// Please note that this method must not be used to set any of the known parameters
7887 /// which have their own setter method. If done anyway, the request will fail.
7888 ///
7889 /// # Additional Parameters
7890 ///
7891 /// * *$.xgafv* (query-string) - V1 error format.
7892 /// * *access_token* (query-string) - OAuth access token.
7893 /// * *alt* (query-string) - Data format for response.
7894 /// * *callback* (query-string) - JSONP
7895 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7896 /// * *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.
7897 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7898 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7899 /// * *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.
7900 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7901 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7902 pub fn param<T>(mut self, name: T, value: T) -> ProjectGithubEnterpriseConfigDeleteCall<'a, C>
7903 where
7904 T: AsRef<str>,
7905 {
7906 self._additional_params
7907 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7908 self
7909 }
7910
7911 /// Identifies the authorization scope for the method you are building.
7912 ///
7913 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7914 /// [`Scope::CloudPlatform`].
7915 ///
7916 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7917 /// tokens for more than one scope.
7918 ///
7919 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7920 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7921 /// sufficient, a read-write scope will do as well.
7922 pub fn add_scope<St>(mut self, scope: St) -> ProjectGithubEnterpriseConfigDeleteCall<'a, C>
7923 where
7924 St: AsRef<str>,
7925 {
7926 self._scopes.insert(String::from(scope.as_ref()));
7927 self
7928 }
7929 /// Identifies the authorization scope(s) for the method you are building.
7930 ///
7931 /// See [`Self::add_scope()`] for details.
7932 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectGithubEnterpriseConfigDeleteCall<'a, C>
7933 where
7934 I: IntoIterator<Item = St>,
7935 St: AsRef<str>,
7936 {
7937 self._scopes
7938 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7939 self
7940 }
7941
7942 /// Removes all scopes, and no default scope will be used either.
7943 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7944 /// for details).
7945 pub fn clear_scopes(mut self) -> ProjectGithubEnterpriseConfigDeleteCall<'a, C> {
7946 self._scopes.clear();
7947 self
7948 }
7949}
7950
7951/// Retrieve a GitHubEnterpriseConfig.
7952///
7953/// A builder for the *githubEnterpriseConfigs.get* method supported by a *project* resource.
7954/// It is not used directly, but through a [`ProjectMethods`] instance.
7955///
7956/// # Example
7957///
7958/// Instantiate a resource method builder
7959///
7960/// ```test_harness,no_run
7961/// # extern crate hyper;
7962/// # extern crate hyper_rustls;
7963/// # extern crate google_cloudbuild1 as cloudbuild1;
7964/// # async fn dox() {
7965/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7966///
7967/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7968/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7969/// # secret,
7970/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7971/// # ).build().await.unwrap();
7972///
7973/// # let client = hyper_util::client::legacy::Client::builder(
7974/// # hyper_util::rt::TokioExecutor::new()
7975/// # )
7976/// # .build(
7977/// # hyper_rustls::HttpsConnectorBuilder::new()
7978/// # .with_native_roots()
7979/// # .unwrap()
7980/// # .https_or_http()
7981/// # .enable_http1()
7982/// # .build()
7983/// # );
7984/// # let mut hub = CloudBuild::new(client, auth);
7985/// // You can configure optional parameters by calling the respective setters at will, and
7986/// // execute the final call using `doit()`.
7987/// // Values shown here are possibly random and not representative !
7988/// let result = hub.projects().github_enterprise_configs_get("name")
7989/// .project_id("eos")
7990/// .config_id("labore")
7991/// .doit().await;
7992/// # }
7993/// ```
7994pub struct ProjectGithubEnterpriseConfigGetCall<'a, C>
7995where
7996 C: 'a,
7997{
7998 hub: &'a CloudBuild<C>,
7999 _name: String,
8000 _project_id: Option<String>,
8001 _config_id: Option<String>,
8002 _delegate: Option<&'a mut dyn common::Delegate>,
8003 _additional_params: HashMap<String, String>,
8004 _scopes: BTreeSet<String>,
8005}
8006
8007impl<'a, C> common::CallBuilder for ProjectGithubEnterpriseConfigGetCall<'a, C> {}
8008
8009impl<'a, C> ProjectGithubEnterpriseConfigGetCall<'a, C>
8010where
8011 C: common::Connector,
8012{
8013 /// Perform the operation you have build so far.
8014 pub async fn doit(mut self) -> common::Result<(common::Response, GitHubEnterpriseConfig)> {
8015 use std::borrow::Cow;
8016 use std::io::{Read, Seek};
8017
8018 use common::{url::Params, ToParts};
8019 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8020
8021 let mut dd = common::DefaultDelegate;
8022 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8023 dlg.begin(common::MethodInfo {
8024 id: "cloudbuild.projects.githubEnterpriseConfigs.get",
8025 http_method: hyper::Method::GET,
8026 });
8027
8028 for &field in ["alt", "name", "projectId", "configId"].iter() {
8029 if self._additional_params.contains_key(field) {
8030 dlg.finished(false);
8031 return Err(common::Error::FieldClash(field));
8032 }
8033 }
8034
8035 let mut params = Params::with_capacity(5 + self._additional_params.len());
8036 params.push("name", self._name);
8037 if let Some(value) = self._project_id.as_ref() {
8038 params.push("projectId", value);
8039 }
8040 if let Some(value) = self._config_id.as_ref() {
8041 params.push("configId", value);
8042 }
8043
8044 params.extend(self._additional_params.iter());
8045
8046 params.push("alt", "json");
8047 let mut url = self.hub._base_url.clone() + "v1/{+name}";
8048 if self._scopes.is_empty() {
8049 self._scopes
8050 .insert(Scope::CloudPlatform.as_ref().to_string());
8051 }
8052
8053 #[allow(clippy::single_element_loop)]
8054 for &(find_this, param_name) in [("{+name}", "name")].iter() {
8055 url = params.uri_replacement(url, param_name, find_this, true);
8056 }
8057 {
8058 let to_remove = ["name"];
8059 params.remove_params(&to_remove);
8060 }
8061
8062 let url = params.parse_with_url(&url);
8063
8064 loop {
8065 let token = match self
8066 .hub
8067 .auth
8068 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8069 .await
8070 {
8071 Ok(token) => token,
8072 Err(e) => match dlg.token(e) {
8073 Ok(token) => token,
8074 Err(e) => {
8075 dlg.finished(false);
8076 return Err(common::Error::MissingToken(e));
8077 }
8078 },
8079 };
8080 let mut req_result = {
8081 let client = &self.hub.client;
8082 dlg.pre_request();
8083 let mut req_builder = hyper::Request::builder()
8084 .method(hyper::Method::GET)
8085 .uri(url.as_str())
8086 .header(USER_AGENT, self.hub._user_agent.clone());
8087
8088 if let Some(token) = token.as_ref() {
8089 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8090 }
8091
8092 let request = req_builder
8093 .header(CONTENT_LENGTH, 0_u64)
8094 .body(common::to_body::<String>(None));
8095
8096 client.request(request.unwrap()).await
8097 };
8098
8099 match req_result {
8100 Err(err) => {
8101 if let common::Retry::After(d) = dlg.http_error(&err) {
8102 sleep(d).await;
8103 continue;
8104 }
8105 dlg.finished(false);
8106 return Err(common::Error::HttpError(err));
8107 }
8108 Ok(res) => {
8109 let (mut parts, body) = res.into_parts();
8110 let mut body = common::Body::new(body);
8111 if !parts.status.is_success() {
8112 let bytes = common::to_bytes(body).await.unwrap_or_default();
8113 let error = serde_json::from_str(&common::to_string(&bytes));
8114 let response = common::to_response(parts, bytes.into());
8115
8116 if let common::Retry::After(d) =
8117 dlg.http_failure(&response, error.as_ref().ok())
8118 {
8119 sleep(d).await;
8120 continue;
8121 }
8122
8123 dlg.finished(false);
8124
8125 return Err(match error {
8126 Ok(value) => common::Error::BadRequest(value),
8127 _ => common::Error::Failure(response),
8128 });
8129 }
8130 let response = {
8131 let bytes = common::to_bytes(body).await.unwrap_or_default();
8132 let encoded = common::to_string(&bytes);
8133 match serde_json::from_str(&encoded) {
8134 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8135 Err(error) => {
8136 dlg.response_json_decode_error(&encoded, &error);
8137 return Err(common::Error::JsonDecodeError(
8138 encoded.to_string(),
8139 error,
8140 ));
8141 }
8142 }
8143 };
8144
8145 dlg.finished(true);
8146 return Ok(response);
8147 }
8148 }
8149 }
8150 }
8151
8152 /// This field should contain the name of the enterprise config resource. For example: "projects/{$project_id}/locations/{$location_id}/githubEnterpriseConfigs/{$config_id}"
8153 ///
8154 /// Sets the *name* path property to the given value.
8155 ///
8156 /// Even though the property as already been set when instantiating this call,
8157 /// we provide this method for API completeness.
8158 pub fn name(mut self, new_value: &str) -> ProjectGithubEnterpriseConfigGetCall<'a, C> {
8159 self._name = new_value.to_string();
8160 self
8161 }
8162 /// ID of the project
8163 ///
8164 /// Sets the *project id* query property to the given value.
8165 pub fn project_id(mut self, new_value: &str) -> ProjectGithubEnterpriseConfigGetCall<'a, C> {
8166 self._project_id = Some(new_value.to_string());
8167 self
8168 }
8169 /// Unique identifier of the `GitHubEnterpriseConfig`
8170 ///
8171 /// Sets the *config id* query property to the given value.
8172 pub fn config_id(mut self, new_value: &str) -> ProjectGithubEnterpriseConfigGetCall<'a, C> {
8173 self._config_id = Some(new_value.to_string());
8174 self
8175 }
8176 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8177 /// while executing the actual API request.
8178 ///
8179 /// ````text
8180 /// It should be used to handle progress information, and to implement a certain level of resilience.
8181 /// ````
8182 ///
8183 /// Sets the *delegate* property to the given value.
8184 pub fn delegate(
8185 mut self,
8186 new_value: &'a mut dyn common::Delegate,
8187 ) -> ProjectGithubEnterpriseConfigGetCall<'a, C> {
8188 self._delegate = Some(new_value);
8189 self
8190 }
8191
8192 /// Set any additional parameter of the query string used in the request.
8193 /// It should be used to set parameters which are not yet available through their own
8194 /// setters.
8195 ///
8196 /// Please note that this method must not be used to set any of the known parameters
8197 /// which have their own setter method. If done anyway, the request will fail.
8198 ///
8199 /// # Additional Parameters
8200 ///
8201 /// * *$.xgafv* (query-string) - V1 error format.
8202 /// * *access_token* (query-string) - OAuth access token.
8203 /// * *alt* (query-string) - Data format for response.
8204 /// * *callback* (query-string) - JSONP
8205 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8206 /// * *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.
8207 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8208 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8209 /// * *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.
8210 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8211 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8212 pub fn param<T>(mut self, name: T, value: T) -> ProjectGithubEnterpriseConfigGetCall<'a, C>
8213 where
8214 T: AsRef<str>,
8215 {
8216 self._additional_params
8217 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8218 self
8219 }
8220
8221 /// Identifies the authorization scope for the method you are building.
8222 ///
8223 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8224 /// [`Scope::CloudPlatform`].
8225 ///
8226 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8227 /// tokens for more than one scope.
8228 ///
8229 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8230 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8231 /// sufficient, a read-write scope will do as well.
8232 pub fn add_scope<St>(mut self, scope: St) -> ProjectGithubEnterpriseConfigGetCall<'a, C>
8233 where
8234 St: AsRef<str>,
8235 {
8236 self._scopes.insert(String::from(scope.as_ref()));
8237 self
8238 }
8239 /// Identifies the authorization scope(s) for the method you are building.
8240 ///
8241 /// See [`Self::add_scope()`] for details.
8242 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectGithubEnterpriseConfigGetCall<'a, C>
8243 where
8244 I: IntoIterator<Item = St>,
8245 St: AsRef<str>,
8246 {
8247 self._scopes
8248 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8249 self
8250 }
8251
8252 /// Removes all scopes, and no default scope will be used either.
8253 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8254 /// for details).
8255 pub fn clear_scopes(mut self) -> ProjectGithubEnterpriseConfigGetCall<'a, C> {
8256 self._scopes.clear();
8257 self
8258 }
8259}
8260
8261/// List all GitHubEnterpriseConfigs for a given project.
8262///
8263/// A builder for the *githubEnterpriseConfigs.list* method supported by a *project* resource.
8264/// It is not used directly, but through a [`ProjectMethods`] instance.
8265///
8266/// # Example
8267///
8268/// Instantiate a resource method builder
8269///
8270/// ```test_harness,no_run
8271/// # extern crate hyper;
8272/// # extern crate hyper_rustls;
8273/// # extern crate google_cloudbuild1 as cloudbuild1;
8274/// # async fn dox() {
8275/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8276///
8277/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8278/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8279/// # secret,
8280/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8281/// # ).build().await.unwrap();
8282///
8283/// # let client = hyper_util::client::legacy::Client::builder(
8284/// # hyper_util::rt::TokioExecutor::new()
8285/// # )
8286/// # .build(
8287/// # hyper_rustls::HttpsConnectorBuilder::new()
8288/// # .with_native_roots()
8289/// # .unwrap()
8290/// # .https_or_http()
8291/// # .enable_http1()
8292/// # .build()
8293/// # );
8294/// # let mut hub = CloudBuild::new(client, auth);
8295/// // You can configure optional parameters by calling the respective setters at will, and
8296/// // execute the final call using `doit()`.
8297/// // Values shown here are possibly random and not representative !
8298/// let result = hub.projects().github_enterprise_configs_list("parent")
8299/// .project_id("duo")
8300/// .doit().await;
8301/// # }
8302/// ```
8303pub struct ProjectGithubEnterpriseConfigListCall<'a, C>
8304where
8305 C: 'a,
8306{
8307 hub: &'a CloudBuild<C>,
8308 _parent: String,
8309 _project_id: Option<String>,
8310 _delegate: Option<&'a mut dyn common::Delegate>,
8311 _additional_params: HashMap<String, String>,
8312 _scopes: BTreeSet<String>,
8313}
8314
8315impl<'a, C> common::CallBuilder for ProjectGithubEnterpriseConfigListCall<'a, C> {}
8316
8317impl<'a, C> ProjectGithubEnterpriseConfigListCall<'a, C>
8318where
8319 C: common::Connector,
8320{
8321 /// Perform the operation you have build so far.
8322 pub async fn doit(
8323 mut self,
8324 ) -> common::Result<(common::Response, ListGithubEnterpriseConfigsResponse)> {
8325 use std::borrow::Cow;
8326 use std::io::{Read, Seek};
8327
8328 use common::{url::Params, ToParts};
8329 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8330
8331 let mut dd = common::DefaultDelegate;
8332 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8333 dlg.begin(common::MethodInfo {
8334 id: "cloudbuild.projects.githubEnterpriseConfigs.list",
8335 http_method: hyper::Method::GET,
8336 });
8337
8338 for &field in ["alt", "parent", "projectId"].iter() {
8339 if self._additional_params.contains_key(field) {
8340 dlg.finished(false);
8341 return Err(common::Error::FieldClash(field));
8342 }
8343 }
8344
8345 let mut params = Params::with_capacity(4 + self._additional_params.len());
8346 params.push("parent", self._parent);
8347 if let Some(value) = self._project_id.as_ref() {
8348 params.push("projectId", value);
8349 }
8350
8351 params.extend(self._additional_params.iter());
8352
8353 params.push("alt", "json");
8354 let mut url = self.hub._base_url.clone() + "v1/{+parent}/githubEnterpriseConfigs";
8355 if self._scopes.is_empty() {
8356 self._scopes
8357 .insert(Scope::CloudPlatform.as_ref().to_string());
8358 }
8359
8360 #[allow(clippy::single_element_loop)]
8361 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
8362 url = params.uri_replacement(url, param_name, find_this, true);
8363 }
8364 {
8365 let to_remove = ["parent"];
8366 params.remove_params(&to_remove);
8367 }
8368
8369 let url = params.parse_with_url(&url);
8370
8371 loop {
8372 let token = match self
8373 .hub
8374 .auth
8375 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8376 .await
8377 {
8378 Ok(token) => token,
8379 Err(e) => match dlg.token(e) {
8380 Ok(token) => token,
8381 Err(e) => {
8382 dlg.finished(false);
8383 return Err(common::Error::MissingToken(e));
8384 }
8385 },
8386 };
8387 let mut req_result = {
8388 let client = &self.hub.client;
8389 dlg.pre_request();
8390 let mut req_builder = hyper::Request::builder()
8391 .method(hyper::Method::GET)
8392 .uri(url.as_str())
8393 .header(USER_AGENT, self.hub._user_agent.clone());
8394
8395 if let Some(token) = token.as_ref() {
8396 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8397 }
8398
8399 let request = req_builder
8400 .header(CONTENT_LENGTH, 0_u64)
8401 .body(common::to_body::<String>(None));
8402
8403 client.request(request.unwrap()).await
8404 };
8405
8406 match req_result {
8407 Err(err) => {
8408 if let common::Retry::After(d) = dlg.http_error(&err) {
8409 sleep(d).await;
8410 continue;
8411 }
8412 dlg.finished(false);
8413 return Err(common::Error::HttpError(err));
8414 }
8415 Ok(res) => {
8416 let (mut parts, body) = res.into_parts();
8417 let mut body = common::Body::new(body);
8418 if !parts.status.is_success() {
8419 let bytes = common::to_bytes(body).await.unwrap_or_default();
8420 let error = serde_json::from_str(&common::to_string(&bytes));
8421 let response = common::to_response(parts, bytes.into());
8422
8423 if let common::Retry::After(d) =
8424 dlg.http_failure(&response, error.as_ref().ok())
8425 {
8426 sleep(d).await;
8427 continue;
8428 }
8429
8430 dlg.finished(false);
8431
8432 return Err(match error {
8433 Ok(value) => common::Error::BadRequest(value),
8434 _ => common::Error::Failure(response),
8435 });
8436 }
8437 let response = {
8438 let bytes = common::to_bytes(body).await.unwrap_or_default();
8439 let encoded = common::to_string(&bytes);
8440 match serde_json::from_str(&encoded) {
8441 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8442 Err(error) => {
8443 dlg.response_json_decode_error(&encoded, &error);
8444 return Err(common::Error::JsonDecodeError(
8445 encoded.to_string(),
8446 error,
8447 ));
8448 }
8449 }
8450 };
8451
8452 dlg.finished(true);
8453 return Ok(response);
8454 }
8455 }
8456 }
8457 }
8458
8459 /// Name of the parent project. For example: projects/{$project_number} or projects/{$project_id}
8460 ///
8461 /// Sets the *parent* path property to the given value.
8462 ///
8463 /// Even though the property as already been set when instantiating this call,
8464 /// we provide this method for API completeness.
8465 pub fn parent(mut self, new_value: &str) -> ProjectGithubEnterpriseConfigListCall<'a, C> {
8466 self._parent = new_value.to_string();
8467 self
8468 }
8469 /// ID of the project
8470 ///
8471 /// Sets the *project id* query property to the given value.
8472 pub fn project_id(mut self, new_value: &str) -> ProjectGithubEnterpriseConfigListCall<'a, C> {
8473 self._project_id = Some(new_value.to_string());
8474 self
8475 }
8476 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8477 /// while executing the actual API request.
8478 ///
8479 /// ````text
8480 /// It should be used to handle progress information, and to implement a certain level of resilience.
8481 /// ````
8482 ///
8483 /// Sets the *delegate* property to the given value.
8484 pub fn delegate(
8485 mut self,
8486 new_value: &'a mut dyn common::Delegate,
8487 ) -> ProjectGithubEnterpriseConfigListCall<'a, C> {
8488 self._delegate = Some(new_value);
8489 self
8490 }
8491
8492 /// Set any additional parameter of the query string used in the request.
8493 /// It should be used to set parameters which are not yet available through their own
8494 /// setters.
8495 ///
8496 /// Please note that this method must not be used to set any of the known parameters
8497 /// which have their own setter method. If done anyway, the request will fail.
8498 ///
8499 /// # Additional Parameters
8500 ///
8501 /// * *$.xgafv* (query-string) - V1 error format.
8502 /// * *access_token* (query-string) - OAuth access token.
8503 /// * *alt* (query-string) - Data format for response.
8504 /// * *callback* (query-string) - JSONP
8505 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8506 /// * *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.
8507 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8508 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8509 /// * *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.
8510 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8511 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8512 pub fn param<T>(mut self, name: T, value: T) -> ProjectGithubEnterpriseConfigListCall<'a, C>
8513 where
8514 T: AsRef<str>,
8515 {
8516 self._additional_params
8517 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8518 self
8519 }
8520
8521 /// Identifies the authorization scope for the method you are building.
8522 ///
8523 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8524 /// [`Scope::CloudPlatform`].
8525 ///
8526 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8527 /// tokens for more than one scope.
8528 ///
8529 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8530 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8531 /// sufficient, a read-write scope will do as well.
8532 pub fn add_scope<St>(mut self, scope: St) -> ProjectGithubEnterpriseConfigListCall<'a, C>
8533 where
8534 St: AsRef<str>,
8535 {
8536 self._scopes.insert(String::from(scope.as_ref()));
8537 self
8538 }
8539 /// Identifies the authorization scope(s) for the method you are building.
8540 ///
8541 /// See [`Self::add_scope()`] for details.
8542 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectGithubEnterpriseConfigListCall<'a, C>
8543 where
8544 I: IntoIterator<Item = St>,
8545 St: AsRef<str>,
8546 {
8547 self._scopes
8548 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8549 self
8550 }
8551
8552 /// Removes all scopes, and no default scope will be used either.
8553 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8554 /// for details).
8555 pub fn clear_scopes(mut self) -> ProjectGithubEnterpriseConfigListCall<'a, C> {
8556 self._scopes.clear();
8557 self
8558 }
8559}
8560
8561/// Update an association between a GCP project and a GitHub Enterprise server.
8562///
8563/// A builder for the *githubEnterpriseConfigs.patch* method supported by a *project* resource.
8564/// It is not used directly, but through a [`ProjectMethods`] instance.
8565///
8566/// # Example
8567///
8568/// Instantiate a resource method builder
8569///
8570/// ```test_harness,no_run
8571/// # extern crate hyper;
8572/// # extern crate hyper_rustls;
8573/// # extern crate google_cloudbuild1 as cloudbuild1;
8574/// use cloudbuild1::api::GitHubEnterpriseConfig;
8575/// # async fn dox() {
8576/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8577///
8578/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8579/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8580/// # secret,
8581/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8582/// # ).build().await.unwrap();
8583///
8584/// # let client = hyper_util::client::legacy::Client::builder(
8585/// # hyper_util::rt::TokioExecutor::new()
8586/// # )
8587/// # .build(
8588/// # hyper_rustls::HttpsConnectorBuilder::new()
8589/// # .with_native_roots()
8590/// # .unwrap()
8591/// # .https_or_http()
8592/// # .enable_http1()
8593/// # .build()
8594/// # );
8595/// # let mut hub = CloudBuild::new(client, auth);
8596/// // As the method needs a request, you would usually fill it with the desired information
8597/// // into the respective structure. Some of the parts shown here might not be applicable !
8598/// // Values shown here are possibly random and not representative !
8599/// let mut req = GitHubEnterpriseConfig::default();
8600///
8601/// // You can configure optional parameters by calling the respective setters at will, and
8602/// // execute the final call using `doit()`.
8603/// // Values shown here are possibly random and not representative !
8604/// let result = hub.projects().github_enterprise_configs_patch(req, "name")
8605/// .update_mask(FieldMask::new::<&str>(&[]))
8606/// .doit().await;
8607/// # }
8608/// ```
8609pub struct ProjectGithubEnterpriseConfigPatchCall<'a, C>
8610where
8611 C: 'a,
8612{
8613 hub: &'a CloudBuild<C>,
8614 _request: GitHubEnterpriseConfig,
8615 _name: String,
8616 _update_mask: Option<common::FieldMask>,
8617 _delegate: Option<&'a mut dyn common::Delegate>,
8618 _additional_params: HashMap<String, String>,
8619 _scopes: BTreeSet<String>,
8620}
8621
8622impl<'a, C> common::CallBuilder for ProjectGithubEnterpriseConfigPatchCall<'a, C> {}
8623
8624impl<'a, C> ProjectGithubEnterpriseConfigPatchCall<'a, C>
8625where
8626 C: common::Connector,
8627{
8628 /// Perform the operation you have build so far.
8629 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
8630 use std::borrow::Cow;
8631 use std::io::{Read, Seek};
8632
8633 use common::{url::Params, ToParts};
8634 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8635
8636 let mut dd = common::DefaultDelegate;
8637 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8638 dlg.begin(common::MethodInfo {
8639 id: "cloudbuild.projects.githubEnterpriseConfigs.patch",
8640 http_method: hyper::Method::PATCH,
8641 });
8642
8643 for &field in ["alt", "name", "updateMask"].iter() {
8644 if self._additional_params.contains_key(field) {
8645 dlg.finished(false);
8646 return Err(common::Error::FieldClash(field));
8647 }
8648 }
8649
8650 let mut params = Params::with_capacity(5 + self._additional_params.len());
8651 params.push("name", self._name);
8652 if let Some(value) = self._update_mask.as_ref() {
8653 params.push("updateMask", value.to_string());
8654 }
8655
8656 params.extend(self._additional_params.iter());
8657
8658 params.push("alt", "json");
8659 let mut url = self.hub._base_url.clone() + "v1/{+name}";
8660 if self._scopes.is_empty() {
8661 self._scopes
8662 .insert(Scope::CloudPlatform.as_ref().to_string());
8663 }
8664
8665 #[allow(clippy::single_element_loop)]
8666 for &(find_this, param_name) in [("{+name}", "name")].iter() {
8667 url = params.uri_replacement(url, param_name, find_this, true);
8668 }
8669 {
8670 let to_remove = ["name"];
8671 params.remove_params(&to_remove);
8672 }
8673
8674 let url = params.parse_with_url(&url);
8675
8676 let mut json_mime_type = mime::APPLICATION_JSON;
8677 let mut request_value_reader = {
8678 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8679 common::remove_json_null_values(&mut value);
8680 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8681 serde_json::to_writer(&mut dst, &value).unwrap();
8682 dst
8683 };
8684 let request_size = request_value_reader
8685 .seek(std::io::SeekFrom::End(0))
8686 .unwrap();
8687 request_value_reader
8688 .seek(std::io::SeekFrom::Start(0))
8689 .unwrap();
8690
8691 loop {
8692 let token = match self
8693 .hub
8694 .auth
8695 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8696 .await
8697 {
8698 Ok(token) => token,
8699 Err(e) => match dlg.token(e) {
8700 Ok(token) => token,
8701 Err(e) => {
8702 dlg.finished(false);
8703 return Err(common::Error::MissingToken(e));
8704 }
8705 },
8706 };
8707 request_value_reader
8708 .seek(std::io::SeekFrom::Start(0))
8709 .unwrap();
8710 let mut req_result = {
8711 let client = &self.hub.client;
8712 dlg.pre_request();
8713 let mut req_builder = hyper::Request::builder()
8714 .method(hyper::Method::PATCH)
8715 .uri(url.as_str())
8716 .header(USER_AGENT, self.hub._user_agent.clone());
8717
8718 if let Some(token) = token.as_ref() {
8719 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8720 }
8721
8722 let request = req_builder
8723 .header(CONTENT_TYPE, json_mime_type.to_string())
8724 .header(CONTENT_LENGTH, request_size as u64)
8725 .body(common::to_body(
8726 request_value_reader.get_ref().clone().into(),
8727 ));
8728
8729 client.request(request.unwrap()).await
8730 };
8731
8732 match req_result {
8733 Err(err) => {
8734 if let common::Retry::After(d) = dlg.http_error(&err) {
8735 sleep(d).await;
8736 continue;
8737 }
8738 dlg.finished(false);
8739 return Err(common::Error::HttpError(err));
8740 }
8741 Ok(res) => {
8742 let (mut parts, body) = res.into_parts();
8743 let mut body = common::Body::new(body);
8744 if !parts.status.is_success() {
8745 let bytes = common::to_bytes(body).await.unwrap_or_default();
8746 let error = serde_json::from_str(&common::to_string(&bytes));
8747 let response = common::to_response(parts, bytes.into());
8748
8749 if let common::Retry::After(d) =
8750 dlg.http_failure(&response, error.as_ref().ok())
8751 {
8752 sleep(d).await;
8753 continue;
8754 }
8755
8756 dlg.finished(false);
8757
8758 return Err(match error {
8759 Ok(value) => common::Error::BadRequest(value),
8760 _ => common::Error::Failure(response),
8761 });
8762 }
8763 let response = {
8764 let bytes = common::to_bytes(body).await.unwrap_or_default();
8765 let encoded = common::to_string(&bytes);
8766 match serde_json::from_str(&encoded) {
8767 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8768 Err(error) => {
8769 dlg.response_json_decode_error(&encoded, &error);
8770 return Err(common::Error::JsonDecodeError(
8771 encoded.to_string(),
8772 error,
8773 ));
8774 }
8775 }
8776 };
8777
8778 dlg.finished(true);
8779 return Ok(response);
8780 }
8781 }
8782 }
8783 }
8784
8785 ///
8786 /// Sets the *request* property to the given value.
8787 ///
8788 /// Even though the property as already been set when instantiating this call,
8789 /// we provide this method for API completeness.
8790 pub fn request(
8791 mut self,
8792 new_value: GitHubEnterpriseConfig,
8793 ) -> ProjectGithubEnterpriseConfigPatchCall<'a, C> {
8794 self._request = new_value;
8795 self
8796 }
8797 /// The full resource name for the GitHubEnterpriseConfig For example: "projects/{$project_id}/locations/{$location_id}/githubEnterpriseConfigs/{$config_id}"
8798 ///
8799 /// Sets the *name* path property to the given value.
8800 ///
8801 /// Even though the property as already been set when instantiating this call,
8802 /// we provide this method for API completeness.
8803 pub fn name(mut self, new_value: &str) -> ProjectGithubEnterpriseConfigPatchCall<'a, C> {
8804 self._name = new_value.to_string();
8805 self
8806 }
8807 /// Update mask for the resource. If this is set, the server will only update the fields specified in the field mask. Otherwise, a full update of the mutable resource fields will be performed.
8808 ///
8809 /// Sets the *update mask* query property to the given value.
8810 pub fn update_mask(
8811 mut self,
8812 new_value: common::FieldMask,
8813 ) -> ProjectGithubEnterpriseConfigPatchCall<'a, C> {
8814 self._update_mask = Some(new_value);
8815 self
8816 }
8817 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8818 /// while executing the actual API request.
8819 ///
8820 /// ````text
8821 /// It should be used to handle progress information, and to implement a certain level of resilience.
8822 /// ````
8823 ///
8824 /// Sets the *delegate* property to the given value.
8825 pub fn delegate(
8826 mut self,
8827 new_value: &'a mut dyn common::Delegate,
8828 ) -> ProjectGithubEnterpriseConfigPatchCall<'a, C> {
8829 self._delegate = Some(new_value);
8830 self
8831 }
8832
8833 /// Set any additional parameter of the query string used in the request.
8834 /// It should be used to set parameters which are not yet available through their own
8835 /// setters.
8836 ///
8837 /// Please note that this method must not be used to set any of the known parameters
8838 /// which have their own setter method. If done anyway, the request will fail.
8839 ///
8840 /// # Additional Parameters
8841 ///
8842 /// * *$.xgafv* (query-string) - V1 error format.
8843 /// * *access_token* (query-string) - OAuth access token.
8844 /// * *alt* (query-string) - Data format for response.
8845 /// * *callback* (query-string) - JSONP
8846 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8847 /// * *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.
8848 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8849 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8850 /// * *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.
8851 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8852 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8853 pub fn param<T>(mut self, name: T, value: T) -> ProjectGithubEnterpriseConfigPatchCall<'a, C>
8854 where
8855 T: AsRef<str>,
8856 {
8857 self._additional_params
8858 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8859 self
8860 }
8861
8862 /// Identifies the authorization scope for the method you are building.
8863 ///
8864 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8865 /// [`Scope::CloudPlatform`].
8866 ///
8867 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8868 /// tokens for more than one scope.
8869 ///
8870 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8871 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8872 /// sufficient, a read-write scope will do as well.
8873 pub fn add_scope<St>(mut self, scope: St) -> ProjectGithubEnterpriseConfigPatchCall<'a, C>
8874 where
8875 St: AsRef<str>,
8876 {
8877 self._scopes.insert(String::from(scope.as_ref()));
8878 self
8879 }
8880 /// Identifies the authorization scope(s) for the method you are building.
8881 ///
8882 /// See [`Self::add_scope()`] for details.
8883 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectGithubEnterpriseConfigPatchCall<'a, C>
8884 where
8885 I: IntoIterator<Item = St>,
8886 St: AsRef<str>,
8887 {
8888 self._scopes
8889 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8890 self
8891 }
8892
8893 /// Removes all scopes, and no default scope will be used either.
8894 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8895 /// for details).
8896 pub fn clear_scopes(mut self) -> ProjectGithubEnterpriseConfigPatchCall<'a, C> {
8897 self._scopes.clear();
8898 self
8899 }
8900}
8901
8902/// Batch connecting Bitbucket Server repositories to Cloud Build.
8903///
8904/// A builder for the *locations.bitbucketServerConfigs.connectedRepositories.batchCreate* method supported by a *project* resource.
8905/// It is not used directly, but through a [`ProjectMethods`] instance.
8906///
8907/// # Example
8908///
8909/// Instantiate a resource method builder
8910///
8911/// ```test_harness,no_run
8912/// # extern crate hyper;
8913/// # extern crate hyper_rustls;
8914/// # extern crate google_cloudbuild1 as cloudbuild1;
8915/// use cloudbuild1::api::BatchCreateBitbucketServerConnectedRepositoriesRequest;
8916/// # async fn dox() {
8917/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8918///
8919/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8920/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8921/// # secret,
8922/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8923/// # ).build().await.unwrap();
8924///
8925/// # let client = hyper_util::client::legacy::Client::builder(
8926/// # hyper_util::rt::TokioExecutor::new()
8927/// # )
8928/// # .build(
8929/// # hyper_rustls::HttpsConnectorBuilder::new()
8930/// # .with_native_roots()
8931/// # .unwrap()
8932/// # .https_or_http()
8933/// # .enable_http1()
8934/// # .build()
8935/// # );
8936/// # let mut hub = CloudBuild::new(client, auth);
8937/// // As the method needs a request, you would usually fill it with the desired information
8938/// // into the respective structure. Some of the parts shown here might not be applicable !
8939/// // Values shown here are possibly random and not representative !
8940/// let mut req = BatchCreateBitbucketServerConnectedRepositoriesRequest::default();
8941///
8942/// // You can configure optional parameters by calling the respective setters at will, and
8943/// // execute the final call using `doit()`.
8944/// // Values shown here are possibly random and not representative !
8945/// let result = hub.projects().locations_bitbucket_server_configs_connected_repositories_batch_create(req, "parent")
8946/// .doit().await;
8947/// # }
8948/// ```
8949pub struct ProjectLocationBitbucketServerConfigConnectedRepositoryBatchCreateCall<'a, C>
8950where
8951 C: 'a,
8952{
8953 hub: &'a CloudBuild<C>,
8954 _request: BatchCreateBitbucketServerConnectedRepositoriesRequest,
8955 _parent: String,
8956 _delegate: Option<&'a mut dyn common::Delegate>,
8957 _additional_params: HashMap<String, String>,
8958 _scopes: BTreeSet<String>,
8959}
8960
8961impl<'a, C> common::CallBuilder
8962 for ProjectLocationBitbucketServerConfigConnectedRepositoryBatchCreateCall<'a, C>
8963{
8964}
8965
8966impl<'a, C> ProjectLocationBitbucketServerConfigConnectedRepositoryBatchCreateCall<'a, C>
8967where
8968 C: common::Connector,
8969{
8970 /// Perform the operation you have build so far.
8971 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
8972 use std::borrow::Cow;
8973 use std::io::{Read, Seek};
8974
8975 use common::{url::Params, ToParts};
8976 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8977
8978 let mut dd = common::DefaultDelegate;
8979 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8980 dlg.begin(common::MethodInfo { id: "cloudbuild.projects.locations.bitbucketServerConfigs.connectedRepositories.batchCreate",
8981 http_method: hyper::Method::POST });
8982
8983 for &field in ["alt", "parent"].iter() {
8984 if self._additional_params.contains_key(field) {
8985 dlg.finished(false);
8986 return Err(common::Error::FieldClash(field));
8987 }
8988 }
8989
8990 let mut params = Params::with_capacity(4 + self._additional_params.len());
8991 params.push("parent", self._parent);
8992
8993 params.extend(self._additional_params.iter());
8994
8995 params.push("alt", "json");
8996 let mut url = self.hub._base_url.clone() + "v1/{+parent}/connectedRepositories:batchCreate";
8997 if self._scopes.is_empty() {
8998 self._scopes
8999 .insert(Scope::CloudPlatform.as_ref().to_string());
9000 }
9001
9002 #[allow(clippy::single_element_loop)]
9003 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
9004 url = params.uri_replacement(url, param_name, find_this, true);
9005 }
9006 {
9007 let to_remove = ["parent"];
9008 params.remove_params(&to_remove);
9009 }
9010
9011 let url = params.parse_with_url(&url);
9012
9013 let mut json_mime_type = mime::APPLICATION_JSON;
9014 let mut request_value_reader = {
9015 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9016 common::remove_json_null_values(&mut value);
9017 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9018 serde_json::to_writer(&mut dst, &value).unwrap();
9019 dst
9020 };
9021 let request_size = request_value_reader
9022 .seek(std::io::SeekFrom::End(0))
9023 .unwrap();
9024 request_value_reader
9025 .seek(std::io::SeekFrom::Start(0))
9026 .unwrap();
9027
9028 loop {
9029 let token = match self
9030 .hub
9031 .auth
9032 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9033 .await
9034 {
9035 Ok(token) => token,
9036 Err(e) => match dlg.token(e) {
9037 Ok(token) => token,
9038 Err(e) => {
9039 dlg.finished(false);
9040 return Err(common::Error::MissingToken(e));
9041 }
9042 },
9043 };
9044 request_value_reader
9045 .seek(std::io::SeekFrom::Start(0))
9046 .unwrap();
9047 let mut req_result = {
9048 let client = &self.hub.client;
9049 dlg.pre_request();
9050 let mut req_builder = hyper::Request::builder()
9051 .method(hyper::Method::POST)
9052 .uri(url.as_str())
9053 .header(USER_AGENT, self.hub._user_agent.clone());
9054
9055 if let Some(token) = token.as_ref() {
9056 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9057 }
9058
9059 let request = req_builder
9060 .header(CONTENT_TYPE, json_mime_type.to_string())
9061 .header(CONTENT_LENGTH, request_size as u64)
9062 .body(common::to_body(
9063 request_value_reader.get_ref().clone().into(),
9064 ));
9065
9066 client.request(request.unwrap()).await
9067 };
9068
9069 match req_result {
9070 Err(err) => {
9071 if let common::Retry::After(d) = dlg.http_error(&err) {
9072 sleep(d).await;
9073 continue;
9074 }
9075 dlg.finished(false);
9076 return Err(common::Error::HttpError(err));
9077 }
9078 Ok(res) => {
9079 let (mut parts, body) = res.into_parts();
9080 let mut body = common::Body::new(body);
9081 if !parts.status.is_success() {
9082 let bytes = common::to_bytes(body).await.unwrap_or_default();
9083 let error = serde_json::from_str(&common::to_string(&bytes));
9084 let response = common::to_response(parts, bytes.into());
9085
9086 if let common::Retry::After(d) =
9087 dlg.http_failure(&response, error.as_ref().ok())
9088 {
9089 sleep(d).await;
9090 continue;
9091 }
9092
9093 dlg.finished(false);
9094
9095 return Err(match error {
9096 Ok(value) => common::Error::BadRequest(value),
9097 _ => common::Error::Failure(response),
9098 });
9099 }
9100 let response = {
9101 let bytes = common::to_bytes(body).await.unwrap_or_default();
9102 let encoded = common::to_string(&bytes);
9103 match serde_json::from_str(&encoded) {
9104 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9105 Err(error) => {
9106 dlg.response_json_decode_error(&encoded, &error);
9107 return Err(common::Error::JsonDecodeError(
9108 encoded.to_string(),
9109 error,
9110 ));
9111 }
9112 }
9113 };
9114
9115 dlg.finished(true);
9116 return Ok(response);
9117 }
9118 }
9119 }
9120 }
9121
9122 ///
9123 /// Sets the *request* property to the given value.
9124 ///
9125 /// Even though the property as already been set when instantiating this call,
9126 /// we provide this method for API completeness.
9127 pub fn request(
9128 mut self,
9129 new_value: BatchCreateBitbucketServerConnectedRepositoriesRequest,
9130 ) -> ProjectLocationBitbucketServerConfigConnectedRepositoryBatchCreateCall<'a, C> {
9131 self._request = new_value;
9132 self
9133 }
9134 /// The name of the `BitbucketServerConfig` that added connected repository. Format: `projects/{project}/locations/{location}/bitbucketServerConfigs/{config}`
9135 ///
9136 /// Sets the *parent* path property to the given value.
9137 ///
9138 /// Even though the property as already been set when instantiating this call,
9139 /// we provide this method for API completeness.
9140 pub fn parent(
9141 mut self,
9142 new_value: &str,
9143 ) -> ProjectLocationBitbucketServerConfigConnectedRepositoryBatchCreateCall<'a, C> {
9144 self._parent = new_value.to_string();
9145 self
9146 }
9147 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9148 /// while executing the actual API request.
9149 ///
9150 /// ````text
9151 /// It should be used to handle progress information, and to implement a certain level of resilience.
9152 /// ````
9153 ///
9154 /// Sets the *delegate* property to the given value.
9155 pub fn delegate(
9156 mut self,
9157 new_value: &'a mut dyn common::Delegate,
9158 ) -> ProjectLocationBitbucketServerConfigConnectedRepositoryBatchCreateCall<'a, C> {
9159 self._delegate = Some(new_value);
9160 self
9161 }
9162
9163 /// Set any additional parameter of the query string used in the request.
9164 /// It should be used to set parameters which are not yet available through their own
9165 /// setters.
9166 ///
9167 /// Please note that this method must not be used to set any of the known parameters
9168 /// which have their own setter method. If done anyway, the request will fail.
9169 ///
9170 /// # Additional Parameters
9171 ///
9172 /// * *$.xgafv* (query-string) - V1 error format.
9173 /// * *access_token* (query-string) - OAuth access token.
9174 /// * *alt* (query-string) - Data format for response.
9175 /// * *callback* (query-string) - JSONP
9176 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9177 /// * *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.
9178 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9179 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9180 /// * *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.
9181 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9182 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9183 pub fn param<T>(
9184 mut self,
9185 name: T,
9186 value: T,
9187 ) -> ProjectLocationBitbucketServerConfigConnectedRepositoryBatchCreateCall<'a, C>
9188 where
9189 T: AsRef<str>,
9190 {
9191 self._additional_params
9192 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9193 self
9194 }
9195
9196 /// Identifies the authorization scope for the method you are building.
9197 ///
9198 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9199 /// [`Scope::CloudPlatform`].
9200 ///
9201 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9202 /// tokens for more than one scope.
9203 ///
9204 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9205 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9206 /// sufficient, a read-write scope will do as well.
9207 pub fn add_scope<St>(
9208 mut self,
9209 scope: St,
9210 ) -> ProjectLocationBitbucketServerConfigConnectedRepositoryBatchCreateCall<'a, C>
9211 where
9212 St: AsRef<str>,
9213 {
9214 self._scopes.insert(String::from(scope.as_ref()));
9215 self
9216 }
9217 /// Identifies the authorization scope(s) for the method you are building.
9218 ///
9219 /// See [`Self::add_scope()`] for details.
9220 pub fn add_scopes<I, St>(
9221 mut self,
9222 scopes: I,
9223 ) -> ProjectLocationBitbucketServerConfigConnectedRepositoryBatchCreateCall<'a, C>
9224 where
9225 I: IntoIterator<Item = St>,
9226 St: AsRef<str>,
9227 {
9228 self._scopes
9229 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9230 self
9231 }
9232
9233 /// Removes all scopes, and no default scope will be used either.
9234 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9235 /// for details).
9236 pub fn clear_scopes(
9237 mut self,
9238 ) -> ProjectLocationBitbucketServerConfigConnectedRepositoryBatchCreateCall<'a, C> {
9239 self._scopes.clear();
9240 self
9241 }
9242}
9243
9244/// List all repositories for a given `BitbucketServerConfig`. This API is experimental.
9245///
9246/// A builder for the *locations.bitbucketServerConfigs.repos.list* method supported by a *project* resource.
9247/// It is not used directly, but through a [`ProjectMethods`] instance.
9248///
9249/// # Example
9250///
9251/// Instantiate a resource method builder
9252///
9253/// ```test_harness,no_run
9254/// # extern crate hyper;
9255/// # extern crate hyper_rustls;
9256/// # extern crate google_cloudbuild1 as cloudbuild1;
9257/// # async fn dox() {
9258/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9259///
9260/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9261/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9262/// # secret,
9263/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9264/// # ).build().await.unwrap();
9265///
9266/// # let client = hyper_util::client::legacy::Client::builder(
9267/// # hyper_util::rt::TokioExecutor::new()
9268/// # )
9269/// # .build(
9270/// # hyper_rustls::HttpsConnectorBuilder::new()
9271/// # .with_native_roots()
9272/// # .unwrap()
9273/// # .https_or_http()
9274/// # .enable_http1()
9275/// # .build()
9276/// # );
9277/// # let mut hub = CloudBuild::new(client, auth);
9278/// // You can configure optional parameters by calling the respective setters at will, and
9279/// // execute the final call using `doit()`.
9280/// // Values shown here are possibly random and not representative !
9281/// let result = hub.projects().locations_bitbucket_server_configs_repos_list("parent")
9282/// .page_token("kasd")
9283/// .page_size(-24)
9284/// .doit().await;
9285/// # }
9286/// ```
9287pub struct ProjectLocationBitbucketServerConfigRepoListCall<'a, C>
9288where
9289 C: 'a,
9290{
9291 hub: &'a CloudBuild<C>,
9292 _parent: String,
9293 _page_token: Option<String>,
9294 _page_size: Option<i32>,
9295 _delegate: Option<&'a mut dyn common::Delegate>,
9296 _additional_params: HashMap<String, String>,
9297 _scopes: BTreeSet<String>,
9298}
9299
9300impl<'a, C> common::CallBuilder for ProjectLocationBitbucketServerConfigRepoListCall<'a, C> {}
9301
9302impl<'a, C> ProjectLocationBitbucketServerConfigRepoListCall<'a, C>
9303where
9304 C: common::Connector,
9305{
9306 /// Perform the operation you have build so far.
9307 pub async fn doit(
9308 mut self,
9309 ) -> common::Result<(common::Response, ListBitbucketServerRepositoriesResponse)> {
9310 use std::borrow::Cow;
9311 use std::io::{Read, Seek};
9312
9313 use common::{url::Params, ToParts};
9314 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9315
9316 let mut dd = common::DefaultDelegate;
9317 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9318 dlg.begin(common::MethodInfo {
9319 id: "cloudbuild.projects.locations.bitbucketServerConfigs.repos.list",
9320 http_method: hyper::Method::GET,
9321 });
9322
9323 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
9324 if self._additional_params.contains_key(field) {
9325 dlg.finished(false);
9326 return Err(common::Error::FieldClash(field));
9327 }
9328 }
9329
9330 let mut params = Params::with_capacity(5 + self._additional_params.len());
9331 params.push("parent", self._parent);
9332 if let Some(value) = self._page_token.as_ref() {
9333 params.push("pageToken", value);
9334 }
9335 if let Some(value) = self._page_size.as_ref() {
9336 params.push("pageSize", value.to_string());
9337 }
9338
9339 params.extend(self._additional_params.iter());
9340
9341 params.push("alt", "json");
9342 let mut url = self.hub._base_url.clone() + "v1/{+parent}/repos";
9343 if self._scopes.is_empty() {
9344 self._scopes
9345 .insert(Scope::CloudPlatform.as_ref().to_string());
9346 }
9347
9348 #[allow(clippy::single_element_loop)]
9349 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
9350 url = params.uri_replacement(url, param_name, find_this, true);
9351 }
9352 {
9353 let to_remove = ["parent"];
9354 params.remove_params(&to_remove);
9355 }
9356
9357 let url = params.parse_with_url(&url);
9358
9359 loop {
9360 let token = match self
9361 .hub
9362 .auth
9363 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9364 .await
9365 {
9366 Ok(token) => token,
9367 Err(e) => match dlg.token(e) {
9368 Ok(token) => token,
9369 Err(e) => {
9370 dlg.finished(false);
9371 return Err(common::Error::MissingToken(e));
9372 }
9373 },
9374 };
9375 let mut req_result = {
9376 let client = &self.hub.client;
9377 dlg.pre_request();
9378 let mut req_builder = hyper::Request::builder()
9379 .method(hyper::Method::GET)
9380 .uri(url.as_str())
9381 .header(USER_AGENT, self.hub._user_agent.clone());
9382
9383 if let Some(token) = token.as_ref() {
9384 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9385 }
9386
9387 let request = req_builder
9388 .header(CONTENT_LENGTH, 0_u64)
9389 .body(common::to_body::<String>(None));
9390
9391 client.request(request.unwrap()).await
9392 };
9393
9394 match req_result {
9395 Err(err) => {
9396 if let common::Retry::After(d) = dlg.http_error(&err) {
9397 sleep(d).await;
9398 continue;
9399 }
9400 dlg.finished(false);
9401 return Err(common::Error::HttpError(err));
9402 }
9403 Ok(res) => {
9404 let (mut parts, body) = res.into_parts();
9405 let mut body = common::Body::new(body);
9406 if !parts.status.is_success() {
9407 let bytes = common::to_bytes(body).await.unwrap_or_default();
9408 let error = serde_json::from_str(&common::to_string(&bytes));
9409 let response = common::to_response(parts, bytes.into());
9410
9411 if let common::Retry::After(d) =
9412 dlg.http_failure(&response, error.as_ref().ok())
9413 {
9414 sleep(d).await;
9415 continue;
9416 }
9417
9418 dlg.finished(false);
9419
9420 return Err(match error {
9421 Ok(value) => common::Error::BadRequest(value),
9422 _ => common::Error::Failure(response),
9423 });
9424 }
9425 let response = {
9426 let bytes = common::to_bytes(body).await.unwrap_or_default();
9427 let encoded = common::to_string(&bytes);
9428 match serde_json::from_str(&encoded) {
9429 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9430 Err(error) => {
9431 dlg.response_json_decode_error(&encoded, &error);
9432 return Err(common::Error::JsonDecodeError(
9433 encoded.to_string(),
9434 error,
9435 ));
9436 }
9437 }
9438 };
9439
9440 dlg.finished(true);
9441 return Ok(response);
9442 }
9443 }
9444 }
9445 }
9446
9447 /// Required. Name of the parent resource.
9448 ///
9449 /// Sets the *parent* path property to the given value.
9450 ///
9451 /// Even though the property as already been set when instantiating this call,
9452 /// we provide this method for API completeness.
9453 pub fn parent(
9454 mut self,
9455 new_value: &str,
9456 ) -> ProjectLocationBitbucketServerConfigRepoListCall<'a, C> {
9457 self._parent = new_value.to_string();
9458 self
9459 }
9460 /// A page token, received from a previous `ListBitbucketServerRepositoriesRequest` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListBitbucketServerConfigsRequest` must match the call that provided the page token.
9461 ///
9462 /// Sets the *page token* query property to the given value.
9463 pub fn page_token(
9464 mut self,
9465 new_value: &str,
9466 ) -> ProjectLocationBitbucketServerConfigRepoListCall<'a, C> {
9467 self._page_token = Some(new_value.to_string());
9468 self
9469 }
9470 /// The maximum number of configs to return. The service may return fewer than this value. The maximum value is 1000; values above 1000 will be coerced to 1000.
9471 ///
9472 /// Sets the *page size* query property to the given value.
9473 pub fn page_size(
9474 mut self,
9475 new_value: i32,
9476 ) -> ProjectLocationBitbucketServerConfigRepoListCall<'a, C> {
9477 self._page_size = Some(new_value);
9478 self
9479 }
9480 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9481 /// while executing the actual API request.
9482 ///
9483 /// ````text
9484 /// It should be used to handle progress information, and to implement a certain level of resilience.
9485 /// ````
9486 ///
9487 /// Sets the *delegate* property to the given value.
9488 pub fn delegate(
9489 mut self,
9490 new_value: &'a mut dyn common::Delegate,
9491 ) -> ProjectLocationBitbucketServerConfigRepoListCall<'a, C> {
9492 self._delegate = Some(new_value);
9493 self
9494 }
9495
9496 /// Set any additional parameter of the query string used in the request.
9497 /// It should be used to set parameters which are not yet available through their own
9498 /// setters.
9499 ///
9500 /// Please note that this method must not be used to set any of the known parameters
9501 /// which have their own setter method. If done anyway, the request will fail.
9502 ///
9503 /// # Additional Parameters
9504 ///
9505 /// * *$.xgafv* (query-string) - V1 error format.
9506 /// * *access_token* (query-string) - OAuth access token.
9507 /// * *alt* (query-string) - Data format for response.
9508 /// * *callback* (query-string) - JSONP
9509 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9510 /// * *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.
9511 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9512 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9513 /// * *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.
9514 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9515 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9516 pub fn param<T>(
9517 mut self,
9518 name: T,
9519 value: T,
9520 ) -> ProjectLocationBitbucketServerConfigRepoListCall<'a, C>
9521 where
9522 T: AsRef<str>,
9523 {
9524 self._additional_params
9525 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9526 self
9527 }
9528
9529 /// Identifies the authorization scope for the method you are building.
9530 ///
9531 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9532 /// [`Scope::CloudPlatform`].
9533 ///
9534 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9535 /// tokens for more than one scope.
9536 ///
9537 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9538 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9539 /// sufficient, a read-write scope will do as well.
9540 pub fn add_scope<St>(
9541 mut self,
9542 scope: St,
9543 ) -> ProjectLocationBitbucketServerConfigRepoListCall<'a, C>
9544 where
9545 St: AsRef<str>,
9546 {
9547 self._scopes.insert(String::from(scope.as_ref()));
9548 self
9549 }
9550 /// Identifies the authorization scope(s) for the method you are building.
9551 ///
9552 /// See [`Self::add_scope()`] for details.
9553 pub fn add_scopes<I, St>(
9554 mut self,
9555 scopes: I,
9556 ) -> ProjectLocationBitbucketServerConfigRepoListCall<'a, C>
9557 where
9558 I: IntoIterator<Item = St>,
9559 St: AsRef<str>,
9560 {
9561 self._scopes
9562 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9563 self
9564 }
9565
9566 /// Removes all scopes, and no default scope will be used either.
9567 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9568 /// for details).
9569 pub fn clear_scopes(mut self) -> ProjectLocationBitbucketServerConfigRepoListCall<'a, C> {
9570 self._scopes.clear();
9571 self
9572 }
9573}
9574
9575/// Creates a new `BitbucketServerConfig`. This API is experimental.
9576///
9577/// A builder for the *locations.bitbucketServerConfigs.create* method supported by a *project* resource.
9578/// It is not used directly, but through a [`ProjectMethods`] instance.
9579///
9580/// # Example
9581///
9582/// Instantiate a resource method builder
9583///
9584/// ```test_harness,no_run
9585/// # extern crate hyper;
9586/// # extern crate hyper_rustls;
9587/// # extern crate google_cloudbuild1 as cloudbuild1;
9588/// use cloudbuild1::api::BitbucketServerConfig;
9589/// # async fn dox() {
9590/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9591///
9592/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9593/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9594/// # secret,
9595/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9596/// # ).build().await.unwrap();
9597///
9598/// # let client = hyper_util::client::legacy::Client::builder(
9599/// # hyper_util::rt::TokioExecutor::new()
9600/// # )
9601/// # .build(
9602/// # hyper_rustls::HttpsConnectorBuilder::new()
9603/// # .with_native_roots()
9604/// # .unwrap()
9605/// # .https_or_http()
9606/// # .enable_http1()
9607/// # .build()
9608/// # );
9609/// # let mut hub = CloudBuild::new(client, auth);
9610/// // As the method needs a request, you would usually fill it with the desired information
9611/// // into the respective structure. Some of the parts shown here might not be applicable !
9612/// // Values shown here are possibly random and not representative !
9613/// let mut req = BitbucketServerConfig::default();
9614///
9615/// // You can configure optional parameters by calling the respective setters at will, and
9616/// // execute the final call using `doit()`.
9617/// // Values shown here are possibly random and not representative !
9618/// let result = hub.projects().locations_bitbucket_server_configs_create(req, "parent")
9619/// .bitbucket_server_config_id("et")
9620/// .doit().await;
9621/// # }
9622/// ```
9623pub struct ProjectLocationBitbucketServerConfigCreateCall<'a, C>
9624where
9625 C: 'a,
9626{
9627 hub: &'a CloudBuild<C>,
9628 _request: BitbucketServerConfig,
9629 _parent: String,
9630 _bitbucket_server_config_id: Option<String>,
9631 _delegate: Option<&'a mut dyn common::Delegate>,
9632 _additional_params: HashMap<String, String>,
9633 _scopes: BTreeSet<String>,
9634}
9635
9636impl<'a, C> common::CallBuilder for ProjectLocationBitbucketServerConfigCreateCall<'a, C> {}
9637
9638impl<'a, C> ProjectLocationBitbucketServerConfigCreateCall<'a, C>
9639where
9640 C: common::Connector,
9641{
9642 /// Perform the operation you have build so far.
9643 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
9644 use std::borrow::Cow;
9645 use std::io::{Read, Seek};
9646
9647 use common::{url::Params, ToParts};
9648 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9649
9650 let mut dd = common::DefaultDelegate;
9651 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9652 dlg.begin(common::MethodInfo {
9653 id: "cloudbuild.projects.locations.bitbucketServerConfigs.create",
9654 http_method: hyper::Method::POST,
9655 });
9656
9657 for &field in ["alt", "parent", "bitbucketServerConfigId"].iter() {
9658 if self._additional_params.contains_key(field) {
9659 dlg.finished(false);
9660 return Err(common::Error::FieldClash(field));
9661 }
9662 }
9663
9664 let mut params = Params::with_capacity(5 + self._additional_params.len());
9665 params.push("parent", self._parent);
9666 if let Some(value) = self._bitbucket_server_config_id.as_ref() {
9667 params.push("bitbucketServerConfigId", value);
9668 }
9669
9670 params.extend(self._additional_params.iter());
9671
9672 params.push("alt", "json");
9673 let mut url = self.hub._base_url.clone() + "v1/{+parent}/bitbucketServerConfigs";
9674 if self._scopes.is_empty() {
9675 self._scopes
9676 .insert(Scope::CloudPlatform.as_ref().to_string());
9677 }
9678
9679 #[allow(clippy::single_element_loop)]
9680 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
9681 url = params.uri_replacement(url, param_name, find_this, true);
9682 }
9683 {
9684 let to_remove = ["parent"];
9685 params.remove_params(&to_remove);
9686 }
9687
9688 let url = params.parse_with_url(&url);
9689
9690 let mut json_mime_type = mime::APPLICATION_JSON;
9691 let mut request_value_reader = {
9692 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9693 common::remove_json_null_values(&mut value);
9694 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9695 serde_json::to_writer(&mut dst, &value).unwrap();
9696 dst
9697 };
9698 let request_size = request_value_reader
9699 .seek(std::io::SeekFrom::End(0))
9700 .unwrap();
9701 request_value_reader
9702 .seek(std::io::SeekFrom::Start(0))
9703 .unwrap();
9704
9705 loop {
9706 let token = match self
9707 .hub
9708 .auth
9709 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9710 .await
9711 {
9712 Ok(token) => token,
9713 Err(e) => match dlg.token(e) {
9714 Ok(token) => token,
9715 Err(e) => {
9716 dlg.finished(false);
9717 return Err(common::Error::MissingToken(e));
9718 }
9719 },
9720 };
9721 request_value_reader
9722 .seek(std::io::SeekFrom::Start(0))
9723 .unwrap();
9724 let mut req_result = {
9725 let client = &self.hub.client;
9726 dlg.pre_request();
9727 let mut req_builder = hyper::Request::builder()
9728 .method(hyper::Method::POST)
9729 .uri(url.as_str())
9730 .header(USER_AGENT, self.hub._user_agent.clone());
9731
9732 if let Some(token) = token.as_ref() {
9733 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9734 }
9735
9736 let request = req_builder
9737 .header(CONTENT_TYPE, json_mime_type.to_string())
9738 .header(CONTENT_LENGTH, request_size as u64)
9739 .body(common::to_body(
9740 request_value_reader.get_ref().clone().into(),
9741 ));
9742
9743 client.request(request.unwrap()).await
9744 };
9745
9746 match req_result {
9747 Err(err) => {
9748 if let common::Retry::After(d) = dlg.http_error(&err) {
9749 sleep(d).await;
9750 continue;
9751 }
9752 dlg.finished(false);
9753 return Err(common::Error::HttpError(err));
9754 }
9755 Ok(res) => {
9756 let (mut parts, body) = res.into_parts();
9757 let mut body = common::Body::new(body);
9758 if !parts.status.is_success() {
9759 let bytes = common::to_bytes(body).await.unwrap_or_default();
9760 let error = serde_json::from_str(&common::to_string(&bytes));
9761 let response = common::to_response(parts, bytes.into());
9762
9763 if let common::Retry::After(d) =
9764 dlg.http_failure(&response, error.as_ref().ok())
9765 {
9766 sleep(d).await;
9767 continue;
9768 }
9769
9770 dlg.finished(false);
9771
9772 return Err(match error {
9773 Ok(value) => common::Error::BadRequest(value),
9774 _ => common::Error::Failure(response),
9775 });
9776 }
9777 let response = {
9778 let bytes = common::to_bytes(body).await.unwrap_or_default();
9779 let encoded = common::to_string(&bytes);
9780 match serde_json::from_str(&encoded) {
9781 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9782 Err(error) => {
9783 dlg.response_json_decode_error(&encoded, &error);
9784 return Err(common::Error::JsonDecodeError(
9785 encoded.to_string(),
9786 error,
9787 ));
9788 }
9789 }
9790 };
9791
9792 dlg.finished(true);
9793 return Ok(response);
9794 }
9795 }
9796 }
9797 }
9798
9799 ///
9800 /// Sets the *request* property to the given value.
9801 ///
9802 /// Even though the property as already been set when instantiating this call,
9803 /// we provide this method for API completeness.
9804 pub fn request(
9805 mut self,
9806 new_value: BitbucketServerConfig,
9807 ) -> ProjectLocationBitbucketServerConfigCreateCall<'a, C> {
9808 self._request = new_value;
9809 self
9810 }
9811 /// Required. Name of the parent resource.
9812 ///
9813 /// Sets the *parent* path property to the given value.
9814 ///
9815 /// Even though the property as already been set when instantiating this call,
9816 /// we provide this method for API completeness.
9817 pub fn parent(
9818 mut self,
9819 new_value: &str,
9820 ) -> ProjectLocationBitbucketServerConfigCreateCall<'a, C> {
9821 self._parent = new_value.to_string();
9822 self
9823 }
9824 /// Optional. The ID to use for the BitbucketServerConfig, which will become the final component of the BitbucketServerConfig's resource name. bitbucket_server_config_id must meet the following requirements: + They must contain only alphanumeric characters and dashes. + They can be 1-64 characters long. + They must begin and end with an alphanumeric character.
9825 ///
9826 /// Sets the *bitbucket server config id* query property to the given value.
9827 pub fn bitbucket_server_config_id(
9828 mut self,
9829 new_value: &str,
9830 ) -> ProjectLocationBitbucketServerConfigCreateCall<'a, C> {
9831 self._bitbucket_server_config_id = Some(new_value.to_string());
9832 self
9833 }
9834 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9835 /// while executing the actual API request.
9836 ///
9837 /// ````text
9838 /// It should be used to handle progress information, and to implement a certain level of resilience.
9839 /// ````
9840 ///
9841 /// Sets the *delegate* property to the given value.
9842 pub fn delegate(
9843 mut self,
9844 new_value: &'a mut dyn common::Delegate,
9845 ) -> ProjectLocationBitbucketServerConfigCreateCall<'a, C> {
9846 self._delegate = Some(new_value);
9847 self
9848 }
9849
9850 /// Set any additional parameter of the query string used in the request.
9851 /// It should be used to set parameters which are not yet available through their own
9852 /// setters.
9853 ///
9854 /// Please note that this method must not be used to set any of the known parameters
9855 /// which have their own setter method. If done anyway, the request will fail.
9856 ///
9857 /// # Additional Parameters
9858 ///
9859 /// * *$.xgafv* (query-string) - V1 error format.
9860 /// * *access_token* (query-string) - OAuth access token.
9861 /// * *alt* (query-string) - Data format for response.
9862 /// * *callback* (query-string) - JSONP
9863 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9864 /// * *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.
9865 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9866 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9867 /// * *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.
9868 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9869 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9870 pub fn param<T>(
9871 mut self,
9872 name: T,
9873 value: T,
9874 ) -> ProjectLocationBitbucketServerConfigCreateCall<'a, C>
9875 where
9876 T: AsRef<str>,
9877 {
9878 self._additional_params
9879 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9880 self
9881 }
9882
9883 /// Identifies the authorization scope for the method you are building.
9884 ///
9885 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9886 /// [`Scope::CloudPlatform`].
9887 ///
9888 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9889 /// tokens for more than one scope.
9890 ///
9891 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9892 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9893 /// sufficient, a read-write scope will do as well.
9894 pub fn add_scope<St>(
9895 mut self,
9896 scope: St,
9897 ) -> ProjectLocationBitbucketServerConfigCreateCall<'a, C>
9898 where
9899 St: AsRef<str>,
9900 {
9901 self._scopes.insert(String::from(scope.as_ref()));
9902 self
9903 }
9904 /// Identifies the authorization scope(s) for the method you are building.
9905 ///
9906 /// See [`Self::add_scope()`] for details.
9907 pub fn add_scopes<I, St>(
9908 mut self,
9909 scopes: I,
9910 ) -> ProjectLocationBitbucketServerConfigCreateCall<'a, C>
9911 where
9912 I: IntoIterator<Item = St>,
9913 St: AsRef<str>,
9914 {
9915 self._scopes
9916 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9917 self
9918 }
9919
9920 /// Removes all scopes, and no default scope will be used either.
9921 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9922 /// for details).
9923 pub fn clear_scopes(mut self) -> ProjectLocationBitbucketServerConfigCreateCall<'a, C> {
9924 self._scopes.clear();
9925 self
9926 }
9927}
9928
9929/// Delete a `BitbucketServerConfig`. This API is experimental.
9930///
9931/// A builder for the *locations.bitbucketServerConfigs.delete* method supported by a *project* resource.
9932/// It is not used directly, but through a [`ProjectMethods`] instance.
9933///
9934/// # Example
9935///
9936/// Instantiate a resource method builder
9937///
9938/// ```test_harness,no_run
9939/// # extern crate hyper;
9940/// # extern crate hyper_rustls;
9941/// # extern crate google_cloudbuild1 as cloudbuild1;
9942/// # async fn dox() {
9943/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9944///
9945/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9946/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9947/// # secret,
9948/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9949/// # ).build().await.unwrap();
9950///
9951/// # let client = hyper_util::client::legacy::Client::builder(
9952/// # hyper_util::rt::TokioExecutor::new()
9953/// # )
9954/// # .build(
9955/// # hyper_rustls::HttpsConnectorBuilder::new()
9956/// # .with_native_roots()
9957/// # .unwrap()
9958/// # .https_or_http()
9959/// # .enable_http1()
9960/// # .build()
9961/// # );
9962/// # let mut hub = CloudBuild::new(client, auth);
9963/// // You can configure optional parameters by calling the respective setters at will, and
9964/// // execute the final call using `doit()`.
9965/// // Values shown here are possibly random and not representative !
9966/// let result = hub.projects().locations_bitbucket_server_configs_delete("name")
9967/// .doit().await;
9968/// # }
9969/// ```
9970pub struct ProjectLocationBitbucketServerConfigDeleteCall<'a, C>
9971where
9972 C: 'a,
9973{
9974 hub: &'a CloudBuild<C>,
9975 _name: String,
9976 _delegate: Option<&'a mut dyn common::Delegate>,
9977 _additional_params: HashMap<String, String>,
9978 _scopes: BTreeSet<String>,
9979}
9980
9981impl<'a, C> common::CallBuilder for ProjectLocationBitbucketServerConfigDeleteCall<'a, C> {}
9982
9983impl<'a, C> ProjectLocationBitbucketServerConfigDeleteCall<'a, C>
9984where
9985 C: common::Connector,
9986{
9987 /// Perform the operation you have build so far.
9988 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
9989 use std::borrow::Cow;
9990 use std::io::{Read, Seek};
9991
9992 use common::{url::Params, ToParts};
9993 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9994
9995 let mut dd = common::DefaultDelegate;
9996 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9997 dlg.begin(common::MethodInfo {
9998 id: "cloudbuild.projects.locations.bitbucketServerConfigs.delete",
9999 http_method: hyper::Method::DELETE,
10000 });
10001
10002 for &field in ["alt", "name"].iter() {
10003 if self._additional_params.contains_key(field) {
10004 dlg.finished(false);
10005 return Err(common::Error::FieldClash(field));
10006 }
10007 }
10008
10009 let mut params = Params::with_capacity(3 + self._additional_params.len());
10010 params.push("name", self._name);
10011
10012 params.extend(self._additional_params.iter());
10013
10014 params.push("alt", "json");
10015 let mut url = self.hub._base_url.clone() + "v1/{+name}";
10016 if self._scopes.is_empty() {
10017 self._scopes
10018 .insert(Scope::CloudPlatform.as_ref().to_string());
10019 }
10020
10021 #[allow(clippy::single_element_loop)]
10022 for &(find_this, param_name) in [("{+name}", "name")].iter() {
10023 url = params.uri_replacement(url, param_name, find_this, true);
10024 }
10025 {
10026 let to_remove = ["name"];
10027 params.remove_params(&to_remove);
10028 }
10029
10030 let url = params.parse_with_url(&url);
10031
10032 loop {
10033 let token = match self
10034 .hub
10035 .auth
10036 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10037 .await
10038 {
10039 Ok(token) => token,
10040 Err(e) => match dlg.token(e) {
10041 Ok(token) => token,
10042 Err(e) => {
10043 dlg.finished(false);
10044 return Err(common::Error::MissingToken(e));
10045 }
10046 },
10047 };
10048 let mut req_result = {
10049 let client = &self.hub.client;
10050 dlg.pre_request();
10051 let mut req_builder = hyper::Request::builder()
10052 .method(hyper::Method::DELETE)
10053 .uri(url.as_str())
10054 .header(USER_AGENT, self.hub._user_agent.clone());
10055
10056 if let Some(token) = token.as_ref() {
10057 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10058 }
10059
10060 let request = req_builder
10061 .header(CONTENT_LENGTH, 0_u64)
10062 .body(common::to_body::<String>(None));
10063
10064 client.request(request.unwrap()).await
10065 };
10066
10067 match req_result {
10068 Err(err) => {
10069 if let common::Retry::After(d) = dlg.http_error(&err) {
10070 sleep(d).await;
10071 continue;
10072 }
10073 dlg.finished(false);
10074 return Err(common::Error::HttpError(err));
10075 }
10076 Ok(res) => {
10077 let (mut parts, body) = res.into_parts();
10078 let mut body = common::Body::new(body);
10079 if !parts.status.is_success() {
10080 let bytes = common::to_bytes(body).await.unwrap_or_default();
10081 let error = serde_json::from_str(&common::to_string(&bytes));
10082 let response = common::to_response(parts, bytes.into());
10083
10084 if let common::Retry::After(d) =
10085 dlg.http_failure(&response, error.as_ref().ok())
10086 {
10087 sleep(d).await;
10088 continue;
10089 }
10090
10091 dlg.finished(false);
10092
10093 return Err(match error {
10094 Ok(value) => common::Error::BadRequest(value),
10095 _ => common::Error::Failure(response),
10096 });
10097 }
10098 let response = {
10099 let bytes = common::to_bytes(body).await.unwrap_or_default();
10100 let encoded = common::to_string(&bytes);
10101 match serde_json::from_str(&encoded) {
10102 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10103 Err(error) => {
10104 dlg.response_json_decode_error(&encoded, &error);
10105 return Err(common::Error::JsonDecodeError(
10106 encoded.to_string(),
10107 error,
10108 ));
10109 }
10110 }
10111 };
10112
10113 dlg.finished(true);
10114 return Ok(response);
10115 }
10116 }
10117 }
10118 }
10119
10120 /// Required. The config resource name.
10121 ///
10122 /// Sets the *name* path property to the given value.
10123 ///
10124 /// Even though the property as already been set when instantiating this call,
10125 /// we provide this method for API completeness.
10126 pub fn name(
10127 mut self,
10128 new_value: &str,
10129 ) -> ProjectLocationBitbucketServerConfigDeleteCall<'a, C> {
10130 self._name = new_value.to_string();
10131 self
10132 }
10133 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10134 /// while executing the actual API request.
10135 ///
10136 /// ````text
10137 /// It should be used to handle progress information, and to implement a certain level of resilience.
10138 /// ````
10139 ///
10140 /// Sets the *delegate* property to the given value.
10141 pub fn delegate(
10142 mut self,
10143 new_value: &'a mut dyn common::Delegate,
10144 ) -> ProjectLocationBitbucketServerConfigDeleteCall<'a, C> {
10145 self._delegate = Some(new_value);
10146 self
10147 }
10148
10149 /// Set any additional parameter of the query string used in the request.
10150 /// It should be used to set parameters which are not yet available through their own
10151 /// setters.
10152 ///
10153 /// Please note that this method must not be used to set any of the known parameters
10154 /// which have their own setter method. If done anyway, the request will fail.
10155 ///
10156 /// # Additional Parameters
10157 ///
10158 /// * *$.xgafv* (query-string) - V1 error format.
10159 /// * *access_token* (query-string) - OAuth access token.
10160 /// * *alt* (query-string) - Data format for response.
10161 /// * *callback* (query-string) - JSONP
10162 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10163 /// * *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.
10164 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10165 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10166 /// * *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.
10167 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10168 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10169 pub fn param<T>(
10170 mut self,
10171 name: T,
10172 value: T,
10173 ) -> ProjectLocationBitbucketServerConfigDeleteCall<'a, C>
10174 where
10175 T: AsRef<str>,
10176 {
10177 self._additional_params
10178 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10179 self
10180 }
10181
10182 /// Identifies the authorization scope for the method you are building.
10183 ///
10184 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10185 /// [`Scope::CloudPlatform`].
10186 ///
10187 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10188 /// tokens for more than one scope.
10189 ///
10190 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10191 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10192 /// sufficient, a read-write scope will do as well.
10193 pub fn add_scope<St>(
10194 mut self,
10195 scope: St,
10196 ) -> ProjectLocationBitbucketServerConfigDeleteCall<'a, C>
10197 where
10198 St: AsRef<str>,
10199 {
10200 self._scopes.insert(String::from(scope.as_ref()));
10201 self
10202 }
10203 /// Identifies the authorization scope(s) for the method you are building.
10204 ///
10205 /// See [`Self::add_scope()`] for details.
10206 pub fn add_scopes<I, St>(
10207 mut self,
10208 scopes: I,
10209 ) -> ProjectLocationBitbucketServerConfigDeleteCall<'a, C>
10210 where
10211 I: IntoIterator<Item = St>,
10212 St: AsRef<str>,
10213 {
10214 self._scopes
10215 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10216 self
10217 }
10218
10219 /// Removes all scopes, and no default scope will be used either.
10220 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10221 /// for details).
10222 pub fn clear_scopes(mut self) -> ProjectLocationBitbucketServerConfigDeleteCall<'a, C> {
10223 self._scopes.clear();
10224 self
10225 }
10226}
10227
10228/// Retrieve a `BitbucketServerConfig`. This API is experimental.
10229///
10230/// A builder for the *locations.bitbucketServerConfigs.get* method supported by a *project* resource.
10231/// It is not used directly, but through a [`ProjectMethods`] instance.
10232///
10233/// # Example
10234///
10235/// Instantiate a resource method builder
10236///
10237/// ```test_harness,no_run
10238/// # extern crate hyper;
10239/// # extern crate hyper_rustls;
10240/// # extern crate google_cloudbuild1 as cloudbuild1;
10241/// # async fn dox() {
10242/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10243///
10244/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10245/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10246/// # secret,
10247/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10248/// # ).build().await.unwrap();
10249///
10250/// # let client = hyper_util::client::legacy::Client::builder(
10251/// # hyper_util::rt::TokioExecutor::new()
10252/// # )
10253/// # .build(
10254/// # hyper_rustls::HttpsConnectorBuilder::new()
10255/// # .with_native_roots()
10256/// # .unwrap()
10257/// # .https_or_http()
10258/// # .enable_http1()
10259/// # .build()
10260/// # );
10261/// # let mut hub = CloudBuild::new(client, auth);
10262/// // You can configure optional parameters by calling the respective setters at will, and
10263/// // execute the final call using `doit()`.
10264/// // Values shown here are possibly random and not representative !
10265/// let result = hub.projects().locations_bitbucket_server_configs_get("name")
10266/// .doit().await;
10267/// # }
10268/// ```
10269pub struct ProjectLocationBitbucketServerConfigGetCall<'a, C>
10270where
10271 C: 'a,
10272{
10273 hub: &'a CloudBuild<C>,
10274 _name: String,
10275 _delegate: Option<&'a mut dyn common::Delegate>,
10276 _additional_params: HashMap<String, String>,
10277 _scopes: BTreeSet<String>,
10278}
10279
10280impl<'a, C> common::CallBuilder for ProjectLocationBitbucketServerConfigGetCall<'a, C> {}
10281
10282impl<'a, C> ProjectLocationBitbucketServerConfigGetCall<'a, C>
10283where
10284 C: common::Connector,
10285{
10286 /// Perform the operation you have build so far.
10287 pub async fn doit(mut self) -> common::Result<(common::Response, BitbucketServerConfig)> {
10288 use std::borrow::Cow;
10289 use std::io::{Read, Seek};
10290
10291 use common::{url::Params, ToParts};
10292 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10293
10294 let mut dd = common::DefaultDelegate;
10295 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10296 dlg.begin(common::MethodInfo {
10297 id: "cloudbuild.projects.locations.bitbucketServerConfigs.get",
10298 http_method: hyper::Method::GET,
10299 });
10300
10301 for &field in ["alt", "name"].iter() {
10302 if self._additional_params.contains_key(field) {
10303 dlg.finished(false);
10304 return Err(common::Error::FieldClash(field));
10305 }
10306 }
10307
10308 let mut params = Params::with_capacity(3 + self._additional_params.len());
10309 params.push("name", self._name);
10310
10311 params.extend(self._additional_params.iter());
10312
10313 params.push("alt", "json");
10314 let mut url = self.hub._base_url.clone() + "v1/{+name}";
10315 if self._scopes.is_empty() {
10316 self._scopes
10317 .insert(Scope::CloudPlatform.as_ref().to_string());
10318 }
10319
10320 #[allow(clippy::single_element_loop)]
10321 for &(find_this, param_name) in [("{+name}", "name")].iter() {
10322 url = params.uri_replacement(url, param_name, find_this, true);
10323 }
10324 {
10325 let to_remove = ["name"];
10326 params.remove_params(&to_remove);
10327 }
10328
10329 let url = params.parse_with_url(&url);
10330
10331 loop {
10332 let token = match self
10333 .hub
10334 .auth
10335 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10336 .await
10337 {
10338 Ok(token) => token,
10339 Err(e) => match dlg.token(e) {
10340 Ok(token) => token,
10341 Err(e) => {
10342 dlg.finished(false);
10343 return Err(common::Error::MissingToken(e));
10344 }
10345 },
10346 };
10347 let mut req_result = {
10348 let client = &self.hub.client;
10349 dlg.pre_request();
10350 let mut req_builder = hyper::Request::builder()
10351 .method(hyper::Method::GET)
10352 .uri(url.as_str())
10353 .header(USER_AGENT, self.hub._user_agent.clone());
10354
10355 if let Some(token) = token.as_ref() {
10356 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10357 }
10358
10359 let request = req_builder
10360 .header(CONTENT_LENGTH, 0_u64)
10361 .body(common::to_body::<String>(None));
10362
10363 client.request(request.unwrap()).await
10364 };
10365
10366 match req_result {
10367 Err(err) => {
10368 if let common::Retry::After(d) = dlg.http_error(&err) {
10369 sleep(d).await;
10370 continue;
10371 }
10372 dlg.finished(false);
10373 return Err(common::Error::HttpError(err));
10374 }
10375 Ok(res) => {
10376 let (mut parts, body) = res.into_parts();
10377 let mut body = common::Body::new(body);
10378 if !parts.status.is_success() {
10379 let bytes = common::to_bytes(body).await.unwrap_or_default();
10380 let error = serde_json::from_str(&common::to_string(&bytes));
10381 let response = common::to_response(parts, bytes.into());
10382
10383 if let common::Retry::After(d) =
10384 dlg.http_failure(&response, error.as_ref().ok())
10385 {
10386 sleep(d).await;
10387 continue;
10388 }
10389
10390 dlg.finished(false);
10391
10392 return Err(match error {
10393 Ok(value) => common::Error::BadRequest(value),
10394 _ => common::Error::Failure(response),
10395 });
10396 }
10397 let response = {
10398 let bytes = common::to_bytes(body).await.unwrap_or_default();
10399 let encoded = common::to_string(&bytes);
10400 match serde_json::from_str(&encoded) {
10401 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10402 Err(error) => {
10403 dlg.response_json_decode_error(&encoded, &error);
10404 return Err(common::Error::JsonDecodeError(
10405 encoded.to_string(),
10406 error,
10407 ));
10408 }
10409 }
10410 };
10411
10412 dlg.finished(true);
10413 return Ok(response);
10414 }
10415 }
10416 }
10417 }
10418
10419 /// Required. The config resource name.
10420 ///
10421 /// Sets the *name* path property to the given value.
10422 ///
10423 /// Even though the property as already been set when instantiating this call,
10424 /// we provide this method for API completeness.
10425 pub fn name(mut self, new_value: &str) -> ProjectLocationBitbucketServerConfigGetCall<'a, C> {
10426 self._name = new_value.to_string();
10427 self
10428 }
10429 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10430 /// while executing the actual API request.
10431 ///
10432 /// ````text
10433 /// It should be used to handle progress information, and to implement a certain level of resilience.
10434 /// ````
10435 ///
10436 /// Sets the *delegate* property to the given value.
10437 pub fn delegate(
10438 mut self,
10439 new_value: &'a mut dyn common::Delegate,
10440 ) -> ProjectLocationBitbucketServerConfigGetCall<'a, C> {
10441 self._delegate = Some(new_value);
10442 self
10443 }
10444
10445 /// Set any additional parameter of the query string used in the request.
10446 /// It should be used to set parameters which are not yet available through their own
10447 /// setters.
10448 ///
10449 /// Please note that this method must not be used to set any of the known parameters
10450 /// which have their own setter method. If done anyway, the request will fail.
10451 ///
10452 /// # Additional Parameters
10453 ///
10454 /// * *$.xgafv* (query-string) - V1 error format.
10455 /// * *access_token* (query-string) - OAuth access token.
10456 /// * *alt* (query-string) - Data format for response.
10457 /// * *callback* (query-string) - JSONP
10458 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10459 /// * *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.
10460 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10461 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10462 /// * *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.
10463 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10464 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10465 pub fn param<T>(
10466 mut self,
10467 name: T,
10468 value: T,
10469 ) -> ProjectLocationBitbucketServerConfigGetCall<'a, C>
10470 where
10471 T: AsRef<str>,
10472 {
10473 self._additional_params
10474 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10475 self
10476 }
10477
10478 /// Identifies the authorization scope for the method you are building.
10479 ///
10480 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10481 /// [`Scope::CloudPlatform`].
10482 ///
10483 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10484 /// tokens for more than one scope.
10485 ///
10486 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10487 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10488 /// sufficient, a read-write scope will do as well.
10489 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationBitbucketServerConfigGetCall<'a, C>
10490 where
10491 St: AsRef<str>,
10492 {
10493 self._scopes.insert(String::from(scope.as_ref()));
10494 self
10495 }
10496 /// Identifies the authorization scope(s) for the method you are building.
10497 ///
10498 /// See [`Self::add_scope()`] for details.
10499 pub fn add_scopes<I, St>(
10500 mut self,
10501 scopes: I,
10502 ) -> ProjectLocationBitbucketServerConfigGetCall<'a, C>
10503 where
10504 I: IntoIterator<Item = St>,
10505 St: AsRef<str>,
10506 {
10507 self._scopes
10508 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10509 self
10510 }
10511
10512 /// Removes all scopes, and no default scope will be used either.
10513 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10514 /// for details).
10515 pub fn clear_scopes(mut self) -> ProjectLocationBitbucketServerConfigGetCall<'a, C> {
10516 self._scopes.clear();
10517 self
10518 }
10519}
10520
10521/// List all `BitbucketServerConfigs` for a given project. This API is experimental.
10522///
10523/// A builder for the *locations.bitbucketServerConfigs.list* method supported by a *project* resource.
10524/// It is not used directly, but through a [`ProjectMethods`] instance.
10525///
10526/// # Example
10527///
10528/// Instantiate a resource method builder
10529///
10530/// ```test_harness,no_run
10531/// # extern crate hyper;
10532/// # extern crate hyper_rustls;
10533/// # extern crate google_cloudbuild1 as cloudbuild1;
10534/// # async fn dox() {
10535/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10536///
10537/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10538/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10539/// # secret,
10540/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10541/// # ).build().await.unwrap();
10542///
10543/// # let client = hyper_util::client::legacy::Client::builder(
10544/// # hyper_util::rt::TokioExecutor::new()
10545/// # )
10546/// # .build(
10547/// # hyper_rustls::HttpsConnectorBuilder::new()
10548/// # .with_native_roots()
10549/// # .unwrap()
10550/// # .https_or_http()
10551/// # .enable_http1()
10552/// # .build()
10553/// # );
10554/// # let mut hub = CloudBuild::new(client, auth);
10555/// // You can configure optional parameters by calling the respective setters at will, and
10556/// // execute the final call using `doit()`.
10557/// // Values shown here are possibly random and not representative !
10558/// let result = hub.projects().locations_bitbucket_server_configs_list("parent")
10559/// .page_token("sed")
10560/// .page_size(-20)
10561/// .doit().await;
10562/// # }
10563/// ```
10564pub struct ProjectLocationBitbucketServerConfigListCall<'a, C>
10565where
10566 C: 'a,
10567{
10568 hub: &'a CloudBuild<C>,
10569 _parent: String,
10570 _page_token: Option<String>,
10571 _page_size: Option<i32>,
10572 _delegate: Option<&'a mut dyn common::Delegate>,
10573 _additional_params: HashMap<String, String>,
10574 _scopes: BTreeSet<String>,
10575}
10576
10577impl<'a, C> common::CallBuilder for ProjectLocationBitbucketServerConfigListCall<'a, C> {}
10578
10579impl<'a, C> ProjectLocationBitbucketServerConfigListCall<'a, C>
10580where
10581 C: common::Connector,
10582{
10583 /// Perform the operation you have build so far.
10584 pub async fn doit(
10585 mut self,
10586 ) -> common::Result<(common::Response, ListBitbucketServerConfigsResponse)> {
10587 use std::borrow::Cow;
10588 use std::io::{Read, Seek};
10589
10590 use common::{url::Params, ToParts};
10591 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10592
10593 let mut dd = common::DefaultDelegate;
10594 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10595 dlg.begin(common::MethodInfo {
10596 id: "cloudbuild.projects.locations.bitbucketServerConfigs.list",
10597 http_method: hyper::Method::GET,
10598 });
10599
10600 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
10601 if self._additional_params.contains_key(field) {
10602 dlg.finished(false);
10603 return Err(common::Error::FieldClash(field));
10604 }
10605 }
10606
10607 let mut params = Params::with_capacity(5 + self._additional_params.len());
10608 params.push("parent", self._parent);
10609 if let Some(value) = self._page_token.as_ref() {
10610 params.push("pageToken", value);
10611 }
10612 if let Some(value) = self._page_size.as_ref() {
10613 params.push("pageSize", value.to_string());
10614 }
10615
10616 params.extend(self._additional_params.iter());
10617
10618 params.push("alt", "json");
10619 let mut url = self.hub._base_url.clone() + "v1/{+parent}/bitbucketServerConfigs";
10620 if self._scopes.is_empty() {
10621 self._scopes
10622 .insert(Scope::CloudPlatform.as_ref().to_string());
10623 }
10624
10625 #[allow(clippy::single_element_loop)]
10626 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
10627 url = params.uri_replacement(url, param_name, find_this, true);
10628 }
10629 {
10630 let to_remove = ["parent"];
10631 params.remove_params(&to_remove);
10632 }
10633
10634 let url = params.parse_with_url(&url);
10635
10636 loop {
10637 let token = match self
10638 .hub
10639 .auth
10640 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10641 .await
10642 {
10643 Ok(token) => token,
10644 Err(e) => match dlg.token(e) {
10645 Ok(token) => token,
10646 Err(e) => {
10647 dlg.finished(false);
10648 return Err(common::Error::MissingToken(e));
10649 }
10650 },
10651 };
10652 let mut req_result = {
10653 let client = &self.hub.client;
10654 dlg.pre_request();
10655 let mut req_builder = hyper::Request::builder()
10656 .method(hyper::Method::GET)
10657 .uri(url.as_str())
10658 .header(USER_AGENT, self.hub._user_agent.clone());
10659
10660 if let Some(token) = token.as_ref() {
10661 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10662 }
10663
10664 let request = req_builder
10665 .header(CONTENT_LENGTH, 0_u64)
10666 .body(common::to_body::<String>(None));
10667
10668 client.request(request.unwrap()).await
10669 };
10670
10671 match req_result {
10672 Err(err) => {
10673 if let common::Retry::After(d) = dlg.http_error(&err) {
10674 sleep(d).await;
10675 continue;
10676 }
10677 dlg.finished(false);
10678 return Err(common::Error::HttpError(err));
10679 }
10680 Ok(res) => {
10681 let (mut parts, body) = res.into_parts();
10682 let mut body = common::Body::new(body);
10683 if !parts.status.is_success() {
10684 let bytes = common::to_bytes(body).await.unwrap_or_default();
10685 let error = serde_json::from_str(&common::to_string(&bytes));
10686 let response = common::to_response(parts, bytes.into());
10687
10688 if let common::Retry::After(d) =
10689 dlg.http_failure(&response, error.as_ref().ok())
10690 {
10691 sleep(d).await;
10692 continue;
10693 }
10694
10695 dlg.finished(false);
10696
10697 return Err(match error {
10698 Ok(value) => common::Error::BadRequest(value),
10699 _ => common::Error::Failure(response),
10700 });
10701 }
10702 let response = {
10703 let bytes = common::to_bytes(body).await.unwrap_or_default();
10704 let encoded = common::to_string(&bytes);
10705 match serde_json::from_str(&encoded) {
10706 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10707 Err(error) => {
10708 dlg.response_json_decode_error(&encoded, &error);
10709 return Err(common::Error::JsonDecodeError(
10710 encoded.to_string(),
10711 error,
10712 ));
10713 }
10714 }
10715 };
10716
10717 dlg.finished(true);
10718 return Ok(response);
10719 }
10720 }
10721 }
10722 }
10723
10724 /// Required. Name of the parent resource.
10725 ///
10726 /// Sets the *parent* path property to the given value.
10727 ///
10728 /// Even though the property as already been set when instantiating this call,
10729 /// we provide this method for API completeness.
10730 pub fn parent(
10731 mut self,
10732 new_value: &str,
10733 ) -> ProjectLocationBitbucketServerConfigListCall<'a, C> {
10734 self._parent = new_value.to_string();
10735 self
10736 }
10737 /// A page token, received from a previous `ListBitbucketServerConfigsRequest` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListBitbucketServerConfigsRequest` must match the call that provided the page token.
10738 ///
10739 /// Sets the *page token* query property to the given value.
10740 pub fn page_token(
10741 mut self,
10742 new_value: &str,
10743 ) -> ProjectLocationBitbucketServerConfigListCall<'a, C> {
10744 self._page_token = Some(new_value.to_string());
10745 self
10746 }
10747 /// The maximum number of configs to return. The service may return fewer than this value. If unspecified, at most 50 configs will be returned. The maximum value is 1000; values above 1000 will be coerced to 1000.
10748 ///
10749 /// Sets the *page size* query property to the given value.
10750 pub fn page_size(
10751 mut self,
10752 new_value: i32,
10753 ) -> ProjectLocationBitbucketServerConfigListCall<'a, C> {
10754 self._page_size = Some(new_value);
10755 self
10756 }
10757 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10758 /// while executing the actual API request.
10759 ///
10760 /// ````text
10761 /// It should be used to handle progress information, and to implement a certain level of resilience.
10762 /// ````
10763 ///
10764 /// Sets the *delegate* property to the given value.
10765 pub fn delegate(
10766 mut self,
10767 new_value: &'a mut dyn common::Delegate,
10768 ) -> ProjectLocationBitbucketServerConfigListCall<'a, C> {
10769 self._delegate = Some(new_value);
10770 self
10771 }
10772
10773 /// Set any additional parameter of the query string used in the request.
10774 /// It should be used to set parameters which are not yet available through their own
10775 /// setters.
10776 ///
10777 /// Please note that this method must not be used to set any of the known parameters
10778 /// which have their own setter method. If done anyway, the request will fail.
10779 ///
10780 /// # Additional Parameters
10781 ///
10782 /// * *$.xgafv* (query-string) - V1 error format.
10783 /// * *access_token* (query-string) - OAuth access token.
10784 /// * *alt* (query-string) - Data format for response.
10785 /// * *callback* (query-string) - JSONP
10786 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10787 /// * *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.
10788 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10789 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10790 /// * *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.
10791 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10792 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10793 pub fn param<T>(
10794 mut self,
10795 name: T,
10796 value: T,
10797 ) -> ProjectLocationBitbucketServerConfigListCall<'a, C>
10798 where
10799 T: AsRef<str>,
10800 {
10801 self._additional_params
10802 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10803 self
10804 }
10805
10806 /// Identifies the authorization scope for the method you are building.
10807 ///
10808 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10809 /// [`Scope::CloudPlatform`].
10810 ///
10811 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10812 /// tokens for more than one scope.
10813 ///
10814 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10815 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10816 /// sufficient, a read-write scope will do as well.
10817 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationBitbucketServerConfigListCall<'a, C>
10818 where
10819 St: AsRef<str>,
10820 {
10821 self._scopes.insert(String::from(scope.as_ref()));
10822 self
10823 }
10824 /// Identifies the authorization scope(s) for the method you are building.
10825 ///
10826 /// See [`Self::add_scope()`] for details.
10827 pub fn add_scopes<I, St>(
10828 mut self,
10829 scopes: I,
10830 ) -> ProjectLocationBitbucketServerConfigListCall<'a, C>
10831 where
10832 I: IntoIterator<Item = St>,
10833 St: AsRef<str>,
10834 {
10835 self._scopes
10836 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10837 self
10838 }
10839
10840 /// Removes all scopes, and no default scope will be used either.
10841 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10842 /// for details).
10843 pub fn clear_scopes(mut self) -> ProjectLocationBitbucketServerConfigListCall<'a, C> {
10844 self._scopes.clear();
10845 self
10846 }
10847}
10848
10849/// Updates an existing `BitbucketServerConfig`. This API is experimental.
10850///
10851/// A builder for the *locations.bitbucketServerConfigs.patch* method supported by a *project* resource.
10852/// It is not used directly, but through a [`ProjectMethods`] instance.
10853///
10854/// # Example
10855///
10856/// Instantiate a resource method builder
10857///
10858/// ```test_harness,no_run
10859/// # extern crate hyper;
10860/// # extern crate hyper_rustls;
10861/// # extern crate google_cloudbuild1 as cloudbuild1;
10862/// use cloudbuild1::api::BitbucketServerConfig;
10863/// # async fn dox() {
10864/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10865///
10866/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10867/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10868/// # secret,
10869/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10870/// # ).build().await.unwrap();
10871///
10872/// # let client = hyper_util::client::legacy::Client::builder(
10873/// # hyper_util::rt::TokioExecutor::new()
10874/// # )
10875/// # .build(
10876/// # hyper_rustls::HttpsConnectorBuilder::new()
10877/// # .with_native_roots()
10878/// # .unwrap()
10879/// # .https_or_http()
10880/// # .enable_http1()
10881/// # .build()
10882/// # );
10883/// # let mut hub = CloudBuild::new(client, auth);
10884/// // As the method needs a request, you would usually fill it with the desired information
10885/// // into the respective structure. Some of the parts shown here might not be applicable !
10886/// // Values shown here are possibly random and not representative !
10887/// let mut req = BitbucketServerConfig::default();
10888///
10889/// // You can configure optional parameters by calling the respective setters at will, and
10890/// // execute the final call using `doit()`.
10891/// // Values shown here are possibly random and not representative !
10892/// let result = hub.projects().locations_bitbucket_server_configs_patch(req, "name")
10893/// .update_mask(FieldMask::new::<&str>(&[]))
10894/// .doit().await;
10895/// # }
10896/// ```
10897pub struct ProjectLocationBitbucketServerConfigPatchCall<'a, C>
10898where
10899 C: 'a,
10900{
10901 hub: &'a CloudBuild<C>,
10902 _request: BitbucketServerConfig,
10903 _name: String,
10904 _update_mask: Option<common::FieldMask>,
10905 _delegate: Option<&'a mut dyn common::Delegate>,
10906 _additional_params: HashMap<String, String>,
10907 _scopes: BTreeSet<String>,
10908}
10909
10910impl<'a, C> common::CallBuilder for ProjectLocationBitbucketServerConfigPatchCall<'a, C> {}
10911
10912impl<'a, C> ProjectLocationBitbucketServerConfigPatchCall<'a, C>
10913where
10914 C: common::Connector,
10915{
10916 /// Perform the operation you have build so far.
10917 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
10918 use std::borrow::Cow;
10919 use std::io::{Read, Seek};
10920
10921 use common::{url::Params, ToParts};
10922 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10923
10924 let mut dd = common::DefaultDelegate;
10925 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10926 dlg.begin(common::MethodInfo {
10927 id: "cloudbuild.projects.locations.bitbucketServerConfigs.patch",
10928 http_method: hyper::Method::PATCH,
10929 });
10930
10931 for &field in ["alt", "name", "updateMask"].iter() {
10932 if self._additional_params.contains_key(field) {
10933 dlg.finished(false);
10934 return Err(common::Error::FieldClash(field));
10935 }
10936 }
10937
10938 let mut params = Params::with_capacity(5 + self._additional_params.len());
10939 params.push("name", self._name);
10940 if let Some(value) = self._update_mask.as_ref() {
10941 params.push("updateMask", value.to_string());
10942 }
10943
10944 params.extend(self._additional_params.iter());
10945
10946 params.push("alt", "json");
10947 let mut url = self.hub._base_url.clone() + "v1/{+name}";
10948 if self._scopes.is_empty() {
10949 self._scopes
10950 .insert(Scope::CloudPlatform.as_ref().to_string());
10951 }
10952
10953 #[allow(clippy::single_element_loop)]
10954 for &(find_this, param_name) in [("{+name}", "name")].iter() {
10955 url = params.uri_replacement(url, param_name, find_this, true);
10956 }
10957 {
10958 let to_remove = ["name"];
10959 params.remove_params(&to_remove);
10960 }
10961
10962 let url = params.parse_with_url(&url);
10963
10964 let mut json_mime_type = mime::APPLICATION_JSON;
10965 let mut request_value_reader = {
10966 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10967 common::remove_json_null_values(&mut value);
10968 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10969 serde_json::to_writer(&mut dst, &value).unwrap();
10970 dst
10971 };
10972 let request_size = request_value_reader
10973 .seek(std::io::SeekFrom::End(0))
10974 .unwrap();
10975 request_value_reader
10976 .seek(std::io::SeekFrom::Start(0))
10977 .unwrap();
10978
10979 loop {
10980 let token = match self
10981 .hub
10982 .auth
10983 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10984 .await
10985 {
10986 Ok(token) => token,
10987 Err(e) => match dlg.token(e) {
10988 Ok(token) => token,
10989 Err(e) => {
10990 dlg.finished(false);
10991 return Err(common::Error::MissingToken(e));
10992 }
10993 },
10994 };
10995 request_value_reader
10996 .seek(std::io::SeekFrom::Start(0))
10997 .unwrap();
10998 let mut req_result = {
10999 let client = &self.hub.client;
11000 dlg.pre_request();
11001 let mut req_builder = hyper::Request::builder()
11002 .method(hyper::Method::PATCH)
11003 .uri(url.as_str())
11004 .header(USER_AGENT, self.hub._user_agent.clone());
11005
11006 if let Some(token) = token.as_ref() {
11007 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11008 }
11009
11010 let request = req_builder
11011 .header(CONTENT_TYPE, json_mime_type.to_string())
11012 .header(CONTENT_LENGTH, request_size as u64)
11013 .body(common::to_body(
11014 request_value_reader.get_ref().clone().into(),
11015 ));
11016
11017 client.request(request.unwrap()).await
11018 };
11019
11020 match req_result {
11021 Err(err) => {
11022 if let common::Retry::After(d) = dlg.http_error(&err) {
11023 sleep(d).await;
11024 continue;
11025 }
11026 dlg.finished(false);
11027 return Err(common::Error::HttpError(err));
11028 }
11029 Ok(res) => {
11030 let (mut parts, body) = res.into_parts();
11031 let mut body = common::Body::new(body);
11032 if !parts.status.is_success() {
11033 let bytes = common::to_bytes(body).await.unwrap_or_default();
11034 let error = serde_json::from_str(&common::to_string(&bytes));
11035 let response = common::to_response(parts, bytes.into());
11036
11037 if let common::Retry::After(d) =
11038 dlg.http_failure(&response, error.as_ref().ok())
11039 {
11040 sleep(d).await;
11041 continue;
11042 }
11043
11044 dlg.finished(false);
11045
11046 return Err(match error {
11047 Ok(value) => common::Error::BadRequest(value),
11048 _ => common::Error::Failure(response),
11049 });
11050 }
11051 let response = {
11052 let bytes = common::to_bytes(body).await.unwrap_or_default();
11053 let encoded = common::to_string(&bytes);
11054 match serde_json::from_str(&encoded) {
11055 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11056 Err(error) => {
11057 dlg.response_json_decode_error(&encoded, &error);
11058 return Err(common::Error::JsonDecodeError(
11059 encoded.to_string(),
11060 error,
11061 ));
11062 }
11063 }
11064 };
11065
11066 dlg.finished(true);
11067 return Ok(response);
11068 }
11069 }
11070 }
11071 }
11072
11073 ///
11074 /// Sets the *request* property to the given value.
11075 ///
11076 /// Even though the property as already been set when instantiating this call,
11077 /// we provide this method for API completeness.
11078 pub fn request(
11079 mut self,
11080 new_value: BitbucketServerConfig,
11081 ) -> ProjectLocationBitbucketServerConfigPatchCall<'a, C> {
11082 self._request = new_value;
11083 self
11084 }
11085 /// The resource name for the config.
11086 ///
11087 /// Sets the *name* path property to the given value.
11088 ///
11089 /// Even though the property as already been set when instantiating this call,
11090 /// we provide this method for API completeness.
11091 pub fn name(mut self, new_value: &str) -> ProjectLocationBitbucketServerConfigPatchCall<'a, C> {
11092 self._name = new_value.to_string();
11093 self
11094 }
11095 /// Update mask for the resource. If this is set, the server will only update the fields specified in the field mask. Otherwise, a full update of the mutable resource fields will be performed.
11096 ///
11097 /// Sets the *update mask* query property to the given value.
11098 pub fn update_mask(
11099 mut self,
11100 new_value: common::FieldMask,
11101 ) -> ProjectLocationBitbucketServerConfigPatchCall<'a, C> {
11102 self._update_mask = Some(new_value);
11103 self
11104 }
11105 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11106 /// while executing the actual API request.
11107 ///
11108 /// ````text
11109 /// It should be used to handle progress information, and to implement a certain level of resilience.
11110 /// ````
11111 ///
11112 /// Sets the *delegate* property to the given value.
11113 pub fn delegate(
11114 mut self,
11115 new_value: &'a mut dyn common::Delegate,
11116 ) -> ProjectLocationBitbucketServerConfigPatchCall<'a, C> {
11117 self._delegate = Some(new_value);
11118 self
11119 }
11120
11121 /// Set any additional parameter of the query string used in the request.
11122 /// It should be used to set parameters which are not yet available through their own
11123 /// setters.
11124 ///
11125 /// Please note that this method must not be used to set any of the known parameters
11126 /// which have their own setter method. If done anyway, the request will fail.
11127 ///
11128 /// # Additional Parameters
11129 ///
11130 /// * *$.xgafv* (query-string) - V1 error format.
11131 /// * *access_token* (query-string) - OAuth access token.
11132 /// * *alt* (query-string) - Data format for response.
11133 /// * *callback* (query-string) - JSONP
11134 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11135 /// * *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.
11136 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11137 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11138 /// * *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.
11139 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11140 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11141 pub fn param<T>(
11142 mut self,
11143 name: T,
11144 value: T,
11145 ) -> ProjectLocationBitbucketServerConfigPatchCall<'a, C>
11146 where
11147 T: AsRef<str>,
11148 {
11149 self._additional_params
11150 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11151 self
11152 }
11153
11154 /// Identifies the authorization scope for the method you are building.
11155 ///
11156 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11157 /// [`Scope::CloudPlatform`].
11158 ///
11159 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11160 /// tokens for more than one scope.
11161 ///
11162 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11163 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11164 /// sufficient, a read-write scope will do as well.
11165 pub fn add_scope<St>(
11166 mut self,
11167 scope: St,
11168 ) -> ProjectLocationBitbucketServerConfigPatchCall<'a, C>
11169 where
11170 St: AsRef<str>,
11171 {
11172 self._scopes.insert(String::from(scope.as_ref()));
11173 self
11174 }
11175 /// Identifies the authorization scope(s) for the method you are building.
11176 ///
11177 /// See [`Self::add_scope()`] for details.
11178 pub fn add_scopes<I, St>(
11179 mut self,
11180 scopes: I,
11181 ) -> ProjectLocationBitbucketServerConfigPatchCall<'a, C>
11182 where
11183 I: IntoIterator<Item = St>,
11184 St: AsRef<str>,
11185 {
11186 self._scopes
11187 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11188 self
11189 }
11190
11191 /// Removes all scopes, and no default scope will be used either.
11192 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11193 /// for details).
11194 pub fn clear_scopes(mut self) -> ProjectLocationBitbucketServerConfigPatchCall<'a, C> {
11195 self._scopes.clear();
11196 self
11197 }
11198}
11199
11200/// Remove a Bitbucket Server repository from a given BitbucketServerConfig's connected repositories. This API is experimental.
11201///
11202/// A builder for the *locations.bitbucketServerConfigs.removeBitbucketServerConnectedRepository* method supported by a *project* resource.
11203/// It is not used directly, but through a [`ProjectMethods`] instance.
11204///
11205/// # Example
11206///
11207/// Instantiate a resource method builder
11208///
11209/// ```test_harness,no_run
11210/// # extern crate hyper;
11211/// # extern crate hyper_rustls;
11212/// # extern crate google_cloudbuild1 as cloudbuild1;
11213/// use cloudbuild1::api::RemoveBitbucketServerConnectedRepositoryRequest;
11214/// # async fn dox() {
11215/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11216///
11217/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11218/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11219/// # secret,
11220/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11221/// # ).build().await.unwrap();
11222///
11223/// # let client = hyper_util::client::legacy::Client::builder(
11224/// # hyper_util::rt::TokioExecutor::new()
11225/// # )
11226/// # .build(
11227/// # hyper_rustls::HttpsConnectorBuilder::new()
11228/// # .with_native_roots()
11229/// # .unwrap()
11230/// # .https_or_http()
11231/// # .enable_http1()
11232/// # .build()
11233/// # );
11234/// # let mut hub = CloudBuild::new(client, auth);
11235/// // As the method needs a request, you would usually fill it with the desired information
11236/// // into the respective structure. Some of the parts shown here might not be applicable !
11237/// // Values shown here are possibly random and not representative !
11238/// let mut req = RemoveBitbucketServerConnectedRepositoryRequest::default();
11239///
11240/// // You can configure optional parameters by calling the respective setters at will, and
11241/// // execute the final call using `doit()`.
11242/// // Values shown here are possibly random and not representative !
11243/// let result = hub.projects().locations_bitbucket_server_configs_remove_bitbucket_server_connected_repository(req, "config")
11244/// .doit().await;
11245/// # }
11246/// ```
11247pub struct ProjectLocationBitbucketServerConfigRemoveBitbucketServerConnectedRepositoryCall<'a, C>
11248where
11249 C: 'a,
11250{
11251 hub: &'a CloudBuild<C>,
11252 _request: RemoveBitbucketServerConnectedRepositoryRequest,
11253 _config: String,
11254 _delegate: Option<&'a mut dyn common::Delegate>,
11255 _additional_params: HashMap<String, String>,
11256 _scopes: BTreeSet<String>,
11257}
11258
11259impl<'a, C> common::CallBuilder
11260 for ProjectLocationBitbucketServerConfigRemoveBitbucketServerConnectedRepositoryCall<'a, C>
11261{
11262}
11263
11264impl<'a, C> ProjectLocationBitbucketServerConfigRemoveBitbucketServerConnectedRepositoryCall<'a, C>
11265where
11266 C: common::Connector,
11267{
11268 /// Perform the operation you have build so far.
11269 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
11270 use std::borrow::Cow;
11271 use std::io::{Read, Seek};
11272
11273 use common::{url::Params, ToParts};
11274 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11275
11276 let mut dd = common::DefaultDelegate;
11277 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11278 dlg.begin(common::MethodInfo { id: "cloudbuild.projects.locations.bitbucketServerConfigs.removeBitbucketServerConnectedRepository",
11279 http_method: hyper::Method::POST });
11280
11281 for &field in ["alt", "config"].iter() {
11282 if self._additional_params.contains_key(field) {
11283 dlg.finished(false);
11284 return Err(common::Error::FieldClash(field));
11285 }
11286 }
11287
11288 let mut params = Params::with_capacity(4 + self._additional_params.len());
11289 params.push("config", self._config);
11290
11291 params.extend(self._additional_params.iter());
11292
11293 params.push("alt", "json");
11294 let mut url =
11295 self.hub._base_url.clone() + "v1/{+config}:removeBitbucketServerConnectedRepository";
11296 if self._scopes.is_empty() {
11297 self._scopes
11298 .insert(Scope::CloudPlatform.as_ref().to_string());
11299 }
11300
11301 #[allow(clippy::single_element_loop)]
11302 for &(find_this, param_name) in [("{+config}", "config")].iter() {
11303 url = params.uri_replacement(url, param_name, find_this, true);
11304 }
11305 {
11306 let to_remove = ["config"];
11307 params.remove_params(&to_remove);
11308 }
11309
11310 let url = params.parse_with_url(&url);
11311
11312 let mut json_mime_type = mime::APPLICATION_JSON;
11313 let mut request_value_reader = {
11314 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11315 common::remove_json_null_values(&mut value);
11316 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11317 serde_json::to_writer(&mut dst, &value).unwrap();
11318 dst
11319 };
11320 let request_size = request_value_reader
11321 .seek(std::io::SeekFrom::End(0))
11322 .unwrap();
11323 request_value_reader
11324 .seek(std::io::SeekFrom::Start(0))
11325 .unwrap();
11326
11327 loop {
11328 let token = match self
11329 .hub
11330 .auth
11331 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11332 .await
11333 {
11334 Ok(token) => token,
11335 Err(e) => match dlg.token(e) {
11336 Ok(token) => token,
11337 Err(e) => {
11338 dlg.finished(false);
11339 return Err(common::Error::MissingToken(e));
11340 }
11341 },
11342 };
11343 request_value_reader
11344 .seek(std::io::SeekFrom::Start(0))
11345 .unwrap();
11346 let mut req_result = {
11347 let client = &self.hub.client;
11348 dlg.pre_request();
11349 let mut req_builder = hyper::Request::builder()
11350 .method(hyper::Method::POST)
11351 .uri(url.as_str())
11352 .header(USER_AGENT, self.hub._user_agent.clone());
11353
11354 if let Some(token) = token.as_ref() {
11355 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11356 }
11357
11358 let request = req_builder
11359 .header(CONTENT_TYPE, json_mime_type.to_string())
11360 .header(CONTENT_LENGTH, request_size as u64)
11361 .body(common::to_body(
11362 request_value_reader.get_ref().clone().into(),
11363 ));
11364
11365 client.request(request.unwrap()).await
11366 };
11367
11368 match req_result {
11369 Err(err) => {
11370 if let common::Retry::After(d) = dlg.http_error(&err) {
11371 sleep(d).await;
11372 continue;
11373 }
11374 dlg.finished(false);
11375 return Err(common::Error::HttpError(err));
11376 }
11377 Ok(res) => {
11378 let (mut parts, body) = res.into_parts();
11379 let mut body = common::Body::new(body);
11380 if !parts.status.is_success() {
11381 let bytes = common::to_bytes(body).await.unwrap_or_default();
11382 let error = serde_json::from_str(&common::to_string(&bytes));
11383 let response = common::to_response(parts, bytes.into());
11384
11385 if let common::Retry::After(d) =
11386 dlg.http_failure(&response, error.as_ref().ok())
11387 {
11388 sleep(d).await;
11389 continue;
11390 }
11391
11392 dlg.finished(false);
11393
11394 return Err(match error {
11395 Ok(value) => common::Error::BadRequest(value),
11396 _ => common::Error::Failure(response),
11397 });
11398 }
11399 let response = {
11400 let bytes = common::to_bytes(body).await.unwrap_or_default();
11401 let encoded = common::to_string(&bytes);
11402 match serde_json::from_str(&encoded) {
11403 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11404 Err(error) => {
11405 dlg.response_json_decode_error(&encoded, &error);
11406 return Err(common::Error::JsonDecodeError(
11407 encoded.to_string(),
11408 error,
11409 ));
11410 }
11411 }
11412 };
11413
11414 dlg.finished(true);
11415 return Ok(response);
11416 }
11417 }
11418 }
11419 }
11420
11421 ///
11422 /// Sets the *request* property to the given value.
11423 ///
11424 /// Even though the property as already been set when instantiating this call,
11425 /// we provide this method for API completeness.
11426 pub fn request(
11427 mut self,
11428 new_value: RemoveBitbucketServerConnectedRepositoryRequest,
11429 ) -> ProjectLocationBitbucketServerConfigRemoveBitbucketServerConnectedRepositoryCall<'a, C>
11430 {
11431 self._request = new_value;
11432 self
11433 }
11434 /// Required. The name of the `BitbucketServerConfig` to remove a connected repository. Format: `projects/{project}/locations/{location}/bitbucketServerConfigs/{config}`
11435 ///
11436 /// Sets the *config* path property to the given value.
11437 ///
11438 /// Even though the property as already been set when instantiating this call,
11439 /// we provide this method for API completeness.
11440 pub fn config(
11441 mut self,
11442 new_value: &str,
11443 ) -> ProjectLocationBitbucketServerConfigRemoveBitbucketServerConnectedRepositoryCall<'a, C>
11444 {
11445 self._config = new_value.to_string();
11446 self
11447 }
11448 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11449 /// while executing the actual API request.
11450 ///
11451 /// ````text
11452 /// It should be used to handle progress information, and to implement a certain level of resilience.
11453 /// ````
11454 ///
11455 /// Sets the *delegate* property to the given value.
11456 pub fn delegate(
11457 mut self,
11458 new_value: &'a mut dyn common::Delegate,
11459 ) -> ProjectLocationBitbucketServerConfigRemoveBitbucketServerConnectedRepositoryCall<'a, C>
11460 {
11461 self._delegate = Some(new_value);
11462 self
11463 }
11464
11465 /// Set any additional parameter of the query string used in the request.
11466 /// It should be used to set parameters which are not yet available through their own
11467 /// setters.
11468 ///
11469 /// Please note that this method must not be used to set any of the known parameters
11470 /// which have their own setter method. If done anyway, the request will fail.
11471 ///
11472 /// # Additional Parameters
11473 ///
11474 /// * *$.xgafv* (query-string) - V1 error format.
11475 /// * *access_token* (query-string) - OAuth access token.
11476 /// * *alt* (query-string) - Data format for response.
11477 /// * *callback* (query-string) - JSONP
11478 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11479 /// * *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.
11480 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11481 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11482 /// * *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.
11483 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11484 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11485 pub fn param<T>(
11486 mut self,
11487 name: T,
11488 value: T,
11489 ) -> ProjectLocationBitbucketServerConfigRemoveBitbucketServerConnectedRepositoryCall<'a, C>
11490 where
11491 T: AsRef<str>,
11492 {
11493 self._additional_params
11494 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11495 self
11496 }
11497
11498 /// Identifies the authorization scope for the method you are building.
11499 ///
11500 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11501 /// [`Scope::CloudPlatform`].
11502 ///
11503 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11504 /// tokens for more than one scope.
11505 ///
11506 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11507 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11508 /// sufficient, a read-write scope will do as well.
11509 pub fn add_scope<St>(
11510 mut self,
11511 scope: St,
11512 ) -> ProjectLocationBitbucketServerConfigRemoveBitbucketServerConnectedRepositoryCall<'a, C>
11513 where
11514 St: AsRef<str>,
11515 {
11516 self._scopes.insert(String::from(scope.as_ref()));
11517 self
11518 }
11519 /// Identifies the authorization scope(s) for the method you are building.
11520 ///
11521 /// See [`Self::add_scope()`] for details.
11522 pub fn add_scopes<I, St>(
11523 mut self,
11524 scopes: I,
11525 ) -> ProjectLocationBitbucketServerConfigRemoveBitbucketServerConnectedRepositoryCall<'a, C>
11526 where
11527 I: IntoIterator<Item = St>,
11528 St: AsRef<str>,
11529 {
11530 self._scopes
11531 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11532 self
11533 }
11534
11535 /// Removes all scopes, and no default scope will be used either.
11536 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11537 /// for details).
11538 pub fn clear_scopes(
11539 mut self,
11540 ) -> ProjectLocationBitbucketServerConfigRemoveBitbucketServerConnectedRepositoryCall<'a, C>
11541 {
11542 self._scopes.clear();
11543 self
11544 }
11545}
11546
11547/// Approves or rejects a pending build. If approved, the returned LRO will be analogous to the LRO returned from a CreateBuild call. If rejected, the returned LRO will be immediately done.
11548///
11549/// A builder for the *locations.builds.approve* method supported by a *project* resource.
11550/// It is not used directly, but through a [`ProjectMethods`] instance.
11551///
11552/// # Example
11553///
11554/// Instantiate a resource method builder
11555///
11556/// ```test_harness,no_run
11557/// # extern crate hyper;
11558/// # extern crate hyper_rustls;
11559/// # extern crate google_cloudbuild1 as cloudbuild1;
11560/// use cloudbuild1::api::ApproveBuildRequest;
11561/// # async fn dox() {
11562/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11563///
11564/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11565/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11566/// # secret,
11567/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11568/// # ).build().await.unwrap();
11569///
11570/// # let client = hyper_util::client::legacy::Client::builder(
11571/// # hyper_util::rt::TokioExecutor::new()
11572/// # )
11573/// # .build(
11574/// # hyper_rustls::HttpsConnectorBuilder::new()
11575/// # .with_native_roots()
11576/// # .unwrap()
11577/// # .https_or_http()
11578/// # .enable_http1()
11579/// # .build()
11580/// # );
11581/// # let mut hub = CloudBuild::new(client, auth);
11582/// // As the method needs a request, you would usually fill it with the desired information
11583/// // into the respective structure. Some of the parts shown here might not be applicable !
11584/// // Values shown here are possibly random and not representative !
11585/// let mut req = ApproveBuildRequest::default();
11586///
11587/// // You can configure optional parameters by calling the respective setters at will, and
11588/// // execute the final call using `doit()`.
11589/// // Values shown here are possibly random and not representative !
11590/// let result = hub.projects().locations_builds_approve(req, "name")
11591/// .doit().await;
11592/// # }
11593/// ```
11594pub struct ProjectLocationBuildApproveCall<'a, C>
11595where
11596 C: 'a,
11597{
11598 hub: &'a CloudBuild<C>,
11599 _request: ApproveBuildRequest,
11600 _name: String,
11601 _delegate: Option<&'a mut dyn common::Delegate>,
11602 _additional_params: HashMap<String, String>,
11603 _scopes: BTreeSet<String>,
11604}
11605
11606impl<'a, C> common::CallBuilder for ProjectLocationBuildApproveCall<'a, C> {}
11607
11608impl<'a, C> ProjectLocationBuildApproveCall<'a, C>
11609where
11610 C: common::Connector,
11611{
11612 /// Perform the operation you have build so far.
11613 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
11614 use std::borrow::Cow;
11615 use std::io::{Read, Seek};
11616
11617 use common::{url::Params, ToParts};
11618 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11619
11620 let mut dd = common::DefaultDelegate;
11621 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11622 dlg.begin(common::MethodInfo {
11623 id: "cloudbuild.projects.locations.builds.approve",
11624 http_method: hyper::Method::POST,
11625 });
11626
11627 for &field in ["alt", "name"].iter() {
11628 if self._additional_params.contains_key(field) {
11629 dlg.finished(false);
11630 return Err(common::Error::FieldClash(field));
11631 }
11632 }
11633
11634 let mut params = Params::with_capacity(4 + self._additional_params.len());
11635 params.push("name", self._name);
11636
11637 params.extend(self._additional_params.iter());
11638
11639 params.push("alt", "json");
11640 let mut url = self.hub._base_url.clone() + "v1/{+name}:approve";
11641 if self._scopes.is_empty() {
11642 self._scopes
11643 .insert(Scope::CloudPlatform.as_ref().to_string());
11644 }
11645
11646 #[allow(clippy::single_element_loop)]
11647 for &(find_this, param_name) in [("{+name}", "name")].iter() {
11648 url = params.uri_replacement(url, param_name, find_this, true);
11649 }
11650 {
11651 let to_remove = ["name"];
11652 params.remove_params(&to_remove);
11653 }
11654
11655 let url = params.parse_with_url(&url);
11656
11657 let mut json_mime_type = mime::APPLICATION_JSON;
11658 let mut request_value_reader = {
11659 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11660 common::remove_json_null_values(&mut value);
11661 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11662 serde_json::to_writer(&mut dst, &value).unwrap();
11663 dst
11664 };
11665 let request_size = request_value_reader
11666 .seek(std::io::SeekFrom::End(0))
11667 .unwrap();
11668 request_value_reader
11669 .seek(std::io::SeekFrom::Start(0))
11670 .unwrap();
11671
11672 loop {
11673 let token = match self
11674 .hub
11675 .auth
11676 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11677 .await
11678 {
11679 Ok(token) => token,
11680 Err(e) => match dlg.token(e) {
11681 Ok(token) => token,
11682 Err(e) => {
11683 dlg.finished(false);
11684 return Err(common::Error::MissingToken(e));
11685 }
11686 },
11687 };
11688 request_value_reader
11689 .seek(std::io::SeekFrom::Start(0))
11690 .unwrap();
11691 let mut req_result = {
11692 let client = &self.hub.client;
11693 dlg.pre_request();
11694 let mut req_builder = hyper::Request::builder()
11695 .method(hyper::Method::POST)
11696 .uri(url.as_str())
11697 .header(USER_AGENT, self.hub._user_agent.clone());
11698
11699 if let Some(token) = token.as_ref() {
11700 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11701 }
11702
11703 let request = req_builder
11704 .header(CONTENT_TYPE, json_mime_type.to_string())
11705 .header(CONTENT_LENGTH, request_size as u64)
11706 .body(common::to_body(
11707 request_value_reader.get_ref().clone().into(),
11708 ));
11709
11710 client.request(request.unwrap()).await
11711 };
11712
11713 match req_result {
11714 Err(err) => {
11715 if let common::Retry::After(d) = dlg.http_error(&err) {
11716 sleep(d).await;
11717 continue;
11718 }
11719 dlg.finished(false);
11720 return Err(common::Error::HttpError(err));
11721 }
11722 Ok(res) => {
11723 let (mut parts, body) = res.into_parts();
11724 let mut body = common::Body::new(body);
11725 if !parts.status.is_success() {
11726 let bytes = common::to_bytes(body).await.unwrap_or_default();
11727 let error = serde_json::from_str(&common::to_string(&bytes));
11728 let response = common::to_response(parts, bytes.into());
11729
11730 if let common::Retry::After(d) =
11731 dlg.http_failure(&response, error.as_ref().ok())
11732 {
11733 sleep(d).await;
11734 continue;
11735 }
11736
11737 dlg.finished(false);
11738
11739 return Err(match error {
11740 Ok(value) => common::Error::BadRequest(value),
11741 _ => common::Error::Failure(response),
11742 });
11743 }
11744 let response = {
11745 let bytes = common::to_bytes(body).await.unwrap_or_default();
11746 let encoded = common::to_string(&bytes);
11747 match serde_json::from_str(&encoded) {
11748 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11749 Err(error) => {
11750 dlg.response_json_decode_error(&encoded, &error);
11751 return Err(common::Error::JsonDecodeError(
11752 encoded.to_string(),
11753 error,
11754 ));
11755 }
11756 }
11757 };
11758
11759 dlg.finished(true);
11760 return Ok(response);
11761 }
11762 }
11763 }
11764 }
11765
11766 ///
11767 /// Sets the *request* property to the given value.
11768 ///
11769 /// Even though the property as already been set when instantiating this call,
11770 /// we provide this method for API completeness.
11771 pub fn request(
11772 mut self,
11773 new_value: ApproveBuildRequest,
11774 ) -> ProjectLocationBuildApproveCall<'a, C> {
11775 self._request = new_value;
11776 self
11777 }
11778 /// Required. Name of the target build. For example: "projects/{$project_id}/builds/{$build_id}"
11779 ///
11780 /// Sets the *name* path property to the given value.
11781 ///
11782 /// Even though the property as already been set when instantiating this call,
11783 /// we provide this method for API completeness.
11784 pub fn name(mut self, new_value: &str) -> ProjectLocationBuildApproveCall<'a, C> {
11785 self._name = new_value.to_string();
11786 self
11787 }
11788 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11789 /// while executing the actual API request.
11790 ///
11791 /// ````text
11792 /// It should be used to handle progress information, and to implement a certain level of resilience.
11793 /// ````
11794 ///
11795 /// Sets the *delegate* property to the given value.
11796 pub fn delegate(
11797 mut self,
11798 new_value: &'a mut dyn common::Delegate,
11799 ) -> ProjectLocationBuildApproveCall<'a, C> {
11800 self._delegate = Some(new_value);
11801 self
11802 }
11803
11804 /// Set any additional parameter of the query string used in the request.
11805 /// It should be used to set parameters which are not yet available through their own
11806 /// setters.
11807 ///
11808 /// Please note that this method must not be used to set any of the known parameters
11809 /// which have their own setter method. If done anyway, the request will fail.
11810 ///
11811 /// # Additional Parameters
11812 ///
11813 /// * *$.xgafv* (query-string) - V1 error format.
11814 /// * *access_token* (query-string) - OAuth access token.
11815 /// * *alt* (query-string) - Data format for response.
11816 /// * *callback* (query-string) - JSONP
11817 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11818 /// * *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.
11819 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11820 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11821 /// * *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.
11822 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11823 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11824 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationBuildApproveCall<'a, C>
11825 where
11826 T: AsRef<str>,
11827 {
11828 self._additional_params
11829 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11830 self
11831 }
11832
11833 /// Identifies the authorization scope for the method you are building.
11834 ///
11835 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11836 /// [`Scope::CloudPlatform`].
11837 ///
11838 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11839 /// tokens for more than one scope.
11840 ///
11841 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11842 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11843 /// sufficient, a read-write scope will do as well.
11844 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationBuildApproveCall<'a, C>
11845 where
11846 St: AsRef<str>,
11847 {
11848 self._scopes.insert(String::from(scope.as_ref()));
11849 self
11850 }
11851 /// Identifies the authorization scope(s) for the method you are building.
11852 ///
11853 /// See [`Self::add_scope()`] for details.
11854 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationBuildApproveCall<'a, C>
11855 where
11856 I: IntoIterator<Item = St>,
11857 St: AsRef<str>,
11858 {
11859 self._scopes
11860 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11861 self
11862 }
11863
11864 /// Removes all scopes, and no default scope will be used either.
11865 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11866 /// for details).
11867 pub fn clear_scopes(mut self) -> ProjectLocationBuildApproveCall<'a, C> {
11868 self._scopes.clear();
11869 self
11870 }
11871}
11872
11873/// Cancels a build in progress.
11874///
11875/// A builder for the *locations.builds.cancel* method supported by a *project* resource.
11876/// It is not used directly, but through a [`ProjectMethods`] instance.
11877///
11878/// # Example
11879///
11880/// Instantiate a resource method builder
11881///
11882/// ```test_harness,no_run
11883/// # extern crate hyper;
11884/// # extern crate hyper_rustls;
11885/// # extern crate google_cloudbuild1 as cloudbuild1;
11886/// use cloudbuild1::api::CancelBuildRequest;
11887/// # async fn dox() {
11888/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11889///
11890/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11891/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11892/// # secret,
11893/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11894/// # ).build().await.unwrap();
11895///
11896/// # let client = hyper_util::client::legacy::Client::builder(
11897/// # hyper_util::rt::TokioExecutor::new()
11898/// # )
11899/// # .build(
11900/// # hyper_rustls::HttpsConnectorBuilder::new()
11901/// # .with_native_roots()
11902/// # .unwrap()
11903/// # .https_or_http()
11904/// # .enable_http1()
11905/// # .build()
11906/// # );
11907/// # let mut hub = CloudBuild::new(client, auth);
11908/// // As the method needs a request, you would usually fill it with the desired information
11909/// // into the respective structure. Some of the parts shown here might not be applicable !
11910/// // Values shown here are possibly random and not representative !
11911/// let mut req = CancelBuildRequest::default();
11912///
11913/// // You can configure optional parameters by calling the respective setters at will, and
11914/// // execute the final call using `doit()`.
11915/// // Values shown here are possibly random and not representative !
11916/// let result = hub.projects().locations_builds_cancel(req, "name")
11917/// .doit().await;
11918/// # }
11919/// ```
11920pub struct ProjectLocationBuildCancelCall<'a, C>
11921where
11922 C: 'a,
11923{
11924 hub: &'a CloudBuild<C>,
11925 _request: CancelBuildRequest,
11926 _name: String,
11927 _delegate: Option<&'a mut dyn common::Delegate>,
11928 _additional_params: HashMap<String, String>,
11929 _scopes: BTreeSet<String>,
11930}
11931
11932impl<'a, C> common::CallBuilder for ProjectLocationBuildCancelCall<'a, C> {}
11933
11934impl<'a, C> ProjectLocationBuildCancelCall<'a, C>
11935where
11936 C: common::Connector,
11937{
11938 /// Perform the operation you have build so far.
11939 pub async fn doit(mut self) -> common::Result<(common::Response, Build)> {
11940 use std::borrow::Cow;
11941 use std::io::{Read, Seek};
11942
11943 use common::{url::Params, ToParts};
11944 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11945
11946 let mut dd = common::DefaultDelegate;
11947 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11948 dlg.begin(common::MethodInfo {
11949 id: "cloudbuild.projects.locations.builds.cancel",
11950 http_method: hyper::Method::POST,
11951 });
11952
11953 for &field in ["alt", "name"].iter() {
11954 if self._additional_params.contains_key(field) {
11955 dlg.finished(false);
11956 return Err(common::Error::FieldClash(field));
11957 }
11958 }
11959
11960 let mut params = Params::with_capacity(4 + self._additional_params.len());
11961 params.push("name", self._name);
11962
11963 params.extend(self._additional_params.iter());
11964
11965 params.push("alt", "json");
11966 let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
11967 if self._scopes.is_empty() {
11968 self._scopes
11969 .insert(Scope::CloudPlatform.as_ref().to_string());
11970 }
11971
11972 #[allow(clippy::single_element_loop)]
11973 for &(find_this, param_name) in [("{+name}", "name")].iter() {
11974 url = params.uri_replacement(url, param_name, find_this, true);
11975 }
11976 {
11977 let to_remove = ["name"];
11978 params.remove_params(&to_remove);
11979 }
11980
11981 let url = params.parse_with_url(&url);
11982
11983 let mut json_mime_type = mime::APPLICATION_JSON;
11984 let mut request_value_reader = {
11985 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11986 common::remove_json_null_values(&mut value);
11987 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11988 serde_json::to_writer(&mut dst, &value).unwrap();
11989 dst
11990 };
11991 let request_size = request_value_reader
11992 .seek(std::io::SeekFrom::End(0))
11993 .unwrap();
11994 request_value_reader
11995 .seek(std::io::SeekFrom::Start(0))
11996 .unwrap();
11997
11998 loop {
11999 let token = match self
12000 .hub
12001 .auth
12002 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12003 .await
12004 {
12005 Ok(token) => token,
12006 Err(e) => match dlg.token(e) {
12007 Ok(token) => token,
12008 Err(e) => {
12009 dlg.finished(false);
12010 return Err(common::Error::MissingToken(e));
12011 }
12012 },
12013 };
12014 request_value_reader
12015 .seek(std::io::SeekFrom::Start(0))
12016 .unwrap();
12017 let mut req_result = {
12018 let client = &self.hub.client;
12019 dlg.pre_request();
12020 let mut req_builder = hyper::Request::builder()
12021 .method(hyper::Method::POST)
12022 .uri(url.as_str())
12023 .header(USER_AGENT, self.hub._user_agent.clone());
12024
12025 if let Some(token) = token.as_ref() {
12026 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12027 }
12028
12029 let request = req_builder
12030 .header(CONTENT_TYPE, json_mime_type.to_string())
12031 .header(CONTENT_LENGTH, request_size as u64)
12032 .body(common::to_body(
12033 request_value_reader.get_ref().clone().into(),
12034 ));
12035
12036 client.request(request.unwrap()).await
12037 };
12038
12039 match req_result {
12040 Err(err) => {
12041 if let common::Retry::After(d) = dlg.http_error(&err) {
12042 sleep(d).await;
12043 continue;
12044 }
12045 dlg.finished(false);
12046 return Err(common::Error::HttpError(err));
12047 }
12048 Ok(res) => {
12049 let (mut parts, body) = res.into_parts();
12050 let mut body = common::Body::new(body);
12051 if !parts.status.is_success() {
12052 let bytes = common::to_bytes(body).await.unwrap_or_default();
12053 let error = serde_json::from_str(&common::to_string(&bytes));
12054 let response = common::to_response(parts, bytes.into());
12055
12056 if let common::Retry::After(d) =
12057 dlg.http_failure(&response, error.as_ref().ok())
12058 {
12059 sleep(d).await;
12060 continue;
12061 }
12062
12063 dlg.finished(false);
12064
12065 return Err(match error {
12066 Ok(value) => common::Error::BadRequest(value),
12067 _ => common::Error::Failure(response),
12068 });
12069 }
12070 let response = {
12071 let bytes = common::to_bytes(body).await.unwrap_or_default();
12072 let encoded = common::to_string(&bytes);
12073 match serde_json::from_str(&encoded) {
12074 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12075 Err(error) => {
12076 dlg.response_json_decode_error(&encoded, &error);
12077 return Err(common::Error::JsonDecodeError(
12078 encoded.to_string(),
12079 error,
12080 ));
12081 }
12082 }
12083 };
12084
12085 dlg.finished(true);
12086 return Ok(response);
12087 }
12088 }
12089 }
12090 }
12091
12092 ///
12093 /// Sets the *request* property to the given value.
12094 ///
12095 /// Even though the property as already been set when instantiating this call,
12096 /// we provide this method for API completeness.
12097 pub fn request(
12098 mut self,
12099 new_value: CancelBuildRequest,
12100 ) -> ProjectLocationBuildCancelCall<'a, C> {
12101 self._request = new_value;
12102 self
12103 }
12104 /// The name of the `Build` to cancel. Format: `projects/{project}/locations/{location}/builds/{build}`
12105 ///
12106 /// Sets the *name* path property to the given value.
12107 ///
12108 /// Even though the property as already been set when instantiating this call,
12109 /// we provide this method for API completeness.
12110 pub fn name(mut self, new_value: &str) -> ProjectLocationBuildCancelCall<'a, C> {
12111 self._name = new_value.to_string();
12112 self
12113 }
12114 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12115 /// while executing the actual API request.
12116 ///
12117 /// ````text
12118 /// It should be used to handle progress information, and to implement a certain level of resilience.
12119 /// ````
12120 ///
12121 /// Sets the *delegate* property to the given value.
12122 pub fn delegate(
12123 mut self,
12124 new_value: &'a mut dyn common::Delegate,
12125 ) -> ProjectLocationBuildCancelCall<'a, C> {
12126 self._delegate = Some(new_value);
12127 self
12128 }
12129
12130 /// Set any additional parameter of the query string used in the request.
12131 /// It should be used to set parameters which are not yet available through their own
12132 /// setters.
12133 ///
12134 /// Please note that this method must not be used to set any of the known parameters
12135 /// which have their own setter method. If done anyway, the request will fail.
12136 ///
12137 /// # Additional Parameters
12138 ///
12139 /// * *$.xgafv* (query-string) - V1 error format.
12140 /// * *access_token* (query-string) - OAuth access token.
12141 /// * *alt* (query-string) - Data format for response.
12142 /// * *callback* (query-string) - JSONP
12143 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12144 /// * *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.
12145 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12146 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12147 /// * *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.
12148 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12149 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12150 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationBuildCancelCall<'a, C>
12151 where
12152 T: AsRef<str>,
12153 {
12154 self._additional_params
12155 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12156 self
12157 }
12158
12159 /// Identifies the authorization scope for the method you are building.
12160 ///
12161 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12162 /// [`Scope::CloudPlatform`].
12163 ///
12164 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12165 /// tokens for more than one scope.
12166 ///
12167 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12168 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12169 /// sufficient, a read-write scope will do as well.
12170 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationBuildCancelCall<'a, C>
12171 where
12172 St: AsRef<str>,
12173 {
12174 self._scopes.insert(String::from(scope.as_ref()));
12175 self
12176 }
12177 /// Identifies the authorization scope(s) for the method you are building.
12178 ///
12179 /// See [`Self::add_scope()`] for details.
12180 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationBuildCancelCall<'a, C>
12181 where
12182 I: IntoIterator<Item = St>,
12183 St: AsRef<str>,
12184 {
12185 self._scopes
12186 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12187 self
12188 }
12189
12190 /// Removes all scopes, and no default scope will be used either.
12191 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12192 /// for details).
12193 pub fn clear_scopes(mut self) -> ProjectLocationBuildCancelCall<'a, C> {
12194 self._scopes.clear();
12195 self
12196 }
12197}
12198
12199/// Starts a build with the specified configuration. This method returns a long-running `Operation`, which includes the build ID. Pass the build ID to `GetBuild` to determine the build status (such as `SUCCESS` or `FAILURE`).
12200///
12201/// A builder for the *locations.builds.create* method supported by a *project* resource.
12202/// It is not used directly, but through a [`ProjectMethods`] instance.
12203///
12204/// # Example
12205///
12206/// Instantiate a resource method builder
12207///
12208/// ```test_harness,no_run
12209/// # extern crate hyper;
12210/// # extern crate hyper_rustls;
12211/// # extern crate google_cloudbuild1 as cloudbuild1;
12212/// use cloudbuild1::api::Build;
12213/// # async fn dox() {
12214/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12215///
12216/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12217/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12218/// # secret,
12219/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12220/// # ).build().await.unwrap();
12221///
12222/// # let client = hyper_util::client::legacy::Client::builder(
12223/// # hyper_util::rt::TokioExecutor::new()
12224/// # )
12225/// # .build(
12226/// # hyper_rustls::HttpsConnectorBuilder::new()
12227/// # .with_native_roots()
12228/// # .unwrap()
12229/// # .https_or_http()
12230/// # .enable_http1()
12231/// # .build()
12232/// # );
12233/// # let mut hub = CloudBuild::new(client, auth);
12234/// // As the method needs a request, you would usually fill it with the desired information
12235/// // into the respective structure. Some of the parts shown here might not be applicable !
12236/// // Values shown here are possibly random and not representative !
12237/// let mut req = Build::default();
12238///
12239/// // You can configure optional parameters by calling the respective setters at will, and
12240/// // execute the final call using `doit()`.
12241/// // Values shown here are possibly random and not representative !
12242/// let result = hub.projects().locations_builds_create(req, "parent")
12243/// .project_id("diam")
12244/// .doit().await;
12245/// # }
12246/// ```
12247pub struct ProjectLocationBuildCreateCall<'a, C>
12248where
12249 C: 'a,
12250{
12251 hub: &'a CloudBuild<C>,
12252 _request: Build,
12253 _parent: String,
12254 _project_id: Option<String>,
12255 _delegate: Option<&'a mut dyn common::Delegate>,
12256 _additional_params: HashMap<String, String>,
12257 _scopes: BTreeSet<String>,
12258}
12259
12260impl<'a, C> common::CallBuilder for ProjectLocationBuildCreateCall<'a, C> {}
12261
12262impl<'a, C> ProjectLocationBuildCreateCall<'a, C>
12263where
12264 C: common::Connector,
12265{
12266 /// Perform the operation you have build so far.
12267 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
12268 use std::borrow::Cow;
12269 use std::io::{Read, Seek};
12270
12271 use common::{url::Params, ToParts};
12272 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12273
12274 let mut dd = common::DefaultDelegate;
12275 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12276 dlg.begin(common::MethodInfo {
12277 id: "cloudbuild.projects.locations.builds.create",
12278 http_method: hyper::Method::POST,
12279 });
12280
12281 for &field in ["alt", "parent", "projectId"].iter() {
12282 if self._additional_params.contains_key(field) {
12283 dlg.finished(false);
12284 return Err(common::Error::FieldClash(field));
12285 }
12286 }
12287
12288 let mut params = Params::with_capacity(5 + self._additional_params.len());
12289 params.push("parent", self._parent);
12290 if let Some(value) = self._project_id.as_ref() {
12291 params.push("projectId", value);
12292 }
12293
12294 params.extend(self._additional_params.iter());
12295
12296 params.push("alt", "json");
12297 let mut url = self.hub._base_url.clone() + "v1/{+parent}/builds";
12298 if self._scopes.is_empty() {
12299 self._scopes
12300 .insert(Scope::CloudPlatform.as_ref().to_string());
12301 }
12302
12303 #[allow(clippy::single_element_loop)]
12304 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
12305 url = params.uri_replacement(url, param_name, find_this, true);
12306 }
12307 {
12308 let to_remove = ["parent"];
12309 params.remove_params(&to_remove);
12310 }
12311
12312 let url = params.parse_with_url(&url);
12313
12314 let mut json_mime_type = mime::APPLICATION_JSON;
12315 let mut request_value_reader = {
12316 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12317 common::remove_json_null_values(&mut value);
12318 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12319 serde_json::to_writer(&mut dst, &value).unwrap();
12320 dst
12321 };
12322 let request_size = request_value_reader
12323 .seek(std::io::SeekFrom::End(0))
12324 .unwrap();
12325 request_value_reader
12326 .seek(std::io::SeekFrom::Start(0))
12327 .unwrap();
12328
12329 loop {
12330 let token = match self
12331 .hub
12332 .auth
12333 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12334 .await
12335 {
12336 Ok(token) => token,
12337 Err(e) => match dlg.token(e) {
12338 Ok(token) => token,
12339 Err(e) => {
12340 dlg.finished(false);
12341 return Err(common::Error::MissingToken(e));
12342 }
12343 },
12344 };
12345 request_value_reader
12346 .seek(std::io::SeekFrom::Start(0))
12347 .unwrap();
12348 let mut req_result = {
12349 let client = &self.hub.client;
12350 dlg.pre_request();
12351 let mut req_builder = hyper::Request::builder()
12352 .method(hyper::Method::POST)
12353 .uri(url.as_str())
12354 .header(USER_AGENT, self.hub._user_agent.clone());
12355
12356 if let Some(token) = token.as_ref() {
12357 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12358 }
12359
12360 let request = req_builder
12361 .header(CONTENT_TYPE, json_mime_type.to_string())
12362 .header(CONTENT_LENGTH, request_size as u64)
12363 .body(common::to_body(
12364 request_value_reader.get_ref().clone().into(),
12365 ));
12366
12367 client.request(request.unwrap()).await
12368 };
12369
12370 match req_result {
12371 Err(err) => {
12372 if let common::Retry::After(d) = dlg.http_error(&err) {
12373 sleep(d).await;
12374 continue;
12375 }
12376 dlg.finished(false);
12377 return Err(common::Error::HttpError(err));
12378 }
12379 Ok(res) => {
12380 let (mut parts, body) = res.into_parts();
12381 let mut body = common::Body::new(body);
12382 if !parts.status.is_success() {
12383 let bytes = common::to_bytes(body).await.unwrap_or_default();
12384 let error = serde_json::from_str(&common::to_string(&bytes));
12385 let response = common::to_response(parts, bytes.into());
12386
12387 if let common::Retry::After(d) =
12388 dlg.http_failure(&response, error.as_ref().ok())
12389 {
12390 sleep(d).await;
12391 continue;
12392 }
12393
12394 dlg.finished(false);
12395
12396 return Err(match error {
12397 Ok(value) => common::Error::BadRequest(value),
12398 _ => common::Error::Failure(response),
12399 });
12400 }
12401 let response = {
12402 let bytes = common::to_bytes(body).await.unwrap_or_default();
12403 let encoded = common::to_string(&bytes);
12404 match serde_json::from_str(&encoded) {
12405 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12406 Err(error) => {
12407 dlg.response_json_decode_error(&encoded, &error);
12408 return Err(common::Error::JsonDecodeError(
12409 encoded.to_string(),
12410 error,
12411 ));
12412 }
12413 }
12414 };
12415
12416 dlg.finished(true);
12417 return Ok(response);
12418 }
12419 }
12420 }
12421 }
12422
12423 ///
12424 /// Sets the *request* property to the given value.
12425 ///
12426 /// Even though the property as already been set when instantiating this call,
12427 /// we provide this method for API completeness.
12428 pub fn request(mut self, new_value: Build) -> ProjectLocationBuildCreateCall<'a, C> {
12429 self._request = new_value;
12430 self
12431 }
12432 /// The parent resource where this build will be created. Format: `projects/{project}/locations/{location}`
12433 ///
12434 /// Sets the *parent* path property to the given value.
12435 ///
12436 /// Even though the property as already been set when instantiating this call,
12437 /// we provide this method for API completeness.
12438 pub fn parent(mut self, new_value: &str) -> ProjectLocationBuildCreateCall<'a, C> {
12439 self._parent = new_value.to_string();
12440 self
12441 }
12442 /// Required. ID of the project.
12443 ///
12444 /// Sets the *project id* query property to the given value.
12445 pub fn project_id(mut self, new_value: &str) -> ProjectLocationBuildCreateCall<'a, C> {
12446 self._project_id = Some(new_value.to_string());
12447 self
12448 }
12449 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12450 /// while executing the actual API request.
12451 ///
12452 /// ````text
12453 /// It should be used to handle progress information, and to implement a certain level of resilience.
12454 /// ````
12455 ///
12456 /// Sets the *delegate* property to the given value.
12457 pub fn delegate(
12458 mut self,
12459 new_value: &'a mut dyn common::Delegate,
12460 ) -> ProjectLocationBuildCreateCall<'a, C> {
12461 self._delegate = Some(new_value);
12462 self
12463 }
12464
12465 /// Set any additional parameter of the query string used in the request.
12466 /// It should be used to set parameters which are not yet available through their own
12467 /// setters.
12468 ///
12469 /// Please note that this method must not be used to set any of the known parameters
12470 /// which have their own setter method. If done anyway, the request will fail.
12471 ///
12472 /// # Additional Parameters
12473 ///
12474 /// * *$.xgafv* (query-string) - V1 error format.
12475 /// * *access_token* (query-string) - OAuth access token.
12476 /// * *alt* (query-string) - Data format for response.
12477 /// * *callback* (query-string) - JSONP
12478 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12479 /// * *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.
12480 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12481 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12482 /// * *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.
12483 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12484 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12485 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationBuildCreateCall<'a, C>
12486 where
12487 T: AsRef<str>,
12488 {
12489 self._additional_params
12490 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12491 self
12492 }
12493
12494 /// Identifies the authorization scope for the method you are building.
12495 ///
12496 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12497 /// [`Scope::CloudPlatform`].
12498 ///
12499 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12500 /// tokens for more than one scope.
12501 ///
12502 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12503 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12504 /// sufficient, a read-write scope will do as well.
12505 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationBuildCreateCall<'a, C>
12506 where
12507 St: AsRef<str>,
12508 {
12509 self._scopes.insert(String::from(scope.as_ref()));
12510 self
12511 }
12512 /// Identifies the authorization scope(s) for the method you are building.
12513 ///
12514 /// See [`Self::add_scope()`] for details.
12515 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationBuildCreateCall<'a, C>
12516 where
12517 I: IntoIterator<Item = St>,
12518 St: AsRef<str>,
12519 {
12520 self._scopes
12521 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12522 self
12523 }
12524
12525 /// Removes all scopes, and no default scope will be used either.
12526 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12527 /// for details).
12528 pub fn clear_scopes(mut self) -> ProjectLocationBuildCreateCall<'a, C> {
12529 self._scopes.clear();
12530 self
12531 }
12532}
12533
12534/// Returns information about a previously requested build. The `Build` that is returned includes its status (such as `SUCCESS`, `FAILURE`, or `WORKING`), and timing information.
12535///
12536/// A builder for the *locations.builds.get* method supported by a *project* resource.
12537/// It is not used directly, but through a [`ProjectMethods`] instance.
12538///
12539/// # Example
12540///
12541/// Instantiate a resource method builder
12542///
12543/// ```test_harness,no_run
12544/// # extern crate hyper;
12545/// # extern crate hyper_rustls;
12546/// # extern crate google_cloudbuild1 as cloudbuild1;
12547/// # async fn dox() {
12548/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12549///
12550/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12551/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12552/// # secret,
12553/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12554/// # ).build().await.unwrap();
12555///
12556/// # let client = hyper_util::client::legacy::Client::builder(
12557/// # hyper_util::rt::TokioExecutor::new()
12558/// # )
12559/// # .build(
12560/// # hyper_rustls::HttpsConnectorBuilder::new()
12561/// # .with_native_roots()
12562/// # .unwrap()
12563/// # .https_or_http()
12564/// # .enable_http1()
12565/// # .build()
12566/// # );
12567/// # let mut hub = CloudBuild::new(client, auth);
12568/// // You can configure optional parameters by calling the respective setters at will, and
12569/// // execute the final call using `doit()`.
12570/// // Values shown here are possibly random and not representative !
12571/// let result = hub.projects().locations_builds_get("name")
12572/// .project_id("et")
12573/// .id("et")
12574/// .doit().await;
12575/// # }
12576/// ```
12577pub struct ProjectLocationBuildGetCall<'a, C>
12578where
12579 C: 'a,
12580{
12581 hub: &'a CloudBuild<C>,
12582 _name: String,
12583 _project_id: Option<String>,
12584 _id: Option<String>,
12585 _delegate: Option<&'a mut dyn common::Delegate>,
12586 _additional_params: HashMap<String, String>,
12587 _scopes: BTreeSet<String>,
12588}
12589
12590impl<'a, C> common::CallBuilder for ProjectLocationBuildGetCall<'a, C> {}
12591
12592impl<'a, C> ProjectLocationBuildGetCall<'a, C>
12593where
12594 C: common::Connector,
12595{
12596 /// Perform the operation you have build so far.
12597 pub async fn doit(mut self) -> common::Result<(common::Response, Build)> {
12598 use std::borrow::Cow;
12599 use std::io::{Read, Seek};
12600
12601 use common::{url::Params, ToParts};
12602 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12603
12604 let mut dd = common::DefaultDelegate;
12605 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12606 dlg.begin(common::MethodInfo {
12607 id: "cloudbuild.projects.locations.builds.get",
12608 http_method: hyper::Method::GET,
12609 });
12610
12611 for &field in ["alt", "name", "projectId", "id"].iter() {
12612 if self._additional_params.contains_key(field) {
12613 dlg.finished(false);
12614 return Err(common::Error::FieldClash(field));
12615 }
12616 }
12617
12618 let mut params = Params::with_capacity(5 + self._additional_params.len());
12619 params.push("name", self._name);
12620 if let Some(value) = self._project_id.as_ref() {
12621 params.push("projectId", value);
12622 }
12623 if let Some(value) = self._id.as_ref() {
12624 params.push("id", value);
12625 }
12626
12627 params.extend(self._additional_params.iter());
12628
12629 params.push("alt", "json");
12630 let mut url = self.hub._base_url.clone() + "v1/{+name}";
12631 if self._scopes.is_empty() {
12632 self._scopes
12633 .insert(Scope::CloudPlatform.as_ref().to_string());
12634 }
12635
12636 #[allow(clippy::single_element_loop)]
12637 for &(find_this, param_name) in [("{+name}", "name")].iter() {
12638 url = params.uri_replacement(url, param_name, find_this, true);
12639 }
12640 {
12641 let to_remove = ["name"];
12642 params.remove_params(&to_remove);
12643 }
12644
12645 let url = params.parse_with_url(&url);
12646
12647 loop {
12648 let token = match self
12649 .hub
12650 .auth
12651 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12652 .await
12653 {
12654 Ok(token) => token,
12655 Err(e) => match dlg.token(e) {
12656 Ok(token) => token,
12657 Err(e) => {
12658 dlg.finished(false);
12659 return Err(common::Error::MissingToken(e));
12660 }
12661 },
12662 };
12663 let mut req_result = {
12664 let client = &self.hub.client;
12665 dlg.pre_request();
12666 let mut req_builder = hyper::Request::builder()
12667 .method(hyper::Method::GET)
12668 .uri(url.as_str())
12669 .header(USER_AGENT, self.hub._user_agent.clone());
12670
12671 if let Some(token) = token.as_ref() {
12672 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12673 }
12674
12675 let request = req_builder
12676 .header(CONTENT_LENGTH, 0_u64)
12677 .body(common::to_body::<String>(None));
12678
12679 client.request(request.unwrap()).await
12680 };
12681
12682 match req_result {
12683 Err(err) => {
12684 if let common::Retry::After(d) = dlg.http_error(&err) {
12685 sleep(d).await;
12686 continue;
12687 }
12688 dlg.finished(false);
12689 return Err(common::Error::HttpError(err));
12690 }
12691 Ok(res) => {
12692 let (mut parts, body) = res.into_parts();
12693 let mut body = common::Body::new(body);
12694 if !parts.status.is_success() {
12695 let bytes = common::to_bytes(body).await.unwrap_or_default();
12696 let error = serde_json::from_str(&common::to_string(&bytes));
12697 let response = common::to_response(parts, bytes.into());
12698
12699 if let common::Retry::After(d) =
12700 dlg.http_failure(&response, error.as_ref().ok())
12701 {
12702 sleep(d).await;
12703 continue;
12704 }
12705
12706 dlg.finished(false);
12707
12708 return Err(match error {
12709 Ok(value) => common::Error::BadRequest(value),
12710 _ => common::Error::Failure(response),
12711 });
12712 }
12713 let response = {
12714 let bytes = common::to_bytes(body).await.unwrap_or_default();
12715 let encoded = common::to_string(&bytes);
12716 match serde_json::from_str(&encoded) {
12717 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12718 Err(error) => {
12719 dlg.response_json_decode_error(&encoded, &error);
12720 return Err(common::Error::JsonDecodeError(
12721 encoded.to_string(),
12722 error,
12723 ));
12724 }
12725 }
12726 };
12727
12728 dlg.finished(true);
12729 return Ok(response);
12730 }
12731 }
12732 }
12733 }
12734
12735 /// The name of the `Build` to retrieve. Format: `projects/{project}/locations/{location}/builds/{build}`
12736 ///
12737 /// Sets the *name* path property to the given value.
12738 ///
12739 /// Even though the property as already been set when instantiating this call,
12740 /// we provide this method for API completeness.
12741 pub fn name(mut self, new_value: &str) -> ProjectLocationBuildGetCall<'a, C> {
12742 self._name = new_value.to_string();
12743 self
12744 }
12745 /// Required. ID of the project.
12746 ///
12747 /// Sets the *project id* query property to the given value.
12748 pub fn project_id(mut self, new_value: &str) -> ProjectLocationBuildGetCall<'a, C> {
12749 self._project_id = Some(new_value.to_string());
12750 self
12751 }
12752 /// Required. ID of the build.
12753 ///
12754 /// Sets the *id* query property to the given value.
12755 pub fn id(mut self, new_value: &str) -> ProjectLocationBuildGetCall<'a, C> {
12756 self._id = Some(new_value.to_string());
12757 self
12758 }
12759 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12760 /// while executing the actual API request.
12761 ///
12762 /// ````text
12763 /// It should be used to handle progress information, and to implement a certain level of resilience.
12764 /// ````
12765 ///
12766 /// Sets the *delegate* property to the given value.
12767 pub fn delegate(
12768 mut self,
12769 new_value: &'a mut dyn common::Delegate,
12770 ) -> ProjectLocationBuildGetCall<'a, C> {
12771 self._delegate = Some(new_value);
12772 self
12773 }
12774
12775 /// Set any additional parameter of the query string used in the request.
12776 /// It should be used to set parameters which are not yet available through their own
12777 /// setters.
12778 ///
12779 /// Please note that this method must not be used to set any of the known parameters
12780 /// which have their own setter method. If done anyway, the request will fail.
12781 ///
12782 /// # Additional Parameters
12783 ///
12784 /// * *$.xgafv* (query-string) - V1 error format.
12785 /// * *access_token* (query-string) - OAuth access token.
12786 /// * *alt* (query-string) - Data format for response.
12787 /// * *callback* (query-string) - JSONP
12788 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12789 /// * *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.
12790 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12791 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12792 /// * *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.
12793 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12794 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12795 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationBuildGetCall<'a, C>
12796 where
12797 T: AsRef<str>,
12798 {
12799 self._additional_params
12800 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12801 self
12802 }
12803
12804 /// Identifies the authorization scope for the method you are building.
12805 ///
12806 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12807 /// [`Scope::CloudPlatform`].
12808 ///
12809 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12810 /// tokens for more than one scope.
12811 ///
12812 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12813 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12814 /// sufficient, a read-write scope will do as well.
12815 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationBuildGetCall<'a, C>
12816 where
12817 St: AsRef<str>,
12818 {
12819 self._scopes.insert(String::from(scope.as_ref()));
12820 self
12821 }
12822 /// Identifies the authorization scope(s) for the method you are building.
12823 ///
12824 /// See [`Self::add_scope()`] for details.
12825 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationBuildGetCall<'a, C>
12826 where
12827 I: IntoIterator<Item = St>,
12828 St: AsRef<str>,
12829 {
12830 self._scopes
12831 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12832 self
12833 }
12834
12835 /// Removes all scopes, and no default scope will be used either.
12836 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12837 /// for details).
12838 pub fn clear_scopes(mut self) -> ProjectLocationBuildGetCall<'a, C> {
12839 self._scopes.clear();
12840 self
12841 }
12842}
12843
12844/// Lists previously requested builds. Previously requested builds may still be in-progress, or may have finished successfully or unsuccessfully.
12845///
12846/// A builder for the *locations.builds.list* method supported by a *project* resource.
12847/// It is not used directly, but through a [`ProjectMethods`] instance.
12848///
12849/// # Example
12850///
12851/// Instantiate a resource method builder
12852///
12853/// ```test_harness,no_run
12854/// # extern crate hyper;
12855/// # extern crate hyper_rustls;
12856/// # extern crate google_cloudbuild1 as cloudbuild1;
12857/// # async fn dox() {
12858/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12859///
12860/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12861/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12862/// # secret,
12863/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12864/// # ).build().await.unwrap();
12865///
12866/// # let client = hyper_util::client::legacy::Client::builder(
12867/// # hyper_util::rt::TokioExecutor::new()
12868/// # )
12869/// # .build(
12870/// # hyper_rustls::HttpsConnectorBuilder::new()
12871/// # .with_native_roots()
12872/// # .unwrap()
12873/// # .https_or_http()
12874/// # .enable_http1()
12875/// # .build()
12876/// # );
12877/// # let mut hub = CloudBuild::new(client, auth);
12878/// // You can configure optional parameters by calling the respective setters at will, and
12879/// // execute the final call using `doit()`.
12880/// // Values shown here are possibly random and not representative !
12881/// let result = hub.projects().locations_builds_list("parent")
12882/// .project_id("Stet")
12883/// .page_token("dolor")
12884/// .page_size(-20)
12885/// .filter("vero")
12886/// .doit().await;
12887/// # }
12888/// ```
12889pub struct ProjectLocationBuildListCall<'a, C>
12890where
12891 C: 'a,
12892{
12893 hub: &'a CloudBuild<C>,
12894 _parent: String,
12895 _project_id: Option<String>,
12896 _page_token: Option<String>,
12897 _page_size: Option<i32>,
12898 _filter: Option<String>,
12899 _delegate: Option<&'a mut dyn common::Delegate>,
12900 _additional_params: HashMap<String, String>,
12901 _scopes: BTreeSet<String>,
12902}
12903
12904impl<'a, C> common::CallBuilder for ProjectLocationBuildListCall<'a, C> {}
12905
12906impl<'a, C> ProjectLocationBuildListCall<'a, C>
12907where
12908 C: common::Connector,
12909{
12910 /// Perform the operation you have build so far.
12911 pub async fn doit(mut self) -> common::Result<(common::Response, ListBuildsResponse)> {
12912 use std::borrow::Cow;
12913 use std::io::{Read, Seek};
12914
12915 use common::{url::Params, ToParts};
12916 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12917
12918 let mut dd = common::DefaultDelegate;
12919 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12920 dlg.begin(common::MethodInfo {
12921 id: "cloudbuild.projects.locations.builds.list",
12922 http_method: hyper::Method::GET,
12923 });
12924
12925 for &field in [
12926 "alt",
12927 "parent",
12928 "projectId",
12929 "pageToken",
12930 "pageSize",
12931 "filter",
12932 ]
12933 .iter()
12934 {
12935 if self._additional_params.contains_key(field) {
12936 dlg.finished(false);
12937 return Err(common::Error::FieldClash(field));
12938 }
12939 }
12940
12941 let mut params = Params::with_capacity(7 + self._additional_params.len());
12942 params.push("parent", self._parent);
12943 if let Some(value) = self._project_id.as_ref() {
12944 params.push("projectId", value);
12945 }
12946 if let Some(value) = self._page_token.as_ref() {
12947 params.push("pageToken", value);
12948 }
12949 if let Some(value) = self._page_size.as_ref() {
12950 params.push("pageSize", value.to_string());
12951 }
12952 if let Some(value) = self._filter.as_ref() {
12953 params.push("filter", value);
12954 }
12955
12956 params.extend(self._additional_params.iter());
12957
12958 params.push("alt", "json");
12959 let mut url = self.hub._base_url.clone() + "v1/{+parent}/builds";
12960 if self._scopes.is_empty() {
12961 self._scopes
12962 .insert(Scope::CloudPlatform.as_ref().to_string());
12963 }
12964
12965 #[allow(clippy::single_element_loop)]
12966 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
12967 url = params.uri_replacement(url, param_name, find_this, true);
12968 }
12969 {
12970 let to_remove = ["parent"];
12971 params.remove_params(&to_remove);
12972 }
12973
12974 let url = params.parse_with_url(&url);
12975
12976 loop {
12977 let token = match self
12978 .hub
12979 .auth
12980 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12981 .await
12982 {
12983 Ok(token) => token,
12984 Err(e) => match dlg.token(e) {
12985 Ok(token) => token,
12986 Err(e) => {
12987 dlg.finished(false);
12988 return Err(common::Error::MissingToken(e));
12989 }
12990 },
12991 };
12992 let mut req_result = {
12993 let client = &self.hub.client;
12994 dlg.pre_request();
12995 let mut req_builder = hyper::Request::builder()
12996 .method(hyper::Method::GET)
12997 .uri(url.as_str())
12998 .header(USER_AGENT, self.hub._user_agent.clone());
12999
13000 if let Some(token) = token.as_ref() {
13001 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13002 }
13003
13004 let request = req_builder
13005 .header(CONTENT_LENGTH, 0_u64)
13006 .body(common::to_body::<String>(None));
13007
13008 client.request(request.unwrap()).await
13009 };
13010
13011 match req_result {
13012 Err(err) => {
13013 if let common::Retry::After(d) = dlg.http_error(&err) {
13014 sleep(d).await;
13015 continue;
13016 }
13017 dlg.finished(false);
13018 return Err(common::Error::HttpError(err));
13019 }
13020 Ok(res) => {
13021 let (mut parts, body) = res.into_parts();
13022 let mut body = common::Body::new(body);
13023 if !parts.status.is_success() {
13024 let bytes = common::to_bytes(body).await.unwrap_or_default();
13025 let error = serde_json::from_str(&common::to_string(&bytes));
13026 let response = common::to_response(parts, bytes.into());
13027
13028 if let common::Retry::After(d) =
13029 dlg.http_failure(&response, error.as_ref().ok())
13030 {
13031 sleep(d).await;
13032 continue;
13033 }
13034
13035 dlg.finished(false);
13036
13037 return Err(match error {
13038 Ok(value) => common::Error::BadRequest(value),
13039 _ => common::Error::Failure(response),
13040 });
13041 }
13042 let response = {
13043 let bytes = common::to_bytes(body).await.unwrap_or_default();
13044 let encoded = common::to_string(&bytes);
13045 match serde_json::from_str(&encoded) {
13046 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13047 Err(error) => {
13048 dlg.response_json_decode_error(&encoded, &error);
13049 return Err(common::Error::JsonDecodeError(
13050 encoded.to_string(),
13051 error,
13052 ));
13053 }
13054 }
13055 };
13056
13057 dlg.finished(true);
13058 return Ok(response);
13059 }
13060 }
13061 }
13062 }
13063
13064 /// The parent of the collection of `Builds`. Format: `projects/{project}/locations/{location}`
13065 ///
13066 /// Sets the *parent* path property to the given value.
13067 ///
13068 /// Even though the property as already been set when instantiating this call,
13069 /// we provide this method for API completeness.
13070 pub fn parent(mut self, new_value: &str) -> ProjectLocationBuildListCall<'a, C> {
13071 self._parent = new_value.to_string();
13072 self
13073 }
13074 /// Required. ID of the project.
13075 ///
13076 /// Sets the *project id* query property to the given value.
13077 pub fn project_id(mut self, new_value: &str) -> ProjectLocationBuildListCall<'a, C> {
13078 self._project_id = Some(new_value.to_string());
13079 self
13080 }
13081 /// The page token for the next page of Builds. If unspecified, the first page of results is returned. If the token is rejected for any reason, INVALID_ARGUMENT will be thrown. In this case, the token should be discarded, and pagination should be restarted from the first page of results. See https://google.aip.dev/158 for more.
13082 ///
13083 /// Sets the *page token* query property to the given value.
13084 pub fn page_token(mut self, new_value: &str) -> ProjectLocationBuildListCall<'a, C> {
13085 self._page_token = Some(new_value.to_string());
13086 self
13087 }
13088 /// Number of results to return in the list.
13089 ///
13090 /// Sets the *page size* query property to the given value.
13091 pub fn page_size(mut self, new_value: i32) -> ProjectLocationBuildListCall<'a, C> {
13092 self._page_size = Some(new_value);
13093 self
13094 }
13095 /// The raw filter text to constrain the results.
13096 ///
13097 /// Sets the *filter* query property to the given value.
13098 pub fn filter(mut self, new_value: &str) -> ProjectLocationBuildListCall<'a, C> {
13099 self._filter = Some(new_value.to_string());
13100 self
13101 }
13102 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13103 /// while executing the actual API request.
13104 ///
13105 /// ````text
13106 /// It should be used to handle progress information, and to implement a certain level of resilience.
13107 /// ````
13108 ///
13109 /// Sets the *delegate* property to the given value.
13110 pub fn delegate(
13111 mut self,
13112 new_value: &'a mut dyn common::Delegate,
13113 ) -> ProjectLocationBuildListCall<'a, C> {
13114 self._delegate = Some(new_value);
13115 self
13116 }
13117
13118 /// Set any additional parameter of the query string used in the request.
13119 /// It should be used to set parameters which are not yet available through their own
13120 /// setters.
13121 ///
13122 /// Please note that this method must not be used to set any of the known parameters
13123 /// which have their own setter method. If done anyway, the request will fail.
13124 ///
13125 /// # Additional Parameters
13126 ///
13127 /// * *$.xgafv* (query-string) - V1 error format.
13128 /// * *access_token* (query-string) - OAuth access token.
13129 /// * *alt* (query-string) - Data format for response.
13130 /// * *callback* (query-string) - JSONP
13131 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13132 /// * *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.
13133 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13134 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13135 /// * *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.
13136 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13137 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13138 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationBuildListCall<'a, C>
13139 where
13140 T: AsRef<str>,
13141 {
13142 self._additional_params
13143 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13144 self
13145 }
13146
13147 /// Identifies the authorization scope for the method you are building.
13148 ///
13149 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13150 /// [`Scope::CloudPlatform`].
13151 ///
13152 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13153 /// tokens for more than one scope.
13154 ///
13155 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13156 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13157 /// sufficient, a read-write scope will do as well.
13158 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationBuildListCall<'a, C>
13159 where
13160 St: AsRef<str>,
13161 {
13162 self._scopes.insert(String::from(scope.as_ref()));
13163 self
13164 }
13165 /// Identifies the authorization scope(s) for the method you are building.
13166 ///
13167 /// See [`Self::add_scope()`] for details.
13168 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationBuildListCall<'a, C>
13169 where
13170 I: IntoIterator<Item = St>,
13171 St: AsRef<str>,
13172 {
13173 self._scopes
13174 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13175 self
13176 }
13177
13178 /// Removes all scopes, and no default scope will be used either.
13179 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13180 /// for details).
13181 pub fn clear_scopes(mut self) -> ProjectLocationBuildListCall<'a, C> {
13182 self._scopes.clear();
13183 self
13184 }
13185}
13186
13187/// Creates a new build based on the specified build. This method creates a new build using the original build request, which may or may not result in an identical build. For triggered builds: * Triggered builds resolve to a precise revision; therefore a retry of a triggered build will result in a build that uses the same revision. For non-triggered builds that specify `RepoSource`: * If the original build built from the tip of a branch, the retried build will build from the tip of that branch, which may not be the same revision as the original build. * If the original build specified a commit sha or revision ID, the retried build will use the identical source. For builds that specify `StorageSource`: * If the original build pulled source from Cloud Storage without specifying the generation of the object, the new build will use the current object, which may be different from the original build source. * If the original build pulled source from Cloud Storage and specified the generation of the object, the new build will attempt to use the same object, which may or may not be available depending on the bucket's lifecycle management settings.
13188///
13189/// A builder for the *locations.builds.retry* method supported by a *project* resource.
13190/// It is not used directly, but through a [`ProjectMethods`] instance.
13191///
13192/// # Example
13193///
13194/// Instantiate a resource method builder
13195///
13196/// ```test_harness,no_run
13197/// # extern crate hyper;
13198/// # extern crate hyper_rustls;
13199/// # extern crate google_cloudbuild1 as cloudbuild1;
13200/// use cloudbuild1::api::RetryBuildRequest;
13201/// # async fn dox() {
13202/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13203///
13204/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13205/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13206/// # secret,
13207/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13208/// # ).build().await.unwrap();
13209///
13210/// # let client = hyper_util::client::legacy::Client::builder(
13211/// # hyper_util::rt::TokioExecutor::new()
13212/// # )
13213/// # .build(
13214/// # hyper_rustls::HttpsConnectorBuilder::new()
13215/// # .with_native_roots()
13216/// # .unwrap()
13217/// # .https_or_http()
13218/// # .enable_http1()
13219/// # .build()
13220/// # );
13221/// # let mut hub = CloudBuild::new(client, auth);
13222/// // As the method needs a request, you would usually fill it with the desired information
13223/// // into the respective structure. Some of the parts shown here might not be applicable !
13224/// // Values shown here are possibly random and not representative !
13225/// let mut req = RetryBuildRequest::default();
13226///
13227/// // You can configure optional parameters by calling the respective setters at will, and
13228/// // execute the final call using `doit()`.
13229/// // Values shown here are possibly random and not representative !
13230/// let result = hub.projects().locations_builds_retry(req, "name")
13231/// .doit().await;
13232/// # }
13233/// ```
13234pub struct ProjectLocationBuildRetryCall<'a, C>
13235where
13236 C: 'a,
13237{
13238 hub: &'a CloudBuild<C>,
13239 _request: RetryBuildRequest,
13240 _name: String,
13241 _delegate: Option<&'a mut dyn common::Delegate>,
13242 _additional_params: HashMap<String, String>,
13243 _scopes: BTreeSet<String>,
13244}
13245
13246impl<'a, C> common::CallBuilder for ProjectLocationBuildRetryCall<'a, C> {}
13247
13248impl<'a, C> ProjectLocationBuildRetryCall<'a, C>
13249where
13250 C: common::Connector,
13251{
13252 /// Perform the operation you have build so far.
13253 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
13254 use std::borrow::Cow;
13255 use std::io::{Read, Seek};
13256
13257 use common::{url::Params, ToParts};
13258 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13259
13260 let mut dd = common::DefaultDelegate;
13261 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13262 dlg.begin(common::MethodInfo {
13263 id: "cloudbuild.projects.locations.builds.retry",
13264 http_method: hyper::Method::POST,
13265 });
13266
13267 for &field in ["alt", "name"].iter() {
13268 if self._additional_params.contains_key(field) {
13269 dlg.finished(false);
13270 return Err(common::Error::FieldClash(field));
13271 }
13272 }
13273
13274 let mut params = Params::with_capacity(4 + self._additional_params.len());
13275 params.push("name", self._name);
13276
13277 params.extend(self._additional_params.iter());
13278
13279 params.push("alt", "json");
13280 let mut url = self.hub._base_url.clone() + "v1/{+name}:retry";
13281 if self._scopes.is_empty() {
13282 self._scopes
13283 .insert(Scope::CloudPlatform.as_ref().to_string());
13284 }
13285
13286 #[allow(clippy::single_element_loop)]
13287 for &(find_this, param_name) in [("{+name}", "name")].iter() {
13288 url = params.uri_replacement(url, param_name, find_this, true);
13289 }
13290 {
13291 let to_remove = ["name"];
13292 params.remove_params(&to_remove);
13293 }
13294
13295 let url = params.parse_with_url(&url);
13296
13297 let mut json_mime_type = mime::APPLICATION_JSON;
13298 let mut request_value_reader = {
13299 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13300 common::remove_json_null_values(&mut value);
13301 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13302 serde_json::to_writer(&mut dst, &value).unwrap();
13303 dst
13304 };
13305 let request_size = request_value_reader
13306 .seek(std::io::SeekFrom::End(0))
13307 .unwrap();
13308 request_value_reader
13309 .seek(std::io::SeekFrom::Start(0))
13310 .unwrap();
13311
13312 loop {
13313 let token = match self
13314 .hub
13315 .auth
13316 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13317 .await
13318 {
13319 Ok(token) => token,
13320 Err(e) => match dlg.token(e) {
13321 Ok(token) => token,
13322 Err(e) => {
13323 dlg.finished(false);
13324 return Err(common::Error::MissingToken(e));
13325 }
13326 },
13327 };
13328 request_value_reader
13329 .seek(std::io::SeekFrom::Start(0))
13330 .unwrap();
13331 let mut req_result = {
13332 let client = &self.hub.client;
13333 dlg.pre_request();
13334 let mut req_builder = hyper::Request::builder()
13335 .method(hyper::Method::POST)
13336 .uri(url.as_str())
13337 .header(USER_AGENT, self.hub._user_agent.clone());
13338
13339 if let Some(token) = token.as_ref() {
13340 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13341 }
13342
13343 let request = req_builder
13344 .header(CONTENT_TYPE, json_mime_type.to_string())
13345 .header(CONTENT_LENGTH, request_size as u64)
13346 .body(common::to_body(
13347 request_value_reader.get_ref().clone().into(),
13348 ));
13349
13350 client.request(request.unwrap()).await
13351 };
13352
13353 match req_result {
13354 Err(err) => {
13355 if let common::Retry::After(d) = dlg.http_error(&err) {
13356 sleep(d).await;
13357 continue;
13358 }
13359 dlg.finished(false);
13360 return Err(common::Error::HttpError(err));
13361 }
13362 Ok(res) => {
13363 let (mut parts, body) = res.into_parts();
13364 let mut body = common::Body::new(body);
13365 if !parts.status.is_success() {
13366 let bytes = common::to_bytes(body).await.unwrap_or_default();
13367 let error = serde_json::from_str(&common::to_string(&bytes));
13368 let response = common::to_response(parts, bytes.into());
13369
13370 if let common::Retry::After(d) =
13371 dlg.http_failure(&response, error.as_ref().ok())
13372 {
13373 sleep(d).await;
13374 continue;
13375 }
13376
13377 dlg.finished(false);
13378
13379 return Err(match error {
13380 Ok(value) => common::Error::BadRequest(value),
13381 _ => common::Error::Failure(response),
13382 });
13383 }
13384 let response = {
13385 let bytes = common::to_bytes(body).await.unwrap_or_default();
13386 let encoded = common::to_string(&bytes);
13387 match serde_json::from_str(&encoded) {
13388 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13389 Err(error) => {
13390 dlg.response_json_decode_error(&encoded, &error);
13391 return Err(common::Error::JsonDecodeError(
13392 encoded.to_string(),
13393 error,
13394 ));
13395 }
13396 }
13397 };
13398
13399 dlg.finished(true);
13400 return Ok(response);
13401 }
13402 }
13403 }
13404 }
13405
13406 ///
13407 /// Sets the *request* property to the given value.
13408 ///
13409 /// Even though the property as already been set when instantiating this call,
13410 /// we provide this method for API completeness.
13411 pub fn request(mut self, new_value: RetryBuildRequest) -> ProjectLocationBuildRetryCall<'a, C> {
13412 self._request = new_value;
13413 self
13414 }
13415 /// The name of the `Build` to retry. Format: `projects/{project}/locations/{location}/builds/{build}`
13416 ///
13417 /// Sets the *name* path property to the given value.
13418 ///
13419 /// Even though the property as already been set when instantiating this call,
13420 /// we provide this method for API completeness.
13421 pub fn name(mut self, new_value: &str) -> ProjectLocationBuildRetryCall<'a, C> {
13422 self._name = new_value.to_string();
13423 self
13424 }
13425 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13426 /// while executing the actual API request.
13427 ///
13428 /// ````text
13429 /// It should be used to handle progress information, and to implement a certain level of resilience.
13430 /// ````
13431 ///
13432 /// Sets the *delegate* property to the given value.
13433 pub fn delegate(
13434 mut self,
13435 new_value: &'a mut dyn common::Delegate,
13436 ) -> ProjectLocationBuildRetryCall<'a, C> {
13437 self._delegate = Some(new_value);
13438 self
13439 }
13440
13441 /// Set any additional parameter of the query string used in the request.
13442 /// It should be used to set parameters which are not yet available through their own
13443 /// setters.
13444 ///
13445 /// Please note that this method must not be used to set any of the known parameters
13446 /// which have their own setter method. If done anyway, the request will fail.
13447 ///
13448 /// # Additional Parameters
13449 ///
13450 /// * *$.xgafv* (query-string) - V1 error format.
13451 /// * *access_token* (query-string) - OAuth access token.
13452 /// * *alt* (query-string) - Data format for response.
13453 /// * *callback* (query-string) - JSONP
13454 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13455 /// * *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.
13456 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13457 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13458 /// * *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.
13459 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13460 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13461 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationBuildRetryCall<'a, C>
13462 where
13463 T: AsRef<str>,
13464 {
13465 self._additional_params
13466 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13467 self
13468 }
13469
13470 /// Identifies the authorization scope for the method you are building.
13471 ///
13472 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13473 /// [`Scope::CloudPlatform`].
13474 ///
13475 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13476 /// tokens for more than one scope.
13477 ///
13478 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13479 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13480 /// sufficient, a read-write scope will do as well.
13481 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationBuildRetryCall<'a, C>
13482 where
13483 St: AsRef<str>,
13484 {
13485 self._scopes.insert(String::from(scope.as_ref()));
13486 self
13487 }
13488 /// Identifies the authorization scope(s) for the method you are building.
13489 ///
13490 /// See [`Self::add_scope()`] for details.
13491 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationBuildRetryCall<'a, C>
13492 where
13493 I: IntoIterator<Item = St>,
13494 St: AsRef<str>,
13495 {
13496 self._scopes
13497 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13498 self
13499 }
13500
13501 /// Removes all scopes, and no default scope will be used either.
13502 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13503 /// for details).
13504 pub fn clear_scopes(mut self) -> ProjectLocationBuildRetryCall<'a, C> {
13505 self._scopes.clear();
13506 self
13507 }
13508}
13509
13510/// Batch connecting GitLab repositories to Cloud Build. This API is experimental.
13511///
13512/// A builder for the *locations.gitLabConfigs.connectedRepositories.batchCreate* method supported by a *project* resource.
13513/// It is not used directly, but through a [`ProjectMethods`] instance.
13514///
13515/// # Example
13516///
13517/// Instantiate a resource method builder
13518///
13519/// ```test_harness,no_run
13520/// # extern crate hyper;
13521/// # extern crate hyper_rustls;
13522/// # extern crate google_cloudbuild1 as cloudbuild1;
13523/// use cloudbuild1::api::BatchCreateGitLabConnectedRepositoriesRequest;
13524/// # async fn dox() {
13525/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13526///
13527/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13528/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13529/// # secret,
13530/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13531/// # ).build().await.unwrap();
13532///
13533/// # let client = hyper_util::client::legacy::Client::builder(
13534/// # hyper_util::rt::TokioExecutor::new()
13535/// # )
13536/// # .build(
13537/// # hyper_rustls::HttpsConnectorBuilder::new()
13538/// # .with_native_roots()
13539/// # .unwrap()
13540/// # .https_or_http()
13541/// # .enable_http1()
13542/// # .build()
13543/// # );
13544/// # let mut hub = CloudBuild::new(client, auth);
13545/// // As the method needs a request, you would usually fill it with the desired information
13546/// // into the respective structure. Some of the parts shown here might not be applicable !
13547/// // Values shown here are possibly random and not representative !
13548/// let mut req = BatchCreateGitLabConnectedRepositoriesRequest::default();
13549///
13550/// // You can configure optional parameters by calling the respective setters at will, and
13551/// // execute the final call using `doit()`.
13552/// // Values shown here are possibly random and not representative !
13553/// let result = hub.projects().locations_git_lab_configs_connected_repositories_batch_create(req, "parent")
13554/// .doit().await;
13555/// # }
13556/// ```
13557pub struct ProjectLocationGitLabConfigConnectedRepositoryBatchCreateCall<'a, C>
13558where
13559 C: 'a,
13560{
13561 hub: &'a CloudBuild<C>,
13562 _request: BatchCreateGitLabConnectedRepositoriesRequest,
13563 _parent: String,
13564 _delegate: Option<&'a mut dyn common::Delegate>,
13565 _additional_params: HashMap<String, String>,
13566 _scopes: BTreeSet<String>,
13567}
13568
13569impl<'a, C> common::CallBuilder
13570 for ProjectLocationGitLabConfigConnectedRepositoryBatchCreateCall<'a, C>
13571{
13572}
13573
13574impl<'a, C> ProjectLocationGitLabConfigConnectedRepositoryBatchCreateCall<'a, C>
13575where
13576 C: common::Connector,
13577{
13578 /// Perform the operation you have build so far.
13579 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
13580 use std::borrow::Cow;
13581 use std::io::{Read, Seek};
13582
13583 use common::{url::Params, ToParts};
13584 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13585
13586 let mut dd = common::DefaultDelegate;
13587 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13588 dlg.begin(common::MethodInfo {
13589 id: "cloudbuild.projects.locations.gitLabConfigs.connectedRepositories.batchCreate",
13590 http_method: hyper::Method::POST,
13591 });
13592
13593 for &field in ["alt", "parent"].iter() {
13594 if self._additional_params.contains_key(field) {
13595 dlg.finished(false);
13596 return Err(common::Error::FieldClash(field));
13597 }
13598 }
13599
13600 let mut params = Params::with_capacity(4 + self._additional_params.len());
13601 params.push("parent", self._parent);
13602
13603 params.extend(self._additional_params.iter());
13604
13605 params.push("alt", "json");
13606 let mut url = self.hub._base_url.clone() + "v1/{+parent}/connectedRepositories:batchCreate";
13607 if self._scopes.is_empty() {
13608 self._scopes
13609 .insert(Scope::CloudPlatform.as_ref().to_string());
13610 }
13611
13612 #[allow(clippy::single_element_loop)]
13613 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
13614 url = params.uri_replacement(url, param_name, find_this, true);
13615 }
13616 {
13617 let to_remove = ["parent"];
13618 params.remove_params(&to_remove);
13619 }
13620
13621 let url = params.parse_with_url(&url);
13622
13623 let mut json_mime_type = mime::APPLICATION_JSON;
13624 let mut request_value_reader = {
13625 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13626 common::remove_json_null_values(&mut value);
13627 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13628 serde_json::to_writer(&mut dst, &value).unwrap();
13629 dst
13630 };
13631 let request_size = request_value_reader
13632 .seek(std::io::SeekFrom::End(0))
13633 .unwrap();
13634 request_value_reader
13635 .seek(std::io::SeekFrom::Start(0))
13636 .unwrap();
13637
13638 loop {
13639 let token = match self
13640 .hub
13641 .auth
13642 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13643 .await
13644 {
13645 Ok(token) => token,
13646 Err(e) => match dlg.token(e) {
13647 Ok(token) => token,
13648 Err(e) => {
13649 dlg.finished(false);
13650 return Err(common::Error::MissingToken(e));
13651 }
13652 },
13653 };
13654 request_value_reader
13655 .seek(std::io::SeekFrom::Start(0))
13656 .unwrap();
13657 let mut req_result = {
13658 let client = &self.hub.client;
13659 dlg.pre_request();
13660 let mut req_builder = hyper::Request::builder()
13661 .method(hyper::Method::POST)
13662 .uri(url.as_str())
13663 .header(USER_AGENT, self.hub._user_agent.clone());
13664
13665 if let Some(token) = token.as_ref() {
13666 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13667 }
13668
13669 let request = req_builder
13670 .header(CONTENT_TYPE, json_mime_type.to_string())
13671 .header(CONTENT_LENGTH, request_size as u64)
13672 .body(common::to_body(
13673 request_value_reader.get_ref().clone().into(),
13674 ));
13675
13676 client.request(request.unwrap()).await
13677 };
13678
13679 match req_result {
13680 Err(err) => {
13681 if let common::Retry::After(d) = dlg.http_error(&err) {
13682 sleep(d).await;
13683 continue;
13684 }
13685 dlg.finished(false);
13686 return Err(common::Error::HttpError(err));
13687 }
13688 Ok(res) => {
13689 let (mut parts, body) = res.into_parts();
13690 let mut body = common::Body::new(body);
13691 if !parts.status.is_success() {
13692 let bytes = common::to_bytes(body).await.unwrap_or_default();
13693 let error = serde_json::from_str(&common::to_string(&bytes));
13694 let response = common::to_response(parts, bytes.into());
13695
13696 if let common::Retry::After(d) =
13697 dlg.http_failure(&response, error.as_ref().ok())
13698 {
13699 sleep(d).await;
13700 continue;
13701 }
13702
13703 dlg.finished(false);
13704
13705 return Err(match error {
13706 Ok(value) => common::Error::BadRequest(value),
13707 _ => common::Error::Failure(response),
13708 });
13709 }
13710 let response = {
13711 let bytes = common::to_bytes(body).await.unwrap_or_default();
13712 let encoded = common::to_string(&bytes);
13713 match serde_json::from_str(&encoded) {
13714 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13715 Err(error) => {
13716 dlg.response_json_decode_error(&encoded, &error);
13717 return Err(common::Error::JsonDecodeError(
13718 encoded.to_string(),
13719 error,
13720 ));
13721 }
13722 }
13723 };
13724
13725 dlg.finished(true);
13726 return Ok(response);
13727 }
13728 }
13729 }
13730 }
13731
13732 ///
13733 /// Sets the *request* property to the given value.
13734 ///
13735 /// Even though the property as already been set when instantiating this call,
13736 /// we provide this method for API completeness.
13737 pub fn request(
13738 mut self,
13739 new_value: BatchCreateGitLabConnectedRepositoriesRequest,
13740 ) -> ProjectLocationGitLabConfigConnectedRepositoryBatchCreateCall<'a, C> {
13741 self._request = new_value;
13742 self
13743 }
13744 /// The name of the `GitLabConfig` that adds connected repositories. Format: `projects/{project}/locations/{location}/gitLabConfigs/{config}`
13745 ///
13746 /// Sets the *parent* path property to the given value.
13747 ///
13748 /// Even though the property as already been set when instantiating this call,
13749 /// we provide this method for API completeness.
13750 pub fn parent(
13751 mut self,
13752 new_value: &str,
13753 ) -> ProjectLocationGitLabConfigConnectedRepositoryBatchCreateCall<'a, C> {
13754 self._parent = new_value.to_string();
13755 self
13756 }
13757 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13758 /// while executing the actual API request.
13759 ///
13760 /// ````text
13761 /// It should be used to handle progress information, and to implement a certain level of resilience.
13762 /// ````
13763 ///
13764 /// Sets the *delegate* property to the given value.
13765 pub fn delegate(
13766 mut self,
13767 new_value: &'a mut dyn common::Delegate,
13768 ) -> ProjectLocationGitLabConfigConnectedRepositoryBatchCreateCall<'a, C> {
13769 self._delegate = Some(new_value);
13770 self
13771 }
13772
13773 /// Set any additional parameter of the query string used in the request.
13774 /// It should be used to set parameters which are not yet available through their own
13775 /// setters.
13776 ///
13777 /// Please note that this method must not be used to set any of the known parameters
13778 /// which have their own setter method. If done anyway, the request will fail.
13779 ///
13780 /// # Additional Parameters
13781 ///
13782 /// * *$.xgafv* (query-string) - V1 error format.
13783 /// * *access_token* (query-string) - OAuth access token.
13784 /// * *alt* (query-string) - Data format for response.
13785 /// * *callback* (query-string) - JSONP
13786 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13787 /// * *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.
13788 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13789 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13790 /// * *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.
13791 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13792 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13793 pub fn param<T>(
13794 mut self,
13795 name: T,
13796 value: T,
13797 ) -> ProjectLocationGitLabConfigConnectedRepositoryBatchCreateCall<'a, C>
13798 where
13799 T: AsRef<str>,
13800 {
13801 self._additional_params
13802 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13803 self
13804 }
13805
13806 /// Identifies the authorization scope for the method you are building.
13807 ///
13808 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13809 /// [`Scope::CloudPlatform`].
13810 ///
13811 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13812 /// tokens for more than one scope.
13813 ///
13814 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13815 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13816 /// sufficient, a read-write scope will do as well.
13817 pub fn add_scope<St>(
13818 mut self,
13819 scope: St,
13820 ) -> ProjectLocationGitLabConfigConnectedRepositoryBatchCreateCall<'a, C>
13821 where
13822 St: AsRef<str>,
13823 {
13824 self._scopes.insert(String::from(scope.as_ref()));
13825 self
13826 }
13827 /// Identifies the authorization scope(s) for the method you are building.
13828 ///
13829 /// See [`Self::add_scope()`] for details.
13830 pub fn add_scopes<I, St>(
13831 mut self,
13832 scopes: I,
13833 ) -> ProjectLocationGitLabConfigConnectedRepositoryBatchCreateCall<'a, C>
13834 where
13835 I: IntoIterator<Item = St>,
13836 St: AsRef<str>,
13837 {
13838 self._scopes
13839 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13840 self
13841 }
13842
13843 /// Removes all scopes, and no default scope will be used either.
13844 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13845 /// for details).
13846 pub fn clear_scopes(
13847 mut self,
13848 ) -> ProjectLocationGitLabConfigConnectedRepositoryBatchCreateCall<'a, C> {
13849 self._scopes.clear();
13850 self
13851 }
13852}
13853
13854/// List all repositories for a given `GitLabConfig`. This API is experimental
13855///
13856/// A builder for the *locations.gitLabConfigs.repos.list* method supported by a *project* resource.
13857/// It is not used directly, but through a [`ProjectMethods`] instance.
13858///
13859/// # Example
13860///
13861/// Instantiate a resource method builder
13862///
13863/// ```test_harness,no_run
13864/// # extern crate hyper;
13865/// # extern crate hyper_rustls;
13866/// # extern crate google_cloudbuild1 as cloudbuild1;
13867/// # async fn dox() {
13868/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13869///
13870/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13871/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
13872/// # secret,
13873/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13874/// # ).build().await.unwrap();
13875///
13876/// # let client = hyper_util::client::legacy::Client::builder(
13877/// # hyper_util::rt::TokioExecutor::new()
13878/// # )
13879/// # .build(
13880/// # hyper_rustls::HttpsConnectorBuilder::new()
13881/// # .with_native_roots()
13882/// # .unwrap()
13883/// # .https_or_http()
13884/// # .enable_http1()
13885/// # .build()
13886/// # );
13887/// # let mut hub = CloudBuild::new(client, auth);
13888/// // You can configure optional parameters by calling the respective setters at will, and
13889/// // execute the final call using `doit()`.
13890/// // Values shown here are possibly random and not representative !
13891/// let result = hub.projects().locations_git_lab_configs_repos_list("parent")
13892/// .page_token("vero")
13893/// .page_size(-44)
13894/// .doit().await;
13895/// # }
13896/// ```
13897pub struct ProjectLocationGitLabConfigRepoListCall<'a, C>
13898where
13899 C: 'a,
13900{
13901 hub: &'a CloudBuild<C>,
13902 _parent: String,
13903 _page_token: Option<String>,
13904 _page_size: Option<i32>,
13905 _delegate: Option<&'a mut dyn common::Delegate>,
13906 _additional_params: HashMap<String, String>,
13907 _scopes: BTreeSet<String>,
13908}
13909
13910impl<'a, C> common::CallBuilder for ProjectLocationGitLabConfigRepoListCall<'a, C> {}
13911
13912impl<'a, C> ProjectLocationGitLabConfigRepoListCall<'a, C>
13913where
13914 C: common::Connector,
13915{
13916 /// Perform the operation you have build so far.
13917 pub async fn doit(
13918 mut self,
13919 ) -> common::Result<(common::Response, ListGitLabRepositoriesResponse)> {
13920 use std::borrow::Cow;
13921 use std::io::{Read, Seek};
13922
13923 use common::{url::Params, ToParts};
13924 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13925
13926 let mut dd = common::DefaultDelegate;
13927 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13928 dlg.begin(common::MethodInfo {
13929 id: "cloudbuild.projects.locations.gitLabConfigs.repos.list",
13930 http_method: hyper::Method::GET,
13931 });
13932
13933 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
13934 if self._additional_params.contains_key(field) {
13935 dlg.finished(false);
13936 return Err(common::Error::FieldClash(field));
13937 }
13938 }
13939
13940 let mut params = Params::with_capacity(5 + self._additional_params.len());
13941 params.push("parent", self._parent);
13942 if let Some(value) = self._page_token.as_ref() {
13943 params.push("pageToken", value);
13944 }
13945 if let Some(value) = self._page_size.as_ref() {
13946 params.push("pageSize", value.to_string());
13947 }
13948
13949 params.extend(self._additional_params.iter());
13950
13951 params.push("alt", "json");
13952 let mut url = self.hub._base_url.clone() + "v1/{+parent}/repos";
13953 if self._scopes.is_empty() {
13954 self._scopes
13955 .insert(Scope::CloudPlatform.as_ref().to_string());
13956 }
13957
13958 #[allow(clippy::single_element_loop)]
13959 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
13960 url = params.uri_replacement(url, param_name, find_this, true);
13961 }
13962 {
13963 let to_remove = ["parent"];
13964 params.remove_params(&to_remove);
13965 }
13966
13967 let url = params.parse_with_url(&url);
13968
13969 loop {
13970 let token = match self
13971 .hub
13972 .auth
13973 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13974 .await
13975 {
13976 Ok(token) => token,
13977 Err(e) => match dlg.token(e) {
13978 Ok(token) => token,
13979 Err(e) => {
13980 dlg.finished(false);
13981 return Err(common::Error::MissingToken(e));
13982 }
13983 },
13984 };
13985 let mut req_result = {
13986 let client = &self.hub.client;
13987 dlg.pre_request();
13988 let mut req_builder = hyper::Request::builder()
13989 .method(hyper::Method::GET)
13990 .uri(url.as_str())
13991 .header(USER_AGENT, self.hub._user_agent.clone());
13992
13993 if let Some(token) = token.as_ref() {
13994 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13995 }
13996
13997 let request = req_builder
13998 .header(CONTENT_LENGTH, 0_u64)
13999 .body(common::to_body::<String>(None));
14000
14001 client.request(request.unwrap()).await
14002 };
14003
14004 match req_result {
14005 Err(err) => {
14006 if let common::Retry::After(d) = dlg.http_error(&err) {
14007 sleep(d).await;
14008 continue;
14009 }
14010 dlg.finished(false);
14011 return Err(common::Error::HttpError(err));
14012 }
14013 Ok(res) => {
14014 let (mut parts, body) = res.into_parts();
14015 let mut body = common::Body::new(body);
14016 if !parts.status.is_success() {
14017 let bytes = common::to_bytes(body).await.unwrap_or_default();
14018 let error = serde_json::from_str(&common::to_string(&bytes));
14019 let response = common::to_response(parts, bytes.into());
14020
14021 if let common::Retry::After(d) =
14022 dlg.http_failure(&response, error.as_ref().ok())
14023 {
14024 sleep(d).await;
14025 continue;
14026 }
14027
14028 dlg.finished(false);
14029
14030 return Err(match error {
14031 Ok(value) => common::Error::BadRequest(value),
14032 _ => common::Error::Failure(response),
14033 });
14034 }
14035 let response = {
14036 let bytes = common::to_bytes(body).await.unwrap_or_default();
14037 let encoded = common::to_string(&bytes);
14038 match serde_json::from_str(&encoded) {
14039 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14040 Err(error) => {
14041 dlg.response_json_decode_error(&encoded, &error);
14042 return Err(common::Error::JsonDecodeError(
14043 encoded.to_string(),
14044 error,
14045 ));
14046 }
14047 }
14048 };
14049
14050 dlg.finished(true);
14051 return Ok(response);
14052 }
14053 }
14054 }
14055 }
14056
14057 /// Required. Name of the parent resource.
14058 ///
14059 /// Sets the *parent* path property to the given value.
14060 ///
14061 /// Even though the property as already been set when instantiating this call,
14062 /// we provide this method for API completeness.
14063 pub fn parent(mut self, new_value: &str) -> ProjectLocationGitLabConfigRepoListCall<'a, C> {
14064 self._parent = new_value.to_string();
14065 self
14066 }
14067 /// A page token, received from a previous ListGitLabRepositoriesRequest` call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to `ListGitLabRepositoriesRequest` must match the call that provided the page token.
14068 ///
14069 /// Sets the *page token* query property to the given value.
14070 pub fn page_token(mut self, new_value: &str) -> ProjectLocationGitLabConfigRepoListCall<'a, C> {
14071 self._page_token = Some(new_value.to_string());
14072 self
14073 }
14074 /// The maximum number of repositories to return. The service may return fewer than this value.
14075 ///
14076 /// Sets the *page size* query property to the given value.
14077 pub fn page_size(mut self, new_value: i32) -> ProjectLocationGitLabConfigRepoListCall<'a, C> {
14078 self._page_size = Some(new_value);
14079 self
14080 }
14081 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14082 /// while executing the actual API request.
14083 ///
14084 /// ````text
14085 /// It should be used to handle progress information, and to implement a certain level of resilience.
14086 /// ````
14087 ///
14088 /// Sets the *delegate* property to the given value.
14089 pub fn delegate(
14090 mut self,
14091 new_value: &'a mut dyn common::Delegate,
14092 ) -> ProjectLocationGitLabConfigRepoListCall<'a, C> {
14093 self._delegate = Some(new_value);
14094 self
14095 }
14096
14097 /// Set any additional parameter of the query string used in the request.
14098 /// It should be used to set parameters which are not yet available through their own
14099 /// setters.
14100 ///
14101 /// Please note that this method must not be used to set any of the known parameters
14102 /// which have their own setter method. If done anyway, the request will fail.
14103 ///
14104 /// # Additional Parameters
14105 ///
14106 /// * *$.xgafv* (query-string) - V1 error format.
14107 /// * *access_token* (query-string) - OAuth access token.
14108 /// * *alt* (query-string) - Data format for response.
14109 /// * *callback* (query-string) - JSONP
14110 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14111 /// * *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.
14112 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14113 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14114 /// * *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.
14115 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14116 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14117 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGitLabConfigRepoListCall<'a, C>
14118 where
14119 T: AsRef<str>,
14120 {
14121 self._additional_params
14122 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14123 self
14124 }
14125
14126 /// Identifies the authorization scope for the method you are building.
14127 ///
14128 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14129 /// [`Scope::CloudPlatform`].
14130 ///
14131 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14132 /// tokens for more than one scope.
14133 ///
14134 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14135 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14136 /// sufficient, a read-write scope will do as well.
14137 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGitLabConfigRepoListCall<'a, C>
14138 where
14139 St: AsRef<str>,
14140 {
14141 self._scopes.insert(String::from(scope.as_ref()));
14142 self
14143 }
14144 /// Identifies the authorization scope(s) for the method you are building.
14145 ///
14146 /// See [`Self::add_scope()`] for details.
14147 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGitLabConfigRepoListCall<'a, C>
14148 where
14149 I: IntoIterator<Item = St>,
14150 St: AsRef<str>,
14151 {
14152 self._scopes
14153 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14154 self
14155 }
14156
14157 /// Removes all scopes, and no default scope will be used either.
14158 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14159 /// for details).
14160 pub fn clear_scopes(mut self) -> ProjectLocationGitLabConfigRepoListCall<'a, C> {
14161 self._scopes.clear();
14162 self
14163 }
14164}
14165
14166/// Creates a new `GitLabConfig`. This API is experimental
14167///
14168/// A builder for the *locations.gitLabConfigs.create* method supported by a *project* resource.
14169/// It is not used directly, but through a [`ProjectMethods`] instance.
14170///
14171/// # Example
14172///
14173/// Instantiate a resource method builder
14174///
14175/// ```test_harness,no_run
14176/// # extern crate hyper;
14177/// # extern crate hyper_rustls;
14178/// # extern crate google_cloudbuild1 as cloudbuild1;
14179/// use cloudbuild1::api::GitLabConfig;
14180/// # async fn dox() {
14181/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14182///
14183/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14184/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
14185/// # secret,
14186/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14187/// # ).build().await.unwrap();
14188///
14189/// # let client = hyper_util::client::legacy::Client::builder(
14190/// # hyper_util::rt::TokioExecutor::new()
14191/// # )
14192/// # .build(
14193/// # hyper_rustls::HttpsConnectorBuilder::new()
14194/// # .with_native_roots()
14195/// # .unwrap()
14196/// # .https_or_http()
14197/// # .enable_http1()
14198/// # .build()
14199/// # );
14200/// # let mut hub = CloudBuild::new(client, auth);
14201/// // As the method needs a request, you would usually fill it with the desired information
14202/// // into the respective structure. Some of the parts shown here might not be applicable !
14203/// // Values shown here are possibly random and not representative !
14204/// let mut req = GitLabConfig::default();
14205///
14206/// // You can configure optional parameters by calling the respective setters at will, and
14207/// // execute the final call using `doit()`.
14208/// // Values shown here are possibly random and not representative !
14209/// let result = hub.projects().locations_git_lab_configs_create(req, "parent")
14210/// .gitlab_config_id("diam")
14211/// .doit().await;
14212/// # }
14213/// ```
14214pub struct ProjectLocationGitLabConfigCreateCall<'a, C>
14215where
14216 C: 'a,
14217{
14218 hub: &'a CloudBuild<C>,
14219 _request: GitLabConfig,
14220 _parent: String,
14221 _gitlab_config_id: Option<String>,
14222 _delegate: Option<&'a mut dyn common::Delegate>,
14223 _additional_params: HashMap<String, String>,
14224 _scopes: BTreeSet<String>,
14225}
14226
14227impl<'a, C> common::CallBuilder for ProjectLocationGitLabConfigCreateCall<'a, C> {}
14228
14229impl<'a, C> ProjectLocationGitLabConfigCreateCall<'a, C>
14230where
14231 C: common::Connector,
14232{
14233 /// Perform the operation you have build so far.
14234 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
14235 use std::borrow::Cow;
14236 use std::io::{Read, Seek};
14237
14238 use common::{url::Params, ToParts};
14239 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14240
14241 let mut dd = common::DefaultDelegate;
14242 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14243 dlg.begin(common::MethodInfo {
14244 id: "cloudbuild.projects.locations.gitLabConfigs.create",
14245 http_method: hyper::Method::POST,
14246 });
14247
14248 for &field in ["alt", "parent", "gitlabConfigId"].iter() {
14249 if self._additional_params.contains_key(field) {
14250 dlg.finished(false);
14251 return Err(common::Error::FieldClash(field));
14252 }
14253 }
14254
14255 let mut params = Params::with_capacity(5 + self._additional_params.len());
14256 params.push("parent", self._parent);
14257 if let Some(value) = self._gitlab_config_id.as_ref() {
14258 params.push("gitlabConfigId", value);
14259 }
14260
14261 params.extend(self._additional_params.iter());
14262
14263 params.push("alt", "json");
14264 let mut url = self.hub._base_url.clone() + "v1/{+parent}/gitLabConfigs";
14265 if self._scopes.is_empty() {
14266 self._scopes
14267 .insert(Scope::CloudPlatform.as_ref().to_string());
14268 }
14269
14270 #[allow(clippy::single_element_loop)]
14271 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
14272 url = params.uri_replacement(url, param_name, find_this, true);
14273 }
14274 {
14275 let to_remove = ["parent"];
14276 params.remove_params(&to_remove);
14277 }
14278
14279 let url = params.parse_with_url(&url);
14280
14281 let mut json_mime_type = mime::APPLICATION_JSON;
14282 let mut request_value_reader = {
14283 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14284 common::remove_json_null_values(&mut value);
14285 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14286 serde_json::to_writer(&mut dst, &value).unwrap();
14287 dst
14288 };
14289 let request_size = request_value_reader
14290 .seek(std::io::SeekFrom::End(0))
14291 .unwrap();
14292 request_value_reader
14293 .seek(std::io::SeekFrom::Start(0))
14294 .unwrap();
14295
14296 loop {
14297 let token = match self
14298 .hub
14299 .auth
14300 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14301 .await
14302 {
14303 Ok(token) => token,
14304 Err(e) => match dlg.token(e) {
14305 Ok(token) => token,
14306 Err(e) => {
14307 dlg.finished(false);
14308 return Err(common::Error::MissingToken(e));
14309 }
14310 },
14311 };
14312 request_value_reader
14313 .seek(std::io::SeekFrom::Start(0))
14314 .unwrap();
14315 let mut req_result = {
14316 let client = &self.hub.client;
14317 dlg.pre_request();
14318 let mut req_builder = hyper::Request::builder()
14319 .method(hyper::Method::POST)
14320 .uri(url.as_str())
14321 .header(USER_AGENT, self.hub._user_agent.clone());
14322
14323 if let Some(token) = token.as_ref() {
14324 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14325 }
14326
14327 let request = req_builder
14328 .header(CONTENT_TYPE, json_mime_type.to_string())
14329 .header(CONTENT_LENGTH, request_size as u64)
14330 .body(common::to_body(
14331 request_value_reader.get_ref().clone().into(),
14332 ));
14333
14334 client.request(request.unwrap()).await
14335 };
14336
14337 match req_result {
14338 Err(err) => {
14339 if let common::Retry::After(d) = dlg.http_error(&err) {
14340 sleep(d).await;
14341 continue;
14342 }
14343 dlg.finished(false);
14344 return Err(common::Error::HttpError(err));
14345 }
14346 Ok(res) => {
14347 let (mut parts, body) = res.into_parts();
14348 let mut body = common::Body::new(body);
14349 if !parts.status.is_success() {
14350 let bytes = common::to_bytes(body).await.unwrap_or_default();
14351 let error = serde_json::from_str(&common::to_string(&bytes));
14352 let response = common::to_response(parts, bytes.into());
14353
14354 if let common::Retry::After(d) =
14355 dlg.http_failure(&response, error.as_ref().ok())
14356 {
14357 sleep(d).await;
14358 continue;
14359 }
14360
14361 dlg.finished(false);
14362
14363 return Err(match error {
14364 Ok(value) => common::Error::BadRequest(value),
14365 _ => common::Error::Failure(response),
14366 });
14367 }
14368 let response = {
14369 let bytes = common::to_bytes(body).await.unwrap_or_default();
14370 let encoded = common::to_string(&bytes);
14371 match serde_json::from_str(&encoded) {
14372 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14373 Err(error) => {
14374 dlg.response_json_decode_error(&encoded, &error);
14375 return Err(common::Error::JsonDecodeError(
14376 encoded.to_string(),
14377 error,
14378 ));
14379 }
14380 }
14381 };
14382
14383 dlg.finished(true);
14384 return Ok(response);
14385 }
14386 }
14387 }
14388 }
14389
14390 ///
14391 /// Sets the *request* property to the given value.
14392 ///
14393 /// Even though the property as already been set when instantiating this call,
14394 /// we provide this method for API completeness.
14395 pub fn request(
14396 mut self,
14397 new_value: GitLabConfig,
14398 ) -> ProjectLocationGitLabConfigCreateCall<'a, C> {
14399 self._request = new_value;
14400 self
14401 }
14402 /// Required. Name of the parent resource.
14403 ///
14404 /// Sets the *parent* path property to the given value.
14405 ///
14406 /// Even though the property as already been set when instantiating this call,
14407 /// we provide this method for API completeness.
14408 pub fn parent(mut self, new_value: &str) -> ProjectLocationGitLabConfigCreateCall<'a, C> {
14409 self._parent = new_value.to_string();
14410 self
14411 }
14412 /// Optional. The ID to use for the GitLabConfig, which will become the final component of the GitLabConfig’s resource name. gitlab_config_id must meet the following requirements: + They must contain only alphanumeric characters and dashes. + They can be 1-64 characters long. + They must begin and end with an alphanumeric character
14413 ///
14414 /// Sets the *gitlab config id* query property to the given value.
14415 pub fn gitlab_config_id(
14416 mut self,
14417 new_value: &str,
14418 ) -> ProjectLocationGitLabConfigCreateCall<'a, C> {
14419 self._gitlab_config_id = Some(new_value.to_string());
14420 self
14421 }
14422 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14423 /// while executing the actual API request.
14424 ///
14425 /// ````text
14426 /// It should be used to handle progress information, and to implement a certain level of resilience.
14427 /// ````
14428 ///
14429 /// Sets the *delegate* property to the given value.
14430 pub fn delegate(
14431 mut self,
14432 new_value: &'a mut dyn common::Delegate,
14433 ) -> ProjectLocationGitLabConfigCreateCall<'a, C> {
14434 self._delegate = Some(new_value);
14435 self
14436 }
14437
14438 /// Set any additional parameter of the query string used in the request.
14439 /// It should be used to set parameters which are not yet available through their own
14440 /// setters.
14441 ///
14442 /// Please note that this method must not be used to set any of the known parameters
14443 /// which have their own setter method. If done anyway, the request will fail.
14444 ///
14445 /// # Additional Parameters
14446 ///
14447 /// * *$.xgafv* (query-string) - V1 error format.
14448 /// * *access_token* (query-string) - OAuth access token.
14449 /// * *alt* (query-string) - Data format for response.
14450 /// * *callback* (query-string) - JSONP
14451 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14452 /// * *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.
14453 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14454 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14455 /// * *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.
14456 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14457 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14458 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGitLabConfigCreateCall<'a, C>
14459 where
14460 T: AsRef<str>,
14461 {
14462 self._additional_params
14463 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14464 self
14465 }
14466
14467 /// Identifies the authorization scope for the method you are building.
14468 ///
14469 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14470 /// [`Scope::CloudPlatform`].
14471 ///
14472 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14473 /// tokens for more than one scope.
14474 ///
14475 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14476 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14477 /// sufficient, a read-write scope will do as well.
14478 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGitLabConfigCreateCall<'a, C>
14479 where
14480 St: AsRef<str>,
14481 {
14482 self._scopes.insert(String::from(scope.as_ref()));
14483 self
14484 }
14485 /// Identifies the authorization scope(s) for the method you are building.
14486 ///
14487 /// See [`Self::add_scope()`] for details.
14488 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGitLabConfigCreateCall<'a, C>
14489 where
14490 I: IntoIterator<Item = St>,
14491 St: AsRef<str>,
14492 {
14493 self._scopes
14494 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14495 self
14496 }
14497
14498 /// Removes all scopes, and no default scope will be used either.
14499 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14500 /// for details).
14501 pub fn clear_scopes(mut self) -> ProjectLocationGitLabConfigCreateCall<'a, C> {
14502 self._scopes.clear();
14503 self
14504 }
14505}
14506
14507/// Delete a `GitLabConfig`. This API is experimental
14508///
14509/// A builder for the *locations.gitLabConfigs.delete* method supported by a *project* resource.
14510/// It is not used directly, but through a [`ProjectMethods`] instance.
14511///
14512/// # Example
14513///
14514/// Instantiate a resource method builder
14515///
14516/// ```test_harness,no_run
14517/// # extern crate hyper;
14518/// # extern crate hyper_rustls;
14519/// # extern crate google_cloudbuild1 as cloudbuild1;
14520/// # async fn dox() {
14521/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14522///
14523/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14524/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
14525/// # secret,
14526/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14527/// # ).build().await.unwrap();
14528///
14529/// # let client = hyper_util::client::legacy::Client::builder(
14530/// # hyper_util::rt::TokioExecutor::new()
14531/// # )
14532/// # .build(
14533/// # hyper_rustls::HttpsConnectorBuilder::new()
14534/// # .with_native_roots()
14535/// # .unwrap()
14536/// # .https_or_http()
14537/// # .enable_http1()
14538/// # .build()
14539/// # );
14540/// # let mut hub = CloudBuild::new(client, auth);
14541/// // You can configure optional parameters by calling the respective setters at will, and
14542/// // execute the final call using `doit()`.
14543/// // Values shown here are possibly random and not representative !
14544/// let result = hub.projects().locations_git_lab_configs_delete("name")
14545/// .doit().await;
14546/// # }
14547/// ```
14548pub struct ProjectLocationGitLabConfigDeleteCall<'a, C>
14549where
14550 C: 'a,
14551{
14552 hub: &'a CloudBuild<C>,
14553 _name: String,
14554 _delegate: Option<&'a mut dyn common::Delegate>,
14555 _additional_params: HashMap<String, String>,
14556 _scopes: BTreeSet<String>,
14557}
14558
14559impl<'a, C> common::CallBuilder for ProjectLocationGitLabConfigDeleteCall<'a, C> {}
14560
14561impl<'a, C> ProjectLocationGitLabConfigDeleteCall<'a, C>
14562where
14563 C: common::Connector,
14564{
14565 /// Perform the operation you have build so far.
14566 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
14567 use std::borrow::Cow;
14568 use std::io::{Read, Seek};
14569
14570 use common::{url::Params, ToParts};
14571 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14572
14573 let mut dd = common::DefaultDelegate;
14574 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14575 dlg.begin(common::MethodInfo {
14576 id: "cloudbuild.projects.locations.gitLabConfigs.delete",
14577 http_method: hyper::Method::DELETE,
14578 });
14579
14580 for &field in ["alt", "name"].iter() {
14581 if self._additional_params.contains_key(field) {
14582 dlg.finished(false);
14583 return Err(common::Error::FieldClash(field));
14584 }
14585 }
14586
14587 let mut params = Params::with_capacity(3 + self._additional_params.len());
14588 params.push("name", self._name);
14589
14590 params.extend(self._additional_params.iter());
14591
14592 params.push("alt", "json");
14593 let mut url = self.hub._base_url.clone() + "v1/{+name}";
14594 if self._scopes.is_empty() {
14595 self._scopes
14596 .insert(Scope::CloudPlatform.as_ref().to_string());
14597 }
14598
14599 #[allow(clippy::single_element_loop)]
14600 for &(find_this, param_name) in [("{+name}", "name")].iter() {
14601 url = params.uri_replacement(url, param_name, find_this, true);
14602 }
14603 {
14604 let to_remove = ["name"];
14605 params.remove_params(&to_remove);
14606 }
14607
14608 let url = params.parse_with_url(&url);
14609
14610 loop {
14611 let token = match self
14612 .hub
14613 .auth
14614 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14615 .await
14616 {
14617 Ok(token) => token,
14618 Err(e) => match dlg.token(e) {
14619 Ok(token) => token,
14620 Err(e) => {
14621 dlg.finished(false);
14622 return Err(common::Error::MissingToken(e));
14623 }
14624 },
14625 };
14626 let mut req_result = {
14627 let client = &self.hub.client;
14628 dlg.pre_request();
14629 let mut req_builder = hyper::Request::builder()
14630 .method(hyper::Method::DELETE)
14631 .uri(url.as_str())
14632 .header(USER_AGENT, self.hub._user_agent.clone());
14633
14634 if let Some(token) = token.as_ref() {
14635 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14636 }
14637
14638 let request = req_builder
14639 .header(CONTENT_LENGTH, 0_u64)
14640 .body(common::to_body::<String>(None));
14641
14642 client.request(request.unwrap()).await
14643 };
14644
14645 match req_result {
14646 Err(err) => {
14647 if let common::Retry::After(d) = dlg.http_error(&err) {
14648 sleep(d).await;
14649 continue;
14650 }
14651 dlg.finished(false);
14652 return Err(common::Error::HttpError(err));
14653 }
14654 Ok(res) => {
14655 let (mut parts, body) = res.into_parts();
14656 let mut body = common::Body::new(body);
14657 if !parts.status.is_success() {
14658 let bytes = common::to_bytes(body).await.unwrap_or_default();
14659 let error = serde_json::from_str(&common::to_string(&bytes));
14660 let response = common::to_response(parts, bytes.into());
14661
14662 if let common::Retry::After(d) =
14663 dlg.http_failure(&response, error.as_ref().ok())
14664 {
14665 sleep(d).await;
14666 continue;
14667 }
14668
14669 dlg.finished(false);
14670
14671 return Err(match error {
14672 Ok(value) => common::Error::BadRequest(value),
14673 _ => common::Error::Failure(response),
14674 });
14675 }
14676 let response = {
14677 let bytes = common::to_bytes(body).await.unwrap_or_default();
14678 let encoded = common::to_string(&bytes);
14679 match serde_json::from_str(&encoded) {
14680 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14681 Err(error) => {
14682 dlg.response_json_decode_error(&encoded, &error);
14683 return Err(common::Error::JsonDecodeError(
14684 encoded.to_string(),
14685 error,
14686 ));
14687 }
14688 }
14689 };
14690
14691 dlg.finished(true);
14692 return Ok(response);
14693 }
14694 }
14695 }
14696 }
14697
14698 /// Required. The config resource name.
14699 ///
14700 /// Sets the *name* path property to the given value.
14701 ///
14702 /// Even though the property as already been set when instantiating this call,
14703 /// we provide this method for API completeness.
14704 pub fn name(mut self, new_value: &str) -> ProjectLocationGitLabConfigDeleteCall<'a, C> {
14705 self._name = new_value.to_string();
14706 self
14707 }
14708 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14709 /// while executing the actual API request.
14710 ///
14711 /// ````text
14712 /// It should be used to handle progress information, and to implement a certain level of resilience.
14713 /// ````
14714 ///
14715 /// Sets the *delegate* property to the given value.
14716 pub fn delegate(
14717 mut self,
14718 new_value: &'a mut dyn common::Delegate,
14719 ) -> ProjectLocationGitLabConfigDeleteCall<'a, C> {
14720 self._delegate = Some(new_value);
14721 self
14722 }
14723
14724 /// Set any additional parameter of the query string used in the request.
14725 /// It should be used to set parameters which are not yet available through their own
14726 /// setters.
14727 ///
14728 /// Please note that this method must not be used to set any of the known parameters
14729 /// which have their own setter method. If done anyway, the request will fail.
14730 ///
14731 /// # Additional Parameters
14732 ///
14733 /// * *$.xgafv* (query-string) - V1 error format.
14734 /// * *access_token* (query-string) - OAuth access token.
14735 /// * *alt* (query-string) - Data format for response.
14736 /// * *callback* (query-string) - JSONP
14737 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14738 /// * *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.
14739 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14740 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14741 /// * *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.
14742 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14743 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14744 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGitLabConfigDeleteCall<'a, C>
14745 where
14746 T: AsRef<str>,
14747 {
14748 self._additional_params
14749 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14750 self
14751 }
14752
14753 /// Identifies the authorization scope for the method you are building.
14754 ///
14755 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14756 /// [`Scope::CloudPlatform`].
14757 ///
14758 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14759 /// tokens for more than one scope.
14760 ///
14761 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14762 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14763 /// sufficient, a read-write scope will do as well.
14764 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGitLabConfigDeleteCall<'a, C>
14765 where
14766 St: AsRef<str>,
14767 {
14768 self._scopes.insert(String::from(scope.as_ref()));
14769 self
14770 }
14771 /// Identifies the authorization scope(s) for the method you are building.
14772 ///
14773 /// See [`Self::add_scope()`] for details.
14774 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGitLabConfigDeleteCall<'a, C>
14775 where
14776 I: IntoIterator<Item = St>,
14777 St: AsRef<str>,
14778 {
14779 self._scopes
14780 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14781 self
14782 }
14783
14784 /// Removes all scopes, and no default scope will be used either.
14785 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14786 /// for details).
14787 pub fn clear_scopes(mut self) -> ProjectLocationGitLabConfigDeleteCall<'a, C> {
14788 self._scopes.clear();
14789 self
14790 }
14791}
14792
14793/// Retrieves a `GitLabConfig`. This API is experimental
14794///
14795/// A builder for the *locations.gitLabConfigs.get* method supported by a *project* resource.
14796/// It is not used directly, but through a [`ProjectMethods`] instance.
14797///
14798/// # Example
14799///
14800/// Instantiate a resource method builder
14801///
14802/// ```test_harness,no_run
14803/// # extern crate hyper;
14804/// # extern crate hyper_rustls;
14805/// # extern crate google_cloudbuild1 as cloudbuild1;
14806/// # async fn dox() {
14807/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14808///
14809/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14810/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
14811/// # secret,
14812/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14813/// # ).build().await.unwrap();
14814///
14815/// # let client = hyper_util::client::legacy::Client::builder(
14816/// # hyper_util::rt::TokioExecutor::new()
14817/// # )
14818/// # .build(
14819/// # hyper_rustls::HttpsConnectorBuilder::new()
14820/// # .with_native_roots()
14821/// # .unwrap()
14822/// # .https_or_http()
14823/// # .enable_http1()
14824/// # .build()
14825/// # );
14826/// # let mut hub = CloudBuild::new(client, auth);
14827/// // You can configure optional parameters by calling the respective setters at will, and
14828/// // execute the final call using `doit()`.
14829/// // Values shown here are possibly random and not representative !
14830/// let result = hub.projects().locations_git_lab_configs_get("name")
14831/// .doit().await;
14832/// # }
14833/// ```
14834pub struct ProjectLocationGitLabConfigGetCall<'a, C>
14835where
14836 C: 'a,
14837{
14838 hub: &'a CloudBuild<C>,
14839 _name: String,
14840 _delegate: Option<&'a mut dyn common::Delegate>,
14841 _additional_params: HashMap<String, String>,
14842 _scopes: BTreeSet<String>,
14843}
14844
14845impl<'a, C> common::CallBuilder for ProjectLocationGitLabConfigGetCall<'a, C> {}
14846
14847impl<'a, C> ProjectLocationGitLabConfigGetCall<'a, C>
14848where
14849 C: common::Connector,
14850{
14851 /// Perform the operation you have build so far.
14852 pub async fn doit(mut self) -> common::Result<(common::Response, GitLabConfig)> {
14853 use std::borrow::Cow;
14854 use std::io::{Read, Seek};
14855
14856 use common::{url::Params, ToParts};
14857 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14858
14859 let mut dd = common::DefaultDelegate;
14860 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14861 dlg.begin(common::MethodInfo {
14862 id: "cloudbuild.projects.locations.gitLabConfigs.get",
14863 http_method: hyper::Method::GET,
14864 });
14865
14866 for &field in ["alt", "name"].iter() {
14867 if self._additional_params.contains_key(field) {
14868 dlg.finished(false);
14869 return Err(common::Error::FieldClash(field));
14870 }
14871 }
14872
14873 let mut params = Params::with_capacity(3 + self._additional_params.len());
14874 params.push("name", self._name);
14875
14876 params.extend(self._additional_params.iter());
14877
14878 params.push("alt", "json");
14879 let mut url = self.hub._base_url.clone() + "v1/{+name}";
14880 if self._scopes.is_empty() {
14881 self._scopes
14882 .insert(Scope::CloudPlatform.as_ref().to_string());
14883 }
14884
14885 #[allow(clippy::single_element_loop)]
14886 for &(find_this, param_name) in [("{+name}", "name")].iter() {
14887 url = params.uri_replacement(url, param_name, find_this, true);
14888 }
14889 {
14890 let to_remove = ["name"];
14891 params.remove_params(&to_remove);
14892 }
14893
14894 let url = params.parse_with_url(&url);
14895
14896 loop {
14897 let token = match self
14898 .hub
14899 .auth
14900 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14901 .await
14902 {
14903 Ok(token) => token,
14904 Err(e) => match dlg.token(e) {
14905 Ok(token) => token,
14906 Err(e) => {
14907 dlg.finished(false);
14908 return Err(common::Error::MissingToken(e));
14909 }
14910 },
14911 };
14912 let mut req_result = {
14913 let client = &self.hub.client;
14914 dlg.pre_request();
14915 let mut req_builder = hyper::Request::builder()
14916 .method(hyper::Method::GET)
14917 .uri(url.as_str())
14918 .header(USER_AGENT, self.hub._user_agent.clone());
14919
14920 if let Some(token) = token.as_ref() {
14921 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14922 }
14923
14924 let request = req_builder
14925 .header(CONTENT_LENGTH, 0_u64)
14926 .body(common::to_body::<String>(None));
14927
14928 client.request(request.unwrap()).await
14929 };
14930
14931 match req_result {
14932 Err(err) => {
14933 if let common::Retry::After(d) = dlg.http_error(&err) {
14934 sleep(d).await;
14935 continue;
14936 }
14937 dlg.finished(false);
14938 return Err(common::Error::HttpError(err));
14939 }
14940 Ok(res) => {
14941 let (mut parts, body) = res.into_parts();
14942 let mut body = common::Body::new(body);
14943 if !parts.status.is_success() {
14944 let bytes = common::to_bytes(body).await.unwrap_or_default();
14945 let error = serde_json::from_str(&common::to_string(&bytes));
14946 let response = common::to_response(parts, bytes.into());
14947
14948 if let common::Retry::After(d) =
14949 dlg.http_failure(&response, error.as_ref().ok())
14950 {
14951 sleep(d).await;
14952 continue;
14953 }
14954
14955 dlg.finished(false);
14956
14957 return Err(match error {
14958 Ok(value) => common::Error::BadRequest(value),
14959 _ => common::Error::Failure(response),
14960 });
14961 }
14962 let response = {
14963 let bytes = common::to_bytes(body).await.unwrap_or_default();
14964 let encoded = common::to_string(&bytes);
14965 match serde_json::from_str(&encoded) {
14966 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14967 Err(error) => {
14968 dlg.response_json_decode_error(&encoded, &error);
14969 return Err(common::Error::JsonDecodeError(
14970 encoded.to_string(),
14971 error,
14972 ));
14973 }
14974 }
14975 };
14976
14977 dlg.finished(true);
14978 return Ok(response);
14979 }
14980 }
14981 }
14982 }
14983
14984 /// Required. The config resource name.
14985 ///
14986 /// Sets the *name* path property to the given value.
14987 ///
14988 /// Even though the property as already been set when instantiating this call,
14989 /// we provide this method for API completeness.
14990 pub fn name(mut self, new_value: &str) -> ProjectLocationGitLabConfigGetCall<'a, C> {
14991 self._name = new_value.to_string();
14992 self
14993 }
14994 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14995 /// while executing the actual API request.
14996 ///
14997 /// ````text
14998 /// It should be used to handle progress information, and to implement a certain level of resilience.
14999 /// ````
15000 ///
15001 /// Sets the *delegate* property to the given value.
15002 pub fn delegate(
15003 mut self,
15004 new_value: &'a mut dyn common::Delegate,
15005 ) -> ProjectLocationGitLabConfigGetCall<'a, C> {
15006 self._delegate = Some(new_value);
15007 self
15008 }
15009
15010 /// Set any additional parameter of the query string used in the request.
15011 /// It should be used to set parameters which are not yet available through their own
15012 /// setters.
15013 ///
15014 /// Please note that this method must not be used to set any of the known parameters
15015 /// which have their own setter method. If done anyway, the request will fail.
15016 ///
15017 /// # Additional Parameters
15018 ///
15019 /// * *$.xgafv* (query-string) - V1 error format.
15020 /// * *access_token* (query-string) - OAuth access token.
15021 /// * *alt* (query-string) - Data format for response.
15022 /// * *callback* (query-string) - JSONP
15023 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15024 /// * *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.
15025 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15026 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15027 /// * *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.
15028 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15029 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15030 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGitLabConfigGetCall<'a, C>
15031 where
15032 T: AsRef<str>,
15033 {
15034 self._additional_params
15035 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15036 self
15037 }
15038
15039 /// Identifies the authorization scope for the method you are building.
15040 ///
15041 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15042 /// [`Scope::CloudPlatform`].
15043 ///
15044 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15045 /// tokens for more than one scope.
15046 ///
15047 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15048 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15049 /// sufficient, a read-write scope will do as well.
15050 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGitLabConfigGetCall<'a, C>
15051 where
15052 St: AsRef<str>,
15053 {
15054 self._scopes.insert(String::from(scope.as_ref()));
15055 self
15056 }
15057 /// Identifies the authorization scope(s) for the method you are building.
15058 ///
15059 /// See [`Self::add_scope()`] for details.
15060 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGitLabConfigGetCall<'a, C>
15061 where
15062 I: IntoIterator<Item = St>,
15063 St: AsRef<str>,
15064 {
15065 self._scopes
15066 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15067 self
15068 }
15069
15070 /// Removes all scopes, and no default scope will be used either.
15071 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15072 /// for details).
15073 pub fn clear_scopes(mut self) -> ProjectLocationGitLabConfigGetCall<'a, C> {
15074 self._scopes.clear();
15075 self
15076 }
15077}
15078
15079/// List all `GitLabConfigs` for a given project. This API is experimental
15080///
15081/// A builder for the *locations.gitLabConfigs.list* method supported by a *project* resource.
15082/// It is not used directly, but through a [`ProjectMethods`] instance.
15083///
15084/// # Example
15085///
15086/// Instantiate a resource method builder
15087///
15088/// ```test_harness,no_run
15089/// # extern crate hyper;
15090/// # extern crate hyper_rustls;
15091/// # extern crate google_cloudbuild1 as cloudbuild1;
15092/// # async fn dox() {
15093/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15094///
15095/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15096/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
15097/// # secret,
15098/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15099/// # ).build().await.unwrap();
15100///
15101/// # let client = hyper_util::client::legacy::Client::builder(
15102/// # hyper_util::rt::TokioExecutor::new()
15103/// # )
15104/// # .build(
15105/// # hyper_rustls::HttpsConnectorBuilder::new()
15106/// # .with_native_roots()
15107/// # .unwrap()
15108/// # .https_or_http()
15109/// # .enable_http1()
15110/// # .build()
15111/// # );
15112/// # let mut hub = CloudBuild::new(client, auth);
15113/// // You can configure optional parameters by calling the respective setters at will, and
15114/// // execute the final call using `doit()`.
15115/// // Values shown here are possibly random and not representative !
15116/// let result = hub.projects().locations_git_lab_configs_list("parent")
15117/// .page_token("takimata")
15118/// .page_size(-46)
15119/// .doit().await;
15120/// # }
15121/// ```
15122pub struct ProjectLocationGitLabConfigListCall<'a, C>
15123where
15124 C: 'a,
15125{
15126 hub: &'a CloudBuild<C>,
15127 _parent: String,
15128 _page_token: Option<String>,
15129 _page_size: Option<i32>,
15130 _delegate: Option<&'a mut dyn common::Delegate>,
15131 _additional_params: HashMap<String, String>,
15132 _scopes: BTreeSet<String>,
15133}
15134
15135impl<'a, C> common::CallBuilder for ProjectLocationGitLabConfigListCall<'a, C> {}
15136
15137impl<'a, C> ProjectLocationGitLabConfigListCall<'a, C>
15138where
15139 C: common::Connector,
15140{
15141 /// Perform the operation you have build so far.
15142 pub async fn doit(mut self) -> common::Result<(common::Response, ListGitLabConfigsResponse)> {
15143 use std::borrow::Cow;
15144 use std::io::{Read, Seek};
15145
15146 use common::{url::Params, ToParts};
15147 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15148
15149 let mut dd = common::DefaultDelegate;
15150 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15151 dlg.begin(common::MethodInfo {
15152 id: "cloudbuild.projects.locations.gitLabConfigs.list",
15153 http_method: hyper::Method::GET,
15154 });
15155
15156 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
15157 if self._additional_params.contains_key(field) {
15158 dlg.finished(false);
15159 return Err(common::Error::FieldClash(field));
15160 }
15161 }
15162
15163 let mut params = Params::with_capacity(5 + self._additional_params.len());
15164 params.push("parent", self._parent);
15165 if let Some(value) = self._page_token.as_ref() {
15166 params.push("pageToken", value);
15167 }
15168 if let Some(value) = self._page_size.as_ref() {
15169 params.push("pageSize", value.to_string());
15170 }
15171
15172 params.extend(self._additional_params.iter());
15173
15174 params.push("alt", "json");
15175 let mut url = self.hub._base_url.clone() + "v1/{+parent}/gitLabConfigs";
15176 if self._scopes.is_empty() {
15177 self._scopes
15178 .insert(Scope::CloudPlatform.as_ref().to_string());
15179 }
15180
15181 #[allow(clippy::single_element_loop)]
15182 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
15183 url = params.uri_replacement(url, param_name, find_this, true);
15184 }
15185 {
15186 let to_remove = ["parent"];
15187 params.remove_params(&to_remove);
15188 }
15189
15190 let url = params.parse_with_url(&url);
15191
15192 loop {
15193 let token = match self
15194 .hub
15195 .auth
15196 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15197 .await
15198 {
15199 Ok(token) => token,
15200 Err(e) => match dlg.token(e) {
15201 Ok(token) => token,
15202 Err(e) => {
15203 dlg.finished(false);
15204 return Err(common::Error::MissingToken(e));
15205 }
15206 },
15207 };
15208 let mut req_result = {
15209 let client = &self.hub.client;
15210 dlg.pre_request();
15211 let mut req_builder = hyper::Request::builder()
15212 .method(hyper::Method::GET)
15213 .uri(url.as_str())
15214 .header(USER_AGENT, self.hub._user_agent.clone());
15215
15216 if let Some(token) = token.as_ref() {
15217 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15218 }
15219
15220 let request = req_builder
15221 .header(CONTENT_LENGTH, 0_u64)
15222 .body(common::to_body::<String>(None));
15223
15224 client.request(request.unwrap()).await
15225 };
15226
15227 match req_result {
15228 Err(err) => {
15229 if let common::Retry::After(d) = dlg.http_error(&err) {
15230 sleep(d).await;
15231 continue;
15232 }
15233 dlg.finished(false);
15234 return Err(common::Error::HttpError(err));
15235 }
15236 Ok(res) => {
15237 let (mut parts, body) = res.into_parts();
15238 let mut body = common::Body::new(body);
15239 if !parts.status.is_success() {
15240 let bytes = common::to_bytes(body).await.unwrap_or_default();
15241 let error = serde_json::from_str(&common::to_string(&bytes));
15242 let response = common::to_response(parts, bytes.into());
15243
15244 if let common::Retry::After(d) =
15245 dlg.http_failure(&response, error.as_ref().ok())
15246 {
15247 sleep(d).await;
15248 continue;
15249 }
15250
15251 dlg.finished(false);
15252
15253 return Err(match error {
15254 Ok(value) => common::Error::BadRequest(value),
15255 _ => common::Error::Failure(response),
15256 });
15257 }
15258 let response = {
15259 let bytes = common::to_bytes(body).await.unwrap_or_default();
15260 let encoded = common::to_string(&bytes);
15261 match serde_json::from_str(&encoded) {
15262 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15263 Err(error) => {
15264 dlg.response_json_decode_error(&encoded, &error);
15265 return Err(common::Error::JsonDecodeError(
15266 encoded.to_string(),
15267 error,
15268 ));
15269 }
15270 }
15271 };
15272
15273 dlg.finished(true);
15274 return Ok(response);
15275 }
15276 }
15277 }
15278 }
15279
15280 /// Required. Name of the parent resource
15281 ///
15282 /// Sets the *parent* path property to the given value.
15283 ///
15284 /// Even though the property as already been set when instantiating this call,
15285 /// we provide this method for API completeness.
15286 pub fn parent(mut self, new_value: &str) -> ProjectLocationGitLabConfigListCall<'a, C> {
15287 self._parent = new_value.to_string();
15288 self
15289 }
15290 /// A page token, received from a previous ‘ListGitlabConfigsRequest’ call. Provide this to retrieve the subsequent page. When paginating, all other parameters provided to ‘ListGitlabConfigsRequest’ must match the call that provided the page token.
15291 ///
15292 /// Sets the *page token* query property to the given value.
15293 pub fn page_token(mut self, new_value: &str) -> ProjectLocationGitLabConfigListCall<'a, C> {
15294 self._page_token = Some(new_value.to_string());
15295 self
15296 }
15297 /// The maximum number of configs to return. The service may return fewer than this value. If unspecified, at most 50 configs will be returned. The maximum value is 1000;, values above 1000 will be coerced to 1000.
15298 ///
15299 /// Sets the *page size* query property to the given value.
15300 pub fn page_size(mut self, new_value: i32) -> ProjectLocationGitLabConfigListCall<'a, C> {
15301 self._page_size = Some(new_value);
15302 self
15303 }
15304 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15305 /// while executing the actual API request.
15306 ///
15307 /// ````text
15308 /// It should be used to handle progress information, and to implement a certain level of resilience.
15309 /// ````
15310 ///
15311 /// Sets the *delegate* property to the given value.
15312 pub fn delegate(
15313 mut self,
15314 new_value: &'a mut dyn common::Delegate,
15315 ) -> ProjectLocationGitLabConfigListCall<'a, C> {
15316 self._delegate = Some(new_value);
15317 self
15318 }
15319
15320 /// Set any additional parameter of the query string used in the request.
15321 /// It should be used to set parameters which are not yet available through their own
15322 /// setters.
15323 ///
15324 /// Please note that this method must not be used to set any of the known parameters
15325 /// which have their own setter method. If done anyway, the request will fail.
15326 ///
15327 /// # Additional Parameters
15328 ///
15329 /// * *$.xgafv* (query-string) - V1 error format.
15330 /// * *access_token* (query-string) - OAuth access token.
15331 /// * *alt* (query-string) - Data format for response.
15332 /// * *callback* (query-string) - JSONP
15333 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15334 /// * *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.
15335 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15336 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15337 /// * *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.
15338 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15339 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15340 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGitLabConfigListCall<'a, C>
15341 where
15342 T: AsRef<str>,
15343 {
15344 self._additional_params
15345 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15346 self
15347 }
15348
15349 /// Identifies the authorization scope for the method you are building.
15350 ///
15351 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15352 /// [`Scope::CloudPlatform`].
15353 ///
15354 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15355 /// tokens for more than one scope.
15356 ///
15357 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15358 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15359 /// sufficient, a read-write scope will do as well.
15360 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGitLabConfigListCall<'a, C>
15361 where
15362 St: AsRef<str>,
15363 {
15364 self._scopes.insert(String::from(scope.as_ref()));
15365 self
15366 }
15367 /// Identifies the authorization scope(s) for the method you are building.
15368 ///
15369 /// See [`Self::add_scope()`] for details.
15370 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGitLabConfigListCall<'a, C>
15371 where
15372 I: IntoIterator<Item = St>,
15373 St: AsRef<str>,
15374 {
15375 self._scopes
15376 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15377 self
15378 }
15379
15380 /// Removes all scopes, and no default scope will be used either.
15381 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15382 /// for details).
15383 pub fn clear_scopes(mut self) -> ProjectLocationGitLabConfigListCall<'a, C> {
15384 self._scopes.clear();
15385 self
15386 }
15387}
15388
15389/// Updates an existing `GitLabConfig`. This API is experimental
15390///
15391/// A builder for the *locations.gitLabConfigs.patch* method supported by a *project* resource.
15392/// It is not used directly, but through a [`ProjectMethods`] instance.
15393///
15394/// # Example
15395///
15396/// Instantiate a resource method builder
15397///
15398/// ```test_harness,no_run
15399/// # extern crate hyper;
15400/// # extern crate hyper_rustls;
15401/// # extern crate google_cloudbuild1 as cloudbuild1;
15402/// use cloudbuild1::api::GitLabConfig;
15403/// # async fn dox() {
15404/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15405///
15406/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15407/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
15408/// # secret,
15409/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15410/// # ).build().await.unwrap();
15411///
15412/// # let client = hyper_util::client::legacy::Client::builder(
15413/// # hyper_util::rt::TokioExecutor::new()
15414/// # )
15415/// # .build(
15416/// # hyper_rustls::HttpsConnectorBuilder::new()
15417/// # .with_native_roots()
15418/// # .unwrap()
15419/// # .https_or_http()
15420/// # .enable_http1()
15421/// # .build()
15422/// # );
15423/// # let mut hub = CloudBuild::new(client, auth);
15424/// // As the method needs a request, you would usually fill it with the desired information
15425/// // into the respective structure. Some of the parts shown here might not be applicable !
15426/// // Values shown here are possibly random and not representative !
15427/// let mut req = GitLabConfig::default();
15428///
15429/// // You can configure optional parameters by calling the respective setters at will, and
15430/// // execute the final call using `doit()`.
15431/// // Values shown here are possibly random and not representative !
15432/// let result = hub.projects().locations_git_lab_configs_patch(req, "name")
15433/// .update_mask(FieldMask::new::<&str>(&[]))
15434/// .doit().await;
15435/// # }
15436/// ```
15437pub struct ProjectLocationGitLabConfigPatchCall<'a, C>
15438where
15439 C: 'a,
15440{
15441 hub: &'a CloudBuild<C>,
15442 _request: GitLabConfig,
15443 _name: String,
15444 _update_mask: Option<common::FieldMask>,
15445 _delegate: Option<&'a mut dyn common::Delegate>,
15446 _additional_params: HashMap<String, String>,
15447 _scopes: BTreeSet<String>,
15448}
15449
15450impl<'a, C> common::CallBuilder for ProjectLocationGitLabConfigPatchCall<'a, C> {}
15451
15452impl<'a, C> ProjectLocationGitLabConfigPatchCall<'a, C>
15453where
15454 C: common::Connector,
15455{
15456 /// Perform the operation you have build so far.
15457 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
15458 use std::borrow::Cow;
15459 use std::io::{Read, Seek};
15460
15461 use common::{url::Params, ToParts};
15462 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15463
15464 let mut dd = common::DefaultDelegate;
15465 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15466 dlg.begin(common::MethodInfo {
15467 id: "cloudbuild.projects.locations.gitLabConfigs.patch",
15468 http_method: hyper::Method::PATCH,
15469 });
15470
15471 for &field in ["alt", "name", "updateMask"].iter() {
15472 if self._additional_params.contains_key(field) {
15473 dlg.finished(false);
15474 return Err(common::Error::FieldClash(field));
15475 }
15476 }
15477
15478 let mut params = Params::with_capacity(5 + self._additional_params.len());
15479 params.push("name", self._name);
15480 if let Some(value) = self._update_mask.as_ref() {
15481 params.push("updateMask", value.to_string());
15482 }
15483
15484 params.extend(self._additional_params.iter());
15485
15486 params.push("alt", "json");
15487 let mut url = self.hub._base_url.clone() + "v1/{+name}";
15488 if self._scopes.is_empty() {
15489 self._scopes
15490 .insert(Scope::CloudPlatform.as_ref().to_string());
15491 }
15492
15493 #[allow(clippy::single_element_loop)]
15494 for &(find_this, param_name) in [("{+name}", "name")].iter() {
15495 url = params.uri_replacement(url, param_name, find_this, true);
15496 }
15497 {
15498 let to_remove = ["name"];
15499 params.remove_params(&to_remove);
15500 }
15501
15502 let url = params.parse_with_url(&url);
15503
15504 let mut json_mime_type = mime::APPLICATION_JSON;
15505 let mut request_value_reader = {
15506 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15507 common::remove_json_null_values(&mut value);
15508 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15509 serde_json::to_writer(&mut dst, &value).unwrap();
15510 dst
15511 };
15512 let request_size = request_value_reader
15513 .seek(std::io::SeekFrom::End(0))
15514 .unwrap();
15515 request_value_reader
15516 .seek(std::io::SeekFrom::Start(0))
15517 .unwrap();
15518
15519 loop {
15520 let token = match self
15521 .hub
15522 .auth
15523 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15524 .await
15525 {
15526 Ok(token) => token,
15527 Err(e) => match dlg.token(e) {
15528 Ok(token) => token,
15529 Err(e) => {
15530 dlg.finished(false);
15531 return Err(common::Error::MissingToken(e));
15532 }
15533 },
15534 };
15535 request_value_reader
15536 .seek(std::io::SeekFrom::Start(0))
15537 .unwrap();
15538 let mut req_result = {
15539 let client = &self.hub.client;
15540 dlg.pre_request();
15541 let mut req_builder = hyper::Request::builder()
15542 .method(hyper::Method::PATCH)
15543 .uri(url.as_str())
15544 .header(USER_AGENT, self.hub._user_agent.clone());
15545
15546 if let Some(token) = token.as_ref() {
15547 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15548 }
15549
15550 let request = req_builder
15551 .header(CONTENT_TYPE, json_mime_type.to_string())
15552 .header(CONTENT_LENGTH, request_size as u64)
15553 .body(common::to_body(
15554 request_value_reader.get_ref().clone().into(),
15555 ));
15556
15557 client.request(request.unwrap()).await
15558 };
15559
15560 match req_result {
15561 Err(err) => {
15562 if let common::Retry::After(d) = dlg.http_error(&err) {
15563 sleep(d).await;
15564 continue;
15565 }
15566 dlg.finished(false);
15567 return Err(common::Error::HttpError(err));
15568 }
15569 Ok(res) => {
15570 let (mut parts, body) = res.into_parts();
15571 let mut body = common::Body::new(body);
15572 if !parts.status.is_success() {
15573 let bytes = common::to_bytes(body).await.unwrap_or_default();
15574 let error = serde_json::from_str(&common::to_string(&bytes));
15575 let response = common::to_response(parts, bytes.into());
15576
15577 if let common::Retry::After(d) =
15578 dlg.http_failure(&response, error.as_ref().ok())
15579 {
15580 sleep(d).await;
15581 continue;
15582 }
15583
15584 dlg.finished(false);
15585
15586 return Err(match error {
15587 Ok(value) => common::Error::BadRequest(value),
15588 _ => common::Error::Failure(response),
15589 });
15590 }
15591 let response = {
15592 let bytes = common::to_bytes(body).await.unwrap_or_default();
15593 let encoded = common::to_string(&bytes);
15594 match serde_json::from_str(&encoded) {
15595 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15596 Err(error) => {
15597 dlg.response_json_decode_error(&encoded, &error);
15598 return Err(common::Error::JsonDecodeError(
15599 encoded.to_string(),
15600 error,
15601 ));
15602 }
15603 }
15604 };
15605
15606 dlg.finished(true);
15607 return Ok(response);
15608 }
15609 }
15610 }
15611 }
15612
15613 ///
15614 /// Sets the *request* property to the given value.
15615 ///
15616 /// Even though the property as already been set when instantiating this call,
15617 /// we provide this method for API completeness.
15618 pub fn request(
15619 mut self,
15620 new_value: GitLabConfig,
15621 ) -> ProjectLocationGitLabConfigPatchCall<'a, C> {
15622 self._request = new_value;
15623 self
15624 }
15625 /// The resource name for the config.
15626 ///
15627 /// Sets the *name* path property to the given value.
15628 ///
15629 /// Even though the property as already been set when instantiating this call,
15630 /// we provide this method for API completeness.
15631 pub fn name(mut self, new_value: &str) -> ProjectLocationGitLabConfigPatchCall<'a, C> {
15632 self._name = new_value.to_string();
15633 self
15634 }
15635 /// Update mask for the resource. If this is set, the server will only update the fields specified in the field mask. Otherwise, a full update of the mutable resource fields will be performed.
15636 ///
15637 /// Sets the *update mask* query property to the given value.
15638 pub fn update_mask(
15639 mut self,
15640 new_value: common::FieldMask,
15641 ) -> ProjectLocationGitLabConfigPatchCall<'a, C> {
15642 self._update_mask = Some(new_value);
15643 self
15644 }
15645 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15646 /// while executing the actual API request.
15647 ///
15648 /// ````text
15649 /// It should be used to handle progress information, and to implement a certain level of resilience.
15650 /// ````
15651 ///
15652 /// Sets the *delegate* property to the given value.
15653 pub fn delegate(
15654 mut self,
15655 new_value: &'a mut dyn common::Delegate,
15656 ) -> ProjectLocationGitLabConfigPatchCall<'a, C> {
15657 self._delegate = Some(new_value);
15658 self
15659 }
15660
15661 /// Set any additional parameter of the query string used in the request.
15662 /// It should be used to set parameters which are not yet available through their own
15663 /// setters.
15664 ///
15665 /// Please note that this method must not be used to set any of the known parameters
15666 /// which have their own setter method. If done anyway, the request will fail.
15667 ///
15668 /// # Additional Parameters
15669 ///
15670 /// * *$.xgafv* (query-string) - V1 error format.
15671 /// * *access_token* (query-string) - OAuth access token.
15672 /// * *alt* (query-string) - Data format for response.
15673 /// * *callback* (query-string) - JSONP
15674 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15675 /// * *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.
15676 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15677 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15678 /// * *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.
15679 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15680 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15681 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGitLabConfigPatchCall<'a, C>
15682 where
15683 T: AsRef<str>,
15684 {
15685 self._additional_params
15686 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15687 self
15688 }
15689
15690 /// Identifies the authorization scope for the method you are building.
15691 ///
15692 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15693 /// [`Scope::CloudPlatform`].
15694 ///
15695 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15696 /// tokens for more than one scope.
15697 ///
15698 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15699 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15700 /// sufficient, a read-write scope will do as well.
15701 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGitLabConfigPatchCall<'a, C>
15702 where
15703 St: AsRef<str>,
15704 {
15705 self._scopes.insert(String::from(scope.as_ref()));
15706 self
15707 }
15708 /// Identifies the authorization scope(s) for the method you are building.
15709 ///
15710 /// See [`Self::add_scope()`] for details.
15711 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGitLabConfigPatchCall<'a, C>
15712 where
15713 I: IntoIterator<Item = St>,
15714 St: AsRef<str>,
15715 {
15716 self._scopes
15717 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15718 self
15719 }
15720
15721 /// Removes all scopes, and no default scope will be used either.
15722 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15723 /// for details).
15724 pub fn clear_scopes(mut self) -> ProjectLocationGitLabConfigPatchCall<'a, C> {
15725 self._scopes.clear();
15726 self
15727 }
15728}
15729
15730/// Remove a GitLab repository from a given GitLabConfig's connected repositories. This API is experimental.
15731///
15732/// A builder for the *locations.gitLabConfigs.removeGitLabConnectedRepository* method supported by a *project* resource.
15733/// It is not used directly, but through a [`ProjectMethods`] instance.
15734///
15735/// # Example
15736///
15737/// Instantiate a resource method builder
15738///
15739/// ```test_harness,no_run
15740/// # extern crate hyper;
15741/// # extern crate hyper_rustls;
15742/// # extern crate google_cloudbuild1 as cloudbuild1;
15743/// use cloudbuild1::api::RemoveGitLabConnectedRepositoryRequest;
15744/// # async fn dox() {
15745/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15746///
15747/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15748/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
15749/// # secret,
15750/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15751/// # ).build().await.unwrap();
15752///
15753/// # let client = hyper_util::client::legacy::Client::builder(
15754/// # hyper_util::rt::TokioExecutor::new()
15755/// # )
15756/// # .build(
15757/// # hyper_rustls::HttpsConnectorBuilder::new()
15758/// # .with_native_roots()
15759/// # .unwrap()
15760/// # .https_or_http()
15761/// # .enable_http1()
15762/// # .build()
15763/// # );
15764/// # let mut hub = CloudBuild::new(client, auth);
15765/// // As the method needs a request, you would usually fill it with the desired information
15766/// // into the respective structure. Some of the parts shown here might not be applicable !
15767/// // Values shown here are possibly random and not representative !
15768/// let mut req = RemoveGitLabConnectedRepositoryRequest::default();
15769///
15770/// // You can configure optional parameters by calling the respective setters at will, and
15771/// // execute the final call using `doit()`.
15772/// // Values shown here are possibly random and not representative !
15773/// let result = hub.projects().locations_git_lab_configs_remove_git_lab_connected_repository(req, "config")
15774/// .doit().await;
15775/// # }
15776/// ```
15777pub struct ProjectLocationGitLabConfigRemoveGitLabConnectedRepositoryCall<'a, C>
15778where
15779 C: 'a,
15780{
15781 hub: &'a CloudBuild<C>,
15782 _request: RemoveGitLabConnectedRepositoryRequest,
15783 _config: String,
15784 _delegate: Option<&'a mut dyn common::Delegate>,
15785 _additional_params: HashMap<String, String>,
15786 _scopes: BTreeSet<String>,
15787}
15788
15789impl<'a, C> common::CallBuilder
15790 for ProjectLocationGitLabConfigRemoveGitLabConnectedRepositoryCall<'a, C>
15791{
15792}
15793
15794impl<'a, C> ProjectLocationGitLabConfigRemoveGitLabConnectedRepositoryCall<'a, C>
15795where
15796 C: common::Connector,
15797{
15798 /// Perform the operation you have build so far.
15799 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
15800 use std::borrow::Cow;
15801 use std::io::{Read, Seek};
15802
15803 use common::{url::Params, ToParts};
15804 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15805
15806 let mut dd = common::DefaultDelegate;
15807 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15808 dlg.begin(common::MethodInfo {
15809 id: "cloudbuild.projects.locations.gitLabConfigs.removeGitLabConnectedRepository",
15810 http_method: hyper::Method::POST,
15811 });
15812
15813 for &field in ["alt", "config"].iter() {
15814 if self._additional_params.contains_key(field) {
15815 dlg.finished(false);
15816 return Err(common::Error::FieldClash(field));
15817 }
15818 }
15819
15820 let mut params = Params::with_capacity(4 + self._additional_params.len());
15821 params.push("config", self._config);
15822
15823 params.extend(self._additional_params.iter());
15824
15825 params.push("alt", "json");
15826 let mut url = self.hub._base_url.clone() + "v1/{+config}:removeGitLabConnectedRepository";
15827 if self._scopes.is_empty() {
15828 self._scopes
15829 .insert(Scope::CloudPlatform.as_ref().to_string());
15830 }
15831
15832 #[allow(clippy::single_element_loop)]
15833 for &(find_this, param_name) in [("{+config}", "config")].iter() {
15834 url = params.uri_replacement(url, param_name, find_this, true);
15835 }
15836 {
15837 let to_remove = ["config"];
15838 params.remove_params(&to_remove);
15839 }
15840
15841 let url = params.parse_with_url(&url);
15842
15843 let mut json_mime_type = mime::APPLICATION_JSON;
15844 let mut request_value_reader = {
15845 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15846 common::remove_json_null_values(&mut value);
15847 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15848 serde_json::to_writer(&mut dst, &value).unwrap();
15849 dst
15850 };
15851 let request_size = request_value_reader
15852 .seek(std::io::SeekFrom::End(0))
15853 .unwrap();
15854 request_value_reader
15855 .seek(std::io::SeekFrom::Start(0))
15856 .unwrap();
15857
15858 loop {
15859 let token = match self
15860 .hub
15861 .auth
15862 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15863 .await
15864 {
15865 Ok(token) => token,
15866 Err(e) => match dlg.token(e) {
15867 Ok(token) => token,
15868 Err(e) => {
15869 dlg.finished(false);
15870 return Err(common::Error::MissingToken(e));
15871 }
15872 },
15873 };
15874 request_value_reader
15875 .seek(std::io::SeekFrom::Start(0))
15876 .unwrap();
15877 let mut req_result = {
15878 let client = &self.hub.client;
15879 dlg.pre_request();
15880 let mut req_builder = hyper::Request::builder()
15881 .method(hyper::Method::POST)
15882 .uri(url.as_str())
15883 .header(USER_AGENT, self.hub._user_agent.clone());
15884
15885 if let Some(token) = token.as_ref() {
15886 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15887 }
15888
15889 let request = req_builder
15890 .header(CONTENT_TYPE, json_mime_type.to_string())
15891 .header(CONTENT_LENGTH, request_size as u64)
15892 .body(common::to_body(
15893 request_value_reader.get_ref().clone().into(),
15894 ));
15895
15896 client.request(request.unwrap()).await
15897 };
15898
15899 match req_result {
15900 Err(err) => {
15901 if let common::Retry::After(d) = dlg.http_error(&err) {
15902 sleep(d).await;
15903 continue;
15904 }
15905 dlg.finished(false);
15906 return Err(common::Error::HttpError(err));
15907 }
15908 Ok(res) => {
15909 let (mut parts, body) = res.into_parts();
15910 let mut body = common::Body::new(body);
15911 if !parts.status.is_success() {
15912 let bytes = common::to_bytes(body).await.unwrap_or_default();
15913 let error = serde_json::from_str(&common::to_string(&bytes));
15914 let response = common::to_response(parts, bytes.into());
15915
15916 if let common::Retry::After(d) =
15917 dlg.http_failure(&response, error.as_ref().ok())
15918 {
15919 sleep(d).await;
15920 continue;
15921 }
15922
15923 dlg.finished(false);
15924
15925 return Err(match error {
15926 Ok(value) => common::Error::BadRequest(value),
15927 _ => common::Error::Failure(response),
15928 });
15929 }
15930 let response = {
15931 let bytes = common::to_bytes(body).await.unwrap_or_default();
15932 let encoded = common::to_string(&bytes);
15933 match serde_json::from_str(&encoded) {
15934 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15935 Err(error) => {
15936 dlg.response_json_decode_error(&encoded, &error);
15937 return Err(common::Error::JsonDecodeError(
15938 encoded.to_string(),
15939 error,
15940 ));
15941 }
15942 }
15943 };
15944
15945 dlg.finished(true);
15946 return Ok(response);
15947 }
15948 }
15949 }
15950 }
15951
15952 ///
15953 /// Sets the *request* property to the given value.
15954 ///
15955 /// Even though the property as already been set when instantiating this call,
15956 /// we provide this method for API completeness.
15957 pub fn request(
15958 mut self,
15959 new_value: RemoveGitLabConnectedRepositoryRequest,
15960 ) -> ProjectLocationGitLabConfigRemoveGitLabConnectedRepositoryCall<'a, C> {
15961 self._request = new_value;
15962 self
15963 }
15964 /// Required. The name of the `GitLabConfig` to remove a connected repository. Format: `projects/{project}/locations/{location}/gitLabConfigs/{config}`
15965 ///
15966 /// Sets the *config* path property to the given value.
15967 ///
15968 /// Even though the property as already been set when instantiating this call,
15969 /// we provide this method for API completeness.
15970 pub fn config(
15971 mut self,
15972 new_value: &str,
15973 ) -> ProjectLocationGitLabConfigRemoveGitLabConnectedRepositoryCall<'a, C> {
15974 self._config = new_value.to_string();
15975 self
15976 }
15977 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15978 /// while executing the actual API request.
15979 ///
15980 /// ````text
15981 /// It should be used to handle progress information, and to implement a certain level of resilience.
15982 /// ````
15983 ///
15984 /// Sets the *delegate* property to the given value.
15985 pub fn delegate(
15986 mut self,
15987 new_value: &'a mut dyn common::Delegate,
15988 ) -> ProjectLocationGitLabConfigRemoveGitLabConnectedRepositoryCall<'a, C> {
15989 self._delegate = Some(new_value);
15990 self
15991 }
15992
15993 /// Set any additional parameter of the query string used in the request.
15994 /// It should be used to set parameters which are not yet available through their own
15995 /// setters.
15996 ///
15997 /// Please note that this method must not be used to set any of the known parameters
15998 /// which have their own setter method. If done anyway, the request will fail.
15999 ///
16000 /// # Additional Parameters
16001 ///
16002 /// * *$.xgafv* (query-string) - V1 error format.
16003 /// * *access_token* (query-string) - OAuth access token.
16004 /// * *alt* (query-string) - Data format for response.
16005 /// * *callback* (query-string) - JSONP
16006 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16007 /// * *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.
16008 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16009 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16010 /// * *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.
16011 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16012 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16013 pub fn param<T>(
16014 mut self,
16015 name: T,
16016 value: T,
16017 ) -> ProjectLocationGitLabConfigRemoveGitLabConnectedRepositoryCall<'a, C>
16018 where
16019 T: AsRef<str>,
16020 {
16021 self._additional_params
16022 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16023 self
16024 }
16025
16026 /// Identifies the authorization scope for the method you are building.
16027 ///
16028 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16029 /// [`Scope::CloudPlatform`].
16030 ///
16031 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16032 /// tokens for more than one scope.
16033 ///
16034 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16035 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16036 /// sufficient, a read-write scope will do as well.
16037 pub fn add_scope<St>(
16038 mut self,
16039 scope: St,
16040 ) -> ProjectLocationGitLabConfigRemoveGitLabConnectedRepositoryCall<'a, C>
16041 where
16042 St: AsRef<str>,
16043 {
16044 self._scopes.insert(String::from(scope.as_ref()));
16045 self
16046 }
16047 /// Identifies the authorization scope(s) for the method you are building.
16048 ///
16049 /// See [`Self::add_scope()`] for details.
16050 pub fn add_scopes<I, St>(
16051 mut self,
16052 scopes: I,
16053 ) -> ProjectLocationGitLabConfigRemoveGitLabConnectedRepositoryCall<'a, C>
16054 where
16055 I: IntoIterator<Item = St>,
16056 St: AsRef<str>,
16057 {
16058 self._scopes
16059 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16060 self
16061 }
16062
16063 /// Removes all scopes, and no default scope will be used either.
16064 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16065 /// for details).
16066 pub fn clear_scopes(
16067 mut self,
16068 ) -> ProjectLocationGitLabConfigRemoveGitLabConnectedRepositoryCall<'a, C> {
16069 self._scopes.clear();
16070 self
16071 }
16072}
16073
16074/// Create an association between a GCP project and a GitHub Enterprise server.
16075///
16076/// A builder for the *locations.githubEnterpriseConfigs.create* method supported by a *project* resource.
16077/// It is not used directly, but through a [`ProjectMethods`] instance.
16078///
16079/// # Example
16080///
16081/// Instantiate a resource method builder
16082///
16083/// ```test_harness,no_run
16084/// # extern crate hyper;
16085/// # extern crate hyper_rustls;
16086/// # extern crate google_cloudbuild1 as cloudbuild1;
16087/// use cloudbuild1::api::GitHubEnterpriseConfig;
16088/// # async fn dox() {
16089/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16090///
16091/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16092/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
16093/// # secret,
16094/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16095/// # ).build().await.unwrap();
16096///
16097/// # let client = hyper_util::client::legacy::Client::builder(
16098/// # hyper_util::rt::TokioExecutor::new()
16099/// # )
16100/// # .build(
16101/// # hyper_rustls::HttpsConnectorBuilder::new()
16102/// # .with_native_roots()
16103/// # .unwrap()
16104/// # .https_or_http()
16105/// # .enable_http1()
16106/// # .build()
16107/// # );
16108/// # let mut hub = CloudBuild::new(client, auth);
16109/// // As the method needs a request, you would usually fill it with the desired information
16110/// // into the respective structure. Some of the parts shown here might not be applicable !
16111/// // Values shown here are possibly random and not representative !
16112/// let mut req = GitHubEnterpriseConfig::default();
16113///
16114/// // You can configure optional parameters by calling the respective setters at will, and
16115/// // execute the final call using `doit()`.
16116/// // Values shown here are possibly random and not representative !
16117/// let result = hub.projects().locations_github_enterprise_configs_create(req, "parent")
16118/// .project_id("consetetur")
16119/// .ghe_config_id("amet.")
16120/// .doit().await;
16121/// # }
16122/// ```
16123pub struct ProjectLocationGithubEnterpriseConfigCreateCall<'a, C>
16124where
16125 C: 'a,
16126{
16127 hub: &'a CloudBuild<C>,
16128 _request: GitHubEnterpriseConfig,
16129 _parent: String,
16130 _project_id: Option<String>,
16131 _ghe_config_id: Option<String>,
16132 _delegate: Option<&'a mut dyn common::Delegate>,
16133 _additional_params: HashMap<String, String>,
16134 _scopes: BTreeSet<String>,
16135}
16136
16137impl<'a, C> common::CallBuilder for ProjectLocationGithubEnterpriseConfigCreateCall<'a, C> {}
16138
16139impl<'a, C> ProjectLocationGithubEnterpriseConfigCreateCall<'a, C>
16140where
16141 C: common::Connector,
16142{
16143 /// Perform the operation you have build so far.
16144 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
16145 use std::borrow::Cow;
16146 use std::io::{Read, Seek};
16147
16148 use common::{url::Params, ToParts};
16149 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16150
16151 let mut dd = common::DefaultDelegate;
16152 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16153 dlg.begin(common::MethodInfo {
16154 id: "cloudbuild.projects.locations.githubEnterpriseConfigs.create",
16155 http_method: hyper::Method::POST,
16156 });
16157
16158 for &field in ["alt", "parent", "projectId", "gheConfigId"].iter() {
16159 if self._additional_params.contains_key(field) {
16160 dlg.finished(false);
16161 return Err(common::Error::FieldClash(field));
16162 }
16163 }
16164
16165 let mut params = Params::with_capacity(6 + self._additional_params.len());
16166 params.push("parent", self._parent);
16167 if let Some(value) = self._project_id.as_ref() {
16168 params.push("projectId", value);
16169 }
16170 if let Some(value) = self._ghe_config_id.as_ref() {
16171 params.push("gheConfigId", value);
16172 }
16173
16174 params.extend(self._additional_params.iter());
16175
16176 params.push("alt", "json");
16177 let mut url = self.hub._base_url.clone() + "v1/{+parent}/githubEnterpriseConfigs";
16178 if self._scopes.is_empty() {
16179 self._scopes
16180 .insert(Scope::CloudPlatform.as_ref().to_string());
16181 }
16182
16183 #[allow(clippy::single_element_loop)]
16184 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
16185 url = params.uri_replacement(url, param_name, find_this, true);
16186 }
16187 {
16188 let to_remove = ["parent"];
16189 params.remove_params(&to_remove);
16190 }
16191
16192 let url = params.parse_with_url(&url);
16193
16194 let mut json_mime_type = mime::APPLICATION_JSON;
16195 let mut request_value_reader = {
16196 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16197 common::remove_json_null_values(&mut value);
16198 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16199 serde_json::to_writer(&mut dst, &value).unwrap();
16200 dst
16201 };
16202 let request_size = request_value_reader
16203 .seek(std::io::SeekFrom::End(0))
16204 .unwrap();
16205 request_value_reader
16206 .seek(std::io::SeekFrom::Start(0))
16207 .unwrap();
16208
16209 loop {
16210 let token = match self
16211 .hub
16212 .auth
16213 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16214 .await
16215 {
16216 Ok(token) => token,
16217 Err(e) => match dlg.token(e) {
16218 Ok(token) => token,
16219 Err(e) => {
16220 dlg.finished(false);
16221 return Err(common::Error::MissingToken(e));
16222 }
16223 },
16224 };
16225 request_value_reader
16226 .seek(std::io::SeekFrom::Start(0))
16227 .unwrap();
16228 let mut req_result = {
16229 let client = &self.hub.client;
16230 dlg.pre_request();
16231 let mut req_builder = hyper::Request::builder()
16232 .method(hyper::Method::POST)
16233 .uri(url.as_str())
16234 .header(USER_AGENT, self.hub._user_agent.clone());
16235
16236 if let Some(token) = token.as_ref() {
16237 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16238 }
16239
16240 let request = req_builder
16241 .header(CONTENT_TYPE, json_mime_type.to_string())
16242 .header(CONTENT_LENGTH, request_size as u64)
16243 .body(common::to_body(
16244 request_value_reader.get_ref().clone().into(),
16245 ));
16246
16247 client.request(request.unwrap()).await
16248 };
16249
16250 match req_result {
16251 Err(err) => {
16252 if let common::Retry::After(d) = dlg.http_error(&err) {
16253 sleep(d).await;
16254 continue;
16255 }
16256 dlg.finished(false);
16257 return Err(common::Error::HttpError(err));
16258 }
16259 Ok(res) => {
16260 let (mut parts, body) = res.into_parts();
16261 let mut body = common::Body::new(body);
16262 if !parts.status.is_success() {
16263 let bytes = common::to_bytes(body).await.unwrap_or_default();
16264 let error = serde_json::from_str(&common::to_string(&bytes));
16265 let response = common::to_response(parts, bytes.into());
16266
16267 if let common::Retry::After(d) =
16268 dlg.http_failure(&response, error.as_ref().ok())
16269 {
16270 sleep(d).await;
16271 continue;
16272 }
16273
16274 dlg.finished(false);
16275
16276 return Err(match error {
16277 Ok(value) => common::Error::BadRequest(value),
16278 _ => common::Error::Failure(response),
16279 });
16280 }
16281 let response = {
16282 let bytes = common::to_bytes(body).await.unwrap_or_default();
16283 let encoded = common::to_string(&bytes);
16284 match serde_json::from_str(&encoded) {
16285 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16286 Err(error) => {
16287 dlg.response_json_decode_error(&encoded, &error);
16288 return Err(common::Error::JsonDecodeError(
16289 encoded.to_string(),
16290 error,
16291 ));
16292 }
16293 }
16294 };
16295
16296 dlg.finished(true);
16297 return Ok(response);
16298 }
16299 }
16300 }
16301 }
16302
16303 ///
16304 /// Sets the *request* property to the given value.
16305 ///
16306 /// Even though the property as already been set when instantiating this call,
16307 /// we provide this method for API completeness.
16308 pub fn request(
16309 mut self,
16310 new_value: GitHubEnterpriseConfig,
16311 ) -> ProjectLocationGithubEnterpriseConfigCreateCall<'a, C> {
16312 self._request = new_value;
16313 self
16314 }
16315 /// Required. Name of the parent project. For example: projects/{$project_number} or projects/{$project_id}
16316 ///
16317 /// Sets the *parent* path property to the given value.
16318 ///
16319 /// Even though the property as already been set when instantiating this call,
16320 /// we provide this method for API completeness.
16321 pub fn parent(
16322 mut self,
16323 new_value: &str,
16324 ) -> ProjectLocationGithubEnterpriseConfigCreateCall<'a, C> {
16325 self._parent = new_value.to_string();
16326 self
16327 }
16328 /// ID of the project.
16329 ///
16330 /// Sets the *project id* query property to the given value.
16331 pub fn project_id(
16332 mut self,
16333 new_value: &str,
16334 ) -> ProjectLocationGithubEnterpriseConfigCreateCall<'a, C> {
16335 self._project_id = Some(new_value.to_string());
16336 self
16337 }
16338 /// Optional. The ID to use for the GithubEnterpriseConfig, which will become the final component of the GithubEnterpriseConfig's resource name. ghe_config_id must meet the following requirements: + They must contain only alphanumeric characters and dashes. + They can be 1-64 characters long. + They must begin and end with an alphanumeric character
16339 ///
16340 /// Sets the *ghe config id* query property to the given value.
16341 pub fn ghe_config_id(
16342 mut self,
16343 new_value: &str,
16344 ) -> ProjectLocationGithubEnterpriseConfigCreateCall<'a, C> {
16345 self._ghe_config_id = Some(new_value.to_string());
16346 self
16347 }
16348 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16349 /// while executing the actual API request.
16350 ///
16351 /// ````text
16352 /// It should be used to handle progress information, and to implement a certain level of resilience.
16353 /// ````
16354 ///
16355 /// Sets the *delegate* property to the given value.
16356 pub fn delegate(
16357 mut self,
16358 new_value: &'a mut dyn common::Delegate,
16359 ) -> ProjectLocationGithubEnterpriseConfigCreateCall<'a, C> {
16360 self._delegate = Some(new_value);
16361 self
16362 }
16363
16364 /// Set any additional parameter of the query string used in the request.
16365 /// It should be used to set parameters which are not yet available through their own
16366 /// setters.
16367 ///
16368 /// Please note that this method must not be used to set any of the known parameters
16369 /// which have their own setter method. If done anyway, the request will fail.
16370 ///
16371 /// # Additional Parameters
16372 ///
16373 /// * *$.xgafv* (query-string) - V1 error format.
16374 /// * *access_token* (query-string) - OAuth access token.
16375 /// * *alt* (query-string) - Data format for response.
16376 /// * *callback* (query-string) - JSONP
16377 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16378 /// * *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.
16379 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16380 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16381 /// * *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.
16382 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16383 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16384 pub fn param<T>(
16385 mut self,
16386 name: T,
16387 value: T,
16388 ) -> ProjectLocationGithubEnterpriseConfigCreateCall<'a, C>
16389 where
16390 T: AsRef<str>,
16391 {
16392 self._additional_params
16393 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16394 self
16395 }
16396
16397 /// Identifies the authorization scope for the method you are building.
16398 ///
16399 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16400 /// [`Scope::CloudPlatform`].
16401 ///
16402 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16403 /// tokens for more than one scope.
16404 ///
16405 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16406 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16407 /// sufficient, a read-write scope will do as well.
16408 pub fn add_scope<St>(
16409 mut self,
16410 scope: St,
16411 ) -> ProjectLocationGithubEnterpriseConfigCreateCall<'a, C>
16412 where
16413 St: AsRef<str>,
16414 {
16415 self._scopes.insert(String::from(scope.as_ref()));
16416 self
16417 }
16418 /// Identifies the authorization scope(s) for the method you are building.
16419 ///
16420 /// See [`Self::add_scope()`] for details.
16421 pub fn add_scopes<I, St>(
16422 mut self,
16423 scopes: I,
16424 ) -> ProjectLocationGithubEnterpriseConfigCreateCall<'a, C>
16425 where
16426 I: IntoIterator<Item = St>,
16427 St: AsRef<str>,
16428 {
16429 self._scopes
16430 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16431 self
16432 }
16433
16434 /// Removes all scopes, and no default scope will be used either.
16435 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16436 /// for details).
16437 pub fn clear_scopes(mut self) -> ProjectLocationGithubEnterpriseConfigCreateCall<'a, C> {
16438 self._scopes.clear();
16439 self
16440 }
16441}
16442
16443/// Delete an association between a GCP project and a GitHub Enterprise server.
16444///
16445/// A builder for the *locations.githubEnterpriseConfigs.delete* method supported by a *project* resource.
16446/// It is not used directly, but through a [`ProjectMethods`] instance.
16447///
16448/// # Example
16449///
16450/// Instantiate a resource method builder
16451///
16452/// ```test_harness,no_run
16453/// # extern crate hyper;
16454/// # extern crate hyper_rustls;
16455/// # extern crate google_cloudbuild1 as cloudbuild1;
16456/// # async fn dox() {
16457/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16458///
16459/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16460/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
16461/// # secret,
16462/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16463/// # ).build().await.unwrap();
16464///
16465/// # let client = hyper_util::client::legacy::Client::builder(
16466/// # hyper_util::rt::TokioExecutor::new()
16467/// # )
16468/// # .build(
16469/// # hyper_rustls::HttpsConnectorBuilder::new()
16470/// # .with_native_roots()
16471/// # .unwrap()
16472/// # .https_or_http()
16473/// # .enable_http1()
16474/// # .build()
16475/// # );
16476/// # let mut hub = CloudBuild::new(client, auth);
16477/// // You can configure optional parameters by calling the respective setters at will, and
16478/// // execute the final call using `doit()`.
16479/// // Values shown here are possibly random and not representative !
16480/// let result = hub.projects().locations_github_enterprise_configs_delete("name")
16481/// .project_id("takimata")
16482/// .config_id("dolores")
16483/// .doit().await;
16484/// # }
16485/// ```
16486pub struct ProjectLocationGithubEnterpriseConfigDeleteCall<'a, C>
16487where
16488 C: 'a,
16489{
16490 hub: &'a CloudBuild<C>,
16491 _name: String,
16492 _project_id: Option<String>,
16493 _config_id: Option<String>,
16494 _delegate: Option<&'a mut dyn common::Delegate>,
16495 _additional_params: HashMap<String, String>,
16496 _scopes: BTreeSet<String>,
16497}
16498
16499impl<'a, C> common::CallBuilder for ProjectLocationGithubEnterpriseConfigDeleteCall<'a, C> {}
16500
16501impl<'a, C> ProjectLocationGithubEnterpriseConfigDeleteCall<'a, C>
16502where
16503 C: common::Connector,
16504{
16505 /// Perform the operation you have build so far.
16506 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
16507 use std::borrow::Cow;
16508 use std::io::{Read, Seek};
16509
16510 use common::{url::Params, ToParts};
16511 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16512
16513 let mut dd = common::DefaultDelegate;
16514 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16515 dlg.begin(common::MethodInfo {
16516 id: "cloudbuild.projects.locations.githubEnterpriseConfigs.delete",
16517 http_method: hyper::Method::DELETE,
16518 });
16519
16520 for &field in ["alt", "name", "projectId", "configId"].iter() {
16521 if self._additional_params.contains_key(field) {
16522 dlg.finished(false);
16523 return Err(common::Error::FieldClash(field));
16524 }
16525 }
16526
16527 let mut params = Params::with_capacity(5 + self._additional_params.len());
16528 params.push("name", self._name);
16529 if let Some(value) = self._project_id.as_ref() {
16530 params.push("projectId", value);
16531 }
16532 if let Some(value) = self._config_id.as_ref() {
16533 params.push("configId", value);
16534 }
16535
16536 params.extend(self._additional_params.iter());
16537
16538 params.push("alt", "json");
16539 let mut url = self.hub._base_url.clone() + "v1/{+name}";
16540 if self._scopes.is_empty() {
16541 self._scopes
16542 .insert(Scope::CloudPlatform.as_ref().to_string());
16543 }
16544
16545 #[allow(clippy::single_element_loop)]
16546 for &(find_this, param_name) in [("{+name}", "name")].iter() {
16547 url = params.uri_replacement(url, param_name, find_this, true);
16548 }
16549 {
16550 let to_remove = ["name"];
16551 params.remove_params(&to_remove);
16552 }
16553
16554 let url = params.parse_with_url(&url);
16555
16556 loop {
16557 let token = match self
16558 .hub
16559 .auth
16560 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16561 .await
16562 {
16563 Ok(token) => token,
16564 Err(e) => match dlg.token(e) {
16565 Ok(token) => token,
16566 Err(e) => {
16567 dlg.finished(false);
16568 return Err(common::Error::MissingToken(e));
16569 }
16570 },
16571 };
16572 let mut req_result = {
16573 let client = &self.hub.client;
16574 dlg.pre_request();
16575 let mut req_builder = hyper::Request::builder()
16576 .method(hyper::Method::DELETE)
16577 .uri(url.as_str())
16578 .header(USER_AGENT, self.hub._user_agent.clone());
16579
16580 if let Some(token) = token.as_ref() {
16581 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16582 }
16583
16584 let request = req_builder
16585 .header(CONTENT_LENGTH, 0_u64)
16586 .body(common::to_body::<String>(None));
16587
16588 client.request(request.unwrap()).await
16589 };
16590
16591 match req_result {
16592 Err(err) => {
16593 if let common::Retry::After(d) = dlg.http_error(&err) {
16594 sleep(d).await;
16595 continue;
16596 }
16597 dlg.finished(false);
16598 return Err(common::Error::HttpError(err));
16599 }
16600 Ok(res) => {
16601 let (mut parts, body) = res.into_parts();
16602 let mut body = common::Body::new(body);
16603 if !parts.status.is_success() {
16604 let bytes = common::to_bytes(body).await.unwrap_or_default();
16605 let error = serde_json::from_str(&common::to_string(&bytes));
16606 let response = common::to_response(parts, bytes.into());
16607
16608 if let common::Retry::After(d) =
16609 dlg.http_failure(&response, error.as_ref().ok())
16610 {
16611 sleep(d).await;
16612 continue;
16613 }
16614
16615 dlg.finished(false);
16616
16617 return Err(match error {
16618 Ok(value) => common::Error::BadRequest(value),
16619 _ => common::Error::Failure(response),
16620 });
16621 }
16622 let response = {
16623 let bytes = common::to_bytes(body).await.unwrap_or_default();
16624 let encoded = common::to_string(&bytes);
16625 match serde_json::from_str(&encoded) {
16626 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16627 Err(error) => {
16628 dlg.response_json_decode_error(&encoded, &error);
16629 return Err(common::Error::JsonDecodeError(
16630 encoded.to_string(),
16631 error,
16632 ));
16633 }
16634 }
16635 };
16636
16637 dlg.finished(true);
16638 return Ok(response);
16639 }
16640 }
16641 }
16642 }
16643
16644 /// This field should contain the name of the enterprise config resource. For example: "projects/{$project_id}/locations/{$location_id}/githubEnterpriseConfigs/{$config_id}"
16645 ///
16646 /// Sets the *name* path property to the given value.
16647 ///
16648 /// Even though the property as already been set when instantiating this call,
16649 /// we provide this method for API completeness.
16650 pub fn name(
16651 mut self,
16652 new_value: &str,
16653 ) -> ProjectLocationGithubEnterpriseConfigDeleteCall<'a, C> {
16654 self._name = new_value.to_string();
16655 self
16656 }
16657 /// ID of the project
16658 ///
16659 /// Sets the *project id* query property to the given value.
16660 pub fn project_id(
16661 mut self,
16662 new_value: &str,
16663 ) -> ProjectLocationGithubEnterpriseConfigDeleteCall<'a, C> {
16664 self._project_id = Some(new_value.to_string());
16665 self
16666 }
16667 /// Unique identifier of the `GitHubEnterpriseConfig`
16668 ///
16669 /// Sets the *config id* query property to the given value.
16670 pub fn config_id(
16671 mut self,
16672 new_value: &str,
16673 ) -> ProjectLocationGithubEnterpriseConfigDeleteCall<'a, C> {
16674 self._config_id = Some(new_value.to_string());
16675 self
16676 }
16677 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16678 /// while executing the actual API request.
16679 ///
16680 /// ````text
16681 /// It should be used to handle progress information, and to implement a certain level of resilience.
16682 /// ````
16683 ///
16684 /// Sets the *delegate* property to the given value.
16685 pub fn delegate(
16686 mut self,
16687 new_value: &'a mut dyn common::Delegate,
16688 ) -> ProjectLocationGithubEnterpriseConfigDeleteCall<'a, C> {
16689 self._delegate = Some(new_value);
16690 self
16691 }
16692
16693 /// Set any additional parameter of the query string used in the request.
16694 /// It should be used to set parameters which are not yet available through their own
16695 /// setters.
16696 ///
16697 /// Please note that this method must not be used to set any of the known parameters
16698 /// which have their own setter method. If done anyway, the request will fail.
16699 ///
16700 /// # Additional Parameters
16701 ///
16702 /// * *$.xgafv* (query-string) - V1 error format.
16703 /// * *access_token* (query-string) - OAuth access token.
16704 /// * *alt* (query-string) - Data format for response.
16705 /// * *callback* (query-string) - JSONP
16706 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16707 /// * *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.
16708 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16709 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16710 /// * *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.
16711 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16712 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16713 pub fn param<T>(
16714 mut self,
16715 name: T,
16716 value: T,
16717 ) -> ProjectLocationGithubEnterpriseConfigDeleteCall<'a, C>
16718 where
16719 T: AsRef<str>,
16720 {
16721 self._additional_params
16722 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16723 self
16724 }
16725
16726 /// Identifies the authorization scope for the method you are building.
16727 ///
16728 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16729 /// [`Scope::CloudPlatform`].
16730 ///
16731 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16732 /// tokens for more than one scope.
16733 ///
16734 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16735 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16736 /// sufficient, a read-write scope will do as well.
16737 pub fn add_scope<St>(
16738 mut self,
16739 scope: St,
16740 ) -> ProjectLocationGithubEnterpriseConfigDeleteCall<'a, C>
16741 where
16742 St: AsRef<str>,
16743 {
16744 self._scopes.insert(String::from(scope.as_ref()));
16745 self
16746 }
16747 /// Identifies the authorization scope(s) for the method you are building.
16748 ///
16749 /// See [`Self::add_scope()`] for details.
16750 pub fn add_scopes<I, St>(
16751 mut self,
16752 scopes: I,
16753 ) -> ProjectLocationGithubEnterpriseConfigDeleteCall<'a, C>
16754 where
16755 I: IntoIterator<Item = St>,
16756 St: AsRef<str>,
16757 {
16758 self._scopes
16759 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16760 self
16761 }
16762
16763 /// Removes all scopes, and no default scope will be used either.
16764 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16765 /// for details).
16766 pub fn clear_scopes(mut self) -> ProjectLocationGithubEnterpriseConfigDeleteCall<'a, C> {
16767 self._scopes.clear();
16768 self
16769 }
16770}
16771
16772/// Retrieve a GitHubEnterpriseConfig.
16773///
16774/// A builder for the *locations.githubEnterpriseConfigs.get* method supported by a *project* resource.
16775/// It is not used directly, but through a [`ProjectMethods`] instance.
16776///
16777/// # Example
16778///
16779/// Instantiate a resource method builder
16780///
16781/// ```test_harness,no_run
16782/// # extern crate hyper;
16783/// # extern crate hyper_rustls;
16784/// # extern crate google_cloudbuild1 as cloudbuild1;
16785/// # async fn dox() {
16786/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16787///
16788/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16789/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
16790/// # secret,
16791/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16792/// # ).build().await.unwrap();
16793///
16794/// # let client = hyper_util::client::legacy::Client::builder(
16795/// # hyper_util::rt::TokioExecutor::new()
16796/// # )
16797/// # .build(
16798/// # hyper_rustls::HttpsConnectorBuilder::new()
16799/// # .with_native_roots()
16800/// # .unwrap()
16801/// # .https_or_http()
16802/// # .enable_http1()
16803/// # .build()
16804/// # );
16805/// # let mut hub = CloudBuild::new(client, auth);
16806/// // You can configure optional parameters by calling the respective setters at will, and
16807/// // execute the final call using `doit()`.
16808/// // Values shown here are possibly random and not representative !
16809/// let result = hub.projects().locations_github_enterprise_configs_get("name")
16810/// .project_id("et")
16811/// .config_id("accusam")
16812/// .doit().await;
16813/// # }
16814/// ```
16815pub struct ProjectLocationGithubEnterpriseConfigGetCall<'a, C>
16816where
16817 C: 'a,
16818{
16819 hub: &'a CloudBuild<C>,
16820 _name: String,
16821 _project_id: Option<String>,
16822 _config_id: Option<String>,
16823 _delegate: Option<&'a mut dyn common::Delegate>,
16824 _additional_params: HashMap<String, String>,
16825 _scopes: BTreeSet<String>,
16826}
16827
16828impl<'a, C> common::CallBuilder for ProjectLocationGithubEnterpriseConfigGetCall<'a, C> {}
16829
16830impl<'a, C> ProjectLocationGithubEnterpriseConfigGetCall<'a, C>
16831where
16832 C: common::Connector,
16833{
16834 /// Perform the operation you have build so far.
16835 pub async fn doit(mut self) -> common::Result<(common::Response, GitHubEnterpriseConfig)> {
16836 use std::borrow::Cow;
16837 use std::io::{Read, Seek};
16838
16839 use common::{url::Params, ToParts};
16840 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16841
16842 let mut dd = common::DefaultDelegate;
16843 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16844 dlg.begin(common::MethodInfo {
16845 id: "cloudbuild.projects.locations.githubEnterpriseConfigs.get",
16846 http_method: hyper::Method::GET,
16847 });
16848
16849 for &field in ["alt", "name", "projectId", "configId"].iter() {
16850 if self._additional_params.contains_key(field) {
16851 dlg.finished(false);
16852 return Err(common::Error::FieldClash(field));
16853 }
16854 }
16855
16856 let mut params = Params::with_capacity(5 + self._additional_params.len());
16857 params.push("name", self._name);
16858 if let Some(value) = self._project_id.as_ref() {
16859 params.push("projectId", value);
16860 }
16861 if let Some(value) = self._config_id.as_ref() {
16862 params.push("configId", value);
16863 }
16864
16865 params.extend(self._additional_params.iter());
16866
16867 params.push("alt", "json");
16868 let mut url = self.hub._base_url.clone() + "v1/{+name}";
16869 if self._scopes.is_empty() {
16870 self._scopes
16871 .insert(Scope::CloudPlatform.as_ref().to_string());
16872 }
16873
16874 #[allow(clippy::single_element_loop)]
16875 for &(find_this, param_name) in [("{+name}", "name")].iter() {
16876 url = params.uri_replacement(url, param_name, find_this, true);
16877 }
16878 {
16879 let to_remove = ["name"];
16880 params.remove_params(&to_remove);
16881 }
16882
16883 let url = params.parse_with_url(&url);
16884
16885 loop {
16886 let token = match self
16887 .hub
16888 .auth
16889 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16890 .await
16891 {
16892 Ok(token) => token,
16893 Err(e) => match dlg.token(e) {
16894 Ok(token) => token,
16895 Err(e) => {
16896 dlg.finished(false);
16897 return Err(common::Error::MissingToken(e));
16898 }
16899 },
16900 };
16901 let mut req_result = {
16902 let client = &self.hub.client;
16903 dlg.pre_request();
16904 let mut req_builder = hyper::Request::builder()
16905 .method(hyper::Method::GET)
16906 .uri(url.as_str())
16907 .header(USER_AGENT, self.hub._user_agent.clone());
16908
16909 if let Some(token) = token.as_ref() {
16910 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16911 }
16912
16913 let request = req_builder
16914 .header(CONTENT_LENGTH, 0_u64)
16915 .body(common::to_body::<String>(None));
16916
16917 client.request(request.unwrap()).await
16918 };
16919
16920 match req_result {
16921 Err(err) => {
16922 if let common::Retry::After(d) = dlg.http_error(&err) {
16923 sleep(d).await;
16924 continue;
16925 }
16926 dlg.finished(false);
16927 return Err(common::Error::HttpError(err));
16928 }
16929 Ok(res) => {
16930 let (mut parts, body) = res.into_parts();
16931 let mut body = common::Body::new(body);
16932 if !parts.status.is_success() {
16933 let bytes = common::to_bytes(body).await.unwrap_or_default();
16934 let error = serde_json::from_str(&common::to_string(&bytes));
16935 let response = common::to_response(parts, bytes.into());
16936
16937 if let common::Retry::After(d) =
16938 dlg.http_failure(&response, error.as_ref().ok())
16939 {
16940 sleep(d).await;
16941 continue;
16942 }
16943
16944 dlg.finished(false);
16945
16946 return Err(match error {
16947 Ok(value) => common::Error::BadRequest(value),
16948 _ => common::Error::Failure(response),
16949 });
16950 }
16951 let response = {
16952 let bytes = common::to_bytes(body).await.unwrap_or_default();
16953 let encoded = common::to_string(&bytes);
16954 match serde_json::from_str(&encoded) {
16955 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16956 Err(error) => {
16957 dlg.response_json_decode_error(&encoded, &error);
16958 return Err(common::Error::JsonDecodeError(
16959 encoded.to_string(),
16960 error,
16961 ));
16962 }
16963 }
16964 };
16965
16966 dlg.finished(true);
16967 return Ok(response);
16968 }
16969 }
16970 }
16971 }
16972
16973 /// This field should contain the name of the enterprise config resource. For example: "projects/{$project_id}/locations/{$location_id}/githubEnterpriseConfigs/{$config_id}"
16974 ///
16975 /// Sets the *name* path property to the given value.
16976 ///
16977 /// Even though the property as already been set when instantiating this call,
16978 /// we provide this method for API completeness.
16979 pub fn name(mut self, new_value: &str) -> ProjectLocationGithubEnterpriseConfigGetCall<'a, C> {
16980 self._name = new_value.to_string();
16981 self
16982 }
16983 /// ID of the project
16984 ///
16985 /// Sets the *project id* query property to the given value.
16986 pub fn project_id(
16987 mut self,
16988 new_value: &str,
16989 ) -> ProjectLocationGithubEnterpriseConfigGetCall<'a, C> {
16990 self._project_id = Some(new_value.to_string());
16991 self
16992 }
16993 /// Unique identifier of the `GitHubEnterpriseConfig`
16994 ///
16995 /// Sets the *config id* query property to the given value.
16996 pub fn config_id(
16997 mut self,
16998 new_value: &str,
16999 ) -> ProjectLocationGithubEnterpriseConfigGetCall<'a, C> {
17000 self._config_id = Some(new_value.to_string());
17001 self
17002 }
17003 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17004 /// while executing the actual API request.
17005 ///
17006 /// ````text
17007 /// It should be used to handle progress information, and to implement a certain level of resilience.
17008 /// ````
17009 ///
17010 /// Sets the *delegate* property to the given value.
17011 pub fn delegate(
17012 mut self,
17013 new_value: &'a mut dyn common::Delegate,
17014 ) -> ProjectLocationGithubEnterpriseConfigGetCall<'a, C> {
17015 self._delegate = Some(new_value);
17016 self
17017 }
17018
17019 /// Set any additional parameter of the query string used in the request.
17020 /// It should be used to set parameters which are not yet available through their own
17021 /// setters.
17022 ///
17023 /// Please note that this method must not be used to set any of the known parameters
17024 /// which have their own setter method. If done anyway, the request will fail.
17025 ///
17026 /// # Additional Parameters
17027 ///
17028 /// * *$.xgafv* (query-string) - V1 error format.
17029 /// * *access_token* (query-string) - OAuth access token.
17030 /// * *alt* (query-string) - Data format for response.
17031 /// * *callback* (query-string) - JSONP
17032 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17033 /// * *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.
17034 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17035 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17036 /// * *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.
17037 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17038 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17039 pub fn param<T>(
17040 mut self,
17041 name: T,
17042 value: T,
17043 ) -> ProjectLocationGithubEnterpriseConfigGetCall<'a, C>
17044 where
17045 T: AsRef<str>,
17046 {
17047 self._additional_params
17048 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17049 self
17050 }
17051
17052 /// Identifies the authorization scope for the method you are building.
17053 ///
17054 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17055 /// [`Scope::CloudPlatform`].
17056 ///
17057 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17058 /// tokens for more than one scope.
17059 ///
17060 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17061 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17062 /// sufficient, a read-write scope will do as well.
17063 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGithubEnterpriseConfigGetCall<'a, C>
17064 where
17065 St: AsRef<str>,
17066 {
17067 self._scopes.insert(String::from(scope.as_ref()));
17068 self
17069 }
17070 /// Identifies the authorization scope(s) for the method you are building.
17071 ///
17072 /// See [`Self::add_scope()`] for details.
17073 pub fn add_scopes<I, St>(
17074 mut self,
17075 scopes: I,
17076 ) -> ProjectLocationGithubEnterpriseConfigGetCall<'a, C>
17077 where
17078 I: IntoIterator<Item = St>,
17079 St: AsRef<str>,
17080 {
17081 self._scopes
17082 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17083 self
17084 }
17085
17086 /// Removes all scopes, and no default scope will be used either.
17087 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17088 /// for details).
17089 pub fn clear_scopes(mut self) -> ProjectLocationGithubEnterpriseConfigGetCall<'a, C> {
17090 self._scopes.clear();
17091 self
17092 }
17093}
17094
17095/// List all GitHubEnterpriseConfigs for a given project.
17096///
17097/// A builder for the *locations.githubEnterpriseConfigs.list* method supported by a *project* resource.
17098/// It is not used directly, but through a [`ProjectMethods`] instance.
17099///
17100/// # Example
17101///
17102/// Instantiate a resource method builder
17103///
17104/// ```test_harness,no_run
17105/// # extern crate hyper;
17106/// # extern crate hyper_rustls;
17107/// # extern crate google_cloudbuild1 as cloudbuild1;
17108/// # async fn dox() {
17109/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17110///
17111/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17112/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
17113/// # secret,
17114/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17115/// # ).build().await.unwrap();
17116///
17117/// # let client = hyper_util::client::legacy::Client::builder(
17118/// # hyper_util::rt::TokioExecutor::new()
17119/// # )
17120/// # .build(
17121/// # hyper_rustls::HttpsConnectorBuilder::new()
17122/// # .with_native_roots()
17123/// # .unwrap()
17124/// # .https_or_http()
17125/// # .enable_http1()
17126/// # .build()
17127/// # );
17128/// # let mut hub = CloudBuild::new(client, auth);
17129/// // You can configure optional parameters by calling the respective setters at will, and
17130/// // execute the final call using `doit()`.
17131/// // Values shown here are possibly random and not representative !
17132/// let result = hub.projects().locations_github_enterprise_configs_list("parent")
17133/// .project_id("dolore")
17134/// .doit().await;
17135/// # }
17136/// ```
17137pub struct ProjectLocationGithubEnterpriseConfigListCall<'a, C>
17138where
17139 C: 'a,
17140{
17141 hub: &'a CloudBuild<C>,
17142 _parent: String,
17143 _project_id: Option<String>,
17144 _delegate: Option<&'a mut dyn common::Delegate>,
17145 _additional_params: HashMap<String, String>,
17146 _scopes: BTreeSet<String>,
17147}
17148
17149impl<'a, C> common::CallBuilder for ProjectLocationGithubEnterpriseConfigListCall<'a, C> {}
17150
17151impl<'a, C> ProjectLocationGithubEnterpriseConfigListCall<'a, C>
17152where
17153 C: common::Connector,
17154{
17155 /// Perform the operation you have build so far.
17156 pub async fn doit(
17157 mut self,
17158 ) -> common::Result<(common::Response, ListGithubEnterpriseConfigsResponse)> {
17159 use std::borrow::Cow;
17160 use std::io::{Read, Seek};
17161
17162 use common::{url::Params, ToParts};
17163 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17164
17165 let mut dd = common::DefaultDelegate;
17166 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17167 dlg.begin(common::MethodInfo {
17168 id: "cloudbuild.projects.locations.githubEnterpriseConfigs.list",
17169 http_method: hyper::Method::GET,
17170 });
17171
17172 for &field in ["alt", "parent", "projectId"].iter() {
17173 if self._additional_params.contains_key(field) {
17174 dlg.finished(false);
17175 return Err(common::Error::FieldClash(field));
17176 }
17177 }
17178
17179 let mut params = Params::with_capacity(4 + self._additional_params.len());
17180 params.push("parent", self._parent);
17181 if let Some(value) = self._project_id.as_ref() {
17182 params.push("projectId", value);
17183 }
17184
17185 params.extend(self._additional_params.iter());
17186
17187 params.push("alt", "json");
17188 let mut url = self.hub._base_url.clone() + "v1/{+parent}/githubEnterpriseConfigs";
17189 if self._scopes.is_empty() {
17190 self._scopes
17191 .insert(Scope::CloudPlatform.as_ref().to_string());
17192 }
17193
17194 #[allow(clippy::single_element_loop)]
17195 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
17196 url = params.uri_replacement(url, param_name, find_this, true);
17197 }
17198 {
17199 let to_remove = ["parent"];
17200 params.remove_params(&to_remove);
17201 }
17202
17203 let url = params.parse_with_url(&url);
17204
17205 loop {
17206 let token = match self
17207 .hub
17208 .auth
17209 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17210 .await
17211 {
17212 Ok(token) => token,
17213 Err(e) => match dlg.token(e) {
17214 Ok(token) => token,
17215 Err(e) => {
17216 dlg.finished(false);
17217 return Err(common::Error::MissingToken(e));
17218 }
17219 },
17220 };
17221 let mut req_result = {
17222 let client = &self.hub.client;
17223 dlg.pre_request();
17224 let mut req_builder = hyper::Request::builder()
17225 .method(hyper::Method::GET)
17226 .uri(url.as_str())
17227 .header(USER_AGENT, self.hub._user_agent.clone());
17228
17229 if let Some(token) = token.as_ref() {
17230 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17231 }
17232
17233 let request = req_builder
17234 .header(CONTENT_LENGTH, 0_u64)
17235 .body(common::to_body::<String>(None));
17236
17237 client.request(request.unwrap()).await
17238 };
17239
17240 match req_result {
17241 Err(err) => {
17242 if let common::Retry::After(d) = dlg.http_error(&err) {
17243 sleep(d).await;
17244 continue;
17245 }
17246 dlg.finished(false);
17247 return Err(common::Error::HttpError(err));
17248 }
17249 Ok(res) => {
17250 let (mut parts, body) = res.into_parts();
17251 let mut body = common::Body::new(body);
17252 if !parts.status.is_success() {
17253 let bytes = common::to_bytes(body).await.unwrap_or_default();
17254 let error = serde_json::from_str(&common::to_string(&bytes));
17255 let response = common::to_response(parts, bytes.into());
17256
17257 if let common::Retry::After(d) =
17258 dlg.http_failure(&response, error.as_ref().ok())
17259 {
17260 sleep(d).await;
17261 continue;
17262 }
17263
17264 dlg.finished(false);
17265
17266 return Err(match error {
17267 Ok(value) => common::Error::BadRequest(value),
17268 _ => common::Error::Failure(response),
17269 });
17270 }
17271 let response = {
17272 let bytes = common::to_bytes(body).await.unwrap_or_default();
17273 let encoded = common::to_string(&bytes);
17274 match serde_json::from_str(&encoded) {
17275 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17276 Err(error) => {
17277 dlg.response_json_decode_error(&encoded, &error);
17278 return Err(common::Error::JsonDecodeError(
17279 encoded.to_string(),
17280 error,
17281 ));
17282 }
17283 }
17284 };
17285
17286 dlg.finished(true);
17287 return Ok(response);
17288 }
17289 }
17290 }
17291 }
17292
17293 /// Name of the parent project. For example: projects/{$project_number} or projects/{$project_id}
17294 ///
17295 /// Sets the *parent* path property to the given value.
17296 ///
17297 /// Even though the property as already been set when instantiating this call,
17298 /// we provide this method for API completeness.
17299 pub fn parent(
17300 mut self,
17301 new_value: &str,
17302 ) -> ProjectLocationGithubEnterpriseConfigListCall<'a, C> {
17303 self._parent = new_value.to_string();
17304 self
17305 }
17306 /// ID of the project
17307 ///
17308 /// Sets the *project id* query property to the given value.
17309 pub fn project_id(
17310 mut self,
17311 new_value: &str,
17312 ) -> ProjectLocationGithubEnterpriseConfigListCall<'a, C> {
17313 self._project_id = Some(new_value.to_string());
17314 self
17315 }
17316 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17317 /// while executing the actual API request.
17318 ///
17319 /// ````text
17320 /// It should be used to handle progress information, and to implement a certain level of resilience.
17321 /// ````
17322 ///
17323 /// Sets the *delegate* property to the given value.
17324 pub fn delegate(
17325 mut self,
17326 new_value: &'a mut dyn common::Delegate,
17327 ) -> ProjectLocationGithubEnterpriseConfigListCall<'a, C> {
17328 self._delegate = Some(new_value);
17329 self
17330 }
17331
17332 /// Set any additional parameter of the query string used in the request.
17333 /// It should be used to set parameters which are not yet available through their own
17334 /// setters.
17335 ///
17336 /// Please note that this method must not be used to set any of the known parameters
17337 /// which have their own setter method. If done anyway, the request will fail.
17338 ///
17339 /// # Additional Parameters
17340 ///
17341 /// * *$.xgafv* (query-string) - V1 error format.
17342 /// * *access_token* (query-string) - OAuth access token.
17343 /// * *alt* (query-string) - Data format for response.
17344 /// * *callback* (query-string) - JSONP
17345 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17346 /// * *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.
17347 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17348 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17349 /// * *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.
17350 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17351 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17352 pub fn param<T>(
17353 mut self,
17354 name: T,
17355 value: T,
17356 ) -> ProjectLocationGithubEnterpriseConfigListCall<'a, C>
17357 where
17358 T: AsRef<str>,
17359 {
17360 self._additional_params
17361 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17362 self
17363 }
17364
17365 /// Identifies the authorization scope for the method you are building.
17366 ///
17367 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17368 /// [`Scope::CloudPlatform`].
17369 ///
17370 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17371 /// tokens for more than one scope.
17372 ///
17373 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17374 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17375 /// sufficient, a read-write scope will do as well.
17376 pub fn add_scope<St>(
17377 mut self,
17378 scope: St,
17379 ) -> ProjectLocationGithubEnterpriseConfigListCall<'a, C>
17380 where
17381 St: AsRef<str>,
17382 {
17383 self._scopes.insert(String::from(scope.as_ref()));
17384 self
17385 }
17386 /// Identifies the authorization scope(s) for the method you are building.
17387 ///
17388 /// See [`Self::add_scope()`] for details.
17389 pub fn add_scopes<I, St>(
17390 mut self,
17391 scopes: I,
17392 ) -> ProjectLocationGithubEnterpriseConfigListCall<'a, C>
17393 where
17394 I: IntoIterator<Item = St>,
17395 St: AsRef<str>,
17396 {
17397 self._scopes
17398 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17399 self
17400 }
17401
17402 /// Removes all scopes, and no default scope will be used either.
17403 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17404 /// for details).
17405 pub fn clear_scopes(mut self) -> ProjectLocationGithubEnterpriseConfigListCall<'a, C> {
17406 self._scopes.clear();
17407 self
17408 }
17409}
17410
17411/// Update an association between a GCP project and a GitHub Enterprise server.
17412///
17413/// A builder for the *locations.githubEnterpriseConfigs.patch* method supported by a *project* resource.
17414/// It is not used directly, but through a [`ProjectMethods`] instance.
17415///
17416/// # Example
17417///
17418/// Instantiate a resource method builder
17419///
17420/// ```test_harness,no_run
17421/// # extern crate hyper;
17422/// # extern crate hyper_rustls;
17423/// # extern crate google_cloudbuild1 as cloudbuild1;
17424/// use cloudbuild1::api::GitHubEnterpriseConfig;
17425/// # async fn dox() {
17426/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17427///
17428/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17429/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
17430/// # secret,
17431/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17432/// # ).build().await.unwrap();
17433///
17434/// # let client = hyper_util::client::legacy::Client::builder(
17435/// # hyper_util::rt::TokioExecutor::new()
17436/// # )
17437/// # .build(
17438/// # hyper_rustls::HttpsConnectorBuilder::new()
17439/// # .with_native_roots()
17440/// # .unwrap()
17441/// # .https_or_http()
17442/// # .enable_http1()
17443/// # .build()
17444/// # );
17445/// # let mut hub = CloudBuild::new(client, auth);
17446/// // As the method needs a request, you would usually fill it with the desired information
17447/// // into the respective structure. Some of the parts shown here might not be applicable !
17448/// // Values shown here are possibly random and not representative !
17449/// let mut req = GitHubEnterpriseConfig::default();
17450///
17451/// // You can configure optional parameters by calling the respective setters at will, and
17452/// // execute the final call using `doit()`.
17453/// // Values shown here are possibly random and not representative !
17454/// let result = hub.projects().locations_github_enterprise_configs_patch(req, "name")
17455/// .update_mask(FieldMask::new::<&str>(&[]))
17456/// .doit().await;
17457/// # }
17458/// ```
17459pub struct ProjectLocationGithubEnterpriseConfigPatchCall<'a, C>
17460where
17461 C: 'a,
17462{
17463 hub: &'a CloudBuild<C>,
17464 _request: GitHubEnterpriseConfig,
17465 _name: String,
17466 _update_mask: Option<common::FieldMask>,
17467 _delegate: Option<&'a mut dyn common::Delegate>,
17468 _additional_params: HashMap<String, String>,
17469 _scopes: BTreeSet<String>,
17470}
17471
17472impl<'a, C> common::CallBuilder for ProjectLocationGithubEnterpriseConfigPatchCall<'a, C> {}
17473
17474impl<'a, C> ProjectLocationGithubEnterpriseConfigPatchCall<'a, C>
17475where
17476 C: common::Connector,
17477{
17478 /// Perform the operation you have build so far.
17479 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
17480 use std::borrow::Cow;
17481 use std::io::{Read, Seek};
17482
17483 use common::{url::Params, ToParts};
17484 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17485
17486 let mut dd = common::DefaultDelegate;
17487 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17488 dlg.begin(common::MethodInfo {
17489 id: "cloudbuild.projects.locations.githubEnterpriseConfigs.patch",
17490 http_method: hyper::Method::PATCH,
17491 });
17492
17493 for &field in ["alt", "name", "updateMask"].iter() {
17494 if self._additional_params.contains_key(field) {
17495 dlg.finished(false);
17496 return Err(common::Error::FieldClash(field));
17497 }
17498 }
17499
17500 let mut params = Params::with_capacity(5 + self._additional_params.len());
17501 params.push("name", self._name);
17502 if let Some(value) = self._update_mask.as_ref() {
17503 params.push("updateMask", value.to_string());
17504 }
17505
17506 params.extend(self._additional_params.iter());
17507
17508 params.push("alt", "json");
17509 let mut url = self.hub._base_url.clone() + "v1/{+name}";
17510 if self._scopes.is_empty() {
17511 self._scopes
17512 .insert(Scope::CloudPlatform.as_ref().to_string());
17513 }
17514
17515 #[allow(clippy::single_element_loop)]
17516 for &(find_this, param_name) in [("{+name}", "name")].iter() {
17517 url = params.uri_replacement(url, param_name, find_this, true);
17518 }
17519 {
17520 let to_remove = ["name"];
17521 params.remove_params(&to_remove);
17522 }
17523
17524 let url = params.parse_with_url(&url);
17525
17526 let mut json_mime_type = mime::APPLICATION_JSON;
17527 let mut request_value_reader = {
17528 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17529 common::remove_json_null_values(&mut value);
17530 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17531 serde_json::to_writer(&mut dst, &value).unwrap();
17532 dst
17533 };
17534 let request_size = request_value_reader
17535 .seek(std::io::SeekFrom::End(0))
17536 .unwrap();
17537 request_value_reader
17538 .seek(std::io::SeekFrom::Start(0))
17539 .unwrap();
17540
17541 loop {
17542 let token = match self
17543 .hub
17544 .auth
17545 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17546 .await
17547 {
17548 Ok(token) => token,
17549 Err(e) => match dlg.token(e) {
17550 Ok(token) => token,
17551 Err(e) => {
17552 dlg.finished(false);
17553 return Err(common::Error::MissingToken(e));
17554 }
17555 },
17556 };
17557 request_value_reader
17558 .seek(std::io::SeekFrom::Start(0))
17559 .unwrap();
17560 let mut req_result = {
17561 let client = &self.hub.client;
17562 dlg.pre_request();
17563 let mut req_builder = hyper::Request::builder()
17564 .method(hyper::Method::PATCH)
17565 .uri(url.as_str())
17566 .header(USER_AGENT, self.hub._user_agent.clone());
17567
17568 if let Some(token) = token.as_ref() {
17569 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17570 }
17571
17572 let request = req_builder
17573 .header(CONTENT_TYPE, json_mime_type.to_string())
17574 .header(CONTENT_LENGTH, request_size as u64)
17575 .body(common::to_body(
17576 request_value_reader.get_ref().clone().into(),
17577 ));
17578
17579 client.request(request.unwrap()).await
17580 };
17581
17582 match req_result {
17583 Err(err) => {
17584 if let common::Retry::After(d) = dlg.http_error(&err) {
17585 sleep(d).await;
17586 continue;
17587 }
17588 dlg.finished(false);
17589 return Err(common::Error::HttpError(err));
17590 }
17591 Ok(res) => {
17592 let (mut parts, body) = res.into_parts();
17593 let mut body = common::Body::new(body);
17594 if !parts.status.is_success() {
17595 let bytes = common::to_bytes(body).await.unwrap_or_default();
17596 let error = serde_json::from_str(&common::to_string(&bytes));
17597 let response = common::to_response(parts, bytes.into());
17598
17599 if let common::Retry::After(d) =
17600 dlg.http_failure(&response, error.as_ref().ok())
17601 {
17602 sleep(d).await;
17603 continue;
17604 }
17605
17606 dlg.finished(false);
17607
17608 return Err(match error {
17609 Ok(value) => common::Error::BadRequest(value),
17610 _ => common::Error::Failure(response),
17611 });
17612 }
17613 let response = {
17614 let bytes = common::to_bytes(body).await.unwrap_or_default();
17615 let encoded = common::to_string(&bytes);
17616 match serde_json::from_str(&encoded) {
17617 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17618 Err(error) => {
17619 dlg.response_json_decode_error(&encoded, &error);
17620 return Err(common::Error::JsonDecodeError(
17621 encoded.to_string(),
17622 error,
17623 ));
17624 }
17625 }
17626 };
17627
17628 dlg.finished(true);
17629 return Ok(response);
17630 }
17631 }
17632 }
17633 }
17634
17635 ///
17636 /// Sets the *request* property to the given value.
17637 ///
17638 /// Even though the property as already been set when instantiating this call,
17639 /// we provide this method for API completeness.
17640 pub fn request(
17641 mut self,
17642 new_value: GitHubEnterpriseConfig,
17643 ) -> ProjectLocationGithubEnterpriseConfigPatchCall<'a, C> {
17644 self._request = new_value;
17645 self
17646 }
17647 /// The full resource name for the GitHubEnterpriseConfig For example: "projects/{$project_id}/locations/{$location_id}/githubEnterpriseConfigs/{$config_id}"
17648 ///
17649 /// Sets the *name* path property to the given value.
17650 ///
17651 /// Even though the property as already been set when instantiating this call,
17652 /// we provide this method for API completeness.
17653 pub fn name(
17654 mut self,
17655 new_value: &str,
17656 ) -> ProjectLocationGithubEnterpriseConfigPatchCall<'a, C> {
17657 self._name = new_value.to_string();
17658 self
17659 }
17660 /// Update mask for the resource. If this is set, the server will only update the fields specified in the field mask. Otherwise, a full update of the mutable resource fields will be performed.
17661 ///
17662 /// Sets the *update mask* query property to the given value.
17663 pub fn update_mask(
17664 mut self,
17665 new_value: common::FieldMask,
17666 ) -> ProjectLocationGithubEnterpriseConfigPatchCall<'a, C> {
17667 self._update_mask = Some(new_value);
17668 self
17669 }
17670 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17671 /// while executing the actual API request.
17672 ///
17673 /// ````text
17674 /// It should be used to handle progress information, and to implement a certain level of resilience.
17675 /// ````
17676 ///
17677 /// Sets the *delegate* property to the given value.
17678 pub fn delegate(
17679 mut self,
17680 new_value: &'a mut dyn common::Delegate,
17681 ) -> ProjectLocationGithubEnterpriseConfigPatchCall<'a, C> {
17682 self._delegate = Some(new_value);
17683 self
17684 }
17685
17686 /// Set any additional parameter of the query string used in the request.
17687 /// It should be used to set parameters which are not yet available through their own
17688 /// setters.
17689 ///
17690 /// Please note that this method must not be used to set any of the known parameters
17691 /// which have their own setter method. If done anyway, the request will fail.
17692 ///
17693 /// # Additional Parameters
17694 ///
17695 /// * *$.xgafv* (query-string) - V1 error format.
17696 /// * *access_token* (query-string) - OAuth access token.
17697 /// * *alt* (query-string) - Data format for response.
17698 /// * *callback* (query-string) - JSONP
17699 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17700 /// * *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.
17701 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17702 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17703 /// * *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.
17704 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17705 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17706 pub fn param<T>(
17707 mut self,
17708 name: T,
17709 value: T,
17710 ) -> ProjectLocationGithubEnterpriseConfigPatchCall<'a, C>
17711 where
17712 T: AsRef<str>,
17713 {
17714 self._additional_params
17715 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17716 self
17717 }
17718
17719 /// Identifies the authorization scope for the method you are building.
17720 ///
17721 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17722 /// [`Scope::CloudPlatform`].
17723 ///
17724 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17725 /// tokens for more than one scope.
17726 ///
17727 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17728 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17729 /// sufficient, a read-write scope will do as well.
17730 pub fn add_scope<St>(
17731 mut self,
17732 scope: St,
17733 ) -> ProjectLocationGithubEnterpriseConfigPatchCall<'a, C>
17734 where
17735 St: AsRef<str>,
17736 {
17737 self._scopes.insert(String::from(scope.as_ref()));
17738 self
17739 }
17740 /// Identifies the authorization scope(s) for the method you are building.
17741 ///
17742 /// See [`Self::add_scope()`] for details.
17743 pub fn add_scopes<I, St>(
17744 mut self,
17745 scopes: I,
17746 ) -> ProjectLocationGithubEnterpriseConfigPatchCall<'a, C>
17747 where
17748 I: IntoIterator<Item = St>,
17749 St: AsRef<str>,
17750 {
17751 self._scopes
17752 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17753 self
17754 }
17755
17756 /// Removes all scopes, and no default scope will be used either.
17757 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17758 /// for details).
17759 pub fn clear_scopes(mut self) -> ProjectLocationGithubEnterpriseConfigPatchCall<'a, C> {
17760 self._scopes.clear();
17761 self
17762 }
17763}
17764
17765/// Starts asynchronous cancellation on a long-running operation. The server makes a best effort to cancel the operation, but success is not guaranteed. If the server doesn't support this method, it returns `google.rpc.Code.UNIMPLEMENTED`. Clients can use Operations.GetOperation or other methods to check whether the cancellation succeeded or whether the operation completed despite cancellation. On successful cancellation, the operation is not deleted; instead, it becomes an operation with an Operation.error value with a google.rpc.Status.code of 1, corresponding to `Code.CANCELLED`.
17766///
17767/// A builder for the *locations.operations.cancel* method supported by a *project* resource.
17768/// It is not used directly, but through a [`ProjectMethods`] instance.
17769///
17770/// # Example
17771///
17772/// Instantiate a resource method builder
17773///
17774/// ```test_harness,no_run
17775/// # extern crate hyper;
17776/// # extern crate hyper_rustls;
17777/// # extern crate google_cloudbuild1 as cloudbuild1;
17778/// use cloudbuild1::api::CancelOperationRequest;
17779/// # async fn dox() {
17780/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17781///
17782/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17783/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
17784/// # secret,
17785/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17786/// # ).build().await.unwrap();
17787///
17788/// # let client = hyper_util::client::legacy::Client::builder(
17789/// # hyper_util::rt::TokioExecutor::new()
17790/// # )
17791/// # .build(
17792/// # hyper_rustls::HttpsConnectorBuilder::new()
17793/// # .with_native_roots()
17794/// # .unwrap()
17795/// # .https_or_http()
17796/// # .enable_http1()
17797/// # .build()
17798/// # );
17799/// # let mut hub = CloudBuild::new(client, auth);
17800/// // As the method needs a request, you would usually fill it with the desired information
17801/// // into the respective structure. Some of the parts shown here might not be applicable !
17802/// // Values shown here are possibly random and not representative !
17803/// let mut req = CancelOperationRequest::default();
17804///
17805/// // You can configure optional parameters by calling the respective setters at will, and
17806/// // execute the final call using `doit()`.
17807/// // Values shown here are possibly random and not representative !
17808/// let result = hub.projects().locations_operations_cancel(req, "name")
17809/// .doit().await;
17810/// # }
17811/// ```
17812pub struct ProjectLocationOperationCancelCall<'a, C>
17813where
17814 C: 'a,
17815{
17816 hub: &'a CloudBuild<C>,
17817 _request: CancelOperationRequest,
17818 _name: String,
17819 _delegate: Option<&'a mut dyn common::Delegate>,
17820 _additional_params: HashMap<String, String>,
17821 _scopes: BTreeSet<String>,
17822}
17823
17824impl<'a, C> common::CallBuilder for ProjectLocationOperationCancelCall<'a, C> {}
17825
17826impl<'a, C> ProjectLocationOperationCancelCall<'a, C>
17827where
17828 C: common::Connector,
17829{
17830 /// Perform the operation you have build so far.
17831 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
17832 use std::borrow::Cow;
17833 use std::io::{Read, Seek};
17834
17835 use common::{url::Params, ToParts};
17836 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17837
17838 let mut dd = common::DefaultDelegate;
17839 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17840 dlg.begin(common::MethodInfo {
17841 id: "cloudbuild.projects.locations.operations.cancel",
17842 http_method: hyper::Method::POST,
17843 });
17844
17845 for &field in ["alt", "name"].iter() {
17846 if self._additional_params.contains_key(field) {
17847 dlg.finished(false);
17848 return Err(common::Error::FieldClash(field));
17849 }
17850 }
17851
17852 let mut params = Params::with_capacity(4 + self._additional_params.len());
17853 params.push("name", self._name);
17854
17855 params.extend(self._additional_params.iter());
17856
17857 params.push("alt", "json");
17858 let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
17859 if self._scopes.is_empty() {
17860 self._scopes
17861 .insert(Scope::CloudPlatform.as_ref().to_string());
17862 }
17863
17864 #[allow(clippy::single_element_loop)]
17865 for &(find_this, param_name) in [("{+name}", "name")].iter() {
17866 url = params.uri_replacement(url, param_name, find_this, true);
17867 }
17868 {
17869 let to_remove = ["name"];
17870 params.remove_params(&to_remove);
17871 }
17872
17873 let url = params.parse_with_url(&url);
17874
17875 let mut json_mime_type = mime::APPLICATION_JSON;
17876 let mut request_value_reader = {
17877 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17878 common::remove_json_null_values(&mut value);
17879 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17880 serde_json::to_writer(&mut dst, &value).unwrap();
17881 dst
17882 };
17883 let request_size = request_value_reader
17884 .seek(std::io::SeekFrom::End(0))
17885 .unwrap();
17886 request_value_reader
17887 .seek(std::io::SeekFrom::Start(0))
17888 .unwrap();
17889
17890 loop {
17891 let token = match self
17892 .hub
17893 .auth
17894 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17895 .await
17896 {
17897 Ok(token) => token,
17898 Err(e) => match dlg.token(e) {
17899 Ok(token) => token,
17900 Err(e) => {
17901 dlg.finished(false);
17902 return Err(common::Error::MissingToken(e));
17903 }
17904 },
17905 };
17906 request_value_reader
17907 .seek(std::io::SeekFrom::Start(0))
17908 .unwrap();
17909 let mut req_result = {
17910 let client = &self.hub.client;
17911 dlg.pre_request();
17912 let mut req_builder = hyper::Request::builder()
17913 .method(hyper::Method::POST)
17914 .uri(url.as_str())
17915 .header(USER_AGENT, self.hub._user_agent.clone());
17916
17917 if let Some(token) = token.as_ref() {
17918 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17919 }
17920
17921 let request = req_builder
17922 .header(CONTENT_TYPE, json_mime_type.to_string())
17923 .header(CONTENT_LENGTH, request_size as u64)
17924 .body(common::to_body(
17925 request_value_reader.get_ref().clone().into(),
17926 ));
17927
17928 client.request(request.unwrap()).await
17929 };
17930
17931 match req_result {
17932 Err(err) => {
17933 if let common::Retry::After(d) = dlg.http_error(&err) {
17934 sleep(d).await;
17935 continue;
17936 }
17937 dlg.finished(false);
17938 return Err(common::Error::HttpError(err));
17939 }
17940 Ok(res) => {
17941 let (mut parts, body) = res.into_parts();
17942 let mut body = common::Body::new(body);
17943 if !parts.status.is_success() {
17944 let bytes = common::to_bytes(body).await.unwrap_or_default();
17945 let error = serde_json::from_str(&common::to_string(&bytes));
17946 let response = common::to_response(parts, bytes.into());
17947
17948 if let common::Retry::After(d) =
17949 dlg.http_failure(&response, error.as_ref().ok())
17950 {
17951 sleep(d).await;
17952 continue;
17953 }
17954
17955 dlg.finished(false);
17956
17957 return Err(match error {
17958 Ok(value) => common::Error::BadRequest(value),
17959 _ => common::Error::Failure(response),
17960 });
17961 }
17962 let response = {
17963 let bytes = common::to_bytes(body).await.unwrap_or_default();
17964 let encoded = common::to_string(&bytes);
17965 match serde_json::from_str(&encoded) {
17966 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17967 Err(error) => {
17968 dlg.response_json_decode_error(&encoded, &error);
17969 return Err(common::Error::JsonDecodeError(
17970 encoded.to_string(),
17971 error,
17972 ));
17973 }
17974 }
17975 };
17976
17977 dlg.finished(true);
17978 return Ok(response);
17979 }
17980 }
17981 }
17982 }
17983
17984 ///
17985 /// Sets the *request* property to the given value.
17986 ///
17987 /// Even though the property as already been set when instantiating this call,
17988 /// we provide this method for API completeness.
17989 pub fn request(
17990 mut self,
17991 new_value: CancelOperationRequest,
17992 ) -> ProjectLocationOperationCancelCall<'a, C> {
17993 self._request = new_value;
17994 self
17995 }
17996 /// The name of the operation resource to be cancelled.
17997 ///
17998 /// Sets the *name* path property to the given value.
17999 ///
18000 /// Even though the property as already been set when instantiating this call,
18001 /// we provide this method for API completeness.
18002 pub fn name(mut self, new_value: &str) -> ProjectLocationOperationCancelCall<'a, C> {
18003 self._name = new_value.to_string();
18004 self
18005 }
18006 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18007 /// while executing the actual API request.
18008 ///
18009 /// ````text
18010 /// It should be used to handle progress information, and to implement a certain level of resilience.
18011 /// ````
18012 ///
18013 /// Sets the *delegate* property to the given value.
18014 pub fn delegate(
18015 mut self,
18016 new_value: &'a mut dyn common::Delegate,
18017 ) -> ProjectLocationOperationCancelCall<'a, C> {
18018 self._delegate = Some(new_value);
18019 self
18020 }
18021
18022 /// Set any additional parameter of the query string used in the request.
18023 /// It should be used to set parameters which are not yet available through their own
18024 /// setters.
18025 ///
18026 /// Please note that this method must not be used to set any of the known parameters
18027 /// which have their own setter method. If done anyway, the request will fail.
18028 ///
18029 /// # Additional Parameters
18030 ///
18031 /// * *$.xgafv* (query-string) - V1 error format.
18032 /// * *access_token* (query-string) - OAuth access token.
18033 /// * *alt* (query-string) - Data format for response.
18034 /// * *callback* (query-string) - JSONP
18035 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18036 /// * *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.
18037 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18038 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18039 /// * *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.
18040 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18041 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18042 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationCancelCall<'a, C>
18043 where
18044 T: AsRef<str>,
18045 {
18046 self._additional_params
18047 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18048 self
18049 }
18050
18051 /// Identifies the authorization scope for the method you are building.
18052 ///
18053 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18054 /// [`Scope::CloudPlatform`].
18055 ///
18056 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18057 /// tokens for more than one scope.
18058 ///
18059 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18060 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18061 /// sufficient, a read-write scope will do as well.
18062 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationCancelCall<'a, C>
18063 where
18064 St: AsRef<str>,
18065 {
18066 self._scopes.insert(String::from(scope.as_ref()));
18067 self
18068 }
18069 /// Identifies the authorization scope(s) for the method you are building.
18070 ///
18071 /// See [`Self::add_scope()`] for details.
18072 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationCancelCall<'a, C>
18073 where
18074 I: IntoIterator<Item = St>,
18075 St: AsRef<str>,
18076 {
18077 self._scopes
18078 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18079 self
18080 }
18081
18082 /// Removes all scopes, and no default scope will be used either.
18083 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18084 /// for details).
18085 pub fn clear_scopes(mut self) -> ProjectLocationOperationCancelCall<'a, C> {
18086 self._scopes.clear();
18087 self
18088 }
18089}
18090
18091/// Gets the latest state of a long-running operation. Clients can use this method to poll the operation result at intervals as recommended by the API service.
18092///
18093/// A builder for the *locations.operations.get* method supported by a *project* resource.
18094/// It is not used directly, but through a [`ProjectMethods`] instance.
18095///
18096/// # Example
18097///
18098/// Instantiate a resource method builder
18099///
18100/// ```test_harness,no_run
18101/// # extern crate hyper;
18102/// # extern crate hyper_rustls;
18103/// # extern crate google_cloudbuild1 as cloudbuild1;
18104/// # async fn dox() {
18105/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18106///
18107/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18108/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
18109/// # secret,
18110/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18111/// # ).build().await.unwrap();
18112///
18113/// # let client = hyper_util::client::legacy::Client::builder(
18114/// # hyper_util::rt::TokioExecutor::new()
18115/// # )
18116/// # .build(
18117/// # hyper_rustls::HttpsConnectorBuilder::new()
18118/// # .with_native_roots()
18119/// # .unwrap()
18120/// # .https_or_http()
18121/// # .enable_http1()
18122/// # .build()
18123/// # );
18124/// # let mut hub = CloudBuild::new(client, auth);
18125/// // You can configure optional parameters by calling the respective setters at will, and
18126/// // execute the final call using `doit()`.
18127/// // Values shown here are possibly random and not representative !
18128/// let result = hub.projects().locations_operations_get("name")
18129/// .doit().await;
18130/// # }
18131/// ```
18132pub struct ProjectLocationOperationGetCall<'a, C>
18133where
18134 C: 'a,
18135{
18136 hub: &'a CloudBuild<C>,
18137 _name: String,
18138 _delegate: Option<&'a mut dyn common::Delegate>,
18139 _additional_params: HashMap<String, String>,
18140 _scopes: BTreeSet<String>,
18141}
18142
18143impl<'a, C> common::CallBuilder for ProjectLocationOperationGetCall<'a, C> {}
18144
18145impl<'a, C> ProjectLocationOperationGetCall<'a, C>
18146where
18147 C: common::Connector,
18148{
18149 /// Perform the operation you have build so far.
18150 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
18151 use std::borrow::Cow;
18152 use std::io::{Read, Seek};
18153
18154 use common::{url::Params, ToParts};
18155 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18156
18157 let mut dd = common::DefaultDelegate;
18158 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18159 dlg.begin(common::MethodInfo {
18160 id: "cloudbuild.projects.locations.operations.get",
18161 http_method: hyper::Method::GET,
18162 });
18163
18164 for &field in ["alt", "name"].iter() {
18165 if self._additional_params.contains_key(field) {
18166 dlg.finished(false);
18167 return Err(common::Error::FieldClash(field));
18168 }
18169 }
18170
18171 let mut params = Params::with_capacity(3 + self._additional_params.len());
18172 params.push("name", self._name);
18173
18174 params.extend(self._additional_params.iter());
18175
18176 params.push("alt", "json");
18177 let mut url = self.hub._base_url.clone() + "v1/{+name}";
18178 if self._scopes.is_empty() {
18179 self._scopes
18180 .insert(Scope::CloudPlatform.as_ref().to_string());
18181 }
18182
18183 #[allow(clippy::single_element_loop)]
18184 for &(find_this, param_name) in [("{+name}", "name")].iter() {
18185 url = params.uri_replacement(url, param_name, find_this, true);
18186 }
18187 {
18188 let to_remove = ["name"];
18189 params.remove_params(&to_remove);
18190 }
18191
18192 let url = params.parse_with_url(&url);
18193
18194 loop {
18195 let token = match self
18196 .hub
18197 .auth
18198 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18199 .await
18200 {
18201 Ok(token) => token,
18202 Err(e) => match dlg.token(e) {
18203 Ok(token) => token,
18204 Err(e) => {
18205 dlg.finished(false);
18206 return Err(common::Error::MissingToken(e));
18207 }
18208 },
18209 };
18210 let mut req_result = {
18211 let client = &self.hub.client;
18212 dlg.pre_request();
18213 let mut req_builder = hyper::Request::builder()
18214 .method(hyper::Method::GET)
18215 .uri(url.as_str())
18216 .header(USER_AGENT, self.hub._user_agent.clone());
18217
18218 if let Some(token) = token.as_ref() {
18219 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18220 }
18221
18222 let request = req_builder
18223 .header(CONTENT_LENGTH, 0_u64)
18224 .body(common::to_body::<String>(None));
18225
18226 client.request(request.unwrap()).await
18227 };
18228
18229 match req_result {
18230 Err(err) => {
18231 if let common::Retry::After(d) = dlg.http_error(&err) {
18232 sleep(d).await;
18233 continue;
18234 }
18235 dlg.finished(false);
18236 return Err(common::Error::HttpError(err));
18237 }
18238 Ok(res) => {
18239 let (mut parts, body) = res.into_parts();
18240 let mut body = common::Body::new(body);
18241 if !parts.status.is_success() {
18242 let bytes = common::to_bytes(body).await.unwrap_or_default();
18243 let error = serde_json::from_str(&common::to_string(&bytes));
18244 let response = common::to_response(parts, bytes.into());
18245
18246 if let common::Retry::After(d) =
18247 dlg.http_failure(&response, error.as_ref().ok())
18248 {
18249 sleep(d).await;
18250 continue;
18251 }
18252
18253 dlg.finished(false);
18254
18255 return Err(match error {
18256 Ok(value) => common::Error::BadRequest(value),
18257 _ => common::Error::Failure(response),
18258 });
18259 }
18260 let response = {
18261 let bytes = common::to_bytes(body).await.unwrap_or_default();
18262 let encoded = common::to_string(&bytes);
18263 match serde_json::from_str(&encoded) {
18264 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18265 Err(error) => {
18266 dlg.response_json_decode_error(&encoded, &error);
18267 return Err(common::Error::JsonDecodeError(
18268 encoded.to_string(),
18269 error,
18270 ));
18271 }
18272 }
18273 };
18274
18275 dlg.finished(true);
18276 return Ok(response);
18277 }
18278 }
18279 }
18280 }
18281
18282 /// The name of the operation resource.
18283 ///
18284 /// Sets the *name* path property to the given value.
18285 ///
18286 /// Even though the property as already been set when instantiating this call,
18287 /// we provide this method for API completeness.
18288 pub fn name(mut self, new_value: &str) -> ProjectLocationOperationGetCall<'a, C> {
18289 self._name = new_value.to_string();
18290 self
18291 }
18292 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18293 /// while executing the actual API request.
18294 ///
18295 /// ````text
18296 /// It should be used to handle progress information, and to implement a certain level of resilience.
18297 /// ````
18298 ///
18299 /// Sets the *delegate* property to the given value.
18300 pub fn delegate(
18301 mut self,
18302 new_value: &'a mut dyn common::Delegate,
18303 ) -> ProjectLocationOperationGetCall<'a, C> {
18304 self._delegate = Some(new_value);
18305 self
18306 }
18307
18308 /// Set any additional parameter of the query string used in the request.
18309 /// It should be used to set parameters which are not yet available through their own
18310 /// setters.
18311 ///
18312 /// Please note that this method must not be used to set any of the known parameters
18313 /// which have their own setter method. If done anyway, the request will fail.
18314 ///
18315 /// # Additional Parameters
18316 ///
18317 /// * *$.xgafv* (query-string) - V1 error format.
18318 /// * *access_token* (query-string) - OAuth access token.
18319 /// * *alt* (query-string) - Data format for response.
18320 /// * *callback* (query-string) - JSONP
18321 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18322 /// * *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.
18323 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18324 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18325 /// * *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.
18326 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18327 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18328 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationGetCall<'a, C>
18329 where
18330 T: AsRef<str>,
18331 {
18332 self._additional_params
18333 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18334 self
18335 }
18336
18337 /// Identifies the authorization scope for the method you are building.
18338 ///
18339 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18340 /// [`Scope::CloudPlatform`].
18341 ///
18342 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18343 /// tokens for more than one scope.
18344 ///
18345 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18346 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18347 /// sufficient, a read-write scope will do as well.
18348 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationGetCall<'a, C>
18349 where
18350 St: AsRef<str>,
18351 {
18352 self._scopes.insert(String::from(scope.as_ref()));
18353 self
18354 }
18355 /// Identifies the authorization scope(s) for the method you are building.
18356 ///
18357 /// See [`Self::add_scope()`] for details.
18358 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationGetCall<'a, C>
18359 where
18360 I: IntoIterator<Item = St>,
18361 St: AsRef<str>,
18362 {
18363 self._scopes
18364 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18365 self
18366 }
18367
18368 /// Removes all scopes, and no default scope will be used either.
18369 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18370 /// for details).
18371 pub fn clear_scopes(mut self) -> ProjectLocationOperationGetCall<'a, C> {
18372 self._scopes.clear();
18373 self
18374 }
18375}
18376
18377/// Creates a new `BuildTrigger`.
18378///
18379/// A builder for the *locations.triggers.create* method supported by a *project* resource.
18380/// It is not used directly, but through a [`ProjectMethods`] instance.
18381///
18382/// # Example
18383///
18384/// Instantiate a resource method builder
18385///
18386/// ```test_harness,no_run
18387/// # extern crate hyper;
18388/// # extern crate hyper_rustls;
18389/// # extern crate google_cloudbuild1 as cloudbuild1;
18390/// use cloudbuild1::api::BuildTrigger;
18391/// # async fn dox() {
18392/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18393///
18394/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18395/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
18396/// # secret,
18397/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18398/// # ).build().await.unwrap();
18399///
18400/// # let client = hyper_util::client::legacy::Client::builder(
18401/// # hyper_util::rt::TokioExecutor::new()
18402/// # )
18403/// # .build(
18404/// # hyper_rustls::HttpsConnectorBuilder::new()
18405/// # .with_native_roots()
18406/// # .unwrap()
18407/// # .https_or_http()
18408/// # .enable_http1()
18409/// # .build()
18410/// # );
18411/// # let mut hub = CloudBuild::new(client, auth);
18412/// // As the method needs a request, you would usually fill it with the desired information
18413/// // into the respective structure. Some of the parts shown here might not be applicable !
18414/// // Values shown here are possibly random and not representative !
18415/// let mut req = BuildTrigger::default();
18416///
18417/// // You can configure optional parameters by calling the respective setters at will, and
18418/// // execute the final call using `doit()`.
18419/// // Values shown here are possibly random and not representative !
18420/// let result = hub.projects().locations_triggers_create(req, "parent")
18421/// .project_id("ea")
18422/// .doit().await;
18423/// # }
18424/// ```
18425pub struct ProjectLocationTriggerCreateCall<'a, C>
18426where
18427 C: 'a,
18428{
18429 hub: &'a CloudBuild<C>,
18430 _request: BuildTrigger,
18431 _parent: String,
18432 _project_id: Option<String>,
18433 _delegate: Option<&'a mut dyn common::Delegate>,
18434 _additional_params: HashMap<String, String>,
18435 _scopes: BTreeSet<String>,
18436}
18437
18438impl<'a, C> common::CallBuilder for ProjectLocationTriggerCreateCall<'a, C> {}
18439
18440impl<'a, C> ProjectLocationTriggerCreateCall<'a, C>
18441where
18442 C: common::Connector,
18443{
18444 /// Perform the operation you have build so far.
18445 pub async fn doit(mut self) -> common::Result<(common::Response, BuildTrigger)> {
18446 use std::borrow::Cow;
18447 use std::io::{Read, Seek};
18448
18449 use common::{url::Params, ToParts};
18450 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18451
18452 let mut dd = common::DefaultDelegate;
18453 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18454 dlg.begin(common::MethodInfo {
18455 id: "cloudbuild.projects.locations.triggers.create",
18456 http_method: hyper::Method::POST,
18457 });
18458
18459 for &field in ["alt", "parent", "projectId"].iter() {
18460 if self._additional_params.contains_key(field) {
18461 dlg.finished(false);
18462 return Err(common::Error::FieldClash(field));
18463 }
18464 }
18465
18466 let mut params = Params::with_capacity(5 + self._additional_params.len());
18467 params.push("parent", self._parent);
18468 if let Some(value) = self._project_id.as_ref() {
18469 params.push("projectId", value);
18470 }
18471
18472 params.extend(self._additional_params.iter());
18473
18474 params.push("alt", "json");
18475 let mut url = self.hub._base_url.clone() + "v1/{+parent}/triggers";
18476 if self._scopes.is_empty() {
18477 self._scopes
18478 .insert(Scope::CloudPlatform.as_ref().to_string());
18479 }
18480
18481 #[allow(clippy::single_element_loop)]
18482 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
18483 url = params.uri_replacement(url, param_name, find_this, true);
18484 }
18485 {
18486 let to_remove = ["parent"];
18487 params.remove_params(&to_remove);
18488 }
18489
18490 let url = params.parse_with_url(&url);
18491
18492 let mut json_mime_type = mime::APPLICATION_JSON;
18493 let mut request_value_reader = {
18494 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18495 common::remove_json_null_values(&mut value);
18496 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18497 serde_json::to_writer(&mut dst, &value).unwrap();
18498 dst
18499 };
18500 let request_size = request_value_reader
18501 .seek(std::io::SeekFrom::End(0))
18502 .unwrap();
18503 request_value_reader
18504 .seek(std::io::SeekFrom::Start(0))
18505 .unwrap();
18506
18507 loop {
18508 let token = match self
18509 .hub
18510 .auth
18511 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18512 .await
18513 {
18514 Ok(token) => token,
18515 Err(e) => match dlg.token(e) {
18516 Ok(token) => token,
18517 Err(e) => {
18518 dlg.finished(false);
18519 return Err(common::Error::MissingToken(e));
18520 }
18521 },
18522 };
18523 request_value_reader
18524 .seek(std::io::SeekFrom::Start(0))
18525 .unwrap();
18526 let mut req_result = {
18527 let client = &self.hub.client;
18528 dlg.pre_request();
18529 let mut req_builder = hyper::Request::builder()
18530 .method(hyper::Method::POST)
18531 .uri(url.as_str())
18532 .header(USER_AGENT, self.hub._user_agent.clone());
18533
18534 if let Some(token) = token.as_ref() {
18535 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18536 }
18537
18538 let request = req_builder
18539 .header(CONTENT_TYPE, json_mime_type.to_string())
18540 .header(CONTENT_LENGTH, request_size as u64)
18541 .body(common::to_body(
18542 request_value_reader.get_ref().clone().into(),
18543 ));
18544
18545 client.request(request.unwrap()).await
18546 };
18547
18548 match req_result {
18549 Err(err) => {
18550 if let common::Retry::After(d) = dlg.http_error(&err) {
18551 sleep(d).await;
18552 continue;
18553 }
18554 dlg.finished(false);
18555 return Err(common::Error::HttpError(err));
18556 }
18557 Ok(res) => {
18558 let (mut parts, body) = res.into_parts();
18559 let mut body = common::Body::new(body);
18560 if !parts.status.is_success() {
18561 let bytes = common::to_bytes(body).await.unwrap_or_default();
18562 let error = serde_json::from_str(&common::to_string(&bytes));
18563 let response = common::to_response(parts, bytes.into());
18564
18565 if let common::Retry::After(d) =
18566 dlg.http_failure(&response, error.as_ref().ok())
18567 {
18568 sleep(d).await;
18569 continue;
18570 }
18571
18572 dlg.finished(false);
18573
18574 return Err(match error {
18575 Ok(value) => common::Error::BadRequest(value),
18576 _ => common::Error::Failure(response),
18577 });
18578 }
18579 let response = {
18580 let bytes = common::to_bytes(body).await.unwrap_or_default();
18581 let encoded = common::to_string(&bytes);
18582 match serde_json::from_str(&encoded) {
18583 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18584 Err(error) => {
18585 dlg.response_json_decode_error(&encoded, &error);
18586 return Err(common::Error::JsonDecodeError(
18587 encoded.to_string(),
18588 error,
18589 ));
18590 }
18591 }
18592 };
18593
18594 dlg.finished(true);
18595 return Ok(response);
18596 }
18597 }
18598 }
18599 }
18600
18601 ///
18602 /// Sets the *request* property to the given value.
18603 ///
18604 /// Even though the property as already been set when instantiating this call,
18605 /// we provide this method for API completeness.
18606 pub fn request(mut self, new_value: BuildTrigger) -> ProjectLocationTriggerCreateCall<'a, C> {
18607 self._request = new_value;
18608 self
18609 }
18610 /// The parent resource where this trigger will be created. Format: `projects/{project}/locations/{location}`
18611 ///
18612 /// Sets the *parent* path property to the given value.
18613 ///
18614 /// Even though the property as already been set when instantiating this call,
18615 /// we provide this method for API completeness.
18616 pub fn parent(mut self, new_value: &str) -> ProjectLocationTriggerCreateCall<'a, C> {
18617 self._parent = new_value.to_string();
18618 self
18619 }
18620 /// Required. ID of the project for which to configure automatic builds.
18621 ///
18622 /// Sets the *project id* query property to the given value.
18623 pub fn project_id(mut self, new_value: &str) -> ProjectLocationTriggerCreateCall<'a, C> {
18624 self._project_id = Some(new_value.to_string());
18625 self
18626 }
18627 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18628 /// while executing the actual API request.
18629 ///
18630 /// ````text
18631 /// It should be used to handle progress information, and to implement a certain level of resilience.
18632 /// ````
18633 ///
18634 /// Sets the *delegate* property to the given value.
18635 pub fn delegate(
18636 mut self,
18637 new_value: &'a mut dyn common::Delegate,
18638 ) -> ProjectLocationTriggerCreateCall<'a, C> {
18639 self._delegate = Some(new_value);
18640 self
18641 }
18642
18643 /// Set any additional parameter of the query string used in the request.
18644 /// It should be used to set parameters which are not yet available through their own
18645 /// setters.
18646 ///
18647 /// Please note that this method must not be used to set any of the known parameters
18648 /// which have their own setter method. If done anyway, the request will fail.
18649 ///
18650 /// # Additional Parameters
18651 ///
18652 /// * *$.xgafv* (query-string) - V1 error format.
18653 /// * *access_token* (query-string) - OAuth access token.
18654 /// * *alt* (query-string) - Data format for response.
18655 /// * *callback* (query-string) - JSONP
18656 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18657 /// * *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.
18658 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18659 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18660 /// * *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.
18661 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18662 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18663 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationTriggerCreateCall<'a, C>
18664 where
18665 T: AsRef<str>,
18666 {
18667 self._additional_params
18668 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18669 self
18670 }
18671
18672 /// Identifies the authorization scope for the method you are building.
18673 ///
18674 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18675 /// [`Scope::CloudPlatform`].
18676 ///
18677 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18678 /// tokens for more than one scope.
18679 ///
18680 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18681 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18682 /// sufficient, a read-write scope will do as well.
18683 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationTriggerCreateCall<'a, C>
18684 where
18685 St: AsRef<str>,
18686 {
18687 self._scopes.insert(String::from(scope.as_ref()));
18688 self
18689 }
18690 /// Identifies the authorization scope(s) for the method you are building.
18691 ///
18692 /// See [`Self::add_scope()`] for details.
18693 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationTriggerCreateCall<'a, C>
18694 where
18695 I: IntoIterator<Item = St>,
18696 St: AsRef<str>,
18697 {
18698 self._scopes
18699 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18700 self
18701 }
18702
18703 /// Removes all scopes, and no default scope will be used either.
18704 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18705 /// for details).
18706 pub fn clear_scopes(mut self) -> ProjectLocationTriggerCreateCall<'a, C> {
18707 self._scopes.clear();
18708 self
18709 }
18710}
18711
18712/// Deletes a `BuildTrigger` by its project ID and trigger ID.
18713///
18714/// A builder for the *locations.triggers.delete* method supported by a *project* resource.
18715/// It is not used directly, but through a [`ProjectMethods`] instance.
18716///
18717/// # Example
18718///
18719/// Instantiate a resource method builder
18720///
18721/// ```test_harness,no_run
18722/// # extern crate hyper;
18723/// # extern crate hyper_rustls;
18724/// # extern crate google_cloudbuild1 as cloudbuild1;
18725/// # async fn dox() {
18726/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18727///
18728/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18729/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
18730/// # secret,
18731/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18732/// # ).build().await.unwrap();
18733///
18734/// # let client = hyper_util::client::legacy::Client::builder(
18735/// # hyper_util::rt::TokioExecutor::new()
18736/// # )
18737/// # .build(
18738/// # hyper_rustls::HttpsConnectorBuilder::new()
18739/// # .with_native_roots()
18740/// # .unwrap()
18741/// # .https_or_http()
18742/// # .enable_http1()
18743/// # .build()
18744/// # );
18745/// # let mut hub = CloudBuild::new(client, auth);
18746/// // You can configure optional parameters by calling the respective setters at will, and
18747/// // execute the final call using `doit()`.
18748/// // Values shown here are possibly random and not representative !
18749/// let result = hub.projects().locations_triggers_delete("name")
18750/// .trigger_id("Lorem")
18751/// .project_id("invidunt")
18752/// .doit().await;
18753/// # }
18754/// ```
18755pub struct ProjectLocationTriggerDeleteCall<'a, C>
18756where
18757 C: 'a,
18758{
18759 hub: &'a CloudBuild<C>,
18760 _name: String,
18761 _trigger_id: Option<String>,
18762 _project_id: Option<String>,
18763 _delegate: Option<&'a mut dyn common::Delegate>,
18764 _additional_params: HashMap<String, String>,
18765 _scopes: BTreeSet<String>,
18766}
18767
18768impl<'a, C> common::CallBuilder for ProjectLocationTriggerDeleteCall<'a, C> {}
18769
18770impl<'a, C> ProjectLocationTriggerDeleteCall<'a, C>
18771where
18772 C: common::Connector,
18773{
18774 /// Perform the operation you have build so far.
18775 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
18776 use std::borrow::Cow;
18777 use std::io::{Read, Seek};
18778
18779 use common::{url::Params, ToParts};
18780 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18781
18782 let mut dd = common::DefaultDelegate;
18783 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18784 dlg.begin(common::MethodInfo {
18785 id: "cloudbuild.projects.locations.triggers.delete",
18786 http_method: hyper::Method::DELETE,
18787 });
18788
18789 for &field in ["alt", "name", "triggerId", "projectId"].iter() {
18790 if self._additional_params.contains_key(field) {
18791 dlg.finished(false);
18792 return Err(common::Error::FieldClash(field));
18793 }
18794 }
18795
18796 let mut params = Params::with_capacity(5 + self._additional_params.len());
18797 params.push("name", self._name);
18798 if let Some(value) = self._trigger_id.as_ref() {
18799 params.push("triggerId", value);
18800 }
18801 if let Some(value) = self._project_id.as_ref() {
18802 params.push("projectId", value);
18803 }
18804
18805 params.extend(self._additional_params.iter());
18806
18807 params.push("alt", "json");
18808 let mut url = self.hub._base_url.clone() + "v1/{+name}";
18809 if self._scopes.is_empty() {
18810 self._scopes
18811 .insert(Scope::CloudPlatform.as_ref().to_string());
18812 }
18813
18814 #[allow(clippy::single_element_loop)]
18815 for &(find_this, param_name) in [("{+name}", "name")].iter() {
18816 url = params.uri_replacement(url, param_name, find_this, true);
18817 }
18818 {
18819 let to_remove = ["name"];
18820 params.remove_params(&to_remove);
18821 }
18822
18823 let url = params.parse_with_url(&url);
18824
18825 loop {
18826 let token = match self
18827 .hub
18828 .auth
18829 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18830 .await
18831 {
18832 Ok(token) => token,
18833 Err(e) => match dlg.token(e) {
18834 Ok(token) => token,
18835 Err(e) => {
18836 dlg.finished(false);
18837 return Err(common::Error::MissingToken(e));
18838 }
18839 },
18840 };
18841 let mut req_result = {
18842 let client = &self.hub.client;
18843 dlg.pre_request();
18844 let mut req_builder = hyper::Request::builder()
18845 .method(hyper::Method::DELETE)
18846 .uri(url.as_str())
18847 .header(USER_AGENT, self.hub._user_agent.clone());
18848
18849 if let Some(token) = token.as_ref() {
18850 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18851 }
18852
18853 let request = req_builder
18854 .header(CONTENT_LENGTH, 0_u64)
18855 .body(common::to_body::<String>(None));
18856
18857 client.request(request.unwrap()).await
18858 };
18859
18860 match req_result {
18861 Err(err) => {
18862 if let common::Retry::After(d) = dlg.http_error(&err) {
18863 sleep(d).await;
18864 continue;
18865 }
18866 dlg.finished(false);
18867 return Err(common::Error::HttpError(err));
18868 }
18869 Ok(res) => {
18870 let (mut parts, body) = res.into_parts();
18871 let mut body = common::Body::new(body);
18872 if !parts.status.is_success() {
18873 let bytes = common::to_bytes(body).await.unwrap_or_default();
18874 let error = serde_json::from_str(&common::to_string(&bytes));
18875 let response = common::to_response(parts, bytes.into());
18876
18877 if let common::Retry::After(d) =
18878 dlg.http_failure(&response, error.as_ref().ok())
18879 {
18880 sleep(d).await;
18881 continue;
18882 }
18883
18884 dlg.finished(false);
18885
18886 return Err(match error {
18887 Ok(value) => common::Error::BadRequest(value),
18888 _ => common::Error::Failure(response),
18889 });
18890 }
18891 let response = {
18892 let bytes = common::to_bytes(body).await.unwrap_or_default();
18893 let encoded = common::to_string(&bytes);
18894 match serde_json::from_str(&encoded) {
18895 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18896 Err(error) => {
18897 dlg.response_json_decode_error(&encoded, &error);
18898 return Err(common::Error::JsonDecodeError(
18899 encoded.to_string(),
18900 error,
18901 ));
18902 }
18903 }
18904 };
18905
18906 dlg.finished(true);
18907 return Ok(response);
18908 }
18909 }
18910 }
18911 }
18912
18913 /// The name of the `Trigger` to delete. Format: `projects/{project}/locations/{location}/triggers/{trigger}`
18914 ///
18915 /// Sets the *name* path property to the given value.
18916 ///
18917 /// Even though the property as already been set when instantiating this call,
18918 /// we provide this method for API completeness.
18919 pub fn name(mut self, new_value: &str) -> ProjectLocationTriggerDeleteCall<'a, C> {
18920 self._name = new_value.to_string();
18921 self
18922 }
18923 /// Required. ID of the `BuildTrigger` to delete.
18924 ///
18925 /// Sets the *trigger id* query property to the given value.
18926 pub fn trigger_id(mut self, new_value: &str) -> ProjectLocationTriggerDeleteCall<'a, C> {
18927 self._trigger_id = Some(new_value.to_string());
18928 self
18929 }
18930 /// Required. ID of the project that owns the trigger.
18931 ///
18932 /// Sets the *project id* query property to the given value.
18933 pub fn project_id(mut self, new_value: &str) -> ProjectLocationTriggerDeleteCall<'a, C> {
18934 self._project_id = Some(new_value.to_string());
18935 self
18936 }
18937 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18938 /// while executing the actual API request.
18939 ///
18940 /// ````text
18941 /// It should be used to handle progress information, and to implement a certain level of resilience.
18942 /// ````
18943 ///
18944 /// Sets the *delegate* property to the given value.
18945 pub fn delegate(
18946 mut self,
18947 new_value: &'a mut dyn common::Delegate,
18948 ) -> ProjectLocationTriggerDeleteCall<'a, C> {
18949 self._delegate = Some(new_value);
18950 self
18951 }
18952
18953 /// Set any additional parameter of the query string used in the request.
18954 /// It should be used to set parameters which are not yet available through their own
18955 /// setters.
18956 ///
18957 /// Please note that this method must not be used to set any of the known parameters
18958 /// which have their own setter method. If done anyway, the request will fail.
18959 ///
18960 /// # Additional Parameters
18961 ///
18962 /// * *$.xgafv* (query-string) - V1 error format.
18963 /// * *access_token* (query-string) - OAuth access token.
18964 /// * *alt* (query-string) - Data format for response.
18965 /// * *callback* (query-string) - JSONP
18966 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18967 /// * *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.
18968 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18969 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18970 /// * *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.
18971 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18972 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18973 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationTriggerDeleteCall<'a, C>
18974 where
18975 T: AsRef<str>,
18976 {
18977 self._additional_params
18978 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18979 self
18980 }
18981
18982 /// Identifies the authorization scope for the method you are building.
18983 ///
18984 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18985 /// [`Scope::CloudPlatform`].
18986 ///
18987 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18988 /// tokens for more than one scope.
18989 ///
18990 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18991 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18992 /// sufficient, a read-write scope will do as well.
18993 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationTriggerDeleteCall<'a, C>
18994 where
18995 St: AsRef<str>,
18996 {
18997 self._scopes.insert(String::from(scope.as_ref()));
18998 self
18999 }
19000 /// Identifies the authorization scope(s) for the method you are building.
19001 ///
19002 /// See [`Self::add_scope()`] for details.
19003 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationTriggerDeleteCall<'a, C>
19004 where
19005 I: IntoIterator<Item = St>,
19006 St: AsRef<str>,
19007 {
19008 self._scopes
19009 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19010 self
19011 }
19012
19013 /// Removes all scopes, and no default scope will be used either.
19014 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19015 /// for details).
19016 pub fn clear_scopes(mut self) -> ProjectLocationTriggerDeleteCall<'a, C> {
19017 self._scopes.clear();
19018 self
19019 }
19020}
19021
19022/// Returns information about a `BuildTrigger`.
19023///
19024/// A builder for the *locations.triggers.get* method supported by a *project* resource.
19025/// It is not used directly, but through a [`ProjectMethods`] instance.
19026///
19027/// # Example
19028///
19029/// Instantiate a resource method builder
19030///
19031/// ```test_harness,no_run
19032/// # extern crate hyper;
19033/// # extern crate hyper_rustls;
19034/// # extern crate google_cloudbuild1 as cloudbuild1;
19035/// # async fn dox() {
19036/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19037///
19038/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19039/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
19040/// # secret,
19041/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19042/// # ).build().await.unwrap();
19043///
19044/// # let client = hyper_util::client::legacy::Client::builder(
19045/// # hyper_util::rt::TokioExecutor::new()
19046/// # )
19047/// # .build(
19048/// # hyper_rustls::HttpsConnectorBuilder::new()
19049/// # .with_native_roots()
19050/// # .unwrap()
19051/// # .https_or_http()
19052/// # .enable_http1()
19053/// # .build()
19054/// # );
19055/// # let mut hub = CloudBuild::new(client, auth);
19056/// // You can configure optional parameters by calling the respective setters at will, and
19057/// // execute the final call using `doit()`.
19058/// // Values shown here are possibly random and not representative !
19059/// let result = hub.projects().locations_triggers_get("name")
19060/// .trigger_id("est")
19061/// .project_id("At")
19062/// .doit().await;
19063/// # }
19064/// ```
19065pub struct ProjectLocationTriggerGetCall<'a, C>
19066where
19067 C: 'a,
19068{
19069 hub: &'a CloudBuild<C>,
19070 _name: String,
19071 _trigger_id: Option<String>,
19072 _project_id: Option<String>,
19073 _delegate: Option<&'a mut dyn common::Delegate>,
19074 _additional_params: HashMap<String, String>,
19075 _scopes: BTreeSet<String>,
19076}
19077
19078impl<'a, C> common::CallBuilder for ProjectLocationTriggerGetCall<'a, C> {}
19079
19080impl<'a, C> ProjectLocationTriggerGetCall<'a, C>
19081where
19082 C: common::Connector,
19083{
19084 /// Perform the operation you have build so far.
19085 pub async fn doit(mut self) -> common::Result<(common::Response, BuildTrigger)> {
19086 use std::borrow::Cow;
19087 use std::io::{Read, Seek};
19088
19089 use common::{url::Params, ToParts};
19090 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19091
19092 let mut dd = common::DefaultDelegate;
19093 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19094 dlg.begin(common::MethodInfo {
19095 id: "cloudbuild.projects.locations.triggers.get",
19096 http_method: hyper::Method::GET,
19097 });
19098
19099 for &field in ["alt", "name", "triggerId", "projectId"].iter() {
19100 if self._additional_params.contains_key(field) {
19101 dlg.finished(false);
19102 return Err(common::Error::FieldClash(field));
19103 }
19104 }
19105
19106 let mut params = Params::with_capacity(5 + self._additional_params.len());
19107 params.push("name", self._name);
19108 if let Some(value) = self._trigger_id.as_ref() {
19109 params.push("triggerId", value);
19110 }
19111 if let Some(value) = self._project_id.as_ref() {
19112 params.push("projectId", value);
19113 }
19114
19115 params.extend(self._additional_params.iter());
19116
19117 params.push("alt", "json");
19118 let mut url = self.hub._base_url.clone() + "v1/{+name}";
19119 if self._scopes.is_empty() {
19120 self._scopes
19121 .insert(Scope::CloudPlatform.as_ref().to_string());
19122 }
19123
19124 #[allow(clippy::single_element_loop)]
19125 for &(find_this, param_name) in [("{+name}", "name")].iter() {
19126 url = params.uri_replacement(url, param_name, find_this, true);
19127 }
19128 {
19129 let to_remove = ["name"];
19130 params.remove_params(&to_remove);
19131 }
19132
19133 let url = params.parse_with_url(&url);
19134
19135 loop {
19136 let token = match self
19137 .hub
19138 .auth
19139 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19140 .await
19141 {
19142 Ok(token) => token,
19143 Err(e) => match dlg.token(e) {
19144 Ok(token) => token,
19145 Err(e) => {
19146 dlg.finished(false);
19147 return Err(common::Error::MissingToken(e));
19148 }
19149 },
19150 };
19151 let mut req_result = {
19152 let client = &self.hub.client;
19153 dlg.pre_request();
19154 let mut req_builder = hyper::Request::builder()
19155 .method(hyper::Method::GET)
19156 .uri(url.as_str())
19157 .header(USER_AGENT, self.hub._user_agent.clone());
19158
19159 if let Some(token) = token.as_ref() {
19160 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19161 }
19162
19163 let request = req_builder
19164 .header(CONTENT_LENGTH, 0_u64)
19165 .body(common::to_body::<String>(None));
19166
19167 client.request(request.unwrap()).await
19168 };
19169
19170 match req_result {
19171 Err(err) => {
19172 if let common::Retry::After(d) = dlg.http_error(&err) {
19173 sleep(d).await;
19174 continue;
19175 }
19176 dlg.finished(false);
19177 return Err(common::Error::HttpError(err));
19178 }
19179 Ok(res) => {
19180 let (mut parts, body) = res.into_parts();
19181 let mut body = common::Body::new(body);
19182 if !parts.status.is_success() {
19183 let bytes = common::to_bytes(body).await.unwrap_or_default();
19184 let error = serde_json::from_str(&common::to_string(&bytes));
19185 let response = common::to_response(parts, bytes.into());
19186
19187 if let common::Retry::After(d) =
19188 dlg.http_failure(&response, error.as_ref().ok())
19189 {
19190 sleep(d).await;
19191 continue;
19192 }
19193
19194 dlg.finished(false);
19195
19196 return Err(match error {
19197 Ok(value) => common::Error::BadRequest(value),
19198 _ => common::Error::Failure(response),
19199 });
19200 }
19201 let response = {
19202 let bytes = common::to_bytes(body).await.unwrap_or_default();
19203 let encoded = common::to_string(&bytes);
19204 match serde_json::from_str(&encoded) {
19205 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19206 Err(error) => {
19207 dlg.response_json_decode_error(&encoded, &error);
19208 return Err(common::Error::JsonDecodeError(
19209 encoded.to_string(),
19210 error,
19211 ));
19212 }
19213 }
19214 };
19215
19216 dlg.finished(true);
19217 return Ok(response);
19218 }
19219 }
19220 }
19221 }
19222
19223 /// The name of the `Trigger` to retrieve. Format: `projects/{project}/locations/{location}/triggers/{trigger}`
19224 ///
19225 /// Sets the *name* path property to the given value.
19226 ///
19227 /// Even though the property as already been set when instantiating this call,
19228 /// we provide this method for API completeness.
19229 pub fn name(mut self, new_value: &str) -> ProjectLocationTriggerGetCall<'a, C> {
19230 self._name = new_value.to_string();
19231 self
19232 }
19233 /// Required. Identifier (`id` or `name`) of the `BuildTrigger` to get.
19234 ///
19235 /// Sets the *trigger id* query property to the given value.
19236 pub fn trigger_id(mut self, new_value: &str) -> ProjectLocationTriggerGetCall<'a, C> {
19237 self._trigger_id = Some(new_value.to_string());
19238 self
19239 }
19240 /// Required. ID of the project that owns the trigger.
19241 ///
19242 /// Sets the *project id* query property to the given value.
19243 pub fn project_id(mut self, new_value: &str) -> ProjectLocationTriggerGetCall<'a, C> {
19244 self._project_id = Some(new_value.to_string());
19245 self
19246 }
19247 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19248 /// while executing the actual API request.
19249 ///
19250 /// ````text
19251 /// It should be used to handle progress information, and to implement a certain level of resilience.
19252 /// ````
19253 ///
19254 /// Sets the *delegate* property to the given value.
19255 pub fn delegate(
19256 mut self,
19257 new_value: &'a mut dyn common::Delegate,
19258 ) -> ProjectLocationTriggerGetCall<'a, C> {
19259 self._delegate = Some(new_value);
19260 self
19261 }
19262
19263 /// Set any additional parameter of the query string used in the request.
19264 /// It should be used to set parameters which are not yet available through their own
19265 /// setters.
19266 ///
19267 /// Please note that this method must not be used to set any of the known parameters
19268 /// which have their own setter method. If done anyway, the request will fail.
19269 ///
19270 /// # Additional Parameters
19271 ///
19272 /// * *$.xgafv* (query-string) - V1 error format.
19273 /// * *access_token* (query-string) - OAuth access token.
19274 /// * *alt* (query-string) - Data format for response.
19275 /// * *callback* (query-string) - JSONP
19276 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19277 /// * *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.
19278 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19279 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19280 /// * *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.
19281 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19282 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19283 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationTriggerGetCall<'a, C>
19284 where
19285 T: AsRef<str>,
19286 {
19287 self._additional_params
19288 .insert(name.as_ref().to_string(), value.as_ref().to_string());
19289 self
19290 }
19291
19292 /// Identifies the authorization scope for the method you are building.
19293 ///
19294 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19295 /// [`Scope::CloudPlatform`].
19296 ///
19297 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19298 /// tokens for more than one scope.
19299 ///
19300 /// Usually there is more than one suitable scope to authorize an operation, some of which may
19301 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19302 /// sufficient, a read-write scope will do as well.
19303 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationTriggerGetCall<'a, C>
19304 where
19305 St: AsRef<str>,
19306 {
19307 self._scopes.insert(String::from(scope.as_ref()));
19308 self
19309 }
19310 /// Identifies the authorization scope(s) for the method you are building.
19311 ///
19312 /// See [`Self::add_scope()`] for details.
19313 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationTriggerGetCall<'a, C>
19314 where
19315 I: IntoIterator<Item = St>,
19316 St: AsRef<str>,
19317 {
19318 self._scopes
19319 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19320 self
19321 }
19322
19323 /// Removes all scopes, and no default scope will be used either.
19324 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19325 /// for details).
19326 pub fn clear_scopes(mut self) -> ProjectLocationTriggerGetCall<'a, C> {
19327 self._scopes.clear();
19328 self
19329 }
19330}
19331
19332/// Lists existing `BuildTrigger`s.
19333///
19334/// A builder for the *locations.triggers.list* method supported by a *project* resource.
19335/// It is not used directly, but through a [`ProjectMethods`] instance.
19336///
19337/// # Example
19338///
19339/// Instantiate a resource method builder
19340///
19341/// ```test_harness,no_run
19342/// # extern crate hyper;
19343/// # extern crate hyper_rustls;
19344/// # extern crate google_cloudbuild1 as cloudbuild1;
19345/// # async fn dox() {
19346/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19347///
19348/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19349/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
19350/// # secret,
19351/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19352/// # ).build().await.unwrap();
19353///
19354/// # let client = hyper_util::client::legacy::Client::builder(
19355/// # hyper_util::rt::TokioExecutor::new()
19356/// # )
19357/// # .build(
19358/// # hyper_rustls::HttpsConnectorBuilder::new()
19359/// # .with_native_roots()
19360/// # .unwrap()
19361/// # .https_or_http()
19362/// # .enable_http1()
19363/// # .build()
19364/// # );
19365/// # let mut hub = CloudBuild::new(client, auth);
19366/// // You can configure optional parameters by calling the respective setters at will, and
19367/// // execute the final call using `doit()`.
19368/// // Values shown here are possibly random and not representative !
19369/// let result = hub.projects().locations_triggers_list("parent")
19370/// .project_id("sit")
19371/// .page_token("et")
19372/// .page_size(-39)
19373/// .doit().await;
19374/// # }
19375/// ```
19376pub struct ProjectLocationTriggerListCall<'a, C>
19377where
19378 C: 'a,
19379{
19380 hub: &'a CloudBuild<C>,
19381 _parent: String,
19382 _project_id: Option<String>,
19383 _page_token: Option<String>,
19384 _page_size: Option<i32>,
19385 _delegate: Option<&'a mut dyn common::Delegate>,
19386 _additional_params: HashMap<String, String>,
19387 _scopes: BTreeSet<String>,
19388}
19389
19390impl<'a, C> common::CallBuilder for ProjectLocationTriggerListCall<'a, C> {}
19391
19392impl<'a, C> ProjectLocationTriggerListCall<'a, C>
19393where
19394 C: common::Connector,
19395{
19396 /// Perform the operation you have build so far.
19397 pub async fn doit(mut self) -> common::Result<(common::Response, ListBuildTriggersResponse)> {
19398 use std::borrow::Cow;
19399 use std::io::{Read, Seek};
19400
19401 use common::{url::Params, ToParts};
19402 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19403
19404 let mut dd = common::DefaultDelegate;
19405 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19406 dlg.begin(common::MethodInfo {
19407 id: "cloudbuild.projects.locations.triggers.list",
19408 http_method: hyper::Method::GET,
19409 });
19410
19411 for &field in ["alt", "parent", "projectId", "pageToken", "pageSize"].iter() {
19412 if self._additional_params.contains_key(field) {
19413 dlg.finished(false);
19414 return Err(common::Error::FieldClash(field));
19415 }
19416 }
19417
19418 let mut params = Params::with_capacity(6 + self._additional_params.len());
19419 params.push("parent", self._parent);
19420 if let Some(value) = self._project_id.as_ref() {
19421 params.push("projectId", value);
19422 }
19423 if let Some(value) = self._page_token.as_ref() {
19424 params.push("pageToken", value);
19425 }
19426 if let Some(value) = self._page_size.as_ref() {
19427 params.push("pageSize", value.to_string());
19428 }
19429
19430 params.extend(self._additional_params.iter());
19431
19432 params.push("alt", "json");
19433 let mut url = self.hub._base_url.clone() + "v1/{+parent}/triggers";
19434 if self._scopes.is_empty() {
19435 self._scopes
19436 .insert(Scope::CloudPlatform.as_ref().to_string());
19437 }
19438
19439 #[allow(clippy::single_element_loop)]
19440 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
19441 url = params.uri_replacement(url, param_name, find_this, true);
19442 }
19443 {
19444 let to_remove = ["parent"];
19445 params.remove_params(&to_remove);
19446 }
19447
19448 let url = params.parse_with_url(&url);
19449
19450 loop {
19451 let token = match self
19452 .hub
19453 .auth
19454 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19455 .await
19456 {
19457 Ok(token) => token,
19458 Err(e) => match dlg.token(e) {
19459 Ok(token) => token,
19460 Err(e) => {
19461 dlg.finished(false);
19462 return Err(common::Error::MissingToken(e));
19463 }
19464 },
19465 };
19466 let mut req_result = {
19467 let client = &self.hub.client;
19468 dlg.pre_request();
19469 let mut req_builder = hyper::Request::builder()
19470 .method(hyper::Method::GET)
19471 .uri(url.as_str())
19472 .header(USER_AGENT, self.hub._user_agent.clone());
19473
19474 if let Some(token) = token.as_ref() {
19475 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19476 }
19477
19478 let request = req_builder
19479 .header(CONTENT_LENGTH, 0_u64)
19480 .body(common::to_body::<String>(None));
19481
19482 client.request(request.unwrap()).await
19483 };
19484
19485 match req_result {
19486 Err(err) => {
19487 if let common::Retry::After(d) = dlg.http_error(&err) {
19488 sleep(d).await;
19489 continue;
19490 }
19491 dlg.finished(false);
19492 return Err(common::Error::HttpError(err));
19493 }
19494 Ok(res) => {
19495 let (mut parts, body) = res.into_parts();
19496 let mut body = common::Body::new(body);
19497 if !parts.status.is_success() {
19498 let bytes = common::to_bytes(body).await.unwrap_or_default();
19499 let error = serde_json::from_str(&common::to_string(&bytes));
19500 let response = common::to_response(parts, bytes.into());
19501
19502 if let common::Retry::After(d) =
19503 dlg.http_failure(&response, error.as_ref().ok())
19504 {
19505 sleep(d).await;
19506 continue;
19507 }
19508
19509 dlg.finished(false);
19510
19511 return Err(match error {
19512 Ok(value) => common::Error::BadRequest(value),
19513 _ => common::Error::Failure(response),
19514 });
19515 }
19516 let response = {
19517 let bytes = common::to_bytes(body).await.unwrap_or_default();
19518 let encoded = common::to_string(&bytes);
19519 match serde_json::from_str(&encoded) {
19520 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19521 Err(error) => {
19522 dlg.response_json_decode_error(&encoded, &error);
19523 return Err(common::Error::JsonDecodeError(
19524 encoded.to_string(),
19525 error,
19526 ));
19527 }
19528 }
19529 };
19530
19531 dlg.finished(true);
19532 return Ok(response);
19533 }
19534 }
19535 }
19536 }
19537
19538 /// The parent of the collection of `Triggers`. Format: `projects/{project}/locations/{location}`
19539 ///
19540 /// Sets the *parent* path property to the given value.
19541 ///
19542 /// Even though the property as already been set when instantiating this call,
19543 /// we provide this method for API completeness.
19544 pub fn parent(mut self, new_value: &str) -> ProjectLocationTriggerListCall<'a, C> {
19545 self._parent = new_value.to_string();
19546 self
19547 }
19548 /// Required. ID of the project for which to list BuildTriggers.
19549 ///
19550 /// Sets the *project id* query property to the given value.
19551 pub fn project_id(mut self, new_value: &str) -> ProjectLocationTriggerListCall<'a, C> {
19552 self._project_id = Some(new_value.to_string());
19553 self
19554 }
19555 /// Token to provide to skip to a particular spot in the list.
19556 ///
19557 /// Sets the *page token* query property to the given value.
19558 pub fn page_token(mut self, new_value: &str) -> ProjectLocationTriggerListCall<'a, C> {
19559 self._page_token = Some(new_value.to_string());
19560 self
19561 }
19562 /// Number of results to return in the list.
19563 ///
19564 /// Sets the *page size* query property to the given value.
19565 pub fn page_size(mut self, new_value: i32) -> ProjectLocationTriggerListCall<'a, C> {
19566 self._page_size = Some(new_value);
19567 self
19568 }
19569 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19570 /// while executing the actual API request.
19571 ///
19572 /// ````text
19573 /// It should be used to handle progress information, and to implement a certain level of resilience.
19574 /// ````
19575 ///
19576 /// Sets the *delegate* property to the given value.
19577 pub fn delegate(
19578 mut self,
19579 new_value: &'a mut dyn common::Delegate,
19580 ) -> ProjectLocationTriggerListCall<'a, C> {
19581 self._delegate = Some(new_value);
19582 self
19583 }
19584
19585 /// Set any additional parameter of the query string used in the request.
19586 /// It should be used to set parameters which are not yet available through their own
19587 /// setters.
19588 ///
19589 /// Please note that this method must not be used to set any of the known parameters
19590 /// which have their own setter method. If done anyway, the request will fail.
19591 ///
19592 /// # Additional Parameters
19593 ///
19594 /// * *$.xgafv* (query-string) - V1 error format.
19595 /// * *access_token* (query-string) - OAuth access token.
19596 /// * *alt* (query-string) - Data format for response.
19597 /// * *callback* (query-string) - JSONP
19598 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19599 /// * *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.
19600 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19601 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19602 /// * *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.
19603 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19604 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19605 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationTriggerListCall<'a, C>
19606 where
19607 T: AsRef<str>,
19608 {
19609 self._additional_params
19610 .insert(name.as_ref().to_string(), value.as_ref().to_string());
19611 self
19612 }
19613
19614 /// Identifies the authorization scope for the method you are building.
19615 ///
19616 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19617 /// [`Scope::CloudPlatform`].
19618 ///
19619 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19620 /// tokens for more than one scope.
19621 ///
19622 /// Usually there is more than one suitable scope to authorize an operation, some of which may
19623 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19624 /// sufficient, a read-write scope will do as well.
19625 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationTriggerListCall<'a, C>
19626 where
19627 St: AsRef<str>,
19628 {
19629 self._scopes.insert(String::from(scope.as_ref()));
19630 self
19631 }
19632 /// Identifies the authorization scope(s) for the method you are building.
19633 ///
19634 /// See [`Self::add_scope()`] for details.
19635 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationTriggerListCall<'a, C>
19636 where
19637 I: IntoIterator<Item = St>,
19638 St: AsRef<str>,
19639 {
19640 self._scopes
19641 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19642 self
19643 }
19644
19645 /// Removes all scopes, and no default scope will be used either.
19646 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19647 /// for details).
19648 pub fn clear_scopes(mut self) -> ProjectLocationTriggerListCall<'a, C> {
19649 self._scopes.clear();
19650 self
19651 }
19652}
19653
19654/// Updates a `BuildTrigger` by its project ID and trigger ID.
19655///
19656/// A builder for the *locations.triggers.patch* method supported by a *project* resource.
19657/// It is not used directly, but through a [`ProjectMethods`] instance.
19658///
19659/// # Example
19660///
19661/// Instantiate a resource method builder
19662///
19663/// ```test_harness,no_run
19664/// # extern crate hyper;
19665/// # extern crate hyper_rustls;
19666/// # extern crate google_cloudbuild1 as cloudbuild1;
19667/// use cloudbuild1::api::BuildTrigger;
19668/// # async fn dox() {
19669/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19670///
19671/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19672/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
19673/// # secret,
19674/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19675/// # ).build().await.unwrap();
19676///
19677/// # let client = hyper_util::client::legacy::Client::builder(
19678/// # hyper_util::rt::TokioExecutor::new()
19679/// # )
19680/// # .build(
19681/// # hyper_rustls::HttpsConnectorBuilder::new()
19682/// # .with_native_roots()
19683/// # .unwrap()
19684/// # .https_or_http()
19685/// # .enable_http1()
19686/// # .build()
19687/// # );
19688/// # let mut hub = CloudBuild::new(client, auth);
19689/// // As the method needs a request, you would usually fill it with the desired information
19690/// // into the respective structure. Some of the parts shown here might not be applicable !
19691/// // Values shown here are possibly random and not representative !
19692/// let mut req = BuildTrigger::default();
19693///
19694/// // You can configure optional parameters by calling the respective setters at will, and
19695/// // execute the final call using `doit()`.
19696/// // Values shown here are possibly random and not representative !
19697/// let result = hub.projects().locations_triggers_patch(req, "resourceName")
19698/// .update_mask(FieldMask::new::<&str>(&[]))
19699/// .trigger_id("ipsum")
19700/// .project_id("et")
19701/// .doit().await;
19702/// # }
19703/// ```
19704pub struct ProjectLocationTriggerPatchCall<'a, C>
19705where
19706 C: 'a,
19707{
19708 hub: &'a CloudBuild<C>,
19709 _request: BuildTrigger,
19710 _resource_name: String,
19711 _update_mask: Option<common::FieldMask>,
19712 _trigger_id: Option<String>,
19713 _project_id: Option<String>,
19714 _delegate: Option<&'a mut dyn common::Delegate>,
19715 _additional_params: HashMap<String, String>,
19716 _scopes: BTreeSet<String>,
19717}
19718
19719impl<'a, C> common::CallBuilder for ProjectLocationTriggerPatchCall<'a, C> {}
19720
19721impl<'a, C> ProjectLocationTriggerPatchCall<'a, C>
19722where
19723 C: common::Connector,
19724{
19725 /// Perform the operation you have build so far.
19726 pub async fn doit(mut self) -> common::Result<(common::Response, BuildTrigger)> {
19727 use std::borrow::Cow;
19728 use std::io::{Read, Seek};
19729
19730 use common::{url::Params, ToParts};
19731 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19732
19733 let mut dd = common::DefaultDelegate;
19734 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19735 dlg.begin(common::MethodInfo {
19736 id: "cloudbuild.projects.locations.triggers.patch",
19737 http_method: hyper::Method::PATCH,
19738 });
19739
19740 for &field in [
19741 "alt",
19742 "resourceName",
19743 "updateMask",
19744 "triggerId",
19745 "projectId",
19746 ]
19747 .iter()
19748 {
19749 if self._additional_params.contains_key(field) {
19750 dlg.finished(false);
19751 return Err(common::Error::FieldClash(field));
19752 }
19753 }
19754
19755 let mut params = Params::with_capacity(7 + self._additional_params.len());
19756 params.push("resourceName", self._resource_name);
19757 if let Some(value) = self._update_mask.as_ref() {
19758 params.push("updateMask", value.to_string());
19759 }
19760 if let Some(value) = self._trigger_id.as_ref() {
19761 params.push("triggerId", value);
19762 }
19763 if let Some(value) = self._project_id.as_ref() {
19764 params.push("projectId", value);
19765 }
19766
19767 params.extend(self._additional_params.iter());
19768
19769 params.push("alt", "json");
19770 let mut url = self.hub._base_url.clone() + "v1/{+resourceName}";
19771 if self._scopes.is_empty() {
19772 self._scopes
19773 .insert(Scope::CloudPlatform.as_ref().to_string());
19774 }
19775
19776 #[allow(clippy::single_element_loop)]
19777 for &(find_this, param_name) in [("{+resourceName}", "resourceName")].iter() {
19778 url = params.uri_replacement(url, param_name, find_this, true);
19779 }
19780 {
19781 let to_remove = ["resourceName"];
19782 params.remove_params(&to_remove);
19783 }
19784
19785 let url = params.parse_with_url(&url);
19786
19787 let mut json_mime_type = mime::APPLICATION_JSON;
19788 let mut request_value_reader = {
19789 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
19790 common::remove_json_null_values(&mut value);
19791 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
19792 serde_json::to_writer(&mut dst, &value).unwrap();
19793 dst
19794 };
19795 let request_size = request_value_reader
19796 .seek(std::io::SeekFrom::End(0))
19797 .unwrap();
19798 request_value_reader
19799 .seek(std::io::SeekFrom::Start(0))
19800 .unwrap();
19801
19802 loop {
19803 let token = match self
19804 .hub
19805 .auth
19806 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19807 .await
19808 {
19809 Ok(token) => token,
19810 Err(e) => match dlg.token(e) {
19811 Ok(token) => token,
19812 Err(e) => {
19813 dlg.finished(false);
19814 return Err(common::Error::MissingToken(e));
19815 }
19816 },
19817 };
19818 request_value_reader
19819 .seek(std::io::SeekFrom::Start(0))
19820 .unwrap();
19821 let mut req_result = {
19822 let client = &self.hub.client;
19823 dlg.pre_request();
19824 let mut req_builder = hyper::Request::builder()
19825 .method(hyper::Method::PATCH)
19826 .uri(url.as_str())
19827 .header(USER_AGENT, self.hub._user_agent.clone());
19828
19829 if let Some(token) = token.as_ref() {
19830 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19831 }
19832
19833 let request = req_builder
19834 .header(CONTENT_TYPE, json_mime_type.to_string())
19835 .header(CONTENT_LENGTH, request_size as u64)
19836 .body(common::to_body(
19837 request_value_reader.get_ref().clone().into(),
19838 ));
19839
19840 client.request(request.unwrap()).await
19841 };
19842
19843 match req_result {
19844 Err(err) => {
19845 if let common::Retry::After(d) = dlg.http_error(&err) {
19846 sleep(d).await;
19847 continue;
19848 }
19849 dlg.finished(false);
19850 return Err(common::Error::HttpError(err));
19851 }
19852 Ok(res) => {
19853 let (mut parts, body) = res.into_parts();
19854 let mut body = common::Body::new(body);
19855 if !parts.status.is_success() {
19856 let bytes = common::to_bytes(body).await.unwrap_or_default();
19857 let error = serde_json::from_str(&common::to_string(&bytes));
19858 let response = common::to_response(parts, bytes.into());
19859
19860 if let common::Retry::After(d) =
19861 dlg.http_failure(&response, error.as_ref().ok())
19862 {
19863 sleep(d).await;
19864 continue;
19865 }
19866
19867 dlg.finished(false);
19868
19869 return Err(match error {
19870 Ok(value) => common::Error::BadRequest(value),
19871 _ => common::Error::Failure(response),
19872 });
19873 }
19874 let response = {
19875 let bytes = common::to_bytes(body).await.unwrap_or_default();
19876 let encoded = common::to_string(&bytes);
19877 match serde_json::from_str(&encoded) {
19878 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19879 Err(error) => {
19880 dlg.response_json_decode_error(&encoded, &error);
19881 return Err(common::Error::JsonDecodeError(
19882 encoded.to_string(),
19883 error,
19884 ));
19885 }
19886 }
19887 };
19888
19889 dlg.finished(true);
19890 return Ok(response);
19891 }
19892 }
19893 }
19894 }
19895
19896 ///
19897 /// Sets the *request* property to the given value.
19898 ///
19899 /// Even though the property as already been set when instantiating this call,
19900 /// we provide this method for API completeness.
19901 pub fn request(mut self, new_value: BuildTrigger) -> ProjectLocationTriggerPatchCall<'a, C> {
19902 self._request = new_value;
19903 self
19904 }
19905 /// The `Trigger` name with format: `projects/{project}/locations/{location}/triggers/{trigger}`, where {trigger} is a unique identifier generated by the service.
19906 ///
19907 /// Sets the *resource name* path property to the given value.
19908 ///
19909 /// Even though the property as already been set when instantiating this call,
19910 /// we provide this method for API completeness.
19911 pub fn resource_name(mut self, new_value: &str) -> ProjectLocationTriggerPatchCall<'a, C> {
19912 self._resource_name = new_value.to_string();
19913 self
19914 }
19915 /// Update mask for the resource. If this is set, the server will only update the fields specified in the field mask. Otherwise, a full update of the mutable resource fields will be performed.
19916 ///
19917 /// Sets the *update mask* query property to the given value.
19918 pub fn update_mask(
19919 mut self,
19920 new_value: common::FieldMask,
19921 ) -> ProjectLocationTriggerPatchCall<'a, C> {
19922 self._update_mask = Some(new_value);
19923 self
19924 }
19925 /// Required. ID of the `BuildTrigger` to update.
19926 ///
19927 /// Sets the *trigger id* query property to the given value.
19928 pub fn trigger_id(mut self, new_value: &str) -> ProjectLocationTriggerPatchCall<'a, C> {
19929 self._trigger_id = Some(new_value.to_string());
19930 self
19931 }
19932 /// Required. ID of the project that owns the trigger.
19933 ///
19934 /// Sets the *project id* query property to the given value.
19935 pub fn project_id(mut self, new_value: &str) -> ProjectLocationTriggerPatchCall<'a, C> {
19936 self._project_id = Some(new_value.to_string());
19937 self
19938 }
19939 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19940 /// while executing the actual API request.
19941 ///
19942 /// ````text
19943 /// It should be used to handle progress information, and to implement a certain level of resilience.
19944 /// ````
19945 ///
19946 /// Sets the *delegate* property to the given value.
19947 pub fn delegate(
19948 mut self,
19949 new_value: &'a mut dyn common::Delegate,
19950 ) -> ProjectLocationTriggerPatchCall<'a, C> {
19951 self._delegate = Some(new_value);
19952 self
19953 }
19954
19955 /// Set any additional parameter of the query string used in the request.
19956 /// It should be used to set parameters which are not yet available through their own
19957 /// setters.
19958 ///
19959 /// Please note that this method must not be used to set any of the known parameters
19960 /// which have their own setter method. If done anyway, the request will fail.
19961 ///
19962 /// # Additional Parameters
19963 ///
19964 /// * *$.xgafv* (query-string) - V1 error format.
19965 /// * *access_token* (query-string) - OAuth access token.
19966 /// * *alt* (query-string) - Data format for response.
19967 /// * *callback* (query-string) - JSONP
19968 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19969 /// * *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.
19970 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19971 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19972 /// * *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.
19973 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19974 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19975 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationTriggerPatchCall<'a, C>
19976 where
19977 T: AsRef<str>,
19978 {
19979 self._additional_params
19980 .insert(name.as_ref().to_string(), value.as_ref().to_string());
19981 self
19982 }
19983
19984 /// Identifies the authorization scope for the method you are building.
19985 ///
19986 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19987 /// [`Scope::CloudPlatform`].
19988 ///
19989 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19990 /// tokens for more than one scope.
19991 ///
19992 /// Usually there is more than one suitable scope to authorize an operation, some of which may
19993 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19994 /// sufficient, a read-write scope will do as well.
19995 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationTriggerPatchCall<'a, C>
19996 where
19997 St: AsRef<str>,
19998 {
19999 self._scopes.insert(String::from(scope.as_ref()));
20000 self
20001 }
20002 /// Identifies the authorization scope(s) for the method you are building.
20003 ///
20004 /// See [`Self::add_scope()`] for details.
20005 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationTriggerPatchCall<'a, C>
20006 where
20007 I: IntoIterator<Item = St>,
20008 St: AsRef<str>,
20009 {
20010 self._scopes
20011 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20012 self
20013 }
20014
20015 /// Removes all scopes, and no default scope will be used either.
20016 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20017 /// for details).
20018 pub fn clear_scopes(mut self) -> ProjectLocationTriggerPatchCall<'a, C> {
20019 self._scopes.clear();
20020 self
20021 }
20022}
20023
20024/// Runs a `BuildTrigger` at a particular source revision. To run a regional or global trigger, use the POST request that includes the location endpoint in the path (ex. v1/projects/{projectId}/locations/{region}/triggers/{triggerId}:run). The POST request that does not include the location endpoint in the path can only be used when running global triggers.
20025///
20026/// A builder for the *locations.triggers.run* method supported by a *project* resource.
20027/// It is not used directly, but through a [`ProjectMethods`] instance.
20028///
20029/// # Example
20030///
20031/// Instantiate a resource method builder
20032///
20033/// ```test_harness,no_run
20034/// # extern crate hyper;
20035/// # extern crate hyper_rustls;
20036/// # extern crate google_cloudbuild1 as cloudbuild1;
20037/// use cloudbuild1::api::RunBuildTriggerRequest;
20038/// # async fn dox() {
20039/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20040///
20041/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20042/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
20043/// # secret,
20044/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20045/// # ).build().await.unwrap();
20046///
20047/// # let client = hyper_util::client::legacy::Client::builder(
20048/// # hyper_util::rt::TokioExecutor::new()
20049/// # )
20050/// # .build(
20051/// # hyper_rustls::HttpsConnectorBuilder::new()
20052/// # .with_native_roots()
20053/// # .unwrap()
20054/// # .https_or_http()
20055/// # .enable_http1()
20056/// # .build()
20057/// # );
20058/// # let mut hub = CloudBuild::new(client, auth);
20059/// // As the method needs a request, you would usually fill it with the desired information
20060/// // into the respective structure. Some of the parts shown here might not be applicable !
20061/// // Values shown here are possibly random and not representative !
20062/// let mut req = RunBuildTriggerRequest::default();
20063///
20064/// // You can configure optional parameters by calling the respective setters at will, and
20065/// // execute the final call using `doit()`.
20066/// // Values shown here are possibly random and not representative !
20067/// let result = hub.projects().locations_triggers_run(req, "name")
20068/// .doit().await;
20069/// # }
20070/// ```
20071pub struct ProjectLocationTriggerRunCall<'a, C>
20072where
20073 C: 'a,
20074{
20075 hub: &'a CloudBuild<C>,
20076 _request: RunBuildTriggerRequest,
20077 _name: String,
20078 _delegate: Option<&'a mut dyn common::Delegate>,
20079 _additional_params: HashMap<String, String>,
20080 _scopes: BTreeSet<String>,
20081}
20082
20083impl<'a, C> common::CallBuilder for ProjectLocationTriggerRunCall<'a, C> {}
20084
20085impl<'a, C> ProjectLocationTriggerRunCall<'a, C>
20086where
20087 C: common::Connector,
20088{
20089 /// Perform the operation you have build so far.
20090 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
20091 use std::borrow::Cow;
20092 use std::io::{Read, Seek};
20093
20094 use common::{url::Params, ToParts};
20095 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20096
20097 let mut dd = common::DefaultDelegate;
20098 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20099 dlg.begin(common::MethodInfo {
20100 id: "cloudbuild.projects.locations.triggers.run",
20101 http_method: hyper::Method::POST,
20102 });
20103
20104 for &field in ["alt", "name"].iter() {
20105 if self._additional_params.contains_key(field) {
20106 dlg.finished(false);
20107 return Err(common::Error::FieldClash(field));
20108 }
20109 }
20110
20111 let mut params = Params::with_capacity(4 + self._additional_params.len());
20112 params.push("name", self._name);
20113
20114 params.extend(self._additional_params.iter());
20115
20116 params.push("alt", "json");
20117 let mut url = self.hub._base_url.clone() + "v1/{+name}:run";
20118 if self._scopes.is_empty() {
20119 self._scopes
20120 .insert(Scope::CloudPlatform.as_ref().to_string());
20121 }
20122
20123 #[allow(clippy::single_element_loop)]
20124 for &(find_this, param_name) in [("{+name}", "name")].iter() {
20125 url = params.uri_replacement(url, param_name, find_this, true);
20126 }
20127 {
20128 let to_remove = ["name"];
20129 params.remove_params(&to_remove);
20130 }
20131
20132 let url = params.parse_with_url(&url);
20133
20134 let mut json_mime_type = mime::APPLICATION_JSON;
20135 let mut request_value_reader = {
20136 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
20137 common::remove_json_null_values(&mut value);
20138 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
20139 serde_json::to_writer(&mut dst, &value).unwrap();
20140 dst
20141 };
20142 let request_size = request_value_reader
20143 .seek(std::io::SeekFrom::End(0))
20144 .unwrap();
20145 request_value_reader
20146 .seek(std::io::SeekFrom::Start(0))
20147 .unwrap();
20148
20149 loop {
20150 let token = match self
20151 .hub
20152 .auth
20153 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20154 .await
20155 {
20156 Ok(token) => token,
20157 Err(e) => match dlg.token(e) {
20158 Ok(token) => token,
20159 Err(e) => {
20160 dlg.finished(false);
20161 return Err(common::Error::MissingToken(e));
20162 }
20163 },
20164 };
20165 request_value_reader
20166 .seek(std::io::SeekFrom::Start(0))
20167 .unwrap();
20168 let mut req_result = {
20169 let client = &self.hub.client;
20170 dlg.pre_request();
20171 let mut req_builder = hyper::Request::builder()
20172 .method(hyper::Method::POST)
20173 .uri(url.as_str())
20174 .header(USER_AGENT, self.hub._user_agent.clone());
20175
20176 if let Some(token) = token.as_ref() {
20177 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20178 }
20179
20180 let request = req_builder
20181 .header(CONTENT_TYPE, json_mime_type.to_string())
20182 .header(CONTENT_LENGTH, request_size as u64)
20183 .body(common::to_body(
20184 request_value_reader.get_ref().clone().into(),
20185 ));
20186
20187 client.request(request.unwrap()).await
20188 };
20189
20190 match req_result {
20191 Err(err) => {
20192 if let common::Retry::After(d) = dlg.http_error(&err) {
20193 sleep(d).await;
20194 continue;
20195 }
20196 dlg.finished(false);
20197 return Err(common::Error::HttpError(err));
20198 }
20199 Ok(res) => {
20200 let (mut parts, body) = res.into_parts();
20201 let mut body = common::Body::new(body);
20202 if !parts.status.is_success() {
20203 let bytes = common::to_bytes(body).await.unwrap_or_default();
20204 let error = serde_json::from_str(&common::to_string(&bytes));
20205 let response = common::to_response(parts, bytes.into());
20206
20207 if let common::Retry::After(d) =
20208 dlg.http_failure(&response, error.as_ref().ok())
20209 {
20210 sleep(d).await;
20211 continue;
20212 }
20213
20214 dlg.finished(false);
20215
20216 return Err(match error {
20217 Ok(value) => common::Error::BadRequest(value),
20218 _ => common::Error::Failure(response),
20219 });
20220 }
20221 let response = {
20222 let bytes = common::to_bytes(body).await.unwrap_or_default();
20223 let encoded = common::to_string(&bytes);
20224 match serde_json::from_str(&encoded) {
20225 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20226 Err(error) => {
20227 dlg.response_json_decode_error(&encoded, &error);
20228 return Err(common::Error::JsonDecodeError(
20229 encoded.to_string(),
20230 error,
20231 ));
20232 }
20233 }
20234 };
20235
20236 dlg.finished(true);
20237 return Ok(response);
20238 }
20239 }
20240 }
20241 }
20242
20243 ///
20244 /// Sets the *request* property to the given value.
20245 ///
20246 /// Even though the property as already been set when instantiating this call,
20247 /// we provide this method for API completeness.
20248 pub fn request(
20249 mut self,
20250 new_value: RunBuildTriggerRequest,
20251 ) -> ProjectLocationTriggerRunCall<'a, C> {
20252 self._request = new_value;
20253 self
20254 }
20255 /// The name of the `Trigger` to run. Format: `projects/{project}/locations/{location}/triggers/{trigger}`
20256 ///
20257 /// Sets the *name* path property to the given value.
20258 ///
20259 /// Even though the property as already been set when instantiating this call,
20260 /// we provide this method for API completeness.
20261 pub fn name(mut self, new_value: &str) -> ProjectLocationTriggerRunCall<'a, C> {
20262 self._name = new_value.to_string();
20263 self
20264 }
20265 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20266 /// while executing the actual API request.
20267 ///
20268 /// ````text
20269 /// It should be used to handle progress information, and to implement a certain level of resilience.
20270 /// ````
20271 ///
20272 /// Sets the *delegate* property to the given value.
20273 pub fn delegate(
20274 mut self,
20275 new_value: &'a mut dyn common::Delegate,
20276 ) -> ProjectLocationTriggerRunCall<'a, C> {
20277 self._delegate = Some(new_value);
20278 self
20279 }
20280
20281 /// Set any additional parameter of the query string used in the request.
20282 /// It should be used to set parameters which are not yet available through their own
20283 /// setters.
20284 ///
20285 /// Please note that this method must not be used to set any of the known parameters
20286 /// which have their own setter method. If done anyway, the request will fail.
20287 ///
20288 /// # Additional Parameters
20289 ///
20290 /// * *$.xgafv* (query-string) - V1 error format.
20291 /// * *access_token* (query-string) - OAuth access token.
20292 /// * *alt* (query-string) - Data format for response.
20293 /// * *callback* (query-string) - JSONP
20294 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20295 /// * *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.
20296 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20297 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20298 /// * *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.
20299 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20300 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20301 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationTriggerRunCall<'a, C>
20302 where
20303 T: AsRef<str>,
20304 {
20305 self._additional_params
20306 .insert(name.as_ref().to_string(), value.as_ref().to_string());
20307 self
20308 }
20309
20310 /// Identifies the authorization scope for the method you are building.
20311 ///
20312 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20313 /// [`Scope::CloudPlatform`].
20314 ///
20315 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20316 /// tokens for more than one scope.
20317 ///
20318 /// Usually there is more than one suitable scope to authorize an operation, some of which may
20319 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20320 /// sufficient, a read-write scope will do as well.
20321 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationTriggerRunCall<'a, C>
20322 where
20323 St: AsRef<str>,
20324 {
20325 self._scopes.insert(String::from(scope.as_ref()));
20326 self
20327 }
20328 /// Identifies the authorization scope(s) for the method you are building.
20329 ///
20330 /// See [`Self::add_scope()`] for details.
20331 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationTriggerRunCall<'a, C>
20332 where
20333 I: IntoIterator<Item = St>,
20334 St: AsRef<str>,
20335 {
20336 self._scopes
20337 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20338 self
20339 }
20340
20341 /// Removes all scopes, and no default scope will be used either.
20342 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20343 /// for details).
20344 pub fn clear_scopes(mut self) -> ProjectLocationTriggerRunCall<'a, C> {
20345 self._scopes.clear();
20346 self
20347 }
20348}
20349
20350/// ReceiveTriggerWebhook [Experimental] is called when the API receives a webhook request targeted at a specific trigger.
20351///
20352/// A builder for the *locations.triggers.webhook* method supported by a *project* resource.
20353/// It is not used directly, but through a [`ProjectMethods`] instance.
20354///
20355/// # Example
20356///
20357/// Instantiate a resource method builder
20358///
20359/// ```test_harness,no_run
20360/// # extern crate hyper;
20361/// # extern crate hyper_rustls;
20362/// # extern crate google_cloudbuild1 as cloudbuild1;
20363/// use cloudbuild1::api::HttpBody;
20364/// # async fn dox() {
20365/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20366///
20367/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20368/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
20369/// # secret,
20370/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20371/// # ).build().await.unwrap();
20372///
20373/// # let client = hyper_util::client::legacy::Client::builder(
20374/// # hyper_util::rt::TokioExecutor::new()
20375/// # )
20376/// # .build(
20377/// # hyper_rustls::HttpsConnectorBuilder::new()
20378/// # .with_native_roots()
20379/// # .unwrap()
20380/// # .https_or_http()
20381/// # .enable_http1()
20382/// # .build()
20383/// # );
20384/// # let mut hub = CloudBuild::new(client, auth);
20385/// // As the method needs a request, you would usually fill it with the desired information
20386/// // into the respective structure. Some of the parts shown here might not be applicable !
20387/// // Values shown here are possibly random and not representative !
20388/// let mut req = HttpBody::default();
20389///
20390/// // You can configure optional parameters by calling the respective setters at will, and
20391/// // execute the final call using `doit()`.
20392/// // Values shown here are possibly random and not representative !
20393/// let result = hub.projects().locations_triggers_webhook(req, "name")
20394/// .trigger("est")
20395/// .secret("sed")
20396/// .project_id("diam")
20397/// .doit().await;
20398/// # }
20399/// ```
20400pub struct ProjectLocationTriggerWebhookCall<'a, C>
20401where
20402 C: 'a,
20403{
20404 hub: &'a CloudBuild<C>,
20405 _request: HttpBody,
20406 _name: String,
20407 _trigger: Option<String>,
20408 _secret: Option<String>,
20409 _project_id: Option<String>,
20410 _delegate: Option<&'a mut dyn common::Delegate>,
20411 _additional_params: HashMap<String, String>,
20412}
20413
20414impl<'a, C> common::CallBuilder for ProjectLocationTriggerWebhookCall<'a, C> {}
20415
20416impl<'a, C> ProjectLocationTriggerWebhookCall<'a, C>
20417where
20418 C: common::Connector,
20419{
20420 /// Perform the operation you have build so far.
20421 pub async fn doit(
20422 mut self,
20423 ) -> common::Result<(common::Response, ReceiveTriggerWebhookResponse)> {
20424 use std::borrow::Cow;
20425 use std::io::{Read, Seek};
20426
20427 use common::{url::Params, ToParts};
20428 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20429
20430 let mut dd = common::DefaultDelegate;
20431 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20432 dlg.begin(common::MethodInfo {
20433 id: "cloudbuild.projects.locations.triggers.webhook",
20434 http_method: hyper::Method::POST,
20435 });
20436
20437 for &field in ["alt", "name", "trigger", "secret", "projectId"].iter() {
20438 if self._additional_params.contains_key(field) {
20439 dlg.finished(false);
20440 return Err(common::Error::FieldClash(field));
20441 }
20442 }
20443
20444 let mut params = Params::with_capacity(7 + self._additional_params.len());
20445 params.push("name", self._name);
20446 if let Some(value) = self._trigger.as_ref() {
20447 params.push("trigger", value);
20448 }
20449 if let Some(value) = self._secret.as_ref() {
20450 params.push("secret", value);
20451 }
20452 if let Some(value) = self._project_id.as_ref() {
20453 params.push("projectId", value);
20454 }
20455
20456 params.extend(self._additional_params.iter());
20457
20458 params.push("alt", "json");
20459 let mut url = self.hub._base_url.clone() + "v1/{+name}:webhook";
20460
20461 match dlg.api_key() {
20462 Some(value) => params.push("key", value),
20463 None => {
20464 dlg.finished(false);
20465 return Err(common::Error::MissingAPIKey);
20466 }
20467 }
20468
20469 #[allow(clippy::single_element_loop)]
20470 for &(find_this, param_name) in [("{+name}", "name")].iter() {
20471 url = params.uri_replacement(url, param_name, find_this, true);
20472 }
20473 {
20474 let to_remove = ["name"];
20475 params.remove_params(&to_remove);
20476 }
20477
20478 let url = params.parse_with_url(&url);
20479
20480 let mut json_mime_type = mime::APPLICATION_JSON;
20481 let mut request_value_reader = {
20482 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
20483 common::remove_json_null_values(&mut value);
20484 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
20485 serde_json::to_writer(&mut dst, &value).unwrap();
20486 dst
20487 };
20488 let request_size = request_value_reader
20489 .seek(std::io::SeekFrom::End(0))
20490 .unwrap();
20491 request_value_reader
20492 .seek(std::io::SeekFrom::Start(0))
20493 .unwrap();
20494
20495 loop {
20496 request_value_reader
20497 .seek(std::io::SeekFrom::Start(0))
20498 .unwrap();
20499 let mut req_result = {
20500 let client = &self.hub.client;
20501 dlg.pre_request();
20502 let mut req_builder = hyper::Request::builder()
20503 .method(hyper::Method::POST)
20504 .uri(url.as_str())
20505 .header(USER_AGENT, self.hub._user_agent.clone());
20506
20507 let request = req_builder
20508 .header(CONTENT_TYPE, json_mime_type.to_string())
20509 .header(CONTENT_LENGTH, request_size as u64)
20510 .body(common::to_body(
20511 request_value_reader.get_ref().clone().into(),
20512 ));
20513
20514 client.request(request.unwrap()).await
20515 };
20516
20517 match req_result {
20518 Err(err) => {
20519 if let common::Retry::After(d) = dlg.http_error(&err) {
20520 sleep(d).await;
20521 continue;
20522 }
20523 dlg.finished(false);
20524 return Err(common::Error::HttpError(err));
20525 }
20526 Ok(res) => {
20527 let (mut parts, body) = res.into_parts();
20528 let mut body = common::Body::new(body);
20529 if !parts.status.is_success() {
20530 let bytes = common::to_bytes(body).await.unwrap_or_default();
20531 let error = serde_json::from_str(&common::to_string(&bytes));
20532 let response = common::to_response(parts, bytes.into());
20533
20534 if let common::Retry::After(d) =
20535 dlg.http_failure(&response, error.as_ref().ok())
20536 {
20537 sleep(d).await;
20538 continue;
20539 }
20540
20541 dlg.finished(false);
20542
20543 return Err(match error {
20544 Ok(value) => common::Error::BadRequest(value),
20545 _ => common::Error::Failure(response),
20546 });
20547 }
20548 let response = {
20549 let bytes = common::to_bytes(body).await.unwrap_or_default();
20550 let encoded = common::to_string(&bytes);
20551 match serde_json::from_str(&encoded) {
20552 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20553 Err(error) => {
20554 dlg.response_json_decode_error(&encoded, &error);
20555 return Err(common::Error::JsonDecodeError(
20556 encoded.to_string(),
20557 error,
20558 ));
20559 }
20560 }
20561 };
20562
20563 dlg.finished(true);
20564 return Ok(response);
20565 }
20566 }
20567 }
20568 }
20569
20570 ///
20571 /// Sets the *request* property to the given value.
20572 ///
20573 /// Even though the property as already been set when instantiating this call,
20574 /// we provide this method for API completeness.
20575 pub fn request(mut self, new_value: HttpBody) -> ProjectLocationTriggerWebhookCall<'a, C> {
20576 self._request = new_value;
20577 self
20578 }
20579 /// The name of the `ReceiveTriggerWebhook` to retrieve. Format: `projects/{project}/locations/{location}/triggers/{trigger}`
20580 ///
20581 /// Sets the *name* path property to the given value.
20582 ///
20583 /// Even though the property as already been set when instantiating this call,
20584 /// we provide this method for API completeness.
20585 pub fn name(mut self, new_value: &str) -> ProjectLocationTriggerWebhookCall<'a, C> {
20586 self._name = new_value.to_string();
20587 self
20588 }
20589 /// Name of the trigger to run the payload against
20590 ///
20591 /// Sets the *trigger* query property to the given value.
20592 pub fn trigger(mut self, new_value: &str) -> ProjectLocationTriggerWebhookCall<'a, C> {
20593 self._trigger = Some(new_value.to_string());
20594 self
20595 }
20596 /// Secret token used for authorization if an OAuth token isn't provided.
20597 ///
20598 /// Sets the *secret* query property to the given value.
20599 pub fn secret(mut self, new_value: &str) -> ProjectLocationTriggerWebhookCall<'a, C> {
20600 self._secret = Some(new_value.to_string());
20601 self
20602 }
20603 /// Project in which the specified trigger lives
20604 ///
20605 /// Sets the *project id* query property to the given value.
20606 pub fn project_id(mut self, new_value: &str) -> ProjectLocationTriggerWebhookCall<'a, C> {
20607 self._project_id = Some(new_value.to_string());
20608 self
20609 }
20610 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20611 /// while executing the actual API request.
20612 ///
20613 /// ````text
20614 /// It should be used to handle progress information, and to implement a certain level of resilience.
20615 /// ````
20616 ///
20617 /// Sets the *delegate* property to the given value.
20618 pub fn delegate(
20619 mut self,
20620 new_value: &'a mut dyn common::Delegate,
20621 ) -> ProjectLocationTriggerWebhookCall<'a, C> {
20622 self._delegate = Some(new_value);
20623 self
20624 }
20625
20626 /// Set any additional parameter of the query string used in the request.
20627 /// It should be used to set parameters which are not yet available through their own
20628 /// setters.
20629 ///
20630 /// Please note that this method must not be used to set any of the known parameters
20631 /// which have their own setter method. If done anyway, the request will fail.
20632 ///
20633 /// # Additional Parameters
20634 ///
20635 /// * *$.xgafv* (query-string) - V1 error format.
20636 /// * *access_token* (query-string) - OAuth access token.
20637 /// * *alt* (query-string) - Data format for response.
20638 /// * *callback* (query-string) - JSONP
20639 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20640 /// * *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.
20641 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20642 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20643 /// * *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.
20644 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20645 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20646 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationTriggerWebhookCall<'a, C>
20647 where
20648 T: AsRef<str>,
20649 {
20650 self._additional_params
20651 .insert(name.as_ref().to_string(), value.as_ref().to_string());
20652 self
20653 }
20654}
20655
20656/// Creates a `WorkerPool`.
20657///
20658/// A builder for the *locations.workerPools.create* method supported by a *project* resource.
20659/// It is not used directly, but through a [`ProjectMethods`] instance.
20660///
20661/// # Example
20662///
20663/// Instantiate a resource method builder
20664///
20665/// ```test_harness,no_run
20666/// # extern crate hyper;
20667/// # extern crate hyper_rustls;
20668/// # extern crate google_cloudbuild1 as cloudbuild1;
20669/// use cloudbuild1::api::WorkerPool;
20670/// # async fn dox() {
20671/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20672///
20673/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20674/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
20675/// # secret,
20676/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20677/// # ).build().await.unwrap();
20678///
20679/// # let client = hyper_util::client::legacy::Client::builder(
20680/// # hyper_util::rt::TokioExecutor::new()
20681/// # )
20682/// # .build(
20683/// # hyper_rustls::HttpsConnectorBuilder::new()
20684/// # .with_native_roots()
20685/// # .unwrap()
20686/// # .https_or_http()
20687/// # .enable_http1()
20688/// # .build()
20689/// # );
20690/// # let mut hub = CloudBuild::new(client, auth);
20691/// // As the method needs a request, you would usually fill it with the desired information
20692/// // into the respective structure. Some of the parts shown here might not be applicable !
20693/// // Values shown here are possibly random and not representative !
20694/// let mut req = WorkerPool::default();
20695///
20696/// // You can configure optional parameters by calling the respective setters at will, and
20697/// // execute the final call using `doit()`.
20698/// // Values shown here are possibly random and not representative !
20699/// let result = hub.projects().locations_worker_pools_create(req, "parent")
20700/// .worker_pool_id("dolores")
20701/// .validate_only(true)
20702/// .doit().await;
20703/// # }
20704/// ```
20705pub struct ProjectLocationWorkerPoolCreateCall<'a, C>
20706where
20707 C: 'a,
20708{
20709 hub: &'a CloudBuild<C>,
20710 _request: WorkerPool,
20711 _parent: String,
20712 _worker_pool_id: Option<String>,
20713 _validate_only: Option<bool>,
20714 _delegate: Option<&'a mut dyn common::Delegate>,
20715 _additional_params: HashMap<String, String>,
20716 _scopes: BTreeSet<String>,
20717}
20718
20719impl<'a, C> common::CallBuilder for ProjectLocationWorkerPoolCreateCall<'a, C> {}
20720
20721impl<'a, C> ProjectLocationWorkerPoolCreateCall<'a, C>
20722where
20723 C: common::Connector,
20724{
20725 /// Perform the operation you have build so far.
20726 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
20727 use std::borrow::Cow;
20728 use std::io::{Read, Seek};
20729
20730 use common::{url::Params, ToParts};
20731 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20732
20733 let mut dd = common::DefaultDelegate;
20734 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20735 dlg.begin(common::MethodInfo {
20736 id: "cloudbuild.projects.locations.workerPools.create",
20737 http_method: hyper::Method::POST,
20738 });
20739
20740 for &field in ["alt", "parent", "workerPoolId", "validateOnly"].iter() {
20741 if self._additional_params.contains_key(field) {
20742 dlg.finished(false);
20743 return Err(common::Error::FieldClash(field));
20744 }
20745 }
20746
20747 let mut params = Params::with_capacity(6 + self._additional_params.len());
20748 params.push("parent", self._parent);
20749 if let Some(value) = self._worker_pool_id.as_ref() {
20750 params.push("workerPoolId", value);
20751 }
20752 if let Some(value) = self._validate_only.as_ref() {
20753 params.push("validateOnly", value.to_string());
20754 }
20755
20756 params.extend(self._additional_params.iter());
20757
20758 params.push("alt", "json");
20759 let mut url = self.hub._base_url.clone() + "v1/{+parent}/workerPools";
20760 if self._scopes.is_empty() {
20761 self._scopes
20762 .insert(Scope::CloudPlatform.as_ref().to_string());
20763 }
20764
20765 #[allow(clippy::single_element_loop)]
20766 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
20767 url = params.uri_replacement(url, param_name, find_this, true);
20768 }
20769 {
20770 let to_remove = ["parent"];
20771 params.remove_params(&to_remove);
20772 }
20773
20774 let url = params.parse_with_url(&url);
20775
20776 let mut json_mime_type = mime::APPLICATION_JSON;
20777 let mut request_value_reader = {
20778 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
20779 common::remove_json_null_values(&mut value);
20780 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
20781 serde_json::to_writer(&mut dst, &value).unwrap();
20782 dst
20783 };
20784 let request_size = request_value_reader
20785 .seek(std::io::SeekFrom::End(0))
20786 .unwrap();
20787 request_value_reader
20788 .seek(std::io::SeekFrom::Start(0))
20789 .unwrap();
20790
20791 loop {
20792 let token = match self
20793 .hub
20794 .auth
20795 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20796 .await
20797 {
20798 Ok(token) => token,
20799 Err(e) => match dlg.token(e) {
20800 Ok(token) => token,
20801 Err(e) => {
20802 dlg.finished(false);
20803 return Err(common::Error::MissingToken(e));
20804 }
20805 },
20806 };
20807 request_value_reader
20808 .seek(std::io::SeekFrom::Start(0))
20809 .unwrap();
20810 let mut req_result = {
20811 let client = &self.hub.client;
20812 dlg.pre_request();
20813 let mut req_builder = hyper::Request::builder()
20814 .method(hyper::Method::POST)
20815 .uri(url.as_str())
20816 .header(USER_AGENT, self.hub._user_agent.clone());
20817
20818 if let Some(token) = token.as_ref() {
20819 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20820 }
20821
20822 let request = req_builder
20823 .header(CONTENT_TYPE, json_mime_type.to_string())
20824 .header(CONTENT_LENGTH, request_size as u64)
20825 .body(common::to_body(
20826 request_value_reader.get_ref().clone().into(),
20827 ));
20828
20829 client.request(request.unwrap()).await
20830 };
20831
20832 match req_result {
20833 Err(err) => {
20834 if let common::Retry::After(d) = dlg.http_error(&err) {
20835 sleep(d).await;
20836 continue;
20837 }
20838 dlg.finished(false);
20839 return Err(common::Error::HttpError(err));
20840 }
20841 Ok(res) => {
20842 let (mut parts, body) = res.into_parts();
20843 let mut body = common::Body::new(body);
20844 if !parts.status.is_success() {
20845 let bytes = common::to_bytes(body).await.unwrap_or_default();
20846 let error = serde_json::from_str(&common::to_string(&bytes));
20847 let response = common::to_response(parts, bytes.into());
20848
20849 if let common::Retry::After(d) =
20850 dlg.http_failure(&response, error.as_ref().ok())
20851 {
20852 sleep(d).await;
20853 continue;
20854 }
20855
20856 dlg.finished(false);
20857
20858 return Err(match error {
20859 Ok(value) => common::Error::BadRequest(value),
20860 _ => common::Error::Failure(response),
20861 });
20862 }
20863 let response = {
20864 let bytes = common::to_bytes(body).await.unwrap_or_default();
20865 let encoded = common::to_string(&bytes);
20866 match serde_json::from_str(&encoded) {
20867 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20868 Err(error) => {
20869 dlg.response_json_decode_error(&encoded, &error);
20870 return Err(common::Error::JsonDecodeError(
20871 encoded.to_string(),
20872 error,
20873 ));
20874 }
20875 }
20876 };
20877
20878 dlg.finished(true);
20879 return Ok(response);
20880 }
20881 }
20882 }
20883 }
20884
20885 ///
20886 /// Sets the *request* property to the given value.
20887 ///
20888 /// Even though the property as already been set when instantiating this call,
20889 /// we provide this method for API completeness.
20890 pub fn request(mut self, new_value: WorkerPool) -> ProjectLocationWorkerPoolCreateCall<'a, C> {
20891 self._request = new_value;
20892 self
20893 }
20894 /// Required. The parent resource where this worker pool will be created. Format: `projects/{project}/locations/{location}`.
20895 ///
20896 /// Sets the *parent* path property to the given value.
20897 ///
20898 /// Even though the property as already been set when instantiating this call,
20899 /// we provide this method for API completeness.
20900 pub fn parent(mut self, new_value: &str) -> ProjectLocationWorkerPoolCreateCall<'a, C> {
20901 self._parent = new_value.to_string();
20902 self
20903 }
20904 /// Required. Immutable. The ID to use for the `WorkerPool`, which will become the final component of the resource name. This value should be 1-63 characters, and valid characters are /a-z-/.
20905 ///
20906 /// Sets the *worker pool id* query property to the given value.
20907 pub fn worker_pool_id(mut self, new_value: &str) -> ProjectLocationWorkerPoolCreateCall<'a, C> {
20908 self._worker_pool_id = Some(new_value.to_string());
20909 self
20910 }
20911 /// If set, validate the request and preview the response, but do not actually post it.
20912 ///
20913 /// Sets the *validate only* query property to the given value.
20914 pub fn validate_only(mut self, new_value: bool) -> ProjectLocationWorkerPoolCreateCall<'a, C> {
20915 self._validate_only = Some(new_value);
20916 self
20917 }
20918 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20919 /// while executing the actual API request.
20920 ///
20921 /// ````text
20922 /// It should be used to handle progress information, and to implement a certain level of resilience.
20923 /// ````
20924 ///
20925 /// Sets the *delegate* property to the given value.
20926 pub fn delegate(
20927 mut self,
20928 new_value: &'a mut dyn common::Delegate,
20929 ) -> ProjectLocationWorkerPoolCreateCall<'a, C> {
20930 self._delegate = Some(new_value);
20931 self
20932 }
20933
20934 /// Set any additional parameter of the query string used in the request.
20935 /// It should be used to set parameters which are not yet available through their own
20936 /// setters.
20937 ///
20938 /// Please note that this method must not be used to set any of the known parameters
20939 /// which have their own setter method. If done anyway, the request will fail.
20940 ///
20941 /// # Additional Parameters
20942 ///
20943 /// * *$.xgafv* (query-string) - V1 error format.
20944 /// * *access_token* (query-string) - OAuth access token.
20945 /// * *alt* (query-string) - Data format for response.
20946 /// * *callback* (query-string) - JSONP
20947 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20948 /// * *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.
20949 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20950 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20951 /// * *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.
20952 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20953 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20954 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationWorkerPoolCreateCall<'a, C>
20955 where
20956 T: AsRef<str>,
20957 {
20958 self._additional_params
20959 .insert(name.as_ref().to_string(), value.as_ref().to_string());
20960 self
20961 }
20962
20963 /// Identifies the authorization scope for the method you are building.
20964 ///
20965 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20966 /// [`Scope::CloudPlatform`].
20967 ///
20968 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20969 /// tokens for more than one scope.
20970 ///
20971 /// Usually there is more than one suitable scope to authorize an operation, some of which may
20972 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20973 /// sufficient, a read-write scope will do as well.
20974 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationWorkerPoolCreateCall<'a, C>
20975 where
20976 St: AsRef<str>,
20977 {
20978 self._scopes.insert(String::from(scope.as_ref()));
20979 self
20980 }
20981 /// Identifies the authorization scope(s) for the method you are building.
20982 ///
20983 /// See [`Self::add_scope()`] for details.
20984 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationWorkerPoolCreateCall<'a, C>
20985 where
20986 I: IntoIterator<Item = St>,
20987 St: AsRef<str>,
20988 {
20989 self._scopes
20990 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20991 self
20992 }
20993
20994 /// Removes all scopes, and no default scope will be used either.
20995 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20996 /// for details).
20997 pub fn clear_scopes(mut self) -> ProjectLocationWorkerPoolCreateCall<'a, C> {
20998 self._scopes.clear();
20999 self
21000 }
21001}
21002
21003/// Deletes a `WorkerPool`.
21004///
21005/// A builder for the *locations.workerPools.delete* method supported by a *project* resource.
21006/// It is not used directly, but through a [`ProjectMethods`] instance.
21007///
21008/// # Example
21009///
21010/// Instantiate a resource method builder
21011///
21012/// ```test_harness,no_run
21013/// # extern crate hyper;
21014/// # extern crate hyper_rustls;
21015/// # extern crate google_cloudbuild1 as cloudbuild1;
21016/// # async fn dox() {
21017/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21018///
21019/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21020/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
21021/// # secret,
21022/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21023/// # ).build().await.unwrap();
21024///
21025/// # let client = hyper_util::client::legacy::Client::builder(
21026/// # hyper_util::rt::TokioExecutor::new()
21027/// # )
21028/// # .build(
21029/// # hyper_rustls::HttpsConnectorBuilder::new()
21030/// # .with_native_roots()
21031/// # .unwrap()
21032/// # .https_or_http()
21033/// # .enable_http1()
21034/// # .build()
21035/// # );
21036/// # let mut hub = CloudBuild::new(client, auth);
21037/// // You can configure optional parameters by calling the respective setters at will, and
21038/// // execute the final call using `doit()`.
21039/// // Values shown here are possibly random and not representative !
21040/// let result = hub.projects().locations_worker_pools_delete("name")
21041/// .validate_only(false)
21042/// .etag("elitr")
21043/// .allow_missing(false)
21044/// .doit().await;
21045/// # }
21046/// ```
21047pub struct ProjectLocationWorkerPoolDeleteCall<'a, C>
21048where
21049 C: 'a,
21050{
21051 hub: &'a CloudBuild<C>,
21052 _name: String,
21053 _validate_only: Option<bool>,
21054 _etag: Option<String>,
21055 _allow_missing: Option<bool>,
21056 _delegate: Option<&'a mut dyn common::Delegate>,
21057 _additional_params: HashMap<String, String>,
21058 _scopes: BTreeSet<String>,
21059}
21060
21061impl<'a, C> common::CallBuilder for ProjectLocationWorkerPoolDeleteCall<'a, C> {}
21062
21063impl<'a, C> ProjectLocationWorkerPoolDeleteCall<'a, C>
21064where
21065 C: common::Connector,
21066{
21067 /// Perform the operation you have build so far.
21068 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
21069 use std::borrow::Cow;
21070 use std::io::{Read, Seek};
21071
21072 use common::{url::Params, ToParts};
21073 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21074
21075 let mut dd = common::DefaultDelegate;
21076 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21077 dlg.begin(common::MethodInfo {
21078 id: "cloudbuild.projects.locations.workerPools.delete",
21079 http_method: hyper::Method::DELETE,
21080 });
21081
21082 for &field in ["alt", "name", "validateOnly", "etag", "allowMissing"].iter() {
21083 if self._additional_params.contains_key(field) {
21084 dlg.finished(false);
21085 return Err(common::Error::FieldClash(field));
21086 }
21087 }
21088
21089 let mut params = Params::with_capacity(6 + self._additional_params.len());
21090 params.push("name", self._name);
21091 if let Some(value) = self._validate_only.as_ref() {
21092 params.push("validateOnly", value.to_string());
21093 }
21094 if let Some(value) = self._etag.as_ref() {
21095 params.push("etag", value);
21096 }
21097 if let Some(value) = self._allow_missing.as_ref() {
21098 params.push("allowMissing", value.to_string());
21099 }
21100
21101 params.extend(self._additional_params.iter());
21102
21103 params.push("alt", "json");
21104 let mut url = self.hub._base_url.clone() + "v1/{+name}";
21105 if self._scopes.is_empty() {
21106 self._scopes
21107 .insert(Scope::CloudPlatform.as_ref().to_string());
21108 }
21109
21110 #[allow(clippy::single_element_loop)]
21111 for &(find_this, param_name) in [("{+name}", "name")].iter() {
21112 url = params.uri_replacement(url, param_name, find_this, true);
21113 }
21114 {
21115 let to_remove = ["name"];
21116 params.remove_params(&to_remove);
21117 }
21118
21119 let url = params.parse_with_url(&url);
21120
21121 loop {
21122 let token = match self
21123 .hub
21124 .auth
21125 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21126 .await
21127 {
21128 Ok(token) => token,
21129 Err(e) => match dlg.token(e) {
21130 Ok(token) => token,
21131 Err(e) => {
21132 dlg.finished(false);
21133 return Err(common::Error::MissingToken(e));
21134 }
21135 },
21136 };
21137 let mut req_result = {
21138 let client = &self.hub.client;
21139 dlg.pre_request();
21140 let mut req_builder = hyper::Request::builder()
21141 .method(hyper::Method::DELETE)
21142 .uri(url.as_str())
21143 .header(USER_AGENT, self.hub._user_agent.clone());
21144
21145 if let Some(token) = token.as_ref() {
21146 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21147 }
21148
21149 let request = req_builder
21150 .header(CONTENT_LENGTH, 0_u64)
21151 .body(common::to_body::<String>(None));
21152
21153 client.request(request.unwrap()).await
21154 };
21155
21156 match req_result {
21157 Err(err) => {
21158 if let common::Retry::After(d) = dlg.http_error(&err) {
21159 sleep(d).await;
21160 continue;
21161 }
21162 dlg.finished(false);
21163 return Err(common::Error::HttpError(err));
21164 }
21165 Ok(res) => {
21166 let (mut parts, body) = res.into_parts();
21167 let mut body = common::Body::new(body);
21168 if !parts.status.is_success() {
21169 let bytes = common::to_bytes(body).await.unwrap_or_default();
21170 let error = serde_json::from_str(&common::to_string(&bytes));
21171 let response = common::to_response(parts, bytes.into());
21172
21173 if let common::Retry::After(d) =
21174 dlg.http_failure(&response, error.as_ref().ok())
21175 {
21176 sleep(d).await;
21177 continue;
21178 }
21179
21180 dlg.finished(false);
21181
21182 return Err(match error {
21183 Ok(value) => common::Error::BadRequest(value),
21184 _ => common::Error::Failure(response),
21185 });
21186 }
21187 let response = {
21188 let bytes = common::to_bytes(body).await.unwrap_or_default();
21189 let encoded = common::to_string(&bytes);
21190 match serde_json::from_str(&encoded) {
21191 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21192 Err(error) => {
21193 dlg.response_json_decode_error(&encoded, &error);
21194 return Err(common::Error::JsonDecodeError(
21195 encoded.to_string(),
21196 error,
21197 ));
21198 }
21199 }
21200 };
21201
21202 dlg.finished(true);
21203 return Ok(response);
21204 }
21205 }
21206 }
21207 }
21208
21209 /// Required. The name of the `WorkerPool` to delete. Format: `projects/{project}/locations/{location}/workerPools/{workerPool}`.
21210 ///
21211 /// Sets the *name* path property to the given value.
21212 ///
21213 /// Even though the property as already been set when instantiating this call,
21214 /// we provide this method for API completeness.
21215 pub fn name(mut self, new_value: &str) -> ProjectLocationWorkerPoolDeleteCall<'a, C> {
21216 self._name = new_value.to_string();
21217 self
21218 }
21219 /// If set, validate the request and preview the response, but do not actually post it.
21220 ///
21221 /// Sets the *validate only* query property to the given value.
21222 pub fn validate_only(mut self, new_value: bool) -> ProjectLocationWorkerPoolDeleteCall<'a, C> {
21223 self._validate_only = Some(new_value);
21224 self
21225 }
21226 /// Optional. If provided, it must match the server's etag on the workerpool for the request to be processed.
21227 ///
21228 /// Sets the *etag* query property to the given value.
21229 pub fn etag(mut self, new_value: &str) -> ProjectLocationWorkerPoolDeleteCall<'a, C> {
21230 self._etag = Some(new_value.to_string());
21231 self
21232 }
21233 /// If set to true, and the `WorkerPool` is not found, the request will succeed but no action will be taken on the server.
21234 ///
21235 /// Sets the *allow missing* query property to the given value.
21236 pub fn allow_missing(mut self, new_value: bool) -> ProjectLocationWorkerPoolDeleteCall<'a, C> {
21237 self._allow_missing = Some(new_value);
21238 self
21239 }
21240 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21241 /// while executing the actual API request.
21242 ///
21243 /// ````text
21244 /// It should be used to handle progress information, and to implement a certain level of resilience.
21245 /// ````
21246 ///
21247 /// Sets the *delegate* property to the given value.
21248 pub fn delegate(
21249 mut self,
21250 new_value: &'a mut dyn common::Delegate,
21251 ) -> ProjectLocationWorkerPoolDeleteCall<'a, C> {
21252 self._delegate = Some(new_value);
21253 self
21254 }
21255
21256 /// Set any additional parameter of the query string used in the request.
21257 /// It should be used to set parameters which are not yet available through their own
21258 /// setters.
21259 ///
21260 /// Please note that this method must not be used to set any of the known parameters
21261 /// which have their own setter method. If done anyway, the request will fail.
21262 ///
21263 /// # Additional Parameters
21264 ///
21265 /// * *$.xgafv* (query-string) - V1 error format.
21266 /// * *access_token* (query-string) - OAuth access token.
21267 /// * *alt* (query-string) - Data format for response.
21268 /// * *callback* (query-string) - JSONP
21269 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21270 /// * *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.
21271 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21272 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21273 /// * *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.
21274 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21275 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21276 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationWorkerPoolDeleteCall<'a, C>
21277 where
21278 T: AsRef<str>,
21279 {
21280 self._additional_params
21281 .insert(name.as_ref().to_string(), value.as_ref().to_string());
21282 self
21283 }
21284
21285 /// Identifies the authorization scope for the method you are building.
21286 ///
21287 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21288 /// [`Scope::CloudPlatform`].
21289 ///
21290 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21291 /// tokens for more than one scope.
21292 ///
21293 /// Usually there is more than one suitable scope to authorize an operation, some of which may
21294 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21295 /// sufficient, a read-write scope will do as well.
21296 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationWorkerPoolDeleteCall<'a, C>
21297 where
21298 St: AsRef<str>,
21299 {
21300 self._scopes.insert(String::from(scope.as_ref()));
21301 self
21302 }
21303 /// Identifies the authorization scope(s) for the method you are building.
21304 ///
21305 /// See [`Self::add_scope()`] for details.
21306 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationWorkerPoolDeleteCall<'a, C>
21307 where
21308 I: IntoIterator<Item = St>,
21309 St: AsRef<str>,
21310 {
21311 self._scopes
21312 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21313 self
21314 }
21315
21316 /// Removes all scopes, and no default scope will be used either.
21317 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21318 /// for details).
21319 pub fn clear_scopes(mut self) -> ProjectLocationWorkerPoolDeleteCall<'a, C> {
21320 self._scopes.clear();
21321 self
21322 }
21323}
21324
21325/// Returns details of a `WorkerPool`.
21326///
21327/// A builder for the *locations.workerPools.get* method supported by a *project* resource.
21328/// It is not used directly, but through a [`ProjectMethods`] instance.
21329///
21330/// # Example
21331///
21332/// Instantiate a resource method builder
21333///
21334/// ```test_harness,no_run
21335/// # extern crate hyper;
21336/// # extern crate hyper_rustls;
21337/// # extern crate google_cloudbuild1 as cloudbuild1;
21338/// # async fn dox() {
21339/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21340///
21341/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21342/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
21343/// # secret,
21344/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21345/// # ).build().await.unwrap();
21346///
21347/// # let client = hyper_util::client::legacy::Client::builder(
21348/// # hyper_util::rt::TokioExecutor::new()
21349/// # )
21350/// # .build(
21351/// # hyper_rustls::HttpsConnectorBuilder::new()
21352/// # .with_native_roots()
21353/// # .unwrap()
21354/// # .https_or_http()
21355/// # .enable_http1()
21356/// # .build()
21357/// # );
21358/// # let mut hub = CloudBuild::new(client, auth);
21359/// // You can configure optional parameters by calling the respective setters at will, and
21360/// // execute the final call using `doit()`.
21361/// // Values shown here are possibly random and not representative !
21362/// let result = hub.projects().locations_worker_pools_get("name")
21363/// .doit().await;
21364/// # }
21365/// ```
21366pub struct ProjectLocationWorkerPoolGetCall<'a, C>
21367where
21368 C: 'a,
21369{
21370 hub: &'a CloudBuild<C>,
21371 _name: String,
21372 _delegate: Option<&'a mut dyn common::Delegate>,
21373 _additional_params: HashMap<String, String>,
21374 _scopes: BTreeSet<String>,
21375}
21376
21377impl<'a, C> common::CallBuilder for ProjectLocationWorkerPoolGetCall<'a, C> {}
21378
21379impl<'a, C> ProjectLocationWorkerPoolGetCall<'a, C>
21380where
21381 C: common::Connector,
21382{
21383 /// Perform the operation you have build so far.
21384 pub async fn doit(mut self) -> common::Result<(common::Response, WorkerPool)> {
21385 use std::borrow::Cow;
21386 use std::io::{Read, Seek};
21387
21388 use common::{url::Params, ToParts};
21389 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21390
21391 let mut dd = common::DefaultDelegate;
21392 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21393 dlg.begin(common::MethodInfo {
21394 id: "cloudbuild.projects.locations.workerPools.get",
21395 http_method: hyper::Method::GET,
21396 });
21397
21398 for &field in ["alt", "name"].iter() {
21399 if self._additional_params.contains_key(field) {
21400 dlg.finished(false);
21401 return Err(common::Error::FieldClash(field));
21402 }
21403 }
21404
21405 let mut params = Params::with_capacity(3 + self._additional_params.len());
21406 params.push("name", self._name);
21407
21408 params.extend(self._additional_params.iter());
21409
21410 params.push("alt", "json");
21411 let mut url = self.hub._base_url.clone() + "v1/{+name}";
21412 if self._scopes.is_empty() {
21413 self._scopes
21414 .insert(Scope::CloudPlatform.as_ref().to_string());
21415 }
21416
21417 #[allow(clippy::single_element_loop)]
21418 for &(find_this, param_name) in [("{+name}", "name")].iter() {
21419 url = params.uri_replacement(url, param_name, find_this, true);
21420 }
21421 {
21422 let to_remove = ["name"];
21423 params.remove_params(&to_remove);
21424 }
21425
21426 let url = params.parse_with_url(&url);
21427
21428 loop {
21429 let token = match self
21430 .hub
21431 .auth
21432 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21433 .await
21434 {
21435 Ok(token) => token,
21436 Err(e) => match dlg.token(e) {
21437 Ok(token) => token,
21438 Err(e) => {
21439 dlg.finished(false);
21440 return Err(common::Error::MissingToken(e));
21441 }
21442 },
21443 };
21444 let mut req_result = {
21445 let client = &self.hub.client;
21446 dlg.pre_request();
21447 let mut req_builder = hyper::Request::builder()
21448 .method(hyper::Method::GET)
21449 .uri(url.as_str())
21450 .header(USER_AGENT, self.hub._user_agent.clone());
21451
21452 if let Some(token) = token.as_ref() {
21453 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21454 }
21455
21456 let request = req_builder
21457 .header(CONTENT_LENGTH, 0_u64)
21458 .body(common::to_body::<String>(None));
21459
21460 client.request(request.unwrap()).await
21461 };
21462
21463 match req_result {
21464 Err(err) => {
21465 if let common::Retry::After(d) = dlg.http_error(&err) {
21466 sleep(d).await;
21467 continue;
21468 }
21469 dlg.finished(false);
21470 return Err(common::Error::HttpError(err));
21471 }
21472 Ok(res) => {
21473 let (mut parts, body) = res.into_parts();
21474 let mut body = common::Body::new(body);
21475 if !parts.status.is_success() {
21476 let bytes = common::to_bytes(body).await.unwrap_or_default();
21477 let error = serde_json::from_str(&common::to_string(&bytes));
21478 let response = common::to_response(parts, bytes.into());
21479
21480 if let common::Retry::After(d) =
21481 dlg.http_failure(&response, error.as_ref().ok())
21482 {
21483 sleep(d).await;
21484 continue;
21485 }
21486
21487 dlg.finished(false);
21488
21489 return Err(match error {
21490 Ok(value) => common::Error::BadRequest(value),
21491 _ => common::Error::Failure(response),
21492 });
21493 }
21494 let response = {
21495 let bytes = common::to_bytes(body).await.unwrap_or_default();
21496 let encoded = common::to_string(&bytes);
21497 match serde_json::from_str(&encoded) {
21498 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21499 Err(error) => {
21500 dlg.response_json_decode_error(&encoded, &error);
21501 return Err(common::Error::JsonDecodeError(
21502 encoded.to_string(),
21503 error,
21504 ));
21505 }
21506 }
21507 };
21508
21509 dlg.finished(true);
21510 return Ok(response);
21511 }
21512 }
21513 }
21514 }
21515
21516 /// Required. The name of the `WorkerPool` to retrieve. Format: `projects/{project}/locations/{location}/workerPools/{workerPool}`.
21517 ///
21518 /// Sets the *name* path property to the given value.
21519 ///
21520 /// Even though the property as already been set when instantiating this call,
21521 /// we provide this method for API completeness.
21522 pub fn name(mut self, new_value: &str) -> ProjectLocationWorkerPoolGetCall<'a, C> {
21523 self._name = new_value.to_string();
21524 self
21525 }
21526 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21527 /// while executing the actual API request.
21528 ///
21529 /// ````text
21530 /// It should be used to handle progress information, and to implement a certain level of resilience.
21531 /// ````
21532 ///
21533 /// Sets the *delegate* property to the given value.
21534 pub fn delegate(
21535 mut self,
21536 new_value: &'a mut dyn common::Delegate,
21537 ) -> ProjectLocationWorkerPoolGetCall<'a, C> {
21538 self._delegate = Some(new_value);
21539 self
21540 }
21541
21542 /// Set any additional parameter of the query string used in the request.
21543 /// It should be used to set parameters which are not yet available through their own
21544 /// setters.
21545 ///
21546 /// Please note that this method must not be used to set any of the known parameters
21547 /// which have their own setter method. If done anyway, the request will fail.
21548 ///
21549 /// # Additional Parameters
21550 ///
21551 /// * *$.xgafv* (query-string) - V1 error format.
21552 /// * *access_token* (query-string) - OAuth access token.
21553 /// * *alt* (query-string) - Data format for response.
21554 /// * *callback* (query-string) - JSONP
21555 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21556 /// * *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.
21557 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21558 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21559 /// * *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.
21560 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21561 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21562 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationWorkerPoolGetCall<'a, C>
21563 where
21564 T: AsRef<str>,
21565 {
21566 self._additional_params
21567 .insert(name.as_ref().to_string(), value.as_ref().to_string());
21568 self
21569 }
21570
21571 /// Identifies the authorization scope for the method you are building.
21572 ///
21573 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21574 /// [`Scope::CloudPlatform`].
21575 ///
21576 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21577 /// tokens for more than one scope.
21578 ///
21579 /// Usually there is more than one suitable scope to authorize an operation, some of which may
21580 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21581 /// sufficient, a read-write scope will do as well.
21582 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationWorkerPoolGetCall<'a, C>
21583 where
21584 St: AsRef<str>,
21585 {
21586 self._scopes.insert(String::from(scope.as_ref()));
21587 self
21588 }
21589 /// Identifies the authorization scope(s) for the method you are building.
21590 ///
21591 /// See [`Self::add_scope()`] for details.
21592 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationWorkerPoolGetCall<'a, C>
21593 where
21594 I: IntoIterator<Item = St>,
21595 St: AsRef<str>,
21596 {
21597 self._scopes
21598 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21599 self
21600 }
21601
21602 /// Removes all scopes, and no default scope will be used either.
21603 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21604 /// for details).
21605 pub fn clear_scopes(mut self) -> ProjectLocationWorkerPoolGetCall<'a, C> {
21606 self._scopes.clear();
21607 self
21608 }
21609}
21610
21611/// Lists `WorkerPool`s.
21612///
21613/// A builder for the *locations.workerPools.list* method supported by a *project* resource.
21614/// It is not used directly, but through a [`ProjectMethods`] instance.
21615///
21616/// # Example
21617///
21618/// Instantiate a resource method builder
21619///
21620/// ```test_harness,no_run
21621/// # extern crate hyper;
21622/// # extern crate hyper_rustls;
21623/// # extern crate google_cloudbuild1 as cloudbuild1;
21624/// # async fn dox() {
21625/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21626///
21627/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21628/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
21629/// # secret,
21630/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21631/// # ).build().await.unwrap();
21632///
21633/// # let client = hyper_util::client::legacy::Client::builder(
21634/// # hyper_util::rt::TokioExecutor::new()
21635/// # )
21636/// # .build(
21637/// # hyper_rustls::HttpsConnectorBuilder::new()
21638/// # .with_native_roots()
21639/// # .unwrap()
21640/// # .https_or_http()
21641/// # .enable_http1()
21642/// # .build()
21643/// # );
21644/// # let mut hub = CloudBuild::new(client, auth);
21645/// // You can configure optional parameters by calling the respective setters at will, and
21646/// // execute the final call using `doit()`.
21647/// // Values shown here are possibly random and not representative !
21648/// let result = hub.projects().locations_worker_pools_list("parent")
21649/// .page_token("At")
21650/// .page_size(-45)
21651/// .doit().await;
21652/// # }
21653/// ```
21654pub struct ProjectLocationWorkerPoolListCall<'a, C>
21655where
21656 C: 'a,
21657{
21658 hub: &'a CloudBuild<C>,
21659 _parent: String,
21660 _page_token: Option<String>,
21661 _page_size: Option<i32>,
21662 _delegate: Option<&'a mut dyn common::Delegate>,
21663 _additional_params: HashMap<String, String>,
21664 _scopes: BTreeSet<String>,
21665}
21666
21667impl<'a, C> common::CallBuilder for ProjectLocationWorkerPoolListCall<'a, C> {}
21668
21669impl<'a, C> ProjectLocationWorkerPoolListCall<'a, C>
21670where
21671 C: common::Connector,
21672{
21673 /// Perform the operation you have build so far.
21674 pub async fn doit(mut self) -> common::Result<(common::Response, ListWorkerPoolsResponse)> {
21675 use std::borrow::Cow;
21676 use std::io::{Read, Seek};
21677
21678 use common::{url::Params, ToParts};
21679 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21680
21681 let mut dd = common::DefaultDelegate;
21682 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21683 dlg.begin(common::MethodInfo {
21684 id: "cloudbuild.projects.locations.workerPools.list",
21685 http_method: hyper::Method::GET,
21686 });
21687
21688 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
21689 if self._additional_params.contains_key(field) {
21690 dlg.finished(false);
21691 return Err(common::Error::FieldClash(field));
21692 }
21693 }
21694
21695 let mut params = Params::with_capacity(5 + self._additional_params.len());
21696 params.push("parent", self._parent);
21697 if let Some(value) = self._page_token.as_ref() {
21698 params.push("pageToken", value);
21699 }
21700 if let Some(value) = self._page_size.as_ref() {
21701 params.push("pageSize", value.to_string());
21702 }
21703
21704 params.extend(self._additional_params.iter());
21705
21706 params.push("alt", "json");
21707 let mut url = self.hub._base_url.clone() + "v1/{+parent}/workerPools";
21708 if self._scopes.is_empty() {
21709 self._scopes
21710 .insert(Scope::CloudPlatform.as_ref().to_string());
21711 }
21712
21713 #[allow(clippy::single_element_loop)]
21714 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
21715 url = params.uri_replacement(url, param_name, find_this, true);
21716 }
21717 {
21718 let to_remove = ["parent"];
21719 params.remove_params(&to_remove);
21720 }
21721
21722 let url = params.parse_with_url(&url);
21723
21724 loop {
21725 let token = match self
21726 .hub
21727 .auth
21728 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21729 .await
21730 {
21731 Ok(token) => token,
21732 Err(e) => match dlg.token(e) {
21733 Ok(token) => token,
21734 Err(e) => {
21735 dlg.finished(false);
21736 return Err(common::Error::MissingToken(e));
21737 }
21738 },
21739 };
21740 let mut req_result = {
21741 let client = &self.hub.client;
21742 dlg.pre_request();
21743 let mut req_builder = hyper::Request::builder()
21744 .method(hyper::Method::GET)
21745 .uri(url.as_str())
21746 .header(USER_AGENT, self.hub._user_agent.clone());
21747
21748 if let Some(token) = token.as_ref() {
21749 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21750 }
21751
21752 let request = req_builder
21753 .header(CONTENT_LENGTH, 0_u64)
21754 .body(common::to_body::<String>(None));
21755
21756 client.request(request.unwrap()).await
21757 };
21758
21759 match req_result {
21760 Err(err) => {
21761 if let common::Retry::After(d) = dlg.http_error(&err) {
21762 sleep(d).await;
21763 continue;
21764 }
21765 dlg.finished(false);
21766 return Err(common::Error::HttpError(err));
21767 }
21768 Ok(res) => {
21769 let (mut parts, body) = res.into_parts();
21770 let mut body = common::Body::new(body);
21771 if !parts.status.is_success() {
21772 let bytes = common::to_bytes(body).await.unwrap_or_default();
21773 let error = serde_json::from_str(&common::to_string(&bytes));
21774 let response = common::to_response(parts, bytes.into());
21775
21776 if let common::Retry::After(d) =
21777 dlg.http_failure(&response, error.as_ref().ok())
21778 {
21779 sleep(d).await;
21780 continue;
21781 }
21782
21783 dlg.finished(false);
21784
21785 return Err(match error {
21786 Ok(value) => common::Error::BadRequest(value),
21787 _ => common::Error::Failure(response),
21788 });
21789 }
21790 let response = {
21791 let bytes = common::to_bytes(body).await.unwrap_or_default();
21792 let encoded = common::to_string(&bytes);
21793 match serde_json::from_str(&encoded) {
21794 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21795 Err(error) => {
21796 dlg.response_json_decode_error(&encoded, &error);
21797 return Err(common::Error::JsonDecodeError(
21798 encoded.to_string(),
21799 error,
21800 ));
21801 }
21802 }
21803 };
21804
21805 dlg.finished(true);
21806 return Ok(response);
21807 }
21808 }
21809 }
21810 }
21811
21812 /// Required. The parent of the collection of `WorkerPools`. Format: `projects/{project}/locations/{location}`.
21813 ///
21814 /// Sets the *parent* path property to the given value.
21815 ///
21816 /// Even though the property as already been set when instantiating this call,
21817 /// we provide this method for API completeness.
21818 pub fn parent(mut self, new_value: &str) -> ProjectLocationWorkerPoolListCall<'a, C> {
21819 self._parent = new_value.to_string();
21820 self
21821 }
21822 /// A page token, received from a previous `ListWorkerPools` call. Provide this to retrieve the subsequent page.
21823 ///
21824 /// Sets the *page token* query property to the given value.
21825 pub fn page_token(mut self, new_value: &str) -> ProjectLocationWorkerPoolListCall<'a, C> {
21826 self._page_token = Some(new_value.to_string());
21827 self
21828 }
21829 /// The maximum number of `WorkerPool`s to return. The service may return fewer than this value. If omitted, the server will use a sensible default.
21830 ///
21831 /// Sets the *page size* query property to the given value.
21832 pub fn page_size(mut self, new_value: i32) -> ProjectLocationWorkerPoolListCall<'a, C> {
21833 self._page_size = Some(new_value);
21834 self
21835 }
21836 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21837 /// while executing the actual API request.
21838 ///
21839 /// ````text
21840 /// It should be used to handle progress information, and to implement a certain level of resilience.
21841 /// ````
21842 ///
21843 /// Sets the *delegate* property to the given value.
21844 pub fn delegate(
21845 mut self,
21846 new_value: &'a mut dyn common::Delegate,
21847 ) -> ProjectLocationWorkerPoolListCall<'a, C> {
21848 self._delegate = Some(new_value);
21849 self
21850 }
21851
21852 /// Set any additional parameter of the query string used in the request.
21853 /// It should be used to set parameters which are not yet available through their own
21854 /// setters.
21855 ///
21856 /// Please note that this method must not be used to set any of the known parameters
21857 /// which have their own setter method. If done anyway, the request will fail.
21858 ///
21859 /// # Additional Parameters
21860 ///
21861 /// * *$.xgafv* (query-string) - V1 error format.
21862 /// * *access_token* (query-string) - OAuth access token.
21863 /// * *alt* (query-string) - Data format for response.
21864 /// * *callback* (query-string) - JSONP
21865 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21866 /// * *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.
21867 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21868 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21869 /// * *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.
21870 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21871 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21872 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationWorkerPoolListCall<'a, C>
21873 where
21874 T: AsRef<str>,
21875 {
21876 self._additional_params
21877 .insert(name.as_ref().to_string(), value.as_ref().to_string());
21878 self
21879 }
21880
21881 /// Identifies the authorization scope for the method you are building.
21882 ///
21883 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21884 /// [`Scope::CloudPlatform`].
21885 ///
21886 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21887 /// tokens for more than one scope.
21888 ///
21889 /// Usually there is more than one suitable scope to authorize an operation, some of which may
21890 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21891 /// sufficient, a read-write scope will do as well.
21892 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationWorkerPoolListCall<'a, C>
21893 where
21894 St: AsRef<str>,
21895 {
21896 self._scopes.insert(String::from(scope.as_ref()));
21897 self
21898 }
21899 /// Identifies the authorization scope(s) for the method you are building.
21900 ///
21901 /// See [`Self::add_scope()`] for details.
21902 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationWorkerPoolListCall<'a, C>
21903 where
21904 I: IntoIterator<Item = St>,
21905 St: AsRef<str>,
21906 {
21907 self._scopes
21908 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21909 self
21910 }
21911
21912 /// Removes all scopes, and no default scope will be used either.
21913 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21914 /// for details).
21915 pub fn clear_scopes(mut self) -> ProjectLocationWorkerPoolListCall<'a, C> {
21916 self._scopes.clear();
21917 self
21918 }
21919}
21920
21921/// Updates a `WorkerPool`.
21922///
21923/// A builder for the *locations.workerPools.patch* method supported by a *project* resource.
21924/// It is not used directly, but through a [`ProjectMethods`] instance.
21925///
21926/// # Example
21927///
21928/// Instantiate a resource method builder
21929///
21930/// ```test_harness,no_run
21931/// # extern crate hyper;
21932/// # extern crate hyper_rustls;
21933/// # extern crate google_cloudbuild1 as cloudbuild1;
21934/// use cloudbuild1::api::WorkerPool;
21935/// # async fn dox() {
21936/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21937///
21938/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21939/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
21940/// # secret,
21941/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21942/// # ).build().await.unwrap();
21943///
21944/// # let client = hyper_util::client::legacy::Client::builder(
21945/// # hyper_util::rt::TokioExecutor::new()
21946/// # )
21947/// # .build(
21948/// # hyper_rustls::HttpsConnectorBuilder::new()
21949/// # .with_native_roots()
21950/// # .unwrap()
21951/// # .https_or_http()
21952/// # .enable_http1()
21953/// # .build()
21954/// # );
21955/// # let mut hub = CloudBuild::new(client, auth);
21956/// // As the method needs a request, you would usually fill it with the desired information
21957/// // into the respective structure. Some of the parts shown here might not be applicable !
21958/// // Values shown here are possibly random and not representative !
21959/// let mut req = WorkerPool::default();
21960///
21961/// // You can configure optional parameters by calling the respective setters at will, and
21962/// // execute the final call using `doit()`.
21963/// // Values shown here are possibly random and not representative !
21964/// let result = hub.projects().locations_worker_pools_patch(req, "name")
21965/// .validate_only(true)
21966/// .update_mask(FieldMask::new::<&str>(&[]))
21967/// .doit().await;
21968/// # }
21969/// ```
21970pub struct ProjectLocationWorkerPoolPatchCall<'a, C>
21971where
21972 C: 'a,
21973{
21974 hub: &'a CloudBuild<C>,
21975 _request: WorkerPool,
21976 _name: String,
21977 _validate_only: Option<bool>,
21978 _update_mask: Option<common::FieldMask>,
21979 _delegate: Option<&'a mut dyn common::Delegate>,
21980 _additional_params: HashMap<String, String>,
21981 _scopes: BTreeSet<String>,
21982}
21983
21984impl<'a, C> common::CallBuilder for ProjectLocationWorkerPoolPatchCall<'a, C> {}
21985
21986impl<'a, C> ProjectLocationWorkerPoolPatchCall<'a, C>
21987where
21988 C: common::Connector,
21989{
21990 /// Perform the operation you have build so far.
21991 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
21992 use std::borrow::Cow;
21993 use std::io::{Read, Seek};
21994
21995 use common::{url::Params, ToParts};
21996 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21997
21998 let mut dd = common::DefaultDelegate;
21999 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22000 dlg.begin(common::MethodInfo {
22001 id: "cloudbuild.projects.locations.workerPools.patch",
22002 http_method: hyper::Method::PATCH,
22003 });
22004
22005 for &field in ["alt", "name", "validateOnly", "updateMask"].iter() {
22006 if self._additional_params.contains_key(field) {
22007 dlg.finished(false);
22008 return Err(common::Error::FieldClash(field));
22009 }
22010 }
22011
22012 let mut params = Params::with_capacity(6 + self._additional_params.len());
22013 params.push("name", self._name);
22014 if let Some(value) = self._validate_only.as_ref() {
22015 params.push("validateOnly", value.to_string());
22016 }
22017 if let Some(value) = self._update_mask.as_ref() {
22018 params.push("updateMask", value.to_string());
22019 }
22020
22021 params.extend(self._additional_params.iter());
22022
22023 params.push("alt", "json");
22024 let mut url = self.hub._base_url.clone() + "v1/{+name}";
22025 if self._scopes.is_empty() {
22026 self._scopes
22027 .insert(Scope::CloudPlatform.as_ref().to_string());
22028 }
22029
22030 #[allow(clippy::single_element_loop)]
22031 for &(find_this, param_name) in [("{+name}", "name")].iter() {
22032 url = params.uri_replacement(url, param_name, find_this, true);
22033 }
22034 {
22035 let to_remove = ["name"];
22036 params.remove_params(&to_remove);
22037 }
22038
22039 let url = params.parse_with_url(&url);
22040
22041 let mut json_mime_type = mime::APPLICATION_JSON;
22042 let mut request_value_reader = {
22043 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
22044 common::remove_json_null_values(&mut value);
22045 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
22046 serde_json::to_writer(&mut dst, &value).unwrap();
22047 dst
22048 };
22049 let request_size = request_value_reader
22050 .seek(std::io::SeekFrom::End(0))
22051 .unwrap();
22052 request_value_reader
22053 .seek(std::io::SeekFrom::Start(0))
22054 .unwrap();
22055
22056 loop {
22057 let token = match self
22058 .hub
22059 .auth
22060 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22061 .await
22062 {
22063 Ok(token) => token,
22064 Err(e) => match dlg.token(e) {
22065 Ok(token) => token,
22066 Err(e) => {
22067 dlg.finished(false);
22068 return Err(common::Error::MissingToken(e));
22069 }
22070 },
22071 };
22072 request_value_reader
22073 .seek(std::io::SeekFrom::Start(0))
22074 .unwrap();
22075 let mut req_result = {
22076 let client = &self.hub.client;
22077 dlg.pre_request();
22078 let mut req_builder = hyper::Request::builder()
22079 .method(hyper::Method::PATCH)
22080 .uri(url.as_str())
22081 .header(USER_AGENT, self.hub._user_agent.clone());
22082
22083 if let Some(token) = token.as_ref() {
22084 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22085 }
22086
22087 let request = req_builder
22088 .header(CONTENT_TYPE, json_mime_type.to_string())
22089 .header(CONTENT_LENGTH, request_size as u64)
22090 .body(common::to_body(
22091 request_value_reader.get_ref().clone().into(),
22092 ));
22093
22094 client.request(request.unwrap()).await
22095 };
22096
22097 match req_result {
22098 Err(err) => {
22099 if let common::Retry::After(d) = dlg.http_error(&err) {
22100 sleep(d).await;
22101 continue;
22102 }
22103 dlg.finished(false);
22104 return Err(common::Error::HttpError(err));
22105 }
22106 Ok(res) => {
22107 let (mut parts, body) = res.into_parts();
22108 let mut body = common::Body::new(body);
22109 if !parts.status.is_success() {
22110 let bytes = common::to_bytes(body).await.unwrap_or_default();
22111 let error = serde_json::from_str(&common::to_string(&bytes));
22112 let response = common::to_response(parts, bytes.into());
22113
22114 if let common::Retry::After(d) =
22115 dlg.http_failure(&response, error.as_ref().ok())
22116 {
22117 sleep(d).await;
22118 continue;
22119 }
22120
22121 dlg.finished(false);
22122
22123 return Err(match error {
22124 Ok(value) => common::Error::BadRequest(value),
22125 _ => common::Error::Failure(response),
22126 });
22127 }
22128 let response = {
22129 let bytes = common::to_bytes(body).await.unwrap_or_default();
22130 let encoded = common::to_string(&bytes);
22131 match serde_json::from_str(&encoded) {
22132 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22133 Err(error) => {
22134 dlg.response_json_decode_error(&encoded, &error);
22135 return Err(common::Error::JsonDecodeError(
22136 encoded.to_string(),
22137 error,
22138 ));
22139 }
22140 }
22141 };
22142
22143 dlg.finished(true);
22144 return Ok(response);
22145 }
22146 }
22147 }
22148 }
22149
22150 ///
22151 /// Sets the *request* property to the given value.
22152 ///
22153 /// Even though the property as already been set when instantiating this call,
22154 /// we provide this method for API completeness.
22155 pub fn request(mut self, new_value: WorkerPool) -> ProjectLocationWorkerPoolPatchCall<'a, C> {
22156 self._request = new_value;
22157 self
22158 }
22159 /// Output only. The resource name of the `WorkerPool`, with format `projects/{project}/locations/{location}/workerPools/{worker_pool}`. The value of `{worker_pool}` is provided by `worker_pool_id` in `CreateWorkerPool` request and the value of `{location}` is determined by the endpoint accessed.
22160 ///
22161 /// Sets the *name* path property to the given value.
22162 ///
22163 /// Even though the property as already been set when instantiating this call,
22164 /// we provide this method for API completeness.
22165 pub fn name(mut self, new_value: &str) -> ProjectLocationWorkerPoolPatchCall<'a, C> {
22166 self._name = new_value.to_string();
22167 self
22168 }
22169 /// If set, validate the request and preview the response, but do not actually post it.
22170 ///
22171 /// Sets the *validate only* query property to the given value.
22172 pub fn validate_only(mut self, new_value: bool) -> ProjectLocationWorkerPoolPatchCall<'a, C> {
22173 self._validate_only = Some(new_value);
22174 self
22175 }
22176 /// Optional. A mask specifying which fields in `worker_pool` to update.
22177 ///
22178 /// Sets the *update mask* query property to the given value.
22179 pub fn update_mask(
22180 mut self,
22181 new_value: common::FieldMask,
22182 ) -> ProjectLocationWorkerPoolPatchCall<'a, C> {
22183 self._update_mask = Some(new_value);
22184 self
22185 }
22186 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22187 /// while executing the actual API request.
22188 ///
22189 /// ````text
22190 /// It should be used to handle progress information, and to implement a certain level of resilience.
22191 /// ````
22192 ///
22193 /// Sets the *delegate* property to the given value.
22194 pub fn delegate(
22195 mut self,
22196 new_value: &'a mut dyn common::Delegate,
22197 ) -> ProjectLocationWorkerPoolPatchCall<'a, C> {
22198 self._delegate = Some(new_value);
22199 self
22200 }
22201
22202 /// Set any additional parameter of the query string used in the request.
22203 /// It should be used to set parameters which are not yet available through their own
22204 /// setters.
22205 ///
22206 /// Please note that this method must not be used to set any of the known parameters
22207 /// which have their own setter method. If done anyway, the request will fail.
22208 ///
22209 /// # Additional Parameters
22210 ///
22211 /// * *$.xgafv* (query-string) - V1 error format.
22212 /// * *access_token* (query-string) - OAuth access token.
22213 /// * *alt* (query-string) - Data format for response.
22214 /// * *callback* (query-string) - JSONP
22215 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22216 /// * *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.
22217 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22218 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22219 /// * *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.
22220 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22221 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22222 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationWorkerPoolPatchCall<'a, C>
22223 where
22224 T: AsRef<str>,
22225 {
22226 self._additional_params
22227 .insert(name.as_ref().to_string(), value.as_ref().to_string());
22228 self
22229 }
22230
22231 /// Identifies the authorization scope for the method you are building.
22232 ///
22233 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22234 /// [`Scope::CloudPlatform`].
22235 ///
22236 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22237 /// tokens for more than one scope.
22238 ///
22239 /// Usually there is more than one suitable scope to authorize an operation, some of which may
22240 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22241 /// sufficient, a read-write scope will do as well.
22242 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationWorkerPoolPatchCall<'a, C>
22243 where
22244 St: AsRef<str>,
22245 {
22246 self._scopes.insert(String::from(scope.as_ref()));
22247 self
22248 }
22249 /// Identifies the authorization scope(s) for the method you are building.
22250 ///
22251 /// See [`Self::add_scope()`] for details.
22252 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationWorkerPoolPatchCall<'a, C>
22253 where
22254 I: IntoIterator<Item = St>,
22255 St: AsRef<str>,
22256 {
22257 self._scopes
22258 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22259 self
22260 }
22261
22262 /// Removes all scopes, and no default scope will be used either.
22263 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22264 /// for details).
22265 pub fn clear_scopes(mut self) -> ProjectLocationWorkerPoolPatchCall<'a, C> {
22266 self._scopes.clear();
22267 self
22268 }
22269}
22270
22271/// Returns the `DefaultServiceAccount` used by the project.
22272///
22273/// A builder for the *locations.getDefaultServiceAccount* method supported by a *project* resource.
22274/// It is not used directly, but through a [`ProjectMethods`] instance.
22275///
22276/// # Example
22277///
22278/// Instantiate a resource method builder
22279///
22280/// ```test_harness,no_run
22281/// # extern crate hyper;
22282/// # extern crate hyper_rustls;
22283/// # extern crate google_cloudbuild1 as cloudbuild1;
22284/// # async fn dox() {
22285/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22286///
22287/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22288/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
22289/// # secret,
22290/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22291/// # ).build().await.unwrap();
22292///
22293/// # let client = hyper_util::client::legacy::Client::builder(
22294/// # hyper_util::rt::TokioExecutor::new()
22295/// # )
22296/// # .build(
22297/// # hyper_rustls::HttpsConnectorBuilder::new()
22298/// # .with_native_roots()
22299/// # .unwrap()
22300/// # .https_or_http()
22301/// # .enable_http1()
22302/// # .build()
22303/// # );
22304/// # let mut hub = CloudBuild::new(client, auth);
22305/// // You can configure optional parameters by calling the respective setters at will, and
22306/// // execute the final call using `doit()`.
22307/// // Values shown here are possibly random and not representative !
22308/// let result = hub.projects().locations_get_default_service_account("name")
22309/// .doit().await;
22310/// # }
22311/// ```
22312pub struct ProjectLocationGetDefaultServiceAccountCall<'a, C>
22313where
22314 C: 'a,
22315{
22316 hub: &'a CloudBuild<C>,
22317 _name: String,
22318 _delegate: Option<&'a mut dyn common::Delegate>,
22319 _additional_params: HashMap<String, String>,
22320 _scopes: BTreeSet<String>,
22321}
22322
22323impl<'a, C> common::CallBuilder for ProjectLocationGetDefaultServiceAccountCall<'a, C> {}
22324
22325impl<'a, C> ProjectLocationGetDefaultServiceAccountCall<'a, C>
22326where
22327 C: common::Connector,
22328{
22329 /// Perform the operation you have build so far.
22330 pub async fn doit(mut self) -> common::Result<(common::Response, DefaultServiceAccount)> {
22331 use std::borrow::Cow;
22332 use std::io::{Read, Seek};
22333
22334 use common::{url::Params, ToParts};
22335 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22336
22337 let mut dd = common::DefaultDelegate;
22338 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22339 dlg.begin(common::MethodInfo {
22340 id: "cloudbuild.projects.locations.getDefaultServiceAccount",
22341 http_method: hyper::Method::GET,
22342 });
22343
22344 for &field in ["alt", "name"].iter() {
22345 if self._additional_params.contains_key(field) {
22346 dlg.finished(false);
22347 return Err(common::Error::FieldClash(field));
22348 }
22349 }
22350
22351 let mut params = Params::with_capacity(3 + self._additional_params.len());
22352 params.push("name", self._name);
22353
22354 params.extend(self._additional_params.iter());
22355
22356 params.push("alt", "json");
22357 let mut url = self.hub._base_url.clone() + "v1/{+name}";
22358 if self._scopes.is_empty() {
22359 self._scopes
22360 .insert(Scope::CloudPlatform.as_ref().to_string());
22361 }
22362
22363 #[allow(clippy::single_element_loop)]
22364 for &(find_this, param_name) in [("{+name}", "name")].iter() {
22365 url = params.uri_replacement(url, param_name, find_this, true);
22366 }
22367 {
22368 let to_remove = ["name"];
22369 params.remove_params(&to_remove);
22370 }
22371
22372 let url = params.parse_with_url(&url);
22373
22374 loop {
22375 let token = match self
22376 .hub
22377 .auth
22378 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22379 .await
22380 {
22381 Ok(token) => token,
22382 Err(e) => match dlg.token(e) {
22383 Ok(token) => token,
22384 Err(e) => {
22385 dlg.finished(false);
22386 return Err(common::Error::MissingToken(e));
22387 }
22388 },
22389 };
22390 let mut req_result = {
22391 let client = &self.hub.client;
22392 dlg.pre_request();
22393 let mut req_builder = hyper::Request::builder()
22394 .method(hyper::Method::GET)
22395 .uri(url.as_str())
22396 .header(USER_AGENT, self.hub._user_agent.clone());
22397
22398 if let Some(token) = token.as_ref() {
22399 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22400 }
22401
22402 let request = req_builder
22403 .header(CONTENT_LENGTH, 0_u64)
22404 .body(common::to_body::<String>(None));
22405
22406 client.request(request.unwrap()).await
22407 };
22408
22409 match req_result {
22410 Err(err) => {
22411 if let common::Retry::After(d) = dlg.http_error(&err) {
22412 sleep(d).await;
22413 continue;
22414 }
22415 dlg.finished(false);
22416 return Err(common::Error::HttpError(err));
22417 }
22418 Ok(res) => {
22419 let (mut parts, body) = res.into_parts();
22420 let mut body = common::Body::new(body);
22421 if !parts.status.is_success() {
22422 let bytes = common::to_bytes(body).await.unwrap_or_default();
22423 let error = serde_json::from_str(&common::to_string(&bytes));
22424 let response = common::to_response(parts, bytes.into());
22425
22426 if let common::Retry::After(d) =
22427 dlg.http_failure(&response, error.as_ref().ok())
22428 {
22429 sleep(d).await;
22430 continue;
22431 }
22432
22433 dlg.finished(false);
22434
22435 return Err(match error {
22436 Ok(value) => common::Error::BadRequest(value),
22437 _ => common::Error::Failure(response),
22438 });
22439 }
22440 let response = {
22441 let bytes = common::to_bytes(body).await.unwrap_or_default();
22442 let encoded = common::to_string(&bytes);
22443 match serde_json::from_str(&encoded) {
22444 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22445 Err(error) => {
22446 dlg.response_json_decode_error(&encoded, &error);
22447 return Err(common::Error::JsonDecodeError(
22448 encoded.to_string(),
22449 error,
22450 ));
22451 }
22452 }
22453 };
22454
22455 dlg.finished(true);
22456 return Ok(response);
22457 }
22458 }
22459 }
22460 }
22461
22462 /// Required. The name of the `DefaultServiceAccount` to retrieve. Format: `projects/{project}/locations/{location}/defaultServiceAccount`
22463 ///
22464 /// Sets the *name* path property to the given value.
22465 ///
22466 /// Even though the property as already been set when instantiating this call,
22467 /// we provide this method for API completeness.
22468 pub fn name(mut self, new_value: &str) -> ProjectLocationGetDefaultServiceAccountCall<'a, C> {
22469 self._name = new_value.to_string();
22470 self
22471 }
22472 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22473 /// while executing the actual API request.
22474 ///
22475 /// ````text
22476 /// It should be used to handle progress information, and to implement a certain level of resilience.
22477 /// ````
22478 ///
22479 /// Sets the *delegate* property to the given value.
22480 pub fn delegate(
22481 mut self,
22482 new_value: &'a mut dyn common::Delegate,
22483 ) -> ProjectLocationGetDefaultServiceAccountCall<'a, C> {
22484 self._delegate = Some(new_value);
22485 self
22486 }
22487
22488 /// Set any additional parameter of the query string used in the request.
22489 /// It should be used to set parameters which are not yet available through their own
22490 /// setters.
22491 ///
22492 /// Please note that this method must not be used to set any of the known parameters
22493 /// which have their own setter method. If done anyway, the request will fail.
22494 ///
22495 /// # Additional Parameters
22496 ///
22497 /// * *$.xgafv* (query-string) - V1 error format.
22498 /// * *access_token* (query-string) - OAuth access token.
22499 /// * *alt* (query-string) - Data format for response.
22500 /// * *callback* (query-string) - JSONP
22501 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22502 /// * *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.
22503 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22504 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22505 /// * *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.
22506 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22507 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22508 pub fn param<T>(
22509 mut self,
22510 name: T,
22511 value: T,
22512 ) -> ProjectLocationGetDefaultServiceAccountCall<'a, C>
22513 where
22514 T: AsRef<str>,
22515 {
22516 self._additional_params
22517 .insert(name.as_ref().to_string(), value.as_ref().to_string());
22518 self
22519 }
22520
22521 /// Identifies the authorization scope for the method you are building.
22522 ///
22523 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22524 /// [`Scope::CloudPlatform`].
22525 ///
22526 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22527 /// tokens for more than one scope.
22528 ///
22529 /// Usually there is more than one suitable scope to authorize an operation, some of which may
22530 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22531 /// sufficient, a read-write scope will do as well.
22532 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGetDefaultServiceAccountCall<'a, C>
22533 where
22534 St: AsRef<str>,
22535 {
22536 self._scopes.insert(String::from(scope.as_ref()));
22537 self
22538 }
22539 /// Identifies the authorization scope(s) for the method you are building.
22540 ///
22541 /// See [`Self::add_scope()`] for details.
22542 pub fn add_scopes<I, St>(
22543 mut self,
22544 scopes: I,
22545 ) -> ProjectLocationGetDefaultServiceAccountCall<'a, C>
22546 where
22547 I: IntoIterator<Item = St>,
22548 St: AsRef<str>,
22549 {
22550 self._scopes
22551 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22552 self
22553 }
22554
22555 /// Removes all scopes, and no default scope will be used either.
22556 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22557 /// for details).
22558 pub fn clear_scopes(mut self) -> ProjectLocationGetDefaultServiceAccountCall<'a, C> {
22559 self._scopes.clear();
22560 self
22561 }
22562}
22563
22564/// Creates a new `BuildTrigger`.
22565///
22566/// A builder for the *triggers.create* method supported by a *project* resource.
22567/// It is not used directly, but through a [`ProjectMethods`] instance.
22568///
22569/// # Example
22570///
22571/// Instantiate a resource method builder
22572///
22573/// ```test_harness,no_run
22574/// # extern crate hyper;
22575/// # extern crate hyper_rustls;
22576/// # extern crate google_cloudbuild1 as cloudbuild1;
22577/// use cloudbuild1::api::BuildTrigger;
22578/// # async fn dox() {
22579/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22580///
22581/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22582/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
22583/// # secret,
22584/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22585/// # ).build().await.unwrap();
22586///
22587/// # let client = hyper_util::client::legacy::Client::builder(
22588/// # hyper_util::rt::TokioExecutor::new()
22589/// # )
22590/// # .build(
22591/// # hyper_rustls::HttpsConnectorBuilder::new()
22592/// # .with_native_roots()
22593/// # .unwrap()
22594/// # .https_or_http()
22595/// # .enable_http1()
22596/// # .build()
22597/// # );
22598/// # let mut hub = CloudBuild::new(client, auth);
22599/// // As the method needs a request, you would usually fill it with the desired information
22600/// // into the respective structure. Some of the parts shown here might not be applicable !
22601/// // Values shown here are possibly random and not representative !
22602/// let mut req = BuildTrigger::default();
22603///
22604/// // You can configure optional parameters by calling the respective setters at will, and
22605/// // execute the final call using `doit()`.
22606/// // Values shown here are possibly random and not representative !
22607/// let result = hub.projects().triggers_create(req, "projectId")
22608/// .parent("aliquyam")
22609/// .doit().await;
22610/// # }
22611/// ```
22612pub struct ProjectTriggerCreateCall<'a, C>
22613where
22614 C: 'a,
22615{
22616 hub: &'a CloudBuild<C>,
22617 _request: BuildTrigger,
22618 _project_id: String,
22619 _parent: Option<String>,
22620 _delegate: Option<&'a mut dyn common::Delegate>,
22621 _additional_params: HashMap<String, String>,
22622 _scopes: BTreeSet<String>,
22623}
22624
22625impl<'a, C> common::CallBuilder for ProjectTriggerCreateCall<'a, C> {}
22626
22627impl<'a, C> ProjectTriggerCreateCall<'a, C>
22628where
22629 C: common::Connector,
22630{
22631 /// Perform the operation you have build so far.
22632 pub async fn doit(mut self) -> common::Result<(common::Response, BuildTrigger)> {
22633 use std::borrow::Cow;
22634 use std::io::{Read, Seek};
22635
22636 use common::{url::Params, ToParts};
22637 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22638
22639 let mut dd = common::DefaultDelegate;
22640 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22641 dlg.begin(common::MethodInfo {
22642 id: "cloudbuild.projects.triggers.create",
22643 http_method: hyper::Method::POST,
22644 });
22645
22646 for &field in ["alt", "projectId", "parent"].iter() {
22647 if self._additional_params.contains_key(field) {
22648 dlg.finished(false);
22649 return Err(common::Error::FieldClash(field));
22650 }
22651 }
22652
22653 let mut params = Params::with_capacity(5 + self._additional_params.len());
22654 params.push("projectId", self._project_id);
22655 if let Some(value) = self._parent.as_ref() {
22656 params.push("parent", value);
22657 }
22658
22659 params.extend(self._additional_params.iter());
22660
22661 params.push("alt", "json");
22662 let mut url = self.hub._base_url.clone() + "v1/projects/{projectId}/triggers";
22663 if self._scopes.is_empty() {
22664 self._scopes
22665 .insert(Scope::CloudPlatform.as_ref().to_string());
22666 }
22667
22668 #[allow(clippy::single_element_loop)]
22669 for &(find_this, param_name) in [("{projectId}", "projectId")].iter() {
22670 url = params.uri_replacement(url, param_name, find_this, false);
22671 }
22672 {
22673 let to_remove = ["projectId"];
22674 params.remove_params(&to_remove);
22675 }
22676
22677 let url = params.parse_with_url(&url);
22678
22679 let mut json_mime_type = mime::APPLICATION_JSON;
22680 let mut request_value_reader = {
22681 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
22682 common::remove_json_null_values(&mut value);
22683 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
22684 serde_json::to_writer(&mut dst, &value).unwrap();
22685 dst
22686 };
22687 let request_size = request_value_reader
22688 .seek(std::io::SeekFrom::End(0))
22689 .unwrap();
22690 request_value_reader
22691 .seek(std::io::SeekFrom::Start(0))
22692 .unwrap();
22693
22694 loop {
22695 let token = match self
22696 .hub
22697 .auth
22698 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22699 .await
22700 {
22701 Ok(token) => token,
22702 Err(e) => match dlg.token(e) {
22703 Ok(token) => token,
22704 Err(e) => {
22705 dlg.finished(false);
22706 return Err(common::Error::MissingToken(e));
22707 }
22708 },
22709 };
22710 request_value_reader
22711 .seek(std::io::SeekFrom::Start(0))
22712 .unwrap();
22713 let mut req_result = {
22714 let client = &self.hub.client;
22715 dlg.pre_request();
22716 let mut req_builder = hyper::Request::builder()
22717 .method(hyper::Method::POST)
22718 .uri(url.as_str())
22719 .header(USER_AGENT, self.hub._user_agent.clone());
22720
22721 if let Some(token) = token.as_ref() {
22722 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22723 }
22724
22725 let request = req_builder
22726 .header(CONTENT_TYPE, json_mime_type.to_string())
22727 .header(CONTENT_LENGTH, request_size as u64)
22728 .body(common::to_body(
22729 request_value_reader.get_ref().clone().into(),
22730 ));
22731
22732 client.request(request.unwrap()).await
22733 };
22734
22735 match req_result {
22736 Err(err) => {
22737 if let common::Retry::After(d) = dlg.http_error(&err) {
22738 sleep(d).await;
22739 continue;
22740 }
22741 dlg.finished(false);
22742 return Err(common::Error::HttpError(err));
22743 }
22744 Ok(res) => {
22745 let (mut parts, body) = res.into_parts();
22746 let mut body = common::Body::new(body);
22747 if !parts.status.is_success() {
22748 let bytes = common::to_bytes(body).await.unwrap_or_default();
22749 let error = serde_json::from_str(&common::to_string(&bytes));
22750 let response = common::to_response(parts, bytes.into());
22751
22752 if let common::Retry::After(d) =
22753 dlg.http_failure(&response, error.as_ref().ok())
22754 {
22755 sleep(d).await;
22756 continue;
22757 }
22758
22759 dlg.finished(false);
22760
22761 return Err(match error {
22762 Ok(value) => common::Error::BadRequest(value),
22763 _ => common::Error::Failure(response),
22764 });
22765 }
22766 let response = {
22767 let bytes = common::to_bytes(body).await.unwrap_or_default();
22768 let encoded = common::to_string(&bytes);
22769 match serde_json::from_str(&encoded) {
22770 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22771 Err(error) => {
22772 dlg.response_json_decode_error(&encoded, &error);
22773 return Err(common::Error::JsonDecodeError(
22774 encoded.to_string(),
22775 error,
22776 ));
22777 }
22778 }
22779 };
22780
22781 dlg.finished(true);
22782 return Ok(response);
22783 }
22784 }
22785 }
22786 }
22787
22788 ///
22789 /// Sets the *request* property to the given value.
22790 ///
22791 /// Even though the property as already been set when instantiating this call,
22792 /// we provide this method for API completeness.
22793 pub fn request(mut self, new_value: BuildTrigger) -> ProjectTriggerCreateCall<'a, C> {
22794 self._request = new_value;
22795 self
22796 }
22797 /// Required. ID of the project for which to configure automatic builds.
22798 ///
22799 /// Sets the *project id* path property to the given value.
22800 ///
22801 /// Even though the property as already been set when instantiating this call,
22802 /// we provide this method for API completeness.
22803 pub fn project_id(mut self, new_value: &str) -> ProjectTriggerCreateCall<'a, C> {
22804 self._project_id = new_value.to_string();
22805 self
22806 }
22807 /// The parent resource where this trigger will be created. Format: `projects/{project}/locations/{location}`
22808 ///
22809 /// Sets the *parent* query property to the given value.
22810 pub fn parent(mut self, new_value: &str) -> ProjectTriggerCreateCall<'a, C> {
22811 self._parent = Some(new_value.to_string());
22812 self
22813 }
22814 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22815 /// while executing the actual API request.
22816 ///
22817 /// ````text
22818 /// It should be used to handle progress information, and to implement a certain level of resilience.
22819 /// ````
22820 ///
22821 /// Sets the *delegate* property to the given value.
22822 pub fn delegate(
22823 mut self,
22824 new_value: &'a mut dyn common::Delegate,
22825 ) -> ProjectTriggerCreateCall<'a, C> {
22826 self._delegate = Some(new_value);
22827 self
22828 }
22829
22830 /// Set any additional parameter of the query string used in the request.
22831 /// It should be used to set parameters which are not yet available through their own
22832 /// setters.
22833 ///
22834 /// Please note that this method must not be used to set any of the known parameters
22835 /// which have their own setter method. If done anyway, the request will fail.
22836 ///
22837 /// # Additional Parameters
22838 ///
22839 /// * *$.xgafv* (query-string) - V1 error format.
22840 /// * *access_token* (query-string) - OAuth access token.
22841 /// * *alt* (query-string) - Data format for response.
22842 /// * *callback* (query-string) - JSONP
22843 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22844 /// * *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.
22845 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22846 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22847 /// * *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.
22848 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22849 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22850 pub fn param<T>(mut self, name: T, value: T) -> ProjectTriggerCreateCall<'a, C>
22851 where
22852 T: AsRef<str>,
22853 {
22854 self._additional_params
22855 .insert(name.as_ref().to_string(), value.as_ref().to_string());
22856 self
22857 }
22858
22859 /// Identifies the authorization scope for the method you are building.
22860 ///
22861 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22862 /// [`Scope::CloudPlatform`].
22863 ///
22864 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22865 /// tokens for more than one scope.
22866 ///
22867 /// Usually there is more than one suitable scope to authorize an operation, some of which may
22868 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22869 /// sufficient, a read-write scope will do as well.
22870 pub fn add_scope<St>(mut self, scope: St) -> ProjectTriggerCreateCall<'a, C>
22871 where
22872 St: AsRef<str>,
22873 {
22874 self._scopes.insert(String::from(scope.as_ref()));
22875 self
22876 }
22877 /// Identifies the authorization scope(s) for the method you are building.
22878 ///
22879 /// See [`Self::add_scope()`] for details.
22880 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectTriggerCreateCall<'a, C>
22881 where
22882 I: IntoIterator<Item = St>,
22883 St: AsRef<str>,
22884 {
22885 self._scopes
22886 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22887 self
22888 }
22889
22890 /// Removes all scopes, and no default scope will be used either.
22891 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22892 /// for details).
22893 pub fn clear_scopes(mut self) -> ProjectTriggerCreateCall<'a, C> {
22894 self._scopes.clear();
22895 self
22896 }
22897}
22898
22899/// Deletes a `BuildTrigger` by its project ID and trigger ID.
22900///
22901/// A builder for the *triggers.delete* method supported by a *project* resource.
22902/// It is not used directly, but through a [`ProjectMethods`] instance.
22903///
22904/// # Example
22905///
22906/// Instantiate a resource method builder
22907///
22908/// ```test_harness,no_run
22909/// # extern crate hyper;
22910/// # extern crate hyper_rustls;
22911/// # extern crate google_cloudbuild1 as cloudbuild1;
22912/// # async fn dox() {
22913/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22914///
22915/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22916/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
22917/// # secret,
22918/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22919/// # ).build().await.unwrap();
22920///
22921/// # let client = hyper_util::client::legacy::Client::builder(
22922/// # hyper_util::rt::TokioExecutor::new()
22923/// # )
22924/// # .build(
22925/// # hyper_rustls::HttpsConnectorBuilder::new()
22926/// # .with_native_roots()
22927/// # .unwrap()
22928/// # .https_or_http()
22929/// # .enable_http1()
22930/// # .build()
22931/// # );
22932/// # let mut hub = CloudBuild::new(client, auth);
22933/// // You can configure optional parameters by calling the respective setters at will, and
22934/// // execute the final call using `doit()`.
22935/// // Values shown here are possibly random and not representative !
22936/// let result = hub.projects().triggers_delete("projectId", "triggerId")
22937/// .name("et")
22938/// .doit().await;
22939/// # }
22940/// ```
22941pub struct ProjectTriggerDeleteCall<'a, C>
22942where
22943 C: 'a,
22944{
22945 hub: &'a CloudBuild<C>,
22946 _project_id: String,
22947 _trigger_id: String,
22948 _name: Option<String>,
22949 _delegate: Option<&'a mut dyn common::Delegate>,
22950 _additional_params: HashMap<String, String>,
22951 _scopes: BTreeSet<String>,
22952}
22953
22954impl<'a, C> common::CallBuilder for ProjectTriggerDeleteCall<'a, C> {}
22955
22956impl<'a, C> ProjectTriggerDeleteCall<'a, C>
22957where
22958 C: common::Connector,
22959{
22960 /// Perform the operation you have build so far.
22961 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
22962 use std::borrow::Cow;
22963 use std::io::{Read, Seek};
22964
22965 use common::{url::Params, ToParts};
22966 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22967
22968 let mut dd = common::DefaultDelegate;
22969 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22970 dlg.begin(common::MethodInfo {
22971 id: "cloudbuild.projects.triggers.delete",
22972 http_method: hyper::Method::DELETE,
22973 });
22974
22975 for &field in ["alt", "projectId", "triggerId", "name"].iter() {
22976 if self._additional_params.contains_key(field) {
22977 dlg.finished(false);
22978 return Err(common::Error::FieldClash(field));
22979 }
22980 }
22981
22982 let mut params = Params::with_capacity(5 + self._additional_params.len());
22983 params.push("projectId", self._project_id);
22984 params.push("triggerId", self._trigger_id);
22985 if let Some(value) = self._name.as_ref() {
22986 params.push("name", value);
22987 }
22988
22989 params.extend(self._additional_params.iter());
22990
22991 params.push("alt", "json");
22992 let mut url = self.hub._base_url.clone() + "v1/projects/{projectId}/triggers/{triggerId}";
22993 if self._scopes.is_empty() {
22994 self._scopes
22995 .insert(Scope::CloudPlatform.as_ref().to_string());
22996 }
22997
22998 #[allow(clippy::single_element_loop)]
22999 for &(find_this, param_name) in
23000 [("{projectId}", "projectId"), ("{triggerId}", "triggerId")].iter()
23001 {
23002 url = params.uri_replacement(url, param_name, find_this, false);
23003 }
23004 {
23005 let to_remove = ["triggerId", "projectId"];
23006 params.remove_params(&to_remove);
23007 }
23008
23009 let url = params.parse_with_url(&url);
23010
23011 loop {
23012 let token = match self
23013 .hub
23014 .auth
23015 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23016 .await
23017 {
23018 Ok(token) => token,
23019 Err(e) => match dlg.token(e) {
23020 Ok(token) => token,
23021 Err(e) => {
23022 dlg.finished(false);
23023 return Err(common::Error::MissingToken(e));
23024 }
23025 },
23026 };
23027 let mut req_result = {
23028 let client = &self.hub.client;
23029 dlg.pre_request();
23030 let mut req_builder = hyper::Request::builder()
23031 .method(hyper::Method::DELETE)
23032 .uri(url.as_str())
23033 .header(USER_AGENT, self.hub._user_agent.clone());
23034
23035 if let Some(token) = token.as_ref() {
23036 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23037 }
23038
23039 let request = req_builder
23040 .header(CONTENT_LENGTH, 0_u64)
23041 .body(common::to_body::<String>(None));
23042
23043 client.request(request.unwrap()).await
23044 };
23045
23046 match req_result {
23047 Err(err) => {
23048 if let common::Retry::After(d) = dlg.http_error(&err) {
23049 sleep(d).await;
23050 continue;
23051 }
23052 dlg.finished(false);
23053 return Err(common::Error::HttpError(err));
23054 }
23055 Ok(res) => {
23056 let (mut parts, body) = res.into_parts();
23057 let mut body = common::Body::new(body);
23058 if !parts.status.is_success() {
23059 let bytes = common::to_bytes(body).await.unwrap_or_default();
23060 let error = serde_json::from_str(&common::to_string(&bytes));
23061 let response = common::to_response(parts, bytes.into());
23062
23063 if let common::Retry::After(d) =
23064 dlg.http_failure(&response, error.as_ref().ok())
23065 {
23066 sleep(d).await;
23067 continue;
23068 }
23069
23070 dlg.finished(false);
23071
23072 return Err(match error {
23073 Ok(value) => common::Error::BadRequest(value),
23074 _ => common::Error::Failure(response),
23075 });
23076 }
23077 let response = {
23078 let bytes = common::to_bytes(body).await.unwrap_or_default();
23079 let encoded = common::to_string(&bytes);
23080 match serde_json::from_str(&encoded) {
23081 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23082 Err(error) => {
23083 dlg.response_json_decode_error(&encoded, &error);
23084 return Err(common::Error::JsonDecodeError(
23085 encoded.to_string(),
23086 error,
23087 ));
23088 }
23089 }
23090 };
23091
23092 dlg.finished(true);
23093 return Ok(response);
23094 }
23095 }
23096 }
23097 }
23098
23099 /// Required. ID of the project that owns the trigger.
23100 ///
23101 /// Sets the *project id* path property to the given value.
23102 ///
23103 /// Even though the property as already been set when instantiating this call,
23104 /// we provide this method for API completeness.
23105 pub fn project_id(mut self, new_value: &str) -> ProjectTriggerDeleteCall<'a, C> {
23106 self._project_id = new_value.to_string();
23107 self
23108 }
23109 /// Required. ID of the `BuildTrigger` to delete.
23110 ///
23111 /// Sets the *trigger id* path property to the given value.
23112 ///
23113 /// Even though the property as already been set when instantiating this call,
23114 /// we provide this method for API completeness.
23115 pub fn trigger_id(mut self, new_value: &str) -> ProjectTriggerDeleteCall<'a, C> {
23116 self._trigger_id = new_value.to_string();
23117 self
23118 }
23119 /// The name of the `Trigger` to delete. Format: `projects/{project}/locations/{location}/triggers/{trigger}`
23120 ///
23121 /// Sets the *name* query property to the given value.
23122 pub fn name(mut self, new_value: &str) -> ProjectTriggerDeleteCall<'a, C> {
23123 self._name = Some(new_value.to_string());
23124 self
23125 }
23126 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23127 /// while executing the actual API request.
23128 ///
23129 /// ````text
23130 /// It should be used to handle progress information, and to implement a certain level of resilience.
23131 /// ````
23132 ///
23133 /// Sets the *delegate* property to the given value.
23134 pub fn delegate(
23135 mut self,
23136 new_value: &'a mut dyn common::Delegate,
23137 ) -> ProjectTriggerDeleteCall<'a, C> {
23138 self._delegate = Some(new_value);
23139 self
23140 }
23141
23142 /// Set any additional parameter of the query string used in the request.
23143 /// It should be used to set parameters which are not yet available through their own
23144 /// setters.
23145 ///
23146 /// Please note that this method must not be used to set any of the known parameters
23147 /// which have their own setter method. If done anyway, the request will fail.
23148 ///
23149 /// # Additional Parameters
23150 ///
23151 /// * *$.xgafv* (query-string) - V1 error format.
23152 /// * *access_token* (query-string) - OAuth access token.
23153 /// * *alt* (query-string) - Data format for response.
23154 /// * *callback* (query-string) - JSONP
23155 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23156 /// * *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.
23157 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23158 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23159 /// * *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.
23160 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
23161 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
23162 pub fn param<T>(mut self, name: T, value: T) -> ProjectTriggerDeleteCall<'a, C>
23163 where
23164 T: AsRef<str>,
23165 {
23166 self._additional_params
23167 .insert(name.as_ref().to_string(), value.as_ref().to_string());
23168 self
23169 }
23170
23171 /// Identifies the authorization scope for the method you are building.
23172 ///
23173 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23174 /// [`Scope::CloudPlatform`].
23175 ///
23176 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23177 /// tokens for more than one scope.
23178 ///
23179 /// Usually there is more than one suitable scope to authorize an operation, some of which may
23180 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23181 /// sufficient, a read-write scope will do as well.
23182 pub fn add_scope<St>(mut self, scope: St) -> ProjectTriggerDeleteCall<'a, C>
23183 where
23184 St: AsRef<str>,
23185 {
23186 self._scopes.insert(String::from(scope.as_ref()));
23187 self
23188 }
23189 /// Identifies the authorization scope(s) for the method you are building.
23190 ///
23191 /// See [`Self::add_scope()`] for details.
23192 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectTriggerDeleteCall<'a, C>
23193 where
23194 I: IntoIterator<Item = St>,
23195 St: AsRef<str>,
23196 {
23197 self._scopes
23198 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23199 self
23200 }
23201
23202 /// Removes all scopes, and no default scope will be used either.
23203 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23204 /// for details).
23205 pub fn clear_scopes(mut self) -> ProjectTriggerDeleteCall<'a, C> {
23206 self._scopes.clear();
23207 self
23208 }
23209}
23210
23211/// Returns information about a `BuildTrigger`.
23212///
23213/// A builder for the *triggers.get* method supported by a *project* resource.
23214/// It is not used directly, but through a [`ProjectMethods`] instance.
23215///
23216/// # Example
23217///
23218/// Instantiate a resource method builder
23219///
23220/// ```test_harness,no_run
23221/// # extern crate hyper;
23222/// # extern crate hyper_rustls;
23223/// # extern crate google_cloudbuild1 as cloudbuild1;
23224/// # async fn dox() {
23225/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23226///
23227/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23228/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
23229/// # secret,
23230/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23231/// # ).build().await.unwrap();
23232///
23233/// # let client = hyper_util::client::legacy::Client::builder(
23234/// # hyper_util::rt::TokioExecutor::new()
23235/// # )
23236/// # .build(
23237/// # hyper_rustls::HttpsConnectorBuilder::new()
23238/// # .with_native_roots()
23239/// # .unwrap()
23240/// # .https_or_http()
23241/// # .enable_http1()
23242/// # .build()
23243/// # );
23244/// # let mut hub = CloudBuild::new(client, auth);
23245/// // You can configure optional parameters by calling the respective setters at will, and
23246/// // execute the final call using `doit()`.
23247/// // Values shown here are possibly random and not representative !
23248/// let result = hub.projects().triggers_get("projectId", "triggerId")
23249/// .name("consetetur")
23250/// .doit().await;
23251/// # }
23252/// ```
23253pub struct ProjectTriggerGetCall<'a, C>
23254where
23255 C: 'a,
23256{
23257 hub: &'a CloudBuild<C>,
23258 _project_id: String,
23259 _trigger_id: String,
23260 _name: Option<String>,
23261 _delegate: Option<&'a mut dyn common::Delegate>,
23262 _additional_params: HashMap<String, String>,
23263 _scopes: BTreeSet<String>,
23264}
23265
23266impl<'a, C> common::CallBuilder for ProjectTriggerGetCall<'a, C> {}
23267
23268impl<'a, C> ProjectTriggerGetCall<'a, C>
23269where
23270 C: common::Connector,
23271{
23272 /// Perform the operation you have build so far.
23273 pub async fn doit(mut self) -> common::Result<(common::Response, BuildTrigger)> {
23274 use std::borrow::Cow;
23275 use std::io::{Read, Seek};
23276
23277 use common::{url::Params, ToParts};
23278 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23279
23280 let mut dd = common::DefaultDelegate;
23281 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23282 dlg.begin(common::MethodInfo {
23283 id: "cloudbuild.projects.triggers.get",
23284 http_method: hyper::Method::GET,
23285 });
23286
23287 for &field in ["alt", "projectId", "triggerId", "name"].iter() {
23288 if self._additional_params.contains_key(field) {
23289 dlg.finished(false);
23290 return Err(common::Error::FieldClash(field));
23291 }
23292 }
23293
23294 let mut params = Params::with_capacity(5 + self._additional_params.len());
23295 params.push("projectId", self._project_id);
23296 params.push("triggerId", self._trigger_id);
23297 if let Some(value) = self._name.as_ref() {
23298 params.push("name", value);
23299 }
23300
23301 params.extend(self._additional_params.iter());
23302
23303 params.push("alt", "json");
23304 let mut url = self.hub._base_url.clone() + "v1/projects/{projectId}/triggers/{triggerId}";
23305 if self._scopes.is_empty() {
23306 self._scopes
23307 .insert(Scope::CloudPlatform.as_ref().to_string());
23308 }
23309
23310 #[allow(clippy::single_element_loop)]
23311 for &(find_this, param_name) in
23312 [("{projectId}", "projectId"), ("{triggerId}", "triggerId")].iter()
23313 {
23314 url = params.uri_replacement(url, param_name, find_this, false);
23315 }
23316 {
23317 let to_remove = ["triggerId", "projectId"];
23318 params.remove_params(&to_remove);
23319 }
23320
23321 let url = params.parse_with_url(&url);
23322
23323 loop {
23324 let token = match self
23325 .hub
23326 .auth
23327 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23328 .await
23329 {
23330 Ok(token) => token,
23331 Err(e) => match dlg.token(e) {
23332 Ok(token) => token,
23333 Err(e) => {
23334 dlg.finished(false);
23335 return Err(common::Error::MissingToken(e));
23336 }
23337 },
23338 };
23339 let mut req_result = {
23340 let client = &self.hub.client;
23341 dlg.pre_request();
23342 let mut req_builder = hyper::Request::builder()
23343 .method(hyper::Method::GET)
23344 .uri(url.as_str())
23345 .header(USER_AGENT, self.hub._user_agent.clone());
23346
23347 if let Some(token) = token.as_ref() {
23348 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23349 }
23350
23351 let request = req_builder
23352 .header(CONTENT_LENGTH, 0_u64)
23353 .body(common::to_body::<String>(None));
23354
23355 client.request(request.unwrap()).await
23356 };
23357
23358 match req_result {
23359 Err(err) => {
23360 if let common::Retry::After(d) = dlg.http_error(&err) {
23361 sleep(d).await;
23362 continue;
23363 }
23364 dlg.finished(false);
23365 return Err(common::Error::HttpError(err));
23366 }
23367 Ok(res) => {
23368 let (mut parts, body) = res.into_parts();
23369 let mut body = common::Body::new(body);
23370 if !parts.status.is_success() {
23371 let bytes = common::to_bytes(body).await.unwrap_or_default();
23372 let error = serde_json::from_str(&common::to_string(&bytes));
23373 let response = common::to_response(parts, bytes.into());
23374
23375 if let common::Retry::After(d) =
23376 dlg.http_failure(&response, error.as_ref().ok())
23377 {
23378 sleep(d).await;
23379 continue;
23380 }
23381
23382 dlg.finished(false);
23383
23384 return Err(match error {
23385 Ok(value) => common::Error::BadRequest(value),
23386 _ => common::Error::Failure(response),
23387 });
23388 }
23389 let response = {
23390 let bytes = common::to_bytes(body).await.unwrap_or_default();
23391 let encoded = common::to_string(&bytes);
23392 match serde_json::from_str(&encoded) {
23393 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23394 Err(error) => {
23395 dlg.response_json_decode_error(&encoded, &error);
23396 return Err(common::Error::JsonDecodeError(
23397 encoded.to_string(),
23398 error,
23399 ));
23400 }
23401 }
23402 };
23403
23404 dlg.finished(true);
23405 return Ok(response);
23406 }
23407 }
23408 }
23409 }
23410
23411 /// Required. ID of the project that owns the trigger.
23412 ///
23413 /// Sets the *project id* path property to the given value.
23414 ///
23415 /// Even though the property as already been set when instantiating this call,
23416 /// we provide this method for API completeness.
23417 pub fn project_id(mut self, new_value: &str) -> ProjectTriggerGetCall<'a, C> {
23418 self._project_id = new_value.to_string();
23419 self
23420 }
23421 /// Required. Identifier (`id` or `name`) of the `BuildTrigger` to get.
23422 ///
23423 /// Sets the *trigger id* path property to the given value.
23424 ///
23425 /// Even though the property as already been set when instantiating this call,
23426 /// we provide this method for API completeness.
23427 pub fn trigger_id(mut self, new_value: &str) -> ProjectTriggerGetCall<'a, C> {
23428 self._trigger_id = new_value.to_string();
23429 self
23430 }
23431 /// The name of the `Trigger` to retrieve. Format: `projects/{project}/locations/{location}/triggers/{trigger}`
23432 ///
23433 /// Sets the *name* query property to the given value.
23434 pub fn name(mut self, new_value: &str) -> ProjectTriggerGetCall<'a, C> {
23435 self._name = Some(new_value.to_string());
23436 self
23437 }
23438 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23439 /// while executing the actual API request.
23440 ///
23441 /// ````text
23442 /// It should be used to handle progress information, and to implement a certain level of resilience.
23443 /// ````
23444 ///
23445 /// Sets the *delegate* property to the given value.
23446 pub fn delegate(
23447 mut self,
23448 new_value: &'a mut dyn common::Delegate,
23449 ) -> ProjectTriggerGetCall<'a, C> {
23450 self._delegate = Some(new_value);
23451 self
23452 }
23453
23454 /// Set any additional parameter of the query string used in the request.
23455 /// It should be used to set parameters which are not yet available through their own
23456 /// setters.
23457 ///
23458 /// Please note that this method must not be used to set any of the known parameters
23459 /// which have their own setter method. If done anyway, the request will fail.
23460 ///
23461 /// # Additional Parameters
23462 ///
23463 /// * *$.xgafv* (query-string) - V1 error format.
23464 /// * *access_token* (query-string) - OAuth access token.
23465 /// * *alt* (query-string) - Data format for response.
23466 /// * *callback* (query-string) - JSONP
23467 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23468 /// * *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.
23469 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23470 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23471 /// * *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.
23472 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
23473 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
23474 pub fn param<T>(mut self, name: T, value: T) -> ProjectTriggerGetCall<'a, C>
23475 where
23476 T: AsRef<str>,
23477 {
23478 self._additional_params
23479 .insert(name.as_ref().to_string(), value.as_ref().to_string());
23480 self
23481 }
23482
23483 /// Identifies the authorization scope for the method you are building.
23484 ///
23485 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23486 /// [`Scope::CloudPlatform`].
23487 ///
23488 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23489 /// tokens for more than one scope.
23490 ///
23491 /// Usually there is more than one suitable scope to authorize an operation, some of which may
23492 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23493 /// sufficient, a read-write scope will do as well.
23494 pub fn add_scope<St>(mut self, scope: St) -> ProjectTriggerGetCall<'a, C>
23495 where
23496 St: AsRef<str>,
23497 {
23498 self._scopes.insert(String::from(scope.as_ref()));
23499 self
23500 }
23501 /// Identifies the authorization scope(s) for the method you are building.
23502 ///
23503 /// See [`Self::add_scope()`] for details.
23504 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectTriggerGetCall<'a, C>
23505 where
23506 I: IntoIterator<Item = St>,
23507 St: AsRef<str>,
23508 {
23509 self._scopes
23510 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23511 self
23512 }
23513
23514 /// Removes all scopes, and no default scope will be used either.
23515 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23516 /// for details).
23517 pub fn clear_scopes(mut self) -> ProjectTriggerGetCall<'a, C> {
23518 self._scopes.clear();
23519 self
23520 }
23521}
23522
23523/// Lists existing `BuildTrigger`s.
23524///
23525/// A builder for the *triggers.list* method supported by a *project* resource.
23526/// It is not used directly, but through a [`ProjectMethods`] instance.
23527///
23528/// # Example
23529///
23530/// Instantiate a resource method builder
23531///
23532/// ```test_harness,no_run
23533/// # extern crate hyper;
23534/// # extern crate hyper_rustls;
23535/// # extern crate google_cloudbuild1 as cloudbuild1;
23536/// # async fn dox() {
23537/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23538///
23539/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23540/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
23541/// # secret,
23542/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23543/// # ).build().await.unwrap();
23544///
23545/// # let client = hyper_util::client::legacy::Client::builder(
23546/// # hyper_util::rt::TokioExecutor::new()
23547/// # )
23548/// # .build(
23549/// # hyper_rustls::HttpsConnectorBuilder::new()
23550/// # .with_native_roots()
23551/// # .unwrap()
23552/// # .https_or_http()
23553/// # .enable_http1()
23554/// # .build()
23555/// # );
23556/// # let mut hub = CloudBuild::new(client, auth);
23557/// // You can configure optional parameters by calling the respective setters at will, and
23558/// // execute the final call using `doit()`.
23559/// // Values shown here are possibly random and not representative !
23560/// let result = hub.projects().triggers_list("projectId")
23561/// .parent("est")
23562/// .page_token("aliquyam")
23563/// .page_size(-94)
23564/// .doit().await;
23565/// # }
23566/// ```
23567pub struct ProjectTriggerListCall<'a, C>
23568where
23569 C: 'a,
23570{
23571 hub: &'a CloudBuild<C>,
23572 _project_id: String,
23573 _parent: Option<String>,
23574 _page_token: Option<String>,
23575 _page_size: Option<i32>,
23576 _delegate: Option<&'a mut dyn common::Delegate>,
23577 _additional_params: HashMap<String, String>,
23578 _scopes: BTreeSet<String>,
23579}
23580
23581impl<'a, C> common::CallBuilder for ProjectTriggerListCall<'a, C> {}
23582
23583impl<'a, C> ProjectTriggerListCall<'a, C>
23584where
23585 C: common::Connector,
23586{
23587 /// Perform the operation you have build so far.
23588 pub async fn doit(mut self) -> common::Result<(common::Response, ListBuildTriggersResponse)> {
23589 use std::borrow::Cow;
23590 use std::io::{Read, Seek};
23591
23592 use common::{url::Params, ToParts};
23593 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23594
23595 let mut dd = common::DefaultDelegate;
23596 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23597 dlg.begin(common::MethodInfo {
23598 id: "cloudbuild.projects.triggers.list",
23599 http_method: hyper::Method::GET,
23600 });
23601
23602 for &field in ["alt", "projectId", "parent", "pageToken", "pageSize"].iter() {
23603 if self._additional_params.contains_key(field) {
23604 dlg.finished(false);
23605 return Err(common::Error::FieldClash(field));
23606 }
23607 }
23608
23609 let mut params = Params::with_capacity(6 + self._additional_params.len());
23610 params.push("projectId", self._project_id);
23611 if let Some(value) = self._parent.as_ref() {
23612 params.push("parent", value);
23613 }
23614 if let Some(value) = self._page_token.as_ref() {
23615 params.push("pageToken", value);
23616 }
23617 if let Some(value) = self._page_size.as_ref() {
23618 params.push("pageSize", value.to_string());
23619 }
23620
23621 params.extend(self._additional_params.iter());
23622
23623 params.push("alt", "json");
23624 let mut url = self.hub._base_url.clone() + "v1/projects/{projectId}/triggers";
23625 if self._scopes.is_empty() {
23626 self._scopes
23627 .insert(Scope::CloudPlatform.as_ref().to_string());
23628 }
23629
23630 #[allow(clippy::single_element_loop)]
23631 for &(find_this, param_name) in [("{projectId}", "projectId")].iter() {
23632 url = params.uri_replacement(url, param_name, find_this, false);
23633 }
23634 {
23635 let to_remove = ["projectId"];
23636 params.remove_params(&to_remove);
23637 }
23638
23639 let url = params.parse_with_url(&url);
23640
23641 loop {
23642 let token = match self
23643 .hub
23644 .auth
23645 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23646 .await
23647 {
23648 Ok(token) => token,
23649 Err(e) => match dlg.token(e) {
23650 Ok(token) => token,
23651 Err(e) => {
23652 dlg.finished(false);
23653 return Err(common::Error::MissingToken(e));
23654 }
23655 },
23656 };
23657 let mut req_result = {
23658 let client = &self.hub.client;
23659 dlg.pre_request();
23660 let mut req_builder = hyper::Request::builder()
23661 .method(hyper::Method::GET)
23662 .uri(url.as_str())
23663 .header(USER_AGENT, self.hub._user_agent.clone());
23664
23665 if let Some(token) = token.as_ref() {
23666 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23667 }
23668
23669 let request = req_builder
23670 .header(CONTENT_LENGTH, 0_u64)
23671 .body(common::to_body::<String>(None));
23672
23673 client.request(request.unwrap()).await
23674 };
23675
23676 match req_result {
23677 Err(err) => {
23678 if let common::Retry::After(d) = dlg.http_error(&err) {
23679 sleep(d).await;
23680 continue;
23681 }
23682 dlg.finished(false);
23683 return Err(common::Error::HttpError(err));
23684 }
23685 Ok(res) => {
23686 let (mut parts, body) = res.into_parts();
23687 let mut body = common::Body::new(body);
23688 if !parts.status.is_success() {
23689 let bytes = common::to_bytes(body).await.unwrap_or_default();
23690 let error = serde_json::from_str(&common::to_string(&bytes));
23691 let response = common::to_response(parts, bytes.into());
23692
23693 if let common::Retry::After(d) =
23694 dlg.http_failure(&response, error.as_ref().ok())
23695 {
23696 sleep(d).await;
23697 continue;
23698 }
23699
23700 dlg.finished(false);
23701
23702 return Err(match error {
23703 Ok(value) => common::Error::BadRequest(value),
23704 _ => common::Error::Failure(response),
23705 });
23706 }
23707 let response = {
23708 let bytes = common::to_bytes(body).await.unwrap_or_default();
23709 let encoded = common::to_string(&bytes);
23710 match serde_json::from_str(&encoded) {
23711 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23712 Err(error) => {
23713 dlg.response_json_decode_error(&encoded, &error);
23714 return Err(common::Error::JsonDecodeError(
23715 encoded.to_string(),
23716 error,
23717 ));
23718 }
23719 }
23720 };
23721
23722 dlg.finished(true);
23723 return Ok(response);
23724 }
23725 }
23726 }
23727 }
23728
23729 /// Required. ID of the project for which to list BuildTriggers.
23730 ///
23731 /// Sets the *project id* path property to the given value.
23732 ///
23733 /// Even though the property as already been set when instantiating this call,
23734 /// we provide this method for API completeness.
23735 pub fn project_id(mut self, new_value: &str) -> ProjectTriggerListCall<'a, C> {
23736 self._project_id = new_value.to_string();
23737 self
23738 }
23739 /// The parent of the collection of `Triggers`. Format: `projects/{project}/locations/{location}`
23740 ///
23741 /// Sets the *parent* query property to the given value.
23742 pub fn parent(mut self, new_value: &str) -> ProjectTriggerListCall<'a, C> {
23743 self._parent = Some(new_value.to_string());
23744 self
23745 }
23746 /// Token to provide to skip to a particular spot in the list.
23747 ///
23748 /// Sets the *page token* query property to the given value.
23749 pub fn page_token(mut self, new_value: &str) -> ProjectTriggerListCall<'a, C> {
23750 self._page_token = Some(new_value.to_string());
23751 self
23752 }
23753 /// Number of results to return in the list.
23754 ///
23755 /// Sets the *page size* query property to the given value.
23756 pub fn page_size(mut self, new_value: i32) -> ProjectTriggerListCall<'a, C> {
23757 self._page_size = Some(new_value);
23758 self
23759 }
23760 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23761 /// while executing the actual API request.
23762 ///
23763 /// ````text
23764 /// It should be used to handle progress information, and to implement a certain level of resilience.
23765 /// ````
23766 ///
23767 /// Sets the *delegate* property to the given value.
23768 pub fn delegate(
23769 mut self,
23770 new_value: &'a mut dyn common::Delegate,
23771 ) -> ProjectTriggerListCall<'a, C> {
23772 self._delegate = Some(new_value);
23773 self
23774 }
23775
23776 /// Set any additional parameter of the query string used in the request.
23777 /// It should be used to set parameters which are not yet available through their own
23778 /// setters.
23779 ///
23780 /// Please note that this method must not be used to set any of the known parameters
23781 /// which have their own setter method. If done anyway, the request will fail.
23782 ///
23783 /// # Additional Parameters
23784 ///
23785 /// * *$.xgafv* (query-string) - V1 error format.
23786 /// * *access_token* (query-string) - OAuth access token.
23787 /// * *alt* (query-string) - Data format for response.
23788 /// * *callback* (query-string) - JSONP
23789 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23790 /// * *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.
23791 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23792 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23793 /// * *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.
23794 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
23795 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
23796 pub fn param<T>(mut self, name: T, value: T) -> ProjectTriggerListCall<'a, C>
23797 where
23798 T: AsRef<str>,
23799 {
23800 self._additional_params
23801 .insert(name.as_ref().to_string(), value.as_ref().to_string());
23802 self
23803 }
23804
23805 /// Identifies the authorization scope for the method you are building.
23806 ///
23807 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23808 /// [`Scope::CloudPlatform`].
23809 ///
23810 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23811 /// tokens for more than one scope.
23812 ///
23813 /// Usually there is more than one suitable scope to authorize an operation, some of which may
23814 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23815 /// sufficient, a read-write scope will do as well.
23816 pub fn add_scope<St>(mut self, scope: St) -> ProjectTriggerListCall<'a, C>
23817 where
23818 St: AsRef<str>,
23819 {
23820 self._scopes.insert(String::from(scope.as_ref()));
23821 self
23822 }
23823 /// Identifies the authorization scope(s) for the method you are building.
23824 ///
23825 /// See [`Self::add_scope()`] for details.
23826 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectTriggerListCall<'a, C>
23827 where
23828 I: IntoIterator<Item = St>,
23829 St: AsRef<str>,
23830 {
23831 self._scopes
23832 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23833 self
23834 }
23835
23836 /// Removes all scopes, and no default scope will be used either.
23837 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23838 /// for details).
23839 pub fn clear_scopes(mut self) -> ProjectTriggerListCall<'a, C> {
23840 self._scopes.clear();
23841 self
23842 }
23843}
23844
23845/// Updates a `BuildTrigger` by its project ID and trigger ID.
23846///
23847/// A builder for the *triggers.patch* method supported by a *project* resource.
23848/// It is not used directly, but through a [`ProjectMethods`] instance.
23849///
23850/// # Example
23851///
23852/// Instantiate a resource method builder
23853///
23854/// ```test_harness,no_run
23855/// # extern crate hyper;
23856/// # extern crate hyper_rustls;
23857/// # extern crate google_cloudbuild1 as cloudbuild1;
23858/// use cloudbuild1::api::BuildTrigger;
23859/// # async fn dox() {
23860/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23861///
23862/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23863/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
23864/// # secret,
23865/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23866/// # ).build().await.unwrap();
23867///
23868/// # let client = hyper_util::client::legacy::Client::builder(
23869/// # hyper_util::rt::TokioExecutor::new()
23870/// # )
23871/// # .build(
23872/// # hyper_rustls::HttpsConnectorBuilder::new()
23873/// # .with_native_roots()
23874/// # .unwrap()
23875/// # .https_or_http()
23876/// # .enable_http1()
23877/// # .build()
23878/// # );
23879/// # let mut hub = CloudBuild::new(client, auth);
23880/// // As the method needs a request, you would usually fill it with the desired information
23881/// // into the respective structure. Some of the parts shown here might not be applicable !
23882/// // Values shown here are possibly random and not representative !
23883/// let mut req = BuildTrigger::default();
23884///
23885/// // You can configure optional parameters by calling the respective setters at will, and
23886/// // execute the final call using `doit()`.
23887/// // Values shown here are possibly random and not representative !
23888/// let result = hub.projects().triggers_patch(req, "projectId", "triggerId")
23889/// .update_mask(FieldMask::new::<&str>(&[]))
23890/// .doit().await;
23891/// # }
23892/// ```
23893pub struct ProjectTriggerPatchCall<'a, C>
23894where
23895 C: 'a,
23896{
23897 hub: &'a CloudBuild<C>,
23898 _request: BuildTrigger,
23899 _project_id: String,
23900 _trigger_id: String,
23901 _update_mask: Option<common::FieldMask>,
23902 _delegate: Option<&'a mut dyn common::Delegate>,
23903 _additional_params: HashMap<String, String>,
23904 _scopes: BTreeSet<String>,
23905}
23906
23907impl<'a, C> common::CallBuilder for ProjectTriggerPatchCall<'a, C> {}
23908
23909impl<'a, C> ProjectTriggerPatchCall<'a, C>
23910where
23911 C: common::Connector,
23912{
23913 /// Perform the operation you have build so far.
23914 pub async fn doit(mut self) -> common::Result<(common::Response, BuildTrigger)> {
23915 use std::borrow::Cow;
23916 use std::io::{Read, Seek};
23917
23918 use common::{url::Params, ToParts};
23919 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23920
23921 let mut dd = common::DefaultDelegate;
23922 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23923 dlg.begin(common::MethodInfo {
23924 id: "cloudbuild.projects.triggers.patch",
23925 http_method: hyper::Method::PATCH,
23926 });
23927
23928 for &field in ["alt", "projectId", "triggerId", "updateMask"].iter() {
23929 if self._additional_params.contains_key(field) {
23930 dlg.finished(false);
23931 return Err(common::Error::FieldClash(field));
23932 }
23933 }
23934
23935 let mut params = Params::with_capacity(6 + self._additional_params.len());
23936 params.push("projectId", self._project_id);
23937 params.push("triggerId", self._trigger_id);
23938 if let Some(value) = self._update_mask.as_ref() {
23939 params.push("updateMask", value.to_string());
23940 }
23941
23942 params.extend(self._additional_params.iter());
23943
23944 params.push("alt", "json");
23945 let mut url = self.hub._base_url.clone() + "v1/projects/{projectId}/triggers/{triggerId}";
23946 if self._scopes.is_empty() {
23947 self._scopes
23948 .insert(Scope::CloudPlatform.as_ref().to_string());
23949 }
23950
23951 #[allow(clippy::single_element_loop)]
23952 for &(find_this, param_name) in
23953 [("{projectId}", "projectId"), ("{triggerId}", "triggerId")].iter()
23954 {
23955 url = params.uri_replacement(url, param_name, find_this, false);
23956 }
23957 {
23958 let to_remove = ["triggerId", "projectId"];
23959 params.remove_params(&to_remove);
23960 }
23961
23962 let url = params.parse_with_url(&url);
23963
23964 let mut json_mime_type = mime::APPLICATION_JSON;
23965 let mut request_value_reader = {
23966 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
23967 common::remove_json_null_values(&mut value);
23968 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
23969 serde_json::to_writer(&mut dst, &value).unwrap();
23970 dst
23971 };
23972 let request_size = request_value_reader
23973 .seek(std::io::SeekFrom::End(0))
23974 .unwrap();
23975 request_value_reader
23976 .seek(std::io::SeekFrom::Start(0))
23977 .unwrap();
23978
23979 loop {
23980 let token = match self
23981 .hub
23982 .auth
23983 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23984 .await
23985 {
23986 Ok(token) => token,
23987 Err(e) => match dlg.token(e) {
23988 Ok(token) => token,
23989 Err(e) => {
23990 dlg.finished(false);
23991 return Err(common::Error::MissingToken(e));
23992 }
23993 },
23994 };
23995 request_value_reader
23996 .seek(std::io::SeekFrom::Start(0))
23997 .unwrap();
23998 let mut req_result = {
23999 let client = &self.hub.client;
24000 dlg.pre_request();
24001 let mut req_builder = hyper::Request::builder()
24002 .method(hyper::Method::PATCH)
24003 .uri(url.as_str())
24004 .header(USER_AGENT, self.hub._user_agent.clone());
24005
24006 if let Some(token) = token.as_ref() {
24007 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24008 }
24009
24010 let request = req_builder
24011 .header(CONTENT_TYPE, json_mime_type.to_string())
24012 .header(CONTENT_LENGTH, request_size as u64)
24013 .body(common::to_body(
24014 request_value_reader.get_ref().clone().into(),
24015 ));
24016
24017 client.request(request.unwrap()).await
24018 };
24019
24020 match req_result {
24021 Err(err) => {
24022 if let common::Retry::After(d) = dlg.http_error(&err) {
24023 sleep(d).await;
24024 continue;
24025 }
24026 dlg.finished(false);
24027 return Err(common::Error::HttpError(err));
24028 }
24029 Ok(res) => {
24030 let (mut parts, body) = res.into_parts();
24031 let mut body = common::Body::new(body);
24032 if !parts.status.is_success() {
24033 let bytes = common::to_bytes(body).await.unwrap_or_default();
24034 let error = serde_json::from_str(&common::to_string(&bytes));
24035 let response = common::to_response(parts, bytes.into());
24036
24037 if let common::Retry::After(d) =
24038 dlg.http_failure(&response, error.as_ref().ok())
24039 {
24040 sleep(d).await;
24041 continue;
24042 }
24043
24044 dlg.finished(false);
24045
24046 return Err(match error {
24047 Ok(value) => common::Error::BadRequest(value),
24048 _ => common::Error::Failure(response),
24049 });
24050 }
24051 let response = {
24052 let bytes = common::to_bytes(body).await.unwrap_or_default();
24053 let encoded = common::to_string(&bytes);
24054 match serde_json::from_str(&encoded) {
24055 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24056 Err(error) => {
24057 dlg.response_json_decode_error(&encoded, &error);
24058 return Err(common::Error::JsonDecodeError(
24059 encoded.to_string(),
24060 error,
24061 ));
24062 }
24063 }
24064 };
24065
24066 dlg.finished(true);
24067 return Ok(response);
24068 }
24069 }
24070 }
24071 }
24072
24073 ///
24074 /// Sets the *request* property to the given value.
24075 ///
24076 /// Even though the property as already been set when instantiating this call,
24077 /// we provide this method for API completeness.
24078 pub fn request(mut self, new_value: BuildTrigger) -> ProjectTriggerPatchCall<'a, C> {
24079 self._request = new_value;
24080 self
24081 }
24082 /// Required. ID of the project that owns the trigger.
24083 ///
24084 /// Sets the *project id* path property to the given value.
24085 ///
24086 /// Even though the property as already been set when instantiating this call,
24087 /// we provide this method for API completeness.
24088 pub fn project_id(mut self, new_value: &str) -> ProjectTriggerPatchCall<'a, C> {
24089 self._project_id = new_value.to_string();
24090 self
24091 }
24092 /// Required. ID of the `BuildTrigger` to update.
24093 ///
24094 /// Sets the *trigger id* path property to the given value.
24095 ///
24096 /// Even though the property as already been set when instantiating this call,
24097 /// we provide this method for API completeness.
24098 pub fn trigger_id(mut self, new_value: &str) -> ProjectTriggerPatchCall<'a, C> {
24099 self._trigger_id = new_value.to_string();
24100 self
24101 }
24102 /// Update mask for the resource. If this is set, the server will only update the fields specified in the field mask. Otherwise, a full update of the mutable resource fields will be performed.
24103 ///
24104 /// Sets the *update mask* query property to the given value.
24105 pub fn update_mask(mut self, new_value: common::FieldMask) -> ProjectTriggerPatchCall<'a, C> {
24106 self._update_mask = Some(new_value);
24107 self
24108 }
24109 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24110 /// while executing the actual API request.
24111 ///
24112 /// ````text
24113 /// It should be used to handle progress information, and to implement a certain level of resilience.
24114 /// ````
24115 ///
24116 /// Sets the *delegate* property to the given value.
24117 pub fn delegate(
24118 mut self,
24119 new_value: &'a mut dyn common::Delegate,
24120 ) -> ProjectTriggerPatchCall<'a, C> {
24121 self._delegate = Some(new_value);
24122 self
24123 }
24124
24125 /// Set any additional parameter of the query string used in the request.
24126 /// It should be used to set parameters which are not yet available through their own
24127 /// setters.
24128 ///
24129 /// Please note that this method must not be used to set any of the known parameters
24130 /// which have their own setter method. If done anyway, the request will fail.
24131 ///
24132 /// # Additional Parameters
24133 ///
24134 /// * *$.xgafv* (query-string) - V1 error format.
24135 /// * *access_token* (query-string) - OAuth access token.
24136 /// * *alt* (query-string) - Data format for response.
24137 /// * *callback* (query-string) - JSONP
24138 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24139 /// * *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.
24140 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24141 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24142 /// * *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.
24143 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
24144 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
24145 pub fn param<T>(mut self, name: T, value: T) -> ProjectTriggerPatchCall<'a, C>
24146 where
24147 T: AsRef<str>,
24148 {
24149 self._additional_params
24150 .insert(name.as_ref().to_string(), value.as_ref().to_string());
24151 self
24152 }
24153
24154 /// Identifies the authorization scope for the method you are building.
24155 ///
24156 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24157 /// [`Scope::CloudPlatform`].
24158 ///
24159 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24160 /// tokens for more than one scope.
24161 ///
24162 /// Usually there is more than one suitable scope to authorize an operation, some of which may
24163 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24164 /// sufficient, a read-write scope will do as well.
24165 pub fn add_scope<St>(mut self, scope: St) -> ProjectTriggerPatchCall<'a, C>
24166 where
24167 St: AsRef<str>,
24168 {
24169 self._scopes.insert(String::from(scope.as_ref()));
24170 self
24171 }
24172 /// Identifies the authorization scope(s) for the method you are building.
24173 ///
24174 /// See [`Self::add_scope()`] for details.
24175 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectTriggerPatchCall<'a, C>
24176 where
24177 I: IntoIterator<Item = St>,
24178 St: AsRef<str>,
24179 {
24180 self._scopes
24181 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24182 self
24183 }
24184
24185 /// Removes all scopes, and no default scope will be used either.
24186 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24187 /// for details).
24188 pub fn clear_scopes(mut self) -> ProjectTriggerPatchCall<'a, C> {
24189 self._scopes.clear();
24190 self
24191 }
24192}
24193
24194/// Runs a `BuildTrigger` at a particular source revision. To run a regional or global trigger, use the POST request that includes the location endpoint in the path (ex. v1/projects/{projectId}/locations/{region}/triggers/{triggerId}:run). The POST request that does not include the location endpoint in the path can only be used when running global triggers.
24195///
24196/// A builder for the *triggers.run* method supported by a *project* resource.
24197/// It is not used directly, but through a [`ProjectMethods`] instance.
24198///
24199/// # Example
24200///
24201/// Instantiate a resource method builder
24202///
24203/// ```test_harness,no_run
24204/// # extern crate hyper;
24205/// # extern crate hyper_rustls;
24206/// # extern crate google_cloudbuild1 as cloudbuild1;
24207/// use cloudbuild1::api::RepoSource;
24208/// # async fn dox() {
24209/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24210///
24211/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
24212/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
24213/// # secret,
24214/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24215/// # ).build().await.unwrap();
24216///
24217/// # let client = hyper_util::client::legacy::Client::builder(
24218/// # hyper_util::rt::TokioExecutor::new()
24219/// # )
24220/// # .build(
24221/// # hyper_rustls::HttpsConnectorBuilder::new()
24222/// # .with_native_roots()
24223/// # .unwrap()
24224/// # .https_or_http()
24225/// # .enable_http1()
24226/// # .build()
24227/// # );
24228/// # let mut hub = CloudBuild::new(client, auth);
24229/// // As the method needs a request, you would usually fill it with the desired information
24230/// // into the respective structure. Some of the parts shown here might not be applicable !
24231/// // Values shown here are possibly random and not representative !
24232/// let mut req = RepoSource::default();
24233///
24234/// // You can configure optional parameters by calling the respective setters at will, and
24235/// // execute the final call using `doit()`.
24236/// // Values shown here are possibly random and not representative !
24237/// let result = hub.projects().triggers_run(req, "projectId", "triggerId")
24238/// .name("sed")
24239/// .doit().await;
24240/// # }
24241/// ```
24242pub struct ProjectTriggerRunCall<'a, C>
24243where
24244 C: 'a,
24245{
24246 hub: &'a CloudBuild<C>,
24247 _request: RepoSource,
24248 _project_id: String,
24249 _trigger_id: String,
24250 _name: Option<String>,
24251 _delegate: Option<&'a mut dyn common::Delegate>,
24252 _additional_params: HashMap<String, String>,
24253 _scopes: BTreeSet<String>,
24254}
24255
24256impl<'a, C> common::CallBuilder for ProjectTriggerRunCall<'a, C> {}
24257
24258impl<'a, C> ProjectTriggerRunCall<'a, C>
24259where
24260 C: common::Connector,
24261{
24262 /// Perform the operation you have build so far.
24263 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
24264 use std::borrow::Cow;
24265 use std::io::{Read, Seek};
24266
24267 use common::{url::Params, ToParts};
24268 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24269
24270 let mut dd = common::DefaultDelegate;
24271 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24272 dlg.begin(common::MethodInfo {
24273 id: "cloudbuild.projects.triggers.run",
24274 http_method: hyper::Method::POST,
24275 });
24276
24277 for &field in ["alt", "projectId", "triggerId", "name"].iter() {
24278 if self._additional_params.contains_key(field) {
24279 dlg.finished(false);
24280 return Err(common::Error::FieldClash(field));
24281 }
24282 }
24283
24284 let mut params = Params::with_capacity(6 + self._additional_params.len());
24285 params.push("projectId", self._project_id);
24286 params.push("triggerId", self._trigger_id);
24287 if let Some(value) = self._name.as_ref() {
24288 params.push("name", value);
24289 }
24290
24291 params.extend(self._additional_params.iter());
24292
24293 params.push("alt", "json");
24294 let mut url =
24295 self.hub._base_url.clone() + "v1/projects/{projectId}/triggers/{triggerId}:run";
24296 if self._scopes.is_empty() {
24297 self._scopes
24298 .insert(Scope::CloudPlatform.as_ref().to_string());
24299 }
24300
24301 #[allow(clippy::single_element_loop)]
24302 for &(find_this, param_name) in
24303 [("{projectId}", "projectId"), ("{triggerId}", "triggerId")].iter()
24304 {
24305 url = params.uri_replacement(url, param_name, find_this, false);
24306 }
24307 {
24308 let to_remove = ["triggerId", "projectId"];
24309 params.remove_params(&to_remove);
24310 }
24311
24312 let url = params.parse_with_url(&url);
24313
24314 let mut json_mime_type = mime::APPLICATION_JSON;
24315 let mut request_value_reader = {
24316 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
24317 common::remove_json_null_values(&mut value);
24318 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
24319 serde_json::to_writer(&mut dst, &value).unwrap();
24320 dst
24321 };
24322 let request_size = request_value_reader
24323 .seek(std::io::SeekFrom::End(0))
24324 .unwrap();
24325 request_value_reader
24326 .seek(std::io::SeekFrom::Start(0))
24327 .unwrap();
24328
24329 loop {
24330 let token = match self
24331 .hub
24332 .auth
24333 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24334 .await
24335 {
24336 Ok(token) => token,
24337 Err(e) => match dlg.token(e) {
24338 Ok(token) => token,
24339 Err(e) => {
24340 dlg.finished(false);
24341 return Err(common::Error::MissingToken(e));
24342 }
24343 },
24344 };
24345 request_value_reader
24346 .seek(std::io::SeekFrom::Start(0))
24347 .unwrap();
24348 let mut req_result = {
24349 let client = &self.hub.client;
24350 dlg.pre_request();
24351 let mut req_builder = hyper::Request::builder()
24352 .method(hyper::Method::POST)
24353 .uri(url.as_str())
24354 .header(USER_AGENT, self.hub._user_agent.clone());
24355
24356 if let Some(token) = token.as_ref() {
24357 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24358 }
24359
24360 let request = req_builder
24361 .header(CONTENT_TYPE, json_mime_type.to_string())
24362 .header(CONTENT_LENGTH, request_size as u64)
24363 .body(common::to_body(
24364 request_value_reader.get_ref().clone().into(),
24365 ));
24366
24367 client.request(request.unwrap()).await
24368 };
24369
24370 match req_result {
24371 Err(err) => {
24372 if let common::Retry::After(d) = dlg.http_error(&err) {
24373 sleep(d).await;
24374 continue;
24375 }
24376 dlg.finished(false);
24377 return Err(common::Error::HttpError(err));
24378 }
24379 Ok(res) => {
24380 let (mut parts, body) = res.into_parts();
24381 let mut body = common::Body::new(body);
24382 if !parts.status.is_success() {
24383 let bytes = common::to_bytes(body).await.unwrap_or_default();
24384 let error = serde_json::from_str(&common::to_string(&bytes));
24385 let response = common::to_response(parts, bytes.into());
24386
24387 if let common::Retry::After(d) =
24388 dlg.http_failure(&response, error.as_ref().ok())
24389 {
24390 sleep(d).await;
24391 continue;
24392 }
24393
24394 dlg.finished(false);
24395
24396 return Err(match error {
24397 Ok(value) => common::Error::BadRequest(value),
24398 _ => common::Error::Failure(response),
24399 });
24400 }
24401 let response = {
24402 let bytes = common::to_bytes(body).await.unwrap_or_default();
24403 let encoded = common::to_string(&bytes);
24404 match serde_json::from_str(&encoded) {
24405 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24406 Err(error) => {
24407 dlg.response_json_decode_error(&encoded, &error);
24408 return Err(common::Error::JsonDecodeError(
24409 encoded.to_string(),
24410 error,
24411 ));
24412 }
24413 }
24414 };
24415
24416 dlg.finished(true);
24417 return Ok(response);
24418 }
24419 }
24420 }
24421 }
24422
24423 ///
24424 /// Sets the *request* property to the given value.
24425 ///
24426 /// Even though the property as already been set when instantiating this call,
24427 /// we provide this method for API completeness.
24428 pub fn request(mut self, new_value: RepoSource) -> ProjectTriggerRunCall<'a, C> {
24429 self._request = new_value;
24430 self
24431 }
24432 /// Required. ID of the project.
24433 ///
24434 /// Sets the *project id* path property to the given value.
24435 ///
24436 /// Even though the property as already been set when instantiating this call,
24437 /// we provide this method for API completeness.
24438 pub fn project_id(mut self, new_value: &str) -> ProjectTriggerRunCall<'a, C> {
24439 self._project_id = new_value.to_string();
24440 self
24441 }
24442 /// Required. ID of the trigger.
24443 ///
24444 /// Sets the *trigger id* path property to the given value.
24445 ///
24446 /// Even though the property as already been set when instantiating this call,
24447 /// we provide this method for API completeness.
24448 pub fn trigger_id(mut self, new_value: &str) -> ProjectTriggerRunCall<'a, C> {
24449 self._trigger_id = new_value.to_string();
24450 self
24451 }
24452 /// The name of the `Trigger` to run. Format: `projects/{project}/locations/{location}/triggers/{trigger}`
24453 ///
24454 /// Sets the *name* query property to the given value.
24455 pub fn name(mut self, new_value: &str) -> ProjectTriggerRunCall<'a, C> {
24456 self._name = Some(new_value.to_string());
24457 self
24458 }
24459 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24460 /// while executing the actual API request.
24461 ///
24462 /// ````text
24463 /// It should be used to handle progress information, and to implement a certain level of resilience.
24464 /// ````
24465 ///
24466 /// Sets the *delegate* property to the given value.
24467 pub fn delegate(
24468 mut self,
24469 new_value: &'a mut dyn common::Delegate,
24470 ) -> ProjectTriggerRunCall<'a, C> {
24471 self._delegate = Some(new_value);
24472 self
24473 }
24474
24475 /// Set any additional parameter of the query string used in the request.
24476 /// It should be used to set parameters which are not yet available through their own
24477 /// setters.
24478 ///
24479 /// Please note that this method must not be used to set any of the known parameters
24480 /// which have their own setter method. If done anyway, the request will fail.
24481 ///
24482 /// # Additional Parameters
24483 ///
24484 /// * *$.xgafv* (query-string) - V1 error format.
24485 /// * *access_token* (query-string) - OAuth access token.
24486 /// * *alt* (query-string) - Data format for response.
24487 /// * *callback* (query-string) - JSONP
24488 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24489 /// * *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.
24490 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24491 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24492 /// * *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.
24493 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
24494 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
24495 pub fn param<T>(mut self, name: T, value: T) -> ProjectTriggerRunCall<'a, C>
24496 where
24497 T: AsRef<str>,
24498 {
24499 self._additional_params
24500 .insert(name.as_ref().to_string(), value.as_ref().to_string());
24501 self
24502 }
24503
24504 /// Identifies the authorization scope for the method you are building.
24505 ///
24506 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24507 /// [`Scope::CloudPlatform`].
24508 ///
24509 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24510 /// tokens for more than one scope.
24511 ///
24512 /// Usually there is more than one suitable scope to authorize an operation, some of which may
24513 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24514 /// sufficient, a read-write scope will do as well.
24515 pub fn add_scope<St>(mut self, scope: St) -> ProjectTriggerRunCall<'a, C>
24516 where
24517 St: AsRef<str>,
24518 {
24519 self._scopes.insert(String::from(scope.as_ref()));
24520 self
24521 }
24522 /// Identifies the authorization scope(s) for the method you are building.
24523 ///
24524 /// See [`Self::add_scope()`] for details.
24525 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectTriggerRunCall<'a, C>
24526 where
24527 I: IntoIterator<Item = St>,
24528 St: AsRef<str>,
24529 {
24530 self._scopes
24531 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24532 self
24533 }
24534
24535 /// Removes all scopes, and no default scope will be used either.
24536 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24537 /// for details).
24538 pub fn clear_scopes(mut self) -> ProjectTriggerRunCall<'a, C> {
24539 self._scopes.clear();
24540 self
24541 }
24542}
24543
24544/// ReceiveTriggerWebhook [Experimental] is called when the API receives a webhook request targeted at a specific trigger.
24545///
24546/// A builder for the *triggers.webhook* method supported by a *project* resource.
24547/// It is not used directly, but through a [`ProjectMethods`] instance.
24548///
24549/// # Example
24550///
24551/// Instantiate a resource method builder
24552///
24553/// ```test_harness,no_run
24554/// # extern crate hyper;
24555/// # extern crate hyper_rustls;
24556/// # extern crate google_cloudbuild1 as cloudbuild1;
24557/// use cloudbuild1::api::HttpBody;
24558/// # async fn dox() {
24559/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24560///
24561/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
24562/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
24563/// # secret,
24564/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24565/// # ).build().await.unwrap();
24566///
24567/// # let client = hyper_util::client::legacy::Client::builder(
24568/// # hyper_util::rt::TokioExecutor::new()
24569/// # )
24570/// # .build(
24571/// # hyper_rustls::HttpsConnectorBuilder::new()
24572/// # .with_native_roots()
24573/// # .unwrap()
24574/// # .https_or_http()
24575/// # .enable_http1()
24576/// # .build()
24577/// # );
24578/// # let mut hub = CloudBuild::new(client, auth);
24579/// // As the method needs a request, you would usually fill it with the desired information
24580/// // into the respective structure. Some of the parts shown here might not be applicable !
24581/// // Values shown here are possibly random and not representative !
24582/// let mut req = HttpBody::default();
24583///
24584/// // You can configure optional parameters by calling the respective setters at will, and
24585/// // execute the final call using `doit()`.
24586/// // Values shown here are possibly random and not representative !
24587/// let result = hub.projects().triggers_webhook(req, "projectId", "trigger")
24588/// .secret("ea")
24589/// .name("Stet")
24590/// .doit().await;
24591/// # }
24592/// ```
24593pub struct ProjectTriggerWebhookCall<'a, C>
24594where
24595 C: 'a,
24596{
24597 hub: &'a CloudBuild<C>,
24598 _request: HttpBody,
24599 _project_id: String,
24600 _trigger: String,
24601 _secret: Option<String>,
24602 _name: Option<String>,
24603 _delegate: Option<&'a mut dyn common::Delegate>,
24604 _additional_params: HashMap<String, String>,
24605}
24606
24607impl<'a, C> common::CallBuilder for ProjectTriggerWebhookCall<'a, C> {}
24608
24609impl<'a, C> ProjectTriggerWebhookCall<'a, C>
24610where
24611 C: common::Connector,
24612{
24613 /// Perform the operation you have build so far.
24614 pub async fn doit(
24615 mut self,
24616 ) -> common::Result<(common::Response, ReceiveTriggerWebhookResponse)> {
24617 use std::borrow::Cow;
24618 use std::io::{Read, Seek};
24619
24620 use common::{url::Params, ToParts};
24621 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24622
24623 let mut dd = common::DefaultDelegate;
24624 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24625 dlg.begin(common::MethodInfo {
24626 id: "cloudbuild.projects.triggers.webhook",
24627 http_method: hyper::Method::POST,
24628 });
24629
24630 for &field in ["alt", "projectId", "trigger", "secret", "name"].iter() {
24631 if self._additional_params.contains_key(field) {
24632 dlg.finished(false);
24633 return Err(common::Error::FieldClash(field));
24634 }
24635 }
24636
24637 let mut params = Params::with_capacity(7 + self._additional_params.len());
24638 params.push("projectId", self._project_id);
24639 params.push("trigger", self._trigger);
24640 if let Some(value) = self._secret.as_ref() {
24641 params.push("secret", value);
24642 }
24643 if let Some(value) = self._name.as_ref() {
24644 params.push("name", value);
24645 }
24646
24647 params.extend(self._additional_params.iter());
24648
24649 params.push("alt", "json");
24650 let mut url =
24651 self.hub._base_url.clone() + "v1/projects/{projectId}/triggers/{trigger}:webhook";
24652
24653 match dlg.api_key() {
24654 Some(value) => params.push("key", value),
24655 None => {
24656 dlg.finished(false);
24657 return Err(common::Error::MissingAPIKey);
24658 }
24659 }
24660
24661 #[allow(clippy::single_element_loop)]
24662 for &(find_this, param_name) in
24663 [("{projectId}", "projectId"), ("{trigger}", "trigger")].iter()
24664 {
24665 url = params.uri_replacement(url, param_name, find_this, false);
24666 }
24667 {
24668 let to_remove = ["trigger", "projectId"];
24669 params.remove_params(&to_remove);
24670 }
24671
24672 let url = params.parse_with_url(&url);
24673
24674 let mut json_mime_type = mime::APPLICATION_JSON;
24675 let mut request_value_reader = {
24676 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
24677 common::remove_json_null_values(&mut value);
24678 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
24679 serde_json::to_writer(&mut dst, &value).unwrap();
24680 dst
24681 };
24682 let request_size = request_value_reader
24683 .seek(std::io::SeekFrom::End(0))
24684 .unwrap();
24685 request_value_reader
24686 .seek(std::io::SeekFrom::Start(0))
24687 .unwrap();
24688
24689 loop {
24690 request_value_reader
24691 .seek(std::io::SeekFrom::Start(0))
24692 .unwrap();
24693 let mut req_result = {
24694 let client = &self.hub.client;
24695 dlg.pre_request();
24696 let mut req_builder = hyper::Request::builder()
24697 .method(hyper::Method::POST)
24698 .uri(url.as_str())
24699 .header(USER_AGENT, self.hub._user_agent.clone());
24700
24701 let request = req_builder
24702 .header(CONTENT_TYPE, json_mime_type.to_string())
24703 .header(CONTENT_LENGTH, request_size as u64)
24704 .body(common::to_body(
24705 request_value_reader.get_ref().clone().into(),
24706 ));
24707
24708 client.request(request.unwrap()).await
24709 };
24710
24711 match req_result {
24712 Err(err) => {
24713 if let common::Retry::After(d) = dlg.http_error(&err) {
24714 sleep(d).await;
24715 continue;
24716 }
24717 dlg.finished(false);
24718 return Err(common::Error::HttpError(err));
24719 }
24720 Ok(res) => {
24721 let (mut parts, body) = res.into_parts();
24722 let mut body = common::Body::new(body);
24723 if !parts.status.is_success() {
24724 let bytes = common::to_bytes(body).await.unwrap_or_default();
24725 let error = serde_json::from_str(&common::to_string(&bytes));
24726 let response = common::to_response(parts, bytes.into());
24727
24728 if let common::Retry::After(d) =
24729 dlg.http_failure(&response, error.as_ref().ok())
24730 {
24731 sleep(d).await;
24732 continue;
24733 }
24734
24735 dlg.finished(false);
24736
24737 return Err(match error {
24738 Ok(value) => common::Error::BadRequest(value),
24739 _ => common::Error::Failure(response),
24740 });
24741 }
24742 let response = {
24743 let bytes = common::to_bytes(body).await.unwrap_or_default();
24744 let encoded = common::to_string(&bytes);
24745 match serde_json::from_str(&encoded) {
24746 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24747 Err(error) => {
24748 dlg.response_json_decode_error(&encoded, &error);
24749 return Err(common::Error::JsonDecodeError(
24750 encoded.to_string(),
24751 error,
24752 ));
24753 }
24754 }
24755 };
24756
24757 dlg.finished(true);
24758 return Ok(response);
24759 }
24760 }
24761 }
24762 }
24763
24764 ///
24765 /// Sets the *request* property to the given value.
24766 ///
24767 /// Even though the property as already been set when instantiating this call,
24768 /// we provide this method for API completeness.
24769 pub fn request(mut self, new_value: HttpBody) -> ProjectTriggerWebhookCall<'a, C> {
24770 self._request = new_value;
24771 self
24772 }
24773 /// Project in which the specified trigger lives
24774 ///
24775 /// Sets the *project id* path property to the given value.
24776 ///
24777 /// Even though the property as already been set when instantiating this call,
24778 /// we provide this method for API completeness.
24779 pub fn project_id(mut self, new_value: &str) -> ProjectTriggerWebhookCall<'a, C> {
24780 self._project_id = new_value.to_string();
24781 self
24782 }
24783 /// Name of the trigger to run the payload against
24784 ///
24785 /// Sets the *trigger* path property to the given value.
24786 ///
24787 /// Even though the property as already been set when instantiating this call,
24788 /// we provide this method for API completeness.
24789 pub fn trigger(mut self, new_value: &str) -> ProjectTriggerWebhookCall<'a, C> {
24790 self._trigger = new_value.to_string();
24791 self
24792 }
24793 /// Secret token used for authorization if an OAuth token isn't provided.
24794 ///
24795 /// Sets the *secret* query property to the given value.
24796 pub fn secret(mut self, new_value: &str) -> ProjectTriggerWebhookCall<'a, C> {
24797 self._secret = Some(new_value.to_string());
24798 self
24799 }
24800 /// The name of the `ReceiveTriggerWebhook` to retrieve. Format: `projects/{project}/locations/{location}/triggers/{trigger}`
24801 ///
24802 /// Sets the *name* query property to the given value.
24803 pub fn name(mut self, new_value: &str) -> ProjectTriggerWebhookCall<'a, C> {
24804 self._name = Some(new_value.to_string());
24805 self
24806 }
24807 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24808 /// while executing the actual API request.
24809 ///
24810 /// ````text
24811 /// It should be used to handle progress information, and to implement a certain level of resilience.
24812 /// ````
24813 ///
24814 /// Sets the *delegate* property to the given value.
24815 pub fn delegate(
24816 mut self,
24817 new_value: &'a mut dyn common::Delegate,
24818 ) -> ProjectTriggerWebhookCall<'a, C> {
24819 self._delegate = Some(new_value);
24820 self
24821 }
24822
24823 /// Set any additional parameter of the query string used in the request.
24824 /// It should be used to set parameters which are not yet available through their own
24825 /// setters.
24826 ///
24827 /// Please note that this method must not be used to set any of the known parameters
24828 /// which have their own setter method. If done anyway, the request will fail.
24829 ///
24830 /// # Additional Parameters
24831 ///
24832 /// * *$.xgafv* (query-string) - V1 error format.
24833 /// * *access_token* (query-string) - OAuth access token.
24834 /// * *alt* (query-string) - Data format for response.
24835 /// * *callback* (query-string) - JSONP
24836 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24837 /// * *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.
24838 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24839 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24840 /// * *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.
24841 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
24842 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
24843 pub fn param<T>(mut self, name: T, value: T) -> ProjectTriggerWebhookCall<'a, C>
24844 where
24845 T: AsRef<str>,
24846 {
24847 self._additional_params
24848 .insert(name.as_ref().to_string(), value.as_ref().to_string());
24849 self
24850 }
24851}
24852
24853/// ReceiveWebhook is called when the API receives a GitHub webhook.
24854///
24855/// A builder for the *webhook* method.
24856/// It is not used directly, but through a [`MethodMethods`] instance.
24857///
24858/// # Example
24859///
24860/// Instantiate a resource method builder
24861///
24862/// ```test_harness,no_run
24863/// # extern crate hyper;
24864/// # extern crate hyper_rustls;
24865/// # extern crate google_cloudbuild1 as cloudbuild1;
24866/// use cloudbuild1::api::HttpBody;
24867/// # async fn dox() {
24868/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24869///
24870/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
24871/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
24872/// # secret,
24873/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24874/// # ).build().await.unwrap();
24875///
24876/// # let client = hyper_util::client::legacy::Client::builder(
24877/// # hyper_util::rt::TokioExecutor::new()
24878/// # )
24879/// # .build(
24880/// # hyper_rustls::HttpsConnectorBuilder::new()
24881/// # .with_native_roots()
24882/// # .unwrap()
24883/// # .https_or_http()
24884/// # .enable_http1()
24885/// # .build()
24886/// # );
24887/// # let mut hub = CloudBuild::new(client, auth);
24888/// // As the method needs a request, you would usually fill it with the desired information
24889/// // into the respective structure. Some of the parts shown here might not be applicable !
24890/// // Values shown here are possibly random and not representative !
24891/// let mut req = HttpBody::default();
24892///
24893/// // You can configure optional parameters by calling the respective setters at will, and
24894/// // execute the final call using `doit()`.
24895/// // Values shown here are possibly random and not representative !
24896/// let result = hub.methods().webhook(req)
24897/// .webhook_key("dolores")
24898/// .doit().await;
24899/// # }
24900/// ```
24901pub struct MethodWebhookCall<'a, C>
24902where
24903 C: 'a,
24904{
24905 hub: &'a CloudBuild<C>,
24906 _request: HttpBody,
24907 _webhook_key: Option<String>,
24908 _delegate: Option<&'a mut dyn common::Delegate>,
24909 _additional_params: HashMap<String, String>,
24910}
24911
24912impl<'a, C> common::CallBuilder for MethodWebhookCall<'a, C> {}
24913
24914impl<'a, C> MethodWebhookCall<'a, C>
24915where
24916 C: common::Connector,
24917{
24918 /// Perform the operation you have build so far.
24919 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
24920 use std::borrow::Cow;
24921 use std::io::{Read, Seek};
24922
24923 use common::{url::Params, ToParts};
24924 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24925
24926 let mut dd = common::DefaultDelegate;
24927 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24928 dlg.begin(common::MethodInfo {
24929 id: "cloudbuild.webhook",
24930 http_method: hyper::Method::POST,
24931 });
24932
24933 for &field in ["alt", "webhookKey"].iter() {
24934 if self._additional_params.contains_key(field) {
24935 dlg.finished(false);
24936 return Err(common::Error::FieldClash(field));
24937 }
24938 }
24939
24940 let mut params = Params::with_capacity(4 + self._additional_params.len());
24941 if let Some(value) = self._webhook_key.as_ref() {
24942 params.push("webhookKey", value);
24943 }
24944
24945 params.extend(self._additional_params.iter());
24946
24947 params.push("alt", "json");
24948 let mut url = self.hub._base_url.clone() + "v1/webhook";
24949
24950 match dlg.api_key() {
24951 Some(value) => params.push("key", value),
24952 None => {
24953 dlg.finished(false);
24954 return Err(common::Error::MissingAPIKey);
24955 }
24956 }
24957
24958 let url = params.parse_with_url(&url);
24959
24960 let mut json_mime_type = mime::APPLICATION_JSON;
24961 let mut request_value_reader = {
24962 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
24963 common::remove_json_null_values(&mut value);
24964 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
24965 serde_json::to_writer(&mut dst, &value).unwrap();
24966 dst
24967 };
24968 let request_size = request_value_reader
24969 .seek(std::io::SeekFrom::End(0))
24970 .unwrap();
24971 request_value_reader
24972 .seek(std::io::SeekFrom::Start(0))
24973 .unwrap();
24974
24975 loop {
24976 request_value_reader
24977 .seek(std::io::SeekFrom::Start(0))
24978 .unwrap();
24979 let mut req_result = {
24980 let client = &self.hub.client;
24981 dlg.pre_request();
24982 let mut req_builder = hyper::Request::builder()
24983 .method(hyper::Method::POST)
24984 .uri(url.as_str())
24985 .header(USER_AGENT, self.hub._user_agent.clone());
24986
24987 let request = req_builder
24988 .header(CONTENT_TYPE, json_mime_type.to_string())
24989 .header(CONTENT_LENGTH, request_size as u64)
24990 .body(common::to_body(
24991 request_value_reader.get_ref().clone().into(),
24992 ));
24993
24994 client.request(request.unwrap()).await
24995 };
24996
24997 match req_result {
24998 Err(err) => {
24999 if let common::Retry::After(d) = dlg.http_error(&err) {
25000 sleep(d).await;
25001 continue;
25002 }
25003 dlg.finished(false);
25004 return Err(common::Error::HttpError(err));
25005 }
25006 Ok(res) => {
25007 let (mut parts, body) = res.into_parts();
25008 let mut body = common::Body::new(body);
25009 if !parts.status.is_success() {
25010 let bytes = common::to_bytes(body).await.unwrap_or_default();
25011 let error = serde_json::from_str(&common::to_string(&bytes));
25012 let response = common::to_response(parts, bytes.into());
25013
25014 if let common::Retry::After(d) =
25015 dlg.http_failure(&response, error.as_ref().ok())
25016 {
25017 sleep(d).await;
25018 continue;
25019 }
25020
25021 dlg.finished(false);
25022
25023 return Err(match error {
25024 Ok(value) => common::Error::BadRequest(value),
25025 _ => common::Error::Failure(response),
25026 });
25027 }
25028 let response = {
25029 let bytes = common::to_bytes(body).await.unwrap_or_default();
25030 let encoded = common::to_string(&bytes);
25031 match serde_json::from_str(&encoded) {
25032 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
25033 Err(error) => {
25034 dlg.response_json_decode_error(&encoded, &error);
25035 return Err(common::Error::JsonDecodeError(
25036 encoded.to_string(),
25037 error,
25038 ));
25039 }
25040 }
25041 };
25042
25043 dlg.finished(true);
25044 return Ok(response);
25045 }
25046 }
25047 }
25048 }
25049
25050 ///
25051 /// Sets the *request* property to the given value.
25052 ///
25053 /// Even though the property as already been set when instantiating this call,
25054 /// we provide this method for API completeness.
25055 pub fn request(mut self, new_value: HttpBody) -> MethodWebhookCall<'a, C> {
25056 self._request = new_value;
25057 self
25058 }
25059 /// For GitHub Enterprise webhooks, this key is used to associate the webhook request with the GitHubEnterpriseConfig to use for validation.
25060 ///
25061 /// Sets the *webhook key* query property to the given value.
25062 pub fn webhook_key(mut self, new_value: &str) -> MethodWebhookCall<'a, C> {
25063 self._webhook_key = Some(new_value.to_string());
25064 self
25065 }
25066 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25067 /// while executing the actual API request.
25068 ///
25069 /// ````text
25070 /// It should be used to handle progress information, and to implement a certain level of resilience.
25071 /// ````
25072 ///
25073 /// Sets the *delegate* property to the given value.
25074 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> MethodWebhookCall<'a, C> {
25075 self._delegate = Some(new_value);
25076 self
25077 }
25078
25079 /// Set any additional parameter of the query string used in the request.
25080 /// It should be used to set parameters which are not yet available through their own
25081 /// setters.
25082 ///
25083 /// Please note that this method must not be used to set any of the known parameters
25084 /// which have their own setter method. If done anyway, the request will fail.
25085 ///
25086 /// # Additional Parameters
25087 ///
25088 /// * *$.xgafv* (query-string) - V1 error format.
25089 /// * *access_token* (query-string) - OAuth access token.
25090 /// * *alt* (query-string) - Data format for response.
25091 /// * *callback* (query-string) - JSONP
25092 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25093 /// * *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.
25094 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25095 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25096 /// * *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.
25097 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
25098 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
25099 pub fn param<T>(mut self, name: T, value: T) -> MethodWebhookCall<'a, C>
25100 where
25101 T: AsRef<str>,
25102 {
25103 self._additional_params
25104 .insert(name.as_ref().to_string(), value.as_ref().to_string());
25105 self
25106 }
25107}