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 connector = hyper_rustls::HttpsConnectorBuilder::new()
63/// .with_native_roots()
64/// .unwrap()
65/// .https_only()
66/// .enable_http2()
67/// .build();
68///
69/// let executor = hyper_util::rt::TokioExecutor::new();
70/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
71/// secret,
72/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
73/// yup_oauth2::client::CustomHyperClientBuilder::from(
74/// hyper_util::client::legacy::Client::builder(executor).build(connector),
75/// ),
76/// ).build().await.unwrap();
77///
78/// let client = hyper_util::client::legacy::Client::builder(
79/// hyper_util::rt::TokioExecutor::new()
80/// )
81/// .build(
82/// hyper_rustls::HttpsConnectorBuilder::new()
83/// .with_native_roots()
84/// .unwrap()
85/// .https_or_http()
86/// .enable_http2()
87/// .build()
88/// );
89/// let mut hub = CloudBuild::new(client, auth);
90/// // As the method needs a request, you would usually fill it with the desired information
91/// // into the respective structure. Some of the parts shown here might not be applicable !
92/// // Values shown here are possibly random and not representative !
93/// let mut req = GitHubEnterpriseConfig::default();
94///
95/// // You can configure optional parameters by calling the respective setters at will, and
96/// // execute the final call using `doit()`.
97/// // Values shown here are possibly random and not representative !
98/// let result = hub.projects().github_enterprise_configs_create(req, "parent")
99/// .project_id("sed")
100/// .ghe_config_id("amet.")
101/// .doit().await;
102///
103/// match result {
104/// Err(e) => match e {
105/// // The Error enum provides details about what exactly happened.
106/// // You can also just use its `Debug`, `Display` or `Error` traits
107/// Error::HttpError(_)
108/// |Error::Io(_)
109/// |Error::MissingAPIKey
110/// |Error::MissingToken(_)
111/// |Error::Cancelled
112/// |Error::UploadSizeLimitExceeded(_, _)
113/// |Error::Failure(_)
114/// |Error::BadRequest(_)
115/// |Error::FieldClash(_)
116/// |Error::JsonDecodeError(_, _) => println!("{}", e),
117/// },
118/// Ok(res) => println!("Success: {:?}", res),
119/// }
120/// # }
121/// ```
122#[derive(Clone)]
123pub struct CloudBuild<C> {
124 pub client: common::Client<C>,
125 pub auth: Box<dyn common::GetToken>,
126 _user_agent: String,
127 _base_url: String,
128 _root_url: String,
129}
130
131impl<C> common::Hub for CloudBuild<C> {}
132
133impl<'a, C> CloudBuild<C> {
134 pub fn new<A: 'static + common::GetToken>(client: common::Client<C>, auth: A) -> CloudBuild<C> {
135 CloudBuild {
136 client,
137 auth: Box::new(auth),
138 _user_agent: "google-api-rust-client/7.0.0".to_string(),
139 _base_url: "https://cloudbuild.googleapis.com/".to_string(),
140 _root_url: "https://cloudbuild.googleapis.com/".to_string(),
141 }
142 }
143
144 pub fn github_dot_com_webhook(&'a self) -> GithubDotComWebhookMethods<'a, C> {
145 GithubDotComWebhookMethods { hub: self }
146 }
147 pub fn locations(&'a self) -> LocationMethods<'a, C> {
148 LocationMethods { hub: self }
149 }
150 pub fn methods(&'a self) -> MethodMethods<'a, C> {
151 MethodMethods { hub: self }
152 }
153 pub fn operations(&'a self) -> OperationMethods<'a, C> {
154 OperationMethods { hub: self }
155 }
156 pub fn projects(&'a self) -> ProjectMethods<'a, C> {
157 ProjectMethods { hub: self }
158 }
159
160 /// Set the user-agent header field to use in all requests to the server.
161 /// It defaults to `google-api-rust-client/7.0.0`.
162 ///
163 /// Returns the previously set user-agent.
164 pub fn user_agent(&mut self, agent_name: String) -> String {
165 std::mem::replace(&mut self._user_agent, agent_name)
166 }
167
168 /// Set the base url to use in all requests to the server.
169 /// It defaults to `https://cloudbuild.googleapis.com/`.
170 ///
171 /// Returns the previously set base url.
172 pub fn base_url(&mut self, new_base_url: String) -> String {
173 std::mem::replace(&mut self._base_url, new_base_url)
174 }
175
176 /// Set the root url to use in all requests to the server.
177 /// It defaults to `https://cloudbuild.googleapis.com/`.
178 ///
179 /// Returns the previously set root url.
180 pub fn root_url(&mut self, new_root_url: String) -> String {
181 std::mem::replace(&mut self._root_url, new_root_url)
182 }
183}
184
185// ############
186// SCHEMAS ###
187// ##########
188/// ApprovalConfig describes configuration for manual approval of a build.
189///
190/// This type is not used in any activity, and only used as *part* of another schema.
191///
192#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
193#[serde_with::serde_as]
194#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
195pub struct ApprovalConfig {
196 /// 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.
197 #[serde(rename = "approvalRequired")]
198 pub approval_required: Option<bool>,
199}
200
201impl common::Part for ApprovalConfig {}
202
203/// ApprovalResult describes the decision and associated metadata of a manual approval of a build.
204///
205/// This type is not used in any activity, and only used as *part* of another schema.
206///
207#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
208#[serde_with::serde_as]
209#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
210pub struct ApprovalResult {
211 /// Output only. The time when the approval decision was made.
212 #[serde(rename = "approvalTime")]
213 pub approval_time: Option<chrono::DateTime<chrono::offset::Utc>>,
214 /// 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.
215 #[serde(rename = "approverAccount")]
216 pub approver_account: Option<String>,
217 /// Optional. An optional comment for this manual approval result.
218 pub comment: Option<String>,
219 /// Required. The decision of this manual approval.
220 pub decision: Option<String>,
221 /// 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.
222 pub url: Option<String>,
223}
224
225impl common::Part for ApprovalResult {}
226
227/// Request to approve or reject a pending build.
228///
229/// # Activities
230///
231/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
232/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
233///
234/// * [builds approve projects](ProjectBuildApproveCall) (request)
235/// * [locations builds approve projects](ProjectLocationBuildApproveCall) (request)
236#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
237#[serde_with::serde_as]
238#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
239pub struct ApproveBuildRequest {
240 /// Approval decision and metadata.
241 #[serde(rename = "approvalResult")]
242 pub approval_result: Option<ApprovalResult>,
243}
244
245impl common::RequestValue for ApproveBuildRequest {}
246
247/// Files in the workspace to upload to Cloud Storage upon successful completion of all build steps.
248///
249/// This type is not used in any activity, and only used as *part* of another schema.
250///
251#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
252#[serde_with::serde_as]
253#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
254pub struct ArtifactObjects {
255 /// 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.
256 pub location: Option<String>,
257 /// Path globs used to match files in the build's workspace.
258 pub paths: Option<Vec<String>>,
259 /// Output only. Stores timing information for pushing all artifact objects.
260 pub timing: Option<TimeSpan>,
261}
262
263impl common::Part for ArtifactObjects {}
264
265/// Artifacts produced by a build that should be uploaded upon successful completion of all build steps.
266///
267/// This type is not used in any activity, and only used as *part* of another schema.
268///
269#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
270#[serde_with::serde_as]
271#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
272pub struct Artifacts {
273 /// Optional. A list of Go modules to be uploaded to Artifact Registry upon successful completion of all build steps. If any objects fail to be pushed, the build is marked FAILURE.
274 #[serde(rename = "goModules")]
275 pub go_modules: Option<Vec<GoModule>>,
276 /// 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.
277 pub images: Option<Vec<String>>,
278 /// 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.
279 #[serde(rename = "mavenArtifacts")]
280 pub maven_artifacts: Option<Vec<MavenArtifact>>,
281 /// 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.
282 #[serde(rename = "npmPackages")]
283 pub npm_packages: Option<Vec<NpmPackage>>,
284 /// 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.
285 pub objects: Option<ArtifactObjects>,
286 /// 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.
287 #[serde(rename = "pythonPackages")]
288 pub python_packages: Option<Vec<PythonPackage>>,
289}
290
291impl common::Part for Artifacts {}
292
293/// RPC request object accepted by BatchCreateBitbucketServerConnectedRepositories RPC method.
294///
295/// # Activities
296///
297/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
298/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
299///
300/// * [locations bitbucket server configs connected repositories batch create projects](ProjectLocationBitbucketServerConfigConnectedRepositoryBatchCreateCall) (request)
301#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
302#[serde_with::serde_as]
303#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
304pub struct BatchCreateBitbucketServerConnectedRepositoriesRequest {
305 /// Required. Requests to connect Bitbucket Server repositories.
306 pub requests: Option<Vec<CreateBitbucketServerConnectedRepositoryRequest>>,
307}
308
309impl common::RequestValue for BatchCreateBitbucketServerConnectedRepositoriesRequest {}
310
311/// RPC request object accepted by BatchCreateGitLabConnectedRepositories RPC method.
312///
313/// # Activities
314///
315/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
316/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
317///
318/// * [locations git lab configs connected repositories batch create projects](ProjectLocationGitLabConfigConnectedRepositoryBatchCreateCall) (request)
319#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
320#[serde_with::serde_as]
321#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
322pub struct BatchCreateGitLabConnectedRepositoriesRequest {
323 /// Required. Requests to connect GitLab repositories.
324 pub requests: Option<Vec<CreateGitLabConnectedRepositoryRequest>>,
325}
326
327impl common::RequestValue for BatchCreateGitLabConnectedRepositoriesRequest {}
328
329/// BitbucketServerConfig represents the configuration for a Bitbucket Server.
330///
331/// # Activities
332///
333/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
334/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
335///
336/// * [locations bitbucket server configs create projects](ProjectLocationBitbucketServerConfigCreateCall) (request)
337/// * [locations bitbucket server configs get projects](ProjectLocationBitbucketServerConfigGetCall) (response)
338/// * [locations bitbucket server configs patch projects](ProjectLocationBitbucketServerConfigPatchCall) (request)
339#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
340#[serde_with::serde_as]
341#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
342pub struct BitbucketServerConfig {
343 /// 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.
344 #[serde(rename = "apiKey")]
345 pub api_key: Option<String>,
346 /// Output only. Connected Bitbucket Server repositories for this config.
347 #[serde(rename = "connectedRepositories")]
348 pub connected_repositories: Option<Vec<BitbucketServerRepositoryId>>,
349 /// Time when the config was created.
350 #[serde(rename = "createTime")]
351 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
352 /// 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.
353 #[serde(rename = "hostUri")]
354 pub host_uri: Option<String>,
355 /// The resource name for the config.
356 pub name: Option<String>,
357 /// 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.
358 #[serde(rename = "peeredNetwork")]
359 pub peered_network: Option<String>,
360 /// 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.
361 #[serde(rename = "peeredNetworkIpRange")]
362 pub peered_network_ip_range: Option<String>,
363 /// Required. Secret Manager secrets needed by the config.
364 pub secrets: Option<BitbucketServerSecrets>,
365 /// 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.
366 #[serde(rename = "sslCa")]
367 pub ssl_ca: Option<String>,
368 /// Username of the account Cloud Build will use on Bitbucket Server.
369 pub username: Option<String>,
370 /// Output only. UUID included in webhook requests. The UUID is used to look up the corresponding config.
371 #[serde(rename = "webhookKey")]
372 pub webhook_key: Option<String>,
373}
374
375impl common::RequestValue for BitbucketServerConfig {}
376impl common::ResponseResult for BitbucketServerConfig {}
377
378/// / BitbucketServerConnectedRepository represents a connected Bitbucket Server / repository.
379///
380/// This type is not used in any activity, and only used as *part* of another schema.
381///
382#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
383#[serde_with::serde_as]
384#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
385pub struct BitbucketServerConnectedRepository {
386 /// The name of the `BitbucketServerConfig` that added connected repository. Format: `projects/{project}/locations/{location}/bitbucketServerConfigs/{config}`
387 pub parent: Option<String>,
388 /// The Bitbucket Server repositories to connect.
389 pub repo: Option<BitbucketServerRepositoryId>,
390 /// Output only. The status of the repo connection request.
391 pub status: Option<Status>,
392}
393
394impl common::Part for BitbucketServerConnectedRepository {}
395
396/// BitbucketServerRepository represents a repository hosted on a Bitbucket Server.
397///
398/// This type is not used in any activity, and only used as *part* of another schema.
399///
400#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
401#[serde_with::serde_as]
402#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
403pub struct BitbucketServerRepository {
404 /// Link to the browse repo page on the Bitbucket Server instance.
405 #[serde(rename = "browseUri")]
406 pub browse_uri: Option<String>,
407 /// Description of the repository.
408 pub description: Option<String>,
409 /// Display name of the repository.
410 #[serde(rename = "displayName")]
411 pub display_name: Option<String>,
412 /// The resource name of the repository.
413 pub name: Option<String>,
414 /// Identifier for a repository hosted on a Bitbucket Server.
415 #[serde(rename = "repoId")]
416 pub repo_id: Option<BitbucketServerRepositoryId>,
417}
418
419impl common::Part for BitbucketServerRepository {}
420
421/// BitbucketServerRepositoryId identifies a specific repository hosted on a Bitbucket Server.
422///
423/// This type is not used in any activity, and only used as *part* of another schema.
424///
425#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
426#[serde_with::serde_as]
427#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
428pub struct BitbucketServerRepositoryId {
429 /// Required. Identifier for the project storing the repository.
430 #[serde(rename = "projectKey")]
431 pub project_key: Option<String>,
432 /// Required. Identifier for the repository.
433 #[serde(rename = "repoSlug")]
434 pub repo_slug: Option<String>,
435 /// 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.
436 #[serde(rename = "webhookId")]
437 pub webhook_id: Option<i32>,
438}
439
440impl common::Part for BitbucketServerRepositoryId {}
441
442/// BitbucketServerSecrets represents the secrets in Secret Manager for a Bitbucket Server.
443///
444/// This type is not used in any activity, and only used as *part* of another schema.
445///
446#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
447#[serde_with::serde_as]
448#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
449pub struct BitbucketServerSecrets {
450 /// Required. The resource name for the admin access token's secret version.
451 #[serde(rename = "adminAccessTokenVersionName")]
452 pub admin_access_token_version_name: Option<String>,
453 /// Required. The resource name for the read access token's secret version.
454 #[serde(rename = "readAccessTokenVersionName")]
455 pub read_access_token_version_name: Option<String>,
456 /// 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.
457 #[serde(rename = "webhookSecretVersionName")]
458 pub webhook_secret_version_name: Option<String>,
459}
460
461impl common::Part for BitbucketServerSecrets {}
462
463/// BitbucketServerTriggerConfig describes the configuration of a trigger that creates a build whenever a Bitbucket Server event is received.
464///
465/// This type is not used in any activity, and only used as *part* of another schema.
466///
467#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
468#[serde_with::serde_as]
469#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
470pub struct BitbucketServerTriggerConfig {
471 /// Output only. The BitbucketServerConfig specified in the bitbucket_server_config_resource field.
472 #[serde(rename = "bitbucketServerConfig")]
473 pub bitbucket_server_config: Option<BitbucketServerConfig>,
474 /// Required. The Bitbucket server config resource that this trigger config maps to.
475 #[serde(rename = "bitbucketServerConfigResource")]
476 pub bitbucket_server_config_resource: Option<String>,
477 /// 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".
478 #[serde(rename = "projectKey")]
479 pub project_key: Option<String>,
480 /// Filter to match changes in pull requests.
481 #[serde(rename = "pullRequest")]
482 pub pull_request: Option<PullRequestFilter>,
483 /// Filter to match changes in refs like branches, tags.
484 pub push: Option<PushFilter>,
485 /// 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.
486 #[serde(rename = "repoSlug")]
487 pub repo_slug: Option<String>,
488}
489
490impl common::Part for BitbucketServerTriggerConfig {}
491
492/// 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.
493///
494/// # Activities
495///
496/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
497/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
498///
499/// * [builds cancel projects](ProjectBuildCancelCall) (response)
500/// * [builds create projects](ProjectBuildCreateCall) (request)
501/// * [builds get projects](ProjectBuildGetCall) (response)
502/// * [locations builds cancel projects](ProjectLocationBuildCancelCall) (response)
503/// * [locations builds create projects](ProjectLocationBuildCreateCall) (request)
504/// * [locations builds get projects](ProjectLocationBuildGetCall) (response)
505#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
506#[serde_with::serde_as]
507#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
508pub struct Build {
509 /// Output only. Describes this build's approval configuration, status, and result.
510 pub approval: Option<BuildApproval>,
511 /// Artifacts produced by the build that should be uploaded upon successful completion of all build steps.
512 pub artifacts: Option<Artifacts>,
513 /// Secrets and secret environment variables.
514 #[serde(rename = "availableSecrets")]
515 pub available_secrets: Option<Secrets>,
516 /// Output only. The ID of the `BuildTrigger` that triggered this build, if it was triggered automatically.
517 #[serde(rename = "buildTriggerId")]
518 pub build_trigger_id: Option<String>,
519 /// Output only. Time at which the request to create the build was received.
520 #[serde(rename = "createTime")]
521 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
522 /// Optional. Dependencies that the Cloud Build worker will fetch before executing user steps.
523 pub dependencies: Option<Vec<Dependency>>,
524 /// Output only. Contains information about the build when status=FAILURE.
525 #[serde(rename = "failureInfo")]
526 pub failure_info: Option<FailureInfo>,
527 /// 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.
528 #[serde(rename = "finishTime")]
529 pub finish_time: Option<chrono::DateTime<chrono::offset::Utc>>,
530 /// Optional. Configuration for git operations.
531 #[serde(rename = "gitConfig")]
532 pub git_config: Option<GitConfig>,
533 /// Output only. Unique identifier of the build.
534 pub id: Option<String>,
535 /// 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`.
536 pub images: Option<Vec<String>>,
537 /// Output only. URL to logs for this build in Google Cloud Console.
538 #[serde(rename = "logUrl")]
539 pub log_url: Option<String>,
540 /// 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`.
541 #[serde(rename = "logsBucket")]
542 pub logs_bucket: Option<String>,
543 /// Output only. The 'Build' name with format: `projects/{project}/locations/{location}/builds/{build}`, where {build} is a unique identifier generated by the service.
544 pub name: Option<String>,
545 /// Special options for this build.
546 pub options: Option<BuildOptions>,
547 /// Output only. ID of the project.
548 #[serde(rename = "projectId")]
549 pub project_id: Option<String>,
550 /// 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.
551 #[serde(rename = "queueTtl")]
552 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
553 pub queue_ttl: Option<chrono::Duration>,
554 /// Output only. Results of the build.
555 pub results: Option<Results>,
556 /// 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
557 pub secrets: Option<Vec<Secret>>,
558 /// 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.
559 #[serde(rename = "serviceAccount")]
560 pub service_account: Option<String>,
561 /// Optional. The location of the source files to build.
562 pub source: Option<Source>,
563 /// Output only. A permanent fixed identifier for source.
564 #[serde(rename = "sourceProvenance")]
565 pub source_provenance: Option<SourceProvenance>,
566 /// Output only. Time at which execution of the build was started.
567 #[serde(rename = "startTime")]
568 pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
569 /// Output only. Status of the build.
570 pub status: Option<String>,
571 /// Output only. Customer-readable message about the current status.
572 #[serde(rename = "statusDetail")]
573 pub status_detail: Option<String>,
574 /// Required. The operations to be performed on the workspace.
575 pub steps: Option<Vec<BuildStep>>,
576 /// Substitutions data for `Build` resource.
577 pub substitutions: Option<HashMap<String, String>>,
578 /// Tags for annotation of a `Build`. These are not docker tags.
579 pub tags: Option<Vec<String>>,
580 /// 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.
581 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
582 pub timeout: Option<chrono::Duration>,
583 /// 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.
584 pub timing: Option<HashMap<String, TimeSpan>>,
585 /// Output only. Non-fatal problems encountered during the execution of the build.
586 pub warnings: Option<Vec<Warning>>,
587}
588
589impl common::RequestValue for Build {}
590impl common::ResponseResult for Build {}
591
592/// BuildApproval describes a build's approval configuration, state, and result.
593///
594/// This type is not used in any activity, and only used as *part* of another schema.
595///
596#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
597#[serde_with::serde_as]
598#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
599pub struct BuildApproval {
600 /// Output only. Configuration for manual approval of this build.
601 pub config: Option<ApprovalConfig>,
602 /// Output only. Result of manual approval for this Build.
603 pub result: Option<ApprovalResult>,
604 /// Output only. The state of this build's approval.
605 pub state: Option<String>,
606}
607
608impl common::Part for BuildApproval {}
609
610/// Optional arguments to enable specific features of builds.
611///
612/// This type is not used in any activity, and only used as *part* of another schema.
613///
614#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
615#[serde_with::serde_as]
616#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
617pub struct BuildOptions {
618 /// Option to include built-in and custom substitutions as env variables for all build steps.
619 #[serde(rename = "automapSubstitutions")]
620 pub automap_substitutions: Option<bool>,
621 /// Optional. Option to specify how default logs buckets are setup.
622 #[serde(rename = "defaultLogsBucketBehavior")]
623 pub default_logs_bucket_behavior: Option<String>,
624 /// 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.
625 #[serde(rename = "diskSizeGb")]
626 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
627 pub disk_size_gb: Option<i64>,
628 /// 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.
629 #[serde(rename = "dynamicSubstitutions")]
630 pub dynamic_substitutions: Option<bool>,
631 /// Optional. Option to specify whether structured logging is enabled. If true, JSON-formatted logs are parsed as structured logs.
632 #[serde(rename = "enableStructuredLogging")]
633 pub enable_structured_logging: Option<bool>,
634 /// 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".
635 pub env: Option<Vec<String>>,
636 /// Option to define build log streaming behavior to Cloud Storage.
637 #[serde(rename = "logStreamingOption")]
638 pub log_streaming_option: Option<String>,
639 /// Option to specify the logging mode, which determines if and where build logs are stored.
640 pub logging: Option<String>,
641 /// Compute Engine machine type on which to run the build.
642 #[serde(rename = "machineType")]
643 pub machine_type: Option<String>,
644 /// 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.
645 pub pool: Option<PoolOption>,
646 /// Optional. Option to specify the Pub/Sub topic to receive build status updates.
647 #[serde(rename = "pubsubTopic")]
648 pub pubsub_topic: Option<String>,
649 /// Requested verifiability options.
650 #[serde(rename = "requestedVerifyOption")]
651 pub requested_verify_option: Option<String>,
652 /// 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.
653 #[serde(rename = "secretEnv")]
654 pub secret_env: Option<Vec<String>>,
655 /// Requested hash for SourceProvenance.
656 #[serde(rename = "sourceProvenanceHash")]
657 pub source_provenance_hash: Option<Vec<String>>,
658 /// 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.
659 #[serde(rename = "substitutionOption")]
660 pub substitution_option: Option<String>,
661 /// 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.
662 pub volumes: Option<Vec<Volume>>,
663 /// This field deprecated; please use `pool.name` instead.
664 #[serde(rename = "workerPool")]
665 pub worker_pool: Option<String>,
666}
667
668impl common::Part for BuildOptions {}
669
670/// A step in the build pipeline.
671///
672/// This type is not used in any activity, and only used as *part* of another schema.
673///
674#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
675#[serde_with::serde_as]
676#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
677pub struct BuildStep {
678 /// 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.
679 #[serde(rename = "allowExitCodes")]
680 pub allow_exit_codes: Option<Vec<i32>>,
681 /// 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.
682 #[serde(rename = "allowFailure")]
683 pub allow_failure: Option<bool>,
684 /// 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.
685 pub args: Option<Vec<String>>,
686 /// Option to include built-in and custom substitutions as env variables for this build step. This option will override the global option in BuildOption.
687 #[serde(rename = "automapSubstitutions")]
688 pub automap_substitutions: Option<bool>,
689 /// 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.
690 pub dir: Option<String>,
691 /// Entrypoint to be used instead of the build step image's default entrypoint. If unset, the image's default entrypoint is used.
692 pub entrypoint: Option<String>,
693 /// 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".
694 pub env: Option<Vec<String>>,
695 /// Output only. Return code from running the step.
696 #[serde(rename = "exitCode")]
697 pub exit_code: Option<i32>,
698 /// Unique identifier for this build step, used in `wait_for` to reference this build step as a dependency.
699 pub id: Option<String>,
700 /// 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.
701 pub name: Option<String>,
702 /// Output only. Stores timing information for pulling this build step's builder image only.
703 #[serde(rename = "pullTiming")]
704 pub pull_timing: Option<TimeSpan>,
705 /// A shell script to be executed in the step. When script is provided, the user cannot specify the entrypoint or args.
706 pub script: Option<String>,
707 /// 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`.
708 #[serde(rename = "secretEnv")]
709 pub secret_env: Option<Vec<String>>,
710 /// 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.
711 pub status: Option<String>,
712 /// 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.
713 #[serde_as(as = "Option<common::serde::duration::Wrapper>")]
714 pub timeout: Option<chrono::Duration>,
715 /// Output only. Stores timing information for executing this build step.
716 pub timing: Option<TimeSpan>,
717 /// 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.
718 pub volumes: Option<Vec<Volume>>,
719 /// 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.
720 #[serde(rename = "waitFor")]
721 pub wait_for: Option<Vec<String>>,
722}
723
724impl common::Part for BuildStep {}
725
726/// Configuration for an automated build in response to source repository changes.
727///
728/// # Activities
729///
730/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
731/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
732///
733/// * [locations triggers create projects](ProjectLocationTriggerCreateCall) (request|response)
734/// * [locations triggers get projects](ProjectLocationTriggerGetCall) (response)
735/// * [locations triggers patch projects](ProjectLocationTriggerPatchCall) (request|response)
736/// * [triggers create projects](ProjectTriggerCreateCall) (request|response)
737/// * [triggers get projects](ProjectTriggerGetCall) (response)
738/// * [triggers patch projects](ProjectTriggerPatchCall) (request|response)
739#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
740#[serde_with::serde_as]
741#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
742pub struct BuildTrigger {
743 /// Configuration for manual approval to start a build invocation of this BuildTrigger.
744 #[serde(rename = "approvalConfig")]
745 pub approval_config: Option<ApprovalConfig>,
746 /// 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.
747 pub autodetect: Option<bool>,
748 /// BitbucketServerTriggerConfig describes the configuration of a trigger that creates a build whenever a Bitbucket Server event is received.
749 #[serde(rename = "bitbucketServerTriggerConfig")]
750 pub bitbucket_server_trigger_config: Option<BitbucketServerTriggerConfig>,
751 /// Contents of the build template.
752 pub build: Option<Build>,
753 /// Output only. Time when the trigger was created.
754 #[serde(rename = "createTime")]
755 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
756 /// Human-readable description of this trigger.
757 pub description: Option<String>,
758 /// Optional. The configuration of a trigger that creates a build whenever an event from the DeveloperConnect API is received.
759 #[serde(rename = "developerConnectEventConfig")]
760 pub developer_connect_event_config: Option<DeveloperConnectEventConfig>,
761 /// If true, the trigger will never automatically execute a build.
762 pub disabled: Option<bool>,
763 /// 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.
764 #[serde(rename = "eventType")]
765 pub event_type: Option<String>,
766 /// Path, from the source root, to the build configuration file (i.e. cloudbuild.yaml).
767 pub filename: Option<String>,
768 /// A Common Expression Language string.
769 pub filter: Option<String>,
770 /// The file source describing the local or remote Build template.
771 #[serde(rename = "gitFileSource")]
772 pub git_file_source: Option<GitFileSource>,
773 /// GitHubEventsConfig describes the configuration of a trigger that creates a build whenever a GitHub event is received. Mutually exclusive with `trigger_template`.
774 pub github: Option<GitHubEventsConfig>,
775 /// GitLabEnterpriseEventsConfig describes the configuration of a trigger that creates a build whenever a GitLab Enterprise event is received.
776 #[serde(rename = "gitlabEnterpriseEventsConfig")]
777 pub gitlab_enterprise_events_config: Option<GitLabEventsConfig>,
778 /// Output only. Unique identifier of the trigger.
779 pub id: Option<String>,
780 /// 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.
781 #[serde(rename = "ignoredFiles")]
782 pub ignored_files: Option<Vec<String>>,
783 /// 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.
784 #[serde(rename = "includeBuildLogs")]
785 pub include_build_logs: Option<String>,
786 /// 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.
787 #[serde(rename = "includedFiles")]
788 pub included_files: Option<Vec<String>>,
789 /// 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.
790 pub name: Option<String>,
791 /// PubsubConfig describes the configuration of a trigger that creates a build whenever a Pub/Sub message is published.
792 #[serde(rename = "pubsubConfig")]
793 pub pubsub_config: Option<PubsubConfig>,
794 /// The configuration of a trigger that creates a build whenever an event from Repo API is received.
795 #[serde(rename = "repositoryEventConfig")]
796 pub repository_event_config: Option<RepositoryEventConfig>,
797 /// The `Trigger` name with format: `projects/{project}/locations/{location}/triggers/{trigger}`, where {trigger} is a unique identifier generated by the service.
798 #[serde(rename = "resourceName")]
799 pub resource_name: Option<String>,
800 /// The service account used for all user-controlled operations including UpdateBuildTrigger, RunBuildTrigger, CreateBuild, and CancelBuild. If no service account is set and the legacy Cloud Build service account ([PROJECT_NUM]@cloudbuild.gserviceaccount.com) is the default for the project then it will be used instead. Format: `projects/{PROJECT_ID}/serviceAccounts/{ACCOUNT_ID_OR_EMAIL}`
801 #[serde(rename = "serviceAccount")]
802 pub service_account: Option<String>,
803 /// 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.
804 #[serde(rename = "sourceToBuild")]
805 pub source_to_build: Option<GitRepoSource>,
806 /// Substitutions for Build resource. The keys must match the following regular expression: `^_[A-Z0-9_]+$`.
807 pub substitutions: Option<HashMap<String, String>>,
808 /// Tags for annotation of a `BuildTrigger`
809 pub tags: Option<Vec<String>>,
810 /// 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`.
811 #[serde(rename = "triggerTemplate")]
812 pub trigger_template: Option<RepoSource>,
813 /// WebhookConfig describes the configuration of a trigger that creates a build whenever a webhook is sent to a trigger's webhook URL.
814 #[serde(rename = "webhookConfig")]
815 pub webhook_config: Option<WebhookConfig>,
816}
817
818impl common::RequestValue for BuildTrigger {}
819impl common::ResponseResult for BuildTrigger {}
820
821/// An image built by the pipeline.
822///
823/// This type is not used in any activity, and only used as *part* of another schema.
824///
825#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
826#[serde_with::serde_as]
827#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
828pub struct BuiltImage {
829 /// Output only. Path to the artifact in Artifact Registry.
830 #[serde(rename = "artifactRegistryPackage")]
831 pub artifact_registry_package: Option<String>,
832 /// Docker Registry 2.0 digest.
833 pub digest: Option<String>,
834 /// Name used to push the container image to Google Container Registry, as presented to `docker push`.
835 pub name: Option<String>,
836 /// Output only. Stores timing information for pushing the specified image.
837 #[serde(rename = "pushTiming")]
838 pub push_timing: Option<TimeSpan>,
839}
840
841impl common::Part for BuiltImage {}
842
843/// Request to cancel an ongoing build.
844///
845/// # Activities
846///
847/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
848/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
849///
850/// * [builds cancel projects](ProjectBuildCancelCall) (request)
851/// * [locations builds cancel projects](ProjectLocationBuildCancelCall) (request)
852#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
853#[serde_with::serde_as]
854#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
855pub struct CancelBuildRequest {
856 /// Required. ID of the build.
857 pub id: Option<String>,
858 /// The name of the `Build` to cancel. Format: `projects/{project}/locations/{location}/builds/{build}`
859 pub name: Option<String>,
860 /// Required. ID of the project.
861 #[serde(rename = "projectId")]
862 pub project_id: Option<String>,
863}
864
865impl common::RequestValue for CancelBuildRequest {}
866
867/// The request message for Operations.CancelOperation.
868///
869/// # Activities
870///
871/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
872/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
873///
874/// * [cancel operations](OperationCancelCall) (request)
875/// * [locations operations cancel projects](ProjectLocationOperationCancelCall) (request)
876#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
877#[serde_with::serde_as]
878#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
879pub struct CancelOperationRequest {
880 _never_set: Option<bool>,
881}
882
883impl common::RequestValue for CancelOperationRequest {}
884
885/// Location of the source in a 2nd-gen Google Cloud Build repository resource.
886///
887/// This type is not used in any activity, and only used as *part* of another schema.
888///
889#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
890#[serde_with::serde_as]
891#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
892pub struct ConnectedRepository {
893 /// Optional. Directory, relative to the source root, in which to run the build.
894 pub dir: Option<String>,
895 /// Required. Name of the Google Cloud Build repository, formatted as `projects/*/locations/*/connections/*/repositories/*`.
896 pub repository: Option<String>,
897 /// Required. The revision to fetch from the Git repository such as a branch, a tag, a commit SHA, or any Git ref.
898 pub revision: Option<String>,
899}
900
901impl common::Part for ConnectedRepository {}
902
903/// Request to connect a repository from a connected Bitbucket Server host.
904///
905/// This type is not used in any activity, and only used as *part* of another schema.
906///
907#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
908#[serde_with::serde_as]
909#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
910pub struct CreateBitbucketServerConnectedRepositoryRequest {
911 /// Required. The Bitbucket Server repository to connect.
912 #[serde(rename = "bitbucketServerConnectedRepository")]
913 pub bitbucket_server_connected_repository: Option<BitbucketServerConnectedRepository>,
914 /// Required. The name of the `BitbucketServerConfig` that added connected repository. Format: `projects/{project}/locations/{location}/bitbucketServerConfigs/{config}`
915 pub parent: Option<String>,
916}
917
918impl common::Part for CreateBitbucketServerConnectedRepositoryRequest {}
919
920/// Request to connect a repository from a connected GitLab host.
921///
922/// This type is not used in any activity, and only used as *part* of another schema.
923///
924#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
925#[serde_with::serde_as]
926#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
927pub struct CreateGitLabConnectedRepositoryRequest {
928 /// Required. The GitLab repository to connect.
929 #[serde(rename = "gitlabConnectedRepository")]
930 pub gitlab_connected_repository: Option<GitLabConnectedRepository>,
931 /// Required. The name of the `GitLabConfig` that adds connected repository. Format: `projects/{project}/locations/{location}/gitLabConfigs/{config}`
932 pub parent: Option<String>,
933}
934
935impl common::Part for CreateGitLabConnectedRepositoryRequest {}
936
937/// The default service account used for `Builds`.
938///
939/// # Activities
940///
941/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
942/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
943///
944/// * [locations get default service account projects](ProjectLocationGetDefaultServiceAccountCall) (response)
945#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
946#[serde_with::serde_as]
947#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
948pub struct DefaultServiceAccount {
949 /// Identifier. Format: `projects/{project}/locations/{location}/defaultServiceAccount
950 pub name: Option<String>,
951 /// 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.
952 #[serde(rename = "serviceAccountEmail")]
953 pub service_account_email: Option<String>,
954}
955
956impl common::ResponseResult for DefaultServiceAccount {}
957
958/// A dependency that the Cloud Build worker will fetch before executing user steps.
959///
960/// This type is not used in any activity, and only used as *part* of another schema.
961///
962#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
963#[serde_with::serde_as]
964#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
965pub struct Dependency {
966 /// If set to true disable all dependency fetching (ignoring the default source as well).
967 pub empty: Option<bool>,
968 /// Represents a git repository as a build dependency.
969 #[serde(rename = "gitSource")]
970 pub git_source: Option<GitSourceDependency>,
971}
972
973impl common::Part for Dependency {}
974
975/// This config defines the location of a source through Developer Connect.
976///
977/// This type is not used in any activity, and only used as *part* of another schema.
978///
979#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
980#[serde_with::serde_as]
981#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
982pub struct DeveloperConnectConfig {
983 /// Required. Directory, relative to the source root, in which to run the build.
984 pub dir: Option<String>,
985 /// Required. The Developer Connect Git repository link, formatted as `projects/*/locations/*/connections/*/gitRepositoryLink/*`.
986 #[serde(rename = "gitRepositoryLink")]
987 pub git_repository_link: Option<String>,
988 /// Required. The revision to fetch from the Git repository such as a branch, a tag, a commit SHA, or any Git ref.
989 pub revision: Option<String>,
990}
991
992impl common::Part for DeveloperConnectConfig {}
993
994/// The configuration of a trigger that creates a build whenever an event from the DeveloperConnect API is received.
995///
996/// This type is not used in any activity, and only used as *part* of another schema.
997///
998#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
999#[serde_with::serde_as]
1000#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1001pub struct DeveloperConnectEventConfig {
1002 /// Required. The Developer Connect Git repository link, formatted as `projects/*/locations/*/connections/*/gitRepositoryLink/*`.
1003 #[serde(rename = "gitRepositoryLink")]
1004 pub git_repository_link: Option<String>,
1005 /// Output only. The type of DeveloperConnect GitRepositoryLink.
1006 #[serde(rename = "gitRepositoryLinkType")]
1007 pub git_repository_link_type: Option<String>,
1008 /// Filter to match changes in pull requests.
1009 #[serde(rename = "pullRequest")]
1010 pub pull_request: Option<PullRequestFilter>,
1011 /// Filter to match changes in refs like branches and tags.
1012 pub push: Option<PushFilter>,
1013}
1014
1015impl common::Part for DeveloperConnectEventConfig {}
1016
1017/// 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); }
1018///
1019/// # Activities
1020///
1021/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1022/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1023///
1024/// * [receive github dot com webhook](GithubDotComWebhookReceiveCall) (response)
1025/// * [regional webhook locations](LocationRegionalWebhookCall) (response)
1026/// * [cancel operations](OperationCancelCall) (response)
1027/// * [locations bitbucket server configs remove bitbucket server connected repository projects](ProjectLocationBitbucketServerConfigRemoveBitbucketServerConnectedRepositoryCall) (response)
1028/// * [locations git lab configs remove git lab connected repository projects](ProjectLocationGitLabConfigRemoveGitLabConnectedRepositoryCall) (response)
1029/// * [locations operations cancel projects](ProjectLocationOperationCancelCall) (response)
1030/// * [locations triggers delete projects](ProjectLocationTriggerDeleteCall) (response)
1031/// * [triggers delete projects](ProjectTriggerDeleteCall) (response)
1032/// * [webhook](MethodWebhookCall) (response)
1033#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1034#[serde_with::serde_as]
1035#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1036pub struct Empty {
1037 _never_set: Option<bool>,
1038}
1039
1040impl common::ResponseResult for Empty {}
1041
1042/// A fatal problem encountered during the execution of the build.
1043///
1044/// This type is not used in any activity, and only used as *part* of another schema.
1045///
1046#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1047#[serde_with::serde_as]
1048#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1049pub struct FailureInfo {
1050 /// Explains the failure issue in more detail using hard-coded text.
1051 pub detail: Option<String>,
1052 /// The name of the failure.
1053 #[serde(rename = "type")]
1054 pub type_: Option<String>,
1055}
1056
1057impl common::Part for FailureInfo {}
1058
1059/// Container message for hashes of byte content of files, used in SourceProvenance messages to verify integrity of source input to the build.
1060///
1061/// This type is not used in any activity, and only used as *part* of another schema.
1062///
1063#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1064#[serde_with::serde_as]
1065#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1066pub struct FileHashes {
1067 /// Collection of file hashes.
1068 #[serde(rename = "fileHash")]
1069 pub file_hash: Option<Vec<Hash>>,
1070}
1071
1072impl common::Part for FileHashes {}
1073
1074/// GitConfig is a configuration for git operations.
1075///
1076/// This type is not used in any activity, and only used as *part* of another schema.
1077///
1078#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1079#[serde_with::serde_as]
1080#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1081pub struct GitConfig {
1082 /// Configuration for HTTP related git operations.
1083 pub http: Option<HttpConfig>,
1084}
1085
1086impl common::Part for GitConfig {}
1087
1088/// GitFileSource describes a file within a (possibly remote) code repository.
1089///
1090/// This type is not used in any activity, and only used as *part* of another schema.
1091///
1092#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1093#[serde_with::serde_as]
1094#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1095pub struct GitFileSource {
1096 /// The full resource name of the bitbucket server config. Format: `projects/{project}/locations/{location}/bitbucketServerConfigs/{id}`.
1097 #[serde(rename = "bitbucketServerConfig")]
1098 pub bitbucket_server_config: Option<String>,
1099 /// The full resource name of the github enterprise config. Format: `projects/{project}/locations/{location}/githubEnterpriseConfigs/{id}`. `projects/{project}/githubEnterpriseConfigs/{id}`.
1100 #[serde(rename = "githubEnterpriseConfig")]
1101 pub github_enterprise_config: Option<String>,
1102 /// The path of the file, with the repo root as the root of the path.
1103 pub path: Option<String>,
1104 /// See RepoType above.
1105 #[serde(rename = "repoType")]
1106 pub repo_type: Option<String>,
1107 /// 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.
1108 pub repository: Option<String>,
1109 /// 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.
1110 pub revision: Option<String>,
1111 /// 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.
1112 pub uri: Option<String>,
1113}
1114
1115impl common::Part for GitFileSource {}
1116
1117/// GitHubEnterpriseConfig represents a configuration for a GitHub Enterprise server.
1118///
1119/// # Activities
1120///
1121/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1122/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1123///
1124/// * [github enterprise configs create projects](ProjectGithubEnterpriseConfigCreateCall) (request)
1125/// * [github enterprise configs get projects](ProjectGithubEnterpriseConfigGetCall) (response)
1126/// * [github enterprise configs patch projects](ProjectGithubEnterpriseConfigPatchCall) (request)
1127/// * [locations github enterprise configs create projects](ProjectLocationGithubEnterpriseConfigCreateCall) (request)
1128/// * [locations github enterprise configs get projects](ProjectLocationGithubEnterpriseConfigGetCall) (response)
1129/// * [locations github enterprise configs patch projects](ProjectLocationGithubEnterpriseConfigPatchCall) (request)
1130#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1131#[serde_with::serde_as]
1132#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1133pub struct GitHubEnterpriseConfig {
1134 /// Required. The GitHub app id of the Cloud Build app on the GitHub Enterprise server.
1135 #[serde(rename = "appId")]
1136 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1137 pub app_id: Option<i64>,
1138 /// Output only. Time when the installation was associated with the project.
1139 #[serde(rename = "createTime")]
1140 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1141 /// Optional. Name to display for this config.
1142 #[serde(rename = "displayName")]
1143 pub display_name: Option<String>,
1144 /// The URL of the github enterprise host the configuration is for.
1145 #[serde(rename = "hostUrl")]
1146 pub host_url: Option<String>,
1147 /// The full resource name for the GitHubEnterpriseConfig For example: "projects/{$project_id}/locations/{$location_id}/githubEnterpriseConfigs/{$config_id}"
1148 pub name: Option<String>,
1149 /// 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.
1150 #[serde(rename = "peeredNetwork")]
1151 pub peered_network: Option<String>,
1152 /// Optional. Names of secrets in Secret Manager.
1153 pub secrets: Option<GitHubEnterpriseSecrets>,
1154 /// Optional. SSL certificate to use for requests to GitHub Enterprise.
1155 #[serde(rename = "sslCa")]
1156 pub ssl_ca: Option<String>,
1157 /// The key that should be attached to webhook calls to the ReceiveWebhook endpoint.
1158 #[serde(rename = "webhookKey")]
1159 pub webhook_key: Option<String>,
1160}
1161
1162impl common::RequestValue for GitHubEnterpriseConfig {}
1163impl common::ResponseResult for GitHubEnterpriseConfig {}
1164
1165/// GitHubEnterpriseSecrets represents the names of all necessary secrets in Secret Manager for a GitHub Enterprise server. Format is: projects//secrets/.
1166///
1167/// This type is not used in any activity, and only used as *part* of another schema.
1168///
1169#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1170#[serde_with::serde_as]
1171#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1172pub struct GitHubEnterpriseSecrets {
1173 /// The resource name for the OAuth client ID secret in Secret Manager.
1174 #[serde(rename = "oauthClientIdName")]
1175 pub oauth_client_id_name: Option<String>,
1176 /// The resource name for the OAuth client ID secret version in Secret Manager.
1177 #[serde(rename = "oauthClientIdVersionName")]
1178 pub oauth_client_id_version_name: Option<String>,
1179 /// The resource name for the OAuth secret in Secret Manager.
1180 #[serde(rename = "oauthSecretName")]
1181 pub oauth_secret_name: Option<String>,
1182 /// The resource name for the OAuth secret secret version in Secret Manager.
1183 #[serde(rename = "oauthSecretVersionName")]
1184 pub oauth_secret_version_name: Option<String>,
1185 /// The resource name for the private key secret.
1186 #[serde(rename = "privateKeyName")]
1187 pub private_key_name: Option<String>,
1188 /// The resource name for the private key secret version.
1189 #[serde(rename = "privateKeyVersionName")]
1190 pub private_key_version_name: Option<String>,
1191 /// The resource name for the webhook secret in Secret Manager.
1192 #[serde(rename = "webhookSecretName")]
1193 pub webhook_secret_name: Option<String>,
1194 /// The resource name for the webhook secret secret version in Secret Manager.
1195 #[serde(rename = "webhookSecretVersionName")]
1196 pub webhook_secret_version_name: Option<String>,
1197}
1198
1199impl common::Part for GitHubEnterpriseSecrets {}
1200
1201/// GitHubEventsConfig describes the configuration of a trigger that creates a build whenever a GitHub event is received.
1202///
1203/// This type is not used in any activity, and only used as *part* of another schema.
1204///
1205#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1206#[serde_with::serde_as]
1207#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1208pub struct GitHubEventsConfig {
1209 /// 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}"
1210 #[serde(rename = "enterpriseConfigResourceName")]
1211 pub enterprise_config_resource_name: Option<String>,
1212 /// The installationID that emits the GitHub event.
1213 #[serde(rename = "installationId")]
1214 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1215 pub installation_id: Option<i64>,
1216 /// Name of the repository. For example: The name for https://github.com/googlecloudplatform/cloud-builders is "cloud-builders".
1217 pub name: Option<String>,
1218 /// Owner of the repository. For example: The owner for https://github.com/googlecloudplatform/cloud-builders is "googlecloudplatform".
1219 pub owner: Option<String>,
1220 /// filter to match changes in pull requests.
1221 #[serde(rename = "pullRequest")]
1222 pub pull_request: Option<PullRequestFilter>,
1223 /// filter to match changes in refs like branches, tags.
1224 pub push: Option<PushFilter>,
1225}
1226
1227impl common::Part for GitHubEventsConfig {}
1228
1229/// GitLabConfig represents the configuration for a GitLab integration.
1230///
1231/// # Activities
1232///
1233/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1234/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1235///
1236/// * [locations git lab configs create projects](ProjectLocationGitLabConfigCreateCall) (request)
1237/// * [locations git lab configs get projects](ProjectLocationGitLabConfigGetCall) (response)
1238/// * [locations git lab configs patch projects](ProjectLocationGitLabConfigPatchCall) (request)
1239#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1240#[serde_with::serde_as]
1241#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1242pub struct GitLabConfig {
1243 /// Connected GitLab.com or GitLabEnterprise repositories for this config.
1244 #[serde(rename = "connectedRepositories")]
1245 pub connected_repositories: Option<Vec<GitLabRepositoryId>>,
1246 /// Output only. Time when the config was created.
1247 #[serde(rename = "createTime")]
1248 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1249 /// Optional. GitLabEnterprise config.
1250 #[serde(rename = "enterpriseConfig")]
1251 pub enterprise_config: Option<GitLabEnterpriseConfig>,
1252 /// The resource name for the config.
1253 pub name: Option<String>,
1254 /// Required. Secret Manager secrets needed by the config.
1255 pub secrets: Option<GitLabSecrets>,
1256 /// Username of the GitLab.com or GitLab Enterprise account Cloud Build will use.
1257 pub username: Option<String>,
1258 /// Output only. UUID included in webhook requests. The UUID is used to look up the corresponding config.
1259 #[serde(rename = "webhookKey")]
1260 pub webhook_key: Option<String>,
1261}
1262
1263impl common::RequestValue for GitLabConfig {}
1264impl common::ResponseResult for GitLabConfig {}
1265
1266/// GitLabConnectedRepository represents a GitLab connected repository request response.
1267///
1268/// This type is not used in any activity, and only used as *part* of another schema.
1269///
1270#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1271#[serde_with::serde_as]
1272#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1273pub struct GitLabConnectedRepository {
1274 /// The name of the `GitLabConfig` that added connected repository. Format: `projects/{project}/locations/{location}/gitLabConfigs/{config}`
1275 pub parent: Option<String>,
1276 /// The GitLab repositories to connect.
1277 pub repo: Option<GitLabRepositoryId>,
1278 /// Output only. The status of the repo connection request.
1279 pub status: Option<Status>,
1280}
1281
1282impl common::Part for GitLabConnectedRepository {}
1283
1284/// GitLabEnterpriseConfig represents the configuration for a GitLabEnterprise integration.
1285///
1286/// This type is not used in any activity, and only used as *part* of another schema.
1287///
1288#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1289#[serde_with::serde_as]
1290#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1291pub struct GitLabEnterpriseConfig {
1292 /// Immutable. The URI of the GitlabEnterprise host.
1293 #[serde(rename = "hostUri")]
1294 pub host_uri: Option<String>,
1295 /// The Service Directory configuration to be used when reaching out to the GitLab Enterprise instance.
1296 #[serde(rename = "serviceDirectoryConfig")]
1297 pub service_directory_config: Option<ServiceDirectoryConfig>,
1298 /// The SSL certificate to use in requests to GitLab Enterprise instances.
1299 #[serde(rename = "sslCa")]
1300 pub ssl_ca: Option<String>,
1301}
1302
1303impl common::Part for GitLabEnterpriseConfig {}
1304
1305/// GitLabEventsConfig describes the configuration of a trigger that creates a build whenever a GitLab event is received.
1306///
1307/// This type is not used in any activity, and only used as *part* of another schema.
1308///
1309#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1310#[serde_with::serde_as]
1311#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1312pub struct GitLabEventsConfig {
1313 /// Output only. The GitLabConfig specified in the gitlab_config_resource field.
1314 #[serde(rename = "gitlabConfig")]
1315 pub gitlab_config: Option<GitLabConfig>,
1316 /// The GitLab config resource that this trigger config maps to.
1317 #[serde(rename = "gitlabConfigResource")]
1318 pub gitlab_config_resource: Option<String>,
1319 /// Namespace of the GitLab project.
1320 #[serde(rename = "projectNamespace")]
1321 pub project_namespace: Option<String>,
1322 /// Filter to match changes in pull requests.
1323 #[serde(rename = "pullRequest")]
1324 pub pull_request: Option<PullRequestFilter>,
1325 /// Filter to match changes in refs like branches, tags.
1326 pub push: Option<PushFilter>,
1327}
1328
1329impl common::Part for GitLabEventsConfig {}
1330
1331/// Proto Representing a GitLabRepository
1332///
1333/// This type is not used in any activity, and only used as *part* of another schema.
1334///
1335#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1336#[serde_with::serde_as]
1337#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1338pub struct GitLabRepository {
1339 /// Link to the browse repo page on the GitLab instance
1340 #[serde(rename = "browseUri")]
1341 pub browse_uri: Option<String>,
1342 /// Description of the repository
1343 pub description: Option<String>,
1344 /// Display name of the repository
1345 #[serde(rename = "displayName")]
1346 pub display_name: Option<String>,
1347 /// The resource name of the repository
1348 pub name: Option<String>,
1349 /// Identifier for a repository
1350 #[serde(rename = "repositoryId")]
1351 pub repository_id: Option<GitLabRepositoryId>,
1352}
1353
1354impl common::Part for GitLabRepository {}
1355
1356/// GitLabRepositoryId identifies a specific repository hosted on GitLab.com or GitLabEnterprise
1357///
1358/// This type is not used in any activity, and only used as *part* of another schema.
1359///
1360#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1361#[serde_with::serde_as]
1362#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1363pub struct GitLabRepositoryId {
1364 /// Required. Identifier for the repository. example: "namespace/project-slug", namespace is usually the username or group ID
1365 pub id: Option<String>,
1366 /// 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.
1367 #[serde(rename = "webhookId")]
1368 pub webhook_id: Option<i32>,
1369}
1370
1371impl common::Part for GitLabRepositoryId {}
1372
1373/// GitLabSecrets represents the secrets in Secret Manager for a GitLab integration.
1374///
1375/// This type is not used in any activity, and only used as *part* of another schema.
1376///
1377#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1378#[serde_with::serde_as]
1379#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1380pub struct GitLabSecrets {
1381 /// Required. The resource name for the api access token’s secret version
1382 #[serde(rename = "apiAccessTokenVersion")]
1383 pub api_access_token_version: Option<String>,
1384 /// Required. Immutable. API Key that will be attached to webhook requests from GitLab to Cloud Build.
1385 #[serde(rename = "apiKeyVersion")]
1386 pub api_key_version: Option<String>,
1387 /// Required. The resource name for the read access token’s secret version
1388 #[serde(rename = "readAccessTokenVersion")]
1389 pub read_access_token_version: Option<String>,
1390 /// 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.
1391 #[serde(rename = "webhookSecretVersion")]
1392 pub webhook_secret_version: Option<String>,
1393}
1394
1395impl common::Part for GitLabSecrets {}
1396
1397/// GitRepoSource describes a repo and ref of a code repository.
1398///
1399/// This type is not used in any activity, and only used as *part* of another schema.
1400///
1401#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1402#[serde_with::serde_as]
1403#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1404pub struct GitRepoSource {
1405 /// The full resource name of the bitbucket server config. Format: `projects/{project}/locations/{location}/bitbucketServerConfigs/{id}`.
1406 #[serde(rename = "bitbucketServerConfig")]
1407 pub bitbucket_server_config: Option<String>,
1408 /// The full resource name of the github enterprise config. Format: `projects/{project}/locations/{location}/githubEnterpriseConfigs/{id}`. `projects/{project}/githubEnterpriseConfigs/{id}`.
1409 #[serde(rename = "githubEnterpriseConfig")]
1410 pub github_enterprise_config: Option<String>,
1411 /// The branch or tag to use. Must start with "refs/" (required).
1412 #[serde(rename = "ref")]
1413 pub ref_: Option<String>,
1414 /// See RepoType below.
1415 #[serde(rename = "repoType")]
1416 pub repo_type: Option<String>,
1417 /// The connected repository resource name, in the format `projects/*/locations/*/connections/*/repositories/*`. Either `uri` or `repository` can be specified and is required.
1418 pub repository: Option<String>,
1419 /// The URI of the repo (e.g. https://github.com/user/repo.git). Either `uri` or `repository` can be specified and is required.
1420 pub uri: Option<String>,
1421}
1422
1423impl common::Part for GitRepoSource {}
1424
1425/// Location of the source in any accessible Git repository.
1426///
1427/// This type is not used in any activity, and only used as *part* of another schema.
1428///
1429#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1430#[serde_with::serde_as]
1431#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1432pub struct GitSource {
1433 /// 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.
1434 pub dir: Option<String>,
1435 /// 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.
1436 pub revision: Option<String>,
1437 /// Required. Location of the Git repo to build. This will be used as a `git remote`, see https://git-scm.com/docs/git-remote.
1438 pub url: Option<String>,
1439}
1440
1441impl common::Part for GitSource {}
1442
1443/// Represents a git repository as a build dependency.
1444///
1445/// This type is not used in any activity, and only used as *part* of another schema.
1446///
1447#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1448#[serde_with::serde_as]
1449#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1450pub struct GitSourceDependency {
1451 /// Optional. How much history should be fetched for the build (default 1, -1 for all history).
1452 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1453 pub depth: Option<i64>,
1454 /// Required. Where should the files be placed on the worker.
1455 #[serde(rename = "destPath")]
1456 pub dest_path: Option<String>,
1457 /// Optional. True if submodules should be fetched too (default false).
1458 #[serde(rename = "recurseSubmodules")]
1459 pub recurse_submodules: Option<bool>,
1460 /// Required. The kind of repo (url or dev connect).
1461 pub repository: Option<GitSourceRepository>,
1462 /// Required. The revision that we will fetch the repo at.
1463 pub revision: Option<String>,
1464}
1465
1466impl common::Part for GitSourceDependency {}
1467
1468/// A repository for a git source.
1469///
1470/// This type is not used in any activity, and only used as *part* of another schema.
1471///
1472#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1473#[serde_with::serde_as]
1474#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1475pub struct GitSourceRepository {
1476 /// The Developer Connect Git repository link formatted as `projects/*/locations/*/connections/*/gitRepositoryLink/*`
1477 #[serde(rename = "developerConnect")]
1478 pub developer_connect: Option<String>,
1479 /// Location of the Git repository.
1480 pub url: Option<String>,
1481}
1482
1483impl common::Part for GitSourceRepository {}
1484
1485/// Go module to upload to Artifact Registry upon successful completion of all build steps. A module refers to all dependencies in a go.mod file.
1486///
1487/// This type is not used in any activity, and only used as *part* of another schema.
1488///
1489#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1490#[serde_with::serde_as]
1491#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1492pub struct GoModule {
1493 /// Optional. The Go module's "module path". e.g. example.com/foo/v2
1494 #[serde(rename = "modulePath")]
1495 pub module_path: Option<String>,
1496 /// Optional. The Go module's semantic version in the form vX.Y.Z. e.g. v0.1.1 Pre-release identifiers can also be added by appending a dash and dot separated ASCII alphanumeric characters and hyphens. e.g. v0.2.3-alpha.x.12m.5
1497 #[serde(rename = "moduleVersion")]
1498 pub module_version: Option<String>,
1499 /// Optional. Location of the Artifact Registry repository. i.e. us-east1 Defaults to the build’s location.
1500 #[serde(rename = "repositoryLocation")]
1501 pub repository_location: Option<String>,
1502 /// Optional. Artifact Registry repository name. Specified Go modules will be zipped and uploaded to Artifact Registry with this location as a prefix. e.g. my-go-repo
1503 #[serde(rename = "repositoryName")]
1504 pub repository_name: Option<String>,
1505 /// Optional. Project ID of the Artifact Registry repository. Defaults to the build project.
1506 #[serde(rename = "repositoryProjectId")]
1507 pub repository_project_id: Option<String>,
1508 /// Optional. Source path of the go.mod file in the build's workspace. If not specified, this will default to the current directory. e.g. ~/code/go/mypackage
1509 #[serde(rename = "sourcePath")]
1510 pub source_path: Option<String>,
1511}
1512
1513impl common::Part for GoModule {}
1514
1515/// Container message for hash values.
1516///
1517/// This type is not used in any activity, and only used as *part* of another schema.
1518///
1519#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1520#[serde_with::serde_as]
1521#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1522pub struct Hash {
1523 /// The type of hash that was performed.
1524 #[serde(rename = "type")]
1525 pub type_: Option<String>,
1526 /// The hash value.
1527 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1528 pub value: Option<Vec<u8>>,
1529}
1530
1531impl common::Part for Hash {}
1532
1533/// 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.
1534///
1535/// # Activities
1536///
1537/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1538/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1539///
1540/// * [receive github dot com webhook](GithubDotComWebhookReceiveCall) (request)
1541/// * [regional webhook locations](LocationRegionalWebhookCall) (request)
1542/// * [locations triggers webhook projects](ProjectLocationTriggerWebhookCall) (request)
1543/// * [triggers webhook projects](ProjectTriggerWebhookCall) (request)
1544/// * [webhook](MethodWebhookCall) (request)
1545#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1546#[serde_with::serde_as]
1547#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1548pub struct HttpBody {
1549 /// The HTTP Content-Type header value specifying the content type of the body.
1550 #[serde(rename = "contentType")]
1551 pub content_type: Option<String>,
1552 /// The HTTP request/response body as raw binary.
1553 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1554 pub data: Option<Vec<u8>>,
1555 /// Application specific response metadata. Must be set in the first response for streaming APIs.
1556 pub extensions: Option<Vec<HashMap<String, serde_json::Value>>>,
1557}
1558
1559impl common::RequestValue for HttpBody {}
1560
1561/// HttpConfig is a configuration for HTTP related git operations.
1562///
1563/// This type is not used in any activity, and only used as *part* of another schema.
1564///
1565#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1566#[serde_with::serde_as]
1567#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1568pub struct HttpConfig {
1569 /// SecretVersion resource of the HTTP proxy URL. The Service Account used in the build (either the default Service Account or user-specified Service Account) should have `secretmanager.versions.access` permissions on this secret. The proxy URL should be in format `protocol://@]proxyhost[:port]`.
1570 #[serde(rename = "proxySecretVersionName")]
1571 pub proxy_secret_version_name: Option<String>,
1572}
1573
1574impl common::Part for HttpConfig {}
1575
1576/// Pairs a set of secret environment variables mapped to encrypted values with the Cloud KMS key to use to decrypt the value.
1577///
1578/// This type is not used in any activity, and only used as *part* of another schema.
1579///
1580#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1581#[serde_with::serde_as]
1582#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1583pub struct InlineSecret {
1584 /// 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.
1585 #[serde(rename = "envMap")]
1586 #[serde_as(as = "Option<HashMap<_, common::serde::standard_base64::Wrapper>>")]
1587 pub env_map: Option<HashMap<String, Vec<u8>>>,
1588 /// Resource name of Cloud KMS crypto key to decrypt the encrypted value. In format: projects/*/locations/*/keyRings/*/cryptoKeys/*
1589 #[serde(rename = "kmsKeyName")]
1590 pub kms_key_name: Option<String>,
1591}
1592
1593impl common::Part for InlineSecret {}
1594
1595/// RPC response object returned by ListBitbucketServerConfigs RPC method.
1596///
1597/// # Activities
1598///
1599/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1600/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1601///
1602/// * [locations bitbucket server configs list projects](ProjectLocationBitbucketServerConfigListCall) (response)
1603#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1604#[serde_with::serde_as]
1605#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1606pub struct ListBitbucketServerConfigsResponse {
1607 /// A list of BitbucketServerConfigs
1608 #[serde(rename = "bitbucketServerConfigs")]
1609 pub bitbucket_server_configs: Option<Vec<BitbucketServerConfig>>,
1610 /// A token that can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
1611 #[serde(rename = "nextPageToken")]
1612 pub next_page_token: Option<String>,
1613}
1614
1615impl common::ResponseResult for ListBitbucketServerConfigsResponse {}
1616
1617/// RPC response object returned by the ListBitbucketServerRepositories RPC method.
1618///
1619/// # Activities
1620///
1621/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1622/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1623///
1624/// * [locations bitbucket server configs repos list projects](ProjectLocationBitbucketServerConfigRepoListCall) (response)
1625#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1626#[serde_with::serde_as]
1627#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1628pub struct ListBitbucketServerRepositoriesResponse {
1629 /// List of Bitbucket Server repositories.
1630 #[serde(rename = "bitbucketServerRepositories")]
1631 pub bitbucket_server_repositories: Option<Vec<BitbucketServerRepository>>,
1632 /// A token that can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
1633 #[serde(rename = "nextPageToken")]
1634 pub next_page_token: Option<String>,
1635}
1636
1637impl common::ResponseResult for ListBitbucketServerRepositoriesResponse {}
1638
1639/// Response containing existing `BuildTriggers`.
1640///
1641/// # Activities
1642///
1643/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1644/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1645///
1646/// * [locations triggers list projects](ProjectLocationTriggerListCall) (response)
1647/// * [triggers list projects](ProjectTriggerListCall) (response)
1648#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1649#[serde_with::serde_as]
1650#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1651pub struct ListBuildTriggersResponse {
1652 /// Token to receive the next page of results.
1653 #[serde(rename = "nextPageToken")]
1654 pub next_page_token: Option<String>,
1655 /// `BuildTriggers` for the project, sorted by `create_time` descending.
1656 pub triggers: Option<Vec<BuildTrigger>>,
1657}
1658
1659impl common::ResponseResult for ListBuildTriggersResponse {}
1660
1661/// Response including listed builds.
1662///
1663/// # Activities
1664///
1665/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1666/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1667///
1668/// * [builds list projects](ProjectBuildListCall) (response)
1669/// * [locations builds list projects](ProjectLocationBuildListCall) (response)
1670#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1671#[serde_with::serde_as]
1672#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1673pub struct ListBuildsResponse {
1674 /// Builds will be sorted by `create_time`, descending.
1675 pub builds: Option<Vec<Build>>,
1676 /// Token to receive the next page of results. This will be absent if the end of the response list has been reached.
1677 #[serde(rename = "nextPageToken")]
1678 pub next_page_token: Option<String>,
1679}
1680
1681impl common::ResponseResult for ListBuildsResponse {}
1682
1683/// RPC response object returned by ListGitLabConfigs RPC method.
1684///
1685/// # Activities
1686///
1687/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1688/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1689///
1690/// * [locations git lab configs list projects](ProjectLocationGitLabConfigListCall) (response)
1691#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1692#[serde_with::serde_as]
1693#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1694pub struct ListGitLabConfigsResponse {
1695 /// A list of GitLabConfigs
1696 #[serde(rename = "gitlabConfigs")]
1697 pub gitlab_configs: Option<Vec<GitLabConfig>>,
1698 /// A token that can be sent as `page_token` to retrieve the next page If this field is omitted, there are no subsequent pages.
1699 #[serde(rename = "nextPageToken")]
1700 pub next_page_token: Option<String>,
1701}
1702
1703impl common::ResponseResult for ListGitLabConfigsResponse {}
1704
1705/// RPC response object returned by the ListGitLabRepositories RPC method.
1706///
1707/// # Activities
1708///
1709/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1710/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1711///
1712/// * [locations git lab configs repos list projects](ProjectLocationGitLabConfigRepoListCall) (response)
1713#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1714#[serde_with::serde_as]
1715#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1716pub struct ListGitLabRepositoriesResponse {
1717 /// List of GitLab repositories
1718 #[serde(rename = "gitlabRepositories")]
1719 pub gitlab_repositories: Option<Vec<GitLabRepository>>,
1720 /// A token that can be sent as `page_token` to retrieve the next page. If this field is omitted, there are no subsequent pages.
1721 #[serde(rename = "nextPageToken")]
1722 pub next_page_token: Option<String>,
1723}
1724
1725impl common::ResponseResult for ListGitLabRepositoriesResponse {}
1726
1727/// RPC response object returned by ListGithubEnterpriseConfigs RPC method.
1728///
1729/// # Activities
1730///
1731/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1732/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1733///
1734/// * [github enterprise configs list projects](ProjectGithubEnterpriseConfigListCall) (response)
1735/// * [locations github enterprise configs list projects](ProjectLocationGithubEnterpriseConfigListCall) (response)
1736#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1737#[serde_with::serde_as]
1738#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1739pub struct ListGithubEnterpriseConfigsResponse {
1740 /// A list of GitHubEnterpriseConfigs
1741 pub configs: Option<Vec<GitHubEnterpriseConfig>>,
1742}
1743
1744impl common::ResponseResult for ListGithubEnterpriseConfigsResponse {}
1745
1746/// Response containing existing `WorkerPools`.
1747///
1748/// # Activities
1749///
1750/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1751/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1752///
1753/// * [locations worker pools list projects](ProjectLocationWorkerPoolListCall) (response)
1754#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1755#[serde_with::serde_as]
1756#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1757pub struct ListWorkerPoolsResponse {
1758 /// Continuation token used to page through large result sets. Provide this value in a subsequent ListWorkerPoolsRequest to return the next page of results.
1759 #[serde(rename = "nextPageToken")]
1760 pub next_page_token: Option<String>,
1761 /// `WorkerPools` for the specified project.
1762 #[serde(rename = "workerPools")]
1763 pub worker_pools: Option<Vec<WorkerPool>>,
1764}
1765
1766impl common::ResponseResult for ListWorkerPoolsResponse {}
1767
1768/// A Maven artifact to upload to Artifact Registry upon successful completion of all build steps.
1769///
1770/// This type is not used in any activity, and only used as *part* of another schema.
1771///
1772#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1773#[serde_with::serde_as]
1774#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1775pub struct MavenArtifact {
1776 /// Maven `artifactId` value used when uploading the artifact to Artifact Registry.
1777 #[serde(rename = "artifactId")]
1778 pub artifact_id: Option<String>,
1779 /// Optional. Path to a folder containing the files to upload to Artifact Registry. This can be either an absolute path, e.g. `/workspace/my-app/target/`, or a relative path from /workspace, e.g. `my-app/target/`. This field is mutually exclusive with the `path` field.
1780 #[serde(rename = "deployFolder")]
1781 pub deploy_folder: Option<String>,
1782 /// Maven `groupId` value used when uploading the artifact to Artifact Registry.
1783 #[serde(rename = "groupId")]
1784 pub group_id: Option<String>,
1785 /// Optional. 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.
1786 pub path: Option<String>,
1787 /// 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.
1788 pub repository: Option<String>,
1789 /// Maven `version` value used when uploading the artifact to Artifact Registry.
1790 pub version: Option<String>,
1791}
1792
1793impl common::Part for MavenArtifact {}
1794
1795/// Defines the network configuration for the pool.
1796///
1797/// This type is not used in any activity, and only used as *part* of another schema.
1798///
1799#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1800#[serde_with::serde_as]
1801#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1802pub struct NetworkConfig {
1803 /// Option to configure network egress for the workers.
1804 #[serde(rename = "egressOption")]
1805 pub egress_option: Option<String>,
1806 /// 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)
1807 #[serde(rename = "peeredNetwork")]
1808 pub peered_network: Option<String>,
1809 /// 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.
1810 #[serde(rename = "peeredNetworkIpRange")]
1811 pub peered_network_ip_range: Option<String>,
1812}
1813
1814impl common::Part for NetworkConfig {}
1815
1816/// Npm package to upload to Artifact Registry upon successful completion of all build steps.
1817///
1818/// This type is not used in any activity, and only used as *part* of another schema.
1819///
1820#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1821#[serde_with::serde_as]
1822#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1823pub struct NpmPackage {
1824 /// Optional. Path to the package.json. e.g. workspace/path/to/package Only one of `archive` or `package_path` can be specified.
1825 #[serde(rename = "packagePath")]
1826 pub package_path: Option<String>,
1827 /// 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.
1828 pub repository: Option<String>,
1829}
1830
1831impl common::Part for NpmPackage {}
1832
1833/// This resource represents a long-running operation that is the result of a network API call.
1834///
1835/// # Activities
1836///
1837/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1838/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1839///
1840/// * [cancel operations](OperationCancelCall) (none)
1841/// * [get operations](OperationGetCall) (response)
1842/// * [builds approve projects](ProjectBuildApproveCall) (response)
1843/// * [builds create projects](ProjectBuildCreateCall) (response)
1844/// * [builds retry projects](ProjectBuildRetryCall) (response)
1845/// * [github enterprise configs create projects](ProjectGithubEnterpriseConfigCreateCall) (response)
1846/// * [github enterprise configs delete projects](ProjectGithubEnterpriseConfigDeleteCall) (response)
1847/// * [github enterprise configs patch projects](ProjectGithubEnterpriseConfigPatchCall) (response)
1848/// * [locations bitbucket server configs connected repositories batch create projects](ProjectLocationBitbucketServerConfigConnectedRepositoryBatchCreateCall) (response)
1849/// * [locations bitbucket server configs create projects](ProjectLocationBitbucketServerConfigCreateCall) (response)
1850/// * [locations bitbucket server configs delete projects](ProjectLocationBitbucketServerConfigDeleteCall) (response)
1851/// * [locations bitbucket server configs patch projects](ProjectLocationBitbucketServerConfigPatchCall) (response)
1852/// * [locations builds approve projects](ProjectLocationBuildApproveCall) (response)
1853/// * [locations builds create projects](ProjectLocationBuildCreateCall) (response)
1854/// * [locations builds retry projects](ProjectLocationBuildRetryCall) (response)
1855/// * [locations git lab configs connected repositories batch create projects](ProjectLocationGitLabConfigConnectedRepositoryBatchCreateCall) (response)
1856/// * [locations git lab configs create projects](ProjectLocationGitLabConfigCreateCall) (response)
1857/// * [locations git lab configs delete projects](ProjectLocationGitLabConfigDeleteCall) (response)
1858/// * [locations git lab configs patch projects](ProjectLocationGitLabConfigPatchCall) (response)
1859/// * [locations github enterprise configs create projects](ProjectLocationGithubEnterpriseConfigCreateCall) (response)
1860/// * [locations github enterprise configs delete projects](ProjectLocationGithubEnterpriseConfigDeleteCall) (response)
1861/// * [locations github enterprise configs patch projects](ProjectLocationGithubEnterpriseConfigPatchCall) (response)
1862/// * [locations operations get projects](ProjectLocationOperationGetCall) (response)
1863/// * [locations triggers run projects](ProjectLocationTriggerRunCall) (response)
1864/// * [locations worker pools create projects](ProjectLocationWorkerPoolCreateCall) (response)
1865/// * [locations worker pools delete projects](ProjectLocationWorkerPoolDeleteCall) (response)
1866/// * [locations worker pools patch projects](ProjectLocationWorkerPoolPatchCall) (response)
1867/// * [triggers run projects](ProjectTriggerRunCall) (response)
1868#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1869#[serde_with::serde_as]
1870#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1871pub struct Operation {
1872 /// 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.
1873 pub done: Option<bool>,
1874 /// The error result of the operation in case of failure or cancellation.
1875 pub error: Option<Status>,
1876 /// 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.
1877 pub metadata: Option<HashMap<String, serde_json::Value>>,
1878 /// 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}`.
1879 pub name: Option<String>,
1880 /// 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`.
1881 pub response: Option<HashMap<String, serde_json::Value>>,
1882}
1883
1884impl common::Resource for Operation {}
1885impl common::ResponseResult for Operation {}
1886
1887/// 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.
1888///
1889/// This type is not used in any activity, and only used as *part* of another schema.
1890///
1891#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1892#[serde_with::serde_as]
1893#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1894pub struct PoolOption {
1895 /// 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}
1896 pub name: Option<String>,
1897}
1898
1899impl common::Part for PoolOption {}
1900
1901/// Configuration for a V1 `PrivatePool`.
1902///
1903/// This type is not used in any activity, and only used as *part* of another schema.
1904///
1905#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1906#[serde_with::serde_as]
1907#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1908pub struct PrivatePoolV1Config {
1909 /// Network configuration for the pool.
1910 #[serde(rename = "networkConfig")]
1911 pub network_config: Option<NetworkConfig>,
1912 /// Immutable. Private Service Connect(PSC) Network configuration for the pool.
1913 #[serde(rename = "privateServiceConnect")]
1914 pub private_service_connect: Option<PrivateServiceConnect>,
1915 /// Machine configuration for the workers in the pool.
1916 #[serde(rename = "workerConfig")]
1917 pub worker_config: Option<WorkerConfig>,
1918}
1919
1920impl common::Part for PrivatePoolV1Config {}
1921
1922/// Defines the Private Service Connect network configuration for the pool.
1923///
1924/// This type is not used in any activity, and only used as *part* of another schema.
1925///
1926#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1927#[serde_with::serde_as]
1928#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1929pub struct PrivateServiceConnect {
1930 /// Required. Immutable. The network attachment that the worker network interface is peered to. Must be in the format `projects/{project}/regions/{region}/networkAttachments/{networkAttachment}`. The region of network attachment must be the same as the worker pool. See [Network Attachments](https://cloud.google.com/vpc/docs/about-network-attachments)
1931 #[serde(rename = "networkAttachment")]
1932 pub network_attachment: Option<String>,
1933 /// Required. Immutable. Disable public IP on the primary network interface. If true, workers are created without any public address, which prevents network egress to public IPs unless a network proxy is configured. If false, workers are created with a public address which allows for public internet egress. The public address only applies to traffic through the primary network interface. If `route_all_traffic` is set to true, all traffic will go through the non-primary network interface, this boolean has no effect.
1934 #[serde(rename = "publicIpAddressDisabled")]
1935 pub public_ip_address_disabled: Option<bool>,
1936 /// Immutable. Route all traffic through PSC interface. Enable this if you want full control of traffic in the private pool. Configure Cloud NAT for the subnet of network attachment if you need to access public Internet. If false, Only route RFC 1918 (10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16) and RFC 6598 (100.64.0.0/10) through PSC interface.
1937 #[serde(rename = "routeAllTraffic")]
1938 pub route_all_traffic: Option<bool>,
1939}
1940
1941impl common::Part for PrivateServiceConnect {}
1942
1943/// PubsubConfig describes the configuration of a trigger that creates a build whenever a Pub/Sub message is published.
1944///
1945/// This type is not used in any activity, and only used as *part* of another schema.
1946///
1947#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1948#[serde_with::serde_as]
1949#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1950pub struct PubsubConfig {
1951 /// Service account that will make the push request.
1952 #[serde(rename = "serviceAccountEmail")]
1953 pub service_account_email: Option<String>,
1954 /// Potential issues with the underlying Pub/Sub subscription configuration. Only populated on get requests.
1955 pub state: Option<String>,
1956 /// Output only. Name of the subscription. Format is `projects/{project}/subscriptions/{subscription}`.
1957 pub subscription: Option<String>,
1958 /// Optional. The name of the topic from which this subscription is receiving messages. Format is `projects/{project}/topics/{topic}`.
1959 pub topic: Option<String>,
1960}
1961
1962impl common::Part for PubsubConfig {}
1963
1964/// PullRequestFilter contains filter properties for matching GitHub Pull Requests.
1965///
1966/// This type is not used in any activity, and only used as *part* of another schema.
1967///
1968#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1969#[serde_with::serde_as]
1970#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1971pub struct PullRequestFilter {
1972 /// 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
1973 pub branch: Option<String>,
1974 /// 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.
1975 #[serde(rename = "commentControl")]
1976 pub comment_control: Option<String>,
1977 /// If true, branches that do NOT match the git_ref will trigger a build.
1978 #[serde(rename = "invertRegex")]
1979 pub invert_regex: Option<bool>,
1980}
1981
1982impl common::Part for PullRequestFilter {}
1983
1984/// Push contains filter properties for matching GitHub git pushes.
1985///
1986/// This type is not used in any activity, and only used as *part* of another schema.
1987///
1988#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1989#[serde_with::serde_as]
1990#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1991pub struct PushFilter {
1992 /// 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
1993 pub branch: Option<String>,
1994 /// When true, only trigger a build if the revision regex does NOT match the git_ref regex.
1995 #[serde(rename = "invertRegex")]
1996 pub invert_regex: Option<bool>,
1997 /// 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
1998 pub tag: Option<String>,
1999}
2000
2001impl common::Part for PushFilter {}
2002
2003/// 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.
2004///
2005/// This type is not used in any activity, and only used as *part* of another schema.
2006///
2007#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2008#[serde_with::serde_as]
2009#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2010pub struct PythonPackage {
2011 /// Path globs used to match files in the build's workspace. For Python/ Twine, this is usually `dist/*`, and sometimes additionally an `.asc` file.
2012 pub paths: Option<Vec<String>>,
2013 /// 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.
2014 pub repository: Option<String>,
2015}
2016
2017impl common::Part for PythonPackage {}
2018
2019/// ReceiveTriggerWebhookResponse \[Experimental\] is the response object for the ReceiveTriggerWebhook method.
2020///
2021/// # Activities
2022///
2023/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2024/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2025///
2026/// * [locations triggers webhook projects](ProjectLocationTriggerWebhookCall) (response)
2027/// * [triggers webhook projects](ProjectTriggerWebhookCall) (response)
2028#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2029#[serde_with::serde_as]
2030#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2031pub struct ReceiveTriggerWebhookResponse {
2032 _never_set: Option<bool>,
2033}
2034
2035impl common::ResponseResult for ReceiveTriggerWebhookResponse {}
2036
2037/// RPC request object accepted by RemoveBitbucketServerConnectedRepository RPC method.
2038///
2039/// # Activities
2040///
2041/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2042/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2043///
2044/// * [locations bitbucket server configs remove bitbucket server connected repository projects](ProjectLocationBitbucketServerConfigRemoveBitbucketServerConnectedRepositoryCall) (request)
2045#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2046#[serde_with::serde_as]
2047#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2048pub struct RemoveBitbucketServerConnectedRepositoryRequest {
2049 /// The connected repository to remove.
2050 #[serde(rename = "connectedRepository")]
2051 pub connected_repository: Option<BitbucketServerRepositoryId>,
2052}
2053
2054impl common::RequestValue for RemoveBitbucketServerConnectedRepositoryRequest {}
2055
2056/// RPC request object accepted by RemoveGitLabConnectedRepository RPC method.
2057///
2058/// # Activities
2059///
2060/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2061/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2062///
2063/// * [locations git lab configs remove git lab connected repository projects](ProjectLocationGitLabConfigRemoveGitLabConnectedRepositoryCall) (request)
2064#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2065#[serde_with::serde_as]
2066#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2067pub struct RemoveGitLabConnectedRepositoryRequest {
2068 /// The connected repository to remove.
2069 #[serde(rename = "connectedRepository")]
2070 pub connected_repository: Option<GitLabRepositoryId>,
2071}
2072
2073impl common::RequestValue for RemoveGitLabConnectedRepositoryRequest {}
2074
2075/// Location of the source in a Google Cloud Source Repository.
2076///
2077/// # Activities
2078///
2079/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2080/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2081///
2082/// * [triggers run projects](ProjectTriggerRunCall) (request)
2083#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2084#[serde_with::serde_as]
2085#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2086pub struct RepoSource {
2087 /// 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
2088 #[serde(rename = "branchName")]
2089 pub branch_name: Option<String>,
2090 /// Explicit commit SHA to build.
2091 #[serde(rename = "commitSha")]
2092 pub commit_sha: Option<String>,
2093 /// 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.
2094 pub dir: Option<String>,
2095 /// Optional. Only trigger a build if the revision regex does NOT match the revision regex.
2096 #[serde(rename = "invertRegex")]
2097 pub invert_regex: Option<bool>,
2098 /// Optional. ID of the project that owns the Cloud Source Repository. If omitted, the project ID requesting the build is assumed.
2099 #[serde(rename = "projectId")]
2100 pub project_id: Option<String>,
2101 /// Required. Name of the Cloud Source Repository.
2102 #[serde(rename = "repoName")]
2103 pub repo_name: Option<String>,
2104 /// Optional. Substitutions to use in a triggered build. Should only be used with RunBuildTrigger
2105 pub substitutions: Option<HashMap<String, String>>,
2106 /// 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
2107 #[serde(rename = "tagName")]
2108 pub tag_name: Option<String>,
2109}
2110
2111impl common::RequestValue for RepoSource {}
2112
2113/// The configuration of a trigger that creates a build whenever an event from Repo API is received.
2114///
2115/// This type is not used in any activity, and only used as *part* of another schema.
2116///
2117#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2118#[serde_with::serde_as]
2119#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2120pub struct RepositoryEventConfig {
2121 /// Filter to match changes in pull requests.
2122 #[serde(rename = "pullRequest")]
2123 pub pull_request: Option<PullRequestFilter>,
2124 /// Filter to match changes in refs like branches, tags.
2125 pub push: Option<PushFilter>,
2126 /// The resource name of the Repo API resource.
2127 pub repository: Option<String>,
2128 /// Output only. The type of the SCM vendor the repository points to.
2129 #[serde(rename = "repositoryType")]
2130 pub repository_type: Option<String>,
2131}
2132
2133impl common::Part for RepositoryEventConfig {}
2134
2135/// Artifacts created by the build pipeline.
2136///
2137/// This type is not used in any activity, and only used as *part* of another schema.
2138///
2139#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2140#[serde_with::serde_as]
2141#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2142pub struct Results {
2143 /// Path to the artifact manifest for non-container artifacts uploaded to Cloud Storage. Only populated when artifacts are uploaded to Cloud Storage.
2144 #[serde(rename = "artifactManifest")]
2145 pub artifact_manifest: Option<String>,
2146 /// Time to push all non-container artifacts to Cloud Storage.
2147 #[serde(rename = "artifactTiming")]
2148 pub artifact_timing: Option<TimeSpan>,
2149 /// List of build step digests, in the order corresponding to build step indices.
2150 #[serde(rename = "buildStepImages")]
2151 pub build_step_images: Option<Vec<String>>,
2152 /// 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.
2153 #[serde(rename = "buildStepOutputs")]
2154 #[serde_as(as = "Option<Vec<common::serde::standard_base64::Wrapper>>")]
2155 pub build_step_outputs: Option<Vec<Vec<u8>>>,
2156 /// Optional. Go module artifacts uploaded to Artifact Registry at the end of the build.
2157 #[serde(rename = "goModules")]
2158 pub go_modules: Option<Vec<UploadedGoModule>>,
2159 /// Container images that were built as a part of the build.
2160 pub images: Option<Vec<BuiltImage>>,
2161 /// Maven artifacts uploaded to Artifact Registry at the end of the build.
2162 #[serde(rename = "mavenArtifacts")]
2163 pub maven_artifacts: Option<Vec<UploadedMavenArtifact>>,
2164 /// Npm packages uploaded to Artifact Registry at the end of the build.
2165 #[serde(rename = "npmPackages")]
2166 pub npm_packages: Option<Vec<UploadedNpmPackage>>,
2167 /// Number of non-container artifacts uploaded to Cloud Storage. Only populated when artifacts are uploaded to Cloud Storage.
2168 #[serde(rename = "numArtifacts")]
2169 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2170 pub num_artifacts: Option<i64>,
2171 /// Python artifacts uploaded to Artifact Registry at the end of the build.
2172 #[serde(rename = "pythonPackages")]
2173 pub python_packages: Option<Vec<UploadedPythonPackage>>,
2174}
2175
2176impl common::Part for Results {}
2177
2178/// Specifies a build to retry.
2179///
2180/// # Activities
2181///
2182/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2183/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2184///
2185/// * [builds retry projects](ProjectBuildRetryCall) (request)
2186/// * [locations builds retry projects](ProjectLocationBuildRetryCall) (request)
2187#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2188#[serde_with::serde_as]
2189#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2190pub struct RetryBuildRequest {
2191 /// Required. Build ID of the original build.
2192 pub id: Option<String>,
2193 /// The name of the `Build` to retry. Format: `projects/{project}/locations/{location}/builds/{build}`
2194 pub name: Option<String>,
2195 /// Required. ID of the project.
2196 #[serde(rename = "projectId")]
2197 pub project_id: Option<String>,
2198}
2199
2200impl common::RequestValue for RetryBuildRequest {}
2201
2202/// Specifies a build trigger to run and the source to use.
2203///
2204/// # Activities
2205///
2206/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2207/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2208///
2209/// * [locations triggers run projects](ProjectLocationTriggerRunCall) (request)
2210#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2211#[serde_with::serde_as]
2212#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2213pub struct RunBuildTriggerRequest {
2214 /// Required. ID of the project.
2215 #[serde(rename = "projectId")]
2216 pub project_id: Option<String>,
2217 /// Source to build against this trigger. Branch and tag names cannot consist of regular expressions.
2218 pub source: Option<RepoSource>,
2219 /// Required. ID of the trigger.
2220 #[serde(rename = "triggerId")]
2221 pub trigger_id: Option<String>,
2222}
2223
2224impl common::RequestValue for RunBuildTriggerRequest {}
2225
2226/// 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.
2227///
2228/// This type is not used in any activity, and only used as *part* of another schema.
2229///
2230#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2231#[serde_with::serde_as]
2232#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2233pub struct Secret {
2234 /// Cloud KMS key name to use to decrypt these envs.
2235 #[serde(rename = "kmsKeyName")]
2236 pub kms_key_name: Option<String>,
2237 /// 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.
2238 #[serde(rename = "secretEnv")]
2239 #[serde_as(as = "Option<HashMap<_, common::serde::standard_base64::Wrapper>>")]
2240 pub secret_env: Option<HashMap<String, Vec<u8>>>,
2241}
2242
2243impl common::Part for Secret {}
2244
2245/// Pairs a secret environment variable with a SecretVersion in Secret Manager.
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 SecretManagerSecret {
2253 /// 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.
2254 pub env: Option<String>,
2255 /// Resource name of the SecretVersion. In format: projects/*/secrets/*/versions/*
2256 #[serde(rename = "versionName")]
2257 pub version_name: Option<String>,
2258}
2259
2260impl common::Part for SecretManagerSecret {}
2261
2262/// Secrets and secret environment variables.
2263///
2264/// This type is not used in any activity, and only used as *part* of another schema.
2265///
2266#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2267#[serde_with::serde_as]
2268#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2269pub struct Secrets {
2270 /// Secrets encrypted with KMS key and the associated secret environment variable.
2271 pub inline: Option<Vec<InlineSecret>>,
2272 /// Secrets in Secret Manager and associated secret environment variable.
2273 #[serde(rename = "secretManager")]
2274 pub secret_manager: Option<Vec<SecretManagerSecret>>,
2275}
2276
2277impl common::Part for Secrets {}
2278
2279/// ServiceDirectoryConfig represents Service Directory configuration for a SCM host connection.
2280///
2281/// This type is not used in any activity, and only used as *part* of another schema.
2282///
2283#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2284#[serde_with::serde_as]
2285#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2286pub struct ServiceDirectoryConfig {
2287 /// The Service Directory service name. Format: projects/{project}/locations/{location}/namespaces/{namespace}/services/{service}.
2288 pub service: Option<String>,
2289}
2290
2291impl common::Part for ServiceDirectoryConfig {}
2292
2293/// Location of the source in a supported storage service.
2294///
2295/// This type is not used in any activity, and only used as *part* of another schema.
2296///
2297#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2298#[serde_with::serde_as]
2299#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2300pub struct Source {
2301 /// Optional. If provided, get the source from this 2nd-gen Google Cloud Build repository resource.
2302 #[serde(rename = "connectedRepository")]
2303 pub connected_repository: Option<ConnectedRepository>,
2304 /// If provided, get the source from this Developer Connect config.
2305 #[serde(rename = "developerConnectConfig")]
2306 pub developer_connect_config: Option<DeveloperConnectConfig>,
2307 /// If provided, get the source from this Git repository.
2308 #[serde(rename = "gitSource")]
2309 pub git_source: Option<GitSource>,
2310 /// If provided, get the source from this location in a Cloud Source Repository.
2311 #[serde(rename = "repoSource")]
2312 pub repo_source: Option<RepoSource>,
2313 /// If provided, get the source from this location in Cloud Storage.
2314 #[serde(rename = "storageSource")]
2315 pub storage_source: Option<StorageSource>,
2316 /// 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).
2317 #[serde(rename = "storageSourceManifest")]
2318 pub storage_source_manifest: Option<StorageSourceManifest>,
2319}
2320
2321impl common::Part for Source {}
2322
2323/// Provenance of the source. Ways to find the original source, or verify that some source was used for this build.
2324///
2325/// This type is not used in any activity, and only used as *part* of another schema.
2326///
2327#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2328#[serde_with::serde_as]
2329#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2330pub struct SourceProvenance {
2331 /// 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.
2332 #[serde(rename = "fileHashes")]
2333 pub file_hashes: Option<HashMap<String, FileHashes>>,
2334 /// Output only. A copy of the build's `source.connected_repository`, if exists, with any revisions resolved.
2335 #[serde(rename = "resolvedConnectedRepository")]
2336 pub resolved_connected_repository: Option<ConnectedRepository>,
2337 /// Output only. A copy of the build's `source.git_source`, if exists, with any revisions resolved.
2338 #[serde(rename = "resolvedGitSource")]
2339 pub resolved_git_source: Option<GitSource>,
2340 /// A copy of the build's `source.repo_source`, if exists, with any revisions resolved.
2341 #[serde(rename = "resolvedRepoSource")]
2342 pub resolved_repo_source: Option<RepoSource>,
2343 /// A copy of the build's `source.storage_source`, if exists, with any generations resolved.
2344 #[serde(rename = "resolvedStorageSource")]
2345 pub resolved_storage_source: Option<StorageSource>,
2346 /// A copy of the build's `source.storage_source_manifest`, if exists, with any revisions resolved. This feature is in Preview.
2347 #[serde(rename = "resolvedStorageSourceManifest")]
2348 pub resolved_storage_source_manifest: Option<StorageSourceManifest>,
2349}
2350
2351impl common::Part for SourceProvenance {}
2352
2353/// 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).
2354///
2355/// This type is not used in any activity, and only used as *part* of another schema.
2356///
2357#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2358#[serde_with::serde_as]
2359#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2360pub struct Status {
2361 /// The status code, which should be an enum value of google.rpc.Code.
2362 pub code: Option<i32>,
2363 /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
2364 pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
2365 /// 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.
2366 pub message: Option<String>,
2367}
2368
2369impl common::Part for Status {}
2370
2371/// Location of the source in an archive file in Cloud Storage.
2372///
2373/// This type is not used in any activity, and only used as *part* of another schema.
2374///
2375#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2376#[serde_with::serde_as]
2377#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2378pub struct StorageSource {
2379 /// Cloud Storage bucket containing the source (see [Bucket Name Requirements](https://cloud.google.com/storage/docs/bucket-naming#requirements)).
2380 pub bucket: Option<String>,
2381 /// Optional. Cloud Storage generation for the object. If the generation is omitted, the latest generation will be used.
2382 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2383 pub generation: Option<i64>,
2384 /// Required. Cloud Storage object containing the source. This object must be a zipped (`.zip`) or gzipped archive file (`.tar.gz`) containing source to build.
2385 pub object: Option<String>,
2386 /// Optional. Option to specify the tool to fetch the source file for the build.
2387 #[serde(rename = "sourceFetcher")]
2388 pub source_fetcher: Option<String>,
2389}
2390
2391impl common::Part for StorageSource {}
2392
2393/// 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).
2394///
2395/// This type is not used in any activity, and only used as *part* of another schema.
2396///
2397#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2398#[serde_with::serde_as]
2399#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2400pub struct StorageSourceManifest {
2401 /// Required. Cloud Storage bucket containing the source manifest (see [Bucket Name Requirements](https://cloud.google.com/storage/docs/bucket-naming#requirements)).
2402 pub bucket: Option<String>,
2403 /// Cloud Storage generation for the object. If the generation is omitted, the latest generation will be used.
2404 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2405 pub generation: Option<i64>,
2406 /// Required. Cloud Storage object containing the source manifest. This object must be a JSON file.
2407 pub object: Option<String>,
2408}
2409
2410impl common::Part for StorageSourceManifest {}
2411
2412/// Start and end times for a build execution phase.
2413///
2414/// This type is not used in any activity, and only used as *part* of another schema.
2415///
2416#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2417#[serde_with::serde_as]
2418#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2419pub struct TimeSpan {
2420 /// End of time span.
2421 #[serde(rename = "endTime")]
2422 pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2423 /// Start of time span.
2424 #[serde(rename = "startTime")]
2425 pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2426}
2427
2428impl common::Part for TimeSpan {}
2429
2430/// A Go module artifact uploaded to Artifact Registry using the GoModule directive.
2431///
2432/// This type is not used in any activity, and only used as *part* of another schema.
2433///
2434#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2435#[serde_with::serde_as]
2436#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2437pub struct UploadedGoModule {
2438 /// Output only. Path to the artifact in Artifact Registry.
2439 #[serde(rename = "artifactRegistryPackage")]
2440 pub artifact_registry_package: Option<String>,
2441 /// Hash types and values of the Go Module Artifact.
2442 #[serde(rename = "fileHashes")]
2443 pub file_hashes: Option<FileHashes>,
2444 /// Output only. Stores timing information for pushing the specified artifact.
2445 #[serde(rename = "pushTiming")]
2446 pub push_timing: Option<TimeSpan>,
2447 /// URI of the uploaded artifact.
2448 pub uri: Option<String>,
2449}
2450
2451impl common::Part for UploadedGoModule {}
2452
2453/// A Maven artifact uploaded using the MavenArtifact directive.
2454///
2455/// This type is not used in any activity, and only used as *part* of another schema.
2456///
2457#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2458#[serde_with::serde_as]
2459#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2460pub struct UploadedMavenArtifact {
2461 /// Output only. Path to the artifact in Artifact Registry.
2462 #[serde(rename = "artifactRegistryPackage")]
2463 pub artifact_registry_package: Option<String>,
2464 /// Hash types and values of the Maven Artifact.
2465 #[serde(rename = "fileHashes")]
2466 pub file_hashes: Option<FileHashes>,
2467 /// Output only. Stores timing information for pushing the specified artifact.
2468 #[serde(rename = "pushTiming")]
2469 pub push_timing: Option<TimeSpan>,
2470 /// URI of the uploaded artifact.
2471 pub uri: Option<String>,
2472}
2473
2474impl common::Part for UploadedMavenArtifact {}
2475
2476/// An npm package uploaded to Artifact Registry using the NpmPackage directive.
2477///
2478/// This type is not used in any activity, and only used as *part* of another schema.
2479///
2480#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2481#[serde_with::serde_as]
2482#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2483pub struct UploadedNpmPackage {
2484 /// Output only. Path to the artifact in Artifact Registry.
2485 #[serde(rename = "artifactRegistryPackage")]
2486 pub artifact_registry_package: Option<String>,
2487 /// Hash types and values of the npm package.
2488 #[serde(rename = "fileHashes")]
2489 pub file_hashes: Option<FileHashes>,
2490 /// Output only. Stores timing information for pushing the specified artifact.
2491 #[serde(rename = "pushTiming")]
2492 pub push_timing: Option<TimeSpan>,
2493 /// URI of the uploaded npm package.
2494 pub uri: Option<String>,
2495}
2496
2497impl common::Part for UploadedNpmPackage {}
2498
2499/// Artifact uploaded using the PythonPackage directive.
2500///
2501/// This type is not used in any activity, and only used as *part* of another schema.
2502///
2503#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2504#[serde_with::serde_as]
2505#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2506pub struct UploadedPythonPackage {
2507 /// Output only. Path to the artifact in Artifact Registry.
2508 #[serde(rename = "artifactRegistryPackage")]
2509 pub artifact_registry_package: Option<String>,
2510 /// Hash types and values of the Python Artifact.
2511 #[serde(rename = "fileHashes")]
2512 pub file_hashes: Option<FileHashes>,
2513 /// Output only. Stores timing information for pushing the specified artifact.
2514 #[serde(rename = "pushTiming")]
2515 pub push_timing: Option<TimeSpan>,
2516 /// URI of the uploaded artifact.
2517 pub uri: Option<String>,
2518}
2519
2520impl common::Part for UploadedPythonPackage {}
2521
2522/// Volume describes a Docker container volume which is mounted into build steps in order to persist files across build step execution.
2523///
2524/// This type is not used in any activity, and only used as *part* of another schema.
2525///
2526#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2527#[serde_with::serde_as]
2528#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2529pub struct Volume {
2530 /// 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.
2531 pub name: Option<String>,
2532 /// 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.
2533 pub path: Option<String>,
2534}
2535
2536impl common::Part for Volume {}
2537
2538/// A non-fatal problem encountered during the execution of the build.
2539///
2540/// This type is not used in any activity, and only used as *part* of another schema.
2541///
2542#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2543#[serde_with::serde_as]
2544#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2545pub struct Warning {
2546 /// The priority for this warning.
2547 pub priority: Option<String>,
2548 /// Explanation of the warning generated.
2549 pub text: Option<String>,
2550}
2551
2552impl common::Part for Warning {}
2553
2554/// WebhookConfig describes the configuration of a trigger that creates a build whenever a webhook is sent to a trigger's webhook URL.
2555///
2556/// This type is not used in any activity, and only used as *part* of another schema.
2557///
2558#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2559#[serde_with::serde_as]
2560#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2561pub struct WebhookConfig {
2562 /// Required. Resource name for the secret required as a URL parameter.
2563 pub secret: Option<String>,
2564 /// Potential issues with the underlying Pub/Sub subscription configuration. Only populated on get requests.
2565 pub state: Option<String>,
2566}
2567
2568impl common::Part for WebhookConfig {}
2569
2570/// Defines the configuration to be used for creating workers in the pool.
2571///
2572/// This type is not used in any activity, and only used as *part* of another schema.
2573///
2574#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2575#[serde_with::serde_as]
2576#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2577pub struct WorkerConfig {
2578 /// 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 4000. If `0` is specified, Cloud Build will use a standard disk size.
2579 #[serde(rename = "diskSizeGb")]
2580 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2581 pub disk_size_gb: Option<i64>,
2582 /// Optional. Enable nested virtualization on the worker, if supported by the machine type. By default, nested virtualization is disabled.
2583 #[serde(rename = "enableNestedVirtualization")]
2584 pub enable_nested_virtualization: Option<bool>,
2585 /// 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.
2586 #[serde(rename = "machineType")]
2587 pub machine_type: Option<String>,
2588}
2589
2590impl common::Part for WorkerConfig {}
2591
2592/// 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).
2593///
2594/// # Activities
2595///
2596/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2597/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2598///
2599/// * [locations worker pools create projects](ProjectLocationWorkerPoolCreateCall) (request)
2600/// * [locations worker pools get projects](ProjectLocationWorkerPoolGetCall) (response)
2601/// * [locations worker pools patch projects](ProjectLocationWorkerPoolPatchCall) (request)
2602#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2603#[serde_with::serde_as]
2604#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2605pub struct WorkerPool {
2606 /// User specified annotations. See https://google.aip.dev/128#annotations for more details such as format and size limitations.
2607 pub annotations: Option<HashMap<String, String>>,
2608 /// Output only. Time at which the request to create the `WorkerPool` was received.
2609 #[serde(rename = "createTime")]
2610 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2611 /// Output only. Time at which the request to delete the `WorkerPool` was received.
2612 #[serde(rename = "deleteTime")]
2613 pub delete_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2614 /// A user-specified, human-readable name for the `WorkerPool`. If provided, this value must be 1-63 characters.
2615 #[serde(rename = "displayName")]
2616 pub display_name: Option<String>,
2617 /// 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.
2618 pub etag: Option<String>,
2619 /// 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.
2620 pub name: Option<String>,
2621 /// Private Pool configuration.
2622 #[serde(rename = "privatePoolV1Config")]
2623 pub private_pool_v1_config: Option<PrivatePoolV1Config>,
2624 /// Output only. `WorkerPool` state.
2625 pub state: Option<String>,
2626 /// Output only. A unique identifier for the `WorkerPool`.
2627 pub uid: Option<String>,
2628 /// Output only. Time at which the request to update the `WorkerPool` was received.
2629 #[serde(rename = "updateTime")]
2630 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2631}
2632
2633impl common::RequestValue for WorkerPool {}
2634impl common::ResponseResult for WorkerPool {}
2635
2636// ###################
2637// MethodBuilders ###
2638// #################
2639
2640/// A builder providing access to all methods supported on *githubDotComWebhook* resources.
2641/// It is not used directly, but through the [`CloudBuild`] hub.
2642///
2643/// # Example
2644///
2645/// Instantiate a resource builder
2646///
2647/// ```test_harness,no_run
2648/// extern crate hyper;
2649/// extern crate hyper_rustls;
2650/// extern crate google_cloudbuild1 as cloudbuild1;
2651///
2652/// # async fn dox() {
2653/// use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2654///
2655/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2656/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2657/// .with_native_roots()
2658/// .unwrap()
2659/// .https_only()
2660/// .enable_http2()
2661/// .build();
2662///
2663/// let executor = hyper_util::rt::TokioExecutor::new();
2664/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2665/// secret,
2666/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2667/// yup_oauth2::client::CustomHyperClientBuilder::from(
2668/// hyper_util::client::legacy::Client::builder(executor).build(connector),
2669/// ),
2670/// ).build().await.unwrap();
2671///
2672/// let client = hyper_util::client::legacy::Client::builder(
2673/// hyper_util::rt::TokioExecutor::new()
2674/// )
2675/// .build(
2676/// hyper_rustls::HttpsConnectorBuilder::new()
2677/// .with_native_roots()
2678/// .unwrap()
2679/// .https_or_http()
2680/// .enable_http2()
2681/// .build()
2682/// );
2683/// let mut hub = CloudBuild::new(client, auth);
2684/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2685/// // like `receive(...)`
2686/// // to build up your call.
2687/// let rb = hub.github_dot_com_webhook();
2688/// # }
2689/// ```
2690pub struct GithubDotComWebhookMethods<'a, C>
2691where
2692 C: 'a,
2693{
2694 hub: &'a CloudBuild<C>,
2695}
2696
2697impl<'a, C> common::MethodsBuilder for GithubDotComWebhookMethods<'a, C> {}
2698
2699impl<'a, C> GithubDotComWebhookMethods<'a, C> {
2700 /// Create a builder to help you perform the following task:
2701 ///
2702 /// ReceiveGitHubDotComWebhook is called when the API receives a github.com webhook.
2703 ///
2704 /// # Arguments
2705 ///
2706 /// * `request` - No description provided.
2707 pub fn receive(&self, request: HttpBody) -> GithubDotComWebhookReceiveCall<'a, C> {
2708 GithubDotComWebhookReceiveCall {
2709 hub: self.hub,
2710 _request: request,
2711 _webhook_key: Default::default(),
2712 _delegate: Default::default(),
2713 _additional_params: Default::default(),
2714 }
2715 }
2716}
2717
2718/// A builder providing access to all methods supported on *location* resources.
2719/// It is not used directly, but through the [`CloudBuild`] hub.
2720///
2721/// # Example
2722///
2723/// Instantiate a resource builder
2724///
2725/// ```test_harness,no_run
2726/// extern crate hyper;
2727/// extern crate hyper_rustls;
2728/// extern crate google_cloudbuild1 as cloudbuild1;
2729///
2730/// # async fn dox() {
2731/// use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2732///
2733/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2734/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2735/// .with_native_roots()
2736/// .unwrap()
2737/// .https_only()
2738/// .enable_http2()
2739/// .build();
2740///
2741/// let executor = hyper_util::rt::TokioExecutor::new();
2742/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2743/// secret,
2744/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2745/// yup_oauth2::client::CustomHyperClientBuilder::from(
2746/// hyper_util::client::legacy::Client::builder(executor).build(connector),
2747/// ),
2748/// ).build().await.unwrap();
2749///
2750/// let client = hyper_util::client::legacy::Client::builder(
2751/// hyper_util::rt::TokioExecutor::new()
2752/// )
2753/// .build(
2754/// hyper_rustls::HttpsConnectorBuilder::new()
2755/// .with_native_roots()
2756/// .unwrap()
2757/// .https_or_http()
2758/// .enable_http2()
2759/// .build()
2760/// );
2761/// let mut hub = CloudBuild::new(client, auth);
2762/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2763/// // like `regional_webhook(...)`
2764/// // to build up your call.
2765/// let rb = hub.locations();
2766/// # }
2767/// ```
2768pub struct LocationMethods<'a, C>
2769where
2770 C: 'a,
2771{
2772 hub: &'a CloudBuild<C>,
2773}
2774
2775impl<'a, C> common::MethodsBuilder for LocationMethods<'a, C> {}
2776
2777impl<'a, C> LocationMethods<'a, C> {
2778 /// Create a builder to help you perform the following task:
2779 ///
2780 /// ReceiveRegionalWebhook is called when the API receives a regional GitHub webhook.
2781 ///
2782 /// # Arguments
2783 ///
2784 /// * `request` - No description provided.
2785 /// * `location` - Required. The location where the webhook should be sent.
2786 pub fn regional_webhook(
2787 &self,
2788 request: HttpBody,
2789 location: &str,
2790 ) -> LocationRegionalWebhookCall<'a, C> {
2791 LocationRegionalWebhookCall {
2792 hub: self.hub,
2793 _request: request,
2794 _location: location.to_string(),
2795 _webhook_key: Default::default(),
2796 _delegate: Default::default(),
2797 _additional_params: Default::default(),
2798 }
2799 }
2800}
2801
2802/// A builder providing access to all methods supported on *operation* resources.
2803/// It is not used directly, but through the [`CloudBuild`] hub.
2804///
2805/// # Example
2806///
2807/// Instantiate a resource builder
2808///
2809/// ```test_harness,no_run
2810/// extern crate hyper;
2811/// extern crate hyper_rustls;
2812/// extern crate google_cloudbuild1 as cloudbuild1;
2813///
2814/// # async fn dox() {
2815/// use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2816///
2817/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2818/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2819/// .with_native_roots()
2820/// .unwrap()
2821/// .https_only()
2822/// .enable_http2()
2823/// .build();
2824///
2825/// let executor = hyper_util::rt::TokioExecutor::new();
2826/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2827/// secret,
2828/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2829/// yup_oauth2::client::CustomHyperClientBuilder::from(
2830/// hyper_util::client::legacy::Client::builder(executor).build(connector),
2831/// ),
2832/// ).build().await.unwrap();
2833///
2834/// let client = hyper_util::client::legacy::Client::builder(
2835/// hyper_util::rt::TokioExecutor::new()
2836/// )
2837/// .build(
2838/// hyper_rustls::HttpsConnectorBuilder::new()
2839/// .with_native_roots()
2840/// .unwrap()
2841/// .https_or_http()
2842/// .enable_http2()
2843/// .build()
2844/// );
2845/// let mut hub = CloudBuild::new(client, auth);
2846/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2847/// // like `cancel(...)` and `get(...)`
2848/// // to build up your call.
2849/// let rb = hub.operations();
2850/// # }
2851/// ```
2852pub struct OperationMethods<'a, C>
2853where
2854 C: 'a,
2855{
2856 hub: &'a CloudBuild<C>,
2857}
2858
2859impl<'a, C> common::MethodsBuilder for OperationMethods<'a, C> {}
2860
2861impl<'a, C> OperationMethods<'a, C> {
2862 /// Create a builder to help you perform the following task:
2863 ///
2864 /// 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`.
2865 ///
2866 /// # Arguments
2867 ///
2868 /// * `request` - No description provided.
2869 /// * `name` - The name of the operation resource to be cancelled.
2870 pub fn cancel(
2871 &self,
2872 request: CancelOperationRequest,
2873 name: &str,
2874 ) -> OperationCancelCall<'a, C> {
2875 OperationCancelCall {
2876 hub: self.hub,
2877 _request: request,
2878 _name: name.to_string(),
2879 _delegate: Default::default(),
2880 _additional_params: Default::default(),
2881 _scopes: Default::default(),
2882 }
2883 }
2884
2885 /// Create a builder to help you perform the following task:
2886 ///
2887 /// 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.
2888 ///
2889 /// # Arguments
2890 ///
2891 /// * `name` - The name of the operation resource.
2892 pub fn get(&self, name: &str) -> OperationGetCall<'a, C> {
2893 OperationGetCall {
2894 hub: self.hub,
2895 _name: name.to_string(),
2896 _delegate: Default::default(),
2897 _additional_params: Default::default(),
2898 _scopes: Default::default(),
2899 }
2900 }
2901}
2902
2903/// A builder providing access to all methods supported on *project* resources.
2904/// It is not used directly, but through the [`CloudBuild`] hub.
2905///
2906/// # Example
2907///
2908/// Instantiate a resource builder
2909///
2910/// ```test_harness,no_run
2911/// extern crate hyper;
2912/// extern crate hyper_rustls;
2913/// extern crate google_cloudbuild1 as cloudbuild1;
2914///
2915/// # async fn dox() {
2916/// use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2917///
2918/// let secret: yup_oauth2::ApplicationSecret = Default::default();
2919/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
2920/// .with_native_roots()
2921/// .unwrap()
2922/// .https_only()
2923/// .enable_http2()
2924/// .build();
2925///
2926/// let executor = hyper_util::rt::TokioExecutor::new();
2927/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2928/// secret,
2929/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2930/// yup_oauth2::client::CustomHyperClientBuilder::from(
2931/// hyper_util::client::legacy::Client::builder(executor).build(connector),
2932/// ),
2933/// ).build().await.unwrap();
2934///
2935/// let client = hyper_util::client::legacy::Client::builder(
2936/// hyper_util::rt::TokioExecutor::new()
2937/// )
2938/// .build(
2939/// hyper_rustls::HttpsConnectorBuilder::new()
2940/// .with_native_roots()
2941/// .unwrap()
2942/// .https_or_http()
2943/// .enable_http2()
2944/// .build()
2945/// );
2946/// let mut hub = CloudBuild::new(client, auth);
2947/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
2948/// // 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(...)`
2949/// // to build up your call.
2950/// let rb = hub.projects();
2951/// # }
2952/// ```
2953pub struct ProjectMethods<'a, C>
2954where
2955 C: 'a,
2956{
2957 hub: &'a CloudBuild<C>,
2958}
2959
2960impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
2961
2962impl<'a, C> ProjectMethods<'a, C> {
2963 /// Create a builder to help you perform the following task:
2964 ///
2965 /// Approves or rejects a pending build. If approved, the returned long-running operation (LRO) will be analogous to the LRO returned from a CreateBuild call. If rejected, the returned LRO will be immediately done.
2966 ///
2967 /// # Arguments
2968 ///
2969 /// * `request` - No description provided.
2970 /// * `name` - Required. Name of the target build. For example: "projects/{$project_id}/builds/{$build_id}"
2971 pub fn builds_approve(
2972 &self,
2973 request: ApproveBuildRequest,
2974 name: &str,
2975 ) -> ProjectBuildApproveCall<'a, C> {
2976 ProjectBuildApproveCall {
2977 hub: self.hub,
2978 _request: request,
2979 _name: name.to_string(),
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 /// Cancels a build in progress.
2989 ///
2990 /// # Arguments
2991 ///
2992 /// * `request` - No description provided.
2993 /// * `projectId` - Required. ID of the project.
2994 /// * `id` - Required. ID of the build.
2995 pub fn builds_cancel(
2996 &self,
2997 request: CancelBuildRequest,
2998 project_id: &str,
2999 id: &str,
3000 ) -> ProjectBuildCancelCall<'a, C> {
3001 ProjectBuildCancelCall {
3002 hub: self.hub,
3003 _request: request,
3004 _project_id: project_id.to_string(),
3005 _id: id.to_string(),
3006 _delegate: Default::default(),
3007 _additional_params: Default::default(),
3008 _scopes: Default::default(),
3009 }
3010 }
3011
3012 /// Create a builder to help you perform the following task:
3013 ///
3014 /// 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`).
3015 ///
3016 /// # Arguments
3017 ///
3018 /// * `request` - No description provided.
3019 /// * `projectId` - Required. ID of the project.
3020 pub fn builds_create(&self, request: Build, project_id: &str) -> ProjectBuildCreateCall<'a, C> {
3021 ProjectBuildCreateCall {
3022 hub: self.hub,
3023 _request: request,
3024 _project_id: project_id.to_string(),
3025 _parent: Default::default(),
3026 _delegate: Default::default(),
3027 _additional_params: Default::default(),
3028 _scopes: Default::default(),
3029 }
3030 }
3031
3032 /// Create a builder to help you perform the following task:
3033 ///
3034 /// Returns information about a previously requested build. The `Build` that is returned includes its status (such as `SUCCESS`, `FAILURE`, or `WORKING`), and timing information.
3035 ///
3036 /// # Arguments
3037 ///
3038 /// * `projectId` - Required. ID of the project.
3039 /// * `id` - Required. ID of the build.
3040 pub fn builds_get(&self, project_id: &str, id: &str) -> ProjectBuildGetCall<'a, C> {
3041 ProjectBuildGetCall {
3042 hub: self.hub,
3043 _project_id: project_id.to_string(),
3044 _id: id.to_string(),
3045 _name: Default::default(),
3046 _delegate: Default::default(),
3047 _additional_params: Default::default(),
3048 _scopes: Default::default(),
3049 }
3050 }
3051
3052 /// Create a builder to help you perform the following task:
3053 ///
3054 /// Lists previously requested builds. Previously requested builds may still be in-progress, or may have finished successfully or unsuccessfully.
3055 ///
3056 /// # Arguments
3057 ///
3058 /// * `projectId` - Required. ID of the project.
3059 pub fn builds_list(&self, project_id: &str) -> ProjectBuildListCall<'a, C> {
3060 ProjectBuildListCall {
3061 hub: self.hub,
3062 _project_id: project_id.to_string(),
3063 _parent: Default::default(),
3064 _page_token: Default::default(),
3065 _page_size: Default::default(),
3066 _filter: Default::default(),
3067 _delegate: Default::default(),
3068 _additional_params: Default::default(),
3069 _scopes: Default::default(),
3070 }
3071 }
3072
3073 /// Create a builder to help you perform the following task:
3074 ///
3075 /// 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.
3076 ///
3077 /// # Arguments
3078 ///
3079 /// * `request` - No description provided.
3080 /// * `projectId` - Required. ID of the project.
3081 /// * `id` - Required. Build ID of the original build.
3082 pub fn builds_retry(
3083 &self,
3084 request: RetryBuildRequest,
3085 project_id: &str,
3086 id: &str,
3087 ) -> ProjectBuildRetryCall<'a, C> {
3088 ProjectBuildRetryCall {
3089 hub: self.hub,
3090 _request: request,
3091 _project_id: project_id.to_string(),
3092 _id: id.to_string(),
3093 _delegate: Default::default(),
3094 _additional_params: Default::default(),
3095 _scopes: Default::default(),
3096 }
3097 }
3098
3099 /// Create a builder to help you perform the following task:
3100 ///
3101 /// Create an association between a GCP project and a GitHub Enterprise server.
3102 ///
3103 /// # Arguments
3104 ///
3105 /// * `request` - No description provided.
3106 /// * `parent` - Name of the parent project. For example: projects/{$project_number} or projects/{$project_id}
3107 pub fn github_enterprise_configs_create(
3108 &self,
3109 request: GitHubEnterpriseConfig,
3110 parent: &str,
3111 ) -> ProjectGithubEnterpriseConfigCreateCall<'a, C> {
3112 ProjectGithubEnterpriseConfigCreateCall {
3113 hub: self.hub,
3114 _request: request,
3115 _parent: parent.to_string(),
3116 _project_id: Default::default(),
3117 _ghe_config_id: Default::default(),
3118 _delegate: Default::default(),
3119 _additional_params: Default::default(),
3120 _scopes: Default::default(),
3121 }
3122 }
3123
3124 /// Create a builder to help you perform the following task:
3125 ///
3126 /// Delete an association between a GCP project and a GitHub Enterprise server.
3127 ///
3128 /// # Arguments
3129 ///
3130 /// * `name` - This field should contain the name of the enterprise config resource. For example: "projects/{$project_id}/locations/{$location_id}/githubEnterpriseConfigs/{$config_id}"
3131 pub fn github_enterprise_configs_delete(
3132 &self,
3133 name: &str,
3134 ) -> ProjectGithubEnterpriseConfigDeleteCall<'a, C> {
3135 ProjectGithubEnterpriseConfigDeleteCall {
3136 hub: self.hub,
3137 _name: name.to_string(),
3138 _project_id: Default::default(),
3139 _config_id: Default::default(),
3140 _delegate: Default::default(),
3141 _additional_params: Default::default(),
3142 _scopes: Default::default(),
3143 }
3144 }
3145
3146 /// Create a builder to help you perform the following task:
3147 ///
3148 /// Retrieve a GitHubEnterpriseConfig.
3149 ///
3150 /// # Arguments
3151 ///
3152 /// * `name` - This field should contain the name of the enterprise config resource. For example: "projects/{$project_id}/locations/{$location_id}/githubEnterpriseConfigs/{$config_id}"
3153 pub fn github_enterprise_configs_get(
3154 &self,
3155 name: &str,
3156 ) -> ProjectGithubEnterpriseConfigGetCall<'a, C> {
3157 ProjectGithubEnterpriseConfigGetCall {
3158 hub: self.hub,
3159 _name: name.to_string(),
3160 _project_id: Default::default(),
3161 _config_id: Default::default(),
3162 _delegate: Default::default(),
3163 _additional_params: Default::default(),
3164 _scopes: Default::default(),
3165 }
3166 }
3167
3168 /// Create a builder to help you perform the following task:
3169 ///
3170 /// List all GitHubEnterpriseConfigs for a given project.
3171 ///
3172 /// # Arguments
3173 ///
3174 /// * `parent` - Name of the parent project. For example: projects/{$project_number} or projects/{$project_id}
3175 pub fn github_enterprise_configs_list(
3176 &self,
3177 parent: &str,
3178 ) -> ProjectGithubEnterpriseConfigListCall<'a, C> {
3179 ProjectGithubEnterpriseConfigListCall {
3180 hub: self.hub,
3181 _parent: parent.to_string(),
3182 _project_id: Default::default(),
3183 _delegate: Default::default(),
3184 _additional_params: Default::default(),
3185 _scopes: Default::default(),
3186 }
3187 }
3188
3189 /// Create a builder to help you perform the following task:
3190 ///
3191 /// Update an association between a GCP project and a GitHub Enterprise server.
3192 ///
3193 /// # Arguments
3194 ///
3195 /// * `request` - No description provided.
3196 /// * `name` - The full resource name for the GitHubEnterpriseConfig For example: "projects/{$project_id}/locations/{$location_id}/githubEnterpriseConfigs/{$config_id}"
3197 pub fn github_enterprise_configs_patch(
3198 &self,
3199 request: GitHubEnterpriseConfig,
3200 name: &str,
3201 ) -> ProjectGithubEnterpriseConfigPatchCall<'a, C> {
3202 ProjectGithubEnterpriseConfigPatchCall {
3203 hub: self.hub,
3204 _request: request,
3205 _name: name.to_string(),
3206 _update_mask: Default::default(),
3207 _delegate: Default::default(),
3208 _additional_params: Default::default(),
3209 _scopes: Default::default(),
3210 }
3211 }
3212
3213 /// Create a builder to help you perform the following task:
3214 ///
3215 /// Batch connecting Bitbucket Server repositories to Cloud Build.
3216 ///
3217 /// # Arguments
3218 ///
3219 /// * `request` - No description provided.
3220 /// * `parent` - The name of the `BitbucketServerConfig` that added connected repository. Format: `projects/{project}/locations/{location}/bitbucketServerConfigs/{config}`
3221 pub fn locations_bitbucket_server_configs_connected_repositories_batch_create(
3222 &self,
3223 request: BatchCreateBitbucketServerConnectedRepositoriesRequest,
3224 parent: &str,
3225 ) -> ProjectLocationBitbucketServerConfigConnectedRepositoryBatchCreateCall<'a, C> {
3226 ProjectLocationBitbucketServerConfigConnectedRepositoryBatchCreateCall {
3227 hub: self.hub,
3228 _request: request,
3229 _parent: parent.to_string(),
3230 _delegate: Default::default(),
3231 _additional_params: Default::default(),
3232 _scopes: Default::default(),
3233 }
3234 }
3235
3236 /// Create a builder to help you perform the following task:
3237 ///
3238 /// List all repositories for a given `BitbucketServerConfig`. This API is experimental.
3239 ///
3240 /// # Arguments
3241 ///
3242 /// * `parent` - Required. Name of the parent resource.
3243 pub fn locations_bitbucket_server_configs_repos_list(
3244 &self,
3245 parent: &str,
3246 ) -> ProjectLocationBitbucketServerConfigRepoListCall<'a, C> {
3247 ProjectLocationBitbucketServerConfigRepoListCall {
3248 hub: self.hub,
3249 _parent: parent.to_string(),
3250 _page_token: Default::default(),
3251 _page_size: Default::default(),
3252 _delegate: Default::default(),
3253 _additional_params: Default::default(),
3254 _scopes: Default::default(),
3255 }
3256 }
3257
3258 /// Create a builder to help you perform the following task:
3259 ///
3260 /// Creates a new `BitbucketServerConfig`. This API is experimental.
3261 ///
3262 /// # Arguments
3263 ///
3264 /// * `request` - No description provided.
3265 /// * `parent` - Required. Name of the parent resource.
3266 pub fn locations_bitbucket_server_configs_create(
3267 &self,
3268 request: BitbucketServerConfig,
3269 parent: &str,
3270 ) -> ProjectLocationBitbucketServerConfigCreateCall<'a, C> {
3271 ProjectLocationBitbucketServerConfigCreateCall {
3272 hub: self.hub,
3273 _request: request,
3274 _parent: parent.to_string(),
3275 _bitbucket_server_config_id: Default::default(),
3276 _delegate: Default::default(),
3277 _additional_params: Default::default(),
3278 _scopes: Default::default(),
3279 }
3280 }
3281
3282 /// Create a builder to help you perform the following task:
3283 ///
3284 /// Delete a `BitbucketServerConfig`. This API is experimental.
3285 ///
3286 /// # Arguments
3287 ///
3288 /// * `name` - Required. The config resource name.
3289 pub fn locations_bitbucket_server_configs_delete(
3290 &self,
3291 name: &str,
3292 ) -> ProjectLocationBitbucketServerConfigDeleteCall<'a, C> {
3293 ProjectLocationBitbucketServerConfigDeleteCall {
3294 hub: self.hub,
3295 _name: name.to_string(),
3296 _delegate: Default::default(),
3297 _additional_params: Default::default(),
3298 _scopes: Default::default(),
3299 }
3300 }
3301
3302 /// Create a builder to help you perform the following task:
3303 ///
3304 /// Retrieve a `BitbucketServerConfig`. This API is experimental.
3305 ///
3306 /// # Arguments
3307 ///
3308 /// * `name` - Required. The config resource name.
3309 pub fn locations_bitbucket_server_configs_get(
3310 &self,
3311 name: &str,
3312 ) -> ProjectLocationBitbucketServerConfigGetCall<'a, C> {
3313 ProjectLocationBitbucketServerConfigGetCall {
3314 hub: self.hub,
3315 _name: name.to_string(),
3316 _delegate: Default::default(),
3317 _additional_params: Default::default(),
3318 _scopes: Default::default(),
3319 }
3320 }
3321
3322 /// Create a builder to help you perform the following task:
3323 ///
3324 /// List all `BitbucketServerConfigs` for a given project. This API is experimental.
3325 ///
3326 /// # Arguments
3327 ///
3328 /// * `parent` - Required. Name of the parent resource.
3329 pub fn locations_bitbucket_server_configs_list(
3330 &self,
3331 parent: &str,
3332 ) -> ProjectLocationBitbucketServerConfigListCall<'a, C> {
3333 ProjectLocationBitbucketServerConfigListCall {
3334 hub: self.hub,
3335 _parent: parent.to_string(),
3336 _page_token: Default::default(),
3337 _page_size: Default::default(),
3338 _delegate: Default::default(),
3339 _additional_params: Default::default(),
3340 _scopes: Default::default(),
3341 }
3342 }
3343
3344 /// Create a builder to help you perform the following task:
3345 ///
3346 /// Updates an existing `BitbucketServerConfig`. This API is experimental.
3347 ///
3348 /// # Arguments
3349 ///
3350 /// * `request` - No description provided.
3351 /// * `name` - The resource name for the config.
3352 pub fn locations_bitbucket_server_configs_patch(
3353 &self,
3354 request: BitbucketServerConfig,
3355 name: &str,
3356 ) -> ProjectLocationBitbucketServerConfigPatchCall<'a, C> {
3357 ProjectLocationBitbucketServerConfigPatchCall {
3358 hub: self.hub,
3359 _request: request,
3360 _name: name.to_string(),
3361 _update_mask: Default::default(),
3362 _delegate: Default::default(),
3363 _additional_params: Default::default(),
3364 _scopes: Default::default(),
3365 }
3366 }
3367
3368 /// Create a builder to help you perform the following task:
3369 ///
3370 /// Remove a Bitbucket Server repository from a given BitbucketServerConfig's connected repositories. This API is experimental.
3371 ///
3372 /// # Arguments
3373 ///
3374 /// * `request` - No description provided.
3375 /// * `config` - Required. The name of the `BitbucketServerConfig` to remove a connected repository. Format: `projects/{project}/locations/{location}/bitbucketServerConfigs/{config}`
3376 pub fn locations_bitbucket_server_configs_remove_bitbucket_server_connected_repository(
3377 &self,
3378 request: RemoveBitbucketServerConnectedRepositoryRequest,
3379 config: &str,
3380 ) -> ProjectLocationBitbucketServerConfigRemoveBitbucketServerConnectedRepositoryCall<'a, C>
3381 {
3382 ProjectLocationBitbucketServerConfigRemoveBitbucketServerConnectedRepositoryCall {
3383 hub: self.hub,
3384 _request: request,
3385 _config: config.to_string(),
3386 _delegate: Default::default(),
3387 _additional_params: Default::default(),
3388 _scopes: Default::default(),
3389 }
3390 }
3391
3392 /// Create a builder to help you perform the following task:
3393 ///
3394 /// Approves or rejects a pending build. If approved, the returned long-running operation (LRO) will be analogous to the LRO returned from a CreateBuild call. If rejected, the returned LRO will be immediately done.
3395 ///
3396 /// # Arguments
3397 ///
3398 /// * `request` - No description provided.
3399 /// * `name` - Required. Name of the target build. For example: "projects/{$project_id}/builds/{$build_id}"
3400 pub fn locations_builds_approve(
3401 &self,
3402 request: ApproveBuildRequest,
3403 name: &str,
3404 ) -> ProjectLocationBuildApproveCall<'a, C> {
3405 ProjectLocationBuildApproveCall {
3406 hub: self.hub,
3407 _request: request,
3408 _name: name.to_string(),
3409 _delegate: Default::default(),
3410 _additional_params: Default::default(),
3411 _scopes: Default::default(),
3412 }
3413 }
3414
3415 /// Create a builder to help you perform the following task:
3416 ///
3417 /// Cancels a build in progress.
3418 ///
3419 /// # Arguments
3420 ///
3421 /// * `request` - No description provided.
3422 /// * `name` - The name of the `Build` to cancel. Format: `projects/{project}/locations/{location}/builds/{build}`
3423 pub fn locations_builds_cancel(
3424 &self,
3425 request: CancelBuildRequest,
3426 name: &str,
3427 ) -> ProjectLocationBuildCancelCall<'a, C> {
3428 ProjectLocationBuildCancelCall {
3429 hub: self.hub,
3430 _request: request,
3431 _name: name.to_string(),
3432 _delegate: Default::default(),
3433 _additional_params: Default::default(),
3434 _scopes: Default::default(),
3435 }
3436 }
3437
3438 /// Create a builder to help you perform the following task:
3439 ///
3440 /// 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`).
3441 ///
3442 /// # Arguments
3443 ///
3444 /// * `request` - No description provided.
3445 /// * `parent` - The parent resource where this build will be created. Format: `projects/{project}/locations/{location}`
3446 pub fn locations_builds_create(
3447 &self,
3448 request: Build,
3449 parent: &str,
3450 ) -> ProjectLocationBuildCreateCall<'a, C> {
3451 ProjectLocationBuildCreateCall {
3452 hub: self.hub,
3453 _request: request,
3454 _parent: parent.to_string(),
3455 _project_id: Default::default(),
3456 _delegate: Default::default(),
3457 _additional_params: Default::default(),
3458 _scopes: Default::default(),
3459 }
3460 }
3461
3462 /// Create a builder to help you perform the following task:
3463 ///
3464 /// Returns information about a previously requested build. The `Build` that is returned includes its status (such as `SUCCESS`, `FAILURE`, or `WORKING`), and timing information.
3465 ///
3466 /// # Arguments
3467 ///
3468 /// * `name` - The name of the `Build` to retrieve. Format: `projects/{project}/locations/{location}/builds/{build}`
3469 pub fn locations_builds_get(&self, name: &str) -> ProjectLocationBuildGetCall<'a, C> {
3470 ProjectLocationBuildGetCall {
3471 hub: self.hub,
3472 _name: name.to_string(),
3473 _project_id: Default::default(),
3474 _id: Default::default(),
3475 _delegate: Default::default(),
3476 _additional_params: Default::default(),
3477 _scopes: Default::default(),
3478 }
3479 }
3480
3481 /// Create a builder to help you perform the following task:
3482 ///
3483 /// Lists previously requested builds. Previously requested builds may still be in-progress, or may have finished successfully or unsuccessfully.
3484 ///
3485 /// # Arguments
3486 ///
3487 /// * `parent` - The parent of the collection of `Builds`. Format: `projects/{project}/locations/{location}`
3488 pub fn locations_builds_list(&self, parent: &str) -> ProjectLocationBuildListCall<'a, C> {
3489 ProjectLocationBuildListCall {
3490 hub: self.hub,
3491 _parent: parent.to_string(),
3492 _project_id: Default::default(),
3493 _page_token: Default::default(),
3494 _page_size: Default::default(),
3495 _filter: Default::default(),
3496 _delegate: Default::default(),
3497 _additional_params: Default::default(),
3498 _scopes: Default::default(),
3499 }
3500 }
3501
3502 /// Create a builder to help you perform the following task:
3503 ///
3504 /// 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.
3505 ///
3506 /// # Arguments
3507 ///
3508 /// * `request` - No description provided.
3509 /// * `name` - The name of the `Build` to retry. Format: `projects/{project}/locations/{location}/builds/{build}`
3510 pub fn locations_builds_retry(
3511 &self,
3512 request: RetryBuildRequest,
3513 name: &str,
3514 ) -> ProjectLocationBuildRetryCall<'a, C> {
3515 ProjectLocationBuildRetryCall {
3516 hub: self.hub,
3517 _request: request,
3518 _name: name.to_string(),
3519 _delegate: Default::default(),
3520 _additional_params: Default::default(),
3521 _scopes: Default::default(),
3522 }
3523 }
3524
3525 /// Create a builder to help you perform the following task:
3526 ///
3527 /// Batch connecting GitLab repositories to Cloud Build. This API is experimental.
3528 ///
3529 /// # Arguments
3530 ///
3531 /// * `request` - No description provided.
3532 /// * `parent` - The name of the `GitLabConfig` that adds connected repositories. Format: `projects/{project}/locations/{location}/gitLabConfigs/{config}`
3533 pub fn locations_git_lab_configs_connected_repositories_batch_create(
3534 &self,
3535 request: BatchCreateGitLabConnectedRepositoriesRequest,
3536 parent: &str,
3537 ) -> ProjectLocationGitLabConfigConnectedRepositoryBatchCreateCall<'a, C> {
3538 ProjectLocationGitLabConfigConnectedRepositoryBatchCreateCall {
3539 hub: self.hub,
3540 _request: request,
3541 _parent: parent.to_string(),
3542 _delegate: Default::default(),
3543 _additional_params: Default::default(),
3544 _scopes: Default::default(),
3545 }
3546 }
3547
3548 /// Create a builder to help you perform the following task:
3549 ///
3550 /// List all repositories for a given `GitLabConfig`. This API is experimental
3551 ///
3552 /// # Arguments
3553 ///
3554 /// * `parent` - Required. Name of the parent resource.
3555 pub fn locations_git_lab_configs_repos_list(
3556 &self,
3557 parent: &str,
3558 ) -> ProjectLocationGitLabConfigRepoListCall<'a, C> {
3559 ProjectLocationGitLabConfigRepoListCall {
3560 hub: self.hub,
3561 _parent: parent.to_string(),
3562 _page_token: Default::default(),
3563 _page_size: Default::default(),
3564 _delegate: Default::default(),
3565 _additional_params: Default::default(),
3566 _scopes: Default::default(),
3567 }
3568 }
3569
3570 /// Create a builder to help you perform the following task:
3571 ///
3572 /// Creates a new `GitLabConfig`. This API is experimental
3573 ///
3574 /// # Arguments
3575 ///
3576 /// * `request` - No description provided.
3577 /// * `parent` - Required. Name of the parent resource.
3578 pub fn locations_git_lab_configs_create(
3579 &self,
3580 request: GitLabConfig,
3581 parent: &str,
3582 ) -> ProjectLocationGitLabConfigCreateCall<'a, C> {
3583 ProjectLocationGitLabConfigCreateCall {
3584 hub: self.hub,
3585 _request: request,
3586 _parent: parent.to_string(),
3587 _gitlab_config_id: Default::default(),
3588 _delegate: Default::default(),
3589 _additional_params: Default::default(),
3590 _scopes: Default::default(),
3591 }
3592 }
3593
3594 /// Create a builder to help you perform the following task:
3595 ///
3596 /// Delete a `GitLabConfig`. This API is experimental
3597 ///
3598 /// # Arguments
3599 ///
3600 /// * `name` - Required. The config resource name.
3601 pub fn locations_git_lab_configs_delete(
3602 &self,
3603 name: &str,
3604 ) -> ProjectLocationGitLabConfigDeleteCall<'a, C> {
3605 ProjectLocationGitLabConfigDeleteCall {
3606 hub: self.hub,
3607 _name: name.to_string(),
3608 _delegate: Default::default(),
3609 _additional_params: Default::default(),
3610 _scopes: Default::default(),
3611 }
3612 }
3613
3614 /// Create a builder to help you perform the following task:
3615 ///
3616 /// Retrieves a `GitLabConfig`. This API is experimental
3617 ///
3618 /// # Arguments
3619 ///
3620 /// * `name` - Required. The config resource name.
3621 pub fn locations_git_lab_configs_get(
3622 &self,
3623 name: &str,
3624 ) -> ProjectLocationGitLabConfigGetCall<'a, C> {
3625 ProjectLocationGitLabConfigGetCall {
3626 hub: self.hub,
3627 _name: name.to_string(),
3628 _delegate: Default::default(),
3629 _additional_params: Default::default(),
3630 _scopes: Default::default(),
3631 }
3632 }
3633
3634 /// Create a builder to help you perform the following task:
3635 ///
3636 /// List all `GitLabConfigs` for a given project. This API is experimental
3637 ///
3638 /// # Arguments
3639 ///
3640 /// * `parent` - Required. Name of the parent resource
3641 pub fn locations_git_lab_configs_list(
3642 &self,
3643 parent: &str,
3644 ) -> ProjectLocationGitLabConfigListCall<'a, C> {
3645 ProjectLocationGitLabConfigListCall {
3646 hub: self.hub,
3647 _parent: parent.to_string(),
3648 _page_token: Default::default(),
3649 _page_size: Default::default(),
3650 _delegate: Default::default(),
3651 _additional_params: Default::default(),
3652 _scopes: Default::default(),
3653 }
3654 }
3655
3656 /// Create a builder to help you perform the following task:
3657 ///
3658 /// Updates an existing `GitLabConfig`. This API is experimental
3659 ///
3660 /// # Arguments
3661 ///
3662 /// * `request` - No description provided.
3663 /// * `name` - The resource name for the config.
3664 pub fn locations_git_lab_configs_patch(
3665 &self,
3666 request: GitLabConfig,
3667 name: &str,
3668 ) -> ProjectLocationGitLabConfigPatchCall<'a, C> {
3669 ProjectLocationGitLabConfigPatchCall {
3670 hub: self.hub,
3671 _request: request,
3672 _name: name.to_string(),
3673 _update_mask: Default::default(),
3674 _delegate: Default::default(),
3675 _additional_params: Default::default(),
3676 _scopes: Default::default(),
3677 }
3678 }
3679
3680 /// Create a builder to help you perform the following task:
3681 ///
3682 /// Remove a GitLab repository from a given GitLabConfig's connected repositories. This API is experimental.
3683 ///
3684 /// # Arguments
3685 ///
3686 /// * `request` - No description provided.
3687 /// * `config` - Required. The name of the `GitLabConfig` to remove a connected repository. Format: `projects/{project}/locations/{location}/gitLabConfigs/{config}`
3688 pub fn locations_git_lab_configs_remove_git_lab_connected_repository(
3689 &self,
3690 request: RemoveGitLabConnectedRepositoryRequest,
3691 config: &str,
3692 ) -> ProjectLocationGitLabConfigRemoveGitLabConnectedRepositoryCall<'a, C> {
3693 ProjectLocationGitLabConfigRemoveGitLabConnectedRepositoryCall {
3694 hub: self.hub,
3695 _request: request,
3696 _config: config.to_string(),
3697 _delegate: Default::default(),
3698 _additional_params: Default::default(),
3699 _scopes: Default::default(),
3700 }
3701 }
3702
3703 /// Create a builder to help you perform the following task:
3704 ///
3705 /// Create an association between a GCP project and a GitHub Enterprise server.
3706 ///
3707 /// # Arguments
3708 ///
3709 /// * `request` - No description provided.
3710 /// * `parent` - Name of the parent project. For example: projects/{$project_number} or projects/{$project_id}
3711 pub fn locations_github_enterprise_configs_create(
3712 &self,
3713 request: GitHubEnterpriseConfig,
3714 parent: &str,
3715 ) -> ProjectLocationGithubEnterpriseConfigCreateCall<'a, C> {
3716 ProjectLocationGithubEnterpriseConfigCreateCall {
3717 hub: self.hub,
3718 _request: request,
3719 _parent: parent.to_string(),
3720 _project_id: Default::default(),
3721 _ghe_config_id: Default::default(),
3722 _delegate: Default::default(),
3723 _additional_params: Default::default(),
3724 _scopes: Default::default(),
3725 }
3726 }
3727
3728 /// Create a builder to help you perform the following task:
3729 ///
3730 /// Delete an association between a GCP project and a GitHub Enterprise server.
3731 ///
3732 /// # Arguments
3733 ///
3734 /// * `name` - This field should contain the name of the enterprise config resource. For example: "projects/{$project_id}/locations/{$location_id}/githubEnterpriseConfigs/{$config_id}"
3735 pub fn locations_github_enterprise_configs_delete(
3736 &self,
3737 name: &str,
3738 ) -> ProjectLocationGithubEnterpriseConfigDeleteCall<'a, C> {
3739 ProjectLocationGithubEnterpriseConfigDeleteCall {
3740 hub: self.hub,
3741 _name: name.to_string(),
3742 _project_id: Default::default(),
3743 _config_id: Default::default(),
3744 _delegate: Default::default(),
3745 _additional_params: Default::default(),
3746 _scopes: Default::default(),
3747 }
3748 }
3749
3750 /// Create a builder to help you perform the following task:
3751 ///
3752 /// Retrieve a GitHubEnterpriseConfig.
3753 ///
3754 /// # Arguments
3755 ///
3756 /// * `name` - This field should contain the name of the enterprise config resource. For example: "projects/{$project_id}/locations/{$location_id}/githubEnterpriseConfigs/{$config_id}"
3757 pub fn locations_github_enterprise_configs_get(
3758 &self,
3759 name: &str,
3760 ) -> ProjectLocationGithubEnterpriseConfigGetCall<'a, C> {
3761 ProjectLocationGithubEnterpriseConfigGetCall {
3762 hub: self.hub,
3763 _name: name.to_string(),
3764 _project_id: Default::default(),
3765 _config_id: Default::default(),
3766 _delegate: Default::default(),
3767 _additional_params: Default::default(),
3768 _scopes: Default::default(),
3769 }
3770 }
3771
3772 /// Create a builder to help you perform the following task:
3773 ///
3774 /// List all GitHubEnterpriseConfigs for a given project.
3775 ///
3776 /// # Arguments
3777 ///
3778 /// * `parent` - Name of the parent project. For example: projects/{$project_number} or projects/{$project_id}
3779 pub fn locations_github_enterprise_configs_list(
3780 &self,
3781 parent: &str,
3782 ) -> ProjectLocationGithubEnterpriseConfigListCall<'a, C> {
3783 ProjectLocationGithubEnterpriseConfigListCall {
3784 hub: self.hub,
3785 _parent: parent.to_string(),
3786 _project_id: Default::default(),
3787 _delegate: Default::default(),
3788 _additional_params: Default::default(),
3789 _scopes: Default::default(),
3790 }
3791 }
3792
3793 /// Create a builder to help you perform the following task:
3794 ///
3795 /// Update an association between a GCP project and a GitHub Enterprise server.
3796 ///
3797 /// # Arguments
3798 ///
3799 /// * `request` - No description provided.
3800 /// * `name` - The full resource name for the GitHubEnterpriseConfig For example: "projects/{$project_id}/locations/{$location_id}/githubEnterpriseConfigs/{$config_id}"
3801 pub fn locations_github_enterprise_configs_patch(
3802 &self,
3803 request: GitHubEnterpriseConfig,
3804 name: &str,
3805 ) -> ProjectLocationGithubEnterpriseConfigPatchCall<'a, C> {
3806 ProjectLocationGithubEnterpriseConfigPatchCall {
3807 hub: self.hub,
3808 _request: request,
3809 _name: name.to_string(),
3810 _update_mask: Default::default(),
3811 _delegate: Default::default(),
3812 _additional_params: Default::default(),
3813 _scopes: Default::default(),
3814 }
3815 }
3816
3817 /// Create a builder to help you perform the following task:
3818 ///
3819 /// 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`.
3820 ///
3821 /// # Arguments
3822 ///
3823 /// * `request` - No description provided.
3824 /// * `name` - The name of the operation resource to be cancelled.
3825 pub fn locations_operations_cancel(
3826 &self,
3827 request: CancelOperationRequest,
3828 name: &str,
3829 ) -> ProjectLocationOperationCancelCall<'a, C> {
3830 ProjectLocationOperationCancelCall {
3831 hub: self.hub,
3832 _request: request,
3833 _name: name.to_string(),
3834 _delegate: Default::default(),
3835 _additional_params: Default::default(),
3836 _scopes: Default::default(),
3837 }
3838 }
3839
3840 /// Create a builder to help you perform the following task:
3841 ///
3842 /// 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.
3843 ///
3844 /// # Arguments
3845 ///
3846 /// * `name` - The name of the operation resource.
3847 pub fn locations_operations_get(&self, name: &str) -> ProjectLocationOperationGetCall<'a, C> {
3848 ProjectLocationOperationGetCall {
3849 hub: self.hub,
3850 _name: name.to_string(),
3851 _delegate: Default::default(),
3852 _additional_params: Default::default(),
3853 _scopes: Default::default(),
3854 }
3855 }
3856
3857 /// Create a builder to help you perform the following task:
3858 ///
3859 /// Creates a new `BuildTrigger`.
3860 ///
3861 /// # Arguments
3862 ///
3863 /// * `request` - No description provided.
3864 /// * `parent` - The parent resource where this trigger will be created. Format: `projects/{project}/locations/{location}`
3865 pub fn locations_triggers_create(
3866 &self,
3867 request: BuildTrigger,
3868 parent: &str,
3869 ) -> ProjectLocationTriggerCreateCall<'a, C> {
3870 ProjectLocationTriggerCreateCall {
3871 hub: self.hub,
3872 _request: request,
3873 _parent: parent.to_string(),
3874 _project_id: Default::default(),
3875 _delegate: Default::default(),
3876 _additional_params: Default::default(),
3877 _scopes: Default::default(),
3878 }
3879 }
3880
3881 /// Create a builder to help you perform the following task:
3882 ///
3883 /// Deletes a `BuildTrigger` by its project ID and trigger ID.
3884 ///
3885 /// # Arguments
3886 ///
3887 /// * `name` - The name of the `Trigger` to delete. Format: `projects/{project}/locations/{location}/triggers/{trigger}`
3888 pub fn locations_triggers_delete(&self, name: &str) -> ProjectLocationTriggerDeleteCall<'a, C> {
3889 ProjectLocationTriggerDeleteCall {
3890 hub: self.hub,
3891 _name: name.to_string(),
3892 _trigger_id: Default::default(),
3893 _project_id: Default::default(),
3894 _delegate: Default::default(),
3895 _additional_params: Default::default(),
3896 _scopes: Default::default(),
3897 }
3898 }
3899
3900 /// Create a builder to help you perform the following task:
3901 ///
3902 /// Returns information about a `BuildTrigger`.
3903 ///
3904 /// # Arguments
3905 ///
3906 /// * `name` - The name of the `Trigger` to retrieve. Format: `projects/{project}/locations/{location}/triggers/{trigger}`
3907 pub fn locations_triggers_get(&self, name: &str) -> ProjectLocationTriggerGetCall<'a, C> {
3908 ProjectLocationTriggerGetCall {
3909 hub: self.hub,
3910 _name: name.to_string(),
3911 _trigger_id: Default::default(),
3912 _project_id: Default::default(),
3913 _delegate: Default::default(),
3914 _additional_params: Default::default(),
3915 _scopes: Default::default(),
3916 }
3917 }
3918
3919 /// Create a builder to help you perform the following task:
3920 ///
3921 /// Lists existing `BuildTrigger`s.
3922 ///
3923 /// # Arguments
3924 ///
3925 /// * `parent` - The parent of the collection of `Triggers`. Format: `projects/{project}/locations/{location}`
3926 pub fn locations_triggers_list(&self, parent: &str) -> ProjectLocationTriggerListCall<'a, C> {
3927 ProjectLocationTriggerListCall {
3928 hub: self.hub,
3929 _parent: parent.to_string(),
3930 _project_id: Default::default(),
3931 _page_token: Default::default(),
3932 _page_size: Default::default(),
3933 _delegate: Default::default(),
3934 _additional_params: Default::default(),
3935 _scopes: Default::default(),
3936 }
3937 }
3938
3939 /// Create a builder to help you perform the following task:
3940 ///
3941 /// Updates a `BuildTrigger` by its project ID and trigger ID.
3942 ///
3943 /// # Arguments
3944 ///
3945 /// * `request` - No description provided.
3946 /// * `resourceName` - The `Trigger` name with format: `projects/{project}/locations/{location}/triggers/{trigger}`, where {trigger} is a unique identifier generated by the service.
3947 pub fn locations_triggers_patch(
3948 &self,
3949 request: BuildTrigger,
3950 resource_name: &str,
3951 ) -> ProjectLocationTriggerPatchCall<'a, C> {
3952 ProjectLocationTriggerPatchCall {
3953 hub: self.hub,
3954 _request: request,
3955 _resource_name: resource_name.to_string(),
3956 _update_mask: Default::default(),
3957 _trigger_id: Default::default(),
3958 _project_id: Default::default(),
3959 _delegate: Default::default(),
3960 _additional_params: Default::default(),
3961 _scopes: Default::default(),
3962 }
3963 }
3964
3965 /// Create a builder to help you perform the following task:
3966 ///
3967 /// 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.
3968 ///
3969 /// # Arguments
3970 ///
3971 /// * `request` - No description provided.
3972 /// * `name` - The name of the `Trigger` to run. Format: `projects/{project}/locations/{location}/triggers/{trigger}`
3973 pub fn locations_triggers_run(
3974 &self,
3975 request: RunBuildTriggerRequest,
3976 name: &str,
3977 ) -> ProjectLocationTriggerRunCall<'a, C> {
3978 ProjectLocationTriggerRunCall {
3979 hub: self.hub,
3980 _request: request,
3981 _name: name.to_string(),
3982 _delegate: Default::default(),
3983 _additional_params: Default::default(),
3984 _scopes: Default::default(),
3985 }
3986 }
3987
3988 /// Create a builder to help you perform the following task:
3989 ///
3990 /// ReceiveTriggerWebhook [Experimental] is called when the API receives a webhook request targeted at a specific trigger.
3991 ///
3992 /// # Arguments
3993 ///
3994 /// * `request` - No description provided.
3995 /// * `name` - The name of the `ReceiveTriggerWebhook` to retrieve. Format: `projects/{project}/locations/{location}/triggers/{trigger}`
3996 pub fn locations_triggers_webhook(
3997 &self,
3998 request: HttpBody,
3999 name: &str,
4000 ) -> ProjectLocationTriggerWebhookCall<'a, C> {
4001 ProjectLocationTriggerWebhookCall {
4002 hub: self.hub,
4003 _request: request,
4004 _name: name.to_string(),
4005 _trigger: Default::default(),
4006 _secret: Default::default(),
4007 _project_id: Default::default(),
4008 _delegate: Default::default(),
4009 _additional_params: Default::default(),
4010 }
4011 }
4012
4013 /// Create a builder to help you perform the following task:
4014 ///
4015 /// Creates a `WorkerPool`.
4016 ///
4017 /// # Arguments
4018 ///
4019 /// * `request` - No description provided.
4020 /// * `parent` - Required. The parent resource where this worker pool will be created. Format: `projects/{project}/locations/{location}`.
4021 pub fn locations_worker_pools_create(
4022 &self,
4023 request: WorkerPool,
4024 parent: &str,
4025 ) -> ProjectLocationWorkerPoolCreateCall<'a, C> {
4026 ProjectLocationWorkerPoolCreateCall {
4027 hub: self.hub,
4028 _request: request,
4029 _parent: parent.to_string(),
4030 _worker_pool_id: Default::default(),
4031 _validate_only: Default::default(),
4032 _delegate: Default::default(),
4033 _additional_params: Default::default(),
4034 _scopes: Default::default(),
4035 }
4036 }
4037
4038 /// Create a builder to help you perform the following task:
4039 ///
4040 /// Deletes a `WorkerPool`.
4041 ///
4042 /// # Arguments
4043 ///
4044 /// * `name` - Required. The name of the `WorkerPool` to delete. Format: `projects/{project}/locations/{location}/workerPools/{workerPool}`.
4045 pub fn locations_worker_pools_delete(
4046 &self,
4047 name: &str,
4048 ) -> ProjectLocationWorkerPoolDeleteCall<'a, C> {
4049 ProjectLocationWorkerPoolDeleteCall {
4050 hub: self.hub,
4051 _name: name.to_string(),
4052 _validate_only: Default::default(),
4053 _etag: Default::default(),
4054 _allow_missing: Default::default(),
4055 _delegate: Default::default(),
4056 _additional_params: Default::default(),
4057 _scopes: Default::default(),
4058 }
4059 }
4060
4061 /// Create a builder to help you perform the following task:
4062 ///
4063 /// Returns details of a `WorkerPool`.
4064 ///
4065 /// # Arguments
4066 ///
4067 /// * `name` - Required. The name of the `WorkerPool` to retrieve. Format: `projects/{project}/locations/{location}/workerPools/{workerPool}`.
4068 pub fn locations_worker_pools_get(
4069 &self,
4070 name: &str,
4071 ) -> ProjectLocationWorkerPoolGetCall<'a, C> {
4072 ProjectLocationWorkerPoolGetCall {
4073 hub: self.hub,
4074 _name: name.to_string(),
4075 _delegate: Default::default(),
4076 _additional_params: Default::default(),
4077 _scopes: Default::default(),
4078 }
4079 }
4080
4081 /// Create a builder to help you perform the following task:
4082 ///
4083 /// Lists `WorkerPool`s.
4084 ///
4085 /// # Arguments
4086 ///
4087 /// * `parent` - Required. The parent of the collection of `WorkerPools`. Format: `projects/{project}/locations/{location}`.
4088 pub fn locations_worker_pools_list(
4089 &self,
4090 parent: &str,
4091 ) -> ProjectLocationWorkerPoolListCall<'a, C> {
4092 ProjectLocationWorkerPoolListCall {
4093 hub: self.hub,
4094 _parent: parent.to_string(),
4095 _page_token: Default::default(),
4096 _page_size: Default::default(),
4097 _delegate: Default::default(),
4098 _additional_params: Default::default(),
4099 _scopes: Default::default(),
4100 }
4101 }
4102
4103 /// Create a builder to help you perform the following task:
4104 ///
4105 /// Updates a `WorkerPool`.
4106 ///
4107 /// # Arguments
4108 ///
4109 /// * `request` - No description provided.
4110 /// * `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.
4111 pub fn locations_worker_pools_patch(
4112 &self,
4113 request: WorkerPool,
4114 name: &str,
4115 ) -> ProjectLocationWorkerPoolPatchCall<'a, C> {
4116 ProjectLocationWorkerPoolPatchCall {
4117 hub: self.hub,
4118 _request: request,
4119 _name: name.to_string(),
4120 _validate_only: Default::default(),
4121 _update_mask: Default::default(),
4122 _delegate: Default::default(),
4123 _additional_params: Default::default(),
4124 _scopes: Default::default(),
4125 }
4126 }
4127
4128 /// Create a builder to help you perform the following task:
4129 ///
4130 /// Returns the `DefaultServiceAccount` used by the project.
4131 ///
4132 /// # Arguments
4133 ///
4134 /// * `name` - Required. The name of the `DefaultServiceAccount` to retrieve. Format: `projects/{project}/locations/{location}/defaultServiceAccount`
4135 pub fn locations_get_default_service_account(
4136 &self,
4137 name: &str,
4138 ) -> ProjectLocationGetDefaultServiceAccountCall<'a, C> {
4139 ProjectLocationGetDefaultServiceAccountCall {
4140 hub: self.hub,
4141 _name: name.to_string(),
4142 _delegate: Default::default(),
4143 _additional_params: Default::default(),
4144 _scopes: Default::default(),
4145 }
4146 }
4147
4148 /// Create a builder to help you perform the following task:
4149 ///
4150 /// Creates a new `BuildTrigger`.
4151 ///
4152 /// # Arguments
4153 ///
4154 /// * `request` - No description provided.
4155 /// * `projectId` - Required. ID of the project for which to configure automatic builds.
4156 pub fn triggers_create(
4157 &self,
4158 request: BuildTrigger,
4159 project_id: &str,
4160 ) -> ProjectTriggerCreateCall<'a, C> {
4161 ProjectTriggerCreateCall {
4162 hub: self.hub,
4163 _request: request,
4164 _project_id: project_id.to_string(),
4165 _parent: Default::default(),
4166 _delegate: Default::default(),
4167 _additional_params: Default::default(),
4168 _scopes: Default::default(),
4169 }
4170 }
4171
4172 /// Create a builder to help you perform the following task:
4173 ///
4174 /// Deletes a `BuildTrigger` by its project ID and trigger ID.
4175 ///
4176 /// # Arguments
4177 ///
4178 /// * `projectId` - Required. ID of the project that owns the trigger.
4179 /// * `triggerId` - Required. ID of the `BuildTrigger` to delete.
4180 pub fn triggers_delete(
4181 &self,
4182 project_id: &str,
4183 trigger_id: &str,
4184 ) -> ProjectTriggerDeleteCall<'a, C> {
4185 ProjectTriggerDeleteCall {
4186 hub: self.hub,
4187 _project_id: project_id.to_string(),
4188 _trigger_id: trigger_id.to_string(),
4189 _name: Default::default(),
4190 _delegate: Default::default(),
4191 _additional_params: Default::default(),
4192 _scopes: Default::default(),
4193 }
4194 }
4195
4196 /// Create a builder to help you perform the following task:
4197 ///
4198 /// Returns information about a `BuildTrigger`.
4199 ///
4200 /// # Arguments
4201 ///
4202 /// * `projectId` - Required. ID of the project that owns the trigger.
4203 /// * `triggerId` - Required. Identifier (`id` or `name`) of the `BuildTrigger` to get.
4204 pub fn triggers_get(&self, project_id: &str, trigger_id: &str) -> ProjectTriggerGetCall<'a, C> {
4205 ProjectTriggerGetCall {
4206 hub: self.hub,
4207 _project_id: project_id.to_string(),
4208 _trigger_id: trigger_id.to_string(),
4209 _name: Default::default(),
4210 _delegate: Default::default(),
4211 _additional_params: Default::default(),
4212 _scopes: Default::default(),
4213 }
4214 }
4215
4216 /// Create a builder to help you perform the following task:
4217 ///
4218 /// Lists existing `BuildTrigger`s.
4219 ///
4220 /// # Arguments
4221 ///
4222 /// * `projectId` - Required. ID of the project for which to list BuildTriggers.
4223 pub fn triggers_list(&self, project_id: &str) -> ProjectTriggerListCall<'a, C> {
4224 ProjectTriggerListCall {
4225 hub: self.hub,
4226 _project_id: project_id.to_string(),
4227 _parent: Default::default(),
4228 _page_token: Default::default(),
4229 _page_size: Default::default(),
4230 _delegate: Default::default(),
4231 _additional_params: Default::default(),
4232 _scopes: Default::default(),
4233 }
4234 }
4235
4236 /// Create a builder to help you perform the following task:
4237 ///
4238 /// Updates a `BuildTrigger` by its project ID and trigger ID.
4239 ///
4240 /// # Arguments
4241 ///
4242 /// * `request` - No description provided.
4243 /// * `projectId` - Required. ID of the project that owns the trigger.
4244 /// * `triggerId` - Required. ID of the `BuildTrigger` to update.
4245 pub fn triggers_patch(
4246 &self,
4247 request: BuildTrigger,
4248 project_id: &str,
4249 trigger_id: &str,
4250 ) -> ProjectTriggerPatchCall<'a, C> {
4251 ProjectTriggerPatchCall {
4252 hub: self.hub,
4253 _request: request,
4254 _project_id: project_id.to_string(),
4255 _trigger_id: trigger_id.to_string(),
4256 _update_mask: Default::default(),
4257 _delegate: Default::default(),
4258 _additional_params: Default::default(),
4259 _scopes: Default::default(),
4260 }
4261 }
4262
4263 /// Create a builder to help you perform the following task:
4264 ///
4265 /// 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.
4266 ///
4267 /// # Arguments
4268 ///
4269 /// * `request` - No description provided.
4270 /// * `projectId` - Required. ID of the project.
4271 /// * `triggerId` - Required. ID of the trigger.
4272 pub fn triggers_run(
4273 &self,
4274 request: RepoSource,
4275 project_id: &str,
4276 trigger_id: &str,
4277 ) -> ProjectTriggerRunCall<'a, C> {
4278 ProjectTriggerRunCall {
4279 hub: self.hub,
4280 _request: request,
4281 _project_id: project_id.to_string(),
4282 _trigger_id: trigger_id.to_string(),
4283 _name: Default::default(),
4284 _delegate: Default::default(),
4285 _additional_params: Default::default(),
4286 _scopes: Default::default(),
4287 }
4288 }
4289
4290 /// Create a builder to help you perform the following task:
4291 ///
4292 /// ReceiveTriggerWebhook [Experimental] is called when the API receives a webhook request targeted at a specific trigger.
4293 ///
4294 /// # Arguments
4295 ///
4296 /// * `request` - No description provided.
4297 /// * `projectId` - Project in which the specified trigger lives
4298 /// * `trigger` - Name of the trigger to run the payload against
4299 pub fn triggers_webhook(
4300 &self,
4301 request: HttpBody,
4302 project_id: &str,
4303 trigger: &str,
4304 ) -> ProjectTriggerWebhookCall<'a, C> {
4305 ProjectTriggerWebhookCall {
4306 hub: self.hub,
4307 _request: request,
4308 _project_id: project_id.to_string(),
4309 _trigger: trigger.to_string(),
4310 _secret: Default::default(),
4311 _name: Default::default(),
4312 _delegate: Default::default(),
4313 _additional_params: Default::default(),
4314 }
4315 }
4316}
4317
4318/// A builder providing access to all free methods, which are not associated with a particular resource.
4319/// It is not used directly, but through the [`CloudBuild`] hub.
4320///
4321/// # Example
4322///
4323/// Instantiate a resource builder
4324///
4325/// ```test_harness,no_run
4326/// extern crate hyper;
4327/// extern crate hyper_rustls;
4328/// extern crate google_cloudbuild1 as cloudbuild1;
4329///
4330/// # async fn dox() {
4331/// use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4332///
4333/// let secret: yup_oauth2::ApplicationSecret = Default::default();
4334/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
4335/// .with_native_roots()
4336/// .unwrap()
4337/// .https_only()
4338/// .enable_http2()
4339/// .build();
4340///
4341/// let executor = hyper_util::rt::TokioExecutor::new();
4342/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4343/// secret,
4344/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4345/// yup_oauth2::client::CustomHyperClientBuilder::from(
4346/// hyper_util::client::legacy::Client::builder(executor).build(connector),
4347/// ),
4348/// ).build().await.unwrap();
4349///
4350/// let client = hyper_util::client::legacy::Client::builder(
4351/// hyper_util::rt::TokioExecutor::new()
4352/// )
4353/// .build(
4354/// hyper_rustls::HttpsConnectorBuilder::new()
4355/// .with_native_roots()
4356/// .unwrap()
4357/// .https_or_http()
4358/// .enable_http2()
4359/// .build()
4360/// );
4361/// let mut hub = CloudBuild::new(client, auth);
4362/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
4363/// // like `webhook(...)`
4364/// // to build up your call.
4365/// let rb = hub.methods();
4366/// # }
4367/// ```
4368pub struct MethodMethods<'a, C>
4369where
4370 C: 'a,
4371{
4372 hub: &'a CloudBuild<C>,
4373}
4374
4375impl<'a, C> common::MethodsBuilder for MethodMethods<'a, C> {}
4376
4377impl<'a, C> MethodMethods<'a, C> {
4378 /// Create a builder to help you perform the following task:
4379 ///
4380 /// ReceiveWebhook is called when the API receives a GitHub webhook.
4381 ///
4382 /// # Arguments
4383 ///
4384 /// * `request` - No description provided.
4385 pub fn webhook(&self, request: HttpBody) -> MethodWebhookCall<'a, C> {
4386 MethodWebhookCall {
4387 hub: self.hub,
4388 _request: request,
4389 _webhook_key: Default::default(),
4390 _delegate: Default::default(),
4391 _additional_params: Default::default(),
4392 }
4393 }
4394}
4395
4396// ###################
4397// CallBuilders ###
4398// #################
4399
4400/// ReceiveGitHubDotComWebhook is called when the API receives a github.com webhook.
4401///
4402/// A builder for the *receive* method supported by a *githubDotComWebhook* resource.
4403/// It is not used directly, but through a [`GithubDotComWebhookMethods`] instance.
4404///
4405/// # Example
4406///
4407/// Instantiate a resource method builder
4408///
4409/// ```test_harness,no_run
4410/// # extern crate hyper;
4411/// # extern crate hyper_rustls;
4412/// # extern crate google_cloudbuild1 as cloudbuild1;
4413/// use cloudbuild1::api::HttpBody;
4414/// # async fn dox() {
4415/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4416///
4417/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4418/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4419/// # .with_native_roots()
4420/// # .unwrap()
4421/// # .https_only()
4422/// # .enable_http2()
4423/// # .build();
4424///
4425/// # let executor = hyper_util::rt::TokioExecutor::new();
4426/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4427/// # secret,
4428/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4429/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4430/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4431/// # ),
4432/// # ).build().await.unwrap();
4433///
4434/// # let client = hyper_util::client::legacy::Client::builder(
4435/// # hyper_util::rt::TokioExecutor::new()
4436/// # )
4437/// # .build(
4438/// # hyper_rustls::HttpsConnectorBuilder::new()
4439/// # .with_native_roots()
4440/// # .unwrap()
4441/// # .https_or_http()
4442/// # .enable_http2()
4443/// # .build()
4444/// # );
4445/// # let mut hub = CloudBuild::new(client, auth);
4446/// // As the method needs a request, you would usually fill it with the desired information
4447/// // into the respective structure. Some of the parts shown here might not be applicable !
4448/// // Values shown here are possibly random and not representative !
4449/// let mut req = HttpBody::default();
4450///
4451/// // You can configure optional parameters by calling the respective setters at will, and
4452/// // execute the final call using `doit()`.
4453/// // Values shown here are possibly random and not representative !
4454/// let result = hub.github_dot_com_webhook().receive(req)
4455/// .webhook_key("takimata")
4456/// .doit().await;
4457/// # }
4458/// ```
4459pub struct GithubDotComWebhookReceiveCall<'a, C>
4460where
4461 C: 'a,
4462{
4463 hub: &'a CloudBuild<C>,
4464 _request: HttpBody,
4465 _webhook_key: Option<String>,
4466 _delegate: Option<&'a mut dyn common::Delegate>,
4467 _additional_params: HashMap<String, String>,
4468}
4469
4470impl<'a, C> common::CallBuilder for GithubDotComWebhookReceiveCall<'a, C> {}
4471
4472impl<'a, C> GithubDotComWebhookReceiveCall<'a, C>
4473where
4474 C: common::Connector,
4475{
4476 /// Perform the operation you have build so far.
4477 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
4478 use std::borrow::Cow;
4479 use std::io::{Read, Seek};
4480
4481 use common::{url::Params, ToParts};
4482 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4483
4484 let mut dd = common::DefaultDelegate;
4485 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4486 dlg.begin(common::MethodInfo {
4487 id: "cloudbuild.githubDotComWebhook.receive",
4488 http_method: hyper::Method::POST,
4489 });
4490
4491 for &field in ["alt", "webhookKey"].iter() {
4492 if self._additional_params.contains_key(field) {
4493 dlg.finished(false);
4494 return Err(common::Error::FieldClash(field));
4495 }
4496 }
4497
4498 let mut params = Params::with_capacity(4 + self._additional_params.len());
4499 if let Some(value) = self._webhook_key.as_ref() {
4500 params.push("webhookKey", value);
4501 }
4502
4503 params.extend(self._additional_params.iter());
4504
4505 params.push("alt", "json");
4506 let mut url = self.hub._base_url.clone() + "v1/githubDotComWebhook:receive";
4507
4508 match dlg.api_key() {
4509 Some(value) => params.push("key", value),
4510 None => {
4511 dlg.finished(false);
4512 return Err(common::Error::MissingAPIKey);
4513 }
4514 }
4515
4516 let url = params.parse_with_url(&url);
4517
4518 let mut json_mime_type = mime::APPLICATION_JSON;
4519 let mut request_value_reader = {
4520 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4521 common::remove_json_null_values(&mut value);
4522 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4523 serde_json::to_writer(&mut dst, &value).unwrap();
4524 dst
4525 };
4526 let request_size = request_value_reader
4527 .seek(std::io::SeekFrom::End(0))
4528 .unwrap();
4529 request_value_reader
4530 .seek(std::io::SeekFrom::Start(0))
4531 .unwrap();
4532
4533 loop {
4534 request_value_reader
4535 .seek(std::io::SeekFrom::Start(0))
4536 .unwrap();
4537 let mut req_result = {
4538 let client = &self.hub.client;
4539 dlg.pre_request();
4540 let mut req_builder = hyper::Request::builder()
4541 .method(hyper::Method::POST)
4542 .uri(url.as_str())
4543 .header(USER_AGENT, self.hub._user_agent.clone());
4544
4545 let request = req_builder
4546 .header(CONTENT_TYPE, json_mime_type.to_string())
4547 .header(CONTENT_LENGTH, request_size as u64)
4548 .body(common::to_body(
4549 request_value_reader.get_ref().clone().into(),
4550 ));
4551
4552 client.request(request.unwrap()).await
4553 };
4554
4555 match req_result {
4556 Err(err) => {
4557 if let common::Retry::After(d) = dlg.http_error(&err) {
4558 sleep(d).await;
4559 continue;
4560 }
4561 dlg.finished(false);
4562 return Err(common::Error::HttpError(err));
4563 }
4564 Ok(res) => {
4565 let (mut parts, body) = res.into_parts();
4566 let mut body = common::Body::new(body);
4567 if !parts.status.is_success() {
4568 let bytes = common::to_bytes(body).await.unwrap_or_default();
4569 let error = serde_json::from_str(&common::to_string(&bytes));
4570 let response = common::to_response(parts, bytes.into());
4571
4572 if let common::Retry::After(d) =
4573 dlg.http_failure(&response, error.as_ref().ok())
4574 {
4575 sleep(d).await;
4576 continue;
4577 }
4578
4579 dlg.finished(false);
4580
4581 return Err(match error {
4582 Ok(value) => common::Error::BadRequest(value),
4583 _ => common::Error::Failure(response),
4584 });
4585 }
4586 let response = {
4587 let bytes = common::to_bytes(body).await.unwrap_or_default();
4588 let encoded = common::to_string(&bytes);
4589 match serde_json::from_str(&encoded) {
4590 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4591 Err(error) => {
4592 dlg.response_json_decode_error(&encoded, &error);
4593 return Err(common::Error::JsonDecodeError(
4594 encoded.to_string(),
4595 error,
4596 ));
4597 }
4598 }
4599 };
4600
4601 dlg.finished(true);
4602 return Ok(response);
4603 }
4604 }
4605 }
4606 }
4607
4608 ///
4609 /// Sets the *request* property to the given value.
4610 ///
4611 /// Even though the property as already been set when instantiating this call,
4612 /// we provide this method for API completeness.
4613 pub fn request(mut self, new_value: HttpBody) -> GithubDotComWebhookReceiveCall<'a, C> {
4614 self._request = new_value;
4615 self
4616 }
4617 /// For GitHub Enterprise webhooks, this key is used to associate the webhook request with the GitHubEnterpriseConfig to use for validation.
4618 ///
4619 /// Sets the *webhook key* query property to the given value.
4620 pub fn webhook_key(mut self, new_value: &str) -> GithubDotComWebhookReceiveCall<'a, C> {
4621 self._webhook_key = Some(new_value.to_string());
4622 self
4623 }
4624 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4625 /// while executing the actual API request.
4626 ///
4627 /// ````text
4628 /// It should be used to handle progress information, and to implement a certain level of resilience.
4629 /// ````
4630 ///
4631 /// Sets the *delegate* property to the given value.
4632 pub fn delegate(
4633 mut self,
4634 new_value: &'a mut dyn common::Delegate,
4635 ) -> GithubDotComWebhookReceiveCall<'a, C> {
4636 self._delegate = Some(new_value);
4637 self
4638 }
4639
4640 /// Set any additional parameter of the query string used in the request.
4641 /// It should be used to set parameters which are not yet available through their own
4642 /// setters.
4643 ///
4644 /// Please note that this method must not be used to set any of the known parameters
4645 /// which have their own setter method. If done anyway, the request will fail.
4646 ///
4647 /// # Additional Parameters
4648 ///
4649 /// * *$.xgafv* (query-string) - V1 error format.
4650 /// * *access_token* (query-string) - OAuth access token.
4651 /// * *alt* (query-string) - Data format for response.
4652 /// * *callback* (query-string) - JSONP
4653 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4654 /// * *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.
4655 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4656 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4657 /// * *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.
4658 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4659 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4660 pub fn param<T>(mut self, name: T, value: T) -> GithubDotComWebhookReceiveCall<'a, C>
4661 where
4662 T: AsRef<str>,
4663 {
4664 self._additional_params
4665 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4666 self
4667 }
4668}
4669
4670/// ReceiveRegionalWebhook is called when the API receives a regional GitHub webhook.
4671///
4672/// A builder for the *regionalWebhook* method supported by a *location* resource.
4673/// It is not used directly, but through a [`LocationMethods`] instance.
4674///
4675/// # Example
4676///
4677/// Instantiate a resource method builder
4678///
4679/// ```test_harness,no_run
4680/// # extern crate hyper;
4681/// # extern crate hyper_rustls;
4682/// # extern crate google_cloudbuild1 as cloudbuild1;
4683/// use cloudbuild1::api::HttpBody;
4684/// # async fn dox() {
4685/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4686///
4687/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4688/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4689/// # .with_native_roots()
4690/// # .unwrap()
4691/// # .https_only()
4692/// # .enable_http2()
4693/// # .build();
4694///
4695/// # let executor = hyper_util::rt::TokioExecutor::new();
4696/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4697/// # secret,
4698/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4699/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4700/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4701/// # ),
4702/// # ).build().await.unwrap();
4703///
4704/// # let client = hyper_util::client::legacy::Client::builder(
4705/// # hyper_util::rt::TokioExecutor::new()
4706/// # )
4707/// # .build(
4708/// # hyper_rustls::HttpsConnectorBuilder::new()
4709/// # .with_native_roots()
4710/// # .unwrap()
4711/// # .https_or_http()
4712/// # .enable_http2()
4713/// # .build()
4714/// # );
4715/// # let mut hub = CloudBuild::new(client, auth);
4716/// // As the method needs a request, you would usually fill it with the desired information
4717/// // into the respective structure. Some of the parts shown here might not be applicable !
4718/// // Values shown here are possibly random and not representative !
4719/// let mut req = HttpBody::default();
4720///
4721/// // You can configure optional parameters by calling the respective setters at will, and
4722/// // execute the final call using `doit()`.
4723/// // Values shown here are possibly random and not representative !
4724/// let result = hub.locations().regional_webhook(req, "location")
4725/// .webhook_key("duo")
4726/// .doit().await;
4727/// # }
4728/// ```
4729pub struct LocationRegionalWebhookCall<'a, C>
4730where
4731 C: 'a,
4732{
4733 hub: &'a CloudBuild<C>,
4734 _request: HttpBody,
4735 _location: String,
4736 _webhook_key: Option<String>,
4737 _delegate: Option<&'a mut dyn common::Delegate>,
4738 _additional_params: HashMap<String, String>,
4739}
4740
4741impl<'a, C> common::CallBuilder for LocationRegionalWebhookCall<'a, C> {}
4742
4743impl<'a, C> LocationRegionalWebhookCall<'a, C>
4744where
4745 C: common::Connector,
4746{
4747 /// Perform the operation you have build so far.
4748 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
4749 use std::borrow::Cow;
4750 use std::io::{Read, Seek};
4751
4752 use common::{url::Params, ToParts};
4753 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4754
4755 let mut dd = common::DefaultDelegate;
4756 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4757 dlg.begin(common::MethodInfo {
4758 id: "cloudbuild.locations.regionalWebhook",
4759 http_method: hyper::Method::POST,
4760 });
4761
4762 for &field in ["alt", "location", "webhookKey"].iter() {
4763 if self._additional_params.contains_key(field) {
4764 dlg.finished(false);
4765 return Err(common::Error::FieldClash(field));
4766 }
4767 }
4768
4769 let mut params = Params::with_capacity(5 + self._additional_params.len());
4770 params.push("location", self._location);
4771 if let Some(value) = self._webhook_key.as_ref() {
4772 params.push("webhookKey", value);
4773 }
4774
4775 params.extend(self._additional_params.iter());
4776
4777 params.push("alt", "json");
4778 let mut url = self.hub._base_url.clone() + "v1/{+location}/regionalWebhook";
4779
4780 match dlg.api_key() {
4781 Some(value) => params.push("key", value),
4782 None => {
4783 dlg.finished(false);
4784 return Err(common::Error::MissingAPIKey);
4785 }
4786 }
4787
4788 #[allow(clippy::single_element_loop)]
4789 for &(find_this, param_name) in [("{+location}", "location")].iter() {
4790 url = params.uri_replacement(url, param_name, find_this, true);
4791 }
4792 {
4793 let to_remove = ["location"];
4794 params.remove_params(&to_remove);
4795 }
4796
4797 let url = params.parse_with_url(&url);
4798
4799 let mut json_mime_type = mime::APPLICATION_JSON;
4800 let mut request_value_reader = {
4801 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4802 common::remove_json_null_values(&mut value);
4803 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4804 serde_json::to_writer(&mut dst, &value).unwrap();
4805 dst
4806 };
4807 let request_size = request_value_reader
4808 .seek(std::io::SeekFrom::End(0))
4809 .unwrap();
4810 request_value_reader
4811 .seek(std::io::SeekFrom::Start(0))
4812 .unwrap();
4813
4814 loop {
4815 request_value_reader
4816 .seek(std::io::SeekFrom::Start(0))
4817 .unwrap();
4818 let mut req_result = {
4819 let client = &self.hub.client;
4820 dlg.pre_request();
4821 let mut req_builder = hyper::Request::builder()
4822 .method(hyper::Method::POST)
4823 .uri(url.as_str())
4824 .header(USER_AGENT, self.hub._user_agent.clone());
4825
4826 let request = req_builder
4827 .header(CONTENT_TYPE, json_mime_type.to_string())
4828 .header(CONTENT_LENGTH, request_size as u64)
4829 .body(common::to_body(
4830 request_value_reader.get_ref().clone().into(),
4831 ));
4832
4833 client.request(request.unwrap()).await
4834 };
4835
4836 match req_result {
4837 Err(err) => {
4838 if let common::Retry::After(d) = dlg.http_error(&err) {
4839 sleep(d).await;
4840 continue;
4841 }
4842 dlg.finished(false);
4843 return Err(common::Error::HttpError(err));
4844 }
4845 Ok(res) => {
4846 let (mut parts, body) = res.into_parts();
4847 let mut body = common::Body::new(body);
4848 if !parts.status.is_success() {
4849 let bytes = common::to_bytes(body).await.unwrap_or_default();
4850 let error = serde_json::from_str(&common::to_string(&bytes));
4851 let response = common::to_response(parts, bytes.into());
4852
4853 if let common::Retry::After(d) =
4854 dlg.http_failure(&response, error.as_ref().ok())
4855 {
4856 sleep(d).await;
4857 continue;
4858 }
4859
4860 dlg.finished(false);
4861
4862 return Err(match error {
4863 Ok(value) => common::Error::BadRequest(value),
4864 _ => common::Error::Failure(response),
4865 });
4866 }
4867 let response = {
4868 let bytes = common::to_bytes(body).await.unwrap_or_default();
4869 let encoded = common::to_string(&bytes);
4870 match serde_json::from_str(&encoded) {
4871 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4872 Err(error) => {
4873 dlg.response_json_decode_error(&encoded, &error);
4874 return Err(common::Error::JsonDecodeError(
4875 encoded.to_string(),
4876 error,
4877 ));
4878 }
4879 }
4880 };
4881
4882 dlg.finished(true);
4883 return Ok(response);
4884 }
4885 }
4886 }
4887 }
4888
4889 ///
4890 /// Sets the *request* property to the given value.
4891 ///
4892 /// Even though the property as already been set when instantiating this call,
4893 /// we provide this method for API completeness.
4894 pub fn request(mut self, new_value: HttpBody) -> LocationRegionalWebhookCall<'a, C> {
4895 self._request = new_value;
4896 self
4897 }
4898 /// Required. The location where the webhook should be sent.
4899 ///
4900 /// Sets the *location* path property to the given value.
4901 ///
4902 /// Even though the property as already been set when instantiating this call,
4903 /// we provide this method for API completeness.
4904 pub fn location(mut self, new_value: &str) -> LocationRegionalWebhookCall<'a, C> {
4905 self._location = new_value.to_string();
4906 self
4907 }
4908 /// For GitHub Enterprise webhooks, this key is used to associate the webhook request with the GitHubEnterpriseConfig to use for validation.
4909 ///
4910 /// Sets the *webhook key* query property to the given value.
4911 pub fn webhook_key(mut self, new_value: &str) -> LocationRegionalWebhookCall<'a, C> {
4912 self._webhook_key = Some(new_value.to_string());
4913 self
4914 }
4915 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4916 /// while executing the actual API request.
4917 ///
4918 /// ````text
4919 /// It should be used to handle progress information, and to implement a certain level of resilience.
4920 /// ````
4921 ///
4922 /// Sets the *delegate* property to the given value.
4923 pub fn delegate(
4924 mut self,
4925 new_value: &'a mut dyn common::Delegate,
4926 ) -> LocationRegionalWebhookCall<'a, C> {
4927 self._delegate = Some(new_value);
4928 self
4929 }
4930
4931 /// Set any additional parameter of the query string used in the request.
4932 /// It should be used to set parameters which are not yet available through their own
4933 /// setters.
4934 ///
4935 /// Please note that this method must not be used to set any of the known parameters
4936 /// which have their own setter method. If done anyway, the request will fail.
4937 ///
4938 /// # Additional Parameters
4939 ///
4940 /// * *$.xgafv* (query-string) - V1 error format.
4941 /// * *access_token* (query-string) - OAuth access token.
4942 /// * *alt* (query-string) - Data format for response.
4943 /// * *callback* (query-string) - JSONP
4944 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4945 /// * *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.
4946 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4947 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4948 /// * *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.
4949 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4950 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4951 pub fn param<T>(mut self, name: T, value: T) -> LocationRegionalWebhookCall<'a, C>
4952 where
4953 T: AsRef<str>,
4954 {
4955 self._additional_params
4956 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4957 self
4958 }
4959}
4960
4961/// 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`.
4962///
4963/// A builder for the *cancel* method supported by a *operation* resource.
4964/// It is not used directly, but through a [`OperationMethods`] instance.
4965///
4966/// # Example
4967///
4968/// Instantiate a resource method builder
4969///
4970/// ```test_harness,no_run
4971/// # extern crate hyper;
4972/// # extern crate hyper_rustls;
4973/// # extern crate google_cloudbuild1 as cloudbuild1;
4974/// use cloudbuild1::api::CancelOperationRequest;
4975/// # async fn dox() {
4976/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4977///
4978/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4979/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4980/// # .with_native_roots()
4981/// # .unwrap()
4982/// # .https_only()
4983/// # .enable_http2()
4984/// # .build();
4985///
4986/// # let executor = hyper_util::rt::TokioExecutor::new();
4987/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4988/// # secret,
4989/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4990/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4991/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4992/// # ),
4993/// # ).build().await.unwrap();
4994///
4995/// # let client = hyper_util::client::legacy::Client::builder(
4996/// # hyper_util::rt::TokioExecutor::new()
4997/// # )
4998/// # .build(
4999/// # hyper_rustls::HttpsConnectorBuilder::new()
5000/// # .with_native_roots()
5001/// # .unwrap()
5002/// # .https_or_http()
5003/// # .enable_http2()
5004/// # .build()
5005/// # );
5006/// # let mut hub = CloudBuild::new(client, auth);
5007/// // As the method needs a request, you would usually fill it with the desired information
5008/// // into the respective structure. Some of the parts shown here might not be applicable !
5009/// // Values shown here are possibly random and not representative !
5010/// let mut req = CancelOperationRequest::default();
5011///
5012/// // You can configure optional parameters by calling the respective setters at will, and
5013/// // execute the final call using `doit()`.
5014/// // Values shown here are possibly random and not representative !
5015/// let result = hub.operations().cancel(req, "name")
5016/// .doit().await;
5017/// # }
5018/// ```
5019pub struct OperationCancelCall<'a, C>
5020where
5021 C: 'a,
5022{
5023 hub: &'a CloudBuild<C>,
5024 _request: CancelOperationRequest,
5025 _name: String,
5026 _delegate: Option<&'a mut dyn common::Delegate>,
5027 _additional_params: HashMap<String, String>,
5028 _scopes: BTreeSet<String>,
5029}
5030
5031impl<'a, C> common::CallBuilder for OperationCancelCall<'a, C> {}
5032
5033impl<'a, C> OperationCancelCall<'a, C>
5034where
5035 C: common::Connector,
5036{
5037 /// Perform the operation you have build so far.
5038 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
5039 use std::borrow::Cow;
5040 use std::io::{Read, Seek};
5041
5042 use common::{url::Params, ToParts};
5043 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5044
5045 let mut dd = common::DefaultDelegate;
5046 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5047 dlg.begin(common::MethodInfo {
5048 id: "cloudbuild.operations.cancel",
5049 http_method: hyper::Method::POST,
5050 });
5051
5052 for &field in ["alt", "name"].iter() {
5053 if self._additional_params.contains_key(field) {
5054 dlg.finished(false);
5055 return Err(common::Error::FieldClash(field));
5056 }
5057 }
5058
5059 let mut params = Params::with_capacity(4 + self._additional_params.len());
5060 params.push("name", self._name);
5061
5062 params.extend(self._additional_params.iter());
5063
5064 params.push("alt", "json");
5065 let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
5066 if self._scopes.is_empty() {
5067 self._scopes
5068 .insert(Scope::CloudPlatform.as_ref().to_string());
5069 }
5070
5071 #[allow(clippy::single_element_loop)]
5072 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5073 url = params.uri_replacement(url, param_name, find_this, true);
5074 }
5075 {
5076 let to_remove = ["name"];
5077 params.remove_params(&to_remove);
5078 }
5079
5080 let url = params.parse_with_url(&url);
5081
5082 let mut json_mime_type = mime::APPLICATION_JSON;
5083 let mut request_value_reader = {
5084 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5085 common::remove_json_null_values(&mut value);
5086 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5087 serde_json::to_writer(&mut dst, &value).unwrap();
5088 dst
5089 };
5090 let request_size = request_value_reader
5091 .seek(std::io::SeekFrom::End(0))
5092 .unwrap();
5093 request_value_reader
5094 .seek(std::io::SeekFrom::Start(0))
5095 .unwrap();
5096
5097 loop {
5098 let token = match self
5099 .hub
5100 .auth
5101 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5102 .await
5103 {
5104 Ok(token) => token,
5105 Err(e) => match dlg.token(e) {
5106 Ok(token) => token,
5107 Err(e) => {
5108 dlg.finished(false);
5109 return Err(common::Error::MissingToken(e));
5110 }
5111 },
5112 };
5113 request_value_reader
5114 .seek(std::io::SeekFrom::Start(0))
5115 .unwrap();
5116 let mut req_result = {
5117 let client = &self.hub.client;
5118 dlg.pre_request();
5119 let mut req_builder = hyper::Request::builder()
5120 .method(hyper::Method::POST)
5121 .uri(url.as_str())
5122 .header(USER_AGENT, self.hub._user_agent.clone());
5123
5124 if let Some(token) = token.as_ref() {
5125 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5126 }
5127
5128 let request = req_builder
5129 .header(CONTENT_TYPE, json_mime_type.to_string())
5130 .header(CONTENT_LENGTH, request_size as u64)
5131 .body(common::to_body(
5132 request_value_reader.get_ref().clone().into(),
5133 ));
5134
5135 client.request(request.unwrap()).await
5136 };
5137
5138 match req_result {
5139 Err(err) => {
5140 if let common::Retry::After(d) = dlg.http_error(&err) {
5141 sleep(d).await;
5142 continue;
5143 }
5144 dlg.finished(false);
5145 return Err(common::Error::HttpError(err));
5146 }
5147 Ok(res) => {
5148 let (mut parts, body) = res.into_parts();
5149 let mut body = common::Body::new(body);
5150 if !parts.status.is_success() {
5151 let bytes = common::to_bytes(body).await.unwrap_or_default();
5152 let error = serde_json::from_str(&common::to_string(&bytes));
5153 let response = common::to_response(parts, bytes.into());
5154
5155 if let common::Retry::After(d) =
5156 dlg.http_failure(&response, error.as_ref().ok())
5157 {
5158 sleep(d).await;
5159 continue;
5160 }
5161
5162 dlg.finished(false);
5163
5164 return Err(match error {
5165 Ok(value) => common::Error::BadRequest(value),
5166 _ => common::Error::Failure(response),
5167 });
5168 }
5169 let response = {
5170 let bytes = common::to_bytes(body).await.unwrap_or_default();
5171 let encoded = common::to_string(&bytes);
5172 match serde_json::from_str(&encoded) {
5173 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5174 Err(error) => {
5175 dlg.response_json_decode_error(&encoded, &error);
5176 return Err(common::Error::JsonDecodeError(
5177 encoded.to_string(),
5178 error,
5179 ));
5180 }
5181 }
5182 };
5183
5184 dlg.finished(true);
5185 return Ok(response);
5186 }
5187 }
5188 }
5189 }
5190
5191 ///
5192 /// Sets the *request* property to the given value.
5193 ///
5194 /// Even though the property as already been set when instantiating this call,
5195 /// we provide this method for API completeness.
5196 pub fn request(mut self, new_value: CancelOperationRequest) -> OperationCancelCall<'a, C> {
5197 self._request = new_value;
5198 self
5199 }
5200 /// The name of the operation resource to be cancelled.
5201 ///
5202 /// Sets the *name* path property to the given value.
5203 ///
5204 /// Even though the property as already been set when instantiating this call,
5205 /// we provide this method for API completeness.
5206 pub fn name(mut self, new_value: &str) -> OperationCancelCall<'a, C> {
5207 self._name = new_value.to_string();
5208 self
5209 }
5210 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5211 /// while executing the actual API request.
5212 ///
5213 /// ````text
5214 /// It should be used to handle progress information, and to implement a certain level of resilience.
5215 /// ````
5216 ///
5217 /// Sets the *delegate* property to the given value.
5218 pub fn delegate(
5219 mut self,
5220 new_value: &'a mut dyn common::Delegate,
5221 ) -> OperationCancelCall<'a, C> {
5222 self._delegate = Some(new_value);
5223 self
5224 }
5225
5226 /// Set any additional parameter of the query string used in the request.
5227 /// It should be used to set parameters which are not yet available through their own
5228 /// setters.
5229 ///
5230 /// Please note that this method must not be used to set any of the known parameters
5231 /// which have their own setter method. If done anyway, the request will fail.
5232 ///
5233 /// # Additional Parameters
5234 ///
5235 /// * *$.xgafv* (query-string) - V1 error format.
5236 /// * *access_token* (query-string) - OAuth access token.
5237 /// * *alt* (query-string) - Data format for response.
5238 /// * *callback* (query-string) - JSONP
5239 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5240 /// * *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.
5241 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5242 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5243 /// * *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.
5244 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5245 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5246 pub fn param<T>(mut self, name: T, value: T) -> OperationCancelCall<'a, C>
5247 where
5248 T: AsRef<str>,
5249 {
5250 self._additional_params
5251 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5252 self
5253 }
5254
5255 /// Identifies the authorization scope for the method you are building.
5256 ///
5257 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5258 /// [`Scope::CloudPlatform`].
5259 ///
5260 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5261 /// tokens for more than one scope.
5262 ///
5263 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5264 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5265 /// sufficient, a read-write scope will do as well.
5266 pub fn add_scope<St>(mut self, scope: St) -> OperationCancelCall<'a, C>
5267 where
5268 St: AsRef<str>,
5269 {
5270 self._scopes.insert(String::from(scope.as_ref()));
5271 self
5272 }
5273 /// Identifies the authorization scope(s) for the method you are building.
5274 ///
5275 /// See [`Self::add_scope()`] for details.
5276 pub fn add_scopes<I, St>(mut self, scopes: I) -> OperationCancelCall<'a, C>
5277 where
5278 I: IntoIterator<Item = St>,
5279 St: AsRef<str>,
5280 {
5281 self._scopes
5282 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5283 self
5284 }
5285
5286 /// Removes all scopes, and no default scope will be used either.
5287 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5288 /// for details).
5289 pub fn clear_scopes(mut self) -> OperationCancelCall<'a, C> {
5290 self._scopes.clear();
5291 self
5292 }
5293}
5294
5295/// 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.
5296///
5297/// A builder for the *get* method supported by a *operation* resource.
5298/// It is not used directly, but through a [`OperationMethods`] instance.
5299///
5300/// # Example
5301///
5302/// Instantiate a resource method builder
5303///
5304/// ```test_harness,no_run
5305/// # extern crate hyper;
5306/// # extern crate hyper_rustls;
5307/// # extern crate google_cloudbuild1 as cloudbuild1;
5308/// # async fn dox() {
5309/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5310///
5311/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5312/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5313/// # .with_native_roots()
5314/// # .unwrap()
5315/// # .https_only()
5316/// # .enable_http2()
5317/// # .build();
5318///
5319/// # let executor = hyper_util::rt::TokioExecutor::new();
5320/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5321/// # secret,
5322/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5323/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5324/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5325/// # ),
5326/// # ).build().await.unwrap();
5327///
5328/// # let client = hyper_util::client::legacy::Client::builder(
5329/// # hyper_util::rt::TokioExecutor::new()
5330/// # )
5331/// # .build(
5332/// # hyper_rustls::HttpsConnectorBuilder::new()
5333/// # .with_native_roots()
5334/// # .unwrap()
5335/// # .https_or_http()
5336/// # .enable_http2()
5337/// # .build()
5338/// # );
5339/// # let mut hub = CloudBuild::new(client, auth);
5340/// // You can configure optional parameters by calling the respective setters at will, and
5341/// // execute the final call using `doit()`.
5342/// // Values shown here are possibly random and not representative !
5343/// let result = hub.operations().get("name")
5344/// .doit().await;
5345/// # }
5346/// ```
5347pub struct OperationGetCall<'a, C>
5348where
5349 C: 'a,
5350{
5351 hub: &'a CloudBuild<C>,
5352 _name: String,
5353 _delegate: Option<&'a mut dyn common::Delegate>,
5354 _additional_params: HashMap<String, String>,
5355 _scopes: BTreeSet<String>,
5356}
5357
5358impl<'a, C> common::CallBuilder for OperationGetCall<'a, C> {}
5359
5360impl<'a, C> OperationGetCall<'a, C>
5361where
5362 C: common::Connector,
5363{
5364 /// Perform the operation you have build so far.
5365 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
5366 use std::borrow::Cow;
5367 use std::io::{Read, Seek};
5368
5369 use common::{url::Params, ToParts};
5370 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5371
5372 let mut dd = common::DefaultDelegate;
5373 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5374 dlg.begin(common::MethodInfo {
5375 id: "cloudbuild.operations.get",
5376 http_method: hyper::Method::GET,
5377 });
5378
5379 for &field in ["alt", "name"].iter() {
5380 if self._additional_params.contains_key(field) {
5381 dlg.finished(false);
5382 return Err(common::Error::FieldClash(field));
5383 }
5384 }
5385
5386 let mut params = Params::with_capacity(3 + self._additional_params.len());
5387 params.push("name", self._name);
5388
5389 params.extend(self._additional_params.iter());
5390
5391 params.push("alt", "json");
5392 let mut url = self.hub._base_url.clone() + "v1/{+name}";
5393 if self._scopes.is_empty() {
5394 self._scopes
5395 .insert(Scope::CloudPlatform.as_ref().to_string());
5396 }
5397
5398 #[allow(clippy::single_element_loop)]
5399 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5400 url = params.uri_replacement(url, param_name, find_this, true);
5401 }
5402 {
5403 let to_remove = ["name"];
5404 params.remove_params(&to_remove);
5405 }
5406
5407 let url = params.parse_with_url(&url);
5408
5409 loop {
5410 let token = match self
5411 .hub
5412 .auth
5413 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5414 .await
5415 {
5416 Ok(token) => token,
5417 Err(e) => match dlg.token(e) {
5418 Ok(token) => token,
5419 Err(e) => {
5420 dlg.finished(false);
5421 return Err(common::Error::MissingToken(e));
5422 }
5423 },
5424 };
5425 let mut req_result = {
5426 let client = &self.hub.client;
5427 dlg.pre_request();
5428 let mut req_builder = hyper::Request::builder()
5429 .method(hyper::Method::GET)
5430 .uri(url.as_str())
5431 .header(USER_AGENT, self.hub._user_agent.clone());
5432
5433 if let Some(token) = token.as_ref() {
5434 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5435 }
5436
5437 let request = req_builder
5438 .header(CONTENT_LENGTH, 0_u64)
5439 .body(common::to_body::<String>(None));
5440
5441 client.request(request.unwrap()).await
5442 };
5443
5444 match req_result {
5445 Err(err) => {
5446 if let common::Retry::After(d) = dlg.http_error(&err) {
5447 sleep(d).await;
5448 continue;
5449 }
5450 dlg.finished(false);
5451 return Err(common::Error::HttpError(err));
5452 }
5453 Ok(res) => {
5454 let (mut parts, body) = res.into_parts();
5455 let mut body = common::Body::new(body);
5456 if !parts.status.is_success() {
5457 let bytes = common::to_bytes(body).await.unwrap_or_default();
5458 let error = serde_json::from_str(&common::to_string(&bytes));
5459 let response = common::to_response(parts, bytes.into());
5460
5461 if let common::Retry::After(d) =
5462 dlg.http_failure(&response, error.as_ref().ok())
5463 {
5464 sleep(d).await;
5465 continue;
5466 }
5467
5468 dlg.finished(false);
5469
5470 return Err(match error {
5471 Ok(value) => common::Error::BadRequest(value),
5472 _ => common::Error::Failure(response),
5473 });
5474 }
5475 let response = {
5476 let bytes = common::to_bytes(body).await.unwrap_or_default();
5477 let encoded = common::to_string(&bytes);
5478 match serde_json::from_str(&encoded) {
5479 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5480 Err(error) => {
5481 dlg.response_json_decode_error(&encoded, &error);
5482 return Err(common::Error::JsonDecodeError(
5483 encoded.to_string(),
5484 error,
5485 ));
5486 }
5487 }
5488 };
5489
5490 dlg.finished(true);
5491 return Ok(response);
5492 }
5493 }
5494 }
5495 }
5496
5497 /// The name of the operation resource.
5498 ///
5499 /// Sets the *name* path property to the given value.
5500 ///
5501 /// Even though the property as already been set when instantiating this call,
5502 /// we provide this method for API completeness.
5503 pub fn name(mut self, new_value: &str) -> OperationGetCall<'a, C> {
5504 self._name = new_value.to_string();
5505 self
5506 }
5507 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5508 /// while executing the actual API request.
5509 ///
5510 /// ````text
5511 /// It should be used to handle progress information, and to implement a certain level of resilience.
5512 /// ````
5513 ///
5514 /// Sets the *delegate* property to the given value.
5515 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> OperationGetCall<'a, C> {
5516 self._delegate = Some(new_value);
5517 self
5518 }
5519
5520 /// Set any additional parameter of the query string used in the request.
5521 /// It should be used to set parameters which are not yet available through their own
5522 /// setters.
5523 ///
5524 /// Please note that this method must not be used to set any of the known parameters
5525 /// which have their own setter method. If done anyway, the request will fail.
5526 ///
5527 /// # Additional Parameters
5528 ///
5529 /// * *$.xgafv* (query-string) - V1 error format.
5530 /// * *access_token* (query-string) - OAuth access token.
5531 /// * *alt* (query-string) - Data format for response.
5532 /// * *callback* (query-string) - JSONP
5533 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5534 /// * *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.
5535 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5536 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5537 /// * *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.
5538 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5539 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5540 pub fn param<T>(mut self, name: T, value: T) -> OperationGetCall<'a, C>
5541 where
5542 T: AsRef<str>,
5543 {
5544 self._additional_params
5545 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5546 self
5547 }
5548
5549 /// Identifies the authorization scope for the method you are building.
5550 ///
5551 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5552 /// [`Scope::CloudPlatform`].
5553 ///
5554 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5555 /// tokens for more than one scope.
5556 ///
5557 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5558 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5559 /// sufficient, a read-write scope will do as well.
5560 pub fn add_scope<St>(mut self, scope: St) -> OperationGetCall<'a, C>
5561 where
5562 St: AsRef<str>,
5563 {
5564 self._scopes.insert(String::from(scope.as_ref()));
5565 self
5566 }
5567 /// Identifies the authorization scope(s) for the method you are building.
5568 ///
5569 /// See [`Self::add_scope()`] for details.
5570 pub fn add_scopes<I, St>(mut self, scopes: I) -> OperationGetCall<'a, C>
5571 where
5572 I: IntoIterator<Item = St>,
5573 St: AsRef<str>,
5574 {
5575 self._scopes
5576 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5577 self
5578 }
5579
5580 /// Removes all scopes, and no default scope will be used either.
5581 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5582 /// for details).
5583 pub fn clear_scopes(mut self) -> OperationGetCall<'a, C> {
5584 self._scopes.clear();
5585 self
5586 }
5587}
5588
5589/// Approves or rejects a pending build. If approved, the returned long-running operation (LRO) will be analogous to the LRO returned from a CreateBuild call. If rejected, the returned LRO will be immediately done.
5590///
5591/// A builder for the *builds.approve* method supported by a *project* resource.
5592/// It is not used directly, but through a [`ProjectMethods`] instance.
5593///
5594/// # Example
5595///
5596/// Instantiate a resource method builder
5597///
5598/// ```test_harness,no_run
5599/// # extern crate hyper;
5600/// # extern crate hyper_rustls;
5601/// # extern crate google_cloudbuild1 as cloudbuild1;
5602/// use cloudbuild1::api::ApproveBuildRequest;
5603/// # async fn dox() {
5604/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5605///
5606/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5607/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5608/// # .with_native_roots()
5609/// # .unwrap()
5610/// # .https_only()
5611/// # .enable_http2()
5612/// # .build();
5613///
5614/// # let executor = hyper_util::rt::TokioExecutor::new();
5615/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5616/// # secret,
5617/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5618/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5619/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5620/// # ),
5621/// # ).build().await.unwrap();
5622///
5623/// # let client = hyper_util::client::legacy::Client::builder(
5624/// # hyper_util::rt::TokioExecutor::new()
5625/// # )
5626/// # .build(
5627/// # hyper_rustls::HttpsConnectorBuilder::new()
5628/// # .with_native_roots()
5629/// # .unwrap()
5630/// # .https_or_http()
5631/// # .enable_http2()
5632/// # .build()
5633/// # );
5634/// # let mut hub = CloudBuild::new(client, auth);
5635/// // As the method needs a request, you would usually fill it with the desired information
5636/// // into the respective structure. Some of the parts shown here might not be applicable !
5637/// // Values shown here are possibly random and not representative !
5638/// let mut req = ApproveBuildRequest::default();
5639///
5640/// // You can configure optional parameters by calling the respective setters at will, and
5641/// // execute the final call using `doit()`.
5642/// // Values shown here are possibly random and not representative !
5643/// let result = hub.projects().builds_approve(req, "name")
5644/// .doit().await;
5645/// # }
5646/// ```
5647pub struct ProjectBuildApproveCall<'a, C>
5648where
5649 C: 'a,
5650{
5651 hub: &'a CloudBuild<C>,
5652 _request: ApproveBuildRequest,
5653 _name: String,
5654 _delegate: Option<&'a mut dyn common::Delegate>,
5655 _additional_params: HashMap<String, String>,
5656 _scopes: BTreeSet<String>,
5657}
5658
5659impl<'a, C> common::CallBuilder for ProjectBuildApproveCall<'a, C> {}
5660
5661impl<'a, C> ProjectBuildApproveCall<'a, C>
5662where
5663 C: common::Connector,
5664{
5665 /// Perform the operation you have build so far.
5666 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
5667 use std::borrow::Cow;
5668 use std::io::{Read, Seek};
5669
5670 use common::{url::Params, ToParts};
5671 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5672
5673 let mut dd = common::DefaultDelegate;
5674 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5675 dlg.begin(common::MethodInfo {
5676 id: "cloudbuild.projects.builds.approve",
5677 http_method: hyper::Method::POST,
5678 });
5679
5680 for &field in ["alt", "name"].iter() {
5681 if self._additional_params.contains_key(field) {
5682 dlg.finished(false);
5683 return Err(common::Error::FieldClash(field));
5684 }
5685 }
5686
5687 let mut params = Params::with_capacity(4 + self._additional_params.len());
5688 params.push("name", self._name);
5689
5690 params.extend(self._additional_params.iter());
5691
5692 params.push("alt", "json");
5693 let mut url = self.hub._base_url.clone() + "v1/{+name}:approve";
5694 if self._scopes.is_empty() {
5695 self._scopes
5696 .insert(Scope::CloudPlatform.as_ref().to_string());
5697 }
5698
5699 #[allow(clippy::single_element_loop)]
5700 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5701 url = params.uri_replacement(url, param_name, find_this, true);
5702 }
5703 {
5704 let to_remove = ["name"];
5705 params.remove_params(&to_remove);
5706 }
5707
5708 let url = params.parse_with_url(&url);
5709
5710 let mut json_mime_type = mime::APPLICATION_JSON;
5711 let mut request_value_reader = {
5712 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5713 common::remove_json_null_values(&mut value);
5714 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5715 serde_json::to_writer(&mut dst, &value).unwrap();
5716 dst
5717 };
5718 let request_size = request_value_reader
5719 .seek(std::io::SeekFrom::End(0))
5720 .unwrap();
5721 request_value_reader
5722 .seek(std::io::SeekFrom::Start(0))
5723 .unwrap();
5724
5725 loop {
5726 let token = match self
5727 .hub
5728 .auth
5729 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5730 .await
5731 {
5732 Ok(token) => token,
5733 Err(e) => match dlg.token(e) {
5734 Ok(token) => token,
5735 Err(e) => {
5736 dlg.finished(false);
5737 return Err(common::Error::MissingToken(e));
5738 }
5739 },
5740 };
5741 request_value_reader
5742 .seek(std::io::SeekFrom::Start(0))
5743 .unwrap();
5744 let mut req_result = {
5745 let client = &self.hub.client;
5746 dlg.pre_request();
5747 let mut req_builder = hyper::Request::builder()
5748 .method(hyper::Method::POST)
5749 .uri(url.as_str())
5750 .header(USER_AGENT, self.hub._user_agent.clone());
5751
5752 if let Some(token) = token.as_ref() {
5753 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5754 }
5755
5756 let request = req_builder
5757 .header(CONTENT_TYPE, json_mime_type.to_string())
5758 .header(CONTENT_LENGTH, request_size as u64)
5759 .body(common::to_body(
5760 request_value_reader.get_ref().clone().into(),
5761 ));
5762
5763 client.request(request.unwrap()).await
5764 };
5765
5766 match req_result {
5767 Err(err) => {
5768 if let common::Retry::After(d) = dlg.http_error(&err) {
5769 sleep(d).await;
5770 continue;
5771 }
5772 dlg.finished(false);
5773 return Err(common::Error::HttpError(err));
5774 }
5775 Ok(res) => {
5776 let (mut parts, body) = res.into_parts();
5777 let mut body = common::Body::new(body);
5778 if !parts.status.is_success() {
5779 let bytes = common::to_bytes(body).await.unwrap_or_default();
5780 let error = serde_json::from_str(&common::to_string(&bytes));
5781 let response = common::to_response(parts, bytes.into());
5782
5783 if let common::Retry::After(d) =
5784 dlg.http_failure(&response, error.as_ref().ok())
5785 {
5786 sleep(d).await;
5787 continue;
5788 }
5789
5790 dlg.finished(false);
5791
5792 return Err(match error {
5793 Ok(value) => common::Error::BadRequest(value),
5794 _ => common::Error::Failure(response),
5795 });
5796 }
5797 let response = {
5798 let bytes = common::to_bytes(body).await.unwrap_or_default();
5799 let encoded = common::to_string(&bytes);
5800 match serde_json::from_str(&encoded) {
5801 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5802 Err(error) => {
5803 dlg.response_json_decode_error(&encoded, &error);
5804 return Err(common::Error::JsonDecodeError(
5805 encoded.to_string(),
5806 error,
5807 ));
5808 }
5809 }
5810 };
5811
5812 dlg.finished(true);
5813 return Ok(response);
5814 }
5815 }
5816 }
5817 }
5818
5819 ///
5820 /// Sets the *request* property to the given value.
5821 ///
5822 /// Even though the property as already been set when instantiating this call,
5823 /// we provide this method for API completeness.
5824 pub fn request(mut self, new_value: ApproveBuildRequest) -> ProjectBuildApproveCall<'a, C> {
5825 self._request = new_value;
5826 self
5827 }
5828 /// Required. Name of the target build. For example: "projects/{$project_id}/builds/{$build_id}"
5829 ///
5830 /// Sets the *name* path property to the given value.
5831 ///
5832 /// Even though the property as already been set when instantiating this call,
5833 /// we provide this method for API completeness.
5834 pub fn name(mut self, new_value: &str) -> ProjectBuildApproveCall<'a, C> {
5835 self._name = new_value.to_string();
5836 self
5837 }
5838 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5839 /// while executing the actual API request.
5840 ///
5841 /// ````text
5842 /// It should be used to handle progress information, and to implement a certain level of resilience.
5843 /// ````
5844 ///
5845 /// Sets the *delegate* property to the given value.
5846 pub fn delegate(
5847 mut self,
5848 new_value: &'a mut dyn common::Delegate,
5849 ) -> ProjectBuildApproveCall<'a, C> {
5850 self._delegate = Some(new_value);
5851 self
5852 }
5853
5854 /// Set any additional parameter of the query string used in the request.
5855 /// It should be used to set parameters which are not yet available through their own
5856 /// setters.
5857 ///
5858 /// Please note that this method must not be used to set any of the known parameters
5859 /// which have their own setter method. If done anyway, the request will fail.
5860 ///
5861 /// # Additional Parameters
5862 ///
5863 /// * *$.xgafv* (query-string) - V1 error format.
5864 /// * *access_token* (query-string) - OAuth access token.
5865 /// * *alt* (query-string) - Data format for response.
5866 /// * *callback* (query-string) - JSONP
5867 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5868 /// * *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.
5869 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5870 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5871 /// * *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.
5872 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5873 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5874 pub fn param<T>(mut self, name: T, value: T) -> ProjectBuildApproveCall<'a, C>
5875 where
5876 T: AsRef<str>,
5877 {
5878 self._additional_params
5879 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5880 self
5881 }
5882
5883 /// Identifies the authorization scope for the method you are building.
5884 ///
5885 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5886 /// [`Scope::CloudPlatform`].
5887 ///
5888 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5889 /// tokens for more than one scope.
5890 ///
5891 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5892 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5893 /// sufficient, a read-write scope will do as well.
5894 pub fn add_scope<St>(mut self, scope: St) -> ProjectBuildApproveCall<'a, C>
5895 where
5896 St: AsRef<str>,
5897 {
5898 self._scopes.insert(String::from(scope.as_ref()));
5899 self
5900 }
5901 /// Identifies the authorization scope(s) for the method you are building.
5902 ///
5903 /// See [`Self::add_scope()`] for details.
5904 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectBuildApproveCall<'a, C>
5905 where
5906 I: IntoIterator<Item = St>,
5907 St: AsRef<str>,
5908 {
5909 self._scopes
5910 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5911 self
5912 }
5913
5914 /// Removes all scopes, and no default scope will be used either.
5915 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5916 /// for details).
5917 pub fn clear_scopes(mut self) -> ProjectBuildApproveCall<'a, C> {
5918 self._scopes.clear();
5919 self
5920 }
5921}
5922
5923/// Cancels a build in progress.
5924///
5925/// A builder for the *builds.cancel* method supported by a *project* resource.
5926/// It is not used directly, but through a [`ProjectMethods`] instance.
5927///
5928/// # Example
5929///
5930/// Instantiate a resource method builder
5931///
5932/// ```test_harness,no_run
5933/// # extern crate hyper;
5934/// # extern crate hyper_rustls;
5935/// # extern crate google_cloudbuild1 as cloudbuild1;
5936/// use cloudbuild1::api::CancelBuildRequest;
5937/// # async fn dox() {
5938/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5939///
5940/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5941/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5942/// # .with_native_roots()
5943/// # .unwrap()
5944/// # .https_only()
5945/// # .enable_http2()
5946/// # .build();
5947///
5948/// # let executor = hyper_util::rt::TokioExecutor::new();
5949/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5950/// # secret,
5951/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5952/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5953/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5954/// # ),
5955/// # ).build().await.unwrap();
5956///
5957/// # let client = hyper_util::client::legacy::Client::builder(
5958/// # hyper_util::rt::TokioExecutor::new()
5959/// # )
5960/// # .build(
5961/// # hyper_rustls::HttpsConnectorBuilder::new()
5962/// # .with_native_roots()
5963/// # .unwrap()
5964/// # .https_or_http()
5965/// # .enable_http2()
5966/// # .build()
5967/// # );
5968/// # let mut hub = CloudBuild::new(client, auth);
5969/// // As the method needs a request, you would usually fill it with the desired information
5970/// // into the respective structure. Some of the parts shown here might not be applicable !
5971/// // Values shown here are possibly random and not representative !
5972/// let mut req = CancelBuildRequest::default();
5973///
5974/// // You can configure optional parameters by calling the respective setters at will, and
5975/// // execute the final call using `doit()`.
5976/// // Values shown here are possibly random and not representative !
5977/// let result = hub.projects().builds_cancel(req, "projectId", "id")
5978/// .doit().await;
5979/// # }
5980/// ```
5981pub struct ProjectBuildCancelCall<'a, C>
5982where
5983 C: 'a,
5984{
5985 hub: &'a CloudBuild<C>,
5986 _request: CancelBuildRequest,
5987 _project_id: String,
5988 _id: String,
5989 _delegate: Option<&'a mut dyn common::Delegate>,
5990 _additional_params: HashMap<String, String>,
5991 _scopes: BTreeSet<String>,
5992}
5993
5994impl<'a, C> common::CallBuilder for ProjectBuildCancelCall<'a, C> {}
5995
5996impl<'a, C> ProjectBuildCancelCall<'a, C>
5997where
5998 C: common::Connector,
5999{
6000 /// Perform the operation you have build so far.
6001 pub async fn doit(mut self) -> common::Result<(common::Response, Build)> {
6002 use std::borrow::Cow;
6003 use std::io::{Read, Seek};
6004
6005 use common::{url::Params, ToParts};
6006 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6007
6008 let mut dd = common::DefaultDelegate;
6009 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6010 dlg.begin(common::MethodInfo {
6011 id: "cloudbuild.projects.builds.cancel",
6012 http_method: hyper::Method::POST,
6013 });
6014
6015 for &field in ["alt", "projectId", "id"].iter() {
6016 if self._additional_params.contains_key(field) {
6017 dlg.finished(false);
6018 return Err(common::Error::FieldClash(field));
6019 }
6020 }
6021
6022 let mut params = Params::with_capacity(5 + self._additional_params.len());
6023 params.push("projectId", self._project_id);
6024 params.push("id", self._id);
6025
6026 params.extend(self._additional_params.iter());
6027
6028 params.push("alt", "json");
6029 let mut url = self.hub._base_url.clone() + "v1/projects/{projectId}/builds/{id}:cancel";
6030 if self._scopes.is_empty() {
6031 self._scopes
6032 .insert(Scope::CloudPlatform.as_ref().to_string());
6033 }
6034
6035 #[allow(clippy::single_element_loop)]
6036 for &(find_this, param_name) in [("{projectId}", "projectId"), ("{id}", "id")].iter() {
6037 url = params.uri_replacement(url, param_name, find_this, false);
6038 }
6039 {
6040 let to_remove = ["id", "projectId"];
6041 params.remove_params(&to_remove);
6042 }
6043
6044 let url = params.parse_with_url(&url);
6045
6046 let mut json_mime_type = mime::APPLICATION_JSON;
6047 let mut request_value_reader = {
6048 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6049 common::remove_json_null_values(&mut value);
6050 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6051 serde_json::to_writer(&mut dst, &value).unwrap();
6052 dst
6053 };
6054 let request_size = request_value_reader
6055 .seek(std::io::SeekFrom::End(0))
6056 .unwrap();
6057 request_value_reader
6058 .seek(std::io::SeekFrom::Start(0))
6059 .unwrap();
6060
6061 loop {
6062 let token = match self
6063 .hub
6064 .auth
6065 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6066 .await
6067 {
6068 Ok(token) => token,
6069 Err(e) => match dlg.token(e) {
6070 Ok(token) => token,
6071 Err(e) => {
6072 dlg.finished(false);
6073 return Err(common::Error::MissingToken(e));
6074 }
6075 },
6076 };
6077 request_value_reader
6078 .seek(std::io::SeekFrom::Start(0))
6079 .unwrap();
6080 let mut req_result = {
6081 let client = &self.hub.client;
6082 dlg.pre_request();
6083 let mut req_builder = hyper::Request::builder()
6084 .method(hyper::Method::POST)
6085 .uri(url.as_str())
6086 .header(USER_AGENT, self.hub._user_agent.clone());
6087
6088 if let Some(token) = token.as_ref() {
6089 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6090 }
6091
6092 let request = req_builder
6093 .header(CONTENT_TYPE, json_mime_type.to_string())
6094 .header(CONTENT_LENGTH, request_size as u64)
6095 .body(common::to_body(
6096 request_value_reader.get_ref().clone().into(),
6097 ));
6098
6099 client.request(request.unwrap()).await
6100 };
6101
6102 match req_result {
6103 Err(err) => {
6104 if let common::Retry::After(d) = dlg.http_error(&err) {
6105 sleep(d).await;
6106 continue;
6107 }
6108 dlg.finished(false);
6109 return Err(common::Error::HttpError(err));
6110 }
6111 Ok(res) => {
6112 let (mut parts, body) = res.into_parts();
6113 let mut body = common::Body::new(body);
6114 if !parts.status.is_success() {
6115 let bytes = common::to_bytes(body).await.unwrap_or_default();
6116 let error = serde_json::from_str(&common::to_string(&bytes));
6117 let response = common::to_response(parts, bytes.into());
6118
6119 if let common::Retry::After(d) =
6120 dlg.http_failure(&response, error.as_ref().ok())
6121 {
6122 sleep(d).await;
6123 continue;
6124 }
6125
6126 dlg.finished(false);
6127
6128 return Err(match error {
6129 Ok(value) => common::Error::BadRequest(value),
6130 _ => common::Error::Failure(response),
6131 });
6132 }
6133 let response = {
6134 let bytes = common::to_bytes(body).await.unwrap_or_default();
6135 let encoded = common::to_string(&bytes);
6136 match serde_json::from_str(&encoded) {
6137 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6138 Err(error) => {
6139 dlg.response_json_decode_error(&encoded, &error);
6140 return Err(common::Error::JsonDecodeError(
6141 encoded.to_string(),
6142 error,
6143 ));
6144 }
6145 }
6146 };
6147
6148 dlg.finished(true);
6149 return Ok(response);
6150 }
6151 }
6152 }
6153 }
6154
6155 ///
6156 /// Sets the *request* property to the given value.
6157 ///
6158 /// Even though the property as already been set when instantiating this call,
6159 /// we provide this method for API completeness.
6160 pub fn request(mut self, new_value: CancelBuildRequest) -> ProjectBuildCancelCall<'a, C> {
6161 self._request = new_value;
6162 self
6163 }
6164 /// Required. ID of the project.
6165 ///
6166 /// Sets the *project id* path property to the given value.
6167 ///
6168 /// Even though the property as already been set when instantiating this call,
6169 /// we provide this method for API completeness.
6170 pub fn project_id(mut self, new_value: &str) -> ProjectBuildCancelCall<'a, C> {
6171 self._project_id = new_value.to_string();
6172 self
6173 }
6174 /// Required. ID of the build.
6175 ///
6176 /// Sets the *id* path property to the given value.
6177 ///
6178 /// Even though the property as already been set when instantiating this call,
6179 /// we provide this method for API completeness.
6180 pub fn id(mut self, new_value: &str) -> ProjectBuildCancelCall<'a, C> {
6181 self._id = new_value.to_string();
6182 self
6183 }
6184 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6185 /// while executing the actual API request.
6186 ///
6187 /// ````text
6188 /// It should be used to handle progress information, and to implement a certain level of resilience.
6189 /// ````
6190 ///
6191 /// Sets the *delegate* property to the given value.
6192 pub fn delegate(
6193 mut self,
6194 new_value: &'a mut dyn common::Delegate,
6195 ) -> ProjectBuildCancelCall<'a, C> {
6196 self._delegate = Some(new_value);
6197 self
6198 }
6199
6200 /// Set any additional parameter of the query string used in the request.
6201 /// It should be used to set parameters which are not yet available through their own
6202 /// setters.
6203 ///
6204 /// Please note that this method must not be used to set any of the known parameters
6205 /// which have their own setter method. If done anyway, the request will fail.
6206 ///
6207 /// # Additional Parameters
6208 ///
6209 /// * *$.xgafv* (query-string) - V1 error format.
6210 /// * *access_token* (query-string) - OAuth access token.
6211 /// * *alt* (query-string) - Data format for response.
6212 /// * *callback* (query-string) - JSONP
6213 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6214 /// * *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.
6215 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6216 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6217 /// * *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.
6218 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6219 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6220 pub fn param<T>(mut self, name: T, value: T) -> ProjectBuildCancelCall<'a, C>
6221 where
6222 T: AsRef<str>,
6223 {
6224 self._additional_params
6225 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6226 self
6227 }
6228
6229 /// Identifies the authorization scope for the method you are building.
6230 ///
6231 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6232 /// [`Scope::CloudPlatform`].
6233 ///
6234 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6235 /// tokens for more than one scope.
6236 ///
6237 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6238 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6239 /// sufficient, a read-write scope will do as well.
6240 pub fn add_scope<St>(mut self, scope: St) -> ProjectBuildCancelCall<'a, C>
6241 where
6242 St: AsRef<str>,
6243 {
6244 self._scopes.insert(String::from(scope.as_ref()));
6245 self
6246 }
6247 /// Identifies the authorization scope(s) for the method you are building.
6248 ///
6249 /// See [`Self::add_scope()`] for details.
6250 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectBuildCancelCall<'a, C>
6251 where
6252 I: IntoIterator<Item = St>,
6253 St: AsRef<str>,
6254 {
6255 self._scopes
6256 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6257 self
6258 }
6259
6260 /// Removes all scopes, and no default scope will be used either.
6261 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6262 /// for details).
6263 pub fn clear_scopes(mut self) -> ProjectBuildCancelCall<'a, C> {
6264 self._scopes.clear();
6265 self
6266 }
6267}
6268
6269/// 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`).
6270///
6271/// A builder for the *builds.create* method supported by a *project* resource.
6272/// It is not used directly, but through a [`ProjectMethods`] instance.
6273///
6274/// # Example
6275///
6276/// Instantiate a resource method builder
6277///
6278/// ```test_harness,no_run
6279/// # extern crate hyper;
6280/// # extern crate hyper_rustls;
6281/// # extern crate google_cloudbuild1 as cloudbuild1;
6282/// use cloudbuild1::api::Build;
6283/// # async fn dox() {
6284/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6285///
6286/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6287/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6288/// # .with_native_roots()
6289/// # .unwrap()
6290/// # .https_only()
6291/// # .enable_http2()
6292/// # .build();
6293///
6294/// # let executor = hyper_util::rt::TokioExecutor::new();
6295/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6296/// # secret,
6297/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6298/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6299/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6300/// # ),
6301/// # ).build().await.unwrap();
6302///
6303/// # let client = hyper_util::client::legacy::Client::builder(
6304/// # hyper_util::rt::TokioExecutor::new()
6305/// # )
6306/// # .build(
6307/// # hyper_rustls::HttpsConnectorBuilder::new()
6308/// # .with_native_roots()
6309/// # .unwrap()
6310/// # .https_or_http()
6311/// # .enable_http2()
6312/// # .build()
6313/// # );
6314/// # let mut hub = CloudBuild::new(client, auth);
6315/// // As the method needs a request, you would usually fill it with the desired information
6316/// // into the respective structure. Some of the parts shown here might not be applicable !
6317/// // Values shown here are possibly random and not representative !
6318/// let mut req = Build::default();
6319///
6320/// // You can configure optional parameters by calling the respective setters at will, and
6321/// // execute the final call using `doit()`.
6322/// // Values shown here are possibly random and not representative !
6323/// let result = hub.projects().builds_create(req, "projectId")
6324/// .parent("ea")
6325/// .doit().await;
6326/// # }
6327/// ```
6328pub struct ProjectBuildCreateCall<'a, C>
6329where
6330 C: 'a,
6331{
6332 hub: &'a CloudBuild<C>,
6333 _request: Build,
6334 _project_id: String,
6335 _parent: Option<String>,
6336 _delegate: Option<&'a mut dyn common::Delegate>,
6337 _additional_params: HashMap<String, String>,
6338 _scopes: BTreeSet<String>,
6339}
6340
6341impl<'a, C> common::CallBuilder for ProjectBuildCreateCall<'a, C> {}
6342
6343impl<'a, C> ProjectBuildCreateCall<'a, C>
6344where
6345 C: common::Connector,
6346{
6347 /// Perform the operation you have build so far.
6348 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
6349 use std::borrow::Cow;
6350 use std::io::{Read, Seek};
6351
6352 use common::{url::Params, ToParts};
6353 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6354
6355 let mut dd = common::DefaultDelegate;
6356 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6357 dlg.begin(common::MethodInfo {
6358 id: "cloudbuild.projects.builds.create",
6359 http_method: hyper::Method::POST,
6360 });
6361
6362 for &field in ["alt", "projectId", "parent"].iter() {
6363 if self._additional_params.contains_key(field) {
6364 dlg.finished(false);
6365 return Err(common::Error::FieldClash(field));
6366 }
6367 }
6368
6369 let mut params = Params::with_capacity(5 + self._additional_params.len());
6370 params.push("projectId", self._project_id);
6371 if let Some(value) = self._parent.as_ref() {
6372 params.push("parent", value);
6373 }
6374
6375 params.extend(self._additional_params.iter());
6376
6377 params.push("alt", "json");
6378 let mut url = self.hub._base_url.clone() + "v1/projects/{projectId}/builds";
6379 if self._scopes.is_empty() {
6380 self._scopes
6381 .insert(Scope::CloudPlatform.as_ref().to_string());
6382 }
6383
6384 #[allow(clippy::single_element_loop)]
6385 for &(find_this, param_name) in [("{projectId}", "projectId")].iter() {
6386 url = params.uri_replacement(url, param_name, find_this, false);
6387 }
6388 {
6389 let to_remove = ["projectId"];
6390 params.remove_params(&to_remove);
6391 }
6392
6393 let url = params.parse_with_url(&url);
6394
6395 let mut json_mime_type = mime::APPLICATION_JSON;
6396 let mut request_value_reader = {
6397 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6398 common::remove_json_null_values(&mut value);
6399 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6400 serde_json::to_writer(&mut dst, &value).unwrap();
6401 dst
6402 };
6403 let request_size = request_value_reader
6404 .seek(std::io::SeekFrom::End(0))
6405 .unwrap();
6406 request_value_reader
6407 .seek(std::io::SeekFrom::Start(0))
6408 .unwrap();
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 request_value_reader
6427 .seek(std::io::SeekFrom::Start(0))
6428 .unwrap();
6429 let mut req_result = {
6430 let client = &self.hub.client;
6431 dlg.pre_request();
6432 let mut req_builder = hyper::Request::builder()
6433 .method(hyper::Method::POST)
6434 .uri(url.as_str())
6435 .header(USER_AGENT, self.hub._user_agent.clone());
6436
6437 if let Some(token) = token.as_ref() {
6438 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6439 }
6440
6441 let request = req_builder
6442 .header(CONTENT_TYPE, json_mime_type.to_string())
6443 .header(CONTENT_LENGTH, request_size as u64)
6444 .body(common::to_body(
6445 request_value_reader.get_ref().clone().into(),
6446 ));
6447
6448 client.request(request.unwrap()).await
6449 };
6450
6451 match req_result {
6452 Err(err) => {
6453 if let common::Retry::After(d) = dlg.http_error(&err) {
6454 sleep(d).await;
6455 continue;
6456 }
6457 dlg.finished(false);
6458 return Err(common::Error::HttpError(err));
6459 }
6460 Ok(res) => {
6461 let (mut parts, body) = res.into_parts();
6462 let mut body = common::Body::new(body);
6463 if !parts.status.is_success() {
6464 let bytes = common::to_bytes(body).await.unwrap_or_default();
6465 let error = serde_json::from_str(&common::to_string(&bytes));
6466 let response = common::to_response(parts, bytes.into());
6467
6468 if let common::Retry::After(d) =
6469 dlg.http_failure(&response, error.as_ref().ok())
6470 {
6471 sleep(d).await;
6472 continue;
6473 }
6474
6475 dlg.finished(false);
6476
6477 return Err(match error {
6478 Ok(value) => common::Error::BadRequest(value),
6479 _ => common::Error::Failure(response),
6480 });
6481 }
6482 let response = {
6483 let bytes = common::to_bytes(body).await.unwrap_or_default();
6484 let encoded = common::to_string(&bytes);
6485 match serde_json::from_str(&encoded) {
6486 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6487 Err(error) => {
6488 dlg.response_json_decode_error(&encoded, &error);
6489 return Err(common::Error::JsonDecodeError(
6490 encoded.to_string(),
6491 error,
6492 ));
6493 }
6494 }
6495 };
6496
6497 dlg.finished(true);
6498 return Ok(response);
6499 }
6500 }
6501 }
6502 }
6503
6504 ///
6505 /// Sets the *request* property to the given value.
6506 ///
6507 /// Even though the property as already been set when instantiating this call,
6508 /// we provide this method for API completeness.
6509 pub fn request(mut self, new_value: Build) -> ProjectBuildCreateCall<'a, C> {
6510 self._request = new_value;
6511 self
6512 }
6513 /// Required. ID of the project.
6514 ///
6515 /// Sets the *project id* path property to the given value.
6516 ///
6517 /// Even though the property as already been set when instantiating this call,
6518 /// we provide this method for API completeness.
6519 pub fn project_id(mut self, new_value: &str) -> ProjectBuildCreateCall<'a, C> {
6520 self._project_id = new_value.to_string();
6521 self
6522 }
6523 /// The parent resource where this build will be created. Format: `projects/{project}/locations/{location}`
6524 ///
6525 /// Sets the *parent* query property to the given value.
6526 pub fn parent(mut self, new_value: &str) -> ProjectBuildCreateCall<'a, C> {
6527 self._parent = Some(new_value.to_string());
6528 self
6529 }
6530 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6531 /// while executing the actual API request.
6532 ///
6533 /// ````text
6534 /// It should be used to handle progress information, and to implement a certain level of resilience.
6535 /// ````
6536 ///
6537 /// Sets the *delegate* property to the given value.
6538 pub fn delegate(
6539 mut self,
6540 new_value: &'a mut dyn common::Delegate,
6541 ) -> ProjectBuildCreateCall<'a, C> {
6542 self._delegate = Some(new_value);
6543 self
6544 }
6545
6546 /// Set any additional parameter of the query string used in the request.
6547 /// It should be used to set parameters which are not yet available through their own
6548 /// setters.
6549 ///
6550 /// Please note that this method must not be used to set any of the known parameters
6551 /// which have their own setter method. If done anyway, the request will fail.
6552 ///
6553 /// # Additional Parameters
6554 ///
6555 /// * *$.xgafv* (query-string) - V1 error format.
6556 /// * *access_token* (query-string) - OAuth access token.
6557 /// * *alt* (query-string) - Data format for response.
6558 /// * *callback* (query-string) - JSONP
6559 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6560 /// * *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.
6561 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6562 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6563 /// * *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.
6564 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6565 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6566 pub fn param<T>(mut self, name: T, value: T) -> ProjectBuildCreateCall<'a, C>
6567 where
6568 T: AsRef<str>,
6569 {
6570 self._additional_params
6571 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6572 self
6573 }
6574
6575 /// Identifies the authorization scope for the method you are building.
6576 ///
6577 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6578 /// [`Scope::CloudPlatform`].
6579 ///
6580 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6581 /// tokens for more than one scope.
6582 ///
6583 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6584 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6585 /// sufficient, a read-write scope will do as well.
6586 pub fn add_scope<St>(mut self, scope: St) -> ProjectBuildCreateCall<'a, C>
6587 where
6588 St: AsRef<str>,
6589 {
6590 self._scopes.insert(String::from(scope.as_ref()));
6591 self
6592 }
6593 /// Identifies the authorization scope(s) for the method you are building.
6594 ///
6595 /// See [`Self::add_scope()`] for details.
6596 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectBuildCreateCall<'a, C>
6597 where
6598 I: IntoIterator<Item = St>,
6599 St: AsRef<str>,
6600 {
6601 self._scopes
6602 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6603 self
6604 }
6605
6606 /// Removes all scopes, and no default scope will be used either.
6607 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6608 /// for details).
6609 pub fn clear_scopes(mut self) -> ProjectBuildCreateCall<'a, C> {
6610 self._scopes.clear();
6611 self
6612 }
6613}
6614
6615/// Returns information about a previously requested build. The `Build` that is returned includes its status (such as `SUCCESS`, `FAILURE`, or `WORKING`), and timing information.
6616///
6617/// A builder for the *builds.get* method supported by a *project* resource.
6618/// It is not used directly, but through a [`ProjectMethods`] instance.
6619///
6620/// # Example
6621///
6622/// Instantiate a resource method builder
6623///
6624/// ```test_harness,no_run
6625/// # extern crate hyper;
6626/// # extern crate hyper_rustls;
6627/// # extern crate google_cloudbuild1 as cloudbuild1;
6628/// # async fn dox() {
6629/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6630///
6631/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6632/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6633/// # .with_native_roots()
6634/// # .unwrap()
6635/// # .https_only()
6636/// # .enable_http2()
6637/// # .build();
6638///
6639/// # let executor = hyper_util::rt::TokioExecutor::new();
6640/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6641/// # secret,
6642/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6643/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6644/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6645/// # ),
6646/// # ).build().await.unwrap();
6647///
6648/// # let client = hyper_util::client::legacy::Client::builder(
6649/// # hyper_util::rt::TokioExecutor::new()
6650/// # )
6651/// # .build(
6652/// # hyper_rustls::HttpsConnectorBuilder::new()
6653/// # .with_native_roots()
6654/// # .unwrap()
6655/// # .https_or_http()
6656/// # .enable_http2()
6657/// # .build()
6658/// # );
6659/// # let mut hub = CloudBuild::new(client, auth);
6660/// // You can configure optional parameters by calling the respective setters at will, and
6661/// // execute the final call using `doit()`.
6662/// // Values shown here are possibly random and not representative !
6663/// let result = hub.projects().builds_get("projectId", "id")
6664/// .name("amet")
6665/// .doit().await;
6666/// # }
6667/// ```
6668pub struct ProjectBuildGetCall<'a, C>
6669where
6670 C: 'a,
6671{
6672 hub: &'a CloudBuild<C>,
6673 _project_id: String,
6674 _id: String,
6675 _name: Option<String>,
6676 _delegate: Option<&'a mut dyn common::Delegate>,
6677 _additional_params: HashMap<String, String>,
6678 _scopes: BTreeSet<String>,
6679}
6680
6681impl<'a, C> common::CallBuilder for ProjectBuildGetCall<'a, C> {}
6682
6683impl<'a, C> ProjectBuildGetCall<'a, C>
6684where
6685 C: common::Connector,
6686{
6687 /// Perform the operation you have build so far.
6688 pub async fn doit(mut self) -> common::Result<(common::Response, Build)> {
6689 use std::borrow::Cow;
6690 use std::io::{Read, Seek};
6691
6692 use common::{url::Params, ToParts};
6693 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6694
6695 let mut dd = common::DefaultDelegate;
6696 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6697 dlg.begin(common::MethodInfo {
6698 id: "cloudbuild.projects.builds.get",
6699 http_method: hyper::Method::GET,
6700 });
6701
6702 for &field in ["alt", "projectId", "id", "name"].iter() {
6703 if self._additional_params.contains_key(field) {
6704 dlg.finished(false);
6705 return Err(common::Error::FieldClash(field));
6706 }
6707 }
6708
6709 let mut params = Params::with_capacity(5 + self._additional_params.len());
6710 params.push("projectId", self._project_id);
6711 params.push("id", self._id);
6712 if let Some(value) = self._name.as_ref() {
6713 params.push("name", value);
6714 }
6715
6716 params.extend(self._additional_params.iter());
6717
6718 params.push("alt", "json");
6719 let mut url = self.hub._base_url.clone() + "v1/projects/{projectId}/builds/{id}";
6720 if self._scopes.is_empty() {
6721 self._scopes
6722 .insert(Scope::CloudPlatform.as_ref().to_string());
6723 }
6724
6725 #[allow(clippy::single_element_loop)]
6726 for &(find_this, param_name) in [("{projectId}", "projectId"), ("{id}", "id")].iter() {
6727 url = params.uri_replacement(url, param_name, find_this, false);
6728 }
6729 {
6730 let to_remove = ["id", "projectId"];
6731 params.remove_params(&to_remove);
6732 }
6733
6734 let url = params.parse_with_url(&url);
6735
6736 loop {
6737 let token = match self
6738 .hub
6739 .auth
6740 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6741 .await
6742 {
6743 Ok(token) => token,
6744 Err(e) => match dlg.token(e) {
6745 Ok(token) => token,
6746 Err(e) => {
6747 dlg.finished(false);
6748 return Err(common::Error::MissingToken(e));
6749 }
6750 },
6751 };
6752 let mut req_result = {
6753 let client = &self.hub.client;
6754 dlg.pre_request();
6755 let mut req_builder = hyper::Request::builder()
6756 .method(hyper::Method::GET)
6757 .uri(url.as_str())
6758 .header(USER_AGENT, self.hub._user_agent.clone());
6759
6760 if let Some(token) = token.as_ref() {
6761 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6762 }
6763
6764 let request = req_builder
6765 .header(CONTENT_LENGTH, 0_u64)
6766 .body(common::to_body::<String>(None));
6767
6768 client.request(request.unwrap()).await
6769 };
6770
6771 match req_result {
6772 Err(err) => {
6773 if let common::Retry::After(d) = dlg.http_error(&err) {
6774 sleep(d).await;
6775 continue;
6776 }
6777 dlg.finished(false);
6778 return Err(common::Error::HttpError(err));
6779 }
6780 Ok(res) => {
6781 let (mut parts, body) = res.into_parts();
6782 let mut body = common::Body::new(body);
6783 if !parts.status.is_success() {
6784 let bytes = common::to_bytes(body).await.unwrap_or_default();
6785 let error = serde_json::from_str(&common::to_string(&bytes));
6786 let response = common::to_response(parts, bytes.into());
6787
6788 if let common::Retry::After(d) =
6789 dlg.http_failure(&response, error.as_ref().ok())
6790 {
6791 sleep(d).await;
6792 continue;
6793 }
6794
6795 dlg.finished(false);
6796
6797 return Err(match error {
6798 Ok(value) => common::Error::BadRequest(value),
6799 _ => common::Error::Failure(response),
6800 });
6801 }
6802 let response = {
6803 let bytes = common::to_bytes(body).await.unwrap_or_default();
6804 let encoded = common::to_string(&bytes);
6805 match serde_json::from_str(&encoded) {
6806 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6807 Err(error) => {
6808 dlg.response_json_decode_error(&encoded, &error);
6809 return Err(common::Error::JsonDecodeError(
6810 encoded.to_string(),
6811 error,
6812 ));
6813 }
6814 }
6815 };
6816
6817 dlg.finished(true);
6818 return Ok(response);
6819 }
6820 }
6821 }
6822 }
6823
6824 /// Required. ID of the project.
6825 ///
6826 /// Sets the *project id* path property to the given value.
6827 ///
6828 /// Even though the property as already been set when instantiating this call,
6829 /// we provide this method for API completeness.
6830 pub fn project_id(mut self, new_value: &str) -> ProjectBuildGetCall<'a, C> {
6831 self._project_id = new_value.to_string();
6832 self
6833 }
6834 /// Required. ID of the build.
6835 ///
6836 /// Sets the *id* path property to the given value.
6837 ///
6838 /// Even though the property as already been set when instantiating this call,
6839 /// we provide this method for API completeness.
6840 pub fn id(mut self, new_value: &str) -> ProjectBuildGetCall<'a, C> {
6841 self._id = new_value.to_string();
6842 self
6843 }
6844 /// The name of the `Build` to retrieve. Format: `projects/{project}/locations/{location}/builds/{build}`
6845 ///
6846 /// Sets the *name* query property to the given value.
6847 pub fn name(mut self, new_value: &str) -> ProjectBuildGetCall<'a, C> {
6848 self._name = Some(new_value.to_string());
6849 self
6850 }
6851 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6852 /// while executing the actual API request.
6853 ///
6854 /// ````text
6855 /// It should be used to handle progress information, and to implement a certain level of resilience.
6856 /// ````
6857 ///
6858 /// Sets the *delegate* property to the given value.
6859 pub fn delegate(
6860 mut self,
6861 new_value: &'a mut dyn common::Delegate,
6862 ) -> ProjectBuildGetCall<'a, C> {
6863 self._delegate = Some(new_value);
6864 self
6865 }
6866
6867 /// Set any additional parameter of the query string used in the request.
6868 /// It should be used to set parameters which are not yet available through their own
6869 /// setters.
6870 ///
6871 /// Please note that this method must not be used to set any of the known parameters
6872 /// which have their own setter method. If done anyway, the request will fail.
6873 ///
6874 /// # Additional Parameters
6875 ///
6876 /// * *$.xgafv* (query-string) - V1 error format.
6877 /// * *access_token* (query-string) - OAuth access token.
6878 /// * *alt* (query-string) - Data format for response.
6879 /// * *callback* (query-string) - JSONP
6880 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6881 /// * *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.
6882 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6883 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6884 /// * *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.
6885 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6886 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6887 pub fn param<T>(mut self, name: T, value: T) -> ProjectBuildGetCall<'a, C>
6888 where
6889 T: AsRef<str>,
6890 {
6891 self._additional_params
6892 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6893 self
6894 }
6895
6896 /// Identifies the authorization scope for the method you are building.
6897 ///
6898 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6899 /// [`Scope::CloudPlatform`].
6900 ///
6901 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6902 /// tokens for more than one scope.
6903 ///
6904 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6905 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6906 /// sufficient, a read-write scope will do as well.
6907 pub fn add_scope<St>(mut self, scope: St) -> ProjectBuildGetCall<'a, C>
6908 where
6909 St: AsRef<str>,
6910 {
6911 self._scopes.insert(String::from(scope.as_ref()));
6912 self
6913 }
6914 /// Identifies the authorization scope(s) for the method you are building.
6915 ///
6916 /// See [`Self::add_scope()`] for details.
6917 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectBuildGetCall<'a, C>
6918 where
6919 I: IntoIterator<Item = St>,
6920 St: AsRef<str>,
6921 {
6922 self._scopes
6923 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6924 self
6925 }
6926
6927 /// Removes all scopes, and no default scope will be used either.
6928 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6929 /// for details).
6930 pub fn clear_scopes(mut self) -> ProjectBuildGetCall<'a, C> {
6931 self._scopes.clear();
6932 self
6933 }
6934}
6935
6936/// Lists previously requested builds. Previously requested builds may still be in-progress, or may have finished successfully or unsuccessfully.
6937///
6938/// A builder for the *builds.list* method supported by a *project* resource.
6939/// It is not used directly, but through a [`ProjectMethods`] instance.
6940///
6941/// # Example
6942///
6943/// Instantiate a resource method builder
6944///
6945/// ```test_harness,no_run
6946/// # extern crate hyper;
6947/// # extern crate hyper_rustls;
6948/// # extern crate google_cloudbuild1 as cloudbuild1;
6949/// # async fn dox() {
6950/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6951///
6952/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6953/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6954/// # .with_native_roots()
6955/// # .unwrap()
6956/// # .https_only()
6957/// # .enable_http2()
6958/// # .build();
6959///
6960/// # let executor = hyper_util::rt::TokioExecutor::new();
6961/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6962/// # secret,
6963/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6964/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6965/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6966/// # ),
6967/// # ).build().await.unwrap();
6968///
6969/// # let client = hyper_util::client::legacy::Client::builder(
6970/// # hyper_util::rt::TokioExecutor::new()
6971/// # )
6972/// # .build(
6973/// # hyper_rustls::HttpsConnectorBuilder::new()
6974/// # .with_native_roots()
6975/// # .unwrap()
6976/// # .https_or_http()
6977/// # .enable_http2()
6978/// # .build()
6979/// # );
6980/// # let mut hub = CloudBuild::new(client, auth);
6981/// // You can configure optional parameters by calling the respective setters at will, and
6982/// // execute the final call using `doit()`.
6983/// // Values shown here are possibly random and not representative !
6984/// let result = hub.projects().builds_list("projectId")
6985/// .parent("ipsum")
6986/// .page_token("sed")
6987/// .page_size(-37)
6988/// .filter("gubergren")
6989/// .doit().await;
6990/// # }
6991/// ```
6992pub struct ProjectBuildListCall<'a, C>
6993where
6994 C: 'a,
6995{
6996 hub: &'a CloudBuild<C>,
6997 _project_id: String,
6998 _parent: Option<String>,
6999 _page_token: Option<String>,
7000 _page_size: Option<i32>,
7001 _filter: Option<String>,
7002 _delegate: Option<&'a mut dyn common::Delegate>,
7003 _additional_params: HashMap<String, String>,
7004 _scopes: BTreeSet<String>,
7005}
7006
7007impl<'a, C> common::CallBuilder for ProjectBuildListCall<'a, C> {}
7008
7009impl<'a, C> ProjectBuildListCall<'a, C>
7010where
7011 C: common::Connector,
7012{
7013 /// Perform the operation you have build so far.
7014 pub async fn doit(mut self) -> common::Result<(common::Response, ListBuildsResponse)> {
7015 use std::borrow::Cow;
7016 use std::io::{Read, Seek};
7017
7018 use common::{url::Params, ToParts};
7019 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7020
7021 let mut dd = common::DefaultDelegate;
7022 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7023 dlg.begin(common::MethodInfo {
7024 id: "cloudbuild.projects.builds.list",
7025 http_method: hyper::Method::GET,
7026 });
7027
7028 for &field in [
7029 "alt",
7030 "projectId",
7031 "parent",
7032 "pageToken",
7033 "pageSize",
7034 "filter",
7035 ]
7036 .iter()
7037 {
7038 if self._additional_params.contains_key(field) {
7039 dlg.finished(false);
7040 return Err(common::Error::FieldClash(field));
7041 }
7042 }
7043
7044 let mut params = Params::with_capacity(7 + self._additional_params.len());
7045 params.push("projectId", self._project_id);
7046 if let Some(value) = self._parent.as_ref() {
7047 params.push("parent", value);
7048 }
7049 if let Some(value) = self._page_token.as_ref() {
7050 params.push("pageToken", value);
7051 }
7052 if let Some(value) = self._page_size.as_ref() {
7053 params.push("pageSize", value.to_string());
7054 }
7055 if let Some(value) = self._filter.as_ref() {
7056 params.push("filter", value);
7057 }
7058
7059 params.extend(self._additional_params.iter());
7060
7061 params.push("alt", "json");
7062 let mut url = self.hub._base_url.clone() + "v1/projects/{projectId}/builds";
7063 if self._scopes.is_empty() {
7064 self._scopes
7065 .insert(Scope::CloudPlatform.as_ref().to_string());
7066 }
7067
7068 #[allow(clippy::single_element_loop)]
7069 for &(find_this, param_name) in [("{projectId}", "projectId")].iter() {
7070 url = params.uri_replacement(url, param_name, find_this, false);
7071 }
7072 {
7073 let to_remove = ["projectId"];
7074 params.remove_params(&to_remove);
7075 }
7076
7077 let url = params.parse_with_url(&url);
7078
7079 loop {
7080 let token = match self
7081 .hub
7082 .auth
7083 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7084 .await
7085 {
7086 Ok(token) => token,
7087 Err(e) => match dlg.token(e) {
7088 Ok(token) => token,
7089 Err(e) => {
7090 dlg.finished(false);
7091 return Err(common::Error::MissingToken(e));
7092 }
7093 },
7094 };
7095 let mut req_result = {
7096 let client = &self.hub.client;
7097 dlg.pre_request();
7098 let mut req_builder = hyper::Request::builder()
7099 .method(hyper::Method::GET)
7100 .uri(url.as_str())
7101 .header(USER_AGENT, self.hub._user_agent.clone());
7102
7103 if let Some(token) = token.as_ref() {
7104 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7105 }
7106
7107 let request = req_builder
7108 .header(CONTENT_LENGTH, 0_u64)
7109 .body(common::to_body::<String>(None));
7110
7111 client.request(request.unwrap()).await
7112 };
7113
7114 match req_result {
7115 Err(err) => {
7116 if let common::Retry::After(d) = dlg.http_error(&err) {
7117 sleep(d).await;
7118 continue;
7119 }
7120 dlg.finished(false);
7121 return Err(common::Error::HttpError(err));
7122 }
7123 Ok(res) => {
7124 let (mut parts, body) = res.into_parts();
7125 let mut body = common::Body::new(body);
7126 if !parts.status.is_success() {
7127 let bytes = common::to_bytes(body).await.unwrap_or_default();
7128 let error = serde_json::from_str(&common::to_string(&bytes));
7129 let response = common::to_response(parts, bytes.into());
7130
7131 if let common::Retry::After(d) =
7132 dlg.http_failure(&response, error.as_ref().ok())
7133 {
7134 sleep(d).await;
7135 continue;
7136 }
7137
7138 dlg.finished(false);
7139
7140 return Err(match error {
7141 Ok(value) => common::Error::BadRequest(value),
7142 _ => common::Error::Failure(response),
7143 });
7144 }
7145 let response = {
7146 let bytes = common::to_bytes(body).await.unwrap_or_default();
7147 let encoded = common::to_string(&bytes);
7148 match serde_json::from_str(&encoded) {
7149 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7150 Err(error) => {
7151 dlg.response_json_decode_error(&encoded, &error);
7152 return Err(common::Error::JsonDecodeError(
7153 encoded.to_string(),
7154 error,
7155 ));
7156 }
7157 }
7158 };
7159
7160 dlg.finished(true);
7161 return Ok(response);
7162 }
7163 }
7164 }
7165 }
7166
7167 /// Required. ID of the project.
7168 ///
7169 /// Sets the *project id* path property to the given value.
7170 ///
7171 /// Even though the property as already been set when instantiating this call,
7172 /// we provide this method for API completeness.
7173 pub fn project_id(mut self, new_value: &str) -> ProjectBuildListCall<'a, C> {
7174 self._project_id = new_value.to_string();
7175 self
7176 }
7177 /// The parent of the collection of `Builds`. Format: `projects/{project}/locations/{location}`
7178 ///
7179 /// Sets the *parent* query property to the given value.
7180 pub fn parent(mut self, new_value: &str) -> ProjectBuildListCall<'a, C> {
7181 self._parent = Some(new_value.to_string());
7182 self
7183 }
7184 /// 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.
7185 ///
7186 /// Sets the *page token* query property to the given value.
7187 pub fn page_token(mut self, new_value: &str) -> ProjectBuildListCall<'a, C> {
7188 self._page_token = Some(new_value.to_string());
7189 self
7190 }
7191 /// Number of results to return in the list.
7192 ///
7193 /// Sets the *page size* query property to the given value.
7194 pub fn page_size(mut self, new_value: i32) -> ProjectBuildListCall<'a, C> {
7195 self._page_size = Some(new_value);
7196 self
7197 }
7198 /// The raw filter text to constrain the results.
7199 ///
7200 /// Sets the *filter* query property to the given value.
7201 pub fn filter(mut self, new_value: &str) -> ProjectBuildListCall<'a, C> {
7202 self._filter = Some(new_value.to_string());
7203 self
7204 }
7205 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7206 /// while executing the actual API request.
7207 ///
7208 /// ````text
7209 /// It should be used to handle progress information, and to implement a certain level of resilience.
7210 /// ````
7211 ///
7212 /// Sets the *delegate* property to the given value.
7213 pub fn delegate(
7214 mut self,
7215 new_value: &'a mut dyn common::Delegate,
7216 ) -> ProjectBuildListCall<'a, C> {
7217 self._delegate = Some(new_value);
7218 self
7219 }
7220
7221 /// Set any additional parameter of the query string used in the request.
7222 /// It should be used to set parameters which are not yet available through their own
7223 /// setters.
7224 ///
7225 /// Please note that this method must not be used to set any of the known parameters
7226 /// which have their own setter method. If done anyway, the request will fail.
7227 ///
7228 /// # Additional Parameters
7229 ///
7230 /// * *$.xgafv* (query-string) - V1 error format.
7231 /// * *access_token* (query-string) - OAuth access token.
7232 /// * *alt* (query-string) - Data format for response.
7233 /// * *callback* (query-string) - JSONP
7234 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7235 /// * *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.
7236 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7237 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7238 /// * *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.
7239 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7240 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7241 pub fn param<T>(mut self, name: T, value: T) -> ProjectBuildListCall<'a, C>
7242 where
7243 T: AsRef<str>,
7244 {
7245 self._additional_params
7246 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7247 self
7248 }
7249
7250 /// Identifies the authorization scope for the method you are building.
7251 ///
7252 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7253 /// [`Scope::CloudPlatform`].
7254 ///
7255 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7256 /// tokens for more than one scope.
7257 ///
7258 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7259 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7260 /// sufficient, a read-write scope will do as well.
7261 pub fn add_scope<St>(mut self, scope: St) -> ProjectBuildListCall<'a, C>
7262 where
7263 St: AsRef<str>,
7264 {
7265 self._scopes.insert(String::from(scope.as_ref()));
7266 self
7267 }
7268 /// Identifies the authorization scope(s) for the method you are building.
7269 ///
7270 /// See [`Self::add_scope()`] for details.
7271 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectBuildListCall<'a, C>
7272 where
7273 I: IntoIterator<Item = St>,
7274 St: AsRef<str>,
7275 {
7276 self._scopes
7277 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7278 self
7279 }
7280
7281 /// Removes all scopes, and no default scope will be used either.
7282 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7283 /// for details).
7284 pub fn clear_scopes(mut self) -> ProjectBuildListCall<'a, C> {
7285 self._scopes.clear();
7286 self
7287 }
7288}
7289
7290/// 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.
7291///
7292/// A builder for the *builds.retry* method supported by a *project* resource.
7293/// It is not used directly, but through a [`ProjectMethods`] instance.
7294///
7295/// # Example
7296///
7297/// Instantiate a resource method builder
7298///
7299/// ```test_harness,no_run
7300/// # extern crate hyper;
7301/// # extern crate hyper_rustls;
7302/// # extern crate google_cloudbuild1 as cloudbuild1;
7303/// use cloudbuild1::api::RetryBuildRequest;
7304/// # async fn dox() {
7305/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7306///
7307/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7308/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7309/// # .with_native_roots()
7310/// # .unwrap()
7311/// # .https_only()
7312/// # .enable_http2()
7313/// # .build();
7314///
7315/// # let executor = hyper_util::rt::TokioExecutor::new();
7316/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7317/// # secret,
7318/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7319/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7320/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7321/// # ),
7322/// # ).build().await.unwrap();
7323///
7324/// # let client = hyper_util::client::legacy::Client::builder(
7325/// # hyper_util::rt::TokioExecutor::new()
7326/// # )
7327/// # .build(
7328/// # hyper_rustls::HttpsConnectorBuilder::new()
7329/// # .with_native_roots()
7330/// # .unwrap()
7331/// # .https_or_http()
7332/// # .enable_http2()
7333/// # .build()
7334/// # );
7335/// # let mut hub = CloudBuild::new(client, auth);
7336/// // As the method needs a request, you would usually fill it with the desired information
7337/// // into the respective structure. Some of the parts shown here might not be applicable !
7338/// // Values shown here are possibly random and not representative !
7339/// let mut req = RetryBuildRequest::default();
7340///
7341/// // You can configure optional parameters by calling the respective setters at will, and
7342/// // execute the final call using `doit()`.
7343/// // Values shown here are possibly random and not representative !
7344/// let result = hub.projects().builds_retry(req, "projectId", "id")
7345/// .doit().await;
7346/// # }
7347/// ```
7348pub struct ProjectBuildRetryCall<'a, C>
7349where
7350 C: 'a,
7351{
7352 hub: &'a CloudBuild<C>,
7353 _request: RetryBuildRequest,
7354 _project_id: String,
7355 _id: String,
7356 _delegate: Option<&'a mut dyn common::Delegate>,
7357 _additional_params: HashMap<String, String>,
7358 _scopes: BTreeSet<String>,
7359}
7360
7361impl<'a, C> common::CallBuilder for ProjectBuildRetryCall<'a, C> {}
7362
7363impl<'a, C> ProjectBuildRetryCall<'a, C>
7364where
7365 C: common::Connector,
7366{
7367 /// Perform the operation you have build so far.
7368 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
7369 use std::borrow::Cow;
7370 use std::io::{Read, Seek};
7371
7372 use common::{url::Params, ToParts};
7373 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7374
7375 let mut dd = common::DefaultDelegate;
7376 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7377 dlg.begin(common::MethodInfo {
7378 id: "cloudbuild.projects.builds.retry",
7379 http_method: hyper::Method::POST,
7380 });
7381
7382 for &field in ["alt", "projectId", "id"].iter() {
7383 if self._additional_params.contains_key(field) {
7384 dlg.finished(false);
7385 return Err(common::Error::FieldClash(field));
7386 }
7387 }
7388
7389 let mut params = Params::with_capacity(5 + self._additional_params.len());
7390 params.push("projectId", self._project_id);
7391 params.push("id", self._id);
7392
7393 params.extend(self._additional_params.iter());
7394
7395 params.push("alt", "json");
7396 let mut url = self.hub._base_url.clone() + "v1/projects/{projectId}/builds/{id}:retry";
7397 if self._scopes.is_empty() {
7398 self._scopes
7399 .insert(Scope::CloudPlatform.as_ref().to_string());
7400 }
7401
7402 #[allow(clippy::single_element_loop)]
7403 for &(find_this, param_name) in [("{projectId}", "projectId"), ("{id}", "id")].iter() {
7404 url = params.uri_replacement(url, param_name, find_this, false);
7405 }
7406 {
7407 let to_remove = ["id", "projectId"];
7408 params.remove_params(&to_remove);
7409 }
7410
7411 let url = params.parse_with_url(&url);
7412
7413 let mut json_mime_type = mime::APPLICATION_JSON;
7414 let mut request_value_reader = {
7415 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7416 common::remove_json_null_values(&mut value);
7417 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7418 serde_json::to_writer(&mut dst, &value).unwrap();
7419 dst
7420 };
7421 let request_size = request_value_reader
7422 .seek(std::io::SeekFrom::End(0))
7423 .unwrap();
7424 request_value_reader
7425 .seek(std::io::SeekFrom::Start(0))
7426 .unwrap();
7427
7428 loop {
7429 let token = match self
7430 .hub
7431 .auth
7432 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7433 .await
7434 {
7435 Ok(token) => token,
7436 Err(e) => match dlg.token(e) {
7437 Ok(token) => token,
7438 Err(e) => {
7439 dlg.finished(false);
7440 return Err(common::Error::MissingToken(e));
7441 }
7442 },
7443 };
7444 request_value_reader
7445 .seek(std::io::SeekFrom::Start(0))
7446 .unwrap();
7447 let mut req_result = {
7448 let client = &self.hub.client;
7449 dlg.pre_request();
7450 let mut req_builder = hyper::Request::builder()
7451 .method(hyper::Method::POST)
7452 .uri(url.as_str())
7453 .header(USER_AGENT, self.hub._user_agent.clone());
7454
7455 if let Some(token) = token.as_ref() {
7456 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7457 }
7458
7459 let request = req_builder
7460 .header(CONTENT_TYPE, json_mime_type.to_string())
7461 .header(CONTENT_LENGTH, request_size as u64)
7462 .body(common::to_body(
7463 request_value_reader.get_ref().clone().into(),
7464 ));
7465
7466 client.request(request.unwrap()).await
7467 };
7468
7469 match req_result {
7470 Err(err) => {
7471 if let common::Retry::After(d) = dlg.http_error(&err) {
7472 sleep(d).await;
7473 continue;
7474 }
7475 dlg.finished(false);
7476 return Err(common::Error::HttpError(err));
7477 }
7478 Ok(res) => {
7479 let (mut parts, body) = res.into_parts();
7480 let mut body = common::Body::new(body);
7481 if !parts.status.is_success() {
7482 let bytes = common::to_bytes(body).await.unwrap_or_default();
7483 let error = serde_json::from_str(&common::to_string(&bytes));
7484 let response = common::to_response(parts, bytes.into());
7485
7486 if let common::Retry::After(d) =
7487 dlg.http_failure(&response, error.as_ref().ok())
7488 {
7489 sleep(d).await;
7490 continue;
7491 }
7492
7493 dlg.finished(false);
7494
7495 return Err(match error {
7496 Ok(value) => common::Error::BadRequest(value),
7497 _ => common::Error::Failure(response),
7498 });
7499 }
7500 let response = {
7501 let bytes = common::to_bytes(body).await.unwrap_or_default();
7502 let encoded = common::to_string(&bytes);
7503 match serde_json::from_str(&encoded) {
7504 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7505 Err(error) => {
7506 dlg.response_json_decode_error(&encoded, &error);
7507 return Err(common::Error::JsonDecodeError(
7508 encoded.to_string(),
7509 error,
7510 ));
7511 }
7512 }
7513 };
7514
7515 dlg.finished(true);
7516 return Ok(response);
7517 }
7518 }
7519 }
7520 }
7521
7522 ///
7523 /// Sets the *request* property to the given value.
7524 ///
7525 /// Even though the property as already been set when instantiating this call,
7526 /// we provide this method for API completeness.
7527 pub fn request(mut self, new_value: RetryBuildRequest) -> ProjectBuildRetryCall<'a, C> {
7528 self._request = new_value;
7529 self
7530 }
7531 /// Required. ID of the project.
7532 ///
7533 /// Sets the *project id* path property to the given value.
7534 ///
7535 /// Even though the property as already been set when instantiating this call,
7536 /// we provide this method for API completeness.
7537 pub fn project_id(mut self, new_value: &str) -> ProjectBuildRetryCall<'a, C> {
7538 self._project_id = new_value.to_string();
7539 self
7540 }
7541 /// Required. Build ID of the original build.
7542 ///
7543 /// Sets the *id* path property to the given value.
7544 ///
7545 /// Even though the property as already been set when instantiating this call,
7546 /// we provide this method for API completeness.
7547 pub fn id(mut self, new_value: &str) -> ProjectBuildRetryCall<'a, C> {
7548 self._id = new_value.to_string();
7549 self
7550 }
7551 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7552 /// while executing the actual API request.
7553 ///
7554 /// ````text
7555 /// It should be used to handle progress information, and to implement a certain level of resilience.
7556 /// ````
7557 ///
7558 /// Sets the *delegate* property to the given value.
7559 pub fn delegate(
7560 mut self,
7561 new_value: &'a mut dyn common::Delegate,
7562 ) -> ProjectBuildRetryCall<'a, C> {
7563 self._delegate = Some(new_value);
7564 self
7565 }
7566
7567 /// Set any additional parameter of the query string used in the request.
7568 /// It should be used to set parameters which are not yet available through their own
7569 /// setters.
7570 ///
7571 /// Please note that this method must not be used to set any of the known parameters
7572 /// which have their own setter method. If done anyway, the request will fail.
7573 ///
7574 /// # Additional Parameters
7575 ///
7576 /// * *$.xgafv* (query-string) - V1 error format.
7577 /// * *access_token* (query-string) - OAuth access token.
7578 /// * *alt* (query-string) - Data format for response.
7579 /// * *callback* (query-string) - JSONP
7580 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7581 /// * *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.
7582 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7583 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7584 /// * *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.
7585 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7586 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7587 pub fn param<T>(mut self, name: T, value: T) -> ProjectBuildRetryCall<'a, C>
7588 where
7589 T: AsRef<str>,
7590 {
7591 self._additional_params
7592 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7593 self
7594 }
7595
7596 /// Identifies the authorization scope for the method you are building.
7597 ///
7598 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7599 /// [`Scope::CloudPlatform`].
7600 ///
7601 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7602 /// tokens for more than one scope.
7603 ///
7604 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7605 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7606 /// sufficient, a read-write scope will do as well.
7607 pub fn add_scope<St>(mut self, scope: St) -> ProjectBuildRetryCall<'a, C>
7608 where
7609 St: AsRef<str>,
7610 {
7611 self._scopes.insert(String::from(scope.as_ref()));
7612 self
7613 }
7614 /// Identifies the authorization scope(s) for the method you are building.
7615 ///
7616 /// See [`Self::add_scope()`] for details.
7617 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectBuildRetryCall<'a, C>
7618 where
7619 I: IntoIterator<Item = St>,
7620 St: AsRef<str>,
7621 {
7622 self._scopes
7623 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7624 self
7625 }
7626
7627 /// Removes all scopes, and no default scope will be used either.
7628 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7629 /// for details).
7630 pub fn clear_scopes(mut self) -> ProjectBuildRetryCall<'a, C> {
7631 self._scopes.clear();
7632 self
7633 }
7634}
7635
7636/// Create an association between a GCP project and a GitHub Enterprise server.
7637///
7638/// A builder for the *githubEnterpriseConfigs.create* method supported by a *project* resource.
7639/// It is not used directly, but through a [`ProjectMethods`] instance.
7640///
7641/// # Example
7642///
7643/// Instantiate a resource method builder
7644///
7645/// ```test_harness,no_run
7646/// # extern crate hyper;
7647/// # extern crate hyper_rustls;
7648/// # extern crate google_cloudbuild1 as cloudbuild1;
7649/// use cloudbuild1::api::GitHubEnterpriseConfig;
7650/// # async fn dox() {
7651/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7652///
7653/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7654/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7655/// # .with_native_roots()
7656/// # .unwrap()
7657/// # .https_only()
7658/// # .enable_http2()
7659/// # .build();
7660///
7661/// # let executor = hyper_util::rt::TokioExecutor::new();
7662/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7663/// # secret,
7664/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7665/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7666/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7667/// # ),
7668/// # ).build().await.unwrap();
7669///
7670/// # let client = hyper_util::client::legacy::Client::builder(
7671/// # hyper_util::rt::TokioExecutor::new()
7672/// # )
7673/// # .build(
7674/// # hyper_rustls::HttpsConnectorBuilder::new()
7675/// # .with_native_roots()
7676/// # .unwrap()
7677/// # .https_or_http()
7678/// # .enable_http2()
7679/// # .build()
7680/// # );
7681/// # let mut hub = CloudBuild::new(client, auth);
7682/// // As the method needs a request, you would usually fill it with the desired information
7683/// // into the respective structure. Some of the parts shown here might not be applicable !
7684/// // Values shown here are possibly random and not representative !
7685/// let mut req = GitHubEnterpriseConfig::default();
7686///
7687/// // You can configure optional parameters by calling the respective setters at will, and
7688/// // execute the final call using `doit()`.
7689/// // Values shown here are possibly random and not representative !
7690/// let result = hub.projects().github_enterprise_configs_create(req, "parent")
7691/// .project_id("ipsum")
7692/// .ghe_config_id("est")
7693/// .doit().await;
7694/// # }
7695/// ```
7696pub struct ProjectGithubEnterpriseConfigCreateCall<'a, C>
7697where
7698 C: 'a,
7699{
7700 hub: &'a CloudBuild<C>,
7701 _request: GitHubEnterpriseConfig,
7702 _parent: String,
7703 _project_id: Option<String>,
7704 _ghe_config_id: Option<String>,
7705 _delegate: Option<&'a mut dyn common::Delegate>,
7706 _additional_params: HashMap<String, String>,
7707 _scopes: BTreeSet<String>,
7708}
7709
7710impl<'a, C> common::CallBuilder for ProjectGithubEnterpriseConfigCreateCall<'a, C> {}
7711
7712impl<'a, C> ProjectGithubEnterpriseConfigCreateCall<'a, C>
7713where
7714 C: common::Connector,
7715{
7716 /// Perform the operation you have build so far.
7717 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
7718 use std::borrow::Cow;
7719 use std::io::{Read, Seek};
7720
7721 use common::{url::Params, ToParts};
7722 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7723
7724 let mut dd = common::DefaultDelegate;
7725 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7726 dlg.begin(common::MethodInfo {
7727 id: "cloudbuild.projects.githubEnterpriseConfigs.create",
7728 http_method: hyper::Method::POST,
7729 });
7730
7731 for &field in ["alt", "parent", "projectId", "gheConfigId"].iter() {
7732 if self._additional_params.contains_key(field) {
7733 dlg.finished(false);
7734 return Err(common::Error::FieldClash(field));
7735 }
7736 }
7737
7738 let mut params = Params::with_capacity(6 + self._additional_params.len());
7739 params.push("parent", self._parent);
7740 if let Some(value) = self._project_id.as_ref() {
7741 params.push("projectId", value);
7742 }
7743 if let Some(value) = self._ghe_config_id.as_ref() {
7744 params.push("gheConfigId", value);
7745 }
7746
7747 params.extend(self._additional_params.iter());
7748
7749 params.push("alt", "json");
7750 let mut url = self.hub._base_url.clone() + "v1/{+parent}/githubEnterpriseConfigs";
7751 if self._scopes.is_empty() {
7752 self._scopes
7753 .insert(Scope::CloudPlatform.as_ref().to_string());
7754 }
7755
7756 #[allow(clippy::single_element_loop)]
7757 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
7758 url = params.uri_replacement(url, param_name, find_this, true);
7759 }
7760 {
7761 let to_remove = ["parent"];
7762 params.remove_params(&to_remove);
7763 }
7764
7765 let url = params.parse_with_url(&url);
7766
7767 let mut json_mime_type = mime::APPLICATION_JSON;
7768 let mut request_value_reader = {
7769 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7770 common::remove_json_null_values(&mut value);
7771 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7772 serde_json::to_writer(&mut dst, &value).unwrap();
7773 dst
7774 };
7775 let request_size = request_value_reader
7776 .seek(std::io::SeekFrom::End(0))
7777 .unwrap();
7778 request_value_reader
7779 .seek(std::io::SeekFrom::Start(0))
7780 .unwrap();
7781
7782 loop {
7783 let token = match self
7784 .hub
7785 .auth
7786 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7787 .await
7788 {
7789 Ok(token) => token,
7790 Err(e) => match dlg.token(e) {
7791 Ok(token) => token,
7792 Err(e) => {
7793 dlg.finished(false);
7794 return Err(common::Error::MissingToken(e));
7795 }
7796 },
7797 };
7798 request_value_reader
7799 .seek(std::io::SeekFrom::Start(0))
7800 .unwrap();
7801 let mut req_result = {
7802 let client = &self.hub.client;
7803 dlg.pre_request();
7804 let mut req_builder = hyper::Request::builder()
7805 .method(hyper::Method::POST)
7806 .uri(url.as_str())
7807 .header(USER_AGENT, self.hub._user_agent.clone());
7808
7809 if let Some(token) = token.as_ref() {
7810 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7811 }
7812
7813 let request = req_builder
7814 .header(CONTENT_TYPE, json_mime_type.to_string())
7815 .header(CONTENT_LENGTH, request_size as u64)
7816 .body(common::to_body(
7817 request_value_reader.get_ref().clone().into(),
7818 ));
7819
7820 client.request(request.unwrap()).await
7821 };
7822
7823 match req_result {
7824 Err(err) => {
7825 if let common::Retry::After(d) = dlg.http_error(&err) {
7826 sleep(d).await;
7827 continue;
7828 }
7829 dlg.finished(false);
7830 return Err(common::Error::HttpError(err));
7831 }
7832 Ok(res) => {
7833 let (mut parts, body) = res.into_parts();
7834 let mut body = common::Body::new(body);
7835 if !parts.status.is_success() {
7836 let bytes = common::to_bytes(body).await.unwrap_or_default();
7837 let error = serde_json::from_str(&common::to_string(&bytes));
7838 let response = common::to_response(parts, bytes.into());
7839
7840 if let common::Retry::After(d) =
7841 dlg.http_failure(&response, error.as_ref().ok())
7842 {
7843 sleep(d).await;
7844 continue;
7845 }
7846
7847 dlg.finished(false);
7848
7849 return Err(match error {
7850 Ok(value) => common::Error::BadRequest(value),
7851 _ => common::Error::Failure(response),
7852 });
7853 }
7854 let response = {
7855 let bytes = common::to_bytes(body).await.unwrap_or_default();
7856 let encoded = common::to_string(&bytes);
7857 match serde_json::from_str(&encoded) {
7858 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7859 Err(error) => {
7860 dlg.response_json_decode_error(&encoded, &error);
7861 return Err(common::Error::JsonDecodeError(
7862 encoded.to_string(),
7863 error,
7864 ));
7865 }
7866 }
7867 };
7868
7869 dlg.finished(true);
7870 return Ok(response);
7871 }
7872 }
7873 }
7874 }
7875
7876 ///
7877 /// Sets the *request* property to the given value.
7878 ///
7879 /// Even though the property as already been set when instantiating this call,
7880 /// we provide this method for API completeness.
7881 pub fn request(
7882 mut self,
7883 new_value: GitHubEnterpriseConfig,
7884 ) -> ProjectGithubEnterpriseConfigCreateCall<'a, C> {
7885 self._request = new_value;
7886 self
7887 }
7888 /// Name of the parent project. For example: projects/{$project_number} or projects/{$project_id}
7889 ///
7890 /// Sets the *parent* path property to the given value.
7891 ///
7892 /// Even though the property as already been set when instantiating this call,
7893 /// we provide this method for API completeness.
7894 pub fn parent(mut self, new_value: &str) -> ProjectGithubEnterpriseConfigCreateCall<'a, C> {
7895 self._parent = new_value.to_string();
7896 self
7897 }
7898 /// ID of the project.
7899 ///
7900 /// Sets the *project id* query property to the given value.
7901 pub fn project_id(mut self, new_value: &str) -> ProjectGithubEnterpriseConfigCreateCall<'a, C> {
7902 self._project_id = Some(new_value.to_string());
7903 self
7904 }
7905 /// 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
7906 ///
7907 /// Sets the *ghe config id* query property to the given value.
7908 pub fn ghe_config_id(
7909 mut self,
7910 new_value: &str,
7911 ) -> ProjectGithubEnterpriseConfigCreateCall<'a, C> {
7912 self._ghe_config_id = Some(new_value.to_string());
7913 self
7914 }
7915 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7916 /// while executing the actual API request.
7917 ///
7918 /// ````text
7919 /// It should be used to handle progress information, and to implement a certain level of resilience.
7920 /// ````
7921 ///
7922 /// Sets the *delegate* property to the given value.
7923 pub fn delegate(
7924 mut self,
7925 new_value: &'a mut dyn common::Delegate,
7926 ) -> ProjectGithubEnterpriseConfigCreateCall<'a, C> {
7927 self._delegate = Some(new_value);
7928 self
7929 }
7930
7931 /// Set any additional parameter of the query string used in the request.
7932 /// It should be used to set parameters which are not yet available through their own
7933 /// setters.
7934 ///
7935 /// Please note that this method must not be used to set any of the known parameters
7936 /// which have their own setter method. If done anyway, the request will fail.
7937 ///
7938 /// # Additional Parameters
7939 ///
7940 /// * *$.xgafv* (query-string) - V1 error format.
7941 /// * *access_token* (query-string) - OAuth access token.
7942 /// * *alt* (query-string) - Data format for response.
7943 /// * *callback* (query-string) - JSONP
7944 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7945 /// * *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.
7946 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7947 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7948 /// * *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.
7949 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7950 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7951 pub fn param<T>(mut self, name: T, value: T) -> ProjectGithubEnterpriseConfigCreateCall<'a, C>
7952 where
7953 T: AsRef<str>,
7954 {
7955 self._additional_params
7956 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7957 self
7958 }
7959
7960 /// Identifies the authorization scope for the method you are building.
7961 ///
7962 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7963 /// [`Scope::CloudPlatform`].
7964 ///
7965 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7966 /// tokens for more than one scope.
7967 ///
7968 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7969 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7970 /// sufficient, a read-write scope will do as well.
7971 pub fn add_scope<St>(mut self, scope: St) -> ProjectGithubEnterpriseConfigCreateCall<'a, C>
7972 where
7973 St: AsRef<str>,
7974 {
7975 self._scopes.insert(String::from(scope.as_ref()));
7976 self
7977 }
7978 /// Identifies the authorization scope(s) for the method you are building.
7979 ///
7980 /// See [`Self::add_scope()`] for details.
7981 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectGithubEnterpriseConfigCreateCall<'a, C>
7982 where
7983 I: IntoIterator<Item = St>,
7984 St: AsRef<str>,
7985 {
7986 self._scopes
7987 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7988 self
7989 }
7990
7991 /// Removes all scopes, and no default scope will be used either.
7992 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7993 /// for details).
7994 pub fn clear_scopes(mut self) -> ProjectGithubEnterpriseConfigCreateCall<'a, C> {
7995 self._scopes.clear();
7996 self
7997 }
7998}
7999
8000/// Delete an association between a GCP project and a GitHub Enterprise server.
8001///
8002/// A builder for the *githubEnterpriseConfigs.delete* method supported by a *project* resource.
8003/// It is not used directly, but through a [`ProjectMethods`] instance.
8004///
8005/// # Example
8006///
8007/// Instantiate a resource method builder
8008///
8009/// ```test_harness,no_run
8010/// # extern crate hyper;
8011/// # extern crate hyper_rustls;
8012/// # extern crate google_cloudbuild1 as cloudbuild1;
8013/// # async fn dox() {
8014/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8015///
8016/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8017/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8018/// # .with_native_roots()
8019/// # .unwrap()
8020/// # .https_only()
8021/// # .enable_http2()
8022/// # .build();
8023///
8024/// # let executor = hyper_util::rt::TokioExecutor::new();
8025/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8026/// # secret,
8027/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8028/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8029/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8030/// # ),
8031/// # ).build().await.unwrap();
8032///
8033/// # let client = hyper_util::client::legacy::Client::builder(
8034/// # hyper_util::rt::TokioExecutor::new()
8035/// # )
8036/// # .build(
8037/// # hyper_rustls::HttpsConnectorBuilder::new()
8038/// # .with_native_roots()
8039/// # .unwrap()
8040/// # .https_or_http()
8041/// # .enable_http2()
8042/// # .build()
8043/// # );
8044/// # let mut hub = CloudBuild::new(client, auth);
8045/// // You can configure optional parameters by calling the respective setters at will, and
8046/// // execute the final call using `doit()`.
8047/// // Values shown here are possibly random and not representative !
8048/// let result = hub.projects().github_enterprise_configs_delete("name")
8049/// .project_id("ea")
8050/// .config_id("dolor")
8051/// .doit().await;
8052/// # }
8053/// ```
8054pub struct ProjectGithubEnterpriseConfigDeleteCall<'a, C>
8055where
8056 C: 'a,
8057{
8058 hub: &'a CloudBuild<C>,
8059 _name: String,
8060 _project_id: Option<String>,
8061 _config_id: Option<String>,
8062 _delegate: Option<&'a mut dyn common::Delegate>,
8063 _additional_params: HashMap<String, String>,
8064 _scopes: BTreeSet<String>,
8065}
8066
8067impl<'a, C> common::CallBuilder for ProjectGithubEnterpriseConfigDeleteCall<'a, C> {}
8068
8069impl<'a, C> ProjectGithubEnterpriseConfigDeleteCall<'a, C>
8070where
8071 C: common::Connector,
8072{
8073 /// Perform the operation you have build so far.
8074 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
8075 use std::borrow::Cow;
8076 use std::io::{Read, Seek};
8077
8078 use common::{url::Params, ToParts};
8079 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8080
8081 let mut dd = common::DefaultDelegate;
8082 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8083 dlg.begin(common::MethodInfo {
8084 id: "cloudbuild.projects.githubEnterpriseConfigs.delete",
8085 http_method: hyper::Method::DELETE,
8086 });
8087
8088 for &field in ["alt", "name", "projectId", "configId"].iter() {
8089 if self._additional_params.contains_key(field) {
8090 dlg.finished(false);
8091 return Err(common::Error::FieldClash(field));
8092 }
8093 }
8094
8095 let mut params = Params::with_capacity(5 + self._additional_params.len());
8096 params.push("name", self._name);
8097 if let Some(value) = self._project_id.as_ref() {
8098 params.push("projectId", value);
8099 }
8100 if let Some(value) = self._config_id.as_ref() {
8101 params.push("configId", value);
8102 }
8103
8104 params.extend(self._additional_params.iter());
8105
8106 params.push("alt", "json");
8107 let mut url = self.hub._base_url.clone() + "v1/{+name}";
8108 if self._scopes.is_empty() {
8109 self._scopes
8110 .insert(Scope::CloudPlatform.as_ref().to_string());
8111 }
8112
8113 #[allow(clippy::single_element_loop)]
8114 for &(find_this, param_name) in [("{+name}", "name")].iter() {
8115 url = params.uri_replacement(url, param_name, find_this, true);
8116 }
8117 {
8118 let to_remove = ["name"];
8119 params.remove_params(&to_remove);
8120 }
8121
8122 let url = params.parse_with_url(&url);
8123
8124 loop {
8125 let token = match self
8126 .hub
8127 .auth
8128 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8129 .await
8130 {
8131 Ok(token) => token,
8132 Err(e) => match dlg.token(e) {
8133 Ok(token) => token,
8134 Err(e) => {
8135 dlg.finished(false);
8136 return Err(common::Error::MissingToken(e));
8137 }
8138 },
8139 };
8140 let mut req_result = {
8141 let client = &self.hub.client;
8142 dlg.pre_request();
8143 let mut req_builder = hyper::Request::builder()
8144 .method(hyper::Method::DELETE)
8145 .uri(url.as_str())
8146 .header(USER_AGENT, self.hub._user_agent.clone());
8147
8148 if let Some(token) = token.as_ref() {
8149 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8150 }
8151
8152 let request = req_builder
8153 .header(CONTENT_LENGTH, 0_u64)
8154 .body(common::to_body::<String>(None));
8155
8156 client.request(request.unwrap()).await
8157 };
8158
8159 match req_result {
8160 Err(err) => {
8161 if let common::Retry::After(d) = dlg.http_error(&err) {
8162 sleep(d).await;
8163 continue;
8164 }
8165 dlg.finished(false);
8166 return Err(common::Error::HttpError(err));
8167 }
8168 Ok(res) => {
8169 let (mut parts, body) = res.into_parts();
8170 let mut body = common::Body::new(body);
8171 if !parts.status.is_success() {
8172 let bytes = common::to_bytes(body).await.unwrap_or_default();
8173 let error = serde_json::from_str(&common::to_string(&bytes));
8174 let response = common::to_response(parts, bytes.into());
8175
8176 if let common::Retry::After(d) =
8177 dlg.http_failure(&response, error.as_ref().ok())
8178 {
8179 sleep(d).await;
8180 continue;
8181 }
8182
8183 dlg.finished(false);
8184
8185 return Err(match error {
8186 Ok(value) => common::Error::BadRequest(value),
8187 _ => common::Error::Failure(response),
8188 });
8189 }
8190 let response = {
8191 let bytes = common::to_bytes(body).await.unwrap_or_default();
8192 let encoded = common::to_string(&bytes);
8193 match serde_json::from_str(&encoded) {
8194 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8195 Err(error) => {
8196 dlg.response_json_decode_error(&encoded, &error);
8197 return Err(common::Error::JsonDecodeError(
8198 encoded.to_string(),
8199 error,
8200 ));
8201 }
8202 }
8203 };
8204
8205 dlg.finished(true);
8206 return Ok(response);
8207 }
8208 }
8209 }
8210 }
8211
8212 /// This field should contain the name of the enterprise config resource. For example: "projects/{$project_id}/locations/{$location_id}/githubEnterpriseConfigs/{$config_id}"
8213 ///
8214 /// Sets the *name* path property to the given value.
8215 ///
8216 /// Even though the property as already been set when instantiating this call,
8217 /// we provide this method for API completeness.
8218 pub fn name(mut self, new_value: &str) -> ProjectGithubEnterpriseConfigDeleteCall<'a, C> {
8219 self._name = new_value.to_string();
8220 self
8221 }
8222 /// ID of the project
8223 ///
8224 /// Sets the *project id* query property to the given value.
8225 pub fn project_id(mut self, new_value: &str) -> ProjectGithubEnterpriseConfigDeleteCall<'a, C> {
8226 self._project_id = Some(new_value.to_string());
8227 self
8228 }
8229 /// Unique identifier of the `GitHubEnterpriseConfig`
8230 ///
8231 /// Sets the *config id* query property to the given value.
8232 pub fn config_id(mut self, new_value: &str) -> ProjectGithubEnterpriseConfigDeleteCall<'a, C> {
8233 self._config_id = Some(new_value.to_string());
8234 self
8235 }
8236 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8237 /// while executing the actual API request.
8238 ///
8239 /// ````text
8240 /// It should be used to handle progress information, and to implement a certain level of resilience.
8241 /// ````
8242 ///
8243 /// Sets the *delegate* property to the given value.
8244 pub fn delegate(
8245 mut self,
8246 new_value: &'a mut dyn common::Delegate,
8247 ) -> ProjectGithubEnterpriseConfigDeleteCall<'a, C> {
8248 self._delegate = Some(new_value);
8249 self
8250 }
8251
8252 /// Set any additional parameter of the query string used in the request.
8253 /// It should be used to set parameters which are not yet available through their own
8254 /// setters.
8255 ///
8256 /// Please note that this method must not be used to set any of the known parameters
8257 /// which have their own setter method. If done anyway, the request will fail.
8258 ///
8259 /// # Additional Parameters
8260 ///
8261 /// * *$.xgafv* (query-string) - V1 error format.
8262 /// * *access_token* (query-string) - OAuth access token.
8263 /// * *alt* (query-string) - Data format for response.
8264 /// * *callback* (query-string) - JSONP
8265 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8266 /// * *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.
8267 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8268 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8269 /// * *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.
8270 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8271 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8272 pub fn param<T>(mut self, name: T, value: T) -> ProjectGithubEnterpriseConfigDeleteCall<'a, C>
8273 where
8274 T: AsRef<str>,
8275 {
8276 self._additional_params
8277 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8278 self
8279 }
8280
8281 /// Identifies the authorization scope for the method you are building.
8282 ///
8283 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8284 /// [`Scope::CloudPlatform`].
8285 ///
8286 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8287 /// tokens for more than one scope.
8288 ///
8289 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8290 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8291 /// sufficient, a read-write scope will do as well.
8292 pub fn add_scope<St>(mut self, scope: St) -> ProjectGithubEnterpriseConfigDeleteCall<'a, C>
8293 where
8294 St: AsRef<str>,
8295 {
8296 self._scopes.insert(String::from(scope.as_ref()));
8297 self
8298 }
8299 /// Identifies the authorization scope(s) for the method you are building.
8300 ///
8301 /// See [`Self::add_scope()`] for details.
8302 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectGithubEnterpriseConfigDeleteCall<'a, C>
8303 where
8304 I: IntoIterator<Item = St>,
8305 St: AsRef<str>,
8306 {
8307 self._scopes
8308 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8309 self
8310 }
8311
8312 /// Removes all scopes, and no default scope will be used either.
8313 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8314 /// for details).
8315 pub fn clear_scopes(mut self) -> ProjectGithubEnterpriseConfigDeleteCall<'a, C> {
8316 self._scopes.clear();
8317 self
8318 }
8319}
8320
8321/// Retrieve a GitHubEnterpriseConfig.
8322///
8323/// A builder for the *githubEnterpriseConfigs.get* method supported by a *project* resource.
8324/// It is not used directly, but through a [`ProjectMethods`] instance.
8325///
8326/// # Example
8327///
8328/// Instantiate a resource method builder
8329///
8330/// ```test_harness,no_run
8331/// # extern crate hyper;
8332/// # extern crate hyper_rustls;
8333/// # extern crate google_cloudbuild1 as cloudbuild1;
8334/// # async fn dox() {
8335/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8336///
8337/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8338/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8339/// # .with_native_roots()
8340/// # .unwrap()
8341/// # .https_only()
8342/// # .enable_http2()
8343/// # .build();
8344///
8345/// # let executor = hyper_util::rt::TokioExecutor::new();
8346/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8347/// # secret,
8348/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8349/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8350/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8351/// # ),
8352/// # ).build().await.unwrap();
8353///
8354/// # let client = hyper_util::client::legacy::Client::builder(
8355/// # hyper_util::rt::TokioExecutor::new()
8356/// # )
8357/// # .build(
8358/// # hyper_rustls::HttpsConnectorBuilder::new()
8359/// # .with_native_roots()
8360/// # .unwrap()
8361/// # .https_or_http()
8362/// # .enable_http2()
8363/// # .build()
8364/// # );
8365/// # let mut hub = CloudBuild::new(client, auth);
8366/// // You can configure optional parameters by calling the respective setters at will, and
8367/// // execute the final call using `doit()`.
8368/// // Values shown here are possibly random and not representative !
8369/// let result = hub.projects().github_enterprise_configs_get("name")
8370/// .project_id("eos")
8371/// .config_id("labore")
8372/// .doit().await;
8373/// # }
8374/// ```
8375pub struct ProjectGithubEnterpriseConfigGetCall<'a, C>
8376where
8377 C: 'a,
8378{
8379 hub: &'a CloudBuild<C>,
8380 _name: String,
8381 _project_id: Option<String>,
8382 _config_id: Option<String>,
8383 _delegate: Option<&'a mut dyn common::Delegate>,
8384 _additional_params: HashMap<String, String>,
8385 _scopes: BTreeSet<String>,
8386}
8387
8388impl<'a, C> common::CallBuilder for ProjectGithubEnterpriseConfigGetCall<'a, C> {}
8389
8390impl<'a, C> ProjectGithubEnterpriseConfigGetCall<'a, C>
8391where
8392 C: common::Connector,
8393{
8394 /// Perform the operation you have build so far.
8395 pub async fn doit(mut self) -> common::Result<(common::Response, GitHubEnterpriseConfig)> {
8396 use std::borrow::Cow;
8397 use std::io::{Read, Seek};
8398
8399 use common::{url::Params, ToParts};
8400 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8401
8402 let mut dd = common::DefaultDelegate;
8403 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8404 dlg.begin(common::MethodInfo {
8405 id: "cloudbuild.projects.githubEnterpriseConfigs.get",
8406 http_method: hyper::Method::GET,
8407 });
8408
8409 for &field in ["alt", "name", "projectId", "configId"].iter() {
8410 if self._additional_params.contains_key(field) {
8411 dlg.finished(false);
8412 return Err(common::Error::FieldClash(field));
8413 }
8414 }
8415
8416 let mut params = Params::with_capacity(5 + self._additional_params.len());
8417 params.push("name", self._name);
8418 if let Some(value) = self._project_id.as_ref() {
8419 params.push("projectId", value);
8420 }
8421 if let Some(value) = self._config_id.as_ref() {
8422 params.push("configId", value);
8423 }
8424
8425 params.extend(self._additional_params.iter());
8426
8427 params.push("alt", "json");
8428 let mut url = self.hub._base_url.clone() + "v1/{+name}";
8429 if self._scopes.is_empty() {
8430 self._scopes
8431 .insert(Scope::CloudPlatform.as_ref().to_string());
8432 }
8433
8434 #[allow(clippy::single_element_loop)]
8435 for &(find_this, param_name) in [("{+name}", "name")].iter() {
8436 url = params.uri_replacement(url, param_name, find_this, true);
8437 }
8438 {
8439 let to_remove = ["name"];
8440 params.remove_params(&to_remove);
8441 }
8442
8443 let url = params.parse_with_url(&url);
8444
8445 loop {
8446 let token = match self
8447 .hub
8448 .auth
8449 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8450 .await
8451 {
8452 Ok(token) => token,
8453 Err(e) => match dlg.token(e) {
8454 Ok(token) => token,
8455 Err(e) => {
8456 dlg.finished(false);
8457 return Err(common::Error::MissingToken(e));
8458 }
8459 },
8460 };
8461 let mut req_result = {
8462 let client = &self.hub.client;
8463 dlg.pre_request();
8464 let mut req_builder = hyper::Request::builder()
8465 .method(hyper::Method::GET)
8466 .uri(url.as_str())
8467 .header(USER_AGENT, self.hub._user_agent.clone());
8468
8469 if let Some(token) = token.as_ref() {
8470 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8471 }
8472
8473 let request = req_builder
8474 .header(CONTENT_LENGTH, 0_u64)
8475 .body(common::to_body::<String>(None));
8476
8477 client.request(request.unwrap()).await
8478 };
8479
8480 match req_result {
8481 Err(err) => {
8482 if let common::Retry::After(d) = dlg.http_error(&err) {
8483 sleep(d).await;
8484 continue;
8485 }
8486 dlg.finished(false);
8487 return Err(common::Error::HttpError(err));
8488 }
8489 Ok(res) => {
8490 let (mut parts, body) = res.into_parts();
8491 let mut body = common::Body::new(body);
8492 if !parts.status.is_success() {
8493 let bytes = common::to_bytes(body).await.unwrap_or_default();
8494 let error = serde_json::from_str(&common::to_string(&bytes));
8495 let response = common::to_response(parts, bytes.into());
8496
8497 if let common::Retry::After(d) =
8498 dlg.http_failure(&response, error.as_ref().ok())
8499 {
8500 sleep(d).await;
8501 continue;
8502 }
8503
8504 dlg.finished(false);
8505
8506 return Err(match error {
8507 Ok(value) => common::Error::BadRequest(value),
8508 _ => common::Error::Failure(response),
8509 });
8510 }
8511 let response = {
8512 let bytes = common::to_bytes(body).await.unwrap_or_default();
8513 let encoded = common::to_string(&bytes);
8514 match serde_json::from_str(&encoded) {
8515 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8516 Err(error) => {
8517 dlg.response_json_decode_error(&encoded, &error);
8518 return Err(common::Error::JsonDecodeError(
8519 encoded.to_string(),
8520 error,
8521 ));
8522 }
8523 }
8524 };
8525
8526 dlg.finished(true);
8527 return Ok(response);
8528 }
8529 }
8530 }
8531 }
8532
8533 /// This field should contain the name of the enterprise config resource. For example: "projects/{$project_id}/locations/{$location_id}/githubEnterpriseConfigs/{$config_id}"
8534 ///
8535 /// Sets the *name* path property to the given value.
8536 ///
8537 /// Even though the property as already been set when instantiating this call,
8538 /// we provide this method for API completeness.
8539 pub fn name(mut self, new_value: &str) -> ProjectGithubEnterpriseConfigGetCall<'a, C> {
8540 self._name = new_value.to_string();
8541 self
8542 }
8543 /// ID of the project
8544 ///
8545 /// Sets the *project id* query property to the given value.
8546 pub fn project_id(mut self, new_value: &str) -> ProjectGithubEnterpriseConfigGetCall<'a, C> {
8547 self._project_id = Some(new_value.to_string());
8548 self
8549 }
8550 /// Unique identifier of the `GitHubEnterpriseConfig`
8551 ///
8552 /// Sets the *config id* query property to the given value.
8553 pub fn config_id(mut self, new_value: &str) -> ProjectGithubEnterpriseConfigGetCall<'a, C> {
8554 self._config_id = Some(new_value.to_string());
8555 self
8556 }
8557 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8558 /// while executing the actual API request.
8559 ///
8560 /// ````text
8561 /// It should be used to handle progress information, and to implement a certain level of resilience.
8562 /// ````
8563 ///
8564 /// Sets the *delegate* property to the given value.
8565 pub fn delegate(
8566 mut self,
8567 new_value: &'a mut dyn common::Delegate,
8568 ) -> ProjectGithubEnterpriseConfigGetCall<'a, C> {
8569 self._delegate = Some(new_value);
8570 self
8571 }
8572
8573 /// Set any additional parameter of the query string used in the request.
8574 /// It should be used to set parameters which are not yet available through their own
8575 /// setters.
8576 ///
8577 /// Please note that this method must not be used to set any of the known parameters
8578 /// which have their own setter method. If done anyway, the request will fail.
8579 ///
8580 /// # Additional Parameters
8581 ///
8582 /// * *$.xgafv* (query-string) - V1 error format.
8583 /// * *access_token* (query-string) - OAuth access token.
8584 /// * *alt* (query-string) - Data format for response.
8585 /// * *callback* (query-string) - JSONP
8586 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8587 /// * *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.
8588 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8589 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8590 /// * *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.
8591 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8592 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8593 pub fn param<T>(mut self, name: T, value: T) -> ProjectGithubEnterpriseConfigGetCall<'a, C>
8594 where
8595 T: AsRef<str>,
8596 {
8597 self._additional_params
8598 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8599 self
8600 }
8601
8602 /// Identifies the authorization scope for the method you are building.
8603 ///
8604 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8605 /// [`Scope::CloudPlatform`].
8606 ///
8607 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8608 /// tokens for more than one scope.
8609 ///
8610 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8611 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8612 /// sufficient, a read-write scope will do as well.
8613 pub fn add_scope<St>(mut self, scope: St) -> ProjectGithubEnterpriseConfigGetCall<'a, C>
8614 where
8615 St: AsRef<str>,
8616 {
8617 self._scopes.insert(String::from(scope.as_ref()));
8618 self
8619 }
8620 /// Identifies the authorization scope(s) for the method you are building.
8621 ///
8622 /// See [`Self::add_scope()`] for details.
8623 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectGithubEnterpriseConfigGetCall<'a, C>
8624 where
8625 I: IntoIterator<Item = St>,
8626 St: AsRef<str>,
8627 {
8628 self._scopes
8629 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8630 self
8631 }
8632
8633 /// Removes all scopes, and no default scope will be used either.
8634 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8635 /// for details).
8636 pub fn clear_scopes(mut self) -> ProjectGithubEnterpriseConfigGetCall<'a, C> {
8637 self._scopes.clear();
8638 self
8639 }
8640}
8641
8642/// List all GitHubEnterpriseConfigs for a given project.
8643///
8644/// A builder for the *githubEnterpriseConfigs.list* method supported by a *project* resource.
8645/// It is not used directly, but through a [`ProjectMethods`] instance.
8646///
8647/// # Example
8648///
8649/// Instantiate a resource method builder
8650///
8651/// ```test_harness,no_run
8652/// # extern crate hyper;
8653/// # extern crate hyper_rustls;
8654/// # extern crate google_cloudbuild1 as cloudbuild1;
8655/// # async fn dox() {
8656/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8657///
8658/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8659/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8660/// # .with_native_roots()
8661/// # .unwrap()
8662/// # .https_only()
8663/// # .enable_http2()
8664/// # .build();
8665///
8666/// # let executor = hyper_util::rt::TokioExecutor::new();
8667/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8668/// # secret,
8669/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8670/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8671/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8672/// # ),
8673/// # ).build().await.unwrap();
8674///
8675/// # let client = hyper_util::client::legacy::Client::builder(
8676/// # hyper_util::rt::TokioExecutor::new()
8677/// # )
8678/// # .build(
8679/// # hyper_rustls::HttpsConnectorBuilder::new()
8680/// # .with_native_roots()
8681/// # .unwrap()
8682/// # .https_or_http()
8683/// # .enable_http2()
8684/// # .build()
8685/// # );
8686/// # let mut hub = CloudBuild::new(client, auth);
8687/// // You can configure optional parameters by calling the respective setters at will, and
8688/// // execute the final call using `doit()`.
8689/// // Values shown here are possibly random and not representative !
8690/// let result = hub.projects().github_enterprise_configs_list("parent")
8691/// .project_id("duo")
8692/// .doit().await;
8693/// # }
8694/// ```
8695pub struct ProjectGithubEnterpriseConfigListCall<'a, C>
8696where
8697 C: 'a,
8698{
8699 hub: &'a CloudBuild<C>,
8700 _parent: String,
8701 _project_id: Option<String>,
8702 _delegate: Option<&'a mut dyn common::Delegate>,
8703 _additional_params: HashMap<String, String>,
8704 _scopes: BTreeSet<String>,
8705}
8706
8707impl<'a, C> common::CallBuilder for ProjectGithubEnterpriseConfigListCall<'a, C> {}
8708
8709impl<'a, C> ProjectGithubEnterpriseConfigListCall<'a, C>
8710where
8711 C: common::Connector,
8712{
8713 /// Perform the operation you have build so far.
8714 pub async fn doit(
8715 mut self,
8716 ) -> common::Result<(common::Response, ListGithubEnterpriseConfigsResponse)> {
8717 use std::borrow::Cow;
8718 use std::io::{Read, Seek};
8719
8720 use common::{url::Params, ToParts};
8721 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8722
8723 let mut dd = common::DefaultDelegate;
8724 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8725 dlg.begin(common::MethodInfo {
8726 id: "cloudbuild.projects.githubEnterpriseConfigs.list",
8727 http_method: hyper::Method::GET,
8728 });
8729
8730 for &field in ["alt", "parent", "projectId"].iter() {
8731 if self._additional_params.contains_key(field) {
8732 dlg.finished(false);
8733 return Err(common::Error::FieldClash(field));
8734 }
8735 }
8736
8737 let mut params = Params::with_capacity(4 + self._additional_params.len());
8738 params.push("parent", self._parent);
8739 if let Some(value) = self._project_id.as_ref() {
8740 params.push("projectId", value);
8741 }
8742
8743 params.extend(self._additional_params.iter());
8744
8745 params.push("alt", "json");
8746 let mut url = self.hub._base_url.clone() + "v1/{+parent}/githubEnterpriseConfigs";
8747 if self._scopes.is_empty() {
8748 self._scopes
8749 .insert(Scope::CloudPlatform.as_ref().to_string());
8750 }
8751
8752 #[allow(clippy::single_element_loop)]
8753 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
8754 url = params.uri_replacement(url, param_name, find_this, true);
8755 }
8756 {
8757 let to_remove = ["parent"];
8758 params.remove_params(&to_remove);
8759 }
8760
8761 let url = params.parse_with_url(&url);
8762
8763 loop {
8764 let token = match self
8765 .hub
8766 .auth
8767 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8768 .await
8769 {
8770 Ok(token) => token,
8771 Err(e) => match dlg.token(e) {
8772 Ok(token) => token,
8773 Err(e) => {
8774 dlg.finished(false);
8775 return Err(common::Error::MissingToken(e));
8776 }
8777 },
8778 };
8779 let mut req_result = {
8780 let client = &self.hub.client;
8781 dlg.pre_request();
8782 let mut req_builder = hyper::Request::builder()
8783 .method(hyper::Method::GET)
8784 .uri(url.as_str())
8785 .header(USER_AGENT, self.hub._user_agent.clone());
8786
8787 if let Some(token) = token.as_ref() {
8788 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8789 }
8790
8791 let request = req_builder
8792 .header(CONTENT_LENGTH, 0_u64)
8793 .body(common::to_body::<String>(None));
8794
8795 client.request(request.unwrap()).await
8796 };
8797
8798 match req_result {
8799 Err(err) => {
8800 if let common::Retry::After(d) = dlg.http_error(&err) {
8801 sleep(d).await;
8802 continue;
8803 }
8804 dlg.finished(false);
8805 return Err(common::Error::HttpError(err));
8806 }
8807 Ok(res) => {
8808 let (mut parts, body) = res.into_parts();
8809 let mut body = common::Body::new(body);
8810 if !parts.status.is_success() {
8811 let bytes = common::to_bytes(body).await.unwrap_or_default();
8812 let error = serde_json::from_str(&common::to_string(&bytes));
8813 let response = common::to_response(parts, bytes.into());
8814
8815 if let common::Retry::After(d) =
8816 dlg.http_failure(&response, error.as_ref().ok())
8817 {
8818 sleep(d).await;
8819 continue;
8820 }
8821
8822 dlg.finished(false);
8823
8824 return Err(match error {
8825 Ok(value) => common::Error::BadRequest(value),
8826 _ => common::Error::Failure(response),
8827 });
8828 }
8829 let response = {
8830 let bytes = common::to_bytes(body).await.unwrap_or_default();
8831 let encoded = common::to_string(&bytes);
8832 match serde_json::from_str(&encoded) {
8833 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8834 Err(error) => {
8835 dlg.response_json_decode_error(&encoded, &error);
8836 return Err(common::Error::JsonDecodeError(
8837 encoded.to_string(),
8838 error,
8839 ));
8840 }
8841 }
8842 };
8843
8844 dlg.finished(true);
8845 return Ok(response);
8846 }
8847 }
8848 }
8849 }
8850
8851 /// Name of the parent project. For example: projects/{$project_number} or projects/{$project_id}
8852 ///
8853 /// Sets the *parent* path property to the given value.
8854 ///
8855 /// Even though the property as already been set when instantiating this call,
8856 /// we provide this method for API completeness.
8857 pub fn parent(mut self, new_value: &str) -> ProjectGithubEnterpriseConfigListCall<'a, C> {
8858 self._parent = new_value.to_string();
8859 self
8860 }
8861 /// ID of the project
8862 ///
8863 /// Sets the *project id* query property to the given value.
8864 pub fn project_id(mut self, new_value: &str) -> ProjectGithubEnterpriseConfigListCall<'a, C> {
8865 self._project_id = Some(new_value.to_string());
8866 self
8867 }
8868 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8869 /// while executing the actual API request.
8870 ///
8871 /// ````text
8872 /// It should be used to handle progress information, and to implement a certain level of resilience.
8873 /// ````
8874 ///
8875 /// Sets the *delegate* property to the given value.
8876 pub fn delegate(
8877 mut self,
8878 new_value: &'a mut dyn common::Delegate,
8879 ) -> ProjectGithubEnterpriseConfigListCall<'a, C> {
8880 self._delegate = Some(new_value);
8881 self
8882 }
8883
8884 /// Set any additional parameter of the query string used in the request.
8885 /// It should be used to set parameters which are not yet available through their own
8886 /// setters.
8887 ///
8888 /// Please note that this method must not be used to set any of the known parameters
8889 /// which have their own setter method. If done anyway, the request will fail.
8890 ///
8891 /// # Additional Parameters
8892 ///
8893 /// * *$.xgafv* (query-string) - V1 error format.
8894 /// * *access_token* (query-string) - OAuth access token.
8895 /// * *alt* (query-string) - Data format for response.
8896 /// * *callback* (query-string) - JSONP
8897 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8898 /// * *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.
8899 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8900 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8901 /// * *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.
8902 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8903 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8904 pub fn param<T>(mut self, name: T, value: T) -> ProjectGithubEnterpriseConfigListCall<'a, C>
8905 where
8906 T: AsRef<str>,
8907 {
8908 self._additional_params
8909 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8910 self
8911 }
8912
8913 /// Identifies the authorization scope for the method you are building.
8914 ///
8915 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8916 /// [`Scope::CloudPlatform`].
8917 ///
8918 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8919 /// tokens for more than one scope.
8920 ///
8921 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8922 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8923 /// sufficient, a read-write scope will do as well.
8924 pub fn add_scope<St>(mut self, scope: St) -> ProjectGithubEnterpriseConfigListCall<'a, C>
8925 where
8926 St: AsRef<str>,
8927 {
8928 self._scopes.insert(String::from(scope.as_ref()));
8929 self
8930 }
8931 /// Identifies the authorization scope(s) for the method you are building.
8932 ///
8933 /// See [`Self::add_scope()`] for details.
8934 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectGithubEnterpriseConfigListCall<'a, C>
8935 where
8936 I: IntoIterator<Item = St>,
8937 St: AsRef<str>,
8938 {
8939 self._scopes
8940 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8941 self
8942 }
8943
8944 /// Removes all scopes, and no default scope will be used either.
8945 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8946 /// for details).
8947 pub fn clear_scopes(mut self) -> ProjectGithubEnterpriseConfigListCall<'a, C> {
8948 self._scopes.clear();
8949 self
8950 }
8951}
8952
8953/// Update an association between a GCP project and a GitHub Enterprise server.
8954///
8955/// A builder for the *githubEnterpriseConfigs.patch* method supported by a *project* resource.
8956/// It is not used directly, but through a [`ProjectMethods`] instance.
8957///
8958/// # Example
8959///
8960/// Instantiate a resource method builder
8961///
8962/// ```test_harness,no_run
8963/// # extern crate hyper;
8964/// # extern crate hyper_rustls;
8965/// # extern crate google_cloudbuild1 as cloudbuild1;
8966/// use cloudbuild1::api::GitHubEnterpriseConfig;
8967/// # async fn dox() {
8968/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8969///
8970/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8971/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8972/// # .with_native_roots()
8973/// # .unwrap()
8974/// # .https_only()
8975/// # .enable_http2()
8976/// # .build();
8977///
8978/// # let executor = hyper_util::rt::TokioExecutor::new();
8979/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8980/// # secret,
8981/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8982/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8983/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8984/// # ),
8985/// # ).build().await.unwrap();
8986///
8987/// # let client = hyper_util::client::legacy::Client::builder(
8988/// # hyper_util::rt::TokioExecutor::new()
8989/// # )
8990/// # .build(
8991/// # hyper_rustls::HttpsConnectorBuilder::new()
8992/// # .with_native_roots()
8993/// # .unwrap()
8994/// # .https_or_http()
8995/// # .enable_http2()
8996/// # .build()
8997/// # );
8998/// # let mut hub = CloudBuild::new(client, auth);
8999/// // As the method needs a request, you would usually fill it with the desired information
9000/// // into the respective structure. Some of the parts shown here might not be applicable !
9001/// // Values shown here are possibly random and not representative !
9002/// let mut req = GitHubEnterpriseConfig::default();
9003///
9004/// // You can configure optional parameters by calling the respective setters at will, and
9005/// // execute the final call using `doit()`.
9006/// // Values shown here are possibly random and not representative !
9007/// let result = hub.projects().github_enterprise_configs_patch(req, "name")
9008/// .update_mask(FieldMask::new::<&str>(&[]))
9009/// .doit().await;
9010/// # }
9011/// ```
9012pub struct ProjectGithubEnterpriseConfigPatchCall<'a, C>
9013where
9014 C: 'a,
9015{
9016 hub: &'a CloudBuild<C>,
9017 _request: GitHubEnterpriseConfig,
9018 _name: String,
9019 _update_mask: Option<common::FieldMask>,
9020 _delegate: Option<&'a mut dyn common::Delegate>,
9021 _additional_params: HashMap<String, String>,
9022 _scopes: BTreeSet<String>,
9023}
9024
9025impl<'a, C> common::CallBuilder for ProjectGithubEnterpriseConfigPatchCall<'a, C> {}
9026
9027impl<'a, C> ProjectGithubEnterpriseConfigPatchCall<'a, C>
9028where
9029 C: common::Connector,
9030{
9031 /// Perform the operation you have build so far.
9032 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
9033 use std::borrow::Cow;
9034 use std::io::{Read, Seek};
9035
9036 use common::{url::Params, ToParts};
9037 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9038
9039 let mut dd = common::DefaultDelegate;
9040 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9041 dlg.begin(common::MethodInfo {
9042 id: "cloudbuild.projects.githubEnterpriseConfigs.patch",
9043 http_method: hyper::Method::PATCH,
9044 });
9045
9046 for &field in ["alt", "name", "updateMask"].iter() {
9047 if self._additional_params.contains_key(field) {
9048 dlg.finished(false);
9049 return Err(common::Error::FieldClash(field));
9050 }
9051 }
9052
9053 let mut params = Params::with_capacity(5 + self._additional_params.len());
9054 params.push("name", self._name);
9055 if let Some(value) = self._update_mask.as_ref() {
9056 params.push("updateMask", value.to_string());
9057 }
9058
9059 params.extend(self._additional_params.iter());
9060
9061 params.push("alt", "json");
9062 let mut url = self.hub._base_url.clone() + "v1/{+name}";
9063 if self._scopes.is_empty() {
9064 self._scopes
9065 .insert(Scope::CloudPlatform.as_ref().to_string());
9066 }
9067
9068 #[allow(clippy::single_element_loop)]
9069 for &(find_this, param_name) in [("{+name}", "name")].iter() {
9070 url = params.uri_replacement(url, param_name, find_this, true);
9071 }
9072 {
9073 let to_remove = ["name"];
9074 params.remove_params(&to_remove);
9075 }
9076
9077 let url = params.parse_with_url(&url);
9078
9079 let mut json_mime_type = mime::APPLICATION_JSON;
9080 let mut request_value_reader = {
9081 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9082 common::remove_json_null_values(&mut value);
9083 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9084 serde_json::to_writer(&mut dst, &value).unwrap();
9085 dst
9086 };
9087 let request_size = request_value_reader
9088 .seek(std::io::SeekFrom::End(0))
9089 .unwrap();
9090 request_value_reader
9091 .seek(std::io::SeekFrom::Start(0))
9092 .unwrap();
9093
9094 loop {
9095 let token = match self
9096 .hub
9097 .auth
9098 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9099 .await
9100 {
9101 Ok(token) => token,
9102 Err(e) => match dlg.token(e) {
9103 Ok(token) => token,
9104 Err(e) => {
9105 dlg.finished(false);
9106 return Err(common::Error::MissingToken(e));
9107 }
9108 },
9109 };
9110 request_value_reader
9111 .seek(std::io::SeekFrom::Start(0))
9112 .unwrap();
9113 let mut req_result = {
9114 let client = &self.hub.client;
9115 dlg.pre_request();
9116 let mut req_builder = hyper::Request::builder()
9117 .method(hyper::Method::PATCH)
9118 .uri(url.as_str())
9119 .header(USER_AGENT, self.hub._user_agent.clone());
9120
9121 if let Some(token) = token.as_ref() {
9122 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9123 }
9124
9125 let request = req_builder
9126 .header(CONTENT_TYPE, json_mime_type.to_string())
9127 .header(CONTENT_LENGTH, request_size as u64)
9128 .body(common::to_body(
9129 request_value_reader.get_ref().clone().into(),
9130 ));
9131
9132 client.request(request.unwrap()).await
9133 };
9134
9135 match req_result {
9136 Err(err) => {
9137 if let common::Retry::After(d) = dlg.http_error(&err) {
9138 sleep(d).await;
9139 continue;
9140 }
9141 dlg.finished(false);
9142 return Err(common::Error::HttpError(err));
9143 }
9144 Ok(res) => {
9145 let (mut parts, body) = res.into_parts();
9146 let mut body = common::Body::new(body);
9147 if !parts.status.is_success() {
9148 let bytes = common::to_bytes(body).await.unwrap_or_default();
9149 let error = serde_json::from_str(&common::to_string(&bytes));
9150 let response = common::to_response(parts, bytes.into());
9151
9152 if let common::Retry::After(d) =
9153 dlg.http_failure(&response, error.as_ref().ok())
9154 {
9155 sleep(d).await;
9156 continue;
9157 }
9158
9159 dlg.finished(false);
9160
9161 return Err(match error {
9162 Ok(value) => common::Error::BadRequest(value),
9163 _ => common::Error::Failure(response),
9164 });
9165 }
9166 let response = {
9167 let bytes = common::to_bytes(body).await.unwrap_or_default();
9168 let encoded = common::to_string(&bytes);
9169 match serde_json::from_str(&encoded) {
9170 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9171 Err(error) => {
9172 dlg.response_json_decode_error(&encoded, &error);
9173 return Err(common::Error::JsonDecodeError(
9174 encoded.to_string(),
9175 error,
9176 ));
9177 }
9178 }
9179 };
9180
9181 dlg.finished(true);
9182 return Ok(response);
9183 }
9184 }
9185 }
9186 }
9187
9188 ///
9189 /// Sets the *request* property to the given value.
9190 ///
9191 /// Even though the property as already been set when instantiating this call,
9192 /// we provide this method for API completeness.
9193 pub fn request(
9194 mut self,
9195 new_value: GitHubEnterpriseConfig,
9196 ) -> ProjectGithubEnterpriseConfigPatchCall<'a, C> {
9197 self._request = new_value;
9198 self
9199 }
9200 /// The full resource name for the GitHubEnterpriseConfig For example: "projects/{$project_id}/locations/{$location_id}/githubEnterpriseConfigs/{$config_id}"
9201 ///
9202 /// Sets the *name* path property to the given value.
9203 ///
9204 /// Even though the property as already been set when instantiating this call,
9205 /// we provide this method for API completeness.
9206 pub fn name(mut self, new_value: &str) -> ProjectGithubEnterpriseConfigPatchCall<'a, C> {
9207 self._name = new_value.to_string();
9208 self
9209 }
9210 /// 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.
9211 ///
9212 /// Sets the *update mask* query property to the given value.
9213 pub fn update_mask(
9214 mut self,
9215 new_value: common::FieldMask,
9216 ) -> ProjectGithubEnterpriseConfigPatchCall<'a, C> {
9217 self._update_mask = Some(new_value);
9218 self
9219 }
9220 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9221 /// while executing the actual API request.
9222 ///
9223 /// ````text
9224 /// It should be used to handle progress information, and to implement a certain level of resilience.
9225 /// ````
9226 ///
9227 /// Sets the *delegate* property to the given value.
9228 pub fn delegate(
9229 mut self,
9230 new_value: &'a mut dyn common::Delegate,
9231 ) -> ProjectGithubEnterpriseConfigPatchCall<'a, C> {
9232 self._delegate = Some(new_value);
9233 self
9234 }
9235
9236 /// Set any additional parameter of the query string used in the request.
9237 /// It should be used to set parameters which are not yet available through their own
9238 /// setters.
9239 ///
9240 /// Please note that this method must not be used to set any of the known parameters
9241 /// which have their own setter method. If done anyway, the request will fail.
9242 ///
9243 /// # Additional Parameters
9244 ///
9245 /// * *$.xgafv* (query-string) - V1 error format.
9246 /// * *access_token* (query-string) - OAuth access token.
9247 /// * *alt* (query-string) - Data format for response.
9248 /// * *callback* (query-string) - JSONP
9249 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9250 /// * *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.
9251 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9252 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9253 /// * *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.
9254 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9255 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9256 pub fn param<T>(mut self, name: T, value: T) -> ProjectGithubEnterpriseConfigPatchCall<'a, C>
9257 where
9258 T: AsRef<str>,
9259 {
9260 self._additional_params
9261 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9262 self
9263 }
9264
9265 /// Identifies the authorization scope for the method you are building.
9266 ///
9267 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9268 /// [`Scope::CloudPlatform`].
9269 ///
9270 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9271 /// tokens for more than one scope.
9272 ///
9273 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9274 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9275 /// sufficient, a read-write scope will do as well.
9276 pub fn add_scope<St>(mut self, scope: St) -> ProjectGithubEnterpriseConfigPatchCall<'a, C>
9277 where
9278 St: AsRef<str>,
9279 {
9280 self._scopes.insert(String::from(scope.as_ref()));
9281 self
9282 }
9283 /// Identifies the authorization scope(s) for the method you are building.
9284 ///
9285 /// See [`Self::add_scope()`] for details.
9286 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectGithubEnterpriseConfigPatchCall<'a, C>
9287 where
9288 I: IntoIterator<Item = St>,
9289 St: AsRef<str>,
9290 {
9291 self._scopes
9292 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9293 self
9294 }
9295
9296 /// Removes all scopes, and no default scope will be used either.
9297 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9298 /// for details).
9299 pub fn clear_scopes(mut self) -> ProjectGithubEnterpriseConfigPatchCall<'a, C> {
9300 self._scopes.clear();
9301 self
9302 }
9303}
9304
9305/// Batch connecting Bitbucket Server repositories to Cloud Build.
9306///
9307/// A builder for the *locations.bitbucketServerConfigs.connectedRepositories.batchCreate* method supported by a *project* resource.
9308/// It is not used directly, but through a [`ProjectMethods`] instance.
9309///
9310/// # Example
9311///
9312/// Instantiate a resource method builder
9313///
9314/// ```test_harness,no_run
9315/// # extern crate hyper;
9316/// # extern crate hyper_rustls;
9317/// # extern crate google_cloudbuild1 as cloudbuild1;
9318/// use cloudbuild1::api::BatchCreateBitbucketServerConnectedRepositoriesRequest;
9319/// # async fn dox() {
9320/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9321///
9322/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9323/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9324/// # .with_native_roots()
9325/// # .unwrap()
9326/// # .https_only()
9327/// # .enable_http2()
9328/// # .build();
9329///
9330/// # let executor = hyper_util::rt::TokioExecutor::new();
9331/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9332/// # secret,
9333/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9334/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9335/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9336/// # ),
9337/// # ).build().await.unwrap();
9338///
9339/// # let client = hyper_util::client::legacy::Client::builder(
9340/// # hyper_util::rt::TokioExecutor::new()
9341/// # )
9342/// # .build(
9343/// # hyper_rustls::HttpsConnectorBuilder::new()
9344/// # .with_native_roots()
9345/// # .unwrap()
9346/// # .https_or_http()
9347/// # .enable_http2()
9348/// # .build()
9349/// # );
9350/// # let mut hub = CloudBuild::new(client, auth);
9351/// // As the method needs a request, you would usually fill it with the desired information
9352/// // into the respective structure. Some of the parts shown here might not be applicable !
9353/// // Values shown here are possibly random and not representative !
9354/// let mut req = BatchCreateBitbucketServerConnectedRepositoriesRequest::default();
9355///
9356/// // You can configure optional parameters by calling the respective setters at will, and
9357/// // execute the final call using `doit()`.
9358/// // Values shown here are possibly random and not representative !
9359/// let result = hub.projects().locations_bitbucket_server_configs_connected_repositories_batch_create(req, "parent")
9360/// .doit().await;
9361/// # }
9362/// ```
9363pub struct ProjectLocationBitbucketServerConfigConnectedRepositoryBatchCreateCall<'a, C>
9364where
9365 C: 'a,
9366{
9367 hub: &'a CloudBuild<C>,
9368 _request: BatchCreateBitbucketServerConnectedRepositoriesRequest,
9369 _parent: String,
9370 _delegate: Option<&'a mut dyn common::Delegate>,
9371 _additional_params: HashMap<String, String>,
9372 _scopes: BTreeSet<String>,
9373}
9374
9375impl<'a, C> common::CallBuilder
9376 for ProjectLocationBitbucketServerConfigConnectedRepositoryBatchCreateCall<'a, C>
9377{
9378}
9379
9380impl<'a, C> ProjectLocationBitbucketServerConfigConnectedRepositoryBatchCreateCall<'a, C>
9381where
9382 C: common::Connector,
9383{
9384 /// Perform the operation you have build so far.
9385 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
9386 use std::borrow::Cow;
9387 use std::io::{Read, Seek};
9388
9389 use common::{url::Params, ToParts};
9390 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9391
9392 let mut dd = common::DefaultDelegate;
9393 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9394 dlg.begin(common::MethodInfo { id: "cloudbuild.projects.locations.bitbucketServerConfigs.connectedRepositories.batchCreate",
9395 http_method: hyper::Method::POST });
9396
9397 for &field in ["alt", "parent"].iter() {
9398 if self._additional_params.contains_key(field) {
9399 dlg.finished(false);
9400 return Err(common::Error::FieldClash(field));
9401 }
9402 }
9403
9404 let mut params = Params::with_capacity(4 + self._additional_params.len());
9405 params.push("parent", self._parent);
9406
9407 params.extend(self._additional_params.iter());
9408
9409 params.push("alt", "json");
9410 let mut url = self.hub._base_url.clone() + "v1/{+parent}/connectedRepositories:batchCreate";
9411 if self._scopes.is_empty() {
9412 self._scopes
9413 .insert(Scope::CloudPlatform.as_ref().to_string());
9414 }
9415
9416 #[allow(clippy::single_element_loop)]
9417 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
9418 url = params.uri_replacement(url, param_name, find_this, true);
9419 }
9420 {
9421 let to_remove = ["parent"];
9422 params.remove_params(&to_remove);
9423 }
9424
9425 let url = params.parse_with_url(&url);
9426
9427 let mut json_mime_type = mime::APPLICATION_JSON;
9428 let mut request_value_reader = {
9429 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9430 common::remove_json_null_values(&mut value);
9431 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9432 serde_json::to_writer(&mut dst, &value).unwrap();
9433 dst
9434 };
9435 let request_size = request_value_reader
9436 .seek(std::io::SeekFrom::End(0))
9437 .unwrap();
9438 request_value_reader
9439 .seek(std::io::SeekFrom::Start(0))
9440 .unwrap();
9441
9442 loop {
9443 let token = match self
9444 .hub
9445 .auth
9446 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9447 .await
9448 {
9449 Ok(token) => token,
9450 Err(e) => match dlg.token(e) {
9451 Ok(token) => token,
9452 Err(e) => {
9453 dlg.finished(false);
9454 return Err(common::Error::MissingToken(e));
9455 }
9456 },
9457 };
9458 request_value_reader
9459 .seek(std::io::SeekFrom::Start(0))
9460 .unwrap();
9461 let mut req_result = {
9462 let client = &self.hub.client;
9463 dlg.pre_request();
9464 let mut req_builder = hyper::Request::builder()
9465 .method(hyper::Method::POST)
9466 .uri(url.as_str())
9467 .header(USER_AGENT, self.hub._user_agent.clone());
9468
9469 if let Some(token) = token.as_ref() {
9470 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9471 }
9472
9473 let request = req_builder
9474 .header(CONTENT_TYPE, json_mime_type.to_string())
9475 .header(CONTENT_LENGTH, request_size as u64)
9476 .body(common::to_body(
9477 request_value_reader.get_ref().clone().into(),
9478 ));
9479
9480 client.request(request.unwrap()).await
9481 };
9482
9483 match req_result {
9484 Err(err) => {
9485 if let common::Retry::After(d) = dlg.http_error(&err) {
9486 sleep(d).await;
9487 continue;
9488 }
9489 dlg.finished(false);
9490 return Err(common::Error::HttpError(err));
9491 }
9492 Ok(res) => {
9493 let (mut parts, body) = res.into_parts();
9494 let mut body = common::Body::new(body);
9495 if !parts.status.is_success() {
9496 let bytes = common::to_bytes(body).await.unwrap_or_default();
9497 let error = serde_json::from_str(&common::to_string(&bytes));
9498 let response = common::to_response(parts, bytes.into());
9499
9500 if let common::Retry::After(d) =
9501 dlg.http_failure(&response, error.as_ref().ok())
9502 {
9503 sleep(d).await;
9504 continue;
9505 }
9506
9507 dlg.finished(false);
9508
9509 return Err(match error {
9510 Ok(value) => common::Error::BadRequest(value),
9511 _ => common::Error::Failure(response),
9512 });
9513 }
9514 let response = {
9515 let bytes = common::to_bytes(body).await.unwrap_or_default();
9516 let encoded = common::to_string(&bytes);
9517 match serde_json::from_str(&encoded) {
9518 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9519 Err(error) => {
9520 dlg.response_json_decode_error(&encoded, &error);
9521 return Err(common::Error::JsonDecodeError(
9522 encoded.to_string(),
9523 error,
9524 ));
9525 }
9526 }
9527 };
9528
9529 dlg.finished(true);
9530 return Ok(response);
9531 }
9532 }
9533 }
9534 }
9535
9536 ///
9537 /// Sets the *request* property to the given value.
9538 ///
9539 /// Even though the property as already been set when instantiating this call,
9540 /// we provide this method for API completeness.
9541 pub fn request(
9542 mut self,
9543 new_value: BatchCreateBitbucketServerConnectedRepositoriesRequest,
9544 ) -> ProjectLocationBitbucketServerConfigConnectedRepositoryBatchCreateCall<'a, C> {
9545 self._request = new_value;
9546 self
9547 }
9548 /// The name of the `BitbucketServerConfig` that added connected repository. Format: `projects/{project}/locations/{location}/bitbucketServerConfigs/{config}`
9549 ///
9550 /// Sets the *parent* path property to the given value.
9551 ///
9552 /// Even though the property as already been set when instantiating this call,
9553 /// we provide this method for API completeness.
9554 pub fn parent(
9555 mut self,
9556 new_value: &str,
9557 ) -> ProjectLocationBitbucketServerConfigConnectedRepositoryBatchCreateCall<'a, C> {
9558 self._parent = new_value.to_string();
9559 self
9560 }
9561 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9562 /// while executing the actual API request.
9563 ///
9564 /// ````text
9565 /// It should be used to handle progress information, and to implement a certain level of resilience.
9566 /// ````
9567 ///
9568 /// Sets the *delegate* property to the given value.
9569 pub fn delegate(
9570 mut self,
9571 new_value: &'a mut dyn common::Delegate,
9572 ) -> ProjectLocationBitbucketServerConfigConnectedRepositoryBatchCreateCall<'a, C> {
9573 self._delegate = Some(new_value);
9574 self
9575 }
9576
9577 /// Set any additional parameter of the query string used in the request.
9578 /// It should be used to set parameters which are not yet available through their own
9579 /// setters.
9580 ///
9581 /// Please note that this method must not be used to set any of the known parameters
9582 /// which have their own setter method. If done anyway, the request will fail.
9583 ///
9584 /// # Additional Parameters
9585 ///
9586 /// * *$.xgafv* (query-string) - V1 error format.
9587 /// * *access_token* (query-string) - OAuth access token.
9588 /// * *alt* (query-string) - Data format for response.
9589 /// * *callback* (query-string) - JSONP
9590 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9591 /// * *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.
9592 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9593 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9594 /// * *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.
9595 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9596 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9597 pub fn param<T>(
9598 mut self,
9599 name: T,
9600 value: T,
9601 ) -> ProjectLocationBitbucketServerConfigConnectedRepositoryBatchCreateCall<'a, C>
9602 where
9603 T: AsRef<str>,
9604 {
9605 self._additional_params
9606 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9607 self
9608 }
9609
9610 /// Identifies the authorization scope for the method you are building.
9611 ///
9612 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9613 /// [`Scope::CloudPlatform`].
9614 ///
9615 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9616 /// tokens for more than one scope.
9617 ///
9618 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9619 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9620 /// sufficient, a read-write scope will do as well.
9621 pub fn add_scope<St>(
9622 mut self,
9623 scope: St,
9624 ) -> ProjectLocationBitbucketServerConfigConnectedRepositoryBatchCreateCall<'a, C>
9625 where
9626 St: AsRef<str>,
9627 {
9628 self._scopes.insert(String::from(scope.as_ref()));
9629 self
9630 }
9631 /// Identifies the authorization scope(s) for the method you are building.
9632 ///
9633 /// See [`Self::add_scope()`] for details.
9634 pub fn add_scopes<I, St>(
9635 mut self,
9636 scopes: I,
9637 ) -> ProjectLocationBitbucketServerConfigConnectedRepositoryBatchCreateCall<'a, C>
9638 where
9639 I: IntoIterator<Item = St>,
9640 St: AsRef<str>,
9641 {
9642 self._scopes
9643 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9644 self
9645 }
9646
9647 /// Removes all scopes, and no default scope will be used either.
9648 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9649 /// for details).
9650 pub fn clear_scopes(
9651 mut self,
9652 ) -> ProjectLocationBitbucketServerConfigConnectedRepositoryBatchCreateCall<'a, C> {
9653 self._scopes.clear();
9654 self
9655 }
9656}
9657
9658/// List all repositories for a given `BitbucketServerConfig`. This API is experimental.
9659///
9660/// A builder for the *locations.bitbucketServerConfigs.repos.list* method supported by a *project* resource.
9661/// It is not used directly, but through a [`ProjectMethods`] instance.
9662///
9663/// # Example
9664///
9665/// Instantiate a resource method builder
9666///
9667/// ```test_harness,no_run
9668/// # extern crate hyper;
9669/// # extern crate hyper_rustls;
9670/// # extern crate google_cloudbuild1 as cloudbuild1;
9671/// # async fn dox() {
9672/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9673///
9674/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9675/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9676/// # .with_native_roots()
9677/// # .unwrap()
9678/// # .https_only()
9679/// # .enable_http2()
9680/// # .build();
9681///
9682/// # let executor = hyper_util::rt::TokioExecutor::new();
9683/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9684/// # secret,
9685/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9686/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9687/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9688/// # ),
9689/// # ).build().await.unwrap();
9690///
9691/// # let client = hyper_util::client::legacy::Client::builder(
9692/// # hyper_util::rt::TokioExecutor::new()
9693/// # )
9694/// # .build(
9695/// # hyper_rustls::HttpsConnectorBuilder::new()
9696/// # .with_native_roots()
9697/// # .unwrap()
9698/// # .https_or_http()
9699/// # .enable_http2()
9700/// # .build()
9701/// # );
9702/// # let mut hub = CloudBuild::new(client, auth);
9703/// // You can configure optional parameters by calling the respective setters at will, and
9704/// // execute the final call using `doit()`.
9705/// // Values shown here are possibly random and not representative !
9706/// let result = hub.projects().locations_bitbucket_server_configs_repos_list("parent")
9707/// .page_token("kasd")
9708/// .page_size(-24)
9709/// .doit().await;
9710/// # }
9711/// ```
9712pub struct ProjectLocationBitbucketServerConfigRepoListCall<'a, C>
9713where
9714 C: 'a,
9715{
9716 hub: &'a CloudBuild<C>,
9717 _parent: String,
9718 _page_token: Option<String>,
9719 _page_size: Option<i32>,
9720 _delegate: Option<&'a mut dyn common::Delegate>,
9721 _additional_params: HashMap<String, String>,
9722 _scopes: BTreeSet<String>,
9723}
9724
9725impl<'a, C> common::CallBuilder for ProjectLocationBitbucketServerConfigRepoListCall<'a, C> {}
9726
9727impl<'a, C> ProjectLocationBitbucketServerConfigRepoListCall<'a, C>
9728where
9729 C: common::Connector,
9730{
9731 /// Perform the operation you have build so far.
9732 pub async fn doit(
9733 mut self,
9734 ) -> common::Result<(common::Response, ListBitbucketServerRepositoriesResponse)> {
9735 use std::borrow::Cow;
9736 use std::io::{Read, Seek};
9737
9738 use common::{url::Params, ToParts};
9739 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9740
9741 let mut dd = common::DefaultDelegate;
9742 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9743 dlg.begin(common::MethodInfo {
9744 id: "cloudbuild.projects.locations.bitbucketServerConfigs.repos.list",
9745 http_method: hyper::Method::GET,
9746 });
9747
9748 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
9749 if self._additional_params.contains_key(field) {
9750 dlg.finished(false);
9751 return Err(common::Error::FieldClash(field));
9752 }
9753 }
9754
9755 let mut params = Params::with_capacity(5 + self._additional_params.len());
9756 params.push("parent", self._parent);
9757 if let Some(value) = self._page_token.as_ref() {
9758 params.push("pageToken", value);
9759 }
9760 if let Some(value) = self._page_size.as_ref() {
9761 params.push("pageSize", value.to_string());
9762 }
9763
9764 params.extend(self._additional_params.iter());
9765
9766 params.push("alt", "json");
9767 let mut url = self.hub._base_url.clone() + "v1/{+parent}/repos";
9768 if self._scopes.is_empty() {
9769 self._scopes
9770 .insert(Scope::CloudPlatform.as_ref().to_string());
9771 }
9772
9773 #[allow(clippy::single_element_loop)]
9774 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
9775 url = params.uri_replacement(url, param_name, find_this, true);
9776 }
9777 {
9778 let to_remove = ["parent"];
9779 params.remove_params(&to_remove);
9780 }
9781
9782 let url = params.parse_with_url(&url);
9783
9784 loop {
9785 let token = match self
9786 .hub
9787 .auth
9788 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9789 .await
9790 {
9791 Ok(token) => token,
9792 Err(e) => match dlg.token(e) {
9793 Ok(token) => token,
9794 Err(e) => {
9795 dlg.finished(false);
9796 return Err(common::Error::MissingToken(e));
9797 }
9798 },
9799 };
9800 let mut req_result = {
9801 let client = &self.hub.client;
9802 dlg.pre_request();
9803 let mut req_builder = hyper::Request::builder()
9804 .method(hyper::Method::GET)
9805 .uri(url.as_str())
9806 .header(USER_AGENT, self.hub._user_agent.clone());
9807
9808 if let Some(token) = token.as_ref() {
9809 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9810 }
9811
9812 let request = req_builder
9813 .header(CONTENT_LENGTH, 0_u64)
9814 .body(common::to_body::<String>(None));
9815
9816 client.request(request.unwrap()).await
9817 };
9818
9819 match req_result {
9820 Err(err) => {
9821 if let common::Retry::After(d) = dlg.http_error(&err) {
9822 sleep(d).await;
9823 continue;
9824 }
9825 dlg.finished(false);
9826 return Err(common::Error::HttpError(err));
9827 }
9828 Ok(res) => {
9829 let (mut parts, body) = res.into_parts();
9830 let mut body = common::Body::new(body);
9831 if !parts.status.is_success() {
9832 let bytes = common::to_bytes(body).await.unwrap_or_default();
9833 let error = serde_json::from_str(&common::to_string(&bytes));
9834 let response = common::to_response(parts, bytes.into());
9835
9836 if let common::Retry::After(d) =
9837 dlg.http_failure(&response, error.as_ref().ok())
9838 {
9839 sleep(d).await;
9840 continue;
9841 }
9842
9843 dlg.finished(false);
9844
9845 return Err(match error {
9846 Ok(value) => common::Error::BadRequest(value),
9847 _ => common::Error::Failure(response),
9848 });
9849 }
9850 let response = {
9851 let bytes = common::to_bytes(body).await.unwrap_or_default();
9852 let encoded = common::to_string(&bytes);
9853 match serde_json::from_str(&encoded) {
9854 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9855 Err(error) => {
9856 dlg.response_json_decode_error(&encoded, &error);
9857 return Err(common::Error::JsonDecodeError(
9858 encoded.to_string(),
9859 error,
9860 ));
9861 }
9862 }
9863 };
9864
9865 dlg.finished(true);
9866 return Ok(response);
9867 }
9868 }
9869 }
9870 }
9871
9872 /// Required. Name of the parent resource.
9873 ///
9874 /// Sets the *parent* path property to the given value.
9875 ///
9876 /// Even though the property as already been set when instantiating this call,
9877 /// we provide this method for API completeness.
9878 pub fn parent(
9879 mut self,
9880 new_value: &str,
9881 ) -> ProjectLocationBitbucketServerConfigRepoListCall<'a, C> {
9882 self._parent = new_value.to_string();
9883 self
9884 }
9885 /// 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.
9886 ///
9887 /// Sets the *page token* query property to the given value.
9888 pub fn page_token(
9889 mut self,
9890 new_value: &str,
9891 ) -> ProjectLocationBitbucketServerConfigRepoListCall<'a, C> {
9892 self._page_token = Some(new_value.to_string());
9893 self
9894 }
9895 /// 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.
9896 ///
9897 /// Sets the *page size* query property to the given value.
9898 pub fn page_size(
9899 mut self,
9900 new_value: i32,
9901 ) -> ProjectLocationBitbucketServerConfigRepoListCall<'a, C> {
9902 self._page_size = Some(new_value);
9903 self
9904 }
9905 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9906 /// while executing the actual API request.
9907 ///
9908 /// ````text
9909 /// It should be used to handle progress information, and to implement a certain level of resilience.
9910 /// ````
9911 ///
9912 /// Sets the *delegate* property to the given value.
9913 pub fn delegate(
9914 mut self,
9915 new_value: &'a mut dyn common::Delegate,
9916 ) -> ProjectLocationBitbucketServerConfigRepoListCall<'a, C> {
9917 self._delegate = Some(new_value);
9918 self
9919 }
9920
9921 /// Set any additional parameter of the query string used in the request.
9922 /// It should be used to set parameters which are not yet available through their own
9923 /// setters.
9924 ///
9925 /// Please note that this method must not be used to set any of the known parameters
9926 /// which have their own setter method. If done anyway, the request will fail.
9927 ///
9928 /// # Additional Parameters
9929 ///
9930 /// * *$.xgafv* (query-string) - V1 error format.
9931 /// * *access_token* (query-string) - OAuth access token.
9932 /// * *alt* (query-string) - Data format for response.
9933 /// * *callback* (query-string) - JSONP
9934 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9935 /// * *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.
9936 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9937 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9938 /// * *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.
9939 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9940 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9941 pub fn param<T>(
9942 mut self,
9943 name: T,
9944 value: T,
9945 ) -> ProjectLocationBitbucketServerConfigRepoListCall<'a, C>
9946 where
9947 T: AsRef<str>,
9948 {
9949 self._additional_params
9950 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9951 self
9952 }
9953
9954 /// Identifies the authorization scope for the method you are building.
9955 ///
9956 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9957 /// [`Scope::CloudPlatform`].
9958 ///
9959 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9960 /// tokens for more than one scope.
9961 ///
9962 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9963 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9964 /// sufficient, a read-write scope will do as well.
9965 pub fn add_scope<St>(
9966 mut self,
9967 scope: St,
9968 ) -> ProjectLocationBitbucketServerConfigRepoListCall<'a, C>
9969 where
9970 St: AsRef<str>,
9971 {
9972 self._scopes.insert(String::from(scope.as_ref()));
9973 self
9974 }
9975 /// Identifies the authorization scope(s) for the method you are building.
9976 ///
9977 /// See [`Self::add_scope()`] for details.
9978 pub fn add_scopes<I, St>(
9979 mut self,
9980 scopes: I,
9981 ) -> ProjectLocationBitbucketServerConfigRepoListCall<'a, C>
9982 where
9983 I: IntoIterator<Item = St>,
9984 St: AsRef<str>,
9985 {
9986 self._scopes
9987 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9988 self
9989 }
9990
9991 /// Removes all scopes, and no default scope will be used either.
9992 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9993 /// for details).
9994 pub fn clear_scopes(mut self) -> ProjectLocationBitbucketServerConfigRepoListCall<'a, C> {
9995 self._scopes.clear();
9996 self
9997 }
9998}
9999
10000/// Creates a new `BitbucketServerConfig`. This API is experimental.
10001///
10002/// A builder for the *locations.bitbucketServerConfigs.create* method supported by a *project* resource.
10003/// It is not used directly, but through a [`ProjectMethods`] instance.
10004///
10005/// # Example
10006///
10007/// Instantiate a resource method builder
10008///
10009/// ```test_harness,no_run
10010/// # extern crate hyper;
10011/// # extern crate hyper_rustls;
10012/// # extern crate google_cloudbuild1 as cloudbuild1;
10013/// use cloudbuild1::api::BitbucketServerConfig;
10014/// # async fn dox() {
10015/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10016///
10017/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10018/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10019/// # .with_native_roots()
10020/// # .unwrap()
10021/// # .https_only()
10022/// # .enable_http2()
10023/// # .build();
10024///
10025/// # let executor = hyper_util::rt::TokioExecutor::new();
10026/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10027/// # secret,
10028/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10029/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10030/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10031/// # ),
10032/// # ).build().await.unwrap();
10033///
10034/// # let client = hyper_util::client::legacy::Client::builder(
10035/// # hyper_util::rt::TokioExecutor::new()
10036/// # )
10037/// # .build(
10038/// # hyper_rustls::HttpsConnectorBuilder::new()
10039/// # .with_native_roots()
10040/// # .unwrap()
10041/// # .https_or_http()
10042/// # .enable_http2()
10043/// # .build()
10044/// # );
10045/// # let mut hub = CloudBuild::new(client, auth);
10046/// // As the method needs a request, you would usually fill it with the desired information
10047/// // into the respective structure. Some of the parts shown here might not be applicable !
10048/// // Values shown here are possibly random and not representative !
10049/// let mut req = BitbucketServerConfig::default();
10050///
10051/// // You can configure optional parameters by calling the respective setters at will, and
10052/// // execute the final call using `doit()`.
10053/// // Values shown here are possibly random and not representative !
10054/// let result = hub.projects().locations_bitbucket_server_configs_create(req, "parent")
10055/// .bitbucket_server_config_id("et")
10056/// .doit().await;
10057/// # }
10058/// ```
10059pub struct ProjectLocationBitbucketServerConfigCreateCall<'a, C>
10060where
10061 C: 'a,
10062{
10063 hub: &'a CloudBuild<C>,
10064 _request: BitbucketServerConfig,
10065 _parent: String,
10066 _bitbucket_server_config_id: Option<String>,
10067 _delegate: Option<&'a mut dyn common::Delegate>,
10068 _additional_params: HashMap<String, String>,
10069 _scopes: BTreeSet<String>,
10070}
10071
10072impl<'a, C> common::CallBuilder for ProjectLocationBitbucketServerConfigCreateCall<'a, C> {}
10073
10074impl<'a, C> ProjectLocationBitbucketServerConfigCreateCall<'a, C>
10075where
10076 C: common::Connector,
10077{
10078 /// Perform the operation you have build so far.
10079 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
10080 use std::borrow::Cow;
10081 use std::io::{Read, Seek};
10082
10083 use common::{url::Params, ToParts};
10084 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10085
10086 let mut dd = common::DefaultDelegate;
10087 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10088 dlg.begin(common::MethodInfo {
10089 id: "cloudbuild.projects.locations.bitbucketServerConfigs.create",
10090 http_method: hyper::Method::POST,
10091 });
10092
10093 for &field in ["alt", "parent", "bitbucketServerConfigId"].iter() {
10094 if self._additional_params.contains_key(field) {
10095 dlg.finished(false);
10096 return Err(common::Error::FieldClash(field));
10097 }
10098 }
10099
10100 let mut params = Params::with_capacity(5 + self._additional_params.len());
10101 params.push("parent", self._parent);
10102 if let Some(value) = self._bitbucket_server_config_id.as_ref() {
10103 params.push("bitbucketServerConfigId", value);
10104 }
10105
10106 params.extend(self._additional_params.iter());
10107
10108 params.push("alt", "json");
10109 let mut url = self.hub._base_url.clone() + "v1/{+parent}/bitbucketServerConfigs";
10110 if self._scopes.is_empty() {
10111 self._scopes
10112 .insert(Scope::CloudPlatform.as_ref().to_string());
10113 }
10114
10115 #[allow(clippy::single_element_loop)]
10116 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
10117 url = params.uri_replacement(url, param_name, find_this, true);
10118 }
10119 {
10120 let to_remove = ["parent"];
10121 params.remove_params(&to_remove);
10122 }
10123
10124 let url = params.parse_with_url(&url);
10125
10126 let mut json_mime_type = mime::APPLICATION_JSON;
10127 let mut request_value_reader = {
10128 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10129 common::remove_json_null_values(&mut value);
10130 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10131 serde_json::to_writer(&mut dst, &value).unwrap();
10132 dst
10133 };
10134 let request_size = request_value_reader
10135 .seek(std::io::SeekFrom::End(0))
10136 .unwrap();
10137 request_value_reader
10138 .seek(std::io::SeekFrom::Start(0))
10139 .unwrap();
10140
10141 loop {
10142 let token = match self
10143 .hub
10144 .auth
10145 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10146 .await
10147 {
10148 Ok(token) => token,
10149 Err(e) => match dlg.token(e) {
10150 Ok(token) => token,
10151 Err(e) => {
10152 dlg.finished(false);
10153 return Err(common::Error::MissingToken(e));
10154 }
10155 },
10156 };
10157 request_value_reader
10158 .seek(std::io::SeekFrom::Start(0))
10159 .unwrap();
10160 let mut req_result = {
10161 let client = &self.hub.client;
10162 dlg.pre_request();
10163 let mut req_builder = hyper::Request::builder()
10164 .method(hyper::Method::POST)
10165 .uri(url.as_str())
10166 .header(USER_AGENT, self.hub._user_agent.clone());
10167
10168 if let Some(token) = token.as_ref() {
10169 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10170 }
10171
10172 let request = req_builder
10173 .header(CONTENT_TYPE, json_mime_type.to_string())
10174 .header(CONTENT_LENGTH, request_size as u64)
10175 .body(common::to_body(
10176 request_value_reader.get_ref().clone().into(),
10177 ));
10178
10179 client.request(request.unwrap()).await
10180 };
10181
10182 match req_result {
10183 Err(err) => {
10184 if let common::Retry::After(d) = dlg.http_error(&err) {
10185 sleep(d).await;
10186 continue;
10187 }
10188 dlg.finished(false);
10189 return Err(common::Error::HttpError(err));
10190 }
10191 Ok(res) => {
10192 let (mut parts, body) = res.into_parts();
10193 let mut body = common::Body::new(body);
10194 if !parts.status.is_success() {
10195 let bytes = common::to_bytes(body).await.unwrap_or_default();
10196 let error = serde_json::from_str(&common::to_string(&bytes));
10197 let response = common::to_response(parts, bytes.into());
10198
10199 if let common::Retry::After(d) =
10200 dlg.http_failure(&response, error.as_ref().ok())
10201 {
10202 sleep(d).await;
10203 continue;
10204 }
10205
10206 dlg.finished(false);
10207
10208 return Err(match error {
10209 Ok(value) => common::Error::BadRequest(value),
10210 _ => common::Error::Failure(response),
10211 });
10212 }
10213 let response = {
10214 let bytes = common::to_bytes(body).await.unwrap_or_default();
10215 let encoded = common::to_string(&bytes);
10216 match serde_json::from_str(&encoded) {
10217 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10218 Err(error) => {
10219 dlg.response_json_decode_error(&encoded, &error);
10220 return Err(common::Error::JsonDecodeError(
10221 encoded.to_string(),
10222 error,
10223 ));
10224 }
10225 }
10226 };
10227
10228 dlg.finished(true);
10229 return Ok(response);
10230 }
10231 }
10232 }
10233 }
10234
10235 ///
10236 /// Sets the *request* property to the given value.
10237 ///
10238 /// Even though the property as already been set when instantiating this call,
10239 /// we provide this method for API completeness.
10240 pub fn request(
10241 mut self,
10242 new_value: BitbucketServerConfig,
10243 ) -> ProjectLocationBitbucketServerConfigCreateCall<'a, C> {
10244 self._request = new_value;
10245 self
10246 }
10247 /// Required. Name of the parent resource.
10248 ///
10249 /// Sets the *parent* path property to the given value.
10250 ///
10251 /// Even though the property as already been set when instantiating this call,
10252 /// we provide this method for API completeness.
10253 pub fn parent(
10254 mut self,
10255 new_value: &str,
10256 ) -> ProjectLocationBitbucketServerConfigCreateCall<'a, C> {
10257 self._parent = new_value.to_string();
10258 self
10259 }
10260 /// 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.
10261 ///
10262 /// Sets the *bitbucket server config id* query property to the given value.
10263 pub fn bitbucket_server_config_id(
10264 mut self,
10265 new_value: &str,
10266 ) -> ProjectLocationBitbucketServerConfigCreateCall<'a, C> {
10267 self._bitbucket_server_config_id = Some(new_value.to_string());
10268 self
10269 }
10270 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10271 /// while executing the actual API request.
10272 ///
10273 /// ````text
10274 /// It should be used to handle progress information, and to implement a certain level of resilience.
10275 /// ````
10276 ///
10277 /// Sets the *delegate* property to the given value.
10278 pub fn delegate(
10279 mut self,
10280 new_value: &'a mut dyn common::Delegate,
10281 ) -> ProjectLocationBitbucketServerConfigCreateCall<'a, C> {
10282 self._delegate = Some(new_value);
10283 self
10284 }
10285
10286 /// Set any additional parameter of the query string used in the request.
10287 /// It should be used to set parameters which are not yet available through their own
10288 /// setters.
10289 ///
10290 /// Please note that this method must not be used to set any of the known parameters
10291 /// which have their own setter method. If done anyway, the request will fail.
10292 ///
10293 /// # Additional Parameters
10294 ///
10295 /// * *$.xgafv* (query-string) - V1 error format.
10296 /// * *access_token* (query-string) - OAuth access token.
10297 /// * *alt* (query-string) - Data format for response.
10298 /// * *callback* (query-string) - JSONP
10299 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10300 /// * *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.
10301 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10302 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10303 /// * *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.
10304 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10305 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10306 pub fn param<T>(
10307 mut self,
10308 name: T,
10309 value: T,
10310 ) -> ProjectLocationBitbucketServerConfigCreateCall<'a, C>
10311 where
10312 T: AsRef<str>,
10313 {
10314 self._additional_params
10315 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10316 self
10317 }
10318
10319 /// Identifies the authorization scope for the method you are building.
10320 ///
10321 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10322 /// [`Scope::CloudPlatform`].
10323 ///
10324 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10325 /// tokens for more than one scope.
10326 ///
10327 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10328 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10329 /// sufficient, a read-write scope will do as well.
10330 pub fn add_scope<St>(
10331 mut self,
10332 scope: St,
10333 ) -> ProjectLocationBitbucketServerConfigCreateCall<'a, C>
10334 where
10335 St: AsRef<str>,
10336 {
10337 self._scopes.insert(String::from(scope.as_ref()));
10338 self
10339 }
10340 /// Identifies the authorization scope(s) for the method you are building.
10341 ///
10342 /// See [`Self::add_scope()`] for details.
10343 pub fn add_scopes<I, St>(
10344 mut self,
10345 scopes: I,
10346 ) -> ProjectLocationBitbucketServerConfigCreateCall<'a, C>
10347 where
10348 I: IntoIterator<Item = St>,
10349 St: AsRef<str>,
10350 {
10351 self._scopes
10352 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10353 self
10354 }
10355
10356 /// Removes all scopes, and no default scope will be used either.
10357 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10358 /// for details).
10359 pub fn clear_scopes(mut self) -> ProjectLocationBitbucketServerConfigCreateCall<'a, C> {
10360 self._scopes.clear();
10361 self
10362 }
10363}
10364
10365/// Delete a `BitbucketServerConfig`. This API is experimental.
10366///
10367/// A builder for the *locations.bitbucketServerConfigs.delete* method supported by a *project* resource.
10368/// It is not used directly, but through a [`ProjectMethods`] instance.
10369///
10370/// # Example
10371///
10372/// Instantiate a resource method builder
10373///
10374/// ```test_harness,no_run
10375/// # extern crate hyper;
10376/// # extern crate hyper_rustls;
10377/// # extern crate google_cloudbuild1 as cloudbuild1;
10378/// # async fn dox() {
10379/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10380///
10381/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10382/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10383/// # .with_native_roots()
10384/// # .unwrap()
10385/// # .https_only()
10386/// # .enable_http2()
10387/// # .build();
10388///
10389/// # let executor = hyper_util::rt::TokioExecutor::new();
10390/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10391/// # secret,
10392/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10393/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10394/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10395/// # ),
10396/// # ).build().await.unwrap();
10397///
10398/// # let client = hyper_util::client::legacy::Client::builder(
10399/// # hyper_util::rt::TokioExecutor::new()
10400/// # )
10401/// # .build(
10402/// # hyper_rustls::HttpsConnectorBuilder::new()
10403/// # .with_native_roots()
10404/// # .unwrap()
10405/// # .https_or_http()
10406/// # .enable_http2()
10407/// # .build()
10408/// # );
10409/// # let mut hub = CloudBuild::new(client, auth);
10410/// // You can configure optional parameters by calling the respective setters at will, and
10411/// // execute the final call using `doit()`.
10412/// // Values shown here are possibly random and not representative !
10413/// let result = hub.projects().locations_bitbucket_server_configs_delete("name")
10414/// .doit().await;
10415/// # }
10416/// ```
10417pub struct ProjectLocationBitbucketServerConfigDeleteCall<'a, C>
10418where
10419 C: 'a,
10420{
10421 hub: &'a CloudBuild<C>,
10422 _name: String,
10423 _delegate: Option<&'a mut dyn common::Delegate>,
10424 _additional_params: HashMap<String, String>,
10425 _scopes: BTreeSet<String>,
10426}
10427
10428impl<'a, C> common::CallBuilder for ProjectLocationBitbucketServerConfigDeleteCall<'a, C> {}
10429
10430impl<'a, C> ProjectLocationBitbucketServerConfigDeleteCall<'a, C>
10431where
10432 C: common::Connector,
10433{
10434 /// Perform the operation you have build so far.
10435 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
10436 use std::borrow::Cow;
10437 use std::io::{Read, Seek};
10438
10439 use common::{url::Params, ToParts};
10440 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10441
10442 let mut dd = common::DefaultDelegate;
10443 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10444 dlg.begin(common::MethodInfo {
10445 id: "cloudbuild.projects.locations.bitbucketServerConfigs.delete",
10446 http_method: hyper::Method::DELETE,
10447 });
10448
10449 for &field in ["alt", "name"].iter() {
10450 if self._additional_params.contains_key(field) {
10451 dlg.finished(false);
10452 return Err(common::Error::FieldClash(field));
10453 }
10454 }
10455
10456 let mut params = Params::with_capacity(3 + self._additional_params.len());
10457 params.push("name", self._name);
10458
10459 params.extend(self._additional_params.iter());
10460
10461 params.push("alt", "json");
10462 let mut url = self.hub._base_url.clone() + "v1/{+name}";
10463 if self._scopes.is_empty() {
10464 self._scopes
10465 .insert(Scope::CloudPlatform.as_ref().to_string());
10466 }
10467
10468 #[allow(clippy::single_element_loop)]
10469 for &(find_this, param_name) in [("{+name}", "name")].iter() {
10470 url = params.uri_replacement(url, param_name, find_this, true);
10471 }
10472 {
10473 let to_remove = ["name"];
10474 params.remove_params(&to_remove);
10475 }
10476
10477 let url = params.parse_with_url(&url);
10478
10479 loop {
10480 let token = match self
10481 .hub
10482 .auth
10483 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10484 .await
10485 {
10486 Ok(token) => token,
10487 Err(e) => match dlg.token(e) {
10488 Ok(token) => token,
10489 Err(e) => {
10490 dlg.finished(false);
10491 return Err(common::Error::MissingToken(e));
10492 }
10493 },
10494 };
10495 let mut req_result = {
10496 let client = &self.hub.client;
10497 dlg.pre_request();
10498 let mut req_builder = hyper::Request::builder()
10499 .method(hyper::Method::DELETE)
10500 .uri(url.as_str())
10501 .header(USER_AGENT, self.hub._user_agent.clone());
10502
10503 if let Some(token) = token.as_ref() {
10504 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10505 }
10506
10507 let request = req_builder
10508 .header(CONTENT_LENGTH, 0_u64)
10509 .body(common::to_body::<String>(None));
10510
10511 client.request(request.unwrap()).await
10512 };
10513
10514 match req_result {
10515 Err(err) => {
10516 if let common::Retry::After(d) = dlg.http_error(&err) {
10517 sleep(d).await;
10518 continue;
10519 }
10520 dlg.finished(false);
10521 return Err(common::Error::HttpError(err));
10522 }
10523 Ok(res) => {
10524 let (mut parts, body) = res.into_parts();
10525 let mut body = common::Body::new(body);
10526 if !parts.status.is_success() {
10527 let bytes = common::to_bytes(body).await.unwrap_or_default();
10528 let error = serde_json::from_str(&common::to_string(&bytes));
10529 let response = common::to_response(parts, bytes.into());
10530
10531 if let common::Retry::After(d) =
10532 dlg.http_failure(&response, error.as_ref().ok())
10533 {
10534 sleep(d).await;
10535 continue;
10536 }
10537
10538 dlg.finished(false);
10539
10540 return Err(match error {
10541 Ok(value) => common::Error::BadRequest(value),
10542 _ => common::Error::Failure(response),
10543 });
10544 }
10545 let response = {
10546 let bytes = common::to_bytes(body).await.unwrap_or_default();
10547 let encoded = common::to_string(&bytes);
10548 match serde_json::from_str(&encoded) {
10549 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10550 Err(error) => {
10551 dlg.response_json_decode_error(&encoded, &error);
10552 return Err(common::Error::JsonDecodeError(
10553 encoded.to_string(),
10554 error,
10555 ));
10556 }
10557 }
10558 };
10559
10560 dlg.finished(true);
10561 return Ok(response);
10562 }
10563 }
10564 }
10565 }
10566
10567 /// Required. The config resource name.
10568 ///
10569 /// Sets the *name* path property to the given value.
10570 ///
10571 /// Even though the property as already been set when instantiating this call,
10572 /// we provide this method for API completeness.
10573 pub fn name(
10574 mut self,
10575 new_value: &str,
10576 ) -> ProjectLocationBitbucketServerConfigDeleteCall<'a, C> {
10577 self._name = new_value.to_string();
10578 self
10579 }
10580 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10581 /// while executing the actual API request.
10582 ///
10583 /// ````text
10584 /// It should be used to handle progress information, and to implement a certain level of resilience.
10585 /// ````
10586 ///
10587 /// Sets the *delegate* property to the given value.
10588 pub fn delegate(
10589 mut self,
10590 new_value: &'a mut dyn common::Delegate,
10591 ) -> ProjectLocationBitbucketServerConfigDeleteCall<'a, C> {
10592 self._delegate = Some(new_value);
10593 self
10594 }
10595
10596 /// Set any additional parameter of the query string used in the request.
10597 /// It should be used to set parameters which are not yet available through their own
10598 /// setters.
10599 ///
10600 /// Please note that this method must not be used to set any of the known parameters
10601 /// which have their own setter method. If done anyway, the request will fail.
10602 ///
10603 /// # Additional Parameters
10604 ///
10605 /// * *$.xgafv* (query-string) - V1 error format.
10606 /// * *access_token* (query-string) - OAuth access token.
10607 /// * *alt* (query-string) - Data format for response.
10608 /// * *callback* (query-string) - JSONP
10609 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10610 /// * *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.
10611 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10612 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10613 /// * *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.
10614 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10615 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10616 pub fn param<T>(
10617 mut self,
10618 name: T,
10619 value: T,
10620 ) -> ProjectLocationBitbucketServerConfigDeleteCall<'a, C>
10621 where
10622 T: AsRef<str>,
10623 {
10624 self._additional_params
10625 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10626 self
10627 }
10628
10629 /// Identifies the authorization scope for the method you are building.
10630 ///
10631 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10632 /// [`Scope::CloudPlatform`].
10633 ///
10634 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10635 /// tokens for more than one scope.
10636 ///
10637 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10638 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10639 /// sufficient, a read-write scope will do as well.
10640 pub fn add_scope<St>(
10641 mut self,
10642 scope: St,
10643 ) -> ProjectLocationBitbucketServerConfigDeleteCall<'a, C>
10644 where
10645 St: AsRef<str>,
10646 {
10647 self._scopes.insert(String::from(scope.as_ref()));
10648 self
10649 }
10650 /// Identifies the authorization scope(s) for the method you are building.
10651 ///
10652 /// See [`Self::add_scope()`] for details.
10653 pub fn add_scopes<I, St>(
10654 mut self,
10655 scopes: I,
10656 ) -> ProjectLocationBitbucketServerConfigDeleteCall<'a, C>
10657 where
10658 I: IntoIterator<Item = St>,
10659 St: AsRef<str>,
10660 {
10661 self._scopes
10662 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10663 self
10664 }
10665
10666 /// Removes all scopes, and no default scope will be used either.
10667 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10668 /// for details).
10669 pub fn clear_scopes(mut self) -> ProjectLocationBitbucketServerConfigDeleteCall<'a, C> {
10670 self._scopes.clear();
10671 self
10672 }
10673}
10674
10675/// Retrieve a `BitbucketServerConfig`. This API is experimental.
10676///
10677/// A builder for the *locations.bitbucketServerConfigs.get* method supported by a *project* resource.
10678/// It is not used directly, but through a [`ProjectMethods`] instance.
10679///
10680/// # Example
10681///
10682/// Instantiate a resource method builder
10683///
10684/// ```test_harness,no_run
10685/// # extern crate hyper;
10686/// # extern crate hyper_rustls;
10687/// # extern crate google_cloudbuild1 as cloudbuild1;
10688/// # async fn dox() {
10689/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10690///
10691/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10692/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10693/// # .with_native_roots()
10694/// # .unwrap()
10695/// # .https_only()
10696/// # .enable_http2()
10697/// # .build();
10698///
10699/// # let executor = hyper_util::rt::TokioExecutor::new();
10700/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10701/// # secret,
10702/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10703/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10704/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10705/// # ),
10706/// # ).build().await.unwrap();
10707///
10708/// # let client = hyper_util::client::legacy::Client::builder(
10709/// # hyper_util::rt::TokioExecutor::new()
10710/// # )
10711/// # .build(
10712/// # hyper_rustls::HttpsConnectorBuilder::new()
10713/// # .with_native_roots()
10714/// # .unwrap()
10715/// # .https_or_http()
10716/// # .enable_http2()
10717/// # .build()
10718/// # );
10719/// # let mut hub = CloudBuild::new(client, auth);
10720/// // You can configure optional parameters by calling the respective setters at will, and
10721/// // execute the final call using `doit()`.
10722/// // Values shown here are possibly random and not representative !
10723/// let result = hub.projects().locations_bitbucket_server_configs_get("name")
10724/// .doit().await;
10725/// # }
10726/// ```
10727pub struct ProjectLocationBitbucketServerConfigGetCall<'a, C>
10728where
10729 C: 'a,
10730{
10731 hub: &'a CloudBuild<C>,
10732 _name: String,
10733 _delegate: Option<&'a mut dyn common::Delegate>,
10734 _additional_params: HashMap<String, String>,
10735 _scopes: BTreeSet<String>,
10736}
10737
10738impl<'a, C> common::CallBuilder for ProjectLocationBitbucketServerConfigGetCall<'a, C> {}
10739
10740impl<'a, C> ProjectLocationBitbucketServerConfigGetCall<'a, C>
10741where
10742 C: common::Connector,
10743{
10744 /// Perform the operation you have build so far.
10745 pub async fn doit(mut self) -> common::Result<(common::Response, BitbucketServerConfig)> {
10746 use std::borrow::Cow;
10747 use std::io::{Read, Seek};
10748
10749 use common::{url::Params, ToParts};
10750 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10751
10752 let mut dd = common::DefaultDelegate;
10753 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10754 dlg.begin(common::MethodInfo {
10755 id: "cloudbuild.projects.locations.bitbucketServerConfigs.get",
10756 http_method: hyper::Method::GET,
10757 });
10758
10759 for &field in ["alt", "name"].iter() {
10760 if self._additional_params.contains_key(field) {
10761 dlg.finished(false);
10762 return Err(common::Error::FieldClash(field));
10763 }
10764 }
10765
10766 let mut params = Params::with_capacity(3 + self._additional_params.len());
10767 params.push("name", self._name);
10768
10769 params.extend(self._additional_params.iter());
10770
10771 params.push("alt", "json");
10772 let mut url = self.hub._base_url.clone() + "v1/{+name}";
10773 if self._scopes.is_empty() {
10774 self._scopes
10775 .insert(Scope::CloudPlatform.as_ref().to_string());
10776 }
10777
10778 #[allow(clippy::single_element_loop)]
10779 for &(find_this, param_name) in [("{+name}", "name")].iter() {
10780 url = params.uri_replacement(url, param_name, find_this, true);
10781 }
10782 {
10783 let to_remove = ["name"];
10784 params.remove_params(&to_remove);
10785 }
10786
10787 let url = params.parse_with_url(&url);
10788
10789 loop {
10790 let token = match self
10791 .hub
10792 .auth
10793 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10794 .await
10795 {
10796 Ok(token) => token,
10797 Err(e) => match dlg.token(e) {
10798 Ok(token) => token,
10799 Err(e) => {
10800 dlg.finished(false);
10801 return Err(common::Error::MissingToken(e));
10802 }
10803 },
10804 };
10805 let mut req_result = {
10806 let client = &self.hub.client;
10807 dlg.pre_request();
10808 let mut req_builder = hyper::Request::builder()
10809 .method(hyper::Method::GET)
10810 .uri(url.as_str())
10811 .header(USER_AGENT, self.hub._user_agent.clone());
10812
10813 if let Some(token) = token.as_ref() {
10814 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10815 }
10816
10817 let request = req_builder
10818 .header(CONTENT_LENGTH, 0_u64)
10819 .body(common::to_body::<String>(None));
10820
10821 client.request(request.unwrap()).await
10822 };
10823
10824 match req_result {
10825 Err(err) => {
10826 if let common::Retry::After(d) = dlg.http_error(&err) {
10827 sleep(d).await;
10828 continue;
10829 }
10830 dlg.finished(false);
10831 return Err(common::Error::HttpError(err));
10832 }
10833 Ok(res) => {
10834 let (mut parts, body) = res.into_parts();
10835 let mut body = common::Body::new(body);
10836 if !parts.status.is_success() {
10837 let bytes = common::to_bytes(body).await.unwrap_or_default();
10838 let error = serde_json::from_str(&common::to_string(&bytes));
10839 let response = common::to_response(parts, bytes.into());
10840
10841 if let common::Retry::After(d) =
10842 dlg.http_failure(&response, error.as_ref().ok())
10843 {
10844 sleep(d).await;
10845 continue;
10846 }
10847
10848 dlg.finished(false);
10849
10850 return Err(match error {
10851 Ok(value) => common::Error::BadRequest(value),
10852 _ => common::Error::Failure(response),
10853 });
10854 }
10855 let response = {
10856 let bytes = common::to_bytes(body).await.unwrap_or_default();
10857 let encoded = common::to_string(&bytes);
10858 match serde_json::from_str(&encoded) {
10859 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10860 Err(error) => {
10861 dlg.response_json_decode_error(&encoded, &error);
10862 return Err(common::Error::JsonDecodeError(
10863 encoded.to_string(),
10864 error,
10865 ));
10866 }
10867 }
10868 };
10869
10870 dlg.finished(true);
10871 return Ok(response);
10872 }
10873 }
10874 }
10875 }
10876
10877 /// Required. The config resource name.
10878 ///
10879 /// Sets the *name* path property to the given value.
10880 ///
10881 /// Even though the property as already been set when instantiating this call,
10882 /// we provide this method for API completeness.
10883 pub fn name(mut self, new_value: &str) -> ProjectLocationBitbucketServerConfigGetCall<'a, C> {
10884 self._name = new_value.to_string();
10885 self
10886 }
10887 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10888 /// while executing the actual API request.
10889 ///
10890 /// ````text
10891 /// It should be used to handle progress information, and to implement a certain level of resilience.
10892 /// ````
10893 ///
10894 /// Sets the *delegate* property to the given value.
10895 pub fn delegate(
10896 mut self,
10897 new_value: &'a mut dyn common::Delegate,
10898 ) -> ProjectLocationBitbucketServerConfigGetCall<'a, C> {
10899 self._delegate = Some(new_value);
10900 self
10901 }
10902
10903 /// Set any additional parameter of the query string used in the request.
10904 /// It should be used to set parameters which are not yet available through their own
10905 /// setters.
10906 ///
10907 /// Please note that this method must not be used to set any of the known parameters
10908 /// which have their own setter method. If done anyway, the request will fail.
10909 ///
10910 /// # Additional Parameters
10911 ///
10912 /// * *$.xgafv* (query-string) - V1 error format.
10913 /// * *access_token* (query-string) - OAuth access token.
10914 /// * *alt* (query-string) - Data format for response.
10915 /// * *callback* (query-string) - JSONP
10916 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10917 /// * *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.
10918 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10919 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10920 /// * *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.
10921 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10922 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10923 pub fn param<T>(
10924 mut self,
10925 name: T,
10926 value: T,
10927 ) -> ProjectLocationBitbucketServerConfigGetCall<'a, C>
10928 where
10929 T: AsRef<str>,
10930 {
10931 self._additional_params
10932 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10933 self
10934 }
10935
10936 /// Identifies the authorization scope for the method you are building.
10937 ///
10938 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10939 /// [`Scope::CloudPlatform`].
10940 ///
10941 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10942 /// tokens for more than one scope.
10943 ///
10944 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10945 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10946 /// sufficient, a read-write scope will do as well.
10947 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationBitbucketServerConfigGetCall<'a, C>
10948 where
10949 St: AsRef<str>,
10950 {
10951 self._scopes.insert(String::from(scope.as_ref()));
10952 self
10953 }
10954 /// Identifies the authorization scope(s) for the method you are building.
10955 ///
10956 /// See [`Self::add_scope()`] for details.
10957 pub fn add_scopes<I, St>(
10958 mut self,
10959 scopes: I,
10960 ) -> ProjectLocationBitbucketServerConfigGetCall<'a, C>
10961 where
10962 I: IntoIterator<Item = St>,
10963 St: AsRef<str>,
10964 {
10965 self._scopes
10966 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10967 self
10968 }
10969
10970 /// Removes all scopes, and no default scope will be used either.
10971 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10972 /// for details).
10973 pub fn clear_scopes(mut self) -> ProjectLocationBitbucketServerConfigGetCall<'a, C> {
10974 self._scopes.clear();
10975 self
10976 }
10977}
10978
10979/// List all `BitbucketServerConfigs` for a given project. This API is experimental.
10980///
10981/// A builder for the *locations.bitbucketServerConfigs.list* method supported by a *project* resource.
10982/// It is not used directly, but through a [`ProjectMethods`] instance.
10983///
10984/// # Example
10985///
10986/// Instantiate a resource method builder
10987///
10988/// ```test_harness,no_run
10989/// # extern crate hyper;
10990/// # extern crate hyper_rustls;
10991/// # extern crate google_cloudbuild1 as cloudbuild1;
10992/// # async fn dox() {
10993/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10994///
10995/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10996/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10997/// # .with_native_roots()
10998/// # .unwrap()
10999/// # .https_only()
11000/// # .enable_http2()
11001/// # .build();
11002///
11003/// # let executor = hyper_util::rt::TokioExecutor::new();
11004/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11005/// # secret,
11006/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11007/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11008/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11009/// # ),
11010/// # ).build().await.unwrap();
11011///
11012/// # let client = hyper_util::client::legacy::Client::builder(
11013/// # hyper_util::rt::TokioExecutor::new()
11014/// # )
11015/// # .build(
11016/// # hyper_rustls::HttpsConnectorBuilder::new()
11017/// # .with_native_roots()
11018/// # .unwrap()
11019/// # .https_or_http()
11020/// # .enable_http2()
11021/// # .build()
11022/// # );
11023/// # let mut hub = CloudBuild::new(client, auth);
11024/// // You can configure optional parameters by calling the respective setters at will, and
11025/// // execute the final call using `doit()`.
11026/// // Values shown here are possibly random and not representative !
11027/// let result = hub.projects().locations_bitbucket_server_configs_list("parent")
11028/// .page_token("sed")
11029/// .page_size(-20)
11030/// .doit().await;
11031/// # }
11032/// ```
11033pub struct ProjectLocationBitbucketServerConfigListCall<'a, C>
11034where
11035 C: 'a,
11036{
11037 hub: &'a CloudBuild<C>,
11038 _parent: String,
11039 _page_token: Option<String>,
11040 _page_size: Option<i32>,
11041 _delegate: Option<&'a mut dyn common::Delegate>,
11042 _additional_params: HashMap<String, String>,
11043 _scopes: BTreeSet<String>,
11044}
11045
11046impl<'a, C> common::CallBuilder for ProjectLocationBitbucketServerConfigListCall<'a, C> {}
11047
11048impl<'a, C> ProjectLocationBitbucketServerConfigListCall<'a, C>
11049where
11050 C: common::Connector,
11051{
11052 /// Perform the operation you have build so far.
11053 pub async fn doit(
11054 mut self,
11055 ) -> common::Result<(common::Response, ListBitbucketServerConfigsResponse)> {
11056 use std::borrow::Cow;
11057 use std::io::{Read, Seek};
11058
11059 use common::{url::Params, ToParts};
11060 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11061
11062 let mut dd = common::DefaultDelegate;
11063 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11064 dlg.begin(common::MethodInfo {
11065 id: "cloudbuild.projects.locations.bitbucketServerConfigs.list",
11066 http_method: hyper::Method::GET,
11067 });
11068
11069 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
11070 if self._additional_params.contains_key(field) {
11071 dlg.finished(false);
11072 return Err(common::Error::FieldClash(field));
11073 }
11074 }
11075
11076 let mut params = Params::with_capacity(5 + self._additional_params.len());
11077 params.push("parent", self._parent);
11078 if let Some(value) = self._page_token.as_ref() {
11079 params.push("pageToken", value);
11080 }
11081 if let Some(value) = self._page_size.as_ref() {
11082 params.push("pageSize", value.to_string());
11083 }
11084
11085 params.extend(self._additional_params.iter());
11086
11087 params.push("alt", "json");
11088 let mut url = self.hub._base_url.clone() + "v1/{+parent}/bitbucketServerConfigs";
11089 if self._scopes.is_empty() {
11090 self._scopes
11091 .insert(Scope::CloudPlatform.as_ref().to_string());
11092 }
11093
11094 #[allow(clippy::single_element_loop)]
11095 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
11096 url = params.uri_replacement(url, param_name, find_this, true);
11097 }
11098 {
11099 let to_remove = ["parent"];
11100 params.remove_params(&to_remove);
11101 }
11102
11103 let url = params.parse_with_url(&url);
11104
11105 loop {
11106 let token = match self
11107 .hub
11108 .auth
11109 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11110 .await
11111 {
11112 Ok(token) => token,
11113 Err(e) => match dlg.token(e) {
11114 Ok(token) => token,
11115 Err(e) => {
11116 dlg.finished(false);
11117 return Err(common::Error::MissingToken(e));
11118 }
11119 },
11120 };
11121 let mut req_result = {
11122 let client = &self.hub.client;
11123 dlg.pre_request();
11124 let mut req_builder = hyper::Request::builder()
11125 .method(hyper::Method::GET)
11126 .uri(url.as_str())
11127 .header(USER_AGENT, self.hub._user_agent.clone());
11128
11129 if let Some(token) = token.as_ref() {
11130 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11131 }
11132
11133 let request = req_builder
11134 .header(CONTENT_LENGTH, 0_u64)
11135 .body(common::to_body::<String>(None));
11136
11137 client.request(request.unwrap()).await
11138 };
11139
11140 match req_result {
11141 Err(err) => {
11142 if let common::Retry::After(d) = dlg.http_error(&err) {
11143 sleep(d).await;
11144 continue;
11145 }
11146 dlg.finished(false);
11147 return Err(common::Error::HttpError(err));
11148 }
11149 Ok(res) => {
11150 let (mut parts, body) = res.into_parts();
11151 let mut body = common::Body::new(body);
11152 if !parts.status.is_success() {
11153 let bytes = common::to_bytes(body).await.unwrap_or_default();
11154 let error = serde_json::from_str(&common::to_string(&bytes));
11155 let response = common::to_response(parts, bytes.into());
11156
11157 if let common::Retry::After(d) =
11158 dlg.http_failure(&response, error.as_ref().ok())
11159 {
11160 sleep(d).await;
11161 continue;
11162 }
11163
11164 dlg.finished(false);
11165
11166 return Err(match error {
11167 Ok(value) => common::Error::BadRequest(value),
11168 _ => common::Error::Failure(response),
11169 });
11170 }
11171 let response = {
11172 let bytes = common::to_bytes(body).await.unwrap_or_default();
11173 let encoded = common::to_string(&bytes);
11174 match serde_json::from_str(&encoded) {
11175 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11176 Err(error) => {
11177 dlg.response_json_decode_error(&encoded, &error);
11178 return Err(common::Error::JsonDecodeError(
11179 encoded.to_string(),
11180 error,
11181 ));
11182 }
11183 }
11184 };
11185
11186 dlg.finished(true);
11187 return Ok(response);
11188 }
11189 }
11190 }
11191 }
11192
11193 /// Required. Name of the parent resource.
11194 ///
11195 /// Sets the *parent* path property to the given value.
11196 ///
11197 /// Even though the property as already been set when instantiating this call,
11198 /// we provide this method for API completeness.
11199 pub fn parent(
11200 mut self,
11201 new_value: &str,
11202 ) -> ProjectLocationBitbucketServerConfigListCall<'a, C> {
11203 self._parent = new_value.to_string();
11204 self
11205 }
11206 /// 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.
11207 ///
11208 /// Sets the *page token* query property to the given value.
11209 pub fn page_token(
11210 mut self,
11211 new_value: &str,
11212 ) -> ProjectLocationBitbucketServerConfigListCall<'a, C> {
11213 self._page_token = Some(new_value.to_string());
11214 self
11215 }
11216 /// 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.
11217 ///
11218 /// Sets the *page size* query property to the given value.
11219 pub fn page_size(
11220 mut self,
11221 new_value: i32,
11222 ) -> ProjectLocationBitbucketServerConfigListCall<'a, C> {
11223 self._page_size = Some(new_value);
11224 self
11225 }
11226 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11227 /// while executing the actual API request.
11228 ///
11229 /// ````text
11230 /// It should be used to handle progress information, and to implement a certain level of resilience.
11231 /// ````
11232 ///
11233 /// Sets the *delegate* property to the given value.
11234 pub fn delegate(
11235 mut self,
11236 new_value: &'a mut dyn common::Delegate,
11237 ) -> ProjectLocationBitbucketServerConfigListCall<'a, C> {
11238 self._delegate = Some(new_value);
11239 self
11240 }
11241
11242 /// Set any additional parameter of the query string used in the request.
11243 /// It should be used to set parameters which are not yet available through their own
11244 /// setters.
11245 ///
11246 /// Please note that this method must not be used to set any of the known parameters
11247 /// which have their own setter method. If done anyway, the request will fail.
11248 ///
11249 /// # Additional Parameters
11250 ///
11251 /// * *$.xgafv* (query-string) - V1 error format.
11252 /// * *access_token* (query-string) - OAuth access token.
11253 /// * *alt* (query-string) - Data format for response.
11254 /// * *callback* (query-string) - JSONP
11255 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11256 /// * *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.
11257 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11258 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11259 /// * *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.
11260 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11261 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11262 pub fn param<T>(
11263 mut self,
11264 name: T,
11265 value: T,
11266 ) -> ProjectLocationBitbucketServerConfigListCall<'a, C>
11267 where
11268 T: AsRef<str>,
11269 {
11270 self._additional_params
11271 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11272 self
11273 }
11274
11275 /// Identifies the authorization scope for the method you are building.
11276 ///
11277 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11278 /// [`Scope::CloudPlatform`].
11279 ///
11280 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11281 /// tokens for more than one scope.
11282 ///
11283 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11284 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11285 /// sufficient, a read-write scope will do as well.
11286 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationBitbucketServerConfigListCall<'a, C>
11287 where
11288 St: AsRef<str>,
11289 {
11290 self._scopes.insert(String::from(scope.as_ref()));
11291 self
11292 }
11293 /// Identifies the authorization scope(s) for the method you are building.
11294 ///
11295 /// See [`Self::add_scope()`] for details.
11296 pub fn add_scopes<I, St>(
11297 mut self,
11298 scopes: I,
11299 ) -> ProjectLocationBitbucketServerConfigListCall<'a, C>
11300 where
11301 I: IntoIterator<Item = St>,
11302 St: AsRef<str>,
11303 {
11304 self._scopes
11305 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11306 self
11307 }
11308
11309 /// Removes all scopes, and no default scope will be used either.
11310 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11311 /// for details).
11312 pub fn clear_scopes(mut self) -> ProjectLocationBitbucketServerConfigListCall<'a, C> {
11313 self._scopes.clear();
11314 self
11315 }
11316}
11317
11318/// Updates an existing `BitbucketServerConfig`. This API is experimental.
11319///
11320/// A builder for the *locations.bitbucketServerConfigs.patch* method supported by a *project* resource.
11321/// It is not used directly, but through a [`ProjectMethods`] instance.
11322///
11323/// # Example
11324///
11325/// Instantiate a resource method builder
11326///
11327/// ```test_harness,no_run
11328/// # extern crate hyper;
11329/// # extern crate hyper_rustls;
11330/// # extern crate google_cloudbuild1 as cloudbuild1;
11331/// use cloudbuild1::api::BitbucketServerConfig;
11332/// # async fn dox() {
11333/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11334///
11335/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11336/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11337/// # .with_native_roots()
11338/// # .unwrap()
11339/// # .https_only()
11340/// # .enable_http2()
11341/// # .build();
11342///
11343/// # let executor = hyper_util::rt::TokioExecutor::new();
11344/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11345/// # secret,
11346/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11347/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11348/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11349/// # ),
11350/// # ).build().await.unwrap();
11351///
11352/// # let client = hyper_util::client::legacy::Client::builder(
11353/// # hyper_util::rt::TokioExecutor::new()
11354/// # )
11355/// # .build(
11356/// # hyper_rustls::HttpsConnectorBuilder::new()
11357/// # .with_native_roots()
11358/// # .unwrap()
11359/// # .https_or_http()
11360/// # .enable_http2()
11361/// # .build()
11362/// # );
11363/// # let mut hub = CloudBuild::new(client, auth);
11364/// // As the method needs a request, you would usually fill it with the desired information
11365/// // into the respective structure. Some of the parts shown here might not be applicable !
11366/// // Values shown here are possibly random and not representative !
11367/// let mut req = BitbucketServerConfig::default();
11368///
11369/// // You can configure optional parameters by calling the respective setters at will, and
11370/// // execute the final call using `doit()`.
11371/// // Values shown here are possibly random and not representative !
11372/// let result = hub.projects().locations_bitbucket_server_configs_patch(req, "name")
11373/// .update_mask(FieldMask::new::<&str>(&[]))
11374/// .doit().await;
11375/// # }
11376/// ```
11377pub struct ProjectLocationBitbucketServerConfigPatchCall<'a, C>
11378where
11379 C: 'a,
11380{
11381 hub: &'a CloudBuild<C>,
11382 _request: BitbucketServerConfig,
11383 _name: String,
11384 _update_mask: Option<common::FieldMask>,
11385 _delegate: Option<&'a mut dyn common::Delegate>,
11386 _additional_params: HashMap<String, String>,
11387 _scopes: BTreeSet<String>,
11388}
11389
11390impl<'a, C> common::CallBuilder for ProjectLocationBitbucketServerConfigPatchCall<'a, C> {}
11391
11392impl<'a, C> ProjectLocationBitbucketServerConfigPatchCall<'a, C>
11393where
11394 C: common::Connector,
11395{
11396 /// Perform the operation you have build so far.
11397 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
11398 use std::borrow::Cow;
11399 use std::io::{Read, Seek};
11400
11401 use common::{url::Params, ToParts};
11402 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11403
11404 let mut dd = common::DefaultDelegate;
11405 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11406 dlg.begin(common::MethodInfo {
11407 id: "cloudbuild.projects.locations.bitbucketServerConfigs.patch",
11408 http_method: hyper::Method::PATCH,
11409 });
11410
11411 for &field in ["alt", "name", "updateMask"].iter() {
11412 if self._additional_params.contains_key(field) {
11413 dlg.finished(false);
11414 return Err(common::Error::FieldClash(field));
11415 }
11416 }
11417
11418 let mut params = Params::with_capacity(5 + self._additional_params.len());
11419 params.push("name", self._name);
11420 if let Some(value) = self._update_mask.as_ref() {
11421 params.push("updateMask", value.to_string());
11422 }
11423
11424 params.extend(self._additional_params.iter());
11425
11426 params.push("alt", "json");
11427 let mut url = self.hub._base_url.clone() + "v1/{+name}";
11428 if self._scopes.is_empty() {
11429 self._scopes
11430 .insert(Scope::CloudPlatform.as_ref().to_string());
11431 }
11432
11433 #[allow(clippy::single_element_loop)]
11434 for &(find_this, param_name) in [("{+name}", "name")].iter() {
11435 url = params.uri_replacement(url, param_name, find_this, true);
11436 }
11437 {
11438 let to_remove = ["name"];
11439 params.remove_params(&to_remove);
11440 }
11441
11442 let url = params.parse_with_url(&url);
11443
11444 let mut json_mime_type = mime::APPLICATION_JSON;
11445 let mut request_value_reader = {
11446 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11447 common::remove_json_null_values(&mut value);
11448 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11449 serde_json::to_writer(&mut dst, &value).unwrap();
11450 dst
11451 };
11452 let request_size = request_value_reader
11453 .seek(std::io::SeekFrom::End(0))
11454 .unwrap();
11455 request_value_reader
11456 .seek(std::io::SeekFrom::Start(0))
11457 .unwrap();
11458
11459 loop {
11460 let token = match self
11461 .hub
11462 .auth
11463 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11464 .await
11465 {
11466 Ok(token) => token,
11467 Err(e) => match dlg.token(e) {
11468 Ok(token) => token,
11469 Err(e) => {
11470 dlg.finished(false);
11471 return Err(common::Error::MissingToken(e));
11472 }
11473 },
11474 };
11475 request_value_reader
11476 .seek(std::io::SeekFrom::Start(0))
11477 .unwrap();
11478 let mut req_result = {
11479 let client = &self.hub.client;
11480 dlg.pre_request();
11481 let mut req_builder = hyper::Request::builder()
11482 .method(hyper::Method::PATCH)
11483 .uri(url.as_str())
11484 .header(USER_AGENT, self.hub._user_agent.clone());
11485
11486 if let Some(token) = token.as_ref() {
11487 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11488 }
11489
11490 let request = req_builder
11491 .header(CONTENT_TYPE, json_mime_type.to_string())
11492 .header(CONTENT_LENGTH, request_size as u64)
11493 .body(common::to_body(
11494 request_value_reader.get_ref().clone().into(),
11495 ));
11496
11497 client.request(request.unwrap()).await
11498 };
11499
11500 match req_result {
11501 Err(err) => {
11502 if let common::Retry::After(d) = dlg.http_error(&err) {
11503 sleep(d).await;
11504 continue;
11505 }
11506 dlg.finished(false);
11507 return Err(common::Error::HttpError(err));
11508 }
11509 Ok(res) => {
11510 let (mut parts, body) = res.into_parts();
11511 let mut body = common::Body::new(body);
11512 if !parts.status.is_success() {
11513 let bytes = common::to_bytes(body).await.unwrap_or_default();
11514 let error = serde_json::from_str(&common::to_string(&bytes));
11515 let response = common::to_response(parts, bytes.into());
11516
11517 if let common::Retry::After(d) =
11518 dlg.http_failure(&response, error.as_ref().ok())
11519 {
11520 sleep(d).await;
11521 continue;
11522 }
11523
11524 dlg.finished(false);
11525
11526 return Err(match error {
11527 Ok(value) => common::Error::BadRequest(value),
11528 _ => common::Error::Failure(response),
11529 });
11530 }
11531 let response = {
11532 let bytes = common::to_bytes(body).await.unwrap_or_default();
11533 let encoded = common::to_string(&bytes);
11534 match serde_json::from_str(&encoded) {
11535 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11536 Err(error) => {
11537 dlg.response_json_decode_error(&encoded, &error);
11538 return Err(common::Error::JsonDecodeError(
11539 encoded.to_string(),
11540 error,
11541 ));
11542 }
11543 }
11544 };
11545
11546 dlg.finished(true);
11547 return Ok(response);
11548 }
11549 }
11550 }
11551 }
11552
11553 ///
11554 /// Sets the *request* property to the given value.
11555 ///
11556 /// Even though the property as already been set when instantiating this call,
11557 /// we provide this method for API completeness.
11558 pub fn request(
11559 mut self,
11560 new_value: BitbucketServerConfig,
11561 ) -> ProjectLocationBitbucketServerConfigPatchCall<'a, C> {
11562 self._request = new_value;
11563 self
11564 }
11565 /// The resource name for the config.
11566 ///
11567 /// Sets the *name* path property to the given value.
11568 ///
11569 /// Even though the property as already been set when instantiating this call,
11570 /// we provide this method for API completeness.
11571 pub fn name(mut self, new_value: &str) -> ProjectLocationBitbucketServerConfigPatchCall<'a, C> {
11572 self._name = new_value.to_string();
11573 self
11574 }
11575 /// 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.
11576 ///
11577 /// Sets the *update mask* query property to the given value.
11578 pub fn update_mask(
11579 mut self,
11580 new_value: common::FieldMask,
11581 ) -> ProjectLocationBitbucketServerConfigPatchCall<'a, C> {
11582 self._update_mask = Some(new_value);
11583 self
11584 }
11585 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11586 /// while executing the actual API request.
11587 ///
11588 /// ````text
11589 /// It should be used to handle progress information, and to implement a certain level of resilience.
11590 /// ````
11591 ///
11592 /// Sets the *delegate* property to the given value.
11593 pub fn delegate(
11594 mut self,
11595 new_value: &'a mut dyn common::Delegate,
11596 ) -> ProjectLocationBitbucketServerConfigPatchCall<'a, C> {
11597 self._delegate = Some(new_value);
11598 self
11599 }
11600
11601 /// Set any additional parameter of the query string used in the request.
11602 /// It should be used to set parameters which are not yet available through their own
11603 /// setters.
11604 ///
11605 /// Please note that this method must not be used to set any of the known parameters
11606 /// which have their own setter method. If done anyway, the request will fail.
11607 ///
11608 /// # Additional Parameters
11609 ///
11610 /// * *$.xgafv* (query-string) - V1 error format.
11611 /// * *access_token* (query-string) - OAuth access token.
11612 /// * *alt* (query-string) - Data format for response.
11613 /// * *callback* (query-string) - JSONP
11614 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11615 /// * *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.
11616 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11617 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11618 /// * *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.
11619 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11620 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11621 pub fn param<T>(
11622 mut self,
11623 name: T,
11624 value: T,
11625 ) -> ProjectLocationBitbucketServerConfigPatchCall<'a, C>
11626 where
11627 T: AsRef<str>,
11628 {
11629 self._additional_params
11630 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11631 self
11632 }
11633
11634 /// Identifies the authorization scope for the method you are building.
11635 ///
11636 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11637 /// [`Scope::CloudPlatform`].
11638 ///
11639 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11640 /// tokens for more than one scope.
11641 ///
11642 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11643 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11644 /// sufficient, a read-write scope will do as well.
11645 pub fn add_scope<St>(
11646 mut self,
11647 scope: St,
11648 ) -> ProjectLocationBitbucketServerConfigPatchCall<'a, C>
11649 where
11650 St: AsRef<str>,
11651 {
11652 self._scopes.insert(String::from(scope.as_ref()));
11653 self
11654 }
11655 /// Identifies the authorization scope(s) for the method you are building.
11656 ///
11657 /// See [`Self::add_scope()`] for details.
11658 pub fn add_scopes<I, St>(
11659 mut self,
11660 scopes: I,
11661 ) -> ProjectLocationBitbucketServerConfigPatchCall<'a, C>
11662 where
11663 I: IntoIterator<Item = St>,
11664 St: AsRef<str>,
11665 {
11666 self._scopes
11667 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11668 self
11669 }
11670
11671 /// Removes all scopes, and no default scope will be used either.
11672 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11673 /// for details).
11674 pub fn clear_scopes(mut self) -> ProjectLocationBitbucketServerConfigPatchCall<'a, C> {
11675 self._scopes.clear();
11676 self
11677 }
11678}
11679
11680/// Remove a Bitbucket Server repository from a given BitbucketServerConfig's connected repositories. This API is experimental.
11681///
11682/// A builder for the *locations.bitbucketServerConfigs.removeBitbucketServerConnectedRepository* method supported by a *project* resource.
11683/// It is not used directly, but through a [`ProjectMethods`] instance.
11684///
11685/// # Example
11686///
11687/// Instantiate a resource method builder
11688///
11689/// ```test_harness,no_run
11690/// # extern crate hyper;
11691/// # extern crate hyper_rustls;
11692/// # extern crate google_cloudbuild1 as cloudbuild1;
11693/// use cloudbuild1::api::RemoveBitbucketServerConnectedRepositoryRequest;
11694/// # async fn dox() {
11695/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11696///
11697/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11698/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11699/// # .with_native_roots()
11700/// # .unwrap()
11701/// # .https_only()
11702/// # .enable_http2()
11703/// # .build();
11704///
11705/// # let executor = hyper_util::rt::TokioExecutor::new();
11706/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11707/// # secret,
11708/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11709/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11710/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11711/// # ),
11712/// # ).build().await.unwrap();
11713///
11714/// # let client = hyper_util::client::legacy::Client::builder(
11715/// # hyper_util::rt::TokioExecutor::new()
11716/// # )
11717/// # .build(
11718/// # hyper_rustls::HttpsConnectorBuilder::new()
11719/// # .with_native_roots()
11720/// # .unwrap()
11721/// # .https_or_http()
11722/// # .enable_http2()
11723/// # .build()
11724/// # );
11725/// # let mut hub = CloudBuild::new(client, auth);
11726/// // As the method needs a request, you would usually fill it with the desired information
11727/// // into the respective structure. Some of the parts shown here might not be applicable !
11728/// // Values shown here are possibly random and not representative !
11729/// let mut req = RemoveBitbucketServerConnectedRepositoryRequest::default();
11730///
11731/// // You can configure optional parameters by calling the respective setters at will, and
11732/// // execute the final call using `doit()`.
11733/// // Values shown here are possibly random and not representative !
11734/// let result = hub.projects().locations_bitbucket_server_configs_remove_bitbucket_server_connected_repository(req, "config")
11735/// .doit().await;
11736/// # }
11737/// ```
11738pub struct ProjectLocationBitbucketServerConfigRemoveBitbucketServerConnectedRepositoryCall<'a, C>
11739where
11740 C: 'a,
11741{
11742 hub: &'a CloudBuild<C>,
11743 _request: RemoveBitbucketServerConnectedRepositoryRequest,
11744 _config: String,
11745 _delegate: Option<&'a mut dyn common::Delegate>,
11746 _additional_params: HashMap<String, String>,
11747 _scopes: BTreeSet<String>,
11748}
11749
11750impl<'a, C> common::CallBuilder
11751 for ProjectLocationBitbucketServerConfigRemoveBitbucketServerConnectedRepositoryCall<'a, C>
11752{
11753}
11754
11755impl<'a, C> ProjectLocationBitbucketServerConfigRemoveBitbucketServerConnectedRepositoryCall<'a, C>
11756where
11757 C: common::Connector,
11758{
11759 /// Perform the operation you have build so far.
11760 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
11761 use std::borrow::Cow;
11762 use std::io::{Read, Seek};
11763
11764 use common::{url::Params, ToParts};
11765 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11766
11767 let mut dd = common::DefaultDelegate;
11768 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11769 dlg.begin(common::MethodInfo { id: "cloudbuild.projects.locations.bitbucketServerConfigs.removeBitbucketServerConnectedRepository",
11770 http_method: hyper::Method::POST });
11771
11772 for &field in ["alt", "config"].iter() {
11773 if self._additional_params.contains_key(field) {
11774 dlg.finished(false);
11775 return Err(common::Error::FieldClash(field));
11776 }
11777 }
11778
11779 let mut params = Params::with_capacity(4 + self._additional_params.len());
11780 params.push("config", self._config);
11781
11782 params.extend(self._additional_params.iter());
11783
11784 params.push("alt", "json");
11785 let mut url =
11786 self.hub._base_url.clone() + "v1/{+config}:removeBitbucketServerConnectedRepository";
11787 if self._scopes.is_empty() {
11788 self._scopes
11789 .insert(Scope::CloudPlatform.as_ref().to_string());
11790 }
11791
11792 #[allow(clippy::single_element_loop)]
11793 for &(find_this, param_name) in [("{+config}", "config")].iter() {
11794 url = params.uri_replacement(url, param_name, find_this, true);
11795 }
11796 {
11797 let to_remove = ["config"];
11798 params.remove_params(&to_remove);
11799 }
11800
11801 let url = params.parse_with_url(&url);
11802
11803 let mut json_mime_type = mime::APPLICATION_JSON;
11804 let mut request_value_reader = {
11805 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11806 common::remove_json_null_values(&mut value);
11807 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11808 serde_json::to_writer(&mut dst, &value).unwrap();
11809 dst
11810 };
11811 let request_size = request_value_reader
11812 .seek(std::io::SeekFrom::End(0))
11813 .unwrap();
11814 request_value_reader
11815 .seek(std::io::SeekFrom::Start(0))
11816 .unwrap();
11817
11818 loop {
11819 let token = match self
11820 .hub
11821 .auth
11822 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11823 .await
11824 {
11825 Ok(token) => token,
11826 Err(e) => match dlg.token(e) {
11827 Ok(token) => token,
11828 Err(e) => {
11829 dlg.finished(false);
11830 return Err(common::Error::MissingToken(e));
11831 }
11832 },
11833 };
11834 request_value_reader
11835 .seek(std::io::SeekFrom::Start(0))
11836 .unwrap();
11837 let mut req_result = {
11838 let client = &self.hub.client;
11839 dlg.pre_request();
11840 let mut req_builder = hyper::Request::builder()
11841 .method(hyper::Method::POST)
11842 .uri(url.as_str())
11843 .header(USER_AGENT, self.hub._user_agent.clone());
11844
11845 if let Some(token) = token.as_ref() {
11846 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11847 }
11848
11849 let request = req_builder
11850 .header(CONTENT_TYPE, json_mime_type.to_string())
11851 .header(CONTENT_LENGTH, request_size as u64)
11852 .body(common::to_body(
11853 request_value_reader.get_ref().clone().into(),
11854 ));
11855
11856 client.request(request.unwrap()).await
11857 };
11858
11859 match req_result {
11860 Err(err) => {
11861 if let common::Retry::After(d) = dlg.http_error(&err) {
11862 sleep(d).await;
11863 continue;
11864 }
11865 dlg.finished(false);
11866 return Err(common::Error::HttpError(err));
11867 }
11868 Ok(res) => {
11869 let (mut parts, body) = res.into_parts();
11870 let mut body = common::Body::new(body);
11871 if !parts.status.is_success() {
11872 let bytes = common::to_bytes(body).await.unwrap_or_default();
11873 let error = serde_json::from_str(&common::to_string(&bytes));
11874 let response = common::to_response(parts, bytes.into());
11875
11876 if let common::Retry::After(d) =
11877 dlg.http_failure(&response, error.as_ref().ok())
11878 {
11879 sleep(d).await;
11880 continue;
11881 }
11882
11883 dlg.finished(false);
11884
11885 return Err(match error {
11886 Ok(value) => common::Error::BadRequest(value),
11887 _ => common::Error::Failure(response),
11888 });
11889 }
11890 let response = {
11891 let bytes = common::to_bytes(body).await.unwrap_or_default();
11892 let encoded = common::to_string(&bytes);
11893 match serde_json::from_str(&encoded) {
11894 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11895 Err(error) => {
11896 dlg.response_json_decode_error(&encoded, &error);
11897 return Err(common::Error::JsonDecodeError(
11898 encoded.to_string(),
11899 error,
11900 ));
11901 }
11902 }
11903 };
11904
11905 dlg.finished(true);
11906 return Ok(response);
11907 }
11908 }
11909 }
11910 }
11911
11912 ///
11913 /// Sets the *request* property to the given value.
11914 ///
11915 /// Even though the property as already been set when instantiating this call,
11916 /// we provide this method for API completeness.
11917 pub fn request(
11918 mut self,
11919 new_value: RemoveBitbucketServerConnectedRepositoryRequest,
11920 ) -> ProjectLocationBitbucketServerConfigRemoveBitbucketServerConnectedRepositoryCall<'a, C>
11921 {
11922 self._request = new_value;
11923 self
11924 }
11925 /// Required. The name of the `BitbucketServerConfig` to remove a connected repository. Format: `projects/{project}/locations/{location}/bitbucketServerConfigs/{config}`
11926 ///
11927 /// Sets the *config* path property to the given value.
11928 ///
11929 /// Even though the property as already been set when instantiating this call,
11930 /// we provide this method for API completeness.
11931 pub fn config(
11932 mut self,
11933 new_value: &str,
11934 ) -> ProjectLocationBitbucketServerConfigRemoveBitbucketServerConnectedRepositoryCall<'a, C>
11935 {
11936 self._config = new_value.to_string();
11937 self
11938 }
11939 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11940 /// while executing the actual API request.
11941 ///
11942 /// ````text
11943 /// It should be used to handle progress information, and to implement a certain level of resilience.
11944 /// ````
11945 ///
11946 /// Sets the *delegate* property to the given value.
11947 pub fn delegate(
11948 mut self,
11949 new_value: &'a mut dyn common::Delegate,
11950 ) -> ProjectLocationBitbucketServerConfigRemoveBitbucketServerConnectedRepositoryCall<'a, C>
11951 {
11952 self._delegate = Some(new_value);
11953 self
11954 }
11955
11956 /// Set any additional parameter of the query string used in the request.
11957 /// It should be used to set parameters which are not yet available through their own
11958 /// setters.
11959 ///
11960 /// Please note that this method must not be used to set any of the known parameters
11961 /// which have their own setter method. If done anyway, the request will fail.
11962 ///
11963 /// # Additional Parameters
11964 ///
11965 /// * *$.xgafv* (query-string) - V1 error format.
11966 /// * *access_token* (query-string) - OAuth access token.
11967 /// * *alt* (query-string) - Data format for response.
11968 /// * *callback* (query-string) - JSONP
11969 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11970 /// * *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.
11971 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11972 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11973 /// * *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.
11974 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11975 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11976 pub fn param<T>(
11977 mut self,
11978 name: T,
11979 value: T,
11980 ) -> ProjectLocationBitbucketServerConfigRemoveBitbucketServerConnectedRepositoryCall<'a, C>
11981 where
11982 T: AsRef<str>,
11983 {
11984 self._additional_params
11985 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11986 self
11987 }
11988
11989 /// Identifies the authorization scope for the method you are building.
11990 ///
11991 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11992 /// [`Scope::CloudPlatform`].
11993 ///
11994 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11995 /// tokens for more than one scope.
11996 ///
11997 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11998 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11999 /// sufficient, a read-write scope will do as well.
12000 pub fn add_scope<St>(
12001 mut self,
12002 scope: St,
12003 ) -> ProjectLocationBitbucketServerConfigRemoveBitbucketServerConnectedRepositoryCall<'a, C>
12004 where
12005 St: AsRef<str>,
12006 {
12007 self._scopes.insert(String::from(scope.as_ref()));
12008 self
12009 }
12010 /// Identifies the authorization scope(s) for the method you are building.
12011 ///
12012 /// See [`Self::add_scope()`] for details.
12013 pub fn add_scopes<I, St>(
12014 mut self,
12015 scopes: I,
12016 ) -> ProjectLocationBitbucketServerConfigRemoveBitbucketServerConnectedRepositoryCall<'a, C>
12017 where
12018 I: IntoIterator<Item = St>,
12019 St: AsRef<str>,
12020 {
12021 self._scopes
12022 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12023 self
12024 }
12025
12026 /// Removes all scopes, and no default scope will be used either.
12027 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12028 /// for details).
12029 pub fn clear_scopes(
12030 mut self,
12031 ) -> ProjectLocationBitbucketServerConfigRemoveBitbucketServerConnectedRepositoryCall<'a, C>
12032 {
12033 self._scopes.clear();
12034 self
12035 }
12036}
12037
12038/// Approves or rejects a pending build. If approved, the returned long-running operation (LRO) will be analogous to the LRO returned from a CreateBuild call. If rejected, the returned LRO will be immediately done.
12039///
12040/// A builder for the *locations.builds.approve* method supported by a *project* resource.
12041/// It is not used directly, but through a [`ProjectMethods`] instance.
12042///
12043/// # Example
12044///
12045/// Instantiate a resource method builder
12046///
12047/// ```test_harness,no_run
12048/// # extern crate hyper;
12049/// # extern crate hyper_rustls;
12050/// # extern crate google_cloudbuild1 as cloudbuild1;
12051/// use cloudbuild1::api::ApproveBuildRequest;
12052/// # async fn dox() {
12053/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12054///
12055/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12056/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12057/// # .with_native_roots()
12058/// # .unwrap()
12059/// # .https_only()
12060/// # .enable_http2()
12061/// # .build();
12062///
12063/// # let executor = hyper_util::rt::TokioExecutor::new();
12064/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12065/// # secret,
12066/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12067/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12068/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12069/// # ),
12070/// # ).build().await.unwrap();
12071///
12072/// # let client = hyper_util::client::legacy::Client::builder(
12073/// # hyper_util::rt::TokioExecutor::new()
12074/// # )
12075/// # .build(
12076/// # hyper_rustls::HttpsConnectorBuilder::new()
12077/// # .with_native_roots()
12078/// # .unwrap()
12079/// # .https_or_http()
12080/// # .enable_http2()
12081/// # .build()
12082/// # );
12083/// # let mut hub = CloudBuild::new(client, auth);
12084/// // As the method needs a request, you would usually fill it with the desired information
12085/// // into the respective structure. Some of the parts shown here might not be applicable !
12086/// // Values shown here are possibly random and not representative !
12087/// let mut req = ApproveBuildRequest::default();
12088///
12089/// // You can configure optional parameters by calling the respective setters at will, and
12090/// // execute the final call using `doit()`.
12091/// // Values shown here are possibly random and not representative !
12092/// let result = hub.projects().locations_builds_approve(req, "name")
12093/// .doit().await;
12094/// # }
12095/// ```
12096pub struct ProjectLocationBuildApproveCall<'a, C>
12097where
12098 C: 'a,
12099{
12100 hub: &'a CloudBuild<C>,
12101 _request: ApproveBuildRequest,
12102 _name: String,
12103 _delegate: Option<&'a mut dyn common::Delegate>,
12104 _additional_params: HashMap<String, String>,
12105 _scopes: BTreeSet<String>,
12106}
12107
12108impl<'a, C> common::CallBuilder for ProjectLocationBuildApproveCall<'a, C> {}
12109
12110impl<'a, C> ProjectLocationBuildApproveCall<'a, C>
12111where
12112 C: common::Connector,
12113{
12114 /// Perform the operation you have build so far.
12115 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
12116 use std::borrow::Cow;
12117 use std::io::{Read, Seek};
12118
12119 use common::{url::Params, ToParts};
12120 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12121
12122 let mut dd = common::DefaultDelegate;
12123 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12124 dlg.begin(common::MethodInfo {
12125 id: "cloudbuild.projects.locations.builds.approve",
12126 http_method: hyper::Method::POST,
12127 });
12128
12129 for &field in ["alt", "name"].iter() {
12130 if self._additional_params.contains_key(field) {
12131 dlg.finished(false);
12132 return Err(common::Error::FieldClash(field));
12133 }
12134 }
12135
12136 let mut params = Params::with_capacity(4 + self._additional_params.len());
12137 params.push("name", self._name);
12138
12139 params.extend(self._additional_params.iter());
12140
12141 params.push("alt", "json");
12142 let mut url = self.hub._base_url.clone() + "v1/{+name}:approve";
12143 if self._scopes.is_empty() {
12144 self._scopes
12145 .insert(Scope::CloudPlatform.as_ref().to_string());
12146 }
12147
12148 #[allow(clippy::single_element_loop)]
12149 for &(find_this, param_name) in [("{+name}", "name")].iter() {
12150 url = params.uri_replacement(url, param_name, find_this, true);
12151 }
12152 {
12153 let to_remove = ["name"];
12154 params.remove_params(&to_remove);
12155 }
12156
12157 let url = params.parse_with_url(&url);
12158
12159 let mut json_mime_type = mime::APPLICATION_JSON;
12160 let mut request_value_reader = {
12161 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12162 common::remove_json_null_values(&mut value);
12163 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12164 serde_json::to_writer(&mut dst, &value).unwrap();
12165 dst
12166 };
12167 let request_size = request_value_reader
12168 .seek(std::io::SeekFrom::End(0))
12169 .unwrap();
12170 request_value_reader
12171 .seek(std::io::SeekFrom::Start(0))
12172 .unwrap();
12173
12174 loop {
12175 let token = match self
12176 .hub
12177 .auth
12178 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12179 .await
12180 {
12181 Ok(token) => token,
12182 Err(e) => match dlg.token(e) {
12183 Ok(token) => token,
12184 Err(e) => {
12185 dlg.finished(false);
12186 return Err(common::Error::MissingToken(e));
12187 }
12188 },
12189 };
12190 request_value_reader
12191 .seek(std::io::SeekFrom::Start(0))
12192 .unwrap();
12193 let mut req_result = {
12194 let client = &self.hub.client;
12195 dlg.pre_request();
12196 let mut req_builder = hyper::Request::builder()
12197 .method(hyper::Method::POST)
12198 .uri(url.as_str())
12199 .header(USER_AGENT, self.hub._user_agent.clone());
12200
12201 if let Some(token) = token.as_ref() {
12202 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12203 }
12204
12205 let request = req_builder
12206 .header(CONTENT_TYPE, json_mime_type.to_string())
12207 .header(CONTENT_LENGTH, request_size as u64)
12208 .body(common::to_body(
12209 request_value_reader.get_ref().clone().into(),
12210 ));
12211
12212 client.request(request.unwrap()).await
12213 };
12214
12215 match req_result {
12216 Err(err) => {
12217 if let common::Retry::After(d) = dlg.http_error(&err) {
12218 sleep(d).await;
12219 continue;
12220 }
12221 dlg.finished(false);
12222 return Err(common::Error::HttpError(err));
12223 }
12224 Ok(res) => {
12225 let (mut parts, body) = res.into_parts();
12226 let mut body = common::Body::new(body);
12227 if !parts.status.is_success() {
12228 let bytes = common::to_bytes(body).await.unwrap_or_default();
12229 let error = serde_json::from_str(&common::to_string(&bytes));
12230 let response = common::to_response(parts, bytes.into());
12231
12232 if let common::Retry::After(d) =
12233 dlg.http_failure(&response, error.as_ref().ok())
12234 {
12235 sleep(d).await;
12236 continue;
12237 }
12238
12239 dlg.finished(false);
12240
12241 return Err(match error {
12242 Ok(value) => common::Error::BadRequest(value),
12243 _ => common::Error::Failure(response),
12244 });
12245 }
12246 let response = {
12247 let bytes = common::to_bytes(body).await.unwrap_or_default();
12248 let encoded = common::to_string(&bytes);
12249 match serde_json::from_str(&encoded) {
12250 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12251 Err(error) => {
12252 dlg.response_json_decode_error(&encoded, &error);
12253 return Err(common::Error::JsonDecodeError(
12254 encoded.to_string(),
12255 error,
12256 ));
12257 }
12258 }
12259 };
12260
12261 dlg.finished(true);
12262 return Ok(response);
12263 }
12264 }
12265 }
12266 }
12267
12268 ///
12269 /// Sets the *request* property to the given value.
12270 ///
12271 /// Even though the property as already been set when instantiating this call,
12272 /// we provide this method for API completeness.
12273 pub fn request(
12274 mut self,
12275 new_value: ApproveBuildRequest,
12276 ) -> ProjectLocationBuildApproveCall<'a, C> {
12277 self._request = new_value;
12278 self
12279 }
12280 /// Required. Name of the target build. For example: "projects/{$project_id}/builds/{$build_id}"
12281 ///
12282 /// Sets the *name* path property to the given value.
12283 ///
12284 /// Even though the property as already been set when instantiating this call,
12285 /// we provide this method for API completeness.
12286 pub fn name(mut self, new_value: &str) -> ProjectLocationBuildApproveCall<'a, C> {
12287 self._name = new_value.to_string();
12288 self
12289 }
12290 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12291 /// while executing the actual API request.
12292 ///
12293 /// ````text
12294 /// It should be used to handle progress information, and to implement a certain level of resilience.
12295 /// ````
12296 ///
12297 /// Sets the *delegate* property to the given value.
12298 pub fn delegate(
12299 mut self,
12300 new_value: &'a mut dyn common::Delegate,
12301 ) -> ProjectLocationBuildApproveCall<'a, C> {
12302 self._delegate = Some(new_value);
12303 self
12304 }
12305
12306 /// Set any additional parameter of the query string used in the request.
12307 /// It should be used to set parameters which are not yet available through their own
12308 /// setters.
12309 ///
12310 /// Please note that this method must not be used to set any of the known parameters
12311 /// which have their own setter method. If done anyway, the request will fail.
12312 ///
12313 /// # Additional Parameters
12314 ///
12315 /// * *$.xgafv* (query-string) - V1 error format.
12316 /// * *access_token* (query-string) - OAuth access token.
12317 /// * *alt* (query-string) - Data format for response.
12318 /// * *callback* (query-string) - JSONP
12319 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12320 /// * *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.
12321 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12322 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12323 /// * *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.
12324 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12325 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12326 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationBuildApproveCall<'a, C>
12327 where
12328 T: AsRef<str>,
12329 {
12330 self._additional_params
12331 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12332 self
12333 }
12334
12335 /// Identifies the authorization scope for the method you are building.
12336 ///
12337 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12338 /// [`Scope::CloudPlatform`].
12339 ///
12340 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12341 /// tokens for more than one scope.
12342 ///
12343 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12344 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12345 /// sufficient, a read-write scope will do as well.
12346 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationBuildApproveCall<'a, C>
12347 where
12348 St: AsRef<str>,
12349 {
12350 self._scopes.insert(String::from(scope.as_ref()));
12351 self
12352 }
12353 /// Identifies the authorization scope(s) for the method you are building.
12354 ///
12355 /// See [`Self::add_scope()`] for details.
12356 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationBuildApproveCall<'a, C>
12357 where
12358 I: IntoIterator<Item = St>,
12359 St: AsRef<str>,
12360 {
12361 self._scopes
12362 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12363 self
12364 }
12365
12366 /// Removes all scopes, and no default scope will be used either.
12367 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12368 /// for details).
12369 pub fn clear_scopes(mut self) -> ProjectLocationBuildApproveCall<'a, C> {
12370 self._scopes.clear();
12371 self
12372 }
12373}
12374
12375/// Cancels a build in progress.
12376///
12377/// A builder for the *locations.builds.cancel* method supported by a *project* resource.
12378/// It is not used directly, but through a [`ProjectMethods`] instance.
12379///
12380/// # Example
12381///
12382/// Instantiate a resource method builder
12383///
12384/// ```test_harness,no_run
12385/// # extern crate hyper;
12386/// # extern crate hyper_rustls;
12387/// # extern crate google_cloudbuild1 as cloudbuild1;
12388/// use cloudbuild1::api::CancelBuildRequest;
12389/// # async fn dox() {
12390/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12391///
12392/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12393/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12394/// # .with_native_roots()
12395/// # .unwrap()
12396/// # .https_only()
12397/// # .enable_http2()
12398/// # .build();
12399///
12400/// # let executor = hyper_util::rt::TokioExecutor::new();
12401/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12402/// # secret,
12403/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12404/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12405/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12406/// # ),
12407/// # ).build().await.unwrap();
12408///
12409/// # let client = hyper_util::client::legacy::Client::builder(
12410/// # hyper_util::rt::TokioExecutor::new()
12411/// # )
12412/// # .build(
12413/// # hyper_rustls::HttpsConnectorBuilder::new()
12414/// # .with_native_roots()
12415/// # .unwrap()
12416/// # .https_or_http()
12417/// # .enable_http2()
12418/// # .build()
12419/// # );
12420/// # let mut hub = CloudBuild::new(client, auth);
12421/// // As the method needs a request, you would usually fill it with the desired information
12422/// // into the respective structure. Some of the parts shown here might not be applicable !
12423/// // Values shown here are possibly random and not representative !
12424/// let mut req = CancelBuildRequest::default();
12425///
12426/// // You can configure optional parameters by calling the respective setters at will, and
12427/// // execute the final call using `doit()`.
12428/// // Values shown here are possibly random and not representative !
12429/// let result = hub.projects().locations_builds_cancel(req, "name")
12430/// .doit().await;
12431/// # }
12432/// ```
12433pub struct ProjectLocationBuildCancelCall<'a, C>
12434where
12435 C: 'a,
12436{
12437 hub: &'a CloudBuild<C>,
12438 _request: CancelBuildRequest,
12439 _name: String,
12440 _delegate: Option<&'a mut dyn common::Delegate>,
12441 _additional_params: HashMap<String, String>,
12442 _scopes: BTreeSet<String>,
12443}
12444
12445impl<'a, C> common::CallBuilder for ProjectLocationBuildCancelCall<'a, C> {}
12446
12447impl<'a, C> ProjectLocationBuildCancelCall<'a, C>
12448where
12449 C: common::Connector,
12450{
12451 /// Perform the operation you have build so far.
12452 pub async fn doit(mut self) -> common::Result<(common::Response, Build)> {
12453 use std::borrow::Cow;
12454 use std::io::{Read, Seek};
12455
12456 use common::{url::Params, ToParts};
12457 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12458
12459 let mut dd = common::DefaultDelegate;
12460 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12461 dlg.begin(common::MethodInfo {
12462 id: "cloudbuild.projects.locations.builds.cancel",
12463 http_method: hyper::Method::POST,
12464 });
12465
12466 for &field in ["alt", "name"].iter() {
12467 if self._additional_params.contains_key(field) {
12468 dlg.finished(false);
12469 return Err(common::Error::FieldClash(field));
12470 }
12471 }
12472
12473 let mut params = Params::with_capacity(4 + self._additional_params.len());
12474 params.push("name", self._name);
12475
12476 params.extend(self._additional_params.iter());
12477
12478 params.push("alt", "json");
12479 let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
12480 if self._scopes.is_empty() {
12481 self._scopes
12482 .insert(Scope::CloudPlatform.as_ref().to_string());
12483 }
12484
12485 #[allow(clippy::single_element_loop)]
12486 for &(find_this, param_name) in [("{+name}", "name")].iter() {
12487 url = params.uri_replacement(url, param_name, find_this, true);
12488 }
12489 {
12490 let to_remove = ["name"];
12491 params.remove_params(&to_remove);
12492 }
12493
12494 let url = params.parse_with_url(&url);
12495
12496 let mut json_mime_type = mime::APPLICATION_JSON;
12497 let mut request_value_reader = {
12498 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12499 common::remove_json_null_values(&mut value);
12500 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12501 serde_json::to_writer(&mut dst, &value).unwrap();
12502 dst
12503 };
12504 let request_size = request_value_reader
12505 .seek(std::io::SeekFrom::End(0))
12506 .unwrap();
12507 request_value_reader
12508 .seek(std::io::SeekFrom::Start(0))
12509 .unwrap();
12510
12511 loop {
12512 let token = match self
12513 .hub
12514 .auth
12515 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12516 .await
12517 {
12518 Ok(token) => token,
12519 Err(e) => match dlg.token(e) {
12520 Ok(token) => token,
12521 Err(e) => {
12522 dlg.finished(false);
12523 return Err(common::Error::MissingToken(e));
12524 }
12525 },
12526 };
12527 request_value_reader
12528 .seek(std::io::SeekFrom::Start(0))
12529 .unwrap();
12530 let mut req_result = {
12531 let client = &self.hub.client;
12532 dlg.pre_request();
12533 let mut req_builder = hyper::Request::builder()
12534 .method(hyper::Method::POST)
12535 .uri(url.as_str())
12536 .header(USER_AGENT, self.hub._user_agent.clone());
12537
12538 if let Some(token) = token.as_ref() {
12539 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12540 }
12541
12542 let request = req_builder
12543 .header(CONTENT_TYPE, json_mime_type.to_string())
12544 .header(CONTENT_LENGTH, request_size as u64)
12545 .body(common::to_body(
12546 request_value_reader.get_ref().clone().into(),
12547 ));
12548
12549 client.request(request.unwrap()).await
12550 };
12551
12552 match req_result {
12553 Err(err) => {
12554 if let common::Retry::After(d) = dlg.http_error(&err) {
12555 sleep(d).await;
12556 continue;
12557 }
12558 dlg.finished(false);
12559 return Err(common::Error::HttpError(err));
12560 }
12561 Ok(res) => {
12562 let (mut parts, body) = res.into_parts();
12563 let mut body = common::Body::new(body);
12564 if !parts.status.is_success() {
12565 let bytes = common::to_bytes(body).await.unwrap_or_default();
12566 let error = serde_json::from_str(&common::to_string(&bytes));
12567 let response = common::to_response(parts, bytes.into());
12568
12569 if let common::Retry::After(d) =
12570 dlg.http_failure(&response, error.as_ref().ok())
12571 {
12572 sleep(d).await;
12573 continue;
12574 }
12575
12576 dlg.finished(false);
12577
12578 return Err(match error {
12579 Ok(value) => common::Error::BadRequest(value),
12580 _ => common::Error::Failure(response),
12581 });
12582 }
12583 let response = {
12584 let bytes = common::to_bytes(body).await.unwrap_or_default();
12585 let encoded = common::to_string(&bytes);
12586 match serde_json::from_str(&encoded) {
12587 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12588 Err(error) => {
12589 dlg.response_json_decode_error(&encoded, &error);
12590 return Err(common::Error::JsonDecodeError(
12591 encoded.to_string(),
12592 error,
12593 ));
12594 }
12595 }
12596 };
12597
12598 dlg.finished(true);
12599 return Ok(response);
12600 }
12601 }
12602 }
12603 }
12604
12605 ///
12606 /// Sets the *request* property to the given value.
12607 ///
12608 /// Even though the property as already been set when instantiating this call,
12609 /// we provide this method for API completeness.
12610 pub fn request(
12611 mut self,
12612 new_value: CancelBuildRequest,
12613 ) -> ProjectLocationBuildCancelCall<'a, C> {
12614 self._request = new_value;
12615 self
12616 }
12617 /// The name of the `Build` to cancel. Format: `projects/{project}/locations/{location}/builds/{build}`
12618 ///
12619 /// Sets the *name* path property to the given value.
12620 ///
12621 /// Even though the property as already been set when instantiating this call,
12622 /// we provide this method for API completeness.
12623 pub fn name(mut self, new_value: &str) -> ProjectLocationBuildCancelCall<'a, C> {
12624 self._name = new_value.to_string();
12625 self
12626 }
12627 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12628 /// while executing the actual API request.
12629 ///
12630 /// ````text
12631 /// It should be used to handle progress information, and to implement a certain level of resilience.
12632 /// ````
12633 ///
12634 /// Sets the *delegate* property to the given value.
12635 pub fn delegate(
12636 mut self,
12637 new_value: &'a mut dyn common::Delegate,
12638 ) -> ProjectLocationBuildCancelCall<'a, C> {
12639 self._delegate = Some(new_value);
12640 self
12641 }
12642
12643 /// Set any additional parameter of the query string used in the request.
12644 /// It should be used to set parameters which are not yet available through their own
12645 /// setters.
12646 ///
12647 /// Please note that this method must not be used to set any of the known parameters
12648 /// which have their own setter method. If done anyway, the request will fail.
12649 ///
12650 /// # Additional Parameters
12651 ///
12652 /// * *$.xgafv* (query-string) - V1 error format.
12653 /// * *access_token* (query-string) - OAuth access token.
12654 /// * *alt* (query-string) - Data format for response.
12655 /// * *callback* (query-string) - JSONP
12656 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12657 /// * *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.
12658 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12659 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12660 /// * *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.
12661 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12662 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12663 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationBuildCancelCall<'a, C>
12664 where
12665 T: AsRef<str>,
12666 {
12667 self._additional_params
12668 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12669 self
12670 }
12671
12672 /// Identifies the authorization scope for the method you are building.
12673 ///
12674 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12675 /// [`Scope::CloudPlatform`].
12676 ///
12677 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12678 /// tokens for more than one scope.
12679 ///
12680 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12681 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12682 /// sufficient, a read-write scope will do as well.
12683 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationBuildCancelCall<'a, C>
12684 where
12685 St: AsRef<str>,
12686 {
12687 self._scopes.insert(String::from(scope.as_ref()));
12688 self
12689 }
12690 /// Identifies the authorization scope(s) for the method you are building.
12691 ///
12692 /// See [`Self::add_scope()`] for details.
12693 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationBuildCancelCall<'a, C>
12694 where
12695 I: IntoIterator<Item = St>,
12696 St: AsRef<str>,
12697 {
12698 self._scopes
12699 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12700 self
12701 }
12702
12703 /// Removes all scopes, and no default scope will be used either.
12704 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12705 /// for details).
12706 pub fn clear_scopes(mut self) -> ProjectLocationBuildCancelCall<'a, C> {
12707 self._scopes.clear();
12708 self
12709 }
12710}
12711
12712/// 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`).
12713///
12714/// A builder for the *locations.builds.create* method supported by a *project* resource.
12715/// It is not used directly, but through a [`ProjectMethods`] instance.
12716///
12717/// # Example
12718///
12719/// Instantiate a resource method builder
12720///
12721/// ```test_harness,no_run
12722/// # extern crate hyper;
12723/// # extern crate hyper_rustls;
12724/// # extern crate google_cloudbuild1 as cloudbuild1;
12725/// use cloudbuild1::api::Build;
12726/// # async fn dox() {
12727/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12728///
12729/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12730/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12731/// # .with_native_roots()
12732/// # .unwrap()
12733/// # .https_only()
12734/// # .enable_http2()
12735/// # .build();
12736///
12737/// # let executor = hyper_util::rt::TokioExecutor::new();
12738/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12739/// # secret,
12740/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12741/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12742/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12743/// # ),
12744/// # ).build().await.unwrap();
12745///
12746/// # let client = hyper_util::client::legacy::Client::builder(
12747/// # hyper_util::rt::TokioExecutor::new()
12748/// # )
12749/// # .build(
12750/// # hyper_rustls::HttpsConnectorBuilder::new()
12751/// # .with_native_roots()
12752/// # .unwrap()
12753/// # .https_or_http()
12754/// # .enable_http2()
12755/// # .build()
12756/// # );
12757/// # let mut hub = CloudBuild::new(client, auth);
12758/// // As the method needs a request, you would usually fill it with the desired information
12759/// // into the respective structure. Some of the parts shown here might not be applicable !
12760/// // Values shown here are possibly random and not representative !
12761/// let mut req = Build::default();
12762///
12763/// // You can configure optional parameters by calling the respective setters at will, and
12764/// // execute the final call using `doit()`.
12765/// // Values shown here are possibly random and not representative !
12766/// let result = hub.projects().locations_builds_create(req, "parent")
12767/// .project_id("diam")
12768/// .doit().await;
12769/// # }
12770/// ```
12771pub struct ProjectLocationBuildCreateCall<'a, C>
12772where
12773 C: 'a,
12774{
12775 hub: &'a CloudBuild<C>,
12776 _request: Build,
12777 _parent: String,
12778 _project_id: Option<String>,
12779 _delegate: Option<&'a mut dyn common::Delegate>,
12780 _additional_params: HashMap<String, String>,
12781 _scopes: BTreeSet<String>,
12782}
12783
12784impl<'a, C> common::CallBuilder for ProjectLocationBuildCreateCall<'a, C> {}
12785
12786impl<'a, C> ProjectLocationBuildCreateCall<'a, C>
12787where
12788 C: common::Connector,
12789{
12790 /// Perform the operation you have build so far.
12791 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
12792 use std::borrow::Cow;
12793 use std::io::{Read, Seek};
12794
12795 use common::{url::Params, ToParts};
12796 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12797
12798 let mut dd = common::DefaultDelegate;
12799 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12800 dlg.begin(common::MethodInfo {
12801 id: "cloudbuild.projects.locations.builds.create",
12802 http_method: hyper::Method::POST,
12803 });
12804
12805 for &field in ["alt", "parent", "projectId"].iter() {
12806 if self._additional_params.contains_key(field) {
12807 dlg.finished(false);
12808 return Err(common::Error::FieldClash(field));
12809 }
12810 }
12811
12812 let mut params = Params::with_capacity(5 + self._additional_params.len());
12813 params.push("parent", self._parent);
12814 if let Some(value) = self._project_id.as_ref() {
12815 params.push("projectId", value);
12816 }
12817
12818 params.extend(self._additional_params.iter());
12819
12820 params.push("alt", "json");
12821 let mut url = self.hub._base_url.clone() + "v1/{+parent}/builds";
12822 if self._scopes.is_empty() {
12823 self._scopes
12824 .insert(Scope::CloudPlatform.as_ref().to_string());
12825 }
12826
12827 #[allow(clippy::single_element_loop)]
12828 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
12829 url = params.uri_replacement(url, param_name, find_this, true);
12830 }
12831 {
12832 let to_remove = ["parent"];
12833 params.remove_params(&to_remove);
12834 }
12835
12836 let url = params.parse_with_url(&url);
12837
12838 let mut json_mime_type = mime::APPLICATION_JSON;
12839 let mut request_value_reader = {
12840 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12841 common::remove_json_null_values(&mut value);
12842 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12843 serde_json::to_writer(&mut dst, &value).unwrap();
12844 dst
12845 };
12846 let request_size = request_value_reader
12847 .seek(std::io::SeekFrom::End(0))
12848 .unwrap();
12849 request_value_reader
12850 .seek(std::io::SeekFrom::Start(0))
12851 .unwrap();
12852
12853 loop {
12854 let token = match self
12855 .hub
12856 .auth
12857 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12858 .await
12859 {
12860 Ok(token) => token,
12861 Err(e) => match dlg.token(e) {
12862 Ok(token) => token,
12863 Err(e) => {
12864 dlg.finished(false);
12865 return Err(common::Error::MissingToken(e));
12866 }
12867 },
12868 };
12869 request_value_reader
12870 .seek(std::io::SeekFrom::Start(0))
12871 .unwrap();
12872 let mut req_result = {
12873 let client = &self.hub.client;
12874 dlg.pre_request();
12875 let mut req_builder = hyper::Request::builder()
12876 .method(hyper::Method::POST)
12877 .uri(url.as_str())
12878 .header(USER_AGENT, self.hub._user_agent.clone());
12879
12880 if let Some(token) = token.as_ref() {
12881 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12882 }
12883
12884 let request = req_builder
12885 .header(CONTENT_TYPE, json_mime_type.to_string())
12886 .header(CONTENT_LENGTH, request_size as u64)
12887 .body(common::to_body(
12888 request_value_reader.get_ref().clone().into(),
12889 ));
12890
12891 client.request(request.unwrap()).await
12892 };
12893
12894 match req_result {
12895 Err(err) => {
12896 if let common::Retry::After(d) = dlg.http_error(&err) {
12897 sleep(d).await;
12898 continue;
12899 }
12900 dlg.finished(false);
12901 return Err(common::Error::HttpError(err));
12902 }
12903 Ok(res) => {
12904 let (mut parts, body) = res.into_parts();
12905 let mut body = common::Body::new(body);
12906 if !parts.status.is_success() {
12907 let bytes = common::to_bytes(body).await.unwrap_or_default();
12908 let error = serde_json::from_str(&common::to_string(&bytes));
12909 let response = common::to_response(parts, bytes.into());
12910
12911 if let common::Retry::After(d) =
12912 dlg.http_failure(&response, error.as_ref().ok())
12913 {
12914 sleep(d).await;
12915 continue;
12916 }
12917
12918 dlg.finished(false);
12919
12920 return Err(match error {
12921 Ok(value) => common::Error::BadRequest(value),
12922 _ => common::Error::Failure(response),
12923 });
12924 }
12925 let response = {
12926 let bytes = common::to_bytes(body).await.unwrap_or_default();
12927 let encoded = common::to_string(&bytes);
12928 match serde_json::from_str(&encoded) {
12929 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12930 Err(error) => {
12931 dlg.response_json_decode_error(&encoded, &error);
12932 return Err(common::Error::JsonDecodeError(
12933 encoded.to_string(),
12934 error,
12935 ));
12936 }
12937 }
12938 };
12939
12940 dlg.finished(true);
12941 return Ok(response);
12942 }
12943 }
12944 }
12945 }
12946
12947 ///
12948 /// Sets the *request* property to the given value.
12949 ///
12950 /// Even though the property as already been set when instantiating this call,
12951 /// we provide this method for API completeness.
12952 pub fn request(mut self, new_value: Build) -> ProjectLocationBuildCreateCall<'a, C> {
12953 self._request = new_value;
12954 self
12955 }
12956 /// The parent resource where this build will be created. Format: `projects/{project}/locations/{location}`
12957 ///
12958 /// Sets the *parent* path property to the given value.
12959 ///
12960 /// Even though the property as already been set when instantiating this call,
12961 /// we provide this method for API completeness.
12962 pub fn parent(mut self, new_value: &str) -> ProjectLocationBuildCreateCall<'a, C> {
12963 self._parent = new_value.to_string();
12964 self
12965 }
12966 /// Required. ID of the project.
12967 ///
12968 /// Sets the *project id* query property to the given value.
12969 pub fn project_id(mut self, new_value: &str) -> ProjectLocationBuildCreateCall<'a, C> {
12970 self._project_id = Some(new_value.to_string());
12971 self
12972 }
12973 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12974 /// while executing the actual API request.
12975 ///
12976 /// ````text
12977 /// It should be used to handle progress information, and to implement a certain level of resilience.
12978 /// ````
12979 ///
12980 /// Sets the *delegate* property to the given value.
12981 pub fn delegate(
12982 mut self,
12983 new_value: &'a mut dyn common::Delegate,
12984 ) -> ProjectLocationBuildCreateCall<'a, C> {
12985 self._delegate = Some(new_value);
12986 self
12987 }
12988
12989 /// Set any additional parameter of the query string used in the request.
12990 /// It should be used to set parameters which are not yet available through their own
12991 /// setters.
12992 ///
12993 /// Please note that this method must not be used to set any of the known parameters
12994 /// which have their own setter method. If done anyway, the request will fail.
12995 ///
12996 /// # Additional Parameters
12997 ///
12998 /// * *$.xgafv* (query-string) - V1 error format.
12999 /// * *access_token* (query-string) - OAuth access token.
13000 /// * *alt* (query-string) - Data format for response.
13001 /// * *callback* (query-string) - JSONP
13002 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13003 /// * *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.
13004 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13005 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13006 /// * *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.
13007 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13008 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13009 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationBuildCreateCall<'a, C>
13010 where
13011 T: AsRef<str>,
13012 {
13013 self._additional_params
13014 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13015 self
13016 }
13017
13018 /// Identifies the authorization scope for the method you are building.
13019 ///
13020 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13021 /// [`Scope::CloudPlatform`].
13022 ///
13023 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13024 /// tokens for more than one scope.
13025 ///
13026 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13027 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13028 /// sufficient, a read-write scope will do as well.
13029 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationBuildCreateCall<'a, C>
13030 where
13031 St: AsRef<str>,
13032 {
13033 self._scopes.insert(String::from(scope.as_ref()));
13034 self
13035 }
13036 /// Identifies the authorization scope(s) for the method you are building.
13037 ///
13038 /// See [`Self::add_scope()`] for details.
13039 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationBuildCreateCall<'a, C>
13040 where
13041 I: IntoIterator<Item = St>,
13042 St: AsRef<str>,
13043 {
13044 self._scopes
13045 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13046 self
13047 }
13048
13049 /// Removes all scopes, and no default scope will be used either.
13050 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13051 /// for details).
13052 pub fn clear_scopes(mut self) -> ProjectLocationBuildCreateCall<'a, C> {
13053 self._scopes.clear();
13054 self
13055 }
13056}
13057
13058/// Returns information about a previously requested build. The `Build` that is returned includes its status (such as `SUCCESS`, `FAILURE`, or `WORKING`), and timing information.
13059///
13060/// A builder for the *locations.builds.get* method supported by a *project* resource.
13061/// It is not used directly, but through a [`ProjectMethods`] instance.
13062///
13063/// # Example
13064///
13065/// Instantiate a resource method builder
13066///
13067/// ```test_harness,no_run
13068/// # extern crate hyper;
13069/// # extern crate hyper_rustls;
13070/// # extern crate google_cloudbuild1 as cloudbuild1;
13071/// # async fn dox() {
13072/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13073///
13074/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13075/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13076/// # .with_native_roots()
13077/// # .unwrap()
13078/// # .https_only()
13079/// # .enable_http2()
13080/// # .build();
13081///
13082/// # let executor = hyper_util::rt::TokioExecutor::new();
13083/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13084/// # secret,
13085/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13086/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13087/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13088/// # ),
13089/// # ).build().await.unwrap();
13090///
13091/// # let client = hyper_util::client::legacy::Client::builder(
13092/// # hyper_util::rt::TokioExecutor::new()
13093/// # )
13094/// # .build(
13095/// # hyper_rustls::HttpsConnectorBuilder::new()
13096/// # .with_native_roots()
13097/// # .unwrap()
13098/// # .https_or_http()
13099/// # .enable_http2()
13100/// # .build()
13101/// # );
13102/// # let mut hub = CloudBuild::new(client, auth);
13103/// // You can configure optional parameters by calling the respective setters at will, and
13104/// // execute the final call using `doit()`.
13105/// // Values shown here are possibly random and not representative !
13106/// let result = hub.projects().locations_builds_get("name")
13107/// .project_id("et")
13108/// .id("et")
13109/// .doit().await;
13110/// # }
13111/// ```
13112pub struct ProjectLocationBuildGetCall<'a, C>
13113where
13114 C: 'a,
13115{
13116 hub: &'a CloudBuild<C>,
13117 _name: String,
13118 _project_id: Option<String>,
13119 _id: Option<String>,
13120 _delegate: Option<&'a mut dyn common::Delegate>,
13121 _additional_params: HashMap<String, String>,
13122 _scopes: BTreeSet<String>,
13123}
13124
13125impl<'a, C> common::CallBuilder for ProjectLocationBuildGetCall<'a, C> {}
13126
13127impl<'a, C> ProjectLocationBuildGetCall<'a, C>
13128where
13129 C: common::Connector,
13130{
13131 /// Perform the operation you have build so far.
13132 pub async fn doit(mut self) -> common::Result<(common::Response, Build)> {
13133 use std::borrow::Cow;
13134 use std::io::{Read, Seek};
13135
13136 use common::{url::Params, ToParts};
13137 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13138
13139 let mut dd = common::DefaultDelegate;
13140 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13141 dlg.begin(common::MethodInfo {
13142 id: "cloudbuild.projects.locations.builds.get",
13143 http_method: hyper::Method::GET,
13144 });
13145
13146 for &field in ["alt", "name", "projectId", "id"].iter() {
13147 if self._additional_params.contains_key(field) {
13148 dlg.finished(false);
13149 return Err(common::Error::FieldClash(field));
13150 }
13151 }
13152
13153 let mut params = Params::with_capacity(5 + self._additional_params.len());
13154 params.push("name", self._name);
13155 if let Some(value) = self._project_id.as_ref() {
13156 params.push("projectId", value);
13157 }
13158 if let Some(value) = self._id.as_ref() {
13159 params.push("id", value);
13160 }
13161
13162 params.extend(self._additional_params.iter());
13163
13164 params.push("alt", "json");
13165 let mut url = self.hub._base_url.clone() + "v1/{+name}";
13166 if self._scopes.is_empty() {
13167 self._scopes
13168 .insert(Scope::CloudPlatform.as_ref().to_string());
13169 }
13170
13171 #[allow(clippy::single_element_loop)]
13172 for &(find_this, param_name) in [("{+name}", "name")].iter() {
13173 url = params.uri_replacement(url, param_name, find_this, true);
13174 }
13175 {
13176 let to_remove = ["name"];
13177 params.remove_params(&to_remove);
13178 }
13179
13180 let url = params.parse_with_url(&url);
13181
13182 loop {
13183 let token = match self
13184 .hub
13185 .auth
13186 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13187 .await
13188 {
13189 Ok(token) => token,
13190 Err(e) => match dlg.token(e) {
13191 Ok(token) => token,
13192 Err(e) => {
13193 dlg.finished(false);
13194 return Err(common::Error::MissingToken(e));
13195 }
13196 },
13197 };
13198 let mut req_result = {
13199 let client = &self.hub.client;
13200 dlg.pre_request();
13201 let mut req_builder = hyper::Request::builder()
13202 .method(hyper::Method::GET)
13203 .uri(url.as_str())
13204 .header(USER_AGENT, self.hub._user_agent.clone());
13205
13206 if let Some(token) = token.as_ref() {
13207 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13208 }
13209
13210 let request = req_builder
13211 .header(CONTENT_LENGTH, 0_u64)
13212 .body(common::to_body::<String>(None));
13213
13214 client.request(request.unwrap()).await
13215 };
13216
13217 match req_result {
13218 Err(err) => {
13219 if let common::Retry::After(d) = dlg.http_error(&err) {
13220 sleep(d).await;
13221 continue;
13222 }
13223 dlg.finished(false);
13224 return Err(common::Error::HttpError(err));
13225 }
13226 Ok(res) => {
13227 let (mut parts, body) = res.into_parts();
13228 let mut body = common::Body::new(body);
13229 if !parts.status.is_success() {
13230 let bytes = common::to_bytes(body).await.unwrap_or_default();
13231 let error = serde_json::from_str(&common::to_string(&bytes));
13232 let response = common::to_response(parts, bytes.into());
13233
13234 if let common::Retry::After(d) =
13235 dlg.http_failure(&response, error.as_ref().ok())
13236 {
13237 sleep(d).await;
13238 continue;
13239 }
13240
13241 dlg.finished(false);
13242
13243 return Err(match error {
13244 Ok(value) => common::Error::BadRequest(value),
13245 _ => common::Error::Failure(response),
13246 });
13247 }
13248 let response = {
13249 let bytes = common::to_bytes(body).await.unwrap_or_default();
13250 let encoded = common::to_string(&bytes);
13251 match serde_json::from_str(&encoded) {
13252 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13253 Err(error) => {
13254 dlg.response_json_decode_error(&encoded, &error);
13255 return Err(common::Error::JsonDecodeError(
13256 encoded.to_string(),
13257 error,
13258 ));
13259 }
13260 }
13261 };
13262
13263 dlg.finished(true);
13264 return Ok(response);
13265 }
13266 }
13267 }
13268 }
13269
13270 /// The name of the `Build` to retrieve. Format: `projects/{project}/locations/{location}/builds/{build}`
13271 ///
13272 /// Sets the *name* path property to the given value.
13273 ///
13274 /// Even though the property as already been set when instantiating this call,
13275 /// we provide this method for API completeness.
13276 pub fn name(mut self, new_value: &str) -> ProjectLocationBuildGetCall<'a, C> {
13277 self._name = new_value.to_string();
13278 self
13279 }
13280 /// Required. ID of the project.
13281 ///
13282 /// Sets the *project id* query property to the given value.
13283 pub fn project_id(mut self, new_value: &str) -> ProjectLocationBuildGetCall<'a, C> {
13284 self._project_id = Some(new_value.to_string());
13285 self
13286 }
13287 /// Required. ID of the build.
13288 ///
13289 /// Sets the *id* query property to the given value.
13290 pub fn id(mut self, new_value: &str) -> ProjectLocationBuildGetCall<'a, C> {
13291 self._id = Some(new_value.to_string());
13292 self
13293 }
13294 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13295 /// while executing the actual API request.
13296 ///
13297 /// ````text
13298 /// It should be used to handle progress information, and to implement a certain level of resilience.
13299 /// ````
13300 ///
13301 /// Sets the *delegate* property to the given value.
13302 pub fn delegate(
13303 mut self,
13304 new_value: &'a mut dyn common::Delegate,
13305 ) -> ProjectLocationBuildGetCall<'a, C> {
13306 self._delegate = Some(new_value);
13307 self
13308 }
13309
13310 /// Set any additional parameter of the query string used in the request.
13311 /// It should be used to set parameters which are not yet available through their own
13312 /// setters.
13313 ///
13314 /// Please note that this method must not be used to set any of the known parameters
13315 /// which have their own setter method. If done anyway, the request will fail.
13316 ///
13317 /// # Additional Parameters
13318 ///
13319 /// * *$.xgafv* (query-string) - V1 error format.
13320 /// * *access_token* (query-string) - OAuth access token.
13321 /// * *alt* (query-string) - Data format for response.
13322 /// * *callback* (query-string) - JSONP
13323 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13324 /// * *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.
13325 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13326 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13327 /// * *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.
13328 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13329 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13330 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationBuildGetCall<'a, C>
13331 where
13332 T: AsRef<str>,
13333 {
13334 self._additional_params
13335 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13336 self
13337 }
13338
13339 /// Identifies the authorization scope for the method you are building.
13340 ///
13341 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13342 /// [`Scope::CloudPlatform`].
13343 ///
13344 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13345 /// tokens for more than one scope.
13346 ///
13347 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13348 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13349 /// sufficient, a read-write scope will do as well.
13350 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationBuildGetCall<'a, C>
13351 where
13352 St: AsRef<str>,
13353 {
13354 self._scopes.insert(String::from(scope.as_ref()));
13355 self
13356 }
13357 /// Identifies the authorization scope(s) for the method you are building.
13358 ///
13359 /// See [`Self::add_scope()`] for details.
13360 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationBuildGetCall<'a, C>
13361 where
13362 I: IntoIterator<Item = St>,
13363 St: AsRef<str>,
13364 {
13365 self._scopes
13366 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13367 self
13368 }
13369
13370 /// Removes all scopes, and no default scope will be used either.
13371 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13372 /// for details).
13373 pub fn clear_scopes(mut self) -> ProjectLocationBuildGetCall<'a, C> {
13374 self._scopes.clear();
13375 self
13376 }
13377}
13378
13379/// Lists previously requested builds. Previously requested builds may still be in-progress, or may have finished successfully or unsuccessfully.
13380///
13381/// A builder for the *locations.builds.list* method supported by a *project* resource.
13382/// It is not used directly, but through a [`ProjectMethods`] instance.
13383///
13384/// # Example
13385///
13386/// Instantiate a resource method builder
13387///
13388/// ```test_harness,no_run
13389/// # extern crate hyper;
13390/// # extern crate hyper_rustls;
13391/// # extern crate google_cloudbuild1 as cloudbuild1;
13392/// # async fn dox() {
13393/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13394///
13395/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13396/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13397/// # .with_native_roots()
13398/// # .unwrap()
13399/// # .https_only()
13400/// # .enable_http2()
13401/// # .build();
13402///
13403/// # let executor = hyper_util::rt::TokioExecutor::new();
13404/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13405/// # secret,
13406/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13407/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13408/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13409/// # ),
13410/// # ).build().await.unwrap();
13411///
13412/// # let client = hyper_util::client::legacy::Client::builder(
13413/// # hyper_util::rt::TokioExecutor::new()
13414/// # )
13415/// # .build(
13416/// # hyper_rustls::HttpsConnectorBuilder::new()
13417/// # .with_native_roots()
13418/// # .unwrap()
13419/// # .https_or_http()
13420/// # .enable_http2()
13421/// # .build()
13422/// # );
13423/// # let mut hub = CloudBuild::new(client, auth);
13424/// // You can configure optional parameters by calling the respective setters at will, and
13425/// // execute the final call using `doit()`.
13426/// // Values shown here are possibly random and not representative !
13427/// let result = hub.projects().locations_builds_list("parent")
13428/// .project_id("Stet")
13429/// .page_token("dolor")
13430/// .page_size(-20)
13431/// .filter("vero")
13432/// .doit().await;
13433/// # }
13434/// ```
13435pub struct ProjectLocationBuildListCall<'a, C>
13436where
13437 C: 'a,
13438{
13439 hub: &'a CloudBuild<C>,
13440 _parent: String,
13441 _project_id: Option<String>,
13442 _page_token: Option<String>,
13443 _page_size: Option<i32>,
13444 _filter: Option<String>,
13445 _delegate: Option<&'a mut dyn common::Delegate>,
13446 _additional_params: HashMap<String, String>,
13447 _scopes: BTreeSet<String>,
13448}
13449
13450impl<'a, C> common::CallBuilder for ProjectLocationBuildListCall<'a, C> {}
13451
13452impl<'a, C> ProjectLocationBuildListCall<'a, C>
13453where
13454 C: common::Connector,
13455{
13456 /// Perform the operation you have build so far.
13457 pub async fn doit(mut self) -> common::Result<(common::Response, ListBuildsResponse)> {
13458 use std::borrow::Cow;
13459 use std::io::{Read, Seek};
13460
13461 use common::{url::Params, ToParts};
13462 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13463
13464 let mut dd = common::DefaultDelegate;
13465 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13466 dlg.begin(common::MethodInfo {
13467 id: "cloudbuild.projects.locations.builds.list",
13468 http_method: hyper::Method::GET,
13469 });
13470
13471 for &field in [
13472 "alt",
13473 "parent",
13474 "projectId",
13475 "pageToken",
13476 "pageSize",
13477 "filter",
13478 ]
13479 .iter()
13480 {
13481 if self._additional_params.contains_key(field) {
13482 dlg.finished(false);
13483 return Err(common::Error::FieldClash(field));
13484 }
13485 }
13486
13487 let mut params = Params::with_capacity(7 + self._additional_params.len());
13488 params.push("parent", self._parent);
13489 if let Some(value) = self._project_id.as_ref() {
13490 params.push("projectId", value);
13491 }
13492 if let Some(value) = self._page_token.as_ref() {
13493 params.push("pageToken", value);
13494 }
13495 if let Some(value) = self._page_size.as_ref() {
13496 params.push("pageSize", value.to_string());
13497 }
13498 if let Some(value) = self._filter.as_ref() {
13499 params.push("filter", value);
13500 }
13501
13502 params.extend(self._additional_params.iter());
13503
13504 params.push("alt", "json");
13505 let mut url = self.hub._base_url.clone() + "v1/{+parent}/builds";
13506 if self._scopes.is_empty() {
13507 self._scopes
13508 .insert(Scope::CloudPlatform.as_ref().to_string());
13509 }
13510
13511 #[allow(clippy::single_element_loop)]
13512 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
13513 url = params.uri_replacement(url, param_name, find_this, true);
13514 }
13515 {
13516 let to_remove = ["parent"];
13517 params.remove_params(&to_remove);
13518 }
13519
13520 let url = params.parse_with_url(&url);
13521
13522 loop {
13523 let token = match self
13524 .hub
13525 .auth
13526 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13527 .await
13528 {
13529 Ok(token) => token,
13530 Err(e) => match dlg.token(e) {
13531 Ok(token) => token,
13532 Err(e) => {
13533 dlg.finished(false);
13534 return Err(common::Error::MissingToken(e));
13535 }
13536 },
13537 };
13538 let mut req_result = {
13539 let client = &self.hub.client;
13540 dlg.pre_request();
13541 let mut req_builder = hyper::Request::builder()
13542 .method(hyper::Method::GET)
13543 .uri(url.as_str())
13544 .header(USER_AGENT, self.hub._user_agent.clone());
13545
13546 if let Some(token) = token.as_ref() {
13547 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13548 }
13549
13550 let request = req_builder
13551 .header(CONTENT_LENGTH, 0_u64)
13552 .body(common::to_body::<String>(None));
13553
13554 client.request(request.unwrap()).await
13555 };
13556
13557 match req_result {
13558 Err(err) => {
13559 if let common::Retry::After(d) = dlg.http_error(&err) {
13560 sleep(d).await;
13561 continue;
13562 }
13563 dlg.finished(false);
13564 return Err(common::Error::HttpError(err));
13565 }
13566 Ok(res) => {
13567 let (mut parts, body) = res.into_parts();
13568 let mut body = common::Body::new(body);
13569 if !parts.status.is_success() {
13570 let bytes = common::to_bytes(body).await.unwrap_or_default();
13571 let error = serde_json::from_str(&common::to_string(&bytes));
13572 let response = common::to_response(parts, bytes.into());
13573
13574 if let common::Retry::After(d) =
13575 dlg.http_failure(&response, error.as_ref().ok())
13576 {
13577 sleep(d).await;
13578 continue;
13579 }
13580
13581 dlg.finished(false);
13582
13583 return Err(match error {
13584 Ok(value) => common::Error::BadRequest(value),
13585 _ => common::Error::Failure(response),
13586 });
13587 }
13588 let response = {
13589 let bytes = common::to_bytes(body).await.unwrap_or_default();
13590 let encoded = common::to_string(&bytes);
13591 match serde_json::from_str(&encoded) {
13592 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13593 Err(error) => {
13594 dlg.response_json_decode_error(&encoded, &error);
13595 return Err(common::Error::JsonDecodeError(
13596 encoded.to_string(),
13597 error,
13598 ));
13599 }
13600 }
13601 };
13602
13603 dlg.finished(true);
13604 return Ok(response);
13605 }
13606 }
13607 }
13608 }
13609
13610 /// The parent of the collection of `Builds`. Format: `projects/{project}/locations/{location}`
13611 ///
13612 /// Sets the *parent* path property to the given value.
13613 ///
13614 /// Even though the property as already been set when instantiating this call,
13615 /// we provide this method for API completeness.
13616 pub fn parent(mut self, new_value: &str) -> ProjectLocationBuildListCall<'a, C> {
13617 self._parent = new_value.to_string();
13618 self
13619 }
13620 /// Required. ID of the project.
13621 ///
13622 /// Sets the *project id* query property to the given value.
13623 pub fn project_id(mut self, new_value: &str) -> ProjectLocationBuildListCall<'a, C> {
13624 self._project_id = Some(new_value.to_string());
13625 self
13626 }
13627 /// 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.
13628 ///
13629 /// Sets the *page token* query property to the given value.
13630 pub fn page_token(mut self, new_value: &str) -> ProjectLocationBuildListCall<'a, C> {
13631 self._page_token = Some(new_value.to_string());
13632 self
13633 }
13634 /// Number of results to return in the list.
13635 ///
13636 /// Sets the *page size* query property to the given value.
13637 pub fn page_size(mut self, new_value: i32) -> ProjectLocationBuildListCall<'a, C> {
13638 self._page_size = Some(new_value);
13639 self
13640 }
13641 /// The raw filter text to constrain the results.
13642 ///
13643 /// Sets the *filter* query property to the given value.
13644 pub fn filter(mut self, new_value: &str) -> ProjectLocationBuildListCall<'a, C> {
13645 self._filter = Some(new_value.to_string());
13646 self
13647 }
13648 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13649 /// while executing the actual API request.
13650 ///
13651 /// ````text
13652 /// It should be used to handle progress information, and to implement a certain level of resilience.
13653 /// ````
13654 ///
13655 /// Sets the *delegate* property to the given value.
13656 pub fn delegate(
13657 mut self,
13658 new_value: &'a mut dyn common::Delegate,
13659 ) -> ProjectLocationBuildListCall<'a, C> {
13660 self._delegate = Some(new_value);
13661 self
13662 }
13663
13664 /// Set any additional parameter of the query string used in the request.
13665 /// It should be used to set parameters which are not yet available through their own
13666 /// setters.
13667 ///
13668 /// Please note that this method must not be used to set any of the known parameters
13669 /// which have their own setter method. If done anyway, the request will fail.
13670 ///
13671 /// # Additional Parameters
13672 ///
13673 /// * *$.xgafv* (query-string) - V1 error format.
13674 /// * *access_token* (query-string) - OAuth access token.
13675 /// * *alt* (query-string) - Data format for response.
13676 /// * *callback* (query-string) - JSONP
13677 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13678 /// * *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.
13679 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13680 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13681 /// * *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.
13682 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13683 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13684 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationBuildListCall<'a, C>
13685 where
13686 T: AsRef<str>,
13687 {
13688 self._additional_params
13689 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13690 self
13691 }
13692
13693 /// Identifies the authorization scope for the method you are building.
13694 ///
13695 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13696 /// [`Scope::CloudPlatform`].
13697 ///
13698 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13699 /// tokens for more than one scope.
13700 ///
13701 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13702 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13703 /// sufficient, a read-write scope will do as well.
13704 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationBuildListCall<'a, C>
13705 where
13706 St: AsRef<str>,
13707 {
13708 self._scopes.insert(String::from(scope.as_ref()));
13709 self
13710 }
13711 /// Identifies the authorization scope(s) for the method you are building.
13712 ///
13713 /// See [`Self::add_scope()`] for details.
13714 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationBuildListCall<'a, C>
13715 where
13716 I: IntoIterator<Item = St>,
13717 St: AsRef<str>,
13718 {
13719 self._scopes
13720 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13721 self
13722 }
13723
13724 /// Removes all scopes, and no default scope will be used either.
13725 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13726 /// for details).
13727 pub fn clear_scopes(mut self) -> ProjectLocationBuildListCall<'a, C> {
13728 self._scopes.clear();
13729 self
13730 }
13731}
13732
13733/// 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.
13734///
13735/// A builder for the *locations.builds.retry* method supported by a *project* resource.
13736/// It is not used directly, but through a [`ProjectMethods`] instance.
13737///
13738/// # Example
13739///
13740/// Instantiate a resource method builder
13741///
13742/// ```test_harness,no_run
13743/// # extern crate hyper;
13744/// # extern crate hyper_rustls;
13745/// # extern crate google_cloudbuild1 as cloudbuild1;
13746/// use cloudbuild1::api::RetryBuildRequest;
13747/// # async fn dox() {
13748/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13749///
13750/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13751/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13752/// # .with_native_roots()
13753/// # .unwrap()
13754/// # .https_only()
13755/// # .enable_http2()
13756/// # .build();
13757///
13758/// # let executor = hyper_util::rt::TokioExecutor::new();
13759/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13760/// # secret,
13761/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13762/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13763/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13764/// # ),
13765/// # ).build().await.unwrap();
13766///
13767/// # let client = hyper_util::client::legacy::Client::builder(
13768/// # hyper_util::rt::TokioExecutor::new()
13769/// # )
13770/// # .build(
13771/// # hyper_rustls::HttpsConnectorBuilder::new()
13772/// # .with_native_roots()
13773/// # .unwrap()
13774/// # .https_or_http()
13775/// # .enable_http2()
13776/// # .build()
13777/// # );
13778/// # let mut hub = CloudBuild::new(client, auth);
13779/// // As the method needs a request, you would usually fill it with the desired information
13780/// // into the respective structure. Some of the parts shown here might not be applicable !
13781/// // Values shown here are possibly random and not representative !
13782/// let mut req = RetryBuildRequest::default();
13783///
13784/// // You can configure optional parameters by calling the respective setters at will, and
13785/// // execute the final call using `doit()`.
13786/// // Values shown here are possibly random and not representative !
13787/// let result = hub.projects().locations_builds_retry(req, "name")
13788/// .doit().await;
13789/// # }
13790/// ```
13791pub struct ProjectLocationBuildRetryCall<'a, C>
13792where
13793 C: 'a,
13794{
13795 hub: &'a CloudBuild<C>,
13796 _request: RetryBuildRequest,
13797 _name: String,
13798 _delegate: Option<&'a mut dyn common::Delegate>,
13799 _additional_params: HashMap<String, String>,
13800 _scopes: BTreeSet<String>,
13801}
13802
13803impl<'a, C> common::CallBuilder for ProjectLocationBuildRetryCall<'a, C> {}
13804
13805impl<'a, C> ProjectLocationBuildRetryCall<'a, C>
13806where
13807 C: common::Connector,
13808{
13809 /// Perform the operation you have build so far.
13810 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
13811 use std::borrow::Cow;
13812 use std::io::{Read, Seek};
13813
13814 use common::{url::Params, ToParts};
13815 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13816
13817 let mut dd = common::DefaultDelegate;
13818 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13819 dlg.begin(common::MethodInfo {
13820 id: "cloudbuild.projects.locations.builds.retry",
13821 http_method: hyper::Method::POST,
13822 });
13823
13824 for &field in ["alt", "name"].iter() {
13825 if self._additional_params.contains_key(field) {
13826 dlg.finished(false);
13827 return Err(common::Error::FieldClash(field));
13828 }
13829 }
13830
13831 let mut params = Params::with_capacity(4 + self._additional_params.len());
13832 params.push("name", self._name);
13833
13834 params.extend(self._additional_params.iter());
13835
13836 params.push("alt", "json");
13837 let mut url = self.hub._base_url.clone() + "v1/{+name}:retry";
13838 if self._scopes.is_empty() {
13839 self._scopes
13840 .insert(Scope::CloudPlatform.as_ref().to_string());
13841 }
13842
13843 #[allow(clippy::single_element_loop)]
13844 for &(find_this, param_name) in [("{+name}", "name")].iter() {
13845 url = params.uri_replacement(url, param_name, find_this, true);
13846 }
13847 {
13848 let to_remove = ["name"];
13849 params.remove_params(&to_remove);
13850 }
13851
13852 let url = params.parse_with_url(&url);
13853
13854 let mut json_mime_type = mime::APPLICATION_JSON;
13855 let mut request_value_reader = {
13856 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13857 common::remove_json_null_values(&mut value);
13858 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13859 serde_json::to_writer(&mut dst, &value).unwrap();
13860 dst
13861 };
13862 let request_size = request_value_reader
13863 .seek(std::io::SeekFrom::End(0))
13864 .unwrap();
13865 request_value_reader
13866 .seek(std::io::SeekFrom::Start(0))
13867 .unwrap();
13868
13869 loop {
13870 let token = match self
13871 .hub
13872 .auth
13873 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13874 .await
13875 {
13876 Ok(token) => token,
13877 Err(e) => match dlg.token(e) {
13878 Ok(token) => token,
13879 Err(e) => {
13880 dlg.finished(false);
13881 return Err(common::Error::MissingToken(e));
13882 }
13883 },
13884 };
13885 request_value_reader
13886 .seek(std::io::SeekFrom::Start(0))
13887 .unwrap();
13888 let mut req_result = {
13889 let client = &self.hub.client;
13890 dlg.pre_request();
13891 let mut req_builder = hyper::Request::builder()
13892 .method(hyper::Method::POST)
13893 .uri(url.as_str())
13894 .header(USER_AGENT, self.hub._user_agent.clone());
13895
13896 if let Some(token) = token.as_ref() {
13897 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13898 }
13899
13900 let request = req_builder
13901 .header(CONTENT_TYPE, json_mime_type.to_string())
13902 .header(CONTENT_LENGTH, request_size as u64)
13903 .body(common::to_body(
13904 request_value_reader.get_ref().clone().into(),
13905 ));
13906
13907 client.request(request.unwrap()).await
13908 };
13909
13910 match req_result {
13911 Err(err) => {
13912 if let common::Retry::After(d) = dlg.http_error(&err) {
13913 sleep(d).await;
13914 continue;
13915 }
13916 dlg.finished(false);
13917 return Err(common::Error::HttpError(err));
13918 }
13919 Ok(res) => {
13920 let (mut parts, body) = res.into_parts();
13921 let mut body = common::Body::new(body);
13922 if !parts.status.is_success() {
13923 let bytes = common::to_bytes(body).await.unwrap_or_default();
13924 let error = serde_json::from_str(&common::to_string(&bytes));
13925 let response = common::to_response(parts, bytes.into());
13926
13927 if let common::Retry::After(d) =
13928 dlg.http_failure(&response, error.as_ref().ok())
13929 {
13930 sleep(d).await;
13931 continue;
13932 }
13933
13934 dlg.finished(false);
13935
13936 return Err(match error {
13937 Ok(value) => common::Error::BadRequest(value),
13938 _ => common::Error::Failure(response),
13939 });
13940 }
13941 let response = {
13942 let bytes = common::to_bytes(body).await.unwrap_or_default();
13943 let encoded = common::to_string(&bytes);
13944 match serde_json::from_str(&encoded) {
13945 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13946 Err(error) => {
13947 dlg.response_json_decode_error(&encoded, &error);
13948 return Err(common::Error::JsonDecodeError(
13949 encoded.to_string(),
13950 error,
13951 ));
13952 }
13953 }
13954 };
13955
13956 dlg.finished(true);
13957 return Ok(response);
13958 }
13959 }
13960 }
13961 }
13962
13963 ///
13964 /// Sets the *request* property to the given value.
13965 ///
13966 /// Even though the property as already been set when instantiating this call,
13967 /// we provide this method for API completeness.
13968 pub fn request(mut self, new_value: RetryBuildRequest) -> ProjectLocationBuildRetryCall<'a, C> {
13969 self._request = new_value;
13970 self
13971 }
13972 /// The name of the `Build` to retry. Format: `projects/{project}/locations/{location}/builds/{build}`
13973 ///
13974 /// Sets the *name* path property to the given value.
13975 ///
13976 /// Even though the property as already been set when instantiating this call,
13977 /// we provide this method for API completeness.
13978 pub fn name(mut self, new_value: &str) -> ProjectLocationBuildRetryCall<'a, C> {
13979 self._name = new_value.to_string();
13980 self
13981 }
13982 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13983 /// while executing the actual API request.
13984 ///
13985 /// ````text
13986 /// It should be used to handle progress information, and to implement a certain level of resilience.
13987 /// ````
13988 ///
13989 /// Sets the *delegate* property to the given value.
13990 pub fn delegate(
13991 mut self,
13992 new_value: &'a mut dyn common::Delegate,
13993 ) -> ProjectLocationBuildRetryCall<'a, C> {
13994 self._delegate = Some(new_value);
13995 self
13996 }
13997
13998 /// Set any additional parameter of the query string used in the request.
13999 /// It should be used to set parameters which are not yet available through their own
14000 /// setters.
14001 ///
14002 /// Please note that this method must not be used to set any of the known parameters
14003 /// which have their own setter method. If done anyway, the request will fail.
14004 ///
14005 /// # Additional Parameters
14006 ///
14007 /// * *$.xgafv* (query-string) - V1 error format.
14008 /// * *access_token* (query-string) - OAuth access token.
14009 /// * *alt* (query-string) - Data format for response.
14010 /// * *callback* (query-string) - JSONP
14011 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14012 /// * *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.
14013 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14014 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14015 /// * *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.
14016 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14017 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14018 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationBuildRetryCall<'a, C>
14019 where
14020 T: AsRef<str>,
14021 {
14022 self._additional_params
14023 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14024 self
14025 }
14026
14027 /// Identifies the authorization scope for the method you are building.
14028 ///
14029 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14030 /// [`Scope::CloudPlatform`].
14031 ///
14032 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14033 /// tokens for more than one scope.
14034 ///
14035 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14036 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14037 /// sufficient, a read-write scope will do as well.
14038 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationBuildRetryCall<'a, C>
14039 where
14040 St: AsRef<str>,
14041 {
14042 self._scopes.insert(String::from(scope.as_ref()));
14043 self
14044 }
14045 /// Identifies the authorization scope(s) for the method you are building.
14046 ///
14047 /// See [`Self::add_scope()`] for details.
14048 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationBuildRetryCall<'a, C>
14049 where
14050 I: IntoIterator<Item = St>,
14051 St: AsRef<str>,
14052 {
14053 self._scopes
14054 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14055 self
14056 }
14057
14058 /// Removes all scopes, and no default scope will be used either.
14059 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14060 /// for details).
14061 pub fn clear_scopes(mut self) -> ProjectLocationBuildRetryCall<'a, C> {
14062 self._scopes.clear();
14063 self
14064 }
14065}
14066
14067/// Batch connecting GitLab repositories to Cloud Build. This API is experimental.
14068///
14069/// A builder for the *locations.gitLabConfigs.connectedRepositories.batchCreate* method supported by a *project* resource.
14070/// It is not used directly, but through a [`ProjectMethods`] instance.
14071///
14072/// # Example
14073///
14074/// Instantiate a resource method builder
14075///
14076/// ```test_harness,no_run
14077/// # extern crate hyper;
14078/// # extern crate hyper_rustls;
14079/// # extern crate google_cloudbuild1 as cloudbuild1;
14080/// use cloudbuild1::api::BatchCreateGitLabConnectedRepositoriesRequest;
14081/// # async fn dox() {
14082/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14083///
14084/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14085/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14086/// # .with_native_roots()
14087/// # .unwrap()
14088/// # .https_only()
14089/// # .enable_http2()
14090/// # .build();
14091///
14092/// # let executor = hyper_util::rt::TokioExecutor::new();
14093/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14094/// # secret,
14095/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14096/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14097/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14098/// # ),
14099/// # ).build().await.unwrap();
14100///
14101/// # let client = hyper_util::client::legacy::Client::builder(
14102/// # hyper_util::rt::TokioExecutor::new()
14103/// # )
14104/// # .build(
14105/// # hyper_rustls::HttpsConnectorBuilder::new()
14106/// # .with_native_roots()
14107/// # .unwrap()
14108/// # .https_or_http()
14109/// # .enable_http2()
14110/// # .build()
14111/// # );
14112/// # let mut hub = CloudBuild::new(client, auth);
14113/// // As the method needs a request, you would usually fill it with the desired information
14114/// // into the respective structure. Some of the parts shown here might not be applicable !
14115/// // Values shown here are possibly random and not representative !
14116/// let mut req = BatchCreateGitLabConnectedRepositoriesRequest::default();
14117///
14118/// // You can configure optional parameters by calling the respective setters at will, and
14119/// // execute the final call using `doit()`.
14120/// // Values shown here are possibly random and not representative !
14121/// let result = hub.projects().locations_git_lab_configs_connected_repositories_batch_create(req, "parent")
14122/// .doit().await;
14123/// # }
14124/// ```
14125pub struct ProjectLocationGitLabConfigConnectedRepositoryBatchCreateCall<'a, C>
14126where
14127 C: 'a,
14128{
14129 hub: &'a CloudBuild<C>,
14130 _request: BatchCreateGitLabConnectedRepositoriesRequest,
14131 _parent: String,
14132 _delegate: Option<&'a mut dyn common::Delegate>,
14133 _additional_params: HashMap<String, String>,
14134 _scopes: BTreeSet<String>,
14135}
14136
14137impl<'a, C> common::CallBuilder
14138 for ProjectLocationGitLabConfigConnectedRepositoryBatchCreateCall<'a, C>
14139{
14140}
14141
14142impl<'a, C> ProjectLocationGitLabConfigConnectedRepositoryBatchCreateCall<'a, C>
14143where
14144 C: common::Connector,
14145{
14146 /// Perform the operation you have build so far.
14147 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
14148 use std::borrow::Cow;
14149 use std::io::{Read, Seek};
14150
14151 use common::{url::Params, ToParts};
14152 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14153
14154 let mut dd = common::DefaultDelegate;
14155 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14156 dlg.begin(common::MethodInfo {
14157 id: "cloudbuild.projects.locations.gitLabConfigs.connectedRepositories.batchCreate",
14158 http_method: hyper::Method::POST,
14159 });
14160
14161 for &field in ["alt", "parent"].iter() {
14162 if self._additional_params.contains_key(field) {
14163 dlg.finished(false);
14164 return Err(common::Error::FieldClash(field));
14165 }
14166 }
14167
14168 let mut params = Params::with_capacity(4 + self._additional_params.len());
14169 params.push("parent", self._parent);
14170
14171 params.extend(self._additional_params.iter());
14172
14173 params.push("alt", "json");
14174 let mut url = self.hub._base_url.clone() + "v1/{+parent}/connectedRepositories:batchCreate";
14175 if self._scopes.is_empty() {
14176 self._scopes
14177 .insert(Scope::CloudPlatform.as_ref().to_string());
14178 }
14179
14180 #[allow(clippy::single_element_loop)]
14181 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
14182 url = params.uri_replacement(url, param_name, find_this, true);
14183 }
14184 {
14185 let to_remove = ["parent"];
14186 params.remove_params(&to_remove);
14187 }
14188
14189 let url = params.parse_with_url(&url);
14190
14191 let mut json_mime_type = mime::APPLICATION_JSON;
14192 let mut request_value_reader = {
14193 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14194 common::remove_json_null_values(&mut value);
14195 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14196 serde_json::to_writer(&mut dst, &value).unwrap();
14197 dst
14198 };
14199 let request_size = request_value_reader
14200 .seek(std::io::SeekFrom::End(0))
14201 .unwrap();
14202 request_value_reader
14203 .seek(std::io::SeekFrom::Start(0))
14204 .unwrap();
14205
14206 loop {
14207 let token = match self
14208 .hub
14209 .auth
14210 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14211 .await
14212 {
14213 Ok(token) => token,
14214 Err(e) => match dlg.token(e) {
14215 Ok(token) => token,
14216 Err(e) => {
14217 dlg.finished(false);
14218 return Err(common::Error::MissingToken(e));
14219 }
14220 },
14221 };
14222 request_value_reader
14223 .seek(std::io::SeekFrom::Start(0))
14224 .unwrap();
14225 let mut req_result = {
14226 let client = &self.hub.client;
14227 dlg.pre_request();
14228 let mut req_builder = hyper::Request::builder()
14229 .method(hyper::Method::POST)
14230 .uri(url.as_str())
14231 .header(USER_AGENT, self.hub._user_agent.clone());
14232
14233 if let Some(token) = token.as_ref() {
14234 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14235 }
14236
14237 let request = req_builder
14238 .header(CONTENT_TYPE, json_mime_type.to_string())
14239 .header(CONTENT_LENGTH, request_size as u64)
14240 .body(common::to_body(
14241 request_value_reader.get_ref().clone().into(),
14242 ));
14243
14244 client.request(request.unwrap()).await
14245 };
14246
14247 match req_result {
14248 Err(err) => {
14249 if let common::Retry::After(d) = dlg.http_error(&err) {
14250 sleep(d).await;
14251 continue;
14252 }
14253 dlg.finished(false);
14254 return Err(common::Error::HttpError(err));
14255 }
14256 Ok(res) => {
14257 let (mut parts, body) = res.into_parts();
14258 let mut body = common::Body::new(body);
14259 if !parts.status.is_success() {
14260 let bytes = common::to_bytes(body).await.unwrap_or_default();
14261 let error = serde_json::from_str(&common::to_string(&bytes));
14262 let response = common::to_response(parts, bytes.into());
14263
14264 if let common::Retry::After(d) =
14265 dlg.http_failure(&response, error.as_ref().ok())
14266 {
14267 sleep(d).await;
14268 continue;
14269 }
14270
14271 dlg.finished(false);
14272
14273 return Err(match error {
14274 Ok(value) => common::Error::BadRequest(value),
14275 _ => common::Error::Failure(response),
14276 });
14277 }
14278 let response = {
14279 let bytes = common::to_bytes(body).await.unwrap_or_default();
14280 let encoded = common::to_string(&bytes);
14281 match serde_json::from_str(&encoded) {
14282 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14283 Err(error) => {
14284 dlg.response_json_decode_error(&encoded, &error);
14285 return Err(common::Error::JsonDecodeError(
14286 encoded.to_string(),
14287 error,
14288 ));
14289 }
14290 }
14291 };
14292
14293 dlg.finished(true);
14294 return Ok(response);
14295 }
14296 }
14297 }
14298 }
14299
14300 ///
14301 /// Sets the *request* property to the given value.
14302 ///
14303 /// Even though the property as already been set when instantiating this call,
14304 /// we provide this method for API completeness.
14305 pub fn request(
14306 mut self,
14307 new_value: BatchCreateGitLabConnectedRepositoriesRequest,
14308 ) -> ProjectLocationGitLabConfigConnectedRepositoryBatchCreateCall<'a, C> {
14309 self._request = new_value;
14310 self
14311 }
14312 /// The name of the `GitLabConfig` that adds connected repositories. Format: `projects/{project}/locations/{location}/gitLabConfigs/{config}`
14313 ///
14314 /// Sets the *parent* path property to the given value.
14315 ///
14316 /// Even though the property as already been set when instantiating this call,
14317 /// we provide this method for API completeness.
14318 pub fn parent(
14319 mut self,
14320 new_value: &str,
14321 ) -> ProjectLocationGitLabConfigConnectedRepositoryBatchCreateCall<'a, C> {
14322 self._parent = new_value.to_string();
14323 self
14324 }
14325 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14326 /// while executing the actual API request.
14327 ///
14328 /// ````text
14329 /// It should be used to handle progress information, and to implement a certain level of resilience.
14330 /// ````
14331 ///
14332 /// Sets the *delegate* property to the given value.
14333 pub fn delegate(
14334 mut self,
14335 new_value: &'a mut dyn common::Delegate,
14336 ) -> ProjectLocationGitLabConfigConnectedRepositoryBatchCreateCall<'a, C> {
14337 self._delegate = Some(new_value);
14338 self
14339 }
14340
14341 /// Set any additional parameter of the query string used in the request.
14342 /// It should be used to set parameters which are not yet available through their own
14343 /// setters.
14344 ///
14345 /// Please note that this method must not be used to set any of the known parameters
14346 /// which have their own setter method. If done anyway, the request will fail.
14347 ///
14348 /// # Additional Parameters
14349 ///
14350 /// * *$.xgafv* (query-string) - V1 error format.
14351 /// * *access_token* (query-string) - OAuth access token.
14352 /// * *alt* (query-string) - Data format for response.
14353 /// * *callback* (query-string) - JSONP
14354 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14355 /// * *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.
14356 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14357 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14358 /// * *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.
14359 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14360 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14361 pub fn param<T>(
14362 mut self,
14363 name: T,
14364 value: T,
14365 ) -> ProjectLocationGitLabConfigConnectedRepositoryBatchCreateCall<'a, C>
14366 where
14367 T: AsRef<str>,
14368 {
14369 self._additional_params
14370 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14371 self
14372 }
14373
14374 /// Identifies the authorization scope for the method you are building.
14375 ///
14376 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14377 /// [`Scope::CloudPlatform`].
14378 ///
14379 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14380 /// tokens for more than one scope.
14381 ///
14382 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14383 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14384 /// sufficient, a read-write scope will do as well.
14385 pub fn add_scope<St>(
14386 mut self,
14387 scope: St,
14388 ) -> ProjectLocationGitLabConfigConnectedRepositoryBatchCreateCall<'a, C>
14389 where
14390 St: AsRef<str>,
14391 {
14392 self._scopes.insert(String::from(scope.as_ref()));
14393 self
14394 }
14395 /// Identifies the authorization scope(s) for the method you are building.
14396 ///
14397 /// See [`Self::add_scope()`] for details.
14398 pub fn add_scopes<I, St>(
14399 mut self,
14400 scopes: I,
14401 ) -> ProjectLocationGitLabConfigConnectedRepositoryBatchCreateCall<'a, C>
14402 where
14403 I: IntoIterator<Item = St>,
14404 St: AsRef<str>,
14405 {
14406 self._scopes
14407 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14408 self
14409 }
14410
14411 /// Removes all scopes, and no default scope will be used either.
14412 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14413 /// for details).
14414 pub fn clear_scopes(
14415 mut self,
14416 ) -> ProjectLocationGitLabConfigConnectedRepositoryBatchCreateCall<'a, C> {
14417 self._scopes.clear();
14418 self
14419 }
14420}
14421
14422/// List all repositories for a given `GitLabConfig`. This API is experimental
14423///
14424/// A builder for the *locations.gitLabConfigs.repos.list* method supported by a *project* resource.
14425/// It is not used directly, but through a [`ProjectMethods`] instance.
14426///
14427/// # Example
14428///
14429/// Instantiate a resource method builder
14430///
14431/// ```test_harness,no_run
14432/// # extern crate hyper;
14433/// # extern crate hyper_rustls;
14434/// # extern crate google_cloudbuild1 as cloudbuild1;
14435/// # async fn dox() {
14436/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14437///
14438/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14439/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14440/// # .with_native_roots()
14441/// # .unwrap()
14442/// # .https_only()
14443/// # .enable_http2()
14444/// # .build();
14445///
14446/// # let executor = hyper_util::rt::TokioExecutor::new();
14447/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14448/// # secret,
14449/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14450/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14451/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14452/// # ),
14453/// # ).build().await.unwrap();
14454///
14455/// # let client = hyper_util::client::legacy::Client::builder(
14456/// # hyper_util::rt::TokioExecutor::new()
14457/// # )
14458/// # .build(
14459/// # hyper_rustls::HttpsConnectorBuilder::new()
14460/// # .with_native_roots()
14461/// # .unwrap()
14462/// # .https_or_http()
14463/// # .enable_http2()
14464/// # .build()
14465/// # );
14466/// # let mut hub = CloudBuild::new(client, auth);
14467/// // You can configure optional parameters by calling the respective setters at will, and
14468/// // execute the final call using `doit()`.
14469/// // Values shown here are possibly random and not representative !
14470/// let result = hub.projects().locations_git_lab_configs_repos_list("parent")
14471/// .page_token("vero")
14472/// .page_size(-44)
14473/// .doit().await;
14474/// # }
14475/// ```
14476pub struct ProjectLocationGitLabConfigRepoListCall<'a, C>
14477where
14478 C: 'a,
14479{
14480 hub: &'a CloudBuild<C>,
14481 _parent: String,
14482 _page_token: Option<String>,
14483 _page_size: Option<i32>,
14484 _delegate: Option<&'a mut dyn common::Delegate>,
14485 _additional_params: HashMap<String, String>,
14486 _scopes: BTreeSet<String>,
14487}
14488
14489impl<'a, C> common::CallBuilder for ProjectLocationGitLabConfigRepoListCall<'a, C> {}
14490
14491impl<'a, C> ProjectLocationGitLabConfigRepoListCall<'a, C>
14492where
14493 C: common::Connector,
14494{
14495 /// Perform the operation you have build so far.
14496 pub async fn doit(
14497 mut self,
14498 ) -> common::Result<(common::Response, ListGitLabRepositoriesResponse)> {
14499 use std::borrow::Cow;
14500 use std::io::{Read, Seek};
14501
14502 use common::{url::Params, ToParts};
14503 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14504
14505 let mut dd = common::DefaultDelegate;
14506 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14507 dlg.begin(common::MethodInfo {
14508 id: "cloudbuild.projects.locations.gitLabConfigs.repos.list",
14509 http_method: hyper::Method::GET,
14510 });
14511
14512 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
14513 if self._additional_params.contains_key(field) {
14514 dlg.finished(false);
14515 return Err(common::Error::FieldClash(field));
14516 }
14517 }
14518
14519 let mut params = Params::with_capacity(5 + self._additional_params.len());
14520 params.push("parent", self._parent);
14521 if let Some(value) = self._page_token.as_ref() {
14522 params.push("pageToken", value);
14523 }
14524 if let Some(value) = self._page_size.as_ref() {
14525 params.push("pageSize", value.to_string());
14526 }
14527
14528 params.extend(self._additional_params.iter());
14529
14530 params.push("alt", "json");
14531 let mut url = self.hub._base_url.clone() + "v1/{+parent}/repos";
14532 if self._scopes.is_empty() {
14533 self._scopes
14534 .insert(Scope::CloudPlatform.as_ref().to_string());
14535 }
14536
14537 #[allow(clippy::single_element_loop)]
14538 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
14539 url = params.uri_replacement(url, param_name, find_this, true);
14540 }
14541 {
14542 let to_remove = ["parent"];
14543 params.remove_params(&to_remove);
14544 }
14545
14546 let url = params.parse_with_url(&url);
14547
14548 loop {
14549 let token = match self
14550 .hub
14551 .auth
14552 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14553 .await
14554 {
14555 Ok(token) => token,
14556 Err(e) => match dlg.token(e) {
14557 Ok(token) => token,
14558 Err(e) => {
14559 dlg.finished(false);
14560 return Err(common::Error::MissingToken(e));
14561 }
14562 },
14563 };
14564 let mut req_result = {
14565 let client = &self.hub.client;
14566 dlg.pre_request();
14567 let mut req_builder = hyper::Request::builder()
14568 .method(hyper::Method::GET)
14569 .uri(url.as_str())
14570 .header(USER_AGENT, self.hub._user_agent.clone());
14571
14572 if let Some(token) = token.as_ref() {
14573 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14574 }
14575
14576 let request = req_builder
14577 .header(CONTENT_LENGTH, 0_u64)
14578 .body(common::to_body::<String>(None));
14579
14580 client.request(request.unwrap()).await
14581 };
14582
14583 match req_result {
14584 Err(err) => {
14585 if let common::Retry::After(d) = dlg.http_error(&err) {
14586 sleep(d).await;
14587 continue;
14588 }
14589 dlg.finished(false);
14590 return Err(common::Error::HttpError(err));
14591 }
14592 Ok(res) => {
14593 let (mut parts, body) = res.into_parts();
14594 let mut body = common::Body::new(body);
14595 if !parts.status.is_success() {
14596 let bytes = common::to_bytes(body).await.unwrap_or_default();
14597 let error = serde_json::from_str(&common::to_string(&bytes));
14598 let response = common::to_response(parts, bytes.into());
14599
14600 if let common::Retry::After(d) =
14601 dlg.http_failure(&response, error.as_ref().ok())
14602 {
14603 sleep(d).await;
14604 continue;
14605 }
14606
14607 dlg.finished(false);
14608
14609 return Err(match error {
14610 Ok(value) => common::Error::BadRequest(value),
14611 _ => common::Error::Failure(response),
14612 });
14613 }
14614 let response = {
14615 let bytes = common::to_bytes(body).await.unwrap_or_default();
14616 let encoded = common::to_string(&bytes);
14617 match serde_json::from_str(&encoded) {
14618 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14619 Err(error) => {
14620 dlg.response_json_decode_error(&encoded, &error);
14621 return Err(common::Error::JsonDecodeError(
14622 encoded.to_string(),
14623 error,
14624 ));
14625 }
14626 }
14627 };
14628
14629 dlg.finished(true);
14630 return Ok(response);
14631 }
14632 }
14633 }
14634 }
14635
14636 /// Required. Name of the parent resource.
14637 ///
14638 /// Sets the *parent* path property to the given value.
14639 ///
14640 /// Even though the property as already been set when instantiating this call,
14641 /// we provide this method for API completeness.
14642 pub fn parent(mut self, new_value: &str) -> ProjectLocationGitLabConfigRepoListCall<'a, C> {
14643 self._parent = new_value.to_string();
14644 self
14645 }
14646 /// 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.
14647 ///
14648 /// Sets the *page token* query property to the given value.
14649 pub fn page_token(mut self, new_value: &str) -> ProjectLocationGitLabConfigRepoListCall<'a, C> {
14650 self._page_token = Some(new_value.to_string());
14651 self
14652 }
14653 /// The maximum number of repositories to return. The service may return fewer than this value.
14654 ///
14655 /// Sets the *page size* query property to the given value.
14656 pub fn page_size(mut self, new_value: i32) -> ProjectLocationGitLabConfigRepoListCall<'a, C> {
14657 self._page_size = Some(new_value);
14658 self
14659 }
14660 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14661 /// while executing the actual API request.
14662 ///
14663 /// ````text
14664 /// It should be used to handle progress information, and to implement a certain level of resilience.
14665 /// ````
14666 ///
14667 /// Sets the *delegate* property to the given value.
14668 pub fn delegate(
14669 mut self,
14670 new_value: &'a mut dyn common::Delegate,
14671 ) -> ProjectLocationGitLabConfigRepoListCall<'a, C> {
14672 self._delegate = Some(new_value);
14673 self
14674 }
14675
14676 /// Set any additional parameter of the query string used in the request.
14677 /// It should be used to set parameters which are not yet available through their own
14678 /// setters.
14679 ///
14680 /// Please note that this method must not be used to set any of the known parameters
14681 /// which have their own setter method. If done anyway, the request will fail.
14682 ///
14683 /// # Additional Parameters
14684 ///
14685 /// * *$.xgafv* (query-string) - V1 error format.
14686 /// * *access_token* (query-string) - OAuth access token.
14687 /// * *alt* (query-string) - Data format for response.
14688 /// * *callback* (query-string) - JSONP
14689 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14690 /// * *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.
14691 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14692 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14693 /// * *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.
14694 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14695 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14696 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGitLabConfigRepoListCall<'a, C>
14697 where
14698 T: AsRef<str>,
14699 {
14700 self._additional_params
14701 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14702 self
14703 }
14704
14705 /// Identifies the authorization scope for the method you are building.
14706 ///
14707 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14708 /// [`Scope::CloudPlatform`].
14709 ///
14710 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14711 /// tokens for more than one scope.
14712 ///
14713 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14714 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14715 /// sufficient, a read-write scope will do as well.
14716 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGitLabConfigRepoListCall<'a, C>
14717 where
14718 St: AsRef<str>,
14719 {
14720 self._scopes.insert(String::from(scope.as_ref()));
14721 self
14722 }
14723 /// Identifies the authorization scope(s) for the method you are building.
14724 ///
14725 /// See [`Self::add_scope()`] for details.
14726 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGitLabConfigRepoListCall<'a, C>
14727 where
14728 I: IntoIterator<Item = St>,
14729 St: AsRef<str>,
14730 {
14731 self._scopes
14732 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14733 self
14734 }
14735
14736 /// Removes all scopes, and no default scope will be used either.
14737 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14738 /// for details).
14739 pub fn clear_scopes(mut self) -> ProjectLocationGitLabConfigRepoListCall<'a, C> {
14740 self._scopes.clear();
14741 self
14742 }
14743}
14744
14745/// Creates a new `GitLabConfig`. This API is experimental
14746///
14747/// A builder for the *locations.gitLabConfigs.create* method supported by a *project* resource.
14748/// It is not used directly, but through a [`ProjectMethods`] instance.
14749///
14750/// # Example
14751///
14752/// Instantiate a resource method builder
14753///
14754/// ```test_harness,no_run
14755/// # extern crate hyper;
14756/// # extern crate hyper_rustls;
14757/// # extern crate google_cloudbuild1 as cloudbuild1;
14758/// use cloudbuild1::api::GitLabConfig;
14759/// # async fn dox() {
14760/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14761///
14762/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14763/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14764/// # .with_native_roots()
14765/// # .unwrap()
14766/// # .https_only()
14767/// # .enable_http2()
14768/// # .build();
14769///
14770/// # let executor = hyper_util::rt::TokioExecutor::new();
14771/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14772/// # secret,
14773/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14774/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14775/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14776/// # ),
14777/// # ).build().await.unwrap();
14778///
14779/// # let client = hyper_util::client::legacy::Client::builder(
14780/// # hyper_util::rt::TokioExecutor::new()
14781/// # )
14782/// # .build(
14783/// # hyper_rustls::HttpsConnectorBuilder::new()
14784/// # .with_native_roots()
14785/// # .unwrap()
14786/// # .https_or_http()
14787/// # .enable_http2()
14788/// # .build()
14789/// # );
14790/// # let mut hub = CloudBuild::new(client, auth);
14791/// // As the method needs a request, you would usually fill it with the desired information
14792/// // into the respective structure. Some of the parts shown here might not be applicable !
14793/// // Values shown here are possibly random and not representative !
14794/// let mut req = GitLabConfig::default();
14795///
14796/// // You can configure optional parameters by calling the respective setters at will, and
14797/// // execute the final call using `doit()`.
14798/// // Values shown here are possibly random and not representative !
14799/// let result = hub.projects().locations_git_lab_configs_create(req, "parent")
14800/// .gitlab_config_id("diam")
14801/// .doit().await;
14802/// # }
14803/// ```
14804pub struct ProjectLocationGitLabConfigCreateCall<'a, C>
14805where
14806 C: 'a,
14807{
14808 hub: &'a CloudBuild<C>,
14809 _request: GitLabConfig,
14810 _parent: String,
14811 _gitlab_config_id: Option<String>,
14812 _delegate: Option<&'a mut dyn common::Delegate>,
14813 _additional_params: HashMap<String, String>,
14814 _scopes: BTreeSet<String>,
14815}
14816
14817impl<'a, C> common::CallBuilder for ProjectLocationGitLabConfigCreateCall<'a, C> {}
14818
14819impl<'a, C> ProjectLocationGitLabConfigCreateCall<'a, C>
14820where
14821 C: common::Connector,
14822{
14823 /// Perform the operation you have build so far.
14824 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
14825 use std::borrow::Cow;
14826 use std::io::{Read, Seek};
14827
14828 use common::{url::Params, ToParts};
14829 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14830
14831 let mut dd = common::DefaultDelegate;
14832 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14833 dlg.begin(common::MethodInfo {
14834 id: "cloudbuild.projects.locations.gitLabConfigs.create",
14835 http_method: hyper::Method::POST,
14836 });
14837
14838 for &field in ["alt", "parent", "gitlabConfigId"].iter() {
14839 if self._additional_params.contains_key(field) {
14840 dlg.finished(false);
14841 return Err(common::Error::FieldClash(field));
14842 }
14843 }
14844
14845 let mut params = Params::with_capacity(5 + self._additional_params.len());
14846 params.push("parent", self._parent);
14847 if let Some(value) = self._gitlab_config_id.as_ref() {
14848 params.push("gitlabConfigId", value);
14849 }
14850
14851 params.extend(self._additional_params.iter());
14852
14853 params.push("alt", "json");
14854 let mut url = self.hub._base_url.clone() + "v1/{+parent}/gitLabConfigs";
14855 if self._scopes.is_empty() {
14856 self._scopes
14857 .insert(Scope::CloudPlatform.as_ref().to_string());
14858 }
14859
14860 #[allow(clippy::single_element_loop)]
14861 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
14862 url = params.uri_replacement(url, param_name, find_this, true);
14863 }
14864 {
14865 let to_remove = ["parent"];
14866 params.remove_params(&to_remove);
14867 }
14868
14869 let url = params.parse_with_url(&url);
14870
14871 let mut json_mime_type = mime::APPLICATION_JSON;
14872 let mut request_value_reader = {
14873 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14874 common::remove_json_null_values(&mut value);
14875 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14876 serde_json::to_writer(&mut dst, &value).unwrap();
14877 dst
14878 };
14879 let request_size = request_value_reader
14880 .seek(std::io::SeekFrom::End(0))
14881 .unwrap();
14882 request_value_reader
14883 .seek(std::io::SeekFrom::Start(0))
14884 .unwrap();
14885
14886 loop {
14887 let token = match self
14888 .hub
14889 .auth
14890 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14891 .await
14892 {
14893 Ok(token) => token,
14894 Err(e) => match dlg.token(e) {
14895 Ok(token) => token,
14896 Err(e) => {
14897 dlg.finished(false);
14898 return Err(common::Error::MissingToken(e));
14899 }
14900 },
14901 };
14902 request_value_reader
14903 .seek(std::io::SeekFrom::Start(0))
14904 .unwrap();
14905 let mut req_result = {
14906 let client = &self.hub.client;
14907 dlg.pre_request();
14908 let mut req_builder = hyper::Request::builder()
14909 .method(hyper::Method::POST)
14910 .uri(url.as_str())
14911 .header(USER_AGENT, self.hub._user_agent.clone());
14912
14913 if let Some(token) = token.as_ref() {
14914 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14915 }
14916
14917 let request = req_builder
14918 .header(CONTENT_TYPE, json_mime_type.to_string())
14919 .header(CONTENT_LENGTH, request_size as u64)
14920 .body(common::to_body(
14921 request_value_reader.get_ref().clone().into(),
14922 ));
14923
14924 client.request(request.unwrap()).await
14925 };
14926
14927 match req_result {
14928 Err(err) => {
14929 if let common::Retry::After(d) = dlg.http_error(&err) {
14930 sleep(d).await;
14931 continue;
14932 }
14933 dlg.finished(false);
14934 return Err(common::Error::HttpError(err));
14935 }
14936 Ok(res) => {
14937 let (mut parts, body) = res.into_parts();
14938 let mut body = common::Body::new(body);
14939 if !parts.status.is_success() {
14940 let bytes = common::to_bytes(body).await.unwrap_or_default();
14941 let error = serde_json::from_str(&common::to_string(&bytes));
14942 let response = common::to_response(parts, bytes.into());
14943
14944 if let common::Retry::After(d) =
14945 dlg.http_failure(&response, error.as_ref().ok())
14946 {
14947 sleep(d).await;
14948 continue;
14949 }
14950
14951 dlg.finished(false);
14952
14953 return Err(match error {
14954 Ok(value) => common::Error::BadRequest(value),
14955 _ => common::Error::Failure(response),
14956 });
14957 }
14958 let response = {
14959 let bytes = common::to_bytes(body).await.unwrap_or_default();
14960 let encoded = common::to_string(&bytes);
14961 match serde_json::from_str(&encoded) {
14962 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14963 Err(error) => {
14964 dlg.response_json_decode_error(&encoded, &error);
14965 return Err(common::Error::JsonDecodeError(
14966 encoded.to_string(),
14967 error,
14968 ));
14969 }
14970 }
14971 };
14972
14973 dlg.finished(true);
14974 return Ok(response);
14975 }
14976 }
14977 }
14978 }
14979
14980 ///
14981 /// Sets the *request* property to the given value.
14982 ///
14983 /// Even though the property as already been set when instantiating this call,
14984 /// we provide this method for API completeness.
14985 pub fn request(
14986 mut self,
14987 new_value: GitLabConfig,
14988 ) -> ProjectLocationGitLabConfigCreateCall<'a, C> {
14989 self._request = new_value;
14990 self
14991 }
14992 /// Required. Name of the parent resource.
14993 ///
14994 /// Sets the *parent* path property to the given value.
14995 ///
14996 /// Even though the property as already been set when instantiating this call,
14997 /// we provide this method for API completeness.
14998 pub fn parent(mut self, new_value: &str) -> ProjectLocationGitLabConfigCreateCall<'a, C> {
14999 self._parent = new_value.to_string();
15000 self
15001 }
15002 /// 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
15003 ///
15004 /// Sets the *gitlab config id* query property to the given value.
15005 pub fn gitlab_config_id(
15006 mut self,
15007 new_value: &str,
15008 ) -> ProjectLocationGitLabConfigCreateCall<'a, C> {
15009 self._gitlab_config_id = Some(new_value.to_string());
15010 self
15011 }
15012 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15013 /// while executing the actual API request.
15014 ///
15015 /// ````text
15016 /// It should be used to handle progress information, and to implement a certain level of resilience.
15017 /// ````
15018 ///
15019 /// Sets the *delegate* property to the given value.
15020 pub fn delegate(
15021 mut self,
15022 new_value: &'a mut dyn common::Delegate,
15023 ) -> ProjectLocationGitLabConfigCreateCall<'a, C> {
15024 self._delegate = Some(new_value);
15025 self
15026 }
15027
15028 /// Set any additional parameter of the query string used in the request.
15029 /// It should be used to set parameters which are not yet available through their own
15030 /// setters.
15031 ///
15032 /// Please note that this method must not be used to set any of the known parameters
15033 /// which have their own setter method. If done anyway, the request will fail.
15034 ///
15035 /// # Additional Parameters
15036 ///
15037 /// * *$.xgafv* (query-string) - V1 error format.
15038 /// * *access_token* (query-string) - OAuth access token.
15039 /// * *alt* (query-string) - Data format for response.
15040 /// * *callback* (query-string) - JSONP
15041 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15042 /// * *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.
15043 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15044 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15045 /// * *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.
15046 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15047 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15048 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGitLabConfigCreateCall<'a, C>
15049 where
15050 T: AsRef<str>,
15051 {
15052 self._additional_params
15053 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15054 self
15055 }
15056
15057 /// Identifies the authorization scope for the method you are building.
15058 ///
15059 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15060 /// [`Scope::CloudPlatform`].
15061 ///
15062 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15063 /// tokens for more than one scope.
15064 ///
15065 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15066 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15067 /// sufficient, a read-write scope will do as well.
15068 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGitLabConfigCreateCall<'a, C>
15069 where
15070 St: AsRef<str>,
15071 {
15072 self._scopes.insert(String::from(scope.as_ref()));
15073 self
15074 }
15075 /// Identifies the authorization scope(s) for the method you are building.
15076 ///
15077 /// See [`Self::add_scope()`] for details.
15078 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGitLabConfigCreateCall<'a, C>
15079 where
15080 I: IntoIterator<Item = St>,
15081 St: AsRef<str>,
15082 {
15083 self._scopes
15084 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15085 self
15086 }
15087
15088 /// Removes all scopes, and no default scope will be used either.
15089 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15090 /// for details).
15091 pub fn clear_scopes(mut self) -> ProjectLocationGitLabConfigCreateCall<'a, C> {
15092 self._scopes.clear();
15093 self
15094 }
15095}
15096
15097/// Delete a `GitLabConfig`. This API is experimental
15098///
15099/// A builder for the *locations.gitLabConfigs.delete* method supported by a *project* resource.
15100/// It is not used directly, but through a [`ProjectMethods`] instance.
15101///
15102/// # Example
15103///
15104/// Instantiate a resource method builder
15105///
15106/// ```test_harness,no_run
15107/// # extern crate hyper;
15108/// # extern crate hyper_rustls;
15109/// # extern crate google_cloudbuild1 as cloudbuild1;
15110/// # async fn dox() {
15111/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15112///
15113/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15114/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15115/// # .with_native_roots()
15116/// # .unwrap()
15117/// # .https_only()
15118/// # .enable_http2()
15119/// # .build();
15120///
15121/// # let executor = hyper_util::rt::TokioExecutor::new();
15122/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15123/// # secret,
15124/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15125/// # yup_oauth2::client::CustomHyperClientBuilder::from(
15126/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
15127/// # ),
15128/// # ).build().await.unwrap();
15129///
15130/// # let client = hyper_util::client::legacy::Client::builder(
15131/// # hyper_util::rt::TokioExecutor::new()
15132/// # )
15133/// # .build(
15134/// # hyper_rustls::HttpsConnectorBuilder::new()
15135/// # .with_native_roots()
15136/// # .unwrap()
15137/// # .https_or_http()
15138/// # .enable_http2()
15139/// # .build()
15140/// # );
15141/// # let mut hub = CloudBuild::new(client, auth);
15142/// // You can configure optional parameters by calling the respective setters at will, and
15143/// // execute the final call using `doit()`.
15144/// // Values shown here are possibly random and not representative !
15145/// let result = hub.projects().locations_git_lab_configs_delete("name")
15146/// .doit().await;
15147/// # }
15148/// ```
15149pub struct ProjectLocationGitLabConfigDeleteCall<'a, C>
15150where
15151 C: 'a,
15152{
15153 hub: &'a CloudBuild<C>,
15154 _name: String,
15155 _delegate: Option<&'a mut dyn common::Delegate>,
15156 _additional_params: HashMap<String, String>,
15157 _scopes: BTreeSet<String>,
15158}
15159
15160impl<'a, C> common::CallBuilder for ProjectLocationGitLabConfigDeleteCall<'a, C> {}
15161
15162impl<'a, C> ProjectLocationGitLabConfigDeleteCall<'a, C>
15163where
15164 C: common::Connector,
15165{
15166 /// Perform the operation you have build so far.
15167 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
15168 use std::borrow::Cow;
15169 use std::io::{Read, Seek};
15170
15171 use common::{url::Params, ToParts};
15172 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15173
15174 let mut dd = common::DefaultDelegate;
15175 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15176 dlg.begin(common::MethodInfo {
15177 id: "cloudbuild.projects.locations.gitLabConfigs.delete",
15178 http_method: hyper::Method::DELETE,
15179 });
15180
15181 for &field in ["alt", "name"].iter() {
15182 if self._additional_params.contains_key(field) {
15183 dlg.finished(false);
15184 return Err(common::Error::FieldClash(field));
15185 }
15186 }
15187
15188 let mut params = Params::with_capacity(3 + self._additional_params.len());
15189 params.push("name", self._name);
15190
15191 params.extend(self._additional_params.iter());
15192
15193 params.push("alt", "json");
15194 let mut url = self.hub._base_url.clone() + "v1/{+name}";
15195 if self._scopes.is_empty() {
15196 self._scopes
15197 .insert(Scope::CloudPlatform.as_ref().to_string());
15198 }
15199
15200 #[allow(clippy::single_element_loop)]
15201 for &(find_this, param_name) in [("{+name}", "name")].iter() {
15202 url = params.uri_replacement(url, param_name, find_this, true);
15203 }
15204 {
15205 let to_remove = ["name"];
15206 params.remove_params(&to_remove);
15207 }
15208
15209 let url = params.parse_with_url(&url);
15210
15211 loop {
15212 let token = match self
15213 .hub
15214 .auth
15215 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15216 .await
15217 {
15218 Ok(token) => token,
15219 Err(e) => match dlg.token(e) {
15220 Ok(token) => token,
15221 Err(e) => {
15222 dlg.finished(false);
15223 return Err(common::Error::MissingToken(e));
15224 }
15225 },
15226 };
15227 let mut req_result = {
15228 let client = &self.hub.client;
15229 dlg.pre_request();
15230 let mut req_builder = hyper::Request::builder()
15231 .method(hyper::Method::DELETE)
15232 .uri(url.as_str())
15233 .header(USER_AGENT, self.hub._user_agent.clone());
15234
15235 if let Some(token) = token.as_ref() {
15236 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15237 }
15238
15239 let request = req_builder
15240 .header(CONTENT_LENGTH, 0_u64)
15241 .body(common::to_body::<String>(None));
15242
15243 client.request(request.unwrap()).await
15244 };
15245
15246 match req_result {
15247 Err(err) => {
15248 if let common::Retry::After(d) = dlg.http_error(&err) {
15249 sleep(d).await;
15250 continue;
15251 }
15252 dlg.finished(false);
15253 return Err(common::Error::HttpError(err));
15254 }
15255 Ok(res) => {
15256 let (mut parts, body) = res.into_parts();
15257 let mut body = common::Body::new(body);
15258 if !parts.status.is_success() {
15259 let bytes = common::to_bytes(body).await.unwrap_or_default();
15260 let error = serde_json::from_str(&common::to_string(&bytes));
15261 let response = common::to_response(parts, bytes.into());
15262
15263 if let common::Retry::After(d) =
15264 dlg.http_failure(&response, error.as_ref().ok())
15265 {
15266 sleep(d).await;
15267 continue;
15268 }
15269
15270 dlg.finished(false);
15271
15272 return Err(match error {
15273 Ok(value) => common::Error::BadRequest(value),
15274 _ => common::Error::Failure(response),
15275 });
15276 }
15277 let response = {
15278 let bytes = common::to_bytes(body).await.unwrap_or_default();
15279 let encoded = common::to_string(&bytes);
15280 match serde_json::from_str(&encoded) {
15281 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15282 Err(error) => {
15283 dlg.response_json_decode_error(&encoded, &error);
15284 return Err(common::Error::JsonDecodeError(
15285 encoded.to_string(),
15286 error,
15287 ));
15288 }
15289 }
15290 };
15291
15292 dlg.finished(true);
15293 return Ok(response);
15294 }
15295 }
15296 }
15297 }
15298
15299 /// Required. The config resource name.
15300 ///
15301 /// Sets the *name* path property to the given value.
15302 ///
15303 /// Even though the property as already been set when instantiating this call,
15304 /// we provide this method for API completeness.
15305 pub fn name(mut self, new_value: &str) -> ProjectLocationGitLabConfigDeleteCall<'a, C> {
15306 self._name = new_value.to_string();
15307 self
15308 }
15309 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15310 /// while executing the actual API request.
15311 ///
15312 /// ````text
15313 /// It should be used to handle progress information, and to implement a certain level of resilience.
15314 /// ````
15315 ///
15316 /// Sets the *delegate* property to the given value.
15317 pub fn delegate(
15318 mut self,
15319 new_value: &'a mut dyn common::Delegate,
15320 ) -> ProjectLocationGitLabConfigDeleteCall<'a, C> {
15321 self._delegate = Some(new_value);
15322 self
15323 }
15324
15325 /// Set any additional parameter of the query string used in the request.
15326 /// It should be used to set parameters which are not yet available through their own
15327 /// setters.
15328 ///
15329 /// Please note that this method must not be used to set any of the known parameters
15330 /// which have their own setter method. If done anyway, the request will fail.
15331 ///
15332 /// # Additional Parameters
15333 ///
15334 /// * *$.xgafv* (query-string) - V1 error format.
15335 /// * *access_token* (query-string) - OAuth access token.
15336 /// * *alt* (query-string) - Data format for response.
15337 /// * *callback* (query-string) - JSONP
15338 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15339 /// * *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.
15340 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15341 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15342 /// * *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.
15343 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15344 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15345 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGitLabConfigDeleteCall<'a, C>
15346 where
15347 T: AsRef<str>,
15348 {
15349 self._additional_params
15350 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15351 self
15352 }
15353
15354 /// Identifies the authorization scope for the method you are building.
15355 ///
15356 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15357 /// [`Scope::CloudPlatform`].
15358 ///
15359 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15360 /// tokens for more than one scope.
15361 ///
15362 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15363 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15364 /// sufficient, a read-write scope will do as well.
15365 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGitLabConfigDeleteCall<'a, C>
15366 where
15367 St: AsRef<str>,
15368 {
15369 self._scopes.insert(String::from(scope.as_ref()));
15370 self
15371 }
15372 /// Identifies the authorization scope(s) for the method you are building.
15373 ///
15374 /// See [`Self::add_scope()`] for details.
15375 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGitLabConfigDeleteCall<'a, C>
15376 where
15377 I: IntoIterator<Item = St>,
15378 St: AsRef<str>,
15379 {
15380 self._scopes
15381 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15382 self
15383 }
15384
15385 /// Removes all scopes, and no default scope will be used either.
15386 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15387 /// for details).
15388 pub fn clear_scopes(mut self) -> ProjectLocationGitLabConfigDeleteCall<'a, C> {
15389 self._scopes.clear();
15390 self
15391 }
15392}
15393
15394/// Retrieves a `GitLabConfig`. This API is experimental
15395///
15396/// A builder for the *locations.gitLabConfigs.get* method supported by a *project* resource.
15397/// It is not used directly, but through a [`ProjectMethods`] instance.
15398///
15399/// # Example
15400///
15401/// Instantiate a resource method builder
15402///
15403/// ```test_harness,no_run
15404/// # extern crate hyper;
15405/// # extern crate hyper_rustls;
15406/// # extern crate google_cloudbuild1 as cloudbuild1;
15407/// # async fn dox() {
15408/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15409///
15410/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15411/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15412/// # .with_native_roots()
15413/// # .unwrap()
15414/// # .https_only()
15415/// # .enable_http2()
15416/// # .build();
15417///
15418/// # let executor = hyper_util::rt::TokioExecutor::new();
15419/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15420/// # secret,
15421/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15422/// # yup_oauth2::client::CustomHyperClientBuilder::from(
15423/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
15424/// # ),
15425/// # ).build().await.unwrap();
15426///
15427/// # let client = hyper_util::client::legacy::Client::builder(
15428/// # hyper_util::rt::TokioExecutor::new()
15429/// # )
15430/// # .build(
15431/// # hyper_rustls::HttpsConnectorBuilder::new()
15432/// # .with_native_roots()
15433/// # .unwrap()
15434/// # .https_or_http()
15435/// # .enable_http2()
15436/// # .build()
15437/// # );
15438/// # let mut hub = CloudBuild::new(client, auth);
15439/// // You can configure optional parameters by calling the respective setters at will, and
15440/// // execute the final call using `doit()`.
15441/// // Values shown here are possibly random and not representative !
15442/// let result = hub.projects().locations_git_lab_configs_get("name")
15443/// .doit().await;
15444/// # }
15445/// ```
15446pub struct ProjectLocationGitLabConfigGetCall<'a, C>
15447where
15448 C: 'a,
15449{
15450 hub: &'a CloudBuild<C>,
15451 _name: String,
15452 _delegate: Option<&'a mut dyn common::Delegate>,
15453 _additional_params: HashMap<String, String>,
15454 _scopes: BTreeSet<String>,
15455}
15456
15457impl<'a, C> common::CallBuilder for ProjectLocationGitLabConfigGetCall<'a, C> {}
15458
15459impl<'a, C> ProjectLocationGitLabConfigGetCall<'a, C>
15460where
15461 C: common::Connector,
15462{
15463 /// Perform the operation you have build so far.
15464 pub async fn doit(mut self) -> common::Result<(common::Response, GitLabConfig)> {
15465 use std::borrow::Cow;
15466 use std::io::{Read, Seek};
15467
15468 use common::{url::Params, ToParts};
15469 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15470
15471 let mut dd = common::DefaultDelegate;
15472 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15473 dlg.begin(common::MethodInfo {
15474 id: "cloudbuild.projects.locations.gitLabConfigs.get",
15475 http_method: hyper::Method::GET,
15476 });
15477
15478 for &field in ["alt", "name"].iter() {
15479 if self._additional_params.contains_key(field) {
15480 dlg.finished(false);
15481 return Err(common::Error::FieldClash(field));
15482 }
15483 }
15484
15485 let mut params = Params::with_capacity(3 + self._additional_params.len());
15486 params.push("name", self._name);
15487
15488 params.extend(self._additional_params.iter());
15489
15490 params.push("alt", "json");
15491 let mut url = self.hub._base_url.clone() + "v1/{+name}";
15492 if self._scopes.is_empty() {
15493 self._scopes
15494 .insert(Scope::CloudPlatform.as_ref().to_string());
15495 }
15496
15497 #[allow(clippy::single_element_loop)]
15498 for &(find_this, param_name) in [("{+name}", "name")].iter() {
15499 url = params.uri_replacement(url, param_name, find_this, true);
15500 }
15501 {
15502 let to_remove = ["name"];
15503 params.remove_params(&to_remove);
15504 }
15505
15506 let url = params.parse_with_url(&url);
15507
15508 loop {
15509 let token = match self
15510 .hub
15511 .auth
15512 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15513 .await
15514 {
15515 Ok(token) => token,
15516 Err(e) => match dlg.token(e) {
15517 Ok(token) => token,
15518 Err(e) => {
15519 dlg.finished(false);
15520 return Err(common::Error::MissingToken(e));
15521 }
15522 },
15523 };
15524 let mut req_result = {
15525 let client = &self.hub.client;
15526 dlg.pre_request();
15527 let mut req_builder = hyper::Request::builder()
15528 .method(hyper::Method::GET)
15529 .uri(url.as_str())
15530 .header(USER_AGENT, self.hub._user_agent.clone());
15531
15532 if let Some(token) = token.as_ref() {
15533 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15534 }
15535
15536 let request = req_builder
15537 .header(CONTENT_LENGTH, 0_u64)
15538 .body(common::to_body::<String>(None));
15539
15540 client.request(request.unwrap()).await
15541 };
15542
15543 match req_result {
15544 Err(err) => {
15545 if let common::Retry::After(d) = dlg.http_error(&err) {
15546 sleep(d).await;
15547 continue;
15548 }
15549 dlg.finished(false);
15550 return Err(common::Error::HttpError(err));
15551 }
15552 Ok(res) => {
15553 let (mut parts, body) = res.into_parts();
15554 let mut body = common::Body::new(body);
15555 if !parts.status.is_success() {
15556 let bytes = common::to_bytes(body).await.unwrap_or_default();
15557 let error = serde_json::from_str(&common::to_string(&bytes));
15558 let response = common::to_response(parts, bytes.into());
15559
15560 if let common::Retry::After(d) =
15561 dlg.http_failure(&response, error.as_ref().ok())
15562 {
15563 sleep(d).await;
15564 continue;
15565 }
15566
15567 dlg.finished(false);
15568
15569 return Err(match error {
15570 Ok(value) => common::Error::BadRequest(value),
15571 _ => common::Error::Failure(response),
15572 });
15573 }
15574 let response = {
15575 let bytes = common::to_bytes(body).await.unwrap_or_default();
15576 let encoded = common::to_string(&bytes);
15577 match serde_json::from_str(&encoded) {
15578 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15579 Err(error) => {
15580 dlg.response_json_decode_error(&encoded, &error);
15581 return Err(common::Error::JsonDecodeError(
15582 encoded.to_string(),
15583 error,
15584 ));
15585 }
15586 }
15587 };
15588
15589 dlg.finished(true);
15590 return Ok(response);
15591 }
15592 }
15593 }
15594 }
15595
15596 /// Required. The config resource name.
15597 ///
15598 /// Sets the *name* path property to the given value.
15599 ///
15600 /// Even though the property as already been set when instantiating this call,
15601 /// we provide this method for API completeness.
15602 pub fn name(mut self, new_value: &str) -> ProjectLocationGitLabConfigGetCall<'a, C> {
15603 self._name = new_value.to_string();
15604 self
15605 }
15606 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15607 /// while executing the actual API request.
15608 ///
15609 /// ````text
15610 /// It should be used to handle progress information, and to implement a certain level of resilience.
15611 /// ````
15612 ///
15613 /// Sets the *delegate* property to the given value.
15614 pub fn delegate(
15615 mut self,
15616 new_value: &'a mut dyn common::Delegate,
15617 ) -> ProjectLocationGitLabConfigGetCall<'a, C> {
15618 self._delegate = Some(new_value);
15619 self
15620 }
15621
15622 /// Set any additional parameter of the query string used in the request.
15623 /// It should be used to set parameters which are not yet available through their own
15624 /// setters.
15625 ///
15626 /// Please note that this method must not be used to set any of the known parameters
15627 /// which have their own setter method. If done anyway, the request will fail.
15628 ///
15629 /// # Additional Parameters
15630 ///
15631 /// * *$.xgafv* (query-string) - V1 error format.
15632 /// * *access_token* (query-string) - OAuth access token.
15633 /// * *alt* (query-string) - Data format for response.
15634 /// * *callback* (query-string) - JSONP
15635 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15636 /// * *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.
15637 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15638 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15639 /// * *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.
15640 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15641 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15642 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGitLabConfigGetCall<'a, C>
15643 where
15644 T: AsRef<str>,
15645 {
15646 self._additional_params
15647 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15648 self
15649 }
15650
15651 /// Identifies the authorization scope for the method you are building.
15652 ///
15653 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15654 /// [`Scope::CloudPlatform`].
15655 ///
15656 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15657 /// tokens for more than one scope.
15658 ///
15659 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15660 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15661 /// sufficient, a read-write scope will do as well.
15662 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGitLabConfigGetCall<'a, C>
15663 where
15664 St: AsRef<str>,
15665 {
15666 self._scopes.insert(String::from(scope.as_ref()));
15667 self
15668 }
15669 /// Identifies the authorization scope(s) for the method you are building.
15670 ///
15671 /// See [`Self::add_scope()`] for details.
15672 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGitLabConfigGetCall<'a, C>
15673 where
15674 I: IntoIterator<Item = St>,
15675 St: AsRef<str>,
15676 {
15677 self._scopes
15678 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15679 self
15680 }
15681
15682 /// Removes all scopes, and no default scope will be used either.
15683 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15684 /// for details).
15685 pub fn clear_scopes(mut self) -> ProjectLocationGitLabConfigGetCall<'a, C> {
15686 self._scopes.clear();
15687 self
15688 }
15689}
15690
15691/// List all `GitLabConfigs` for a given project. This API is experimental
15692///
15693/// A builder for the *locations.gitLabConfigs.list* method supported by a *project* resource.
15694/// It is not used directly, but through a [`ProjectMethods`] instance.
15695///
15696/// # Example
15697///
15698/// Instantiate a resource method builder
15699///
15700/// ```test_harness,no_run
15701/// # extern crate hyper;
15702/// # extern crate hyper_rustls;
15703/// # extern crate google_cloudbuild1 as cloudbuild1;
15704/// # async fn dox() {
15705/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15706///
15707/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15708/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15709/// # .with_native_roots()
15710/// # .unwrap()
15711/// # .https_only()
15712/// # .enable_http2()
15713/// # .build();
15714///
15715/// # let executor = hyper_util::rt::TokioExecutor::new();
15716/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15717/// # secret,
15718/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15719/// # yup_oauth2::client::CustomHyperClientBuilder::from(
15720/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
15721/// # ),
15722/// # ).build().await.unwrap();
15723///
15724/// # let client = hyper_util::client::legacy::Client::builder(
15725/// # hyper_util::rt::TokioExecutor::new()
15726/// # )
15727/// # .build(
15728/// # hyper_rustls::HttpsConnectorBuilder::new()
15729/// # .with_native_roots()
15730/// # .unwrap()
15731/// # .https_or_http()
15732/// # .enable_http2()
15733/// # .build()
15734/// # );
15735/// # let mut hub = CloudBuild::new(client, auth);
15736/// // You can configure optional parameters by calling the respective setters at will, and
15737/// // execute the final call using `doit()`.
15738/// // Values shown here are possibly random and not representative !
15739/// let result = hub.projects().locations_git_lab_configs_list("parent")
15740/// .page_token("takimata")
15741/// .page_size(-46)
15742/// .doit().await;
15743/// # }
15744/// ```
15745pub struct ProjectLocationGitLabConfigListCall<'a, C>
15746where
15747 C: 'a,
15748{
15749 hub: &'a CloudBuild<C>,
15750 _parent: String,
15751 _page_token: Option<String>,
15752 _page_size: Option<i32>,
15753 _delegate: Option<&'a mut dyn common::Delegate>,
15754 _additional_params: HashMap<String, String>,
15755 _scopes: BTreeSet<String>,
15756}
15757
15758impl<'a, C> common::CallBuilder for ProjectLocationGitLabConfigListCall<'a, C> {}
15759
15760impl<'a, C> ProjectLocationGitLabConfigListCall<'a, C>
15761where
15762 C: common::Connector,
15763{
15764 /// Perform the operation you have build so far.
15765 pub async fn doit(mut self) -> common::Result<(common::Response, ListGitLabConfigsResponse)> {
15766 use std::borrow::Cow;
15767 use std::io::{Read, Seek};
15768
15769 use common::{url::Params, ToParts};
15770 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15771
15772 let mut dd = common::DefaultDelegate;
15773 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15774 dlg.begin(common::MethodInfo {
15775 id: "cloudbuild.projects.locations.gitLabConfigs.list",
15776 http_method: hyper::Method::GET,
15777 });
15778
15779 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
15780 if self._additional_params.contains_key(field) {
15781 dlg.finished(false);
15782 return Err(common::Error::FieldClash(field));
15783 }
15784 }
15785
15786 let mut params = Params::with_capacity(5 + self._additional_params.len());
15787 params.push("parent", self._parent);
15788 if let Some(value) = self._page_token.as_ref() {
15789 params.push("pageToken", value);
15790 }
15791 if let Some(value) = self._page_size.as_ref() {
15792 params.push("pageSize", value.to_string());
15793 }
15794
15795 params.extend(self._additional_params.iter());
15796
15797 params.push("alt", "json");
15798 let mut url = self.hub._base_url.clone() + "v1/{+parent}/gitLabConfigs";
15799 if self._scopes.is_empty() {
15800 self._scopes
15801 .insert(Scope::CloudPlatform.as_ref().to_string());
15802 }
15803
15804 #[allow(clippy::single_element_loop)]
15805 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
15806 url = params.uri_replacement(url, param_name, find_this, true);
15807 }
15808 {
15809 let to_remove = ["parent"];
15810 params.remove_params(&to_remove);
15811 }
15812
15813 let url = params.parse_with_url(&url);
15814
15815 loop {
15816 let token = match self
15817 .hub
15818 .auth
15819 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15820 .await
15821 {
15822 Ok(token) => token,
15823 Err(e) => match dlg.token(e) {
15824 Ok(token) => token,
15825 Err(e) => {
15826 dlg.finished(false);
15827 return Err(common::Error::MissingToken(e));
15828 }
15829 },
15830 };
15831 let mut req_result = {
15832 let client = &self.hub.client;
15833 dlg.pre_request();
15834 let mut req_builder = hyper::Request::builder()
15835 .method(hyper::Method::GET)
15836 .uri(url.as_str())
15837 .header(USER_AGENT, self.hub._user_agent.clone());
15838
15839 if let Some(token) = token.as_ref() {
15840 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15841 }
15842
15843 let request = req_builder
15844 .header(CONTENT_LENGTH, 0_u64)
15845 .body(common::to_body::<String>(None));
15846
15847 client.request(request.unwrap()).await
15848 };
15849
15850 match req_result {
15851 Err(err) => {
15852 if let common::Retry::After(d) = dlg.http_error(&err) {
15853 sleep(d).await;
15854 continue;
15855 }
15856 dlg.finished(false);
15857 return Err(common::Error::HttpError(err));
15858 }
15859 Ok(res) => {
15860 let (mut parts, body) = res.into_parts();
15861 let mut body = common::Body::new(body);
15862 if !parts.status.is_success() {
15863 let bytes = common::to_bytes(body).await.unwrap_or_default();
15864 let error = serde_json::from_str(&common::to_string(&bytes));
15865 let response = common::to_response(parts, bytes.into());
15866
15867 if let common::Retry::After(d) =
15868 dlg.http_failure(&response, error.as_ref().ok())
15869 {
15870 sleep(d).await;
15871 continue;
15872 }
15873
15874 dlg.finished(false);
15875
15876 return Err(match error {
15877 Ok(value) => common::Error::BadRequest(value),
15878 _ => common::Error::Failure(response),
15879 });
15880 }
15881 let response = {
15882 let bytes = common::to_bytes(body).await.unwrap_or_default();
15883 let encoded = common::to_string(&bytes);
15884 match serde_json::from_str(&encoded) {
15885 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15886 Err(error) => {
15887 dlg.response_json_decode_error(&encoded, &error);
15888 return Err(common::Error::JsonDecodeError(
15889 encoded.to_string(),
15890 error,
15891 ));
15892 }
15893 }
15894 };
15895
15896 dlg.finished(true);
15897 return Ok(response);
15898 }
15899 }
15900 }
15901 }
15902
15903 /// Required. Name of the parent resource
15904 ///
15905 /// Sets the *parent* path property to the given value.
15906 ///
15907 /// Even though the property as already been set when instantiating this call,
15908 /// we provide this method for API completeness.
15909 pub fn parent(mut self, new_value: &str) -> ProjectLocationGitLabConfigListCall<'a, C> {
15910 self._parent = new_value.to_string();
15911 self
15912 }
15913 /// 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.
15914 ///
15915 /// Sets the *page token* query property to the given value.
15916 pub fn page_token(mut self, new_value: &str) -> ProjectLocationGitLabConfigListCall<'a, C> {
15917 self._page_token = Some(new_value.to_string());
15918 self
15919 }
15920 /// 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.
15921 ///
15922 /// Sets the *page size* query property to the given value.
15923 pub fn page_size(mut self, new_value: i32) -> ProjectLocationGitLabConfigListCall<'a, C> {
15924 self._page_size = Some(new_value);
15925 self
15926 }
15927 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15928 /// while executing the actual API request.
15929 ///
15930 /// ````text
15931 /// It should be used to handle progress information, and to implement a certain level of resilience.
15932 /// ````
15933 ///
15934 /// Sets the *delegate* property to the given value.
15935 pub fn delegate(
15936 mut self,
15937 new_value: &'a mut dyn common::Delegate,
15938 ) -> ProjectLocationGitLabConfigListCall<'a, C> {
15939 self._delegate = Some(new_value);
15940 self
15941 }
15942
15943 /// Set any additional parameter of the query string used in the request.
15944 /// It should be used to set parameters which are not yet available through their own
15945 /// setters.
15946 ///
15947 /// Please note that this method must not be used to set any of the known parameters
15948 /// which have their own setter method. If done anyway, the request will fail.
15949 ///
15950 /// # Additional Parameters
15951 ///
15952 /// * *$.xgafv* (query-string) - V1 error format.
15953 /// * *access_token* (query-string) - OAuth access token.
15954 /// * *alt* (query-string) - Data format for response.
15955 /// * *callback* (query-string) - JSONP
15956 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15957 /// * *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.
15958 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15959 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15960 /// * *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.
15961 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15962 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15963 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGitLabConfigListCall<'a, C>
15964 where
15965 T: AsRef<str>,
15966 {
15967 self._additional_params
15968 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15969 self
15970 }
15971
15972 /// Identifies the authorization scope for the method you are building.
15973 ///
15974 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15975 /// [`Scope::CloudPlatform`].
15976 ///
15977 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15978 /// tokens for more than one scope.
15979 ///
15980 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15981 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15982 /// sufficient, a read-write scope will do as well.
15983 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGitLabConfigListCall<'a, C>
15984 where
15985 St: AsRef<str>,
15986 {
15987 self._scopes.insert(String::from(scope.as_ref()));
15988 self
15989 }
15990 /// Identifies the authorization scope(s) for the method you are building.
15991 ///
15992 /// See [`Self::add_scope()`] for details.
15993 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGitLabConfigListCall<'a, C>
15994 where
15995 I: IntoIterator<Item = St>,
15996 St: AsRef<str>,
15997 {
15998 self._scopes
15999 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16000 self
16001 }
16002
16003 /// Removes all scopes, and no default scope will be used either.
16004 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16005 /// for details).
16006 pub fn clear_scopes(mut self) -> ProjectLocationGitLabConfigListCall<'a, C> {
16007 self._scopes.clear();
16008 self
16009 }
16010}
16011
16012/// Updates an existing `GitLabConfig`. This API is experimental
16013///
16014/// A builder for the *locations.gitLabConfigs.patch* method supported by a *project* resource.
16015/// It is not used directly, but through a [`ProjectMethods`] instance.
16016///
16017/// # Example
16018///
16019/// Instantiate a resource method builder
16020///
16021/// ```test_harness,no_run
16022/// # extern crate hyper;
16023/// # extern crate hyper_rustls;
16024/// # extern crate google_cloudbuild1 as cloudbuild1;
16025/// use cloudbuild1::api::GitLabConfig;
16026/// # async fn dox() {
16027/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16028///
16029/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16030/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16031/// # .with_native_roots()
16032/// # .unwrap()
16033/// # .https_only()
16034/// # .enable_http2()
16035/// # .build();
16036///
16037/// # let executor = hyper_util::rt::TokioExecutor::new();
16038/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16039/// # secret,
16040/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16041/// # yup_oauth2::client::CustomHyperClientBuilder::from(
16042/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
16043/// # ),
16044/// # ).build().await.unwrap();
16045///
16046/// # let client = hyper_util::client::legacy::Client::builder(
16047/// # hyper_util::rt::TokioExecutor::new()
16048/// # )
16049/// # .build(
16050/// # hyper_rustls::HttpsConnectorBuilder::new()
16051/// # .with_native_roots()
16052/// # .unwrap()
16053/// # .https_or_http()
16054/// # .enable_http2()
16055/// # .build()
16056/// # );
16057/// # let mut hub = CloudBuild::new(client, auth);
16058/// // As the method needs a request, you would usually fill it with the desired information
16059/// // into the respective structure. Some of the parts shown here might not be applicable !
16060/// // Values shown here are possibly random and not representative !
16061/// let mut req = GitLabConfig::default();
16062///
16063/// // You can configure optional parameters by calling the respective setters at will, and
16064/// // execute the final call using `doit()`.
16065/// // Values shown here are possibly random and not representative !
16066/// let result = hub.projects().locations_git_lab_configs_patch(req, "name")
16067/// .update_mask(FieldMask::new::<&str>(&[]))
16068/// .doit().await;
16069/// # }
16070/// ```
16071pub struct ProjectLocationGitLabConfigPatchCall<'a, C>
16072where
16073 C: 'a,
16074{
16075 hub: &'a CloudBuild<C>,
16076 _request: GitLabConfig,
16077 _name: String,
16078 _update_mask: Option<common::FieldMask>,
16079 _delegate: Option<&'a mut dyn common::Delegate>,
16080 _additional_params: HashMap<String, String>,
16081 _scopes: BTreeSet<String>,
16082}
16083
16084impl<'a, C> common::CallBuilder for ProjectLocationGitLabConfigPatchCall<'a, C> {}
16085
16086impl<'a, C> ProjectLocationGitLabConfigPatchCall<'a, C>
16087where
16088 C: common::Connector,
16089{
16090 /// Perform the operation you have build so far.
16091 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
16092 use std::borrow::Cow;
16093 use std::io::{Read, Seek};
16094
16095 use common::{url::Params, ToParts};
16096 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16097
16098 let mut dd = common::DefaultDelegate;
16099 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16100 dlg.begin(common::MethodInfo {
16101 id: "cloudbuild.projects.locations.gitLabConfigs.patch",
16102 http_method: hyper::Method::PATCH,
16103 });
16104
16105 for &field in ["alt", "name", "updateMask"].iter() {
16106 if self._additional_params.contains_key(field) {
16107 dlg.finished(false);
16108 return Err(common::Error::FieldClash(field));
16109 }
16110 }
16111
16112 let mut params = Params::with_capacity(5 + self._additional_params.len());
16113 params.push("name", self._name);
16114 if let Some(value) = self._update_mask.as_ref() {
16115 params.push("updateMask", value.to_string());
16116 }
16117
16118 params.extend(self._additional_params.iter());
16119
16120 params.push("alt", "json");
16121 let mut url = self.hub._base_url.clone() + "v1/{+name}";
16122 if self._scopes.is_empty() {
16123 self._scopes
16124 .insert(Scope::CloudPlatform.as_ref().to_string());
16125 }
16126
16127 #[allow(clippy::single_element_loop)]
16128 for &(find_this, param_name) in [("{+name}", "name")].iter() {
16129 url = params.uri_replacement(url, param_name, find_this, true);
16130 }
16131 {
16132 let to_remove = ["name"];
16133 params.remove_params(&to_remove);
16134 }
16135
16136 let url = params.parse_with_url(&url);
16137
16138 let mut json_mime_type = mime::APPLICATION_JSON;
16139 let mut request_value_reader = {
16140 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16141 common::remove_json_null_values(&mut value);
16142 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16143 serde_json::to_writer(&mut dst, &value).unwrap();
16144 dst
16145 };
16146 let request_size = request_value_reader
16147 .seek(std::io::SeekFrom::End(0))
16148 .unwrap();
16149 request_value_reader
16150 .seek(std::io::SeekFrom::Start(0))
16151 .unwrap();
16152
16153 loop {
16154 let token = match self
16155 .hub
16156 .auth
16157 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16158 .await
16159 {
16160 Ok(token) => token,
16161 Err(e) => match dlg.token(e) {
16162 Ok(token) => token,
16163 Err(e) => {
16164 dlg.finished(false);
16165 return Err(common::Error::MissingToken(e));
16166 }
16167 },
16168 };
16169 request_value_reader
16170 .seek(std::io::SeekFrom::Start(0))
16171 .unwrap();
16172 let mut req_result = {
16173 let client = &self.hub.client;
16174 dlg.pre_request();
16175 let mut req_builder = hyper::Request::builder()
16176 .method(hyper::Method::PATCH)
16177 .uri(url.as_str())
16178 .header(USER_AGENT, self.hub._user_agent.clone());
16179
16180 if let Some(token) = token.as_ref() {
16181 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16182 }
16183
16184 let request = req_builder
16185 .header(CONTENT_TYPE, json_mime_type.to_string())
16186 .header(CONTENT_LENGTH, request_size as u64)
16187 .body(common::to_body(
16188 request_value_reader.get_ref().clone().into(),
16189 ));
16190
16191 client.request(request.unwrap()).await
16192 };
16193
16194 match req_result {
16195 Err(err) => {
16196 if let common::Retry::After(d) = dlg.http_error(&err) {
16197 sleep(d).await;
16198 continue;
16199 }
16200 dlg.finished(false);
16201 return Err(common::Error::HttpError(err));
16202 }
16203 Ok(res) => {
16204 let (mut parts, body) = res.into_parts();
16205 let mut body = common::Body::new(body);
16206 if !parts.status.is_success() {
16207 let bytes = common::to_bytes(body).await.unwrap_or_default();
16208 let error = serde_json::from_str(&common::to_string(&bytes));
16209 let response = common::to_response(parts, bytes.into());
16210
16211 if let common::Retry::After(d) =
16212 dlg.http_failure(&response, error.as_ref().ok())
16213 {
16214 sleep(d).await;
16215 continue;
16216 }
16217
16218 dlg.finished(false);
16219
16220 return Err(match error {
16221 Ok(value) => common::Error::BadRequest(value),
16222 _ => common::Error::Failure(response),
16223 });
16224 }
16225 let response = {
16226 let bytes = common::to_bytes(body).await.unwrap_or_default();
16227 let encoded = common::to_string(&bytes);
16228 match serde_json::from_str(&encoded) {
16229 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16230 Err(error) => {
16231 dlg.response_json_decode_error(&encoded, &error);
16232 return Err(common::Error::JsonDecodeError(
16233 encoded.to_string(),
16234 error,
16235 ));
16236 }
16237 }
16238 };
16239
16240 dlg.finished(true);
16241 return Ok(response);
16242 }
16243 }
16244 }
16245 }
16246
16247 ///
16248 /// Sets the *request* property to the given value.
16249 ///
16250 /// Even though the property as already been set when instantiating this call,
16251 /// we provide this method for API completeness.
16252 pub fn request(
16253 mut self,
16254 new_value: GitLabConfig,
16255 ) -> ProjectLocationGitLabConfigPatchCall<'a, C> {
16256 self._request = new_value;
16257 self
16258 }
16259 /// The resource name for the config.
16260 ///
16261 /// Sets the *name* path property to the given value.
16262 ///
16263 /// Even though the property as already been set when instantiating this call,
16264 /// we provide this method for API completeness.
16265 pub fn name(mut self, new_value: &str) -> ProjectLocationGitLabConfigPatchCall<'a, C> {
16266 self._name = new_value.to_string();
16267 self
16268 }
16269 /// 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.
16270 ///
16271 /// Sets the *update mask* query property to the given value.
16272 pub fn update_mask(
16273 mut self,
16274 new_value: common::FieldMask,
16275 ) -> ProjectLocationGitLabConfigPatchCall<'a, C> {
16276 self._update_mask = Some(new_value);
16277 self
16278 }
16279 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16280 /// while executing the actual API request.
16281 ///
16282 /// ````text
16283 /// It should be used to handle progress information, and to implement a certain level of resilience.
16284 /// ````
16285 ///
16286 /// Sets the *delegate* property to the given value.
16287 pub fn delegate(
16288 mut self,
16289 new_value: &'a mut dyn common::Delegate,
16290 ) -> ProjectLocationGitLabConfigPatchCall<'a, C> {
16291 self._delegate = Some(new_value);
16292 self
16293 }
16294
16295 /// Set any additional parameter of the query string used in the request.
16296 /// It should be used to set parameters which are not yet available through their own
16297 /// setters.
16298 ///
16299 /// Please note that this method must not be used to set any of the known parameters
16300 /// which have their own setter method. If done anyway, the request will fail.
16301 ///
16302 /// # Additional Parameters
16303 ///
16304 /// * *$.xgafv* (query-string) - V1 error format.
16305 /// * *access_token* (query-string) - OAuth access token.
16306 /// * *alt* (query-string) - Data format for response.
16307 /// * *callback* (query-string) - JSONP
16308 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16309 /// * *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.
16310 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16311 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16312 /// * *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.
16313 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16314 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16315 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGitLabConfigPatchCall<'a, C>
16316 where
16317 T: AsRef<str>,
16318 {
16319 self._additional_params
16320 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16321 self
16322 }
16323
16324 /// Identifies the authorization scope for the method you are building.
16325 ///
16326 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16327 /// [`Scope::CloudPlatform`].
16328 ///
16329 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16330 /// tokens for more than one scope.
16331 ///
16332 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16333 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16334 /// sufficient, a read-write scope will do as well.
16335 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGitLabConfigPatchCall<'a, C>
16336 where
16337 St: AsRef<str>,
16338 {
16339 self._scopes.insert(String::from(scope.as_ref()));
16340 self
16341 }
16342 /// Identifies the authorization scope(s) for the method you are building.
16343 ///
16344 /// See [`Self::add_scope()`] for details.
16345 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGitLabConfigPatchCall<'a, C>
16346 where
16347 I: IntoIterator<Item = St>,
16348 St: AsRef<str>,
16349 {
16350 self._scopes
16351 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16352 self
16353 }
16354
16355 /// Removes all scopes, and no default scope will be used either.
16356 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16357 /// for details).
16358 pub fn clear_scopes(mut self) -> ProjectLocationGitLabConfigPatchCall<'a, C> {
16359 self._scopes.clear();
16360 self
16361 }
16362}
16363
16364/// Remove a GitLab repository from a given GitLabConfig's connected repositories. This API is experimental.
16365///
16366/// A builder for the *locations.gitLabConfigs.removeGitLabConnectedRepository* method supported by a *project* resource.
16367/// It is not used directly, but through a [`ProjectMethods`] instance.
16368///
16369/// # Example
16370///
16371/// Instantiate a resource method builder
16372///
16373/// ```test_harness,no_run
16374/// # extern crate hyper;
16375/// # extern crate hyper_rustls;
16376/// # extern crate google_cloudbuild1 as cloudbuild1;
16377/// use cloudbuild1::api::RemoveGitLabConnectedRepositoryRequest;
16378/// # async fn dox() {
16379/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16380///
16381/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16382/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16383/// # .with_native_roots()
16384/// # .unwrap()
16385/// # .https_only()
16386/// # .enable_http2()
16387/// # .build();
16388///
16389/// # let executor = hyper_util::rt::TokioExecutor::new();
16390/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16391/// # secret,
16392/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16393/// # yup_oauth2::client::CustomHyperClientBuilder::from(
16394/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
16395/// # ),
16396/// # ).build().await.unwrap();
16397///
16398/// # let client = hyper_util::client::legacy::Client::builder(
16399/// # hyper_util::rt::TokioExecutor::new()
16400/// # )
16401/// # .build(
16402/// # hyper_rustls::HttpsConnectorBuilder::new()
16403/// # .with_native_roots()
16404/// # .unwrap()
16405/// # .https_or_http()
16406/// # .enable_http2()
16407/// # .build()
16408/// # );
16409/// # let mut hub = CloudBuild::new(client, auth);
16410/// // As the method needs a request, you would usually fill it with the desired information
16411/// // into the respective structure. Some of the parts shown here might not be applicable !
16412/// // Values shown here are possibly random and not representative !
16413/// let mut req = RemoveGitLabConnectedRepositoryRequest::default();
16414///
16415/// // You can configure optional parameters by calling the respective setters at will, and
16416/// // execute the final call using `doit()`.
16417/// // Values shown here are possibly random and not representative !
16418/// let result = hub.projects().locations_git_lab_configs_remove_git_lab_connected_repository(req, "config")
16419/// .doit().await;
16420/// # }
16421/// ```
16422pub struct ProjectLocationGitLabConfigRemoveGitLabConnectedRepositoryCall<'a, C>
16423where
16424 C: 'a,
16425{
16426 hub: &'a CloudBuild<C>,
16427 _request: RemoveGitLabConnectedRepositoryRequest,
16428 _config: String,
16429 _delegate: Option<&'a mut dyn common::Delegate>,
16430 _additional_params: HashMap<String, String>,
16431 _scopes: BTreeSet<String>,
16432}
16433
16434impl<'a, C> common::CallBuilder
16435 for ProjectLocationGitLabConfigRemoveGitLabConnectedRepositoryCall<'a, C>
16436{
16437}
16438
16439impl<'a, C> ProjectLocationGitLabConfigRemoveGitLabConnectedRepositoryCall<'a, C>
16440where
16441 C: common::Connector,
16442{
16443 /// Perform the operation you have build so far.
16444 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
16445 use std::borrow::Cow;
16446 use std::io::{Read, Seek};
16447
16448 use common::{url::Params, ToParts};
16449 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16450
16451 let mut dd = common::DefaultDelegate;
16452 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16453 dlg.begin(common::MethodInfo {
16454 id: "cloudbuild.projects.locations.gitLabConfigs.removeGitLabConnectedRepository",
16455 http_method: hyper::Method::POST,
16456 });
16457
16458 for &field in ["alt", "config"].iter() {
16459 if self._additional_params.contains_key(field) {
16460 dlg.finished(false);
16461 return Err(common::Error::FieldClash(field));
16462 }
16463 }
16464
16465 let mut params = Params::with_capacity(4 + self._additional_params.len());
16466 params.push("config", self._config);
16467
16468 params.extend(self._additional_params.iter());
16469
16470 params.push("alt", "json");
16471 let mut url = self.hub._base_url.clone() + "v1/{+config}:removeGitLabConnectedRepository";
16472 if self._scopes.is_empty() {
16473 self._scopes
16474 .insert(Scope::CloudPlatform.as_ref().to_string());
16475 }
16476
16477 #[allow(clippy::single_element_loop)]
16478 for &(find_this, param_name) in [("{+config}", "config")].iter() {
16479 url = params.uri_replacement(url, param_name, find_this, true);
16480 }
16481 {
16482 let to_remove = ["config"];
16483 params.remove_params(&to_remove);
16484 }
16485
16486 let url = params.parse_with_url(&url);
16487
16488 let mut json_mime_type = mime::APPLICATION_JSON;
16489 let mut request_value_reader = {
16490 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16491 common::remove_json_null_values(&mut value);
16492 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16493 serde_json::to_writer(&mut dst, &value).unwrap();
16494 dst
16495 };
16496 let request_size = request_value_reader
16497 .seek(std::io::SeekFrom::End(0))
16498 .unwrap();
16499 request_value_reader
16500 .seek(std::io::SeekFrom::Start(0))
16501 .unwrap();
16502
16503 loop {
16504 let token = match self
16505 .hub
16506 .auth
16507 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16508 .await
16509 {
16510 Ok(token) => token,
16511 Err(e) => match dlg.token(e) {
16512 Ok(token) => token,
16513 Err(e) => {
16514 dlg.finished(false);
16515 return Err(common::Error::MissingToken(e));
16516 }
16517 },
16518 };
16519 request_value_reader
16520 .seek(std::io::SeekFrom::Start(0))
16521 .unwrap();
16522 let mut req_result = {
16523 let client = &self.hub.client;
16524 dlg.pre_request();
16525 let mut req_builder = hyper::Request::builder()
16526 .method(hyper::Method::POST)
16527 .uri(url.as_str())
16528 .header(USER_AGENT, self.hub._user_agent.clone());
16529
16530 if let Some(token) = token.as_ref() {
16531 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16532 }
16533
16534 let request = req_builder
16535 .header(CONTENT_TYPE, json_mime_type.to_string())
16536 .header(CONTENT_LENGTH, request_size as u64)
16537 .body(common::to_body(
16538 request_value_reader.get_ref().clone().into(),
16539 ));
16540
16541 client.request(request.unwrap()).await
16542 };
16543
16544 match req_result {
16545 Err(err) => {
16546 if let common::Retry::After(d) = dlg.http_error(&err) {
16547 sleep(d).await;
16548 continue;
16549 }
16550 dlg.finished(false);
16551 return Err(common::Error::HttpError(err));
16552 }
16553 Ok(res) => {
16554 let (mut parts, body) = res.into_parts();
16555 let mut body = common::Body::new(body);
16556 if !parts.status.is_success() {
16557 let bytes = common::to_bytes(body).await.unwrap_or_default();
16558 let error = serde_json::from_str(&common::to_string(&bytes));
16559 let response = common::to_response(parts, bytes.into());
16560
16561 if let common::Retry::After(d) =
16562 dlg.http_failure(&response, error.as_ref().ok())
16563 {
16564 sleep(d).await;
16565 continue;
16566 }
16567
16568 dlg.finished(false);
16569
16570 return Err(match error {
16571 Ok(value) => common::Error::BadRequest(value),
16572 _ => common::Error::Failure(response),
16573 });
16574 }
16575 let response = {
16576 let bytes = common::to_bytes(body).await.unwrap_or_default();
16577 let encoded = common::to_string(&bytes);
16578 match serde_json::from_str(&encoded) {
16579 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16580 Err(error) => {
16581 dlg.response_json_decode_error(&encoded, &error);
16582 return Err(common::Error::JsonDecodeError(
16583 encoded.to_string(),
16584 error,
16585 ));
16586 }
16587 }
16588 };
16589
16590 dlg.finished(true);
16591 return Ok(response);
16592 }
16593 }
16594 }
16595 }
16596
16597 ///
16598 /// Sets the *request* property to the given value.
16599 ///
16600 /// Even though the property as already been set when instantiating this call,
16601 /// we provide this method for API completeness.
16602 pub fn request(
16603 mut self,
16604 new_value: RemoveGitLabConnectedRepositoryRequest,
16605 ) -> ProjectLocationGitLabConfigRemoveGitLabConnectedRepositoryCall<'a, C> {
16606 self._request = new_value;
16607 self
16608 }
16609 /// Required. The name of the `GitLabConfig` to remove a connected repository. Format: `projects/{project}/locations/{location}/gitLabConfigs/{config}`
16610 ///
16611 /// Sets the *config* path property to the given value.
16612 ///
16613 /// Even though the property as already been set when instantiating this call,
16614 /// we provide this method for API completeness.
16615 pub fn config(
16616 mut self,
16617 new_value: &str,
16618 ) -> ProjectLocationGitLabConfigRemoveGitLabConnectedRepositoryCall<'a, C> {
16619 self._config = new_value.to_string();
16620 self
16621 }
16622 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16623 /// while executing the actual API request.
16624 ///
16625 /// ````text
16626 /// It should be used to handle progress information, and to implement a certain level of resilience.
16627 /// ````
16628 ///
16629 /// Sets the *delegate* property to the given value.
16630 pub fn delegate(
16631 mut self,
16632 new_value: &'a mut dyn common::Delegate,
16633 ) -> ProjectLocationGitLabConfigRemoveGitLabConnectedRepositoryCall<'a, C> {
16634 self._delegate = Some(new_value);
16635 self
16636 }
16637
16638 /// Set any additional parameter of the query string used in the request.
16639 /// It should be used to set parameters which are not yet available through their own
16640 /// setters.
16641 ///
16642 /// Please note that this method must not be used to set any of the known parameters
16643 /// which have their own setter method. If done anyway, the request will fail.
16644 ///
16645 /// # Additional Parameters
16646 ///
16647 /// * *$.xgafv* (query-string) - V1 error format.
16648 /// * *access_token* (query-string) - OAuth access token.
16649 /// * *alt* (query-string) - Data format for response.
16650 /// * *callback* (query-string) - JSONP
16651 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16652 /// * *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.
16653 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16654 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16655 /// * *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.
16656 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16657 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16658 pub fn param<T>(
16659 mut self,
16660 name: T,
16661 value: T,
16662 ) -> ProjectLocationGitLabConfigRemoveGitLabConnectedRepositoryCall<'a, C>
16663 where
16664 T: AsRef<str>,
16665 {
16666 self._additional_params
16667 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16668 self
16669 }
16670
16671 /// Identifies the authorization scope for the method you are building.
16672 ///
16673 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16674 /// [`Scope::CloudPlatform`].
16675 ///
16676 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16677 /// tokens for more than one scope.
16678 ///
16679 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16680 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16681 /// sufficient, a read-write scope will do as well.
16682 pub fn add_scope<St>(
16683 mut self,
16684 scope: St,
16685 ) -> ProjectLocationGitLabConfigRemoveGitLabConnectedRepositoryCall<'a, C>
16686 where
16687 St: AsRef<str>,
16688 {
16689 self._scopes.insert(String::from(scope.as_ref()));
16690 self
16691 }
16692 /// Identifies the authorization scope(s) for the method you are building.
16693 ///
16694 /// See [`Self::add_scope()`] for details.
16695 pub fn add_scopes<I, St>(
16696 mut self,
16697 scopes: I,
16698 ) -> ProjectLocationGitLabConfigRemoveGitLabConnectedRepositoryCall<'a, C>
16699 where
16700 I: IntoIterator<Item = St>,
16701 St: AsRef<str>,
16702 {
16703 self._scopes
16704 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16705 self
16706 }
16707
16708 /// Removes all scopes, and no default scope will be used either.
16709 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16710 /// for details).
16711 pub fn clear_scopes(
16712 mut self,
16713 ) -> ProjectLocationGitLabConfigRemoveGitLabConnectedRepositoryCall<'a, C> {
16714 self._scopes.clear();
16715 self
16716 }
16717}
16718
16719/// Create an association between a GCP project and a GitHub Enterprise server.
16720///
16721/// A builder for the *locations.githubEnterpriseConfigs.create* method supported by a *project* resource.
16722/// It is not used directly, but through a [`ProjectMethods`] instance.
16723///
16724/// # Example
16725///
16726/// Instantiate a resource method builder
16727///
16728/// ```test_harness,no_run
16729/// # extern crate hyper;
16730/// # extern crate hyper_rustls;
16731/// # extern crate google_cloudbuild1 as cloudbuild1;
16732/// use cloudbuild1::api::GitHubEnterpriseConfig;
16733/// # async fn dox() {
16734/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16735///
16736/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16737/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16738/// # .with_native_roots()
16739/// # .unwrap()
16740/// # .https_only()
16741/// # .enable_http2()
16742/// # .build();
16743///
16744/// # let executor = hyper_util::rt::TokioExecutor::new();
16745/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16746/// # secret,
16747/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16748/// # yup_oauth2::client::CustomHyperClientBuilder::from(
16749/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
16750/// # ),
16751/// # ).build().await.unwrap();
16752///
16753/// # let client = hyper_util::client::legacy::Client::builder(
16754/// # hyper_util::rt::TokioExecutor::new()
16755/// # )
16756/// # .build(
16757/// # hyper_rustls::HttpsConnectorBuilder::new()
16758/// # .with_native_roots()
16759/// # .unwrap()
16760/// # .https_or_http()
16761/// # .enable_http2()
16762/// # .build()
16763/// # );
16764/// # let mut hub = CloudBuild::new(client, auth);
16765/// // As the method needs a request, you would usually fill it with the desired information
16766/// // into the respective structure. Some of the parts shown here might not be applicable !
16767/// // Values shown here are possibly random and not representative !
16768/// let mut req = GitHubEnterpriseConfig::default();
16769///
16770/// // You can configure optional parameters by calling the respective setters at will, and
16771/// // execute the final call using `doit()`.
16772/// // Values shown here are possibly random and not representative !
16773/// let result = hub.projects().locations_github_enterprise_configs_create(req, "parent")
16774/// .project_id("consetetur")
16775/// .ghe_config_id("amet.")
16776/// .doit().await;
16777/// # }
16778/// ```
16779pub struct ProjectLocationGithubEnterpriseConfigCreateCall<'a, C>
16780where
16781 C: 'a,
16782{
16783 hub: &'a CloudBuild<C>,
16784 _request: GitHubEnterpriseConfig,
16785 _parent: String,
16786 _project_id: Option<String>,
16787 _ghe_config_id: Option<String>,
16788 _delegate: Option<&'a mut dyn common::Delegate>,
16789 _additional_params: HashMap<String, String>,
16790 _scopes: BTreeSet<String>,
16791}
16792
16793impl<'a, C> common::CallBuilder for ProjectLocationGithubEnterpriseConfigCreateCall<'a, C> {}
16794
16795impl<'a, C> ProjectLocationGithubEnterpriseConfigCreateCall<'a, C>
16796where
16797 C: common::Connector,
16798{
16799 /// Perform the operation you have build so far.
16800 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
16801 use std::borrow::Cow;
16802 use std::io::{Read, Seek};
16803
16804 use common::{url::Params, ToParts};
16805 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16806
16807 let mut dd = common::DefaultDelegate;
16808 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16809 dlg.begin(common::MethodInfo {
16810 id: "cloudbuild.projects.locations.githubEnterpriseConfigs.create",
16811 http_method: hyper::Method::POST,
16812 });
16813
16814 for &field in ["alt", "parent", "projectId", "gheConfigId"].iter() {
16815 if self._additional_params.contains_key(field) {
16816 dlg.finished(false);
16817 return Err(common::Error::FieldClash(field));
16818 }
16819 }
16820
16821 let mut params = Params::with_capacity(6 + self._additional_params.len());
16822 params.push("parent", self._parent);
16823 if let Some(value) = self._project_id.as_ref() {
16824 params.push("projectId", value);
16825 }
16826 if let Some(value) = self._ghe_config_id.as_ref() {
16827 params.push("gheConfigId", value);
16828 }
16829
16830 params.extend(self._additional_params.iter());
16831
16832 params.push("alt", "json");
16833 let mut url = self.hub._base_url.clone() + "v1/{+parent}/githubEnterpriseConfigs";
16834 if self._scopes.is_empty() {
16835 self._scopes
16836 .insert(Scope::CloudPlatform.as_ref().to_string());
16837 }
16838
16839 #[allow(clippy::single_element_loop)]
16840 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
16841 url = params.uri_replacement(url, param_name, find_this, true);
16842 }
16843 {
16844 let to_remove = ["parent"];
16845 params.remove_params(&to_remove);
16846 }
16847
16848 let url = params.parse_with_url(&url);
16849
16850 let mut json_mime_type = mime::APPLICATION_JSON;
16851 let mut request_value_reader = {
16852 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16853 common::remove_json_null_values(&mut value);
16854 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16855 serde_json::to_writer(&mut dst, &value).unwrap();
16856 dst
16857 };
16858 let request_size = request_value_reader
16859 .seek(std::io::SeekFrom::End(0))
16860 .unwrap();
16861 request_value_reader
16862 .seek(std::io::SeekFrom::Start(0))
16863 .unwrap();
16864
16865 loop {
16866 let token = match self
16867 .hub
16868 .auth
16869 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16870 .await
16871 {
16872 Ok(token) => token,
16873 Err(e) => match dlg.token(e) {
16874 Ok(token) => token,
16875 Err(e) => {
16876 dlg.finished(false);
16877 return Err(common::Error::MissingToken(e));
16878 }
16879 },
16880 };
16881 request_value_reader
16882 .seek(std::io::SeekFrom::Start(0))
16883 .unwrap();
16884 let mut req_result = {
16885 let client = &self.hub.client;
16886 dlg.pre_request();
16887 let mut req_builder = hyper::Request::builder()
16888 .method(hyper::Method::POST)
16889 .uri(url.as_str())
16890 .header(USER_AGENT, self.hub._user_agent.clone());
16891
16892 if let Some(token) = token.as_ref() {
16893 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16894 }
16895
16896 let request = req_builder
16897 .header(CONTENT_TYPE, json_mime_type.to_string())
16898 .header(CONTENT_LENGTH, request_size as u64)
16899 .body(common::to_body(
16900 request_value_reader.get_ref().clone().into(),
16901 ));
16902
16903 client.request(request.unwrap()).await
16904 };
16905
16906 match req_result {
16907 Err(err) => {
16908 if let common::Retry::After(d) = dlg.http_error(&err) {
16909 sleep(d).await;
16910 continue;
16911 }
16912 dlg.finished(false);
16913 return Err(common::Error::HttpError(err));
16914 }
16915 Ok(res) => {
16916 let (mut parts, body) = res.into_parts();
16917 let mut body = common::Body::new(body);
16918 if !parts.status.is_success() {
16919 let bytes = common::to_bytes(body).await.unwrap_or_default();
16920 let error = serde_json::from_str(&common::to_string(&bytes));
16921 let response = common::to_response(parts, bytes.into());
16922
16923 if let common::Retry::After(d) =
16924 dlg.http_failure(&response, error.as_ref().ok())
16925 {
16926 sleep(d).await;
16927 continue;
16928 }
16929
16930 dlg.finished(false);
16931
16932 return Err(match error {
16933 Ok(value) => common::Error::BadRequest(value),
16934 _ => common::Error::Failure(response),
16935 });
16936 }
16937 let response = {
16938 let bytes = common::to_bytes(body).await.unwrap_or_default();
16939 let encoded = common::to_string(&bytes);
16940 match serde_json::from_str(&encoded) {
16941 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16942 Err(error) => {
16943 dlg.response_json_decode_error(&encoded, &error);
16944 return Err(common::Error::JsonDecodeError(
16945 encoded.to_string(),
16946 error,
16947 ));
16948 }
16949 }
16950 };
16951
16952 dlg.finished(true);
16953 return Ok(response);
16954 }
16955 }
16956 }
16957 }
16958
16959 ///
16960 /// Sets the *request* property to the given value.
16961 ///
16962 /// Even though the property as already been set when instantiating this call,
16963 /// we provide this method for API completeness.
16964 pub fn request(
16965 mut self,
16966 new_value: GitHubEnterpriseConfig,
16967 ) -> ProjectLocationGithubEnterpriseConfigCreateCall<'a, C> {
16968 self._request = new_value;
16969 self
16970 }
16971 /// Name of the parent project. For example: projects/{$project_number} or projects/{$project_id}
16972 ///
16973 /// Sets the *parent* path property to the given value.
16974 ///
16975 /// Even though the property as already been set when instantiating this call,
16976 /// we provide this method for API completeness.
16977 pub fn parent(
16978 mut self,
16979 new_value: &str,
16980 ) -> ProjectLocationGithubEnterpriseConfigCreateCall<'a, C> {
16981 self._parent = new_value.to_string();
16982 self
16983 }
16984 /// ID of the project.
16985 ///
16986 /// Sets the *project id* query property to the given value.
16987 pub fn project_id(
16988 mut self,
16989 new_value: &str,
16990 ) -> ProjectLocationGithubEnterpriseConfigCreateCall<'a, C> {
16991 self._project_id = Some(new_value.to_string());
16992 self
16993 }
16994 /// 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
16995 ///
16996 /// Sets the *ghe config id* query property to the given value.
16997 pub fn ghe_config_id(
16998 mut self,
16999 new_value: &str,
17000 ) -> ProjectLocationGithubEnterpriseConfigCreateCall<'a, C> {
17001 self._ghe_config_id = Some(new_value.to_string());
17002 self
17003 }
17004 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17005 /// while executing the actual API request.
17006 ///
17007 /// ````text
17008 /// It should be used to handle progress information, and to implement a certain level of resilience.
17009 /// ````
17010 ///
17011 /// Sets the *delegate* property to the given value.
17012 pub fn delegate(
17013 mut self,
17014 new_value: &'a mut dyn common::Delegate,
17015 ) -> ProjectLocationGithubEnterpriseConfigCreateCall<'a, C> {
17016 self._delegate = Some(new_value);
17017 self
17018 }
17019
17020 /// Set any additional parameter of the query string used in the request.
17021 /// It should be used to set parameters which are not yet available through their own
17022 /// setters.
17023 ///
17024 /// Please note that this method must not be used to set any of the known parameters
17025 /// which have their own setter method. If done anyway, the request will fail.
17026 ///
17027 /// # Additional Parameters
17028 ///
17029 /// * *$.xgafv* (query-string) - V1 error format.
17030 /// * *access_token* (query-string) - OAuth access token.
17031 /// * *alt* (query-string) - Data format for response.
17032 /// * *callback* (query-string) - JSONP
17033 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17034 /// * *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.
17035 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17036 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17037 /// * *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.
17038 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17039 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17040 pub fn param<T>(
17041 mut self,
17042 name: T,
17043 value: T,
17044 ) -> ProjectLocationGithubEnterpriseConfigCreateCall<'a, C>
17045 where
17046 T: AsRef<str>,
17047 {
17048 self._additional_params
17049 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17050 self
17051 }
17052
17053 /// Identifies the authorization scope for the method you are building.
17054 ///
17055 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17056 /// [`Scope::CloudPlatform`].
17057 ///
17058 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17059 /// tokens for more than one scope.
17060 ///
17061 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17062 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17063 /// sufficient, a read-write scope will do as well.
17064 pub fn add_scope<St>(
17065 mut self,
17066 scope: St,
17067 ) -> ProjectLocationGithubEnterpriseConfigCreateCall<'a, C>
17068 where
17069 St: AsRef<str>,
17070 {
17071 self._scopes.insert(String::from(scope.as_ref()));
17072 self
17073 }
17074 /// Identifies the authorization scope(s) for the method you are building.
17075 ///
17076 /// See [`Self::add_scope()`] for details.
17077 pub fn add_scopes<I, St>(
17078 mut self,
17079 scopes: I,
17080 ) -> ProjectLocationGithubEnterpriseConfigCreateCall<'a, C>
17081 where
17082 I: IntoIterator<Item = St>,
17083 St: AsRef<str>,
17084 {
17085 self._scopes
17086 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17087 self
17088 }
17089
17090 /// Removes all scopes, and no default scope will be used either.
17091 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17092 /// for details).
17093 pub fn clear_scopes(mut self) -> ProjectLocationGithubEnterpriseConfigCreateCall<'a, C> {
17094 self._scopes.clear();
17095 self
17096 }
17097}
17098
17099/// Delete an association between a GCP project and a GitHub Enterprise server.
17100///
17101/// A builder for the *locations.githubEnterpriseConfigs.delete* method supported by a *project* resource.
17102/// It is not used directly, but through a [`ProjectMethods`] instance.
17103///
17104/// # Example
17105///
17106/// Instantiate a resource method builder
17107///
17108/// ```test_harness,no_run
17109/// # extern crate hyper;
17110/// # extern crate hyper_rustls;
17111/// # extern crate google_cloudbuild1 as cloudbuild1;
17112/// # async fn dox() {
17113/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17114///
17115/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17116/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17117/// # .with_native_roots()
17118/// # .unwrap()
17119/// # .https_only()
17120/// # .enable_http2()
17121/// # .build();
17122///
17123/// # let executor = hyper_util::rt::TokioExecutor::new();
17124/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17125/// # secret,
17126/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17127/// # yup_oauth2::client::CustomHyperClientBuilder::from(
17128/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
17129/// # ),
17130/// # ).build().await.unwrap();
17131///
17132/// # let client = hyper_util::client::legacy::Client::builder(
17133/// # hyper_util::rt::TokioExecutor::new()
17134/// # )
17135/// # .build(
17136/// # hyper_rustls::HttpsConnectorBuilder::new()
17137/// # .with_native_roots()
17138/// # .unwrap()
17139/// # .https_or_http()
17140/// # .enable_http2()
17141/// # .build()
17142/// # );
17143/// # let mut hub = CloudBuild::new(client, auth);
17144/// // You can configure optional parameters by calling the respective setters at will, and
17145/// // execute the final call using `doit()`.
17146/// // Values shown here are possibly random and not representative !
17147/// let result = hub.projects().locations_github_enterprise_configs_delete("name")
17148/// .project_id("takimata")
17149/// .config_id("dolores")
17150/// .doit().await;
17151/// # }
17152/// ```
17153pub struct ProjectLocationGithubEnterpriseConfigDeleteCall<'a, C>
17154where
17155 C: 'a,
17156{
17157 hub: &'a CloudBuild<C>,
17158 _name: String,
17159 _project_id: Option<String>,
17160 _config_id: Option<String>,
17161 _delegate: Option<&'a mut dyn common::Delegate>,
17162 _additional_params: HashMap<String, String>,
17163 _scopes: BTreeSet<String>,
17164}
17165
17166impl<'a, C> common::CallBuilder for ProjectLocationGithubEnterpriseConfigDeleteCall<'a, C> {}
17167
17168impl<'a, C> ProjectLocationGithubEnterpriseConfigDeleteCall<'a, C>
17169where
17170 C: common::Connector,
17171{
17172 /// Perform the operation you have build so far.
17173 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
17174 use std::borrow::Cow;
17175 use std::io::{Read, Seek};
17176
17177 use common::{url::Params, ToParts};
17178 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17179
17180 let mut dd = common::DefaultDelegate;
17181 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17182 dlg.begin(common::MethodInfo {
17183 id: "cloudbuild.projects.locations.githubEnterpriseConfigs.delete",
17184 http_method: hyper::Method::DELETE,
17185 });
17186
17187 for &field in ["alt", "name", "projectId", "configId"].iter() {
17188 if self._additional_params.contains_key(field) {
17189 dlg.finished(false);
17190 return Err(common::Error::FieldClash(field));
17191 }
17192 }
17193
17194 let mut params = Params::with_capacity(5 + self._additional_params.len());
17195 params.push("name", self._name);
17196 if let Some(value) = self._project_id.as_ref() {
17197 params.push("projectId", value);
17198 }
17199 if let Some(value) = self._config_id.as_ref() {
17200 params.push("configId", value);
17201 }
17202
17203 params.extend(self._additional_params.iter());
17204
17205 params.push("alt", "json");
17206 let mut url = self.hub._base_url.clone() + "v1/{+name}";
17207 if self._scopes.is_empty() {
17208 self._scopes
17209 .insert(Scope::CloudPlatform.as_ref().to_string());
17210 }
17211
17212 #[allow(clippy::single_element_loop)]
17213 for &(find_this, param_name) in [("{+name}", "name")].iter() {
17214 url = params.uri_replacement(url, param_name, find_this, true);
17215 }
17216 {
17217 let to_remove = ["name"];
17218 params.remove_params(&to_remove);
17219 }
17220
17221 let url = params.parse_with_url(&url);
17222
17223 loop {
17224 let token = match self
17225 .hub
17226 .auth
17227 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17228 .await
17229 {
17230 Ok(token) => token,
17231 Err(e) => match dlg.token(e) {
17232 Ok(token) => token,
17233 Err(e) => {
17234 dlg.finished(false);
17235 return Err(common::Error::MissingToken(e));
17236 }
17237 },
17238 };
17239 let mut req_result = {
17240 let client = &self.hub.client;
17241 dlg.pre_request();
17242 let mut req_builder = hyper::Request::builder()
17243 .method(hyper::Method::DELETE)
17244 .uri(url.as_str())
17245 .header(USER_AGENT, self.hub._user_agent.clone());
17246
17247 if let Some(token) = token.as_ref() {
17248 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17249 }
17250
17251 let request = req_builder
17252 .header(CONTENT_LENGTH, 0_u64)
17253 .body(common::to_body::<String>(None));
17254
17255 client.request(request.unwrap()).await
17256 };
17257
17258 match req_result {
17259 Err(err) => {
17260 if let common::Retry::After(d) = dlg.http_error(&err) {
17261 sleep(d).await;
17262 continue;
17263 }
17264 dlg.finished(false);
17265 return Err(common::Error::HttpError(err));
17266 }
17267 Ok(res) => {
17268 let (mut parts, body) = res.into_parts();
17269 let mut body = common::Body::new(body);
17270 if !parts.status.is_success() {
17271 let bytes = common::to_bytes(body).await.unwrap_or_default();
17272 let error = serde_json::from_str(&common::to_string(&bytes));
17273 let response = common::to_response(parts, bytes.into());
17274
17275 if let common::Retry::After(d) =
17276 dlg.http_failure(&response, error.as_ref().ok())
17277 {
17278 sleep(d).await;
17279 continue;
17280 }
17281
17282 dlg.finished(false);
17283
17284 return Err(match error {
17285 Ok(value) => common::Error::BadRequest(value),
17286 _ => common::Error::Failure(response),
17287 });
17288 }
17289 let response = {
17290 let bytes = common::to_bytes(body).await.unwrap_or_default();
17291 let encoded = common::to_string(&bytes);
17292 match serde_json::from_str(&encoded) {
17293 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17294 Err(error) => {
17295 dlg.response_json_decode_error(&encoded, &error);
17296 return Err(common::Error::JsonDecodeError(
17297 encoded.to_string(),
17298 error,
17299 ));
17300 }
17301 }
17302 };
17303
17304 dlg.finished(true);
17305 return Ok(response);
17306 }
17307 }
17308 }
17309 }
17310
17311 /// This field should contain the name of the enterprise config resource. For example: "projects/{$project_id}/locations/{$location_id}/githubEnterpriseConfigs/{$config_id}"
17312 ///
17313 /// Sets the *name* path property to the given value.
17314 ///
17315 /// Even though the property as already been set when instantiating this call,
17316 /// we provide this method for API completeness.
17317 pub fn name(
17318 mut self,
17319 new_value: &str,
17320 ) -> ProjectLocationGithubEnterpriseConfigDeleteCall<'a, C> {
17321 self._name = new_value.to_string();
17322 self
17323 }
17324 /// ID of the project
17325 ///
17326 /// Sets the *project id* query property to the given value.
17327 pub fn project_id(
17328 mut self,
17329 new_value: &str,
17330 ) -> ProjectLocationGithubEnterpriseConfigDeleteCall<'a, C> {
17331 self._project_id = Some(new_value.to_string());
17332 self
17333 }
17334 /// Unique identifier of the `GitHubEnterpriseConfig`
17335 ///
17336 /// Sets the *config id* query property to the given value.
17337 pub fn config_id(
17338 mut self,
17339 new_value: &str,
17340 ) -> ProjectLocationGithubEnterpriseConfigDeleteCall<'a, C> {
17341 self._config_id = Some(new_value.to_string());
17342 self
17343 }
17344 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17345 /// while executing the actual API request.
17346 ///
17347 /// ````text
17348 /// It should be used to handle progress information, and to implement a certain level of resilience.
17349 /// ````
17350 ///
17351 /// Sets the *delegate* property to the given value.
17352 pub fn delegate(
17353 mut self,
17354 new_value: &'a mut dyn common::Delegate,
17355 ) -> ProjectLocationGithubEnterpriseConfigDeleteCall<'a, C> {
17356 self._delegate = Some(new_value);
17357 self
17358 }
17359
17360 /// Set any additional parameter of the query string used in the request.
17361 /// It should be used to set parameters which are not yet available through their own
17362 /// setters.
17363 ///
17364 /// Please note that this method must not be used to set any of the known parameters
17365 /// which have their own setter method. If done anyway, the request will fail.
17366 ///
17367 /// # Additional Parameters
17368 ///
17369 /// * *$.xgafv* (query-string) - V1 error format.
17370 /// * *access_token* (query-string) - OAuth access token.
17371 /// * *alt* (query-string) - Data format for response.
17372 /// * *callback* (query-string) - JSONP
17373 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17374 /// * *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.
17375 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17376 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17377 /// * *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.
17378 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17379 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17380 pub fn param<T>(
17381 mut self,
17382 name: T,
17383 value: T,
17384 ) -> ProjectLocationGithubEnterpriseConfigDeleteCall<'a, C>
17385 where
17386 T: AsRef<str>,
17387 {
17388 self._additional_params
17389 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17390 self
17391 }
17392
17393 /// Identifies the authorization scope for the method you are building.
17394 ///
17395 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17396 /// [`Scope::CloudPlatform`].
17397 ///
17398 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17399 /// tokens for more than one scope.
17400 ///
17401 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17402 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17403 /// sufficient, a read-write scope will do as well.
17404 pub fn add_scope<St>(
17405 mut self,
17406 scope: St,
17407 ) -> ProjectLocationGithubEnterpriseConfigDeleteCall<'a, C>
17408 where
17409 St: AsRef<str>,
17410 {
17411 self._scopes.insert(String::from(scope.as_ref()));
17412 self
17413 }
17414 /// Identifies the authorization scope(s) for the method you are building.
17415 ///
17416 /// See [`Self::add_scope()`] for details.
17417 pub fn add_scopes<I, St>(
17418 mut self,
17419 scopes: I,
17420 ) -> ProjectLocationGithubEnterpriseConfigDeleteCall<'a, C>
17421 where
17422 I: IntoIterator<Item = St>,
17423 St: AsRef<str>,
17424 {
17425 self._scopes
17426 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17427 self
17428 }
17429
17430 /// Removes all scopes, and no default scope will be used either.
17431 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17432 /// for details).
17433 pub fn clear_scopes(mut self) -> ProjectLocationGithubEnterpriseConfigDeleteCall<'a, C> {
17434 self._scopes.clear();
17435 self
17436 }
17437}
17438
17439/// Retrieve a GitHubEnterpriseConfig.
17440///
17441/// A builder for the *locations.githubEnterpriseConfigs.get* method supported by a *project* resource.
17442/// It is not used directly, but through a [`ProjectMethods`] instance.
17443///
17444/// # Example
17445///
17446/// Instantiate a resource method builder
17447///
17448/// ```test_harness,no_run
17449/// # extern crate hyper;
17450/// # extern crate hyper_rustls;
17451/// # extern crate google_cloudbuild1 as cloudbuild1;
17452/// # async fn dox() {
17453/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17454///
17455/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17456/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17457/// # .with_native_roots()
17458/// # .unwrap()
17459/// # .https_only()
17460/// # .enable_http2()
17461/// # .build();
17462///
17463/// # let executor = hyper_util::rt::TokioExecutor::new();
17464/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17465/// # secret,
17466/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17467/// # yup_oauth2::client::CustomHyperClientBuilder::from(
17468/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
17469/// # ),
17470/// # ).build().await.unwrap();
17471///
17472/// # let client = hyper_util::client::legacy::Client::builder(
17473/// # hyper_util::rt::TokioExecutor::new()
17474/// # )
17475/// # .build(
17476/// # hyper_rustls::HttpsConnectorBuilder::new()
17477/// # .with_native_roots()
17478/// # .unwrap()
17479/// # .https_or_http()
17480/// # .enable_http2()
17481/// # .build()
17482/// # );
17483/// # let mut hub = CloudBuild::new(client, auth);
17484/// // You can configure optional parameters by calling the respective setters at will, and
17485/// // execute the final call using `doit()`.
17486/// // Values shown here are possibly random and not representative !
17487/// let result = hub.projects().locations_github_enterprise_configs_get("name")
17488/// .project_id("et")
17489/// .config_id("accusam")
17490/// .doit().await;
17491/// # }
17492/// ```
17493pub struct ProjectLocationGithubEnterpriseConfigGetCall<'a, C>
17494where
17495 C: 'a,
17496{
17497 hub: &'a CloudBuild<C>,
17498 _name: String,
17499 _project_id: Option<String>,
17500 _config_id: Option<String>,
17501 _delegate: Option<&'a mut dyn common::Delegate>,
17502 _additional_params: HashMap<String, String>,
17503 _scopes: BTreeSet<String>,
17504}
17505
17506impl<'a, C> common::CallBuilder for ProjectLocationGithubEnterpriseConfigGetCall<'a, C> {}
17507
17508impl<'a, C> ProjectLocationGithubEnterpriseConfigGetCall<'a, C>
17509where
17510 C: common::Connector,
17511{
17512 /// Perform the operation you have build so far.
17513 pub async fn doit(mut self) -> common::Result<(common::Response, GitHubEnterpriseConfig)> {
17514 use std::borrow::Cow;
17515 use std::io::{Read, Seek};
17516
17517 use common::{url::Params, ToParts};
17518 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17519
17520 let mut dd = common::DefaultDelegate;
17521 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17522 dlg.begin(common::MethodInfo {
17523 id: "cloudbuild.projects.locations.githubEnterpriseConfigs.get",
17524 http_method: hyper::Method::GET,
17525 });
17526
17527 for &field in ["alt", "name", "projectId", "configId"].iter() {
17528 if self._additional_params.contains_key(field) {
17529 dlg.finished(false);
17530 return Err(common::Error::FieldClash(field));
17531 }
17532 }
17533
17534 let mut params = Params::with_capacity(5 + self._additional_params.len());
17535 params.push("name", self._name);
17536 if let Some(value) = self._project_id.as_ref() {
17537 params.push("projectId", value);
17538 }
17539 if let Some(value) = self._config_id.as_ref() {
17540 params.push("configId", value);
17541 }
17542
17543 params.extend(self._additional_params.iter());
17544
17545 params.push("alt", "json");
17546 let mut url = self.hub._base_url.clone() + "v1/{+name}";
17547 if self._scopes.is_empty() {
17548 self._scopes
17549 .insert(Scope::CloudPlatform.as_ref().to_string());
17550 }
17551
17552 #[allow(clippy::single_element_loop)]
17553 for &(find_this, param_name) in [("{+name}", "name")].iter() {
17554 url = params.uri_replacement(url, param_name, find_this, true);
17555 }
17556 {
17557 let to_remove = ["name"];
17558 params.remove_params(&to_remove);
17559 }
17560
17561 let url = params.parse_with_url(&url);
17562
17563 loop {
17564 let token = match self
17565 .hub
17566 .auth
17567 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17568 .await
17569 {
17570 Ok(token) => token,
17571 Err(e) => match dlg.token(e) {
17572 Ok(token) => token,
17573 Err(e) => {
17574 dlg.finished(false);
17575 return Err(common::Error::MissingToken(e));
17576 }
17577 },
17578 };
17579 let mut req_result = {
17580 let client = &self.hub.client;
17581 dlg.pre_request();
17582 let mut req_builder = hyper::Request::builder()
17583 .method(hyper::Method::GET)
17584 .uri(url.as_str())
17585 .header(USER_AGENT, self.hub._user_agent.clone());
17586
17587 if let Some(token) = token.as_ref() {
17588 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17589 }
17590
17591 let request = req_builder
17592 .header(CONTENT_LENGTH, 0_u64)
17593 .body(common::to_body::<String>(None));
17594
17595 client.request(request.unwrap()).await
17596 };
17597
17598 match req_result {
17599 Err(err) => {
17600 if let common::Retry::After(d) = dlg.http_error(&err) {
17601 sleep(d).await;
17602 continue;
17603 }
17604 dlg.finished(false);
17605 return Err(common::Error::HttpError(err));
17606 }
17607 Ok(res) => {
17608 let (mut parts, body) = res.into_parts();
17609 let mut body = common::Body::new(body);
17610 if !parts.status.is_success() {
17611 let bytes = common::to_bytes(body).await.unwrap_or_default();
17612 let error = serde_json::from_str(&common::to_string(&bytes));
17613 let response = common::to_response(parts, bytes.into());
17614
17615 if let common::Retry::After(d) =
17616 dlg.http_failure(&response, error.as_ref().ok())
17617 {
17618 sleep(d).await;
17619 continue;
17620 }
17621
17622 dlg.finished(false);
17623
17624 return Err(match error {
17625 Ok(value) => common::Error::BadRequest(value),
17626 _ => common::Error::Failure(response),
17627 });
17628 }
17629 let response = {
17630 let bytes = common::to_bytes(body).await.unwrap_or_default();
17631 let encoded = common::to_string(&bytes);
17632 match serde_json::from_str(&encoded) {
17633 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17634 Err(error) => {
17635 dlg.response_json_decode_error(&encoded, &error);
17636 return Err(common::Error::JsonDecodeError(
17637 encoded.to_string(),
17638 error,
17639 ));
17640 }
17641 }
17642 };
17643
17644 dlg.finished(true);
17645 return Ok(response);
17646 }
17647 }
17648 }
17649 }
17650
17651 /// This field should contain the name of the enterprise config resource. For example: "projects/{$project_id}/locations/{$location_id}/githubEnterpriseConfigs/{$config_id}"
17652 ///
17653 /// Sets the *name* path property to the given value.
17654 ///
17655 /// Even though the property as already been set when instantiating this call,
17656 /// we provide this method for API completeness.
17657 pub fn name(mut self, new_value: &str) -> ProjectLocationGithubEnterpriseConfigGetCall<'a, C> {
17658 self._name = new_value.to_string();
17659 self
17660 }
17661 /// ID of the project
17662 ///
17663 /// Sets the *project id* query property to the given value.
17664 pub fn project_id(
17665 mut self,
17666 new_value: &str,
17667 ) -> ProjectLocationGithubEnterpriseConfigGetCall<'a, C> {
17668 self._project_id = Some(new_value.to_string());
17669 self
17670 }
17671 /// Unique identifier of the `GitHubEnterpriseConfig`
17672 ///
17673 /// Sets the *config id* query property to the given value.
17674 pub fn config_id(
17675 mut self,
17676 new_value: &str,
17677 ) -> ProjectLocationGithubEnterpriseConfigGetCall<'a, C> {
17678 self._config_id = Some(new_value.to_string());
17679 self
17680 }
17681 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17682 /// while executing the actual API request.
17683 ///
17684 /// ````text
17685 /// It should be used to handle progress information, and to implement a certain level of resilience.
17686 /// ````
17687 ///
17688 /// Sets the *delegate* property to the given value.
17689 pub fn delegate(
17690 mut self,
17691 new_value: &'a mut dyn common::Delegate,
17692 ) -> ProjectLocationGithubEnterpriseConfigGetCall<'a, C> {
17693 self._delegate = Some(new_value);
17694 self
17695 }
17696
17697 /// Set any additional parameter of the query string used in the request.
17698 /// It should be used to set parameters which are not yet available through their own
17699 /// setters.
17700 ///
17701 /// Please note that this method must not be used to set any of the known parameters
17702 /// which have their own setter method. If done anyway, the request will fail.
17703 ///
17704 /// # Additional Parameters
17705 ///
17706 /// * *$.xgafv* (query-string) - V1 error format.
17707 /// * *access_token* (query-string) - OAuth access token.
17708 /// * *alt* (query-string) - Data format for response.
17709 /// * *callback* (query-string) - JSONP
17710 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17711 /// * *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.
17712 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17713 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17714 /// * *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.
17715 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17716 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17717 pub fn param<T>(
17718 mut self,
17719 name: T,
17720 value: T,
17721 ) -> ProjectLocationGithubEnterpriseConfigGetCall<'a, C>
17722 where
17723 T: AsRef<str>,
17724 {
17725 self._additional_params
17726 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17727 self
17728 }
17729
17730 /// Identifies the authorization scope for the method you are building.
17731 ///
17732 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17733 /// [`Scope::CloudPlatform`].
17734 ///
17735 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17736 /// tokens for more than one scope.
17737 ///
17738 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17739 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17740 /// sufficient, a read-write scope will do as well.
17741 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGithubEnterpriseConfigGetCall<'a, C>
17742 where
17743 St: AsRef<str>,
17744 {
17745 self._scopes.insert(String::from(scope.as_ref()));
17746 self
17747 }
17748 /// Identifies the authorization scope(s) for the method you are building.
17749 ///
17750 /// See [`Self::add_scope()`] for details.
17751 pub fn add_scopes<I, St>(
17752 mut self,
17753 scopes: I,
17754 ) -> ProjectLocationGithubEnterpriseConfigGetCall<'a, C>
17755 where
17756 I: IntoIterator<Item = St>,
17757 St: AsRef<str>,
17758 {
17759 self._scopes
17760 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17761 self
17762 }
17763
17764 /// Removes all scopes, and no default scope will be used either.
17765 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17766 /// for details).
17767 pub fn clear_scopes(mut self) -> ProjectLocationGithubEnterpriseConfigGetCall<'a, C> {
17768 self._scopes.clear();
17769 self
17770 }
17771}
17772
17773/// List all GitHubEnterpriseConfigs for a given project.
17774///
17775/// A builder for the *locations.githubEnterpriseConfigs.list* method supported by a *project* resource.
17776/// It is not used directly, but through a [`ProjectMethods`] instance.
17777///
17778/// # Example
17779///
17780/// Instantiate a resource method builder
17781///
17782/// ```test_harness,no_run
17783/// # extern crate hyper;
17784/// # extern crate hyper_rustls;
17785/// # extern crate google_cloudbuild1 as cloudbuild1;
17786/// # async fn dox() {
17787/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17788///
17789/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17790/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17791/// # .with_native_roots()
17792/// # .unwrap()
17793/// # .https_only()
17794/// # .enable_http2()
17795/// # .build();
17796///
17797/// # let executor = hyper_util::rt::TokioExecutor::new();
17798/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17799/// # secret,
17800/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17801/// # yup_oauth2::client::CustomHyperClientBuilder::from(
17802/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
17803/// # ),
17804/// # ).build().await.unwrap();
17805///
17806/// # let client = hyper_util::client::legacy::Client::builder(
17807/// # hyper_util::rt::TokioExecutor::new()
17808/// # )
17809/// # .build(
17810/// # hyper_rustls::HttpsConnectorBuilder::new()
17811/// # .with_native_roots()
17812/// # .unwrap()
17813/// # .https_or_http()
17814/// # .enable_http2()
17815/// # .build()
17816/// # );
17817/// # let mut hub = CloudBuild::new(client, auth);
17818/// // You can configure optional parameters by calling the respective setters at will, and
17819/// // execute the final call using `doit()`.
17820/// // Values shown here are possibly random and not representative !
17821/// let result = hub.projects().locations_github_enterprise_configs_list("parent")
17822/// .project_id("dolore")
17823/// .doit().await;
17824/// # }
17825/// ```
17826pub struct ProjectLocationGithubEnterpriseConfigListCall<'a, C>
17827where
17828 C: 'a,
17829{
17830 hub: &'a CloudBuild<C>,
17831 _parent: String,
17832 _project_id: Option<String>,
17833 _delegate: Option<&'a mut dyn common::Delegate>,
17834 _additional_params: HashMap<String, String>,
17835 _scopes: BTreeSet<String>,
17836}
17837
17838impl<'a, C> common::CallBuilder for ProjectLocationGithubEnterpriseConfigListCall<'a, C> {}
17839
17840impl<'a, C> ProjectLocationGithubEnterpriseConfigListCall<'a, C>
17841where
17842 C: common::Connector,
17843{
17844 /// Perform the operation you have build so far.
17845 pub async fn doit(
17846 mut self,
17847 ) -> common::Result<(common::Response, ListGithubEnterpriseConfigsResponse)> {
17848 use std::borrow::Cow;
17849 use std::io::{Read, Seek};
17850
17851 use common::{url::Params, ToParts};
17852 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17853
17854 let mut dd = common::DefaultDelegate;
17855 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17856 dlg.begin(common::MethodInfo {
17857 id: "cloudbuild.projects.locations.githubEnterpriseConfigs.list",
17858 http_method: hyper::Method::GET,
17859 });
17860
17861 for &field in ["alt", "parent", "projectId"].iter() {
17862 if self._additional_params.contains_key(field) {
17863 dlg.finished(false);
17864 return Err(common::Error::FieldClash(field));
17865 }
17866 }
17867
17868 let mut params = Params::with_capacity(4 + self._additional_params.len());
17869 params.push("parent", self._parent);
17870 if let Some(value) = self._project_id.as_ref() {
17871 params.push("projectId", value);
17872 }
17873
17874 params.extend(self._additional_params.iter());
17875
17876 params.push("alt", "json");
17877 let mut url = self.hub._base_url.clone() + "v1/{+parent}/githubEnterpriseConfigs";
17878 if self._scopes.is_empty() {
17879 self._scopes
17880 .insert(Scope::CloudPlatform.as_ref().to_string());
17881 }
17882
17883 #[allow(clippy::single_element_loop)]
17884 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
17885 url = params.uri_replacement(url, param_name, find_this, true);
17886 }
17887 {
17888 let to_remove = ["parent"];
17889 params.remove_params(&to_remove);
17890 }
17891
17892 let url = params.parse_with_url(&url);
17893
17894 loop {
17895 let token = match self
17896 .hub
17897 .auth
17898 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17899 .await
17900 {
17901 Ok(token) => token,
17902 Err(e) => match dlg.token(e) {
17903 Ok(token) => token,
17904 Err(e) => {
17905 dlg.finished(false);
17906 return Err(common::Error::MissingToken(e));
17907 }
17908 },
17909 };
17910 let mut req_result = {
17911 let client = &self.hub.client;
17912 dlg.pre_request();
17913 let mut req_builder = hyper::Request::builder()
17914 .method(hyper::Method::GET)
17915 .uri(url.as_str())
17916 .header(USER_AGENT, self.hub._user_agent.clone());
17917
17918 if let Some(token) = token.as_ref() {
17919 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17920 }
17921
17922 let request = req_builder
17923 .header(CONTENT_LENGTH, 0_u64)
17924 .body(common::to_body::<String>(None));
17925
17926 client.request(request.unwrap()).await
17927 };
17928
17929 match req_result {
17930 Err(err) => {
17931 if let common::Retry::After(d) = dlg.http_error(&err) {
17932 sleep(d).await;
17933 continue;
17934 }
17935 dlg.finished(false);
17936 return Err(common::Error::HttpError(err));
17937 }
17938 Ok(res) => {
17939 let (mut parts, body) = res.into_parts();
17940 let mut body = common::Body::new(body);
17941 if !parts.status.is_success() {
17942 let bytes = common::to_bytes(body).await.unwrap_or_default();
17943 let error = serde_json::from_str(&common::to_string(&bytes));
17944 let response = common::to_response(parts, bytes.into());
17945
17946 if let common::Retry::After(d) =
17947 dlg.http_failure(&response, error.as_ref().ok())
17948 {
17949 sleep(d).await;
17950 continue;
17951 }
17952
17953 dlg.finished(false);
17954
17955 return Err(match error {
17956 Ok(value) => common::Error::BadRequest(value),
17957 _ => common::Error::Failure(response),
17958 });
17959 }
17960 let response = {
17961 let bytes = common::to_bytes(body).await.unwrap_or_default();
17962 let encoded = common::to_string(&bytes);
17963 match serde_json::from_str(&encoded) {
17964 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17965 Err(error) => {
17966 dlg.response_json_decode_error(&encoded, &error);
17967 return Err(common::Error::JsonDecodeError(
17968 encoded.to_string(),
17969 error,
17970 ));
17971 }
17972 }
17973 };
17974
17975 dlg.finished(true);
17976 return Ok(response);
17977 }
17978 }
17979 }
17980 }
17981
17982 /// Name of the parent project. For example: projects/{$project_number} or projects/{$project_id}
17983 ///
17984 /// Sets the *parent* path property to the given value.
17985 ///
17986 /// Even though the property as already been set when instantiating this call,
17987 /// we provide this method for API completeness.
17988 pub fn parent(
17989 mut self,
17990 new_value: &str,
17991 ) -> ProjectLocationGithubEnterpriseConfigListCall<'a, C> {
17992 self._parent = new_value.to_string();
17993 self
17994 }
17995 /// ID of the project
17996 ///
17997 /// Sets the *project id* query property to the given value.
17998 pub fn project_id(
17999 mut self,
18000 new_value: &str,
18001 ) -> ProjectLocationGithubEnterpriseConfigListCall<'a, C> {
18002 self._project_id = Some(new_value.to_string());
18003 self
18004 }
18005 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18006 /// while executing the actual API request.
18007 ///
18008 /// ````text
18009 /// It should be used to handle progress information, and to implement a certain level of resilience.
18010 /// ````
18011 ///
18012 /// Sets the *delegate* property to the given value.
18013 pub fn delegate(
18014 mut self,
18015 new_value: &'a mut dyn common::Delegate,
18016 ) -> ProjectLocationGithubEnterpriseConfigListCall<'a, C> {
18017 self._delegate = Some(new_value);
18018 self
18019 }
18020
18021 /// Set any additional parameter of the query string used in the request.
18022 /// It should be used to set parameters which are not yet available through their own
18023 /// setters.
18024 ///
18025 /// Please note that this method must not be used to set any of the known parameters
18026 /// which have their own setter method. If done anyway, the request will fail.
18027 ///
18028 /// # Additional Parameters
18029 ///
18030 /// * *$.xgafv* (query-string) - V1 error format.
18031 /// * *access_token* (query-string) - OAuth access token.
18032 /// * *alt* (query-string) - Data format for response.
18033 /// * *callback* (query-string) - JSONP
18034 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18035 /// * *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.
18036 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18037 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18038 /// * *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.
18039 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18040 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18041 pub fn param<T>(
18042 mut self,
18043 name: T,
18044 value: T,
18045 ) -> ProjectLocationGithubEnterpriseConfigListCall<'a, C>
18046 where
18047 T: AsRef<str>,
18048 {
18049 self._additional_params
18050 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18051 self
18052 }
18053
18054 /// Identifies the authorization scope for the method you are building.
18055 ///
18056 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18057 /// [`Scope::CloudPlatform`].
18058 ///
18059 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18060 /// tokens for more than one scope.
18061 ///
18062 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18063 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18064 /// sufficient, a read-write scope will do as well.
18065 pub fn add_scope<St>(
18066 mut self,
18067 scope: St,
18068 ) -> ProjectLocationGithubEnterpriseConfigListCall<'a, C>
18069 where
18070 St: AsRef<str>,
18071 {
18072 self._scopes.insert(String::from(scope.as_ref()));
18073 self
18074 }
18075 /// Identifies the authorization scope(s) for the method you are building.
18076 ///
18077 /// See [`Self::add_scope()`] for details.
18078 pub fn add_scopes<I, St>(
18079 mut self,
18080 scopes: I,
18081 ) -> ProjectLocationGithubEnterpriseConfigListCall<'a, C>
18082 where
18083 I: IntoIterator<Item = St>,
18084 St: AsRef<str>,
18085 {
18086 self._scopes
18087 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18088 self
18089 }
18090
18091 /// Removes all scopes, and no default scope will be used either.
18092 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18093 /// for details).
18094 pub fn clear_scopes(mut self) -> ProjectLocationGithubEnterpriseConfigListCall<'a, C> {
18095 self._scopes.clear();
18096 self
18097 }
18098}
18099
18100/// Update an association between a GCP project and a GitHub Enterprise server.
18101///
18102/// A builder for the *locations.githubEnterpriseConfigs.patch* method supported by a *project* resource.
18103/// It is not used directly, but through a [`ProjectMethods`] instance.
18104///
18105/// # Example
18106///
18107/// Instantiate a resource method builder
18108///
18109/// ```test_harness,no_run
18110/// # extern crate hyper;
18111/// # extern crate hyper_rustls;
18112/// # extern crate google_cloudbuild1 as cloudbuild1;
18113/// use cloudbuild1::api::GitHubEnterpriseConfig;
18114/// # async fn dox() {
18115/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18116///
18117/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18118/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18119/// # .with_native_roots()
18120/// # .unwrap()
18121/// # .https_only()
18122/// # .enable_http2()
18123/// # .build();
18124///
18125/// # let executor = hyper_util::rt::TokioExecutor::new();
18126/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18127/// # secret,
18128/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18129/// # yup_oauth2::client::CustomHyperClientBuilder::from(
18130/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
18131/// # ),
18132/// # ).build().await.unwrap();
18133///
18134/// # let client = hyper_util::client::legacy::Client::builder(
18135/// # hyper_util::rt::TokioExecutor::new()
18136/// # )
18137/// # .build(
18138/// # hyper_rustls::HttpsConnectorBuilder::new()
18139/// # .with_native_roots()
18140/// # .unwrap()
18141/// # .https_or_http()
18142/// # .enable_http2()
18143/// # .build()
18144/// # );
18145/// # let mut hub = CloudBuild::new(client, auth);
18146/// // As the method needs a request, you would usually fill it with the desired information
18147/// // into the respective structure. Some of the parts shown here might not be applicable !
18148/// // Values shown here are possibly random and not representative !
18149/// let mut req = GitHubEnterpriseConfig::default();
18150///
18151/// // You can configure optional parameters by calling the respective setters at will, and
18152/// // execute the final call using `doit()`.
18153/// // Values shown here are possibly random and not representative !
18154/// let result = hub.projects().locations_github_enterprise_configs_patch(req, "name")
18155/// .update_mask(FieldMask::new::<&str>(&[]))
18156/// .doit().await;
18157/// # }
18158/// ```
18159pub struct ProjectLocationGithubEnterpriseConfigPatchCall<'a, C>
18160where
18161 C: 'a,
18162{
18163 hub: &'a CloudBuild<C>,
18164 _request: GitHubEnterpriseConfig,
18165 _name: String,
18166 _update_mask: Option<common::FieldMask>,
18167 _delegate: Option<&'a mut dyn common::Delegate>,
18168 _additional_params: HashMap<String, String>,
18169 _scopes: BTreeSet<String>,
18170}
18171
18172impl<'a, C> common::CallBuilder for ProjectLocationGithubEnterpriseConfigPatchCall<'a, C> {}
18173
18174impl<'a, C> ProjectLocationGithubEnterpriseConfigPatchCall<'a, C>
18175where
18176 C: common::Connector,
18177{
18178 /// Perform the operation you have build so far.
18179 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
18180 use std::borrow::Cow;
18181 use std::io::{Read, Seek};
18182
18183 use common::{url::Params, ToParts};
18184 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18185
18186 let mut dd = common::DefaultDelegate;
18187 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18188 dlg.begin(common::MethodInfo {
18189 id: "cloudbuild.projects.locations.githubEnterpriseConfigs.patch",
18190 http_method: hyper::Method::PATCH,
18191 });
18192
18193 for &field in ["alt", "name", "updateMask"].iter() {
18194 if self._additional_params.contains_key(field) {
18195 dlg.finished(false);
18196 return Err(common::Error::FieldClash(field));
18197 }
18198 }
18199
18200 let mut params = Params::with_capacity(5 + self._additional_params.len());
18201 params.push("name", self._name);
18202 if let Some(value) = self._update_mask.as_ref() {
18203 params.push("updateMask", value.to_string());
18204 }
18205
18206 params.extend(self._additional_params.iter());
18207
18208 params.push("alt", "json");
18209 let mut url = self.hub._base_url.clone() + "v1/{+name}";
18210 if self._scopes.is_empty() {
18211 self._scopes
18212 .insert(Scope::CloudPlatform.as_ref().to_string());
18213 }
18214
18215 #[allow(clippy::single_element_loop)]
18216 for &(find_this, param_name) in [("{+name}", "name")].iter() {
18217 url = params.uri_replacement(url, param_name, find_this, true);
18218 }
18219 {
18220 let to_remove = ["name"];
18221 params.remove_params(&to_remove);
18222 }
18223
18224 let url = params.parse_with_url(&url);
18225
18226 let mut json_mime_type = mime::APPLICATION_JSON;
18227 let mut request_value_reader = {
18228 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18229 common::remove_json_null_values(&mut value);
18230 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18231 serde_json::to_writer(&mut dst, &value).unwrap();
18232 dst
18233 };
18234 let request_size = request_value_reader
18235 .seek(std::io::SeekFrom::End(0))
18236 .unwrap();
18237 request_value_reader
18238 .seek(std::io::SeekFrom::Start(0))
18239 .unwrap();
18240
18241 loop {
18242 let token = match self
18243 .hub
18244 .auth
18245 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18246 .await
18247 {
18248 Ok(token) => token,
18249 Err(e) => match dlg.token(e) {
18250 Ok(token) => token,
18251 Err(e) => {
18252 dlg.finished(false);
18253 return Err(common::Error::MissingToken(e));
18254 }
18255 },
18256 };
18257 request_value_reader
18258 .seek(std::io::SeekFrom::Start(0))
18259 .unwrap();
18260 let mut req_result = {
18261 let client = &self.hub.client;
18262 dlg.pre_request();
18263 let mut req_builder = hyper::Request::builder()
18264 .method(hyper::Method::PATCH)
18265 .uri(url.as_str())
18266 .header(USER_AGENT, self.hub._user_agent.clone());
18267
18268 if let Some(token) = token.as_ref() {
18269 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18270 }
18271
18272 let request = req_builder
18273 .header(CONTENT_TYPE, json_mime_type.to_string())
18274 .header(CONTENT_LENGTH, request_size as u64)
18275 .body(common::to_body(
18276 request_value_reader.get_ref().clone().into(),
18277 ));
18278
18279 client.request(request.unwrap()).await
18280 };
18281
18282 match req_result {
18283 Err(err) => {
18284 if let common::Retry::After(d) = dlg.http_error(&err) {
18285 sleep(d).await;
18286 continue;
18287 }
18288 dlg.finished(false);
18289 return Err(common::Error::HttpError(err));
18290 }
18291 Ok(res) => {
18292 let (mut parts, body) = res.into_parts();
18293 let mut body = common::Body::new(body);
18294 if !parts.status.is_success() {
18295 let bytes = common::to_bytes(body).await.unwrap_or_default();
18296 let error = serde_json::from_str(&common::to_string(&bytes));
18297 let response = common::to_response(parts, bytes.into());
18298
18299 if let common::Retry::After(d) =
18300 dlg.http_failure(&response, error.as_ref().ok())
18301 {
18302 sleep(d).await;
18303 continue;
18304 }
18305
18306 dlg.finished(false);
18307
18308 return Err(match error {
18309 Ok(value) => common::Error::BadRequest(value),
18310 _ => common::Error::Failure(response),
18311 });
18312 }
18313 let response = {
18314 let bytes = common::to_bytes(body).await.unwrap_or_default();
18315 let encoded = common::to_string(&bytes);
18316 match serde_json::from_str(&encoded) {
18317 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18318 Err(error) => {
18319 dlg.response_json_decode_error(&encoded, &error);
18320 return Err(common::Error::JsonDecodeError(
18321 encoded.to_string(),
18322 error,
18323 ));
18324 }
18325 }
18326 };
18327
18328 dlg.finished(true);
18329 return Ok(response);
18330 }
18331 }
18332 }
18333 }
18334
18335 ///
18336 /// Sets the *request* property to the given value.
18337 ///
18338 /// Even though the property as already been set when instantiating this call,
18339 /// we provide this method for API completeness.
18340 pub fn request(
18341 mut self,
18342 new_value: GitHubEnterpriseConfig,
18343 ) -> ProjectLocationGithubEnterpriseConfigPatchCall<'a, C> {
18344 self._request = new_value;
18345 self
18346 }
18347 /// The full resource name for the GitHubEnterpriseConfig For example: "projects/{$project_id}/locations/{$location_id}/githubEnterpriseConfigs/{$config_id}"
18348 ///
18349 /// Sets the *name* path property to the given value.
18350 ///
18351 /// Even though the property as already been set when instantiating this call,
18352 /// we provide this method for API completeness.
18353 pub fn name(
18354 mut self,
18355 new_value: &str,
18356 ) -> ProjectLocationGithubEnterpriseConfigPatchCall<'a, C> {
18357 self._name = new_value.to_string();
18358 self
18359 }
18360 /// 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.
18361 ///
18362 /// Sets the *update mask* query property to the given value.
18363 pub fn update_mask(
18364 mut self,
18365 new_value: common::FieldMask,
18366 ) -> ProjectLocationGithubEnterpriseConfigPatchCall<'a, C> {
18367 self._update_mask = Some(new_value);
18368 self
18369 }
18370 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18371 /// while executing the actual API request.
18372 ///
18373 /// ````text
18374 /// It should be used to handle progress information, and to implement a certain level of resilience.
18375 /// ````
18376 ///
18377 /// Sets the *delegate* property to the given value.
18378 pub fn delegate(
18379 mut self,
18380 new_value: &'a mut dyn common::Delegate,
18381 ) -> ProjectLocationGithubEnterpriseConfigPatchCall<'a, C> {
18382 self._delegate = Some(new_value);
18383 self
18384 }
18385
18386 /// Set any additional parameter of the query string used in the request.
18387 /// It should be used to set parameters which are not yet available through their own
18388 /// setters.
18389 ///
18390 /// Please note that this method must not be used to set any of the known parameters
18391 /// which have their own setter method. If done anyway, the request will fail.
18392 ///
18393 /// # Additional Parameters
18394 ///
18395 /// * *$.xgafv* (query-string) - V1 error format.
18396 /// * *access_token* (query-string) - OAuth access token.
18397 /// * *alt* (query-string) - Data format for response.
18398 /// * *callback* (query-string) - JSONP
18399 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18400 /// * *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.
18401 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18402 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18403 /// * *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.
18404 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18405 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18406 pub fn param<T>(
18407 mut self,
18408 name: T,
18409 value: T,
18410 ) -> ProjectLocationGithubEnterpriseConfigPatchCall<'a, C>
18411 where
18412 T: AsRef<str>,
18413 {
18414 self._additional_params
18415 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18416 self
18417 }
18418
18419 /// Identifies the authorization scope for the method you are building.
18420 ///
18421 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18422 /// [`Scope::CloudPlatform`].
18423 ///
18424 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18425 /// tokens for more than one scope.
18426 ///
18427 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18428 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18429 /// sufficient, a read-write scope will do as well.
18430 pub fn add_scope<St>(
18431 mut self,
18432 scope: St,
18433 ) -> ProjectLocationGithubEnterpriseConfigPatchCall<'a, C>
18434 where
18435 St: AsRef<str>,
18436 {
18437 self._scopes.insert(String::from(scope.as_ref()));
18438 self
18439 }
18440 /// Identifies the authorization scope(s) for the method you are building.
18441 ///
18442 /// See [`Self::add_scope()`] for details.
18443 pub fn add_scopes<I, St>(
18444 mut self,
18445 scopes: I,
18446 ) -> ProjectLocationGithubEnterpriseConfigPatchCall<'a, C>
18447 where
18448 I: IntoIterator<Item = St>,
18449 St: AsRef<str>,
18450 {
18451 self._scopes
18452 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18453 self
18454 }
18455
18456 /// Removes all scopes, and no default scope will be used either.
18457 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18458 /// for details).
18459 pub fn clear_scopes(mut self) -> ProjectLocationGithubEnterpriseConfigPatchCall<'a, C> {
18460 self._scopes.clear();
18461 self
18462 }
18463}
18464
18465/// 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`.
18466///
18467/// A builder for the *locations.operations.cancel* method supported by a *project* resource.
18468/// It is not used directly, but through a [`ProjectMethods`] instance.
18469///
18470/// # Example
18471///
18472/// Instantiate a resource method builder
18473///
18474/// ```test_harness,no_run
18475/// # extern crate hyper;
18476/// # extern crate hyper_rustls;
18477/// # extern crate google_cloudbuild1 as cloudbuild1;
18478/// use cloudbuild1::api::CancelOperationRequest;
18479/// # async fn dox() {
18480/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18481///
18482/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18483/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18484/// # .with_native_roots()
18485/// # .unwrap()
18486/// # .https_only()
18487/// # .enable_http2()
18488/// # .build();
18489///
18490/// # let executor = hyper_util::rt::TokioExecutor::new();
18491/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18492/// # secret,
18493/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18494/// # yup_oauth2::client::CustomHyperClientBuilder::from(
18495/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
18496/// # ),
18497/// # ).build().await.unwrap();
18498///
18499/// # let client = hyper_util::client::legacy::Client::builder(
18500/// # hyper_util::rt::TokioExecutor::new()
18501/// # )
18502/// # .build(
18503/// # hyper_rustls::HttpsConnectorBuilder::new()
18504/// # .with_native_roots()
18505/// # .unwrap()
18506/// # .https_or_http()
18507/// # .enable_http2()
18508/// # .build()
18509/// # );
18510/// # let mut hub = CloudBuild::new(client, auth);
18511/// // As the method needs a request, you would usually fill it with the desired information
18512/// // into the respective structure. Some of the parts shown here might not be applicable !
18513/// // Values shown here are possibly random and not representative !
18514/// let mut req = CancelOperationRequest::default();
18515///
18516/// // You can configure optional parameters by calling the respective setters at will, and
18517/// // execute the final call using `doit()`.
18518/// // Values shown here are possibly random and not representative !
18519/// let result = hub.projects().locations_operations_cancel(req, "name")
18520/// .doit().await;
18521/// # }
18522/// ```
18523pub struct ProjectLocationOperationCancelCall<'a, C>
18524where
18525 C: 'a,
18526{
18527 hub: &'a CloudBuild<C>,
18528 _request: CancelOperationRequest,
18529 _name: String,
18530 _delegate: Option<&'a mut dyn common::Delegate>,
18531 _additional_params: HashMap<String, String>,
18532 _scopes: BTreeSet<String>,
18533}
18534
18535impl<'a, C> common::CallBuilder for ProjectLocationOperationCancelCall<'a, C> {}
18536
18537impl<'a, C> ProjectLocationOperationCancelCall<'a, C>
18538where
18539 C: common::Connector,
18540{
18541 /// Perform the operation you have build so far.
18542 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
18543 use std::borrow::Cow;
18544 use std::io::{Read, Seek};
18545
18546 use common::{url::Params, ToParts};
18547 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18548
18549 let mut dd = common::DefaultDelegate;
18550 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18551 dlg.begin(common::MethodInfo {
18552 id: "cloudbuild.projects.locations.operations.cancel",
18553 http_method: hyper::Method::POST,
18554 });
18555
18556 for &field in ["alt", "name"].iter() {
18557 if self._additional_params.contains_key(field) {
18558 dlg.finished(false);
18559 return Err(common::Error::FieldClash(field));
18560 }
18561 }
18562
18563 let mut params = Params::with_capacity(4 + self._additional_params.len());
18564 params.push("name", self._name);
18565
18566 params.extend(self._additional_params.iter());
18567
18568 params.push("alt", "json");
18569 let mut url = self.hub._base_url.clone() + "v1/{+name}:cancel";
18570 if self._scopes.is_empty() {
18571 self._scopes
18572 .insert(Scope::CloudPlatform.as_ref().to_string());
18573 }
18574
18575 #[allow(clippy::single_element_loop)]
18576 for &(find_this, param_name) in [("{+name}", "name")].iter() {
18577 url = params.uri_replacement(url, param_name, find_this, true);
18578 }
18579 {
18580 let to_remove = ["name"];
18581 params.remove_params(&to_remove);
18582 }
18583
18584 let url = params.parse_with_url(&url);
18585
18586 let mut json_mime_type = mime::APPLICATION_JSON;
18587 let mut request_value_reader = {
18588 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18589 common::remove_json_null_values(&mut value);
18590 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18591 serde_json::to_writer(&mut dst, &value).unwrap();
18592 dst
18593 };
18594 let request_size = request_value_reader
18595 .seek(std::io::SeekFrom::End(0))
18596 .unwrap();
18597 request_value_reader
18598 .seek(std::io::SeekFrom::Start(0))
18599 .unwrap();
18600
18601 loop {
18602 let token = match self
18603 .hub
18604 .auth
18605 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18606 .await
18607 {
18608 Ok(token) => token,
18609 Err(e) => match dlg.token(e) {
18610 Ok(token) => token,
18611 Err(e) => {
18612 dlg.finished(false);
18613 return Err(common::Error::MissingToken(e));
18614 }
18615 },
18616 };
18617 request_value_reader
18618 .seek(std::io::SeekFrom::Start(0))
18619 .unwrap();
18620 let mut req_result = {
18621 let client = &self.hub.client;
18622 dlg.pre_request();
18623 let mut req_builder = hyper::Request::builder()
18624 .method(hyper::Method::POST)
18625 .uri(url.as_str())
18626 .header(USER_AGENT, self.hub._user_agent.clone());
18627
18628 if let Some(token) = token.as_ref() {
18629 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18630 }
18631
18632 let request = req_builder
18633 .header(CONTENT_TYPE, json_mime_type.to_string())
18634 .header(CONTENT_LENGTH, request_size as u64)
18635 .body(common::to_body(
18636 request_value_reader.get_ref().clone().into(),
18637 ));
18638
18639 client.request(request.unwrap()).await
18640 };
18641
18642 match req_result {
18643 Err(err) => {
18644 if let common::Retry::After(d) = dlg.http_error(&err) {
18645 sleep(d).await;
18646 continue;
18647 }
18648 dlg.finished(false);
18649 return Err(common::Error::HttpError(err));
18650 }
18651 Ok(res) => {
18652 let (mut parts, body) = res.into_parts();
18653 let mut body = common::Body::new(body);
18654 if !parts.status.is_success() {
18655 let bytes = common::to_bytes(body).await.unwrap_or_default();
18656 let error = serde_json::from_str(&common::to_string(&bytes));
18657 let response = common::to_response(parts, bytes.into());
18658
18659 if let common::Retry::After(d) =
18660 dlg.http_failure(&response, error.as_ref().ok())
18661 {
18662 sleep(d).await;
18663 continue;
18664 }
18665
18666 dlg.finished(false);
18667
18668 return Err(match error {
18669 Ok(value) => common::Error::BadRequest(value),
18670 _ => common::Error::Failure(response),
18671 });
18672 }
18673 let response = {
18674 let bytes = common::to_bytes(body).await.unwrap_or_default();
18675 let encoded = common::to_string(&bytes);
18676 match serde_json::from_str(&encoded) {
18677 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18678 Err(error) => {
18679 dlg.response_json_decode_error(&encoded, &error);
18680 return Err(common::Error::JsonDecodeError(
18681 encoded.to_string(),
18682 error,
18683 ));
18684 }
18685 }
18686 };
18687
18688 dlg.finished(true);
18689 return Ok(response);
18690 }
18691 }
18692 }
18693 }
18694
18695 ///
18696 /// Sets the *request* property to the given value.
18697 ///
18698 /// Even though the property as already been set when instantiating this call,
18699 /// we provide this method for API completeness.
18700 pub fn request(
18701 mut self,
18702 new_value: CancelOperationRequest,
18703 ) -> ProjectLocationOperationCancelCall<'a, C> {
18704 self._request = new_value;
18705 self
18706 }
18707 /// The name of the operation resource to be cancelled.
18708 ///
18709 /// Sets the *name* path property to the given value.
18710 ///
18711 /// Even though the property as already been set when instantiating this call,
18712 /// we provide this method for API completeness.
18713 pub fn name(mut self, new_value: &str) -> ProjectLocationOperationCancelCall<'a, C> {
18714 self._name = new_value.to_string();
18715 self
18716 }
18717 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18718 /// while executing the actual API request.
18719 ///
18720 /// ````text
18721 /// It should be used to handle progress information, and to implement a certain level of resilience.
18722 /// ````
18723 ///
18724 /// Sets the *delegate* property to the given value.
18725 pub fn delegate(
18726 mut self,
18727 new_value: &'a mut dyn common::Delegate,
18728 ) -> ProjectLocationOperationCancelCall<'a, C> {
18729 self._delegate = Some(new_value);
18730 self
18731 }
18732
18733 /// Set any additional parameter of the query string used in the request.
18734 /// It should be used to set parameters which are not yet available through their own
18735 /// setters.
18736 ///
18737 /// Please note that this method must not be used to set any of the known parameters
18738 /// which have their own setter method. If done anyway, the request will fail.
18739 ///
18740 /// # Additional Parameters
18741 ///
18742 /// * *$.xgafv* (query-string) - V1 error format.
18743 /// * *access_token* (query-string) - OAuth access token.
18744 /// * *alt* (query-string) - Data format for response.
18745 /// * *callback* (query-string) - JSONP
18746 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18747 /// * *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.
18748 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18749 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18750 /// * *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.
18751 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18752 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18753 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationCancelCall<'a, C>
18754 where
18755 T: AsRef<str>,
18756 {
18757 self._additional_params
18758 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18759 self
18760 }
18761
18762 /// Identifies the authorization scope for the method you are building.
18763 ///
18764 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18765 /// [`Scope::CloudPlatform`].
18766 ///
18767 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18768 /// tokens for more than one scope.
18769 ///
18770 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18771 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18772 /// sufficient, a read-write scope will do as well.
18773 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationCancelCall<'a, C>
18774 where
18775 St: AsRef<str>,
18776 {
18777 self._scopes.insert(String::from(scope.as_ref()));
18778 self
18779 }
18780 /// Identifies the authorization scope(s) for the method you are building.
18781 ///
18782 /// See [`Self::add_scope()`] for details.
18783 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationCancelCall<'a, C>
18784 where
18785 I: IntoIterator<Item = St>,
18786 St: AsRef<str>,
18787 {
18788 self._scopes
18789 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18790 self
18791 }
18792
18793 /// Removes all scopes, and no default scope will be used either.
18794 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18795 /// for details).
18796 pub fn clear_scopes(mut self) -> ProjectLocationOperationCancelCall<'a, C> {
18797 self._scopes.clear();
18798 self
18799 }
18800}
18801
18802/// 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.
18803///
18804/// A builder for the *locations.operations.get* method supported by a *project* resource.
18805/// It is not used directly, but through a [`ProjectMethods`] instance.
18806///
18807/// # Example
18808///
18809/// Instantiate a resource method builder
18810///
18811/// ```test_harness,no_run
18812/// # extern crate hyper;
18813/// # extern crate hyper_rustls;
18814/// # extern crate google_cloudbuild1 as cloudbuild1;
18815/// # async fn dox() {
18816/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18817///
18818/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18819/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18820/// # .with_native_roots()
18821/// # .unwrap()
18822/// # .https_only()
18823/// # .enable_http2()
18824/// # .build();
18825///
18826/// # let executor = hyper_util::rt::TokioExecutor::new();
18827/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18828/// # secret,
18829/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18830/// # yup_oauth2::client::CustomHyperClientBuilder::from(
18831/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
18832/// # ),
18833/// # ).build().await.unwrap();
18834///
18835/// # let client = hyper_util::client::legacy::Client::builder(
18836/// # hyper_util::rt::TokioExecutor::new()
18837/// # )
18838/// # .build(
18839/// # hyper_rustls::HttpsConnectorBuilder::new()
18840/// # .with_native_roots()
18841/// # .unwrap()
18842/// # .https_or_http()
18843/// # .enable_http2()
18844/// # .build()
18845/// # );
18846/// # let mut hub = CloudBuild::new(client, auth);
18847/// // You can configure optional parameters by calling the respective setters at will, and
18848/// // execute the final call using `doit()`.
18849/// // Values shown here are possibly random and not representative !
18850/// let result = hub.projects().locations_operations_get("name")
18851/// .doit().await;
18852/// # }
18853/// ```
18854pub struct ProjectLocationOperationGetCall<'a, C>
18855where
18856 C: 'a,
18857{
18858 hub: &'a CloudBuild<C>,
18859 _name: String,
18860 _delegate: Option<&'a mut dyn common::Delegate>,
18861 _additional_params: HashMap<String, String>,
18862 _scopes: BTreeSet<String>,
18863}
18864
18865impl<'a, C> common::CallBuilder for ProjectLocationOperationGetCall<'a, C> {}
18866
18867impl<'a, C> ProjectLocationOperationGetCall<'a, C>
18868where
18869 C: common::Connector,
18870{
18871 /// Perform the operation you have build so far.
18872 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
18873 use std::borrow::Cow;
18874 use std::io::{Read, Seek};
18875
18876 use common::{url::Params, ToParts};
18877 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18878
18879 let mut dd = common::DefaultDelegate;
18880 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18881 dlg.begin(common::MethodInfo {
18882 id: "cloudbuild.projects.locations.operations.get",
18883 http_method: hyper::Method::GET,
18884 });
18885
18886 for &field in ["alt", "name"].iter() {
18887 if self._additional_params.contains_key(field) {
18888 dlg.finished(false);
18889 return Err(common::Error::FieldClash(field));
18890 }
18891 }
18892
18893 let mut params = Params::with_capacity(3 + self._additional_params.len());
18894 params.push("name", self._name);
18895
18896 params.extend(self._additional_params.iter());
18897
18898 params.push("alt", "json");
18899 let mut url = self.hub._base_url.clone() + "v1/{+name}";
18900 if self._scopes.is_empty() {
18901 self._scopes
18902 .insert(Scope::CloudPlatform.as_ref().to_string());
18903 }
18904
18905 #[allow(clippy::single_element_loop)]
18906 for &(find_this, param_name) in [("{+name}", "name")].iter() {
18907 url = params.uri_replacement(url, param_name, find_this, true);
18908 }
18909 {
18910 let to_remove = ["name"];
18911 params.remove_params(&to_remove);
18912 }
18913
18914 let url = params.parse_with_url(&url);
18915
18916 loop {
18917 let token = match self
18918 .hub
18919 .auth
18920 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18921 .await
18922 {
18923 Ok(token) => token,
18924 Err(e) => match dlg.token(e) {
18925 Ok(token) => token,
18926 Err(e) => {
18927 dlg.finished(false);
18928 return Err(common::Error::MissingToken(e));
18929 }
18930 },
18931 };
18932 let mut req_result = {
18933 let client = &self.hub.client;
18934 dlg.pre_request();
18935 let mut req_builder = hyper::Request::builder()
18936 .method(hyper::Method::GET)
18937 .uri(url.as_str())
18938 .header(USER_AGENT, self.hub._user_agent.clone());
18939
18940 if let Some(token) = token.as_ref() {
18941 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18942 }
18943
18944 let request = req_builder
18945 .header(CONTENT_LENGTH, 0_u64)
18946 .body(common::to_body::<String>(None));
18947
18948 client.request(request.unwrap()).await
18949 };
18950
18951 match req_result {
18952 Err(err) => {
18953 if let common::Retry::After(d) = dlg.http_error(&err) {
18954 sleep(d).await;
18955 continue;
18956 }
18957 dlg.finished(false);
18958 return Err(common::Error::HttpError(err));
18959 }
18960 Ok(res) => {
18961 let (mut parts, body) = res.into_parts();
18962 let mut body = common::Body::new(body);
18963 if !parts.status.is_success() {
18964 let bytes = common::to_bytes(body).await.unwrap_or_default();
18965 let error = serde_json::from_str(&common::to_string(&bytes));
18966 let response = common::to_response(parts, bytes.into());
18967
18968 if let common::Retry::After(d) =
18969 dlg.http_failure(&response, error.as_ref().ok())
18970 {
18971 sleep(d).await;
18972 continue;
18973 }
18974
18975 dlg.finished(false);
18976
18977 return Err(match error {
18978 Ok(value) => common::Error::BadRequest(value),
18979 _ => common::Error::Failure(response),
18980 });
18981 }
18982 let response = {
18983 let bytes = common::to_bytes(body).await.unwrap_or_default();
18984 let encoded = common::to_string(&bytes);
18985 match serde_json::from_str(&encoded) {
18986 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18987 Err(error) => {
18988 dlg.response_json_decode_error(&encoded, &error);
18989 return Err(common::Error::JsonDecodeError(
18990 encoded.to_string(),
18991 error,
18992 ));
18993 }
18994 }
18995 };
18996
18997 dlg.finished(true);
18998 return Ok(response);
18999 }
19000 }
19001 }
19002 }
19003
19004 /// The name of the operation resource.
19005 ///
19006 /// Sets the *name* path property to the given value.
19007 ///
19008 /// Even though the property as already been set when instantiating this call,
19009 /// we provide this method for API completeness.
19010 pub fn name(mut self, new_value: &str) -> ProjectLocationOperationGetCall<'a, C> {
19011 self._name = new_value.to_string();
19012 self
19013 }
19014 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19015 /// while executing the actual API request.
19016 ///
19017 /// ````text
19018 /// It should be used to handle progress information, and to implement a certain level of resilience.
19019 /// ````
19020 ///
19021 /// Sets the *delegate* property to the given value.
19022 pub fn delegate(
19023 mut self,
19024 new_value: &'a mut dyn common::Delegate,
19025 ) -> ProjectLocationOperationGetCall<'a, C> {
19026 self._delegate = Some(new_value);
19027 self
19028 }
19029
19030 /// Set any additional parameter of the query string used in the request.
19031 /// It should be used to set parameters which are not yet available through their own
19032 /// setters.
19033 ///
19034 /// Please note that this method must not be used to set any of the known parameters
19035 /// which have their own setter method. If done anyway, the request will fail.
19036 ///
19037 /// # Additional Parameters
19038 ///
19039 /// * *$.xgafv* (query-string) - V1 error format.
19040 /// * *access_token* (query-string) - OAuth access token.
19041 /// * *alt* (query-string) - Data format for response.
19042 /// * *callback* (query-string) - JSONP
19043 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19044 /// * *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.
19045 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19046 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19047 /// * *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.
19048 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19049 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19050 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOperationGetCall<'a, C>
19051 where
19052 T: AsRef<str>,
19053 {
19054 self._additional_params
19055 .insert(name.as_ref().to_string(), value.as_ref().to_string());
19056 self
19057 }
19058
19059 /// Identifies the authorization scope for the method you are building.
19060 ///
19061 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19062 /// [`Scope::CloudPlatform`].
19063 ///
19064 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19065 /// tokens for more than one scope.
19066 ///
19067 /// Usually there is more than one suitable scope to authorize an operation, some of which may
19068 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19069 /// sufficient, a read-write scope will do as well.
19070 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOperationGetCall<'a, C>
19071 where
19072 St: AsRef<str>,
19073 {
19074 self._scopes.insert(String::from(scope.as_ref()));
19075 self
19076 }
19077 /// Identifies the authorization scope(s) for the method you are building.
19078 ///
19079 /// See [`Self::add_scope()`] for details.
19080 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOperationGetCall<'a, C>
19081 where
19082 I: IntoIterator<Item = St>,
19083 St: AsRef<str>,
19084 {
19085 self._scopes
19086 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19087 self
19088 }
19089
19090 /// Removes all scopes, and no default scope will be used either.
19091 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19092 /// for details).
19093 pub fn clear_scopes(mut self) -> ProjectLocationOperationGetCall<'a, C> {
19094 self._scopes.clear();
19095 self
19096 }
19097}
19098
19099/// Creates a new `BuildTrigger`.
19100///
19101/// A builder for the *locations.triggers.create* method supported by a *project* resource.
19102/// It is not used directly, but through a [`ProjectMethods`] instance.
19103///
19104/// # Example
19105///
19106/// Instantiate a resource method builder
19107///
19108/// ```test_harness,no_run
19109/// # extern crate hyper;
19110/// # extern crate hyper_rustls;
19111/// # extern crate google_cloudbuild1 as cloudbuild1;
19112/// use cloudbuild1::api::BuildTrigger;
19113/// # async fn dox() {
19114/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19115///
19116/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19117/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
19118/// # .with_native_roots()
19119/// # .unwrap()
19120/// # .https_only()
19121/// # .enable_http2()
19122/// # .build();
19123///
19124/// # let executor = hyper_util::rt::TokioExecutor::new();
19125/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
19126/// # secret,
19127/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19128/// # yup_oauth2::client::CustomHyperClientBuilder::from(
19129/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
19130/// # ),
19131/// # ).build().await.unwrap();
19132///
19133/// # let client = hyper_util::client::legacy::Client::builder(
19134/// # hyper_util::rt::TokioExecutor::new()
19135/// # )
19136/// # .build(
19137/// # hyper_rustls::HttpsConnectorBuilder::new()
19138/// # .with_native_roots()
19139/// # .unwrap()
19140/// # .https_or_http()
19141/// # .enable_http2()
19142/// # .build()
19143/// # );
19144/// # let mut hub = CloudBuild::new(client, auth);
19145/// // As the method needs a request, you would usually fill it with the desired information
19146/// // into the respective structure. Some of the parts shown here might not be applicable !
19147/// // Values shown here are possibly random and not representative !
19148/// let mut req = BuildTrigger::default();
19149///
19150/// // You can configure optional parameters by calling the respective setters at will, and
19151/// // execute the final call using `doit()`.
19152/// // Values shown here are possibly random and not representative !
19153/// let result = hub.projects().locations_triggers_create(req, "parent")
19154/// .project_id("ea")
19155/// .doit().await;
19156/// # }
19157/// ```
19158pub struct ProjectLocationTriggerCreateCall<'a, C>
19159where
19160 C: 'a,
19161{
19162 hub: &'a CloudBuild<C>,
19163 _request: BuildTrigger,
19164 _parent: String,
19165 _project_id: Option<String>,
19166 _delegate: Option<&'a mut dyn common::Delegate>,
19167 _additional_params: HashMap<String, String>,
19168 _scopes: BTreeSet<String>,
19169}
19170
19171impl<'a, C> common::CallBuilder for ProjectLocationTriggerCreateCall<'a, C> {}
19172
19173impl<'a, C> ProjectLocationTriggerCreateCall<'a, C>
19174where
19175 C: common::Connector,
19176{
19177 /// Perform the operation you have build so far.
19178 pub async fn doit(mut self) -> common::Result<(common::Response, BuildTrigger)> {
19179 use std::borrow::Cow;
19180 use std::io::{Read, Seek};
19181
19182 use common::{url::Params, ToParts};
19183 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19184
19185 let mut dd = common::DefaultDelegate;
19186 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19187 dlg.begin(common::MethodInfo {
19188 id: "cloudbuild.projects.locations.triggers.create",
19189 http_method: hyper::Method::POST,
19190 });
19191
19192 for &field in ["alt", "parent", "projectId"].iter() {
19193 if self._additional_params.contains_key(field) {
19194 dlg.finished(false);
19195 return Err(common::Error::FieldClash(field));
19196 }
19197 }
19198
19199 let mut params = Params::with_capacity(5 + self._additional_params.len());
19200 params.push("parent", self._parent);
19201 if let Some(value) = self._project_id.as_ref() {
19202 params.push("projectId", value);
19203 }
19204
19205 params.extend(self._additional_params.iter());
19206
19207 params.push("alt", "json");
19208 let mut url = self.hub._base_url.clone() + "v1/{+parent}/triggers";
19209 if self._scopes.is_empty() {
19210 self._scopes
19211 .insert(Scope::CloudPlatform.as_ref().to_string());
19212 }
19213
19214 #[allow(clippy::single_element_loop)]
19215 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
19216 url = params.uri_replacement(url, param_name, find_this, true);
19217 }
19218 {
19219 let to_remove = ["parent"];
19220 params.remove_params(&to_remove);
19221 }
19222
19223 let url = params.parse_with_url(&url);
19224
19225 let mut json_mime_type = mime::APPLICATION_JSON;
19226 let mut request_value_reader = {
19227 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
19228 common::remove_json_null_values(&mut value);
19229 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
19230 serde_json::to_writer(&mut dst, &value).unwrap();
19231 dst
19232 };
19233 let request_size = request_value_reader
19234 .seek(std::io::SeekFrom::End(0))
19235 .unwrap();
19236 request_value_reader
19237 .seek(std::io::SeekFrom::Start(0))
19238 .unwrap();
19239
19240 loop {
19241 let token = match self
19242 .hub
19243 .auth
19244 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19245 .await
19246 {
19247 Ok(token) => token,
19248 Err(e) => match dlg.token(e) {
19249 Ok(token) => token,
19250 Err(e) => {
19251 dlg.finished(false);
19252 return Err(common::Error::MissingToken(e));
19253 }
19254 },
19255 };
19256 request_value_reader
19257 .seek(std::io::SeekFrom::Start(0))
19258 .unwrap();
19259 let mut req_result = {
19260 let client = &self.hub.client;
19261 dlg.pre_request();
19262 let mut req_builder = hyper::Request::builder()
19263 .method(hyper::Method::POST)
19264 .uri(url.as_str())
19265 .header(USER_AGENT, self.hub._user_agent.clone());
19266
19267 if let Some(token) = token.as_ref() {
19268 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19269 }
19270
19271 let request = req_builder
19272 .header(CONTENT_TYPE, json_mime_type.to_string())
19273 .header(CONTENT_LENGTH, request_size as u64)
19274 .body(common::to_body(
19275 request_value_reader.get_ref().clone().into(),
19276 ));
19277
19278 client.request(request.unwrap()).await
19279 };
19280
19281 match req_result {
19282 Err(err) => {
19283 if let common::Retry::After(d) = dlg.http_error(&err) {
19284 sleep(d).await;
19285 continue;
19286 }
19287 dlg.finished(false);
19288 return Err(common::Error::HttpError(err));
19289 }
19290 Ok(res) => {
19291 let (mut parts, body) = res.into_parts();
19292 let mut body = common::Body::new(body);
19293 if !parts.status.is_success() {
19294 let bytes = common::to_bytes(body).await.unwrap_or_default();
19295 let error = serde_json::from_str(&common::to_string(&bytes));
19296 let response = common::to_response(parts, bytes.into());
19297
19298 if let common::Retry::After(d) =
19299 dlg.http_failure(&response, error.as_ref().ok())
19300 {
19301 sleep(d).await;
19302 continue;
19303 }
19304
19305 dlg.finished(false);
19306
19307 return Err(match error {
19308 Ok(value) => common::Error::BadRequest(value),
19309 _ => common::Error::Failure(response),
19310 });
19311 }
19312 let response = {
19313 let bytes = common::to_bytes(body).await.unwrap_or_default();
19314 let encoded = common::to_string(&bytes);
19315 match serde_json::from_str(&encoded) {
19316 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19317 Err(error) => {
19318 dlg.response_json_decode_error(&encoded, &error);
19319 return Err(common::Error::JsonDecodeError(
19320 encoded.to_string(),
19321 error,
19322 ));
19323 }
19324 }
19325 };
19326
19327 dlg.finished(true);
19328 return Ok(response);
19329 }
19330 }
19331 }
19332 }
19333
19334 ///
19335 /// Sets the *request* property to the given value.
19336 ///
19337 /// Even though the property as already been set when instantiating this call,
19338 /// we provide this method for API completeness.
19339 pub fn request(mut self, new_value: BuildTrigger) -> ProjectLocationTriggerCreateCall<'a, C> {
19340 self._request = new_value;
19341 self
19342 }
19343 /// The parent resource where this trigger will be created. Format: `projects/{project}/locations/{location}`
19344 ///
19345 /// Sets the *parent* path property to the given value.
19346 ///
19347 /// Even though the property as already been set when instantiating this call,
19348 /// we provide this method for API completeness.
19349 pub fn parent(mut self, new_value: &str) -> ProjectLocationTriggerCreateCall<'a, C> {
19350 self._parent = new_value.to_string();
19351 self
19352 }
19353 /// Required. ID of the project for which to configure automatic builds.
19354 ///
19355 /// Sets the *project id* query property to the given value.
19356 pub fn project_id(mut self, new_value: &str) -> ProjectLocationTriggerCreateCall<'a, C> {
19357 self._project_id = Some(new_value.to_string());
19358 self
19359 }
19360 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19361 /// while executing the actual API request.
19362 ///
19363 /// ````text
19364 /// It should be used to handle progress information, and to implement a certain level of resilience.
19365 /// ````
19366 ///
19367 /// Sets the *delegate* property to the given value.
19368 pub fn delegate(
19369 mut self,
19370 new_value: &'a mut dyn common::Delegate,
19371 ) -> ProjectLocationTriggerCreateCall<'a, C> {
19372 self._delegate = Some(new_value);
19373 self
19374 }
19375
19376 /// Set any additional parameter of the query string used in the request.
19377 /// It should be used to set parameters which are not yet available through their own
19378 /// setters.
19379 ///
19380 /// Please note that this method must not be used to set any of the known parameters
19381 /// which have their own setter method. If done anyway, the request will fail.
19382 ///
19383 /// # Additional Parameters
19384 ///
19385 /// * *$.xgafv* (query-string) - V1 error format.
19386 /// * *access_token* (query-string) - OAuth access token.
19387 /// * *alt* (query-string) - Data format for response.
19388 /// * *callback* (query-string) - JSONP
19389 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19390 /// * *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.
19391 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19392 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19393 /// * *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.
19394 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19395 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19396 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationTriggerCreateCall<'a, C>
19397 where
19398 T: AsRef<str>,
19399 {
19400 self._additional_params
19401 .insert(name.as_ref().to_string(), value.as_ref().to_string());
19402 self
19403 }
19404
19405 /// Identifies the authorization scope for the method you are building.
19406 ///
19407 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19408 /// [`Scope::CloudPlatform`].
19409 ///
19410 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19411 /// tokens for more than one scope.
19412 ///
19413 /// Usually there is more than one suitable scope to authorize an operation, some of which may
19414 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19415 /// sufficient, a read-write scope will do as well.
19416 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationTriggerCreateCall<'a, C>
19417 where
19418 St: AsRef<str>,
19419 {
19420 self._scopes.insert(String::from(scope.as_ref()));
19421 self
19422 }
19423 /// Identifies the authorization scope(s) for the method you are building.
19424 ///
19425 /// See [`Self::add_scope()`] for details.
19426 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationTriggerCreateCall<'a, C>
19427 where
19428 I: IntoIterator<Item = St>,
19429 St: AsRef<str>,
19430 {
19431 self._scopes
19432 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19433 self
19434 }
19435
19436 /// Removes all scopes, and no default scope will be used either.
19437 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19438 /// for details).
19439 pub fn clear_scopes(mut self) -> ProjectLocationTriggerCreateCall<'a, C> {
19440 self._scopes.clear();
19441 self
19442 }
19443}
19444
19445/// Deletes a `BuildTrigger` by its project ID and trigger ID.
19446///
19447/// A builder for the *locations.triggers.delete* method supported by a *project* resource.
19448/// It is not used directly, but through a [`ProjectMethods`] instance.
19449///
19450/// # Example
19451///
19452/// Instantiate a resource method builder
19453///
19454/// ```test_harness,no_run
19455/// # extern crate hyper;
19456/// # extern crate hyper_rustls;
19457/// # extern crate google_cloudbuild1 as cloudbuild1;
19458/// # async fn dox() {
19459/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19460///
19461/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19462/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
19463/// # .with_native_roots()
19464/// # .unwrap()
19465/// # .https_only()
19466/// # .enable_http2()
19467/// # .build();
19468///
19469/// # let executor = hyper_util::rt::TokioExecutor::new();
19470/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
19471/// # secret,
19472/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19473/// # yup_oauth2::client::CustomHyperClientBuilder::from(
19474/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
19475/// # ),
19476/// # ).build().await.unwrap();
19477///
19478/// # let client = hyper_util::client::legacy::Client::builder(
19479/// # hyper_util::rt::TokioExecutor::new()
19480/// # )
19481/// # .build(
19482/// # hyper_rustls::HttpsConnectorBuilder::new()
19483/// # .with_native_roots()
19484/// # .unwrap()
19485/// # .https_or_http()
19486/// # .enable_http2()
19487/// # .build()
19488/// # );
19489/// # let mut hub = CloudBuild::new(client, auth);
19490/// // You can configure optional parameters by calling the respective setters at will, and
19491/// // execute the final call using `doit()`.
19492/// // Values shown here are possibly random and not representative !
19493/// let result = hub.projects().locations_triggers_delete("name")
19494/// .trigger_id("Lorem")
19495/// .project_id("invidunt")
19496/// .doit().await;
19497/// # }
19498/// ```
19499pub struct ProjectLocationTriggerDeleteCall<'a, C>
19500where
19501 C: 'a,
19502{
19503 hub: &'a CloudBuild<C>,
19504 _name: String,
19505 _trigger_id: Option<String>,
19506 _project_id: Option<String>,
19507 _delegate: Option<&'a mut dyn common::Delegate>,
19508 _additional_params: HashMap<String, String>,
19509 _scopes: BTreeSet<String>,
19510}
19511
19512impl<'a, C> common::CallBuilder for ProjectLocationTriggerDeleteCall<'a, C> {}
19513
19514impl<'a, C> ProjectLocationTriggerDeleteCall<'a, C>
19515where
19516 C: common::Connector,
19517{
19518 /// Perform the operation you have build so far.
19519 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
19520 use std::borrow::Cow;
19521 use std::io::{Read, Seek};
19522
19523 use common::{url::Params, ToParts};
19524 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19525
19526 let mut dd = common::DefaultDelegate;
19527 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19528 dlg.begin(common::MethodInfo {
19529 id: "cloudbuild.projects.locations.triggers.delete",
19530 http_method: hyper::Method::DELETE,
19531 });
19532
19533 for &field in ["alt", "name", "triggerId", "projectId"].iter() {
19534 if self._additional_params.contains_key(field) {
19535 dlg.finished(false);
19536 return Err(common::Error::FieldClash(field));
19537 }
19538 }
19539
19540 let mut params = Params::with_capacity(5 + self._additional_params.len());
19541 params.push("name", self._name);
19542 if let Some(value) = self._trigger_id.as_ref() {
19543 params.push("triggerId", value);
19544 }
19545 if let Some(value) = self._project_id.as_ref() {
19546 params.push("projectId", value);
19547 }
19548
19549 params.extend(self._additional_params.iter());
19550
19551 params.push("alt", "json");
19552 let mut url = self.hub._base_url.clone() + "v1/{+name}";
19553 if self._scopes.is_empty() {
19554 self._scopes
19555 .insert(Scope::CloudPlatform.as_ref().to_string());
19556 }
19557
19558 #[allow(clippy::single_element_loop)]
19559 for &(find_this, param_name) in [("{+name}", "name")].iter() {
19560 url = params.uri_replacement(url, param_name, find_this, true);
19561 }
19562 {
19563 let to_remove = ["name"];
19564 params.remove_params(&to_remove);
19565 }
19566
19567 let url = params.parse_with_url(&url);
19568
19569 loop {
19570 let token = match self
19571 .hub
19572 .auth
19573 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19574 .await
19575 {
19576 Ok(token) => token,
19577 Err(e) => match dlg.token(e) {
19578 Ok(token) => token,
19579 Err(e) => {
19580 dlg.finished(false);
19581 return Err(common::Error::MissingToken(e));
19582 }
19583 },
19584 };
19585 let mut req_result = {
19586 let client = &self.hub.client;
19587 dlg.pre_request();
19588 let mut req_builder = hyper::Request::builder()
19589 .method(hyper::Method::DELETE)
19590 .uri(url.as_str())
19591 .header(USER_AGENT, self.hub._user_agent.clone());
19592
19593 if let Some(token) = token.as_ref() {
19594 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19595 }
19596
19597 let request = req_builder
19598 .header(CONTENT_LENGTH, 0_u64)
19599 .body(common::to_body::<String>(None));
19600
19601 client.request(request.unwrap()).await
19602 };
19603
19604 match req_result {
19605 Err(err) => {
19606 if let common::Retry::After(d) = dlg.http_error(&err) {
19607 sleep(d).await;
19608 continue;
19609 }
19610 dlg.finished(false);
19611 return Err(common::Error::HttpError(err));
19612 }
19613 Ok(res) => {
19614 let (mut parts, body) = res.into_parts();
19615 let mut body = common::Body::new(body);
19616 if !parts.status.is_success() {
19617 let bytes = common::to_bytes(body).await.unwrap_or_default();
19618 let error = serde_json::from_str(&common::to_string(&bytes));
19619 let response = common::to_response(parts, bytes.into());
19620
19621 if let common::Retry::After(d) =
19622 dlg.http_failure(&response, error.as_ref().ok())
19623 {
19624 sleep(d).await;
19625 continue;
19626 }
19627
19628 dlg.finished(false);
19629
19630 return Err(match error {
19631 Ok(value) => common::Error::BadRequest(value),
19632 _ => common::Error::Failure(response),
19633 });
19634 }
19635 let response = {
19636 let bytes = common::to_bytes(body).await.unwrap_or_default();
19637 let encoded = common::to_string(&bytes);
19638 match serde_json::from_str(&encoded) {
19639 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19640 Err(error) => {
19641 dlg.response_json_decode_error(&encoded, &error);
19642 return Err(common::Error::JsonDecodeError(
19643 encoded.to_string(),
19644 error,
19645 ));
19646 }
19647 }
19648 };
19649
19650 dlg.finished(true);
19651 return Ok(response);
19652 }
19653 }
19654 }
19655 }
19656
19657 /// The name of the `Trigger` to delete. Format: `projects/{project}/locations/{location}/triggers/{trigger}`
19658 ///
19659 /// Sets the *name* path property to the given value.
19660 ///
19661 /// Even though the property as already been set when instantiating this call,
19662 /// we provide this method for API completeness.
19663 pub fn name(mut self, new_value: &str) -> ProjectLocationTriggerDeleteCall<'a, C> {
19664 self._name = new_value.to_string();
19665 self
19666 }
19667 /// Required. ID of the `BuildTrigger` to delete.
19668 ///
19669 /// Sets the *trigger id* query property to the given value.
19670 pub fn trigger_id(mut self, new_value: &str) -> ProjectLocationTriggerDeleteCall<'a, C> {
19671 self._trigger_id = Some(new_value.to_string());
19672 self
19673 }
19674 /// Required. ID of the project that owns the trigger.
19675 ///
19676 /// Sets the *project id* query property to the given value.
19677 pub fn project_id(mut self, new_value: &str) -> ProjectLocationTriggerDeleteCall<'a, C> {
19678 self._project_id = Some(new_value.to_string());
19679 self
19680 }
19681 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
19682 /// while executing the actual API request.
19683 ///
19684 /// ````text
19685 /// It should be used to handle progress information, and to implement a certain level of resilience.
19686 /// ````
19687 ///
19688 /// Sets the *delegate* property to the given value.
19689 pub fn delegate(
19690 mut self,
19691 new_value: &'a mut dyn common::Delegate,
19692 ) -> ProjectLocationTriggerDeleteCall<'a, C> {
19693 self._delegate = Some(new_value);
19694 self
19695 }
19696
19697 /// Set any additional parameter of the query string used in the request.
19698 /// It should be used to set parameters which are not yet available through their own
19699 /// setters.
19700 ///
19701 /// Please note that this method must not be used to set any of the known parameters
19702 /// which have their own setter method. If done anyway, the request will fail.
19703 ///
19704 /// # Additional Parameters
19705 ///
19706 /// * *$.xgafv* (query-string) - V1 error format.
19707 /// * *access_token* (query-string) - OAuth access token.
19708 /// * *alt* (query-string) - Data format for response.
19709 /// * *callback* (query-string) - JSONP
19710 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
19711 /// * *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.
19712 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
19713 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
19714 /// * *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.
19715 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
19716 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
19717 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationTriggerDeleteCall<'a, C>
19718 where
19719 T: AsRef<str>,
19720 {
19721 self._additional_params
19722 .insert(name.as_ref().to_string(), value.as_ref().to_string());
19723 self
19724 }
19725
19726 /// Identifies the authorization scope for the method you are building.
19727 ///
19728 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
19729 /// [`Scope::CloudPlatform`].
19730 ///
19731 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
19732 /// tokens for more than one scope.
19733 ///
19734 /// Usually there is more than one suitable scope to authorize an operation, some of which may
19735 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
19736 /// sufficient, a read-write scope will do as well.
19737 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationTriggerDeleteCall<'a, C>
19738 where
19739 St: AsRef<str>,
19740 {
19741 self._scopes.insert(String::from(scope.as_ref()));
19742 self
19743 }
19744 /// Identifies the authorization scope(s) for the method you are building.
19745 ///
19746 /// See [`Self::add_scope()`] for details.
19747 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationTriggerDeleteCall<'a, C>
19748 where
19749 I: IntoIterator<Item = St>,
19750 St: AsRef<str>,
19751 {
19752 self._scopes
19753 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
19754 self
19755 }
19756
19757 /// Removes all scopes, and no default scope will be used either.
19758 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
19759 /// for details).
19760 pub fn clear_scopes(mut self) -> ProjectLocationTriggerDeleteCall<'a, C> {
19761 self._scopes.clear();
19762 self
19763 }
19764}
19765
19766/// Returns information about a `BuildTrigger`.
19767///
19768/// A builder for the *locations.triggers.get* method supported by a *project* resource.
19769/// It is not used directly, but through a [`ProjectMethods`] instance.
19770///
19771/// # Example
19772///
19773/// Instantiate a resource method builder
19774///
19775/// ```test_harness,no_run
19776/// # extern crate hyper;
19777/// # extern crate hyper_rustls;
19778/// # extern crate google_cloudbuild1 as cloudbuild1;
19779/// # async fn dox() {
19780/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
19781///
19782/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
19783/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
19784/// # .with_native_roots()
19785/// # .unwrap()
19786/// # .https_only()
19787/// # .enable_http2()
19788/// # .build();
19789///
19790/// # let executor = hyper_util::rt::TokioExecutor::new();
19791/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
19792/// # secret,
19793/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
19794/// # yup_oauth2::client::CustomHyperClientBuilder::from(
19795/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
19796/// # ),
19797/// # ).build().await.unwrap();
19798///
19799/// # let client = hyper_util::client::legacy::Client::builder(
19800/// # hyper_util::rt::TokioExecutor::new()
19801/// # )
19802/// # .build(
19803/// # hyper_rustls::HttpsConnectorBuilder::new()
19804/// # .with_native_roots()
19805/// # .unwrap()
19806/// # .https_or_http()
19807/// # .enable_http2()
19808/// # .build()
19809/// # );
19810/// # let mut hub = CloudBuild::new(client, auth);
19811/// // You can configure optional parameters by calling the respective setters at will, and
19812/// // execute the final call using `doit()`.
19813/// // Values shown here are possibly random and not representative !
19814/// let result = hub.projects().locations_triggers_get("name")
19815/// .trigger_id("est")
19816/// .project_id("At")
19817/// .doit().await;
19818/// # }
19819/// ```
19820pub struct ProjectLocationTriggerGetCall<'a, C>
19821where
19822 C: 'a,
19823{
19824 hub: &'a CloudBuild<C>,
19825 _name: String,
19826 _trigger_id: Option<String>,
19827 _project_id: Option<String>,
19828 _delegate: Option<&'a mut dyn common::Delegate>,
19829 _additional_params: HashMap<String, String>,
19830 _scopes: BTreeSet<String>,
19831}
19832
19833impl<'a, C> common::CallBuilder for ProjectLocationTriggerGetCall<'a, C> {}
19834
19835impl<'a, C> ProjectLocationTriggerGetCall<'a, C>
19836where
19837 C: common::Connector,
19838{
19839 /// Perform the operation you have build so far.
19840 pub async fn doit(mut self) -> common::Result<(common::Response, BuildTrigger)> {
19841 use std::borrow::Cow;
19842 use std::io::{Read, Seek};
19843
19844 use common::{url::Params, ToParts};
19845 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
19846
19847 let mut dd = common::DefaultDelegate;
19848 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
19849 dlg.begin(common::MethodInfo {
19850 id: "cloudbuild.projects.locations.triggers.get",
19851 http_method: hyper::Method::GET,
19852 });
19853
19854 for &field in ["alt", "name", "triggerId", "projectId"].iter() {
19855 if self._additional_params.contains_key(field) {
19856 dlg.finished(false);
19857 return Err(common::Error::FieldClash(field));
19858 }
19859 }
19860
19861 let mut params = Params::with_capacity(5 + self._additional_params.len());
19862 params.push("name", self._name);
19863 if let Some(value) = self._trigger_id.as_ref() {
19864 params.push("triggerId", value);
19865 }
19866 if let Some(value) = self._project_id.as_ref() {
19867 params.push("projectId", value);
19868 }
19869
19870 params.extend(self._additional_params.iter());
19871
19872 params.push("alt", "json");
19873 let mut url = self.hub._base_url.clone() + "v1/{+name}";
19874 if self._scopes.is_empty() {
19875 self._scopes
19876 .insert(Scope::CloudPlatform.as_ref().to_string());
19877 }
19878
19879 #[allow(clippy::single_element_loop)]
19880 for &(find_this, param_name) in [("{+name}", "name")].iter() {
19881 url = params.uri_replacement(url, param_name, find_this, true);
19882 }
19883 {
19884 let to_remove = ["name"];
19885 params.remove_params(&to_remove);
19886 }
19887
19888 let url = params.parse_with_url(&url);
19889
19890 loop {
19891 let token = match self
19892 .hub
19893 .auth
19894 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
19895 .await
19896 {
19897 Ok(token) => token,
19898 Err(e) => match dlg.token(e) {
19899 Ok(token) => token,
19900 Err(e) => {
19901 dlg.finished(false);
19902 return Err(common::Error::MissingToken(e));
19903 }
19904 },
19905 };
19906 let mut req_result = {
19907 let client = &self.hub.client;
19908 dlg.pre_request();
19909 let mut req_builder = hyper::Request::builder()
19910 .method(hyper::Method::GET)
19911 .uri(url.as_str())
19912 .header(USER_AGENT, self.hub._user_agent.clone());
19913
19914 if let Some(token) = token.as_ref() {
19915 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
19916 }
19917
19918 let request = req_builder
19919 .header(CONTENT_LENGTH, 0_u64)
19920 .body(common::to_body::<String>(None));
19921
19922 client.request(request.unwrap()).await
19923 };
19924
19925 match req_result {
19926 Err(err) => {
19927 if let common::Retry::After(d) = dlg.http_error(&err) {
19928 sleep(d).await;
19929 continue;
19930 }
19931 dlg.finished(false);
19932 return Err(common::Error::HttpError(err));
19933 }
19934 Ok(res) => {
19935 let (mut parts, body) = res.into_parts();
19936 let mut body = common::Body::new(body);
19937 if !parts.status.is_success() {
19938 let bytes = common::to_bytes(body).await.unwrap_or_default();
19939 let error = serde_json::from_str(&common::to_string(&bytes));
19940 let response = common::to_response(parts, bytes.into());
19941
19942 if let common::Retry::After(d) =
19943 dlg.http_failure(&response, error.as_ref().ok())
19944 {
19945 sleep(d).await;
19946 continue;
19947 }
19948
19949 dlg.finished(false);
19950
19951 return Err(match error {
19952 Ok(value) => common::Error::BadRequest(value),
19953 _ => common::Error::Failure(response),
19954 });
19955 }
19956 let response = {
19957 let bytes = common::to_bytes(body).await.unwrap_or_default();
19958 let encoded = common::to_string(&bytes);
19959 match serde_json::from_str(&encoded) {
19960 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
19961 Err(error) => {
19962 dlg.response_json_decode_error(&encoded, &error);
19963 return Err(common::Error::JsonDecodeError(
19964 encoded.to_string(),
19965 error,
19966 ));
19967 }
19968 }
19969 };
19970
19971 dlg.finished(true);
19972 return Ok(response);
19973 }
19974 }
19975 }
19976 }
19977
19978 /// The name of the `Trigger` to retrieve. Format: `projects/{project}/locations/{location}/triggers/{trigger}`
19979 ///
19980 /// Sets the *name* path property to the given value.
19981 ///
19982 /// Even though the property as already been set when instantiating this call,
19983 /// we provide this method for API completeness.
19984 pub fn name(mut self, new_value: &str) -> ProjectLocationTriggerGetCall<'a, C> {
19985 self._name = new_value.to_string();
19986 self
19987 }
19988 /// Required. Identifier (`id` or `name`) of the `BuildTrigger` to get.
19989 ///
19990 /// Sets the *trigger id* query property to the given value.
19991 pub fn trigger_id(mut self, new_value: &str) -> ProjectLocationTriggerGetCall<'a, C> {
19992 self._trigger_id = Some(new_value.to_string());
19993 self
19994 }
19995 /// Required. ID of the project that owns the trigger.
19996 ///
19997 /// Sets the *project id* query property to the given value.
19998 pub fn project_id(mut self, new_value: &str) -> ProjectLocationTriggerGetCall<'a, C> {
19999 self._project_id = Some(new_value.to_string());
20000 self
20001 }
20002 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20003 /// while executing the actual API request.
20004 ///
20005 /// ````text
20006 /// It should be used to handle progress information, and to implement a certain level of resilience.
20007 /// ````
20008 ///
20009 /// Sets the *delegate* property to the given value.
20010 pub fn delegate(
20011 mut self,
20012 new_value: &'a mut dyn common::Delegate,
20013 ) -> ProjectLocationTriggerGetCall<'a, C> {
20014 self._delegate = Some(new_value);
20015 self
20016 }
20017
20018 /// Set any additional parameter of the query string used in the request.
20019 /// It should be used to set parameters which are not yet available through their own
20020 /// setters.
20021 ///
20022 /// Please note that this method must not be used to set any of the known parameters
20023 /// which have their own setter method. If done anyway, the request will fail.
20024 ///
20025 /// # Additional Parameters
20026 ///
20027 /// * *$.xgafv* (query-string) - V1 error format.
20028 /// * *access_token* (query-string) - OAuth access token.
20029 /// * *alt* (query-string) - Data format for response.
20030 /// * *callback* (query-string) - JSONP
20031 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20032 /// * *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.
20033 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20034 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20035 /// * *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.
20036 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20037 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20038 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationTriggerGetCall<'a, C>
20039 where
20040 T: AsRef<str>,
20041 {
20042 self._additional_params
20043 .insert(name.as_ref().to_string(), value.as_ref().to_string());
20044 self
20045 }
20046
20047 /// Identifies the authorization scope for the method you are building.
20048 ///
20049 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20050 /// [`Scope::CloudPlatform`].
20051 ///
20052 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20053 /// tokens for more than one scope.
20054 ///
20055 /// Usually there is more than one suitable scope to authorize an operation, some of which may
20056 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20057 /// sufficient, a read-write scope will do as well.
20058 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationTriggerGetCall<'a, C>
20059 where
20060 St: AsRef<str>,
20061 {
20062 self._scopes.insert(String::from(scope.as_ref()));
20063 self
20064 }
20065 /// Identifies the authorization scope(s) for the method you are building.
20066 ///
20067 /// See [`Self::add_scope()`] for details.
20068 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationTriggerGetCall<'a, C>
20069 where
20070 I: IntoIterator<Item = St>,
20071 St: AsRef<str>,
20072 {
20073 self._scopes
20074 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20075 self
20076 }
20077
20078 /// Removes all scopes, and no default scope will be used either.
20079 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20080 /// for details).
20081 pub fn clear_scopes(mut self) -> ProjectLocationTriggerGetCall<'a, C> {
20082 self._scopes.clear();
20083 self
20084 }
20085}
20086
20087/// Lists existing `BuildTrigger`s.
20088///
20089/// A builder for the *locations.triggers.list* method supported by a *project* resource.
20090/// It is not used directly, but through a [`ProjectMethods`] instance.
20091///
20092/// # Example
20093///
20094/// Instantiate a resource method builder
20095///
20096/// ```test_harness,no_run
20097/// # extern crate hyper;
20098/// # extern crate hyper_rustls;
20099/// # extern crate google_cloudbuild1 as cloudbuild1;
20100/// # async fn dox() {
20101/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20102///
20103/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20104/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20105/// # .with_native_roots()
20106/// # .unwrap()
20107/// # .https_only()
20108/// # .enable_http2()
20109/// # .build();
20110///
20111/// # let executor = hyper_util::rt::TokioExecutor::new();
20112/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
20113/// # secret,
20114/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20115/// # yup_oauth2::client::CustomHyperClientBuilder::from(
20116/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
20117/// # ),
20118/// # ).build().await.unwrap();
20119///
20120/// # let client = hyper_util::client::legacy::Client::builder(
20121/// # hyper_util::rt::TokioExecutor::new()
20122/// # )
20123/// # .build(
20124/// # hyper_rustls::HttpsConnectorBuilder::new()
20125/// # .with_native_roots()
20126/// # .unwrap()
20127/// # .https_or_http()
20128/// # .enable_http2()
20129/// # .build()
20130/// # );
20131/// # let mut hub = CloudBuild::new(client, auth);
20132/// // You can configure optional parameters by calling the respective setters at will, and
20133/// // execute the final call using `doit()`.
20134/// // Values shown here are possibly random and not representative !
20135/// let result = hub.projects().locations_triggers_list("parent")
20136/// .project_id("sit")
20137/// .page_token("et")
20138/// .page_size(-39)
20139/// .doit().await;
20140/// # }
20141/// ```
20142pub struct ProjectLocationTriggerListCall<'a, C>
20143where
20144 C: 'a,
20145{
20146 hub: &'a CloudBuild<C>,
20147 _parent: String,
20148 _project_id: Option<String>,
20149 _page_token: Option<String>,
20150 _page_size: Option<i32>,
20151 _delegate: Option<&'a mut dyn common::Delegate>,
20152 _additional_params: HashMap<String, String>,
20153 _scopes: BTreeSet<String>,
20154}
20155
20156impl<'a, C> common::CallBuilder for ProjectLocationTriggerListCall<'a, C> {}
20157
20158impl<'a, C> ProjectLocationTriggerListCall<'a, C>
20159where
20160 C: common::Connector,
20161{
20162 /// Perform the operation you have build so far.
20163 pub async fn doit(mut self) -> common::Result<(common::Response, ListBuildTriggersResponse)> {
20164 use std::borrow::Cow;
20165 use std::io::{Read, Seek};
20166
20167 use common::{url::Params, ToParts};
20168 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20169
20170 let mut dd = common::DefaultDelegate;
20171 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20172 dlg.begin(common::MethodInfo {
20173 id: "cloudbuild.projects.locations.triggers.list",
20174 http_method: hyper::Method::GET,
20175 });
20176
20177 for &field in ["alt", "parent", "projectId", "pageToken", "pageSize"].iter() {
20178 if self._additional_params.contains_key(field) {
20179 dlg.finished(false);
20180 return Err(common::Error::FieldClash(field));
20181 }
20182 }
20183
20184 let mut params = Params::with_capacity(6 + self._additional_params.len());
20185 params.push("parent", self._parent);
20186 if let Some(value) = self._project_id.as_ref() {
20187 params.push("projectId", value);
20188 }
20189 if let Some(value) = self._page_token.as_ref() {
20190 params.push("pageToken", value);
20191 }
20192 if let Some(value) = self._page_size.as_ref() {
20193 params.push("pageSize", value.to_string());
20194 }
20195
20196 params.extend(self._additional_params.iter());
20197
20198 params.push("alt", "json");
20199 let mut url = self.hub._base_url.clone() + "v1/{+parent}/triggers";
20200 if self._scopes.is_empty() {
20201 self._scopes
20202 .insert(Scope::CloudPlatform.as_ref().to_string());
20203 }
20204
20205 #[allow(clippy::single_element_loop)]
20206 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
20207 url = params.uri_replacement(url, param_name, find_this, true);
20208 }
20209 {
20210 let to_remove = ["parent"];
20211 params.remove_params(&to_remove);
20212 }
20213
20214 let url = params.parse_with_url(&url);
20215
20216 loop {
20217 let token = match self
20218 .hub
20219 .auth
20220 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20221 .await
20222 {
20223 Ok(token) => token,
20224 Err(e) => match dlg.token(e) {
20225 Ok(token) => token,
20226 Err(e) => {
20227 dlg.finished(false);
20228 return Err(common::Error::MissingToken(e));
20229 }
20230 },
20231 };
20232 let mut req_result = {
20233 let client = &self.hub.client;
20234 dlg.pre_request();
20235 let mut req_builder = hyper::Request::builder()
20236 .method(hyper::Method::GET)
20237 .uri(url.as_str())
20238 .header(USER_AGENT, self.hub._user_agent.clone());
20239
20240 if let Some(token) = token.as_ref() {
20241 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20242 }
20243
20244 let request = req_builder
20245 .header(CONTENT_LENGTH, 0_u64)
20246 .body(common::to_body::<String>(None));
20247
20248 client.request(request.unwrap()).await
20249 };
20250
20251 match req_result {
20252 Err(err) => {
20253 if let common::Retry::After(d) = dlg.http_error(&err) {
20254 sleep(d).await;
20255 continue;
20256 }
20257 dlg.finished(false);
20258 return Err(common::Error::HttpError(err));
20259 }
20260 Ok(res) => {
20261 let (mut parts, body) = res.into_parts();
20262 let mut body = common::Body::new(body);
20263 if !parts.status.is_success() {
20264 let bytes = common::to_bytes(body).await.unwrap_or_default();
20265 let error = serde_json::from_str(&common::to_string(&bytes));
20266 let response = common::to_response(parts, bytes.into());
20267
20268 if let common::Retry::After(d) =
20269 dlg.http_failure(&response, error.as_ref().ok())
20270 {
20271 sleep(d).await;
20272 continue;
20273 }
20274
20275 dlg.finished(false);
20276
20277 return Err(match error {
20278 Ok(value) => common::Error::BadRequest(value),
20279 _ => common::Error::Failure(response),
20280 });
20281 }
20282 let response = {
20283 let bytes = common::to_bytes(body).await.unwrap_or_default();
20284 let encoded = common::to_string(&bytes);
20285 match serde_json::from_str(&encoded) {
20286 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20287 Err(error) => {
20288 dlg.response_json_decode_error(&encoded, &error);
20289 return Err(common::Error::JsonDecodeError(
20290 encoded.to_string(),
20291 error,
20292 ));
20293 }
20294 }
20295 };
20296
20297 dlg.finished(true);
20298 return Ok(response);
20299 }
20300 }
20301 }
20302 }
20303
20304 /// The parent of the collection of `Triggers`. Format: `projects/{project}/locations/{location}`
20305 ///
20306 /// Sets the *parent* path property to the given value.
20307 ///
20308 /// Even though the property as already been set when instantiating this call,
20309 /// we provide this method for API completeness.
20310 pub fn parent(mut self, new_value: &str) -> ProjectLocationTriggerListCall<'a, C> {
20311 self._parent = new_value.to_string();
20312 self
20313 }
20314 /// Required. ID of the project for which to list BuildTriggers.
20315 ///
20316 /// Sets the *project id* query property to the given value.
20317 pub fn project_id(mut self, new_value: &str) -> ProjectLocationTriggerListCall<'a, C> {
20318 self._project_id = Some(new_value.to_string());
20319 self
20320 }
20321 /// Token to provide to skip to a particular spot in the list.
20322 ///
20323 /// Sets the *page token* query property to the given value.
20324 pub fn page_token(mut self, new_value: &str) -> ProjectLocationTriggerListCall<'a, C> {
20325 self._page_token = Some(new_value.to_string());
20326 self
20327 }
20328 /// Number of results to return in the list.
20329 ///
20330 /// Sets the *page size* query property to the given value.
20331 pub fn page_size(mut self, new_value: i32) -> ProjectLocationTriggerListCall<'a, C> {
20332 self._page_size = Some(new_value);
20333 self
20334 }
20335 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20336 /// while executing the actual API request.
20337 ///
20338 /// ````text
20339 /// It should be used to handle progress information, and to implement a certain level of resilience.
20340 /// ````
20341 ///
20342 /// Sets the *delegate* property to the given value.
20343 pub fn delegate(
20344 mut self,
20345 new_value: &'a mut dyn common::Delegate,
20346 ) -> ProjectLocationTriggerListCall<'a, C> {
20347 self._delegate = Some(new_value);
20348 self
20349 }
20350
20351 /// Set any additional parameter of the query string used in the request.
20352 /// It should be used to set parameters which are not yet available through their own
20353 /// setters.
20354 ///
20355 /// Please note that this method must not be used to set any of the known parameters
20356 /// which have their own setter method. If done anyway, the request will fail.
20357 ///
20358 /// # Additional Parameters
20359 ///
20360 /// * *$.xgafv* (query-string) - V1 error format.
20361 /// * *access_token* (query-string) - OAuth access token.
20362 /// * *alt* (query-string) - Data format for response.
20363 /// * *callback* (query-string) - JSONP
20364 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20365 /// * *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.
20366 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20367 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20368 /// * *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.
20369 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20370 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20371 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationTriggerListCall<'a, C>
20372 where
20373 T: AsRef<str>,
20374 {
20375 self._additional_params
20376 .insert(name.as_ref().to_string(), value.as_ref().to_string());
20377 self
20378 }
20379
20380 /// Identifies the authorization scope for the method you are building.
20381 ///
20382 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20383 /// [`Scope::CloudPlatform`].
20384 ///
20385 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20386 /// tokens for more than one scope.
20387 ///
20388 /// Usually there is more than one suitable scope to authorize an operation, some of which may
20389 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20390 /// sufficient, a read-write scope will do as well.
20391 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationTriggerListCall<'a, C>
20392 where
20393 St: AsRef<str>,
20394 {
20395 self._scopes.insert(String::from(scope.as_ref()));
20396 self
20397 }
20398 /// Identifies the authorization scope(s) for the method you are building.
20399 ///
20400 /// See [`Self::add_scope()`] for details.
20401 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationTriggerListCall<'a, C>
20402 where
20403 I: IntoIterator<Item = St>,
20404 St: AsRef<str>,
20405 {
20406 self._scopes
20407 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20408 self
20409 }
20410
20411 /// Removes all scopes, and no default scope will be used either.
20412 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20413 /// for details).
20414 pub fn clear_scopes(mut self) -> ProjectLocationTriggerListCall<'a, C> {
20415 self._scopes.clear();
20416 self
20417 }
20418}
20419
20420/// Updates a `BuildTrigger` by its project ID and trigger ID.
20421///
20422/// A builder for the *locations.triggers.patch* method supported by a *project* resource.
20423/// It is not used directly, but through a [`ProjectMethods`] instance.
20424///
20425/// # Example
20426///
20427/// Instantiate a resource method builder
20428///
20429/// ```test_harness,no_run
20430/// # extern crate hyper;
20431/// # extern crate hyper_rustls;
20432/// # extern crate google_cloudbuild1 as cloudbuild1;
20433/// use cloudbuild1::api::BuildTrigger;
20434/// # async fn dox() {
20435/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20436///
20437/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20438/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20439/// # .with_native_roots()
20440/// # .unwrap()
20441/// # .https_only()
20442/// # .enable_http2()
20443/// # .build();
20444///
20445/// # let executor = hyper_util::rt::TokioExecutor::new();
20446/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
20447/// # secret,
20448/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20449/// # yup_oauth2::client::CustomHyperClientBuilder::from(
20450/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
20451/// # ),
20452/// # ).build().await.unwrap();
20453///
20454/// # let client = hyper_util::client::legacy::Client::builder(
20455/// # hyper_util::rt::TokioExecutor::new()
20456/// # )
20457/// # .build(
20458/// # hyper_rustls::HttpsConnectorBuilder::new()
20459/// # .with_native_roots()
20460/// # .unwrap()
20461/// # .https_or_http()
20462/// # .enable_http2()
20463/// # .build()
20464/// # );
20465/// # let mut hub = CloudBuild::new(client, auth);
20466/// // As the method needs a request, you would usually fill it with the desired information
20467/// // into the respective structure. Some of the parts shown here might not be applicable !
20468/// // Values shown here are possibly random and not representative !
20469/// let mut req = BuildTrigger::default();
20470///
20471/// // You can configure optional parameters by calling the respective setters at will, and
20472/// // execute the final call using `doit()`.
20473/// // Values shown here are possibly random and not representative !
20474/// let result = hub.projects().locations_triggers_patch(req, "resourceName")
20475/// .update_mask(FieldMask::new::<&str>(&[]))
20476/// .trigger_id("ipsum")
20477/// .project_id("et")
20478/// .doit().await;
20479/// # }
20480/// ```
20481pub struct ProjectLocationTriggerPatchCall<'a, C>
20482where
20483 C: 'a,
20484{
20485 hub: &'a CloudBuild<C>,
20486 _request: BuildTrigger,
20487 _resource_name: String,
20488 _update_mask: Option<common::FieldMask>,
20489 _trigger_id: Option<String>,
20490 _project_id: Option<String>,
20491 _delegate: Option<&'a mut dyn common::Delegate>,
20492 _additional_params: HashMap<String, String>,
20493 _scopes: BTreeSet<String>,
20494}
20495
20496impl<'a, C> common::CallBuilder for ProjectLocationTriggerPatchCall<'a, C> {}
20497
20498impl<'a, C> ProjectLocationTriggerPatchCall<'a, C>
20499where
20500 C: common::Connector,
20501{
20502 /// Perform the operation you have build so far.
20503 pub async fn doit(mut self) -> common::Result<(common::Response, BuildTrigger)> {
20504 use std::borrow::Cow;
20505 use std::io::{Read, Seek};
20506
20507 use common::{url::Params, ToParts};
20508 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20509
20510 let mut dd = common::DefaultDelegate;
20511 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20512 dlg.begin(common::MethodInfo {
20513 id: "cloudbuild.projects.locations.triggers.patch",
20514 http_method: hyper::Method::PATCH,
20515 });
20516
20517 for &field in [
20518 "alt",
20519 "resourceName",
20520 "updateMask",
20521 "triggerId",
20522 "projectId",
20523 ]
20524 .iter()
20525 {
20526 if self._additional_params.contains_key(field) {
20527 dlg.finished(false);
20528 return Err(common::Error::FieldClash(field));
20529 }
20530 }
20531
20532 let mut params = Params::with_capacity(7 + self._additional_params.len());
20533 params.push("resourceName", self._resource_name);
20534 if let Some(value) = self._update_mask.as_ref() {
20535 params.push("updateMask", value.to_string());
20536 }
20537 if let Some(value) = self._trigger_id.as_ref() {
20538 params.push("triggerId", value);
20539 }
20540 if let Some(value) = self._project_id.as_ref() {
20541 params.push("projectId", value);
20542 }
20543
20544 params.extend(self._additional_params.iter());
20545
20546 params.push("alt", "json");
20547 let mut url = self.hub._base_url.clone() + "v1/{+resourceName}";
20548 if self._scopes.is_empty() {
20549 self._scopes
20550 .insert(Scope::CloudPlatform.as_ref().to_string());
20551 }
20552
20553 #[allow(clippy::single_element_loop)]
20554 for &(find_this, param_name) in [("{+resourceName}", "resourceName")].iter() {
20555 url = params.uri_replacement(url, param_name, find_this, true);
20556 }
20557 {
20558 let to_remove = ["resourceName"];
20559 params.remove_params(&to_remove);
20560 }
20561
20562 let url = params.parse_with_url(&url);
20563
20564 let mut json_mime_type = mime::APPLICATION_JSON;
20565 let mut request_value_reader = {
20566 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
20567 common::remove_json_null_values(&mut value);
20568 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
20569 serde_json::to_writer(&mut dst, &value).unwrap();
20570 dst
20571 };
20572 let request_size = request_value_reader
20573 .seek(std::io::SeekFrom::End(0))
20574 .unwrap();
20575 request_value_reader
20576 .seek(std::io::SeekFrom::Start(0))
20577 .unwrap();
20578
20579 loop {
20580 let token = match self
20581 .hub
20582 .auth
20583 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20584 .await
20585 {
20586 Ok(token) => token,
20587 Err(e) => match dlg.token(e) {
20588 Ok(token) => token,
20589 Err(e) => {
20590 dlg.finished(false);
20591 return Err(common::Error::MissingToken(e));
20592 }
20593 },
20594 };
20595 request_value_reader
20596 .seek(std::io::SeekFrom::Start(0))
20597 .unwrap();
20598 let mut req_result = {
20599 let client = &self.hub.client;
20600 dlg.pre_request();
20601 let mut req_builder = hyper::Request::builder()
20602 .method(hyper::Method::PATCH)
20603 .uri(url.as_str())
20604 .header(USER_AGENT, self.hub._user_agent.clone());
20605
20606 if let Some(token) = token.as_ref() {
20607 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20608 }
20609
20610 let request = req_builder
20611 .header(CONTENT_TYPE, json_mime_type.to_string())
20612 .header(CONTENT_LENGTH, request_size as u64)
20613 .body(common::to_body(
20614 request_value_reader.get_ref().clone().into(),
20615 ));
20616
20617 client.request(request.unwrap()).await
20618 };
20619
20620 match req_result {
20621 Err(err) => {
20622 if let common::Retry::After(d) = dlg.http_error(&err) {
20623 sleep(d).await;
20624 continue;
20625 }
20626 dlg.finished(false);
20627 return Err(common::Error::HttpError(err));
20628 }
20629 Ok(res) => {
20630 let (mut parts, body) = res.into_parts();
20631 let mut body = common::Body::new(body);
20632 if !parts.status.is_success() {
20633 let bytes = common::to_bytes(body).await.unwrap_or_default();
20634 let error = serde_json::from_str(&common::to_string(&bytes));
20635 let response = common::to_response(parts, bytes.into());
20636
20637 if let common::Retry::After(d) =
20638 dlg.http_failure(&response, error.as_ref().ok())
20639 {
20640 sleep(d).await;
20641 continue;
20642 }
20643
20644 dlg.finished(false);
20645
20646 return Err(match error {
20647 Ok(value) => common::Error::BadRequest(value),
20648 _ => common::Error::Failure(response),
20649 });
20650 }
20651 let response = {
20652 let bytes = common::to_bytes(body).await.unwrap_or_default();
20653 let encoded = common::to_string(&bytes);
20654 match serde_json::from_str(&encoded) {
20655 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
20656 Err(error) => {
20657 dlg.response_json_decode_error(&encoded, &error);
20658 return Err(common::Error::JsonDecodeError(
20659 encoded.to_string(),
20660 error,
20661 ));
20662 }
20663 }
20664 };
20665
20666 dlg.finished(true);
20667 return Ok(response);
20668 }
20669 }
20670 }
20671 }
20672
20673 ///
20674 /// Sets the *request* property to the given value.
20675 ///
20676 /// Even though the property as already been set when instantiating this call,
20677 /// we provide this method for API completeness.
20678 pub fn request(mut self, new_value: BuildTrigger) -> ProjectLocationTriggerPatchCall<'a, C> {
20679 self._request = new_value;
20680 self
20681 }
20682 /// The `Trigger` name with format: `projects/{project}/locations/{location}/triggers/{trigger}`, where {trigger} is a unique identifier generated by the service.
20683 ///
20684 /// Sets the *resource name* path property to the given value.
20685 ///
20686 /// Even though the property as already been set when instantiating this call,
20687 /// we provide this method for API completeness.
20688 pub fn resource_name(mut self, new_value: &str) -> ProjectLocationTriggerPatchCall<'a, C> {
20689 self._resource_name = new_value.to_string();
20690 self
20691 }
20692 /// 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.
20693 ///
20694 /// Sets the *update mask* query property to the given value.
20695 pub fn update_mask(
20696 mut self,
20697 new_value: common::FieldMask,
20698 ) -> ProjectLocationTriggerPatchCall<'a, C> {
20699 self._update_mask = Some(new_value);
20700 self
20701 }
20702 /// Required. ID of the `BuildTrigger` to update.
20703 ///
20704 /// Sets the *trigger id* query property to the given value.
20705 pub fn trigger_id(mut self, new_value: &str) -> ProjectLocationTriggerPatchCall<'a, C> {
20706 self._trigger_id = Some(new_value.to_string());
20707 self
20708 }
20709 /// Required. ID of the project that owns the trigger.
20710 ///
20711 /// Sets the *project id* query property to the given value.
20712 pub fn project_id(mut self, new_value: &str) -> ProjectLocationTriggerPatchCall<'a, C> {
20713 self._project_id = Some(new_value.to_string());
20714 self
20715 }
20716 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
20717 /// while executing the actual API request.
20718 ///
20719 /// ````text
20720 /// It should be used to handle progress information, and to implement a certain level of resilience.
20721 /// ````
20722 ///
20723 /// Sets the *delegate* property to the given value.
20724 pub fn delegate(
20725 mut self,
20726 new_value: &'a mut dyn common::Delegate,
20727 ) -> ProjectLocationTriggerPatchCall<'a, C> {
20728 self._delegate = Some(new_value);
20729 self
20730 }
20731
20732 /// Set any additional parameter of the query string used in the request.
20733 /// It should be used to set parameters which are not yet available through their own
20734 /// setters.
20735 ///
20736 /// Please note that this method must not be used to set any of the known parameters
20737 /// which have their own setter method. If done anyway, the request will fail.
20738 ///
20739 /// # Additional Parameters
20740 ///
20741 /// * *$.xgafv* (query-string) - V1 error format.
20742 /// * *access_token* (query-string) - OAuth access token.
20743 /// * *alt* (query-string) - Data format for response.
20744 /// * *callback* (query-string) - JSONP
20745 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
20746 /// * *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.
20747 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
20748 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
20749 /// * *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.
20750 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
20751 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
20752 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationTriggerPatchCall<'a, C>
20753 where
20754 T: AsRef<str>,
20755 {
20756 self._additional_params
20757 .insert(name.as_ref().to_string(), value.as_ref().to_string());
20758 self
20759 }
20760
20761 /// Identifies the authorization scope for the method you are building.
20762 ///
20763 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
20764 /// [`Scope::CloudPlatform`].
20765 ///
20766 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
20767 /// tokens for more than one scope.
20768 ///
20769 /// Usually there is more than one suitable scope to authorize an operation, some of which may
20770 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
20771 /// sufficient, a read-write scope will do as well.
20772 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationTriggerPatchCall<'a, C>
20773 where
20774 St: AsRef<str>,
20775 {
20776 self._scopes.insert(String::from(scope.as_ref()));
20777 self
20778 }
20779 /// Identifies the authorization scope(s) for the method you are building.
20780 ///
20781 /// See [`Self::add_scope()`] for details.
20782 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationTriggerPatchCall<'a, C>
20783 where
20784 I: IntoIterator<Item = St>,
20785 St: AsRef<str>,
20786 {
20787 self._scopes
20788 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
20789 self
20790 }
20791
20792 /// Removes all scopes, and no default scope will be used either.
20793 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
20794 /// for details).
20795 pub fn clear_scopes(mut self) -> ProjectLocationTriggerPatchCall<'a, C> {
20796 self._scopes.clear();
20797 self
20798 }
20799}
20800
20801/// 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.
20802///
20803/// A builder for the *locations.triggers.run* method supported by a *project* resource.
20804/// It is not used directly, but through a [`ProjectMethods`] instance.
20805///
20806/// # Example
20807///
20808/// Instantiate a resource method builder
20809///
20810/// ```test_harness,no_run
20811/// # extern crate hyper;
20812/// # extern crate hyper_rustls;
20813/// # extern crate google_cloudbuild1 as cloudbuild1;
20814/// use cloudbuild1::api::RunBuildTriggerRequest;
20815/// # async fn dox() {
20816/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
20817///
20818/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
20819/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
20820/// # .with_native_roots()
20821/// # .unwrap()
20822/// # .https_only()
20823/// # .enable_http2()
20824/// # .build();
20825///
20826/// # let executor = hyper_util::rt::TokioExecutor::new();
20827/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
20828/// # secret,
20829/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
20830/// # yup_oauth2::client::CustomHyperClientBuilder::from(
20831/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
20832/// # ),
20833/// # ).build().await.unwrap();
20834///
20835/// # let client = hyper_util::client::legacy::Client::builder(
20836/// # hyper_util::rt::TokioExecutor::new()
20837/// # )
20838/// # .build(
20839/// # hyper_rustls::HttpsConnectorBuilder::new()
20840/// # .with_native_roots()
20841/// # .unwrap()
20842/// # .https_or_http()
20843/// # .enable_http2()
20844/// # .build()
20845/// # );
20846/// # let mut hub = CloudBuild::new(client, auth);
20847/// // As the method needs a request, you would usually fill it with the desired information
20848/// // into the respective structure. Some of the parts shown here might not be applicable !
20849/// // Values shown here are possibly random and not representative !
20850/// let mut req = RunBuildTriggerRequest::default();
20851///
20852/// // You can configure optional parameters by calling the respective setters at will, and
20853/// // execute the final call using `doit()`.
20854/// // Values shown here are possibly random and not representative !
20855/// let result = hub.projects().locations_triggers_run(req, "name")
20856/// .doit().await;
20857/// # }
20858/// ```
20859pub struct ProjectLocationTriggerRunCall<'a, C>
20860where
20861 C: 'a,
20862{
20863 hub: &'a CloudBuild<C>,
20864 _request: RunBuildTriggerRequest,
20865 _name: String,
20866 _delegate: Option<&'a mut dyn common::Delegate>,
20867 _additional_params: HashMap<String, String>,
20868 _scopes: BTreeSet<String>,
20869}
20870
20871impl<'a, C> common::CallBuilder for ProjectLocationTriggerRunCall<'a, C> {}
20872
20873impl<'a, C> ProjectLocationTriggerRunCall<'a, C>
20874where
20875 C: common::Connector,
20876{
20877 /// Perform the operation you have build so far.
20878 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
20879 use std::borrow::Cow;
20880 use std::io::{Read, Seek};
20881
20882 use common::{url::Params, ToParts};
20883 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
20884
20885 let mut dd = common::DefaultDelegate;
20886 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
20887 dlg.begin(common::MethodInfo {
20888 id: "cloudbuild.projects.locations.triggers.run",
20889 http_method: hyper::Method::POST,
20890 });
20891
20892 for &field in ["alt", "name"].iter() {
20893 if self._additional_params.contains_key(field) {
20894 dlg.finished(false);
20895 return Err(common::Error::FieldClash(field));
20896 }
20897 }
20898
20899 let mut params = Params::with_capacity(4 + self._additional_params.len());
20900 params.push("name", self._name);
20901
20902 params.extend(self._additional_params.iter());
20903
20904 params.push("alt", "json");
20905 let mut url = self.hub._base_url.clone() + "v1/{+name}:run";
20906 if self._scopes.is_empty() {
20907 self._scopes
20908 .insert(Scope::CloudPlatform.as_ref().to_string());
20909 }
20910
20911 #[allow(clippy::single_element_loop)]
20912 for &(find_this, param_name) in [("{+name}", "name")].iter() {
20913 url = params.uri_replacement(url, param_name, find_this, true);
20914 }
20915 {
20916 let to_remove = ["name"];
20917 params.remove_params(&to_remove);
20918 }
20919
20920 let url = params.parse_with_url(&url);
20921
20922 let mut json_mime_type = mime::APPLICATION_JSON;
20923 let mut request_value_reader = {
20924 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
20925 common::remove_json_null_values(&mut value);
20926 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
20927 serde_json::to_writer(&mut dst, &value).unwrap();
20928 dst
20929 };
20930 let request_size = request_value_reader
20931 .seek(std::io::SeekFrom::End(0))
20932 .unwrap();
20933 request_value_reader
20934 .seek(std::io::SeekFrom::Start(0))
20935 .unwrap();
20936
20937 loop {
20938 let token = match self
20939 .hub
20940 .auth
20941 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
20942 .await
20943 {
20944 Ok(token) => token,
20945 Err(e) => match dlg.token(e) {
20946 Ok(token) => token,
20947 Err(e) => {
20948 dlg.finished(false);
20949 return Err(common::Error::MissingToken(e));
20950 }
20951 },
20952 };
20953 request_value_reader
20954 .seek(std::io::SeekFrom::Start(0))
20955 .unwrap();
20956 let mut req_result = {
20957 let client = &self.hub.client;
20958 dlg.pre_request();
20959 let mut req_builder = hyper::Request::builder()
20960 .method(hyper::Method::POST)
20961 .uri(url.as_str())
20962 .header(USER_AGENT, self.hub._user_agent.clone());
20963
20964 if let Some(token) = token.as_ref() {
20965 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
20966 }
20967
20968 let request = req_builder
20969 .header(CONTENT_TYPE, json_mime_type.to_string())
20970 .header(CONTENT_LENGTH, request_size as u64)
20971 .body(common::to_body(
20972 request_value_reader.get_ref().clone().into(),
20973 ));
20974
20975 client.request(request.unwrap()).await
20976 };
20977
20978 match req_result {
20979 Err(err) => {
20980 if let common::Retry::After(d) = dlg.http_error(&err) {
20981 sleep(d).await;
20982 continue;
20983 }
20984 dlg.finished(false);
20985 return Err(common::Error::HttpError(err));
20986 }
20987 Ok(res) => {
20988 let (mut parts, body) = res.into_parts();
20989 let mut body = common::Body::new(body);
20990 if !parts.status.is_success() {
20991 let bytes = common::to_bytes(body).await.unwrap_or_default();
20992 let error = serde_json::from_str(&common::to_string(&bytes));
20993 let response = common::to_response(parts, bytes.into());
20994
20995 if let common::Retry::After(d) =
20996 dlg.http_failure(&response, error.as_ref().ok())
20997 {
20998 sleep(d).await;
20999 continue;
21000 }
21001
21002 dlg.finished(false);
21003
21004 return Err(match error {
21005 Ok(value) => common::Error::BadRequest(value),
21006 _ => common::Error::Failure(response),
21007 });
21008 }
21009 let response = {
21010 let bytes = common::to_bytes(body).await.unwrap_or_default();
21011 let encoded = common::to_string(&bytes);
21012 match serde_json::from_str(&encoded) {
21013 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21014 Err(error) => {
21015 dlg.response_json_decode_error(&encoded, &error);
21016 return Err(common::Error::JsonDecodeError(
21017 encoded.to_string(),
21018 error,
21019 ));
21020 }
21021 }
21022 };
21023
21024 dlg.finished(true);
21025 return Ok(response);
21026 }
21027 }
21028 }
21029 }
21030
21031 ///
21032 /// Sets the *request* property to the given value.
21033 ///
21034 /// Even though the property as already been set when instantiating this call,
21035 /// we provide this method for API completeness.
21036 pub fn request(
21037 mut self,
21038 new_value: RunBuildTriggerRequest,
21039 ) -> ProjectLocationTriggerRunCall<'a, C> {
21040 self._request = new_value;
21041 self
21042 }
21043 /// The name of the `Trigger` to run. Format: `projects/{project}/locations/{location}/triggers/{trigger}`
21044 ///
21045 /// Sets the *name* path property to the given value.
21046 ///
21047 /// Even though the property as already been set when instantiating this call,
21048 /// we provide this method for API completeness.
21049 pub fn name(mut self, new_value: &str) -> ProjectLocationTriggerRunCall<'a, C> {
21050 self._name = new_value.to_string();
21051 self
21052 }
21053 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21054 /// while executing the actual API request.
21055 ///
21056 /// ````text
21057 /// It should be used to handle progress information, and to implement a certain level of resilience.
21058 /// ````
21059 ///
21060 /// Sets the *delegate* property to the given value.
21061 pub fn delegate(
21062 mut self,
21063 new_value: &'a mut dyn common::Delegate,
21064 ) -> ProjectLocationTriggerRunCall<'a, C> {
21065 self._delegate = Some(new_value);
21066 self
21067 }
21068
21069 /// Set any additional parameter of the query string used in the request.
21070 /// It should be used to set parameters which are not yet available through their own
21071 /// setters.
21072 ///
21073 /// Please note that this method must not be used to set any of the known parameters
21074 /// which have their own setter method. If done anyway, the request will fail.
21075 ///
21076 /// # Additional Parameters
21077 ///
21078 /// * *$.xgafv* (query-string) - V1 error format.
21079 /// * *access_token* (query-string) - OAuth access token.
21080 /// * *alt* (query-string) - Data format for response.
21081 /// * *callback* (query-string) - JSONP
21082 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21083 /// * *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.
21084 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21085 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21086 /// * *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.
21087 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21088 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21089 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationTriggerRunCall<'a, C>
21090 where
21091 T: AsRef<str>,
21092 {
21093 self._additional_params
21094 .insert(name.as_ref().to_string(), value.as_ref().to_string());
21095 self
21096 }
21097
21098 /// Identifies the authorization scope for the method you are building.
21099 ///
21100 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21101 /// [`Scope::CloudPlatform`].
21102 ///
21103 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21104 /// tokens for more than one scope.
21105 ///
21106 /// Usually there is more than one suitable scope to authorize an operation, some of which may
21107 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21108 /// sufficient, a read-write scope will do as well.
21109 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationTriggerRunCall<'a, C>
21110 where
21111 St: AsRef<str>,
21112 {
21113 self._scopes.insert(String::from(scope.as_ref()));
21114 self
21115 }
21116 /// Identifies the authorization scope(s) for the method you are building.
21117 ///
21118 /// See [`Self::add_scope()`] for details.
21119 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationTriggerRunCall<'a, C>
21120 where
21121 I: IntoIterator<Item = St>,
21122 St: AsRef<str>,
21123 {
21124 self._scopes
21125 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21126 self
21127 }
21128
21129 /// Removes all scopes, and no default scope will be used either.
21130 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21131 /// for details).
21132 pub fn clear_scopes(mut self) -> ProjectLocationTriggerRunCall<'a, C> {
21133 self._scopes.clear();
21134 self
21135 }
21136}
21137
21138/// ReceiveTriggerWebhook [Experimental] is called when the API receives a webhook request targeted at a specific trigger.
21139///
21140/// A builder for the *locations.triggers.webhook* method supported by a *project* resource.
21141/// It is not used directly, but through a [`ProjectMethods`] instance.
21142///
21143/// # Example
21144///
21145/// Instantiate a resource method builder
21146///
21147/// ```test_harness,no_run
21148/// # extern crate hyper;
21149/// # extern crate hyper_rustls;
21150/// # extern crate google_cloudbuild1 as cloudbuild1;
21151/// use cloudbuild1::api::HttpBody;
21152/// # async fn dox() {
21153/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21154///
21155/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21156/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
21157/// # .with_native_roots()
21158/// # .unwrap()
21159/// # .https_only()
21160/// # .enable_http2()
21161/// # .build();
21162///
21163/// # let executor = hyper_util::rt::TokioExecutor::new();
21164/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
21165/// # secret,
21166/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21167/// # yup_oauth2::client::CustomHyperClientBuilder::from(
21168/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
21169/// # ),
21170/// # ).build().await.unwrap();
21171///
21172/// # let client = hyper_util::client::legacy::Client::builder(
21173/// # hyper_util::rt::TokioExecutor::new()
21174/// # )
21175/// # .build(
21176/// # hyper_rustls::HttpsConnectorBuilder::new()
21177/// # .with_native_roots()
21178/// # .unwrap()
21179/// # .https_or_http()
21180/// # .enable_http2()
21181/// # .build()
21182/// # );
21183/// # let mut hub = CloudBuild::new(client, auth);
21184/// // As the method needs a request, you would usually fill it with the desired information
21185/// // into the respective structure. Some of the parts shown here might not be applicable !
21186/// // Values shown here are possibly random and not representative !
21187/// let mut req = HttpBody::default();
21188///
21189/// // You can configure optional parameters by calling the respective setters at will, and
21190/// // execute the final call using `doit()`.
21191/// // Values shown here are possibly random and not representative !
21192/// let result = hub.projects().locations_triggers_webhook(req, "name")
21193/// .trigger("est")
21194/// .secret("sed")
21195/// .project_id("diam")
21196/// .doit().await;
21197/// # }
21198/// ```
21199pub struct ProjectLocationTriggerWebhookCall<'a, C>
21200where
21201 C: 'a,
21202{
21203 hub: &'a CloudBuild<C>,
21204 _request: HttpBody,
21205 _name: String,
21206 _trigger: Option<String>,
21207 _secret: Option<String>,
21208 _project_id: Option<String>,
21209 _delegate: Option<&'a mut dyn common::Delegate>,
21210 _additional_params: HashMap<String, String>,
21211}
21212
21213impl<'a, C> common::CallBuilder for ProjectLocationTriggerWebhookCall<'a, C> {}
21214
21215impl<'a, C> ProjectLocationTriggerWebhookCall<'a, C>
21216where
21217 C: common::Connector,
21218{
21219 /// Perform the operation you have build so far.
21220 pub async fn doit(
21221 mut self,
21222 ) -> common::Result<(common::Response, ReceiveTriggerWebhookResponse)> {
21223 use std::borrow::Cow;
21224 use std::io::{Read, Seek};
21225
21226 use common::{url::Params, ToParts};
21227 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21228
21229 let mut dd = common::DefaultDelegate;
21230 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21231 dlg.begin(common::MethodInfo {
21232 id: "cloudbuild.projects.locations.triggers.webhook",
21233 http_method: hyper::Method::POST,
21234 });
21235
21236 for &field in ["alt", "name", "trigger", "secret", "projectId"].iter() {
21237 if self._additional_params.contains_key(field) {
21238 dlg.finished(false);
21239 return Err(common::Error::FieldClash(field));
21240 }
21241 }
21242
21243 let mut params = Params::with_capacity(7 + self._additional_params.len());
21244 params.push("name", self._name);
21245 if let Some(value) = self._trigger.as_ref() {
21246 params.push("trigger", value);
21247 }
21248 if let Some(value) = self._secret.as_ref() {
21249 params.push("secret", value);
21250 }
21251 if let Some(value) = self._project_id.as_ref() {
21252 params.push("projectId", value);
21253 }
21254
21255 params.extend(self._additional_params.iter());
21256
21257 params.push("alt", "json");
21258 let mut url = self.hub._base_url.clone() + "v1/{+name}:webhook";
21259
21260 match dlg.api_key() {
21261 Some(value) => params.push("key", value),
21262 None => {
21263 dlg.finished(false);
21264 return Err(common::Error::MissingAPIKey);
21265 }
21266 }
21267
21268 #[allow(clippy::single_element_loop)]
21269 for &(find_this, param_name) in [("{+name}", "name")].iter() {
21270 url = params.uri_replacement(url, param_name, find_this, true);
21271 }
21272 {
21273 let to_remove = ["name"];
21274 params.remove_params(&to_remove);
21275 }
21276
21277 let url = params.parse_with_url(&url);
21278
21279 let mut json_mime_type = mime::APPLICATION_JSON;
21280 let mut request_value_reader = {
21281 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
21282 common::remove_json_null_values(&mut value);
21283 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
21284 serde_json::to_writer(&mut dst, &value).unwrap();
21285 dst
21286 };
21287 let request_size = request_value_reader
21288 .seek(std::io::SeekFrom::End(0))
21289 .unwrap();
21290 request_value_reader
21291 .seek(std::io::SeekFrom::Start(0))
21292 .unwrap();
21293
21294 loop {
21295 request_value_reader
21296 .seek(std::io::SeekFrom::Start(0))
21297 .unwrap();
21298 let mut req_result = {
21299 let client = &self.hub.client;
21300 dlg.pre_request();
21301 let mut req_builder = hyper::Request::builder()
21302 .method(hyper::Method::POST)
21303 .uri(url.as_str())
21304 .header(USER_AGENT, self.hub._user_agent.clone());
21305
21306 let request = req_builder
21307 .header(CONTENT_TYPE, json_mime_type.to_string())
21308 .header(CONTENT_LENGTH, request_size as u64)
21309 .body(common::to_body(
21310 request_value_reader.get_ref().clone().into(),
21311 ));
21312
21313 client.request(request.unwrap()).await
21314 };
21315
21316 match req_result {
21317 Err(err) => {
21318 if let common::Retry::After(d) = dlg.http_error(&err) {
21319 sleep(d).await;
21320 continue;
21321 }
21322 dlg.finished(false);
21323 return Err(common::Error::HttpError(err));
21324 }
21325 Ok(res) => {
21326 let (mut parts, body) = res.into_parts();
21327 let mut body = common::Body::new(body);
21328 if !parts.status.is_success() {
21329 let bytes = common::to_bytes(body).await.unwrap_or_default();
21330 let error = serde_json::from_str(&common::to_string(&bytes));
21331 let response = common::to_response(parts, bytes.into());
21332
21333 if let common::Retry::After(d) =
21334 dlg.http_failure(&response, error.as_ref().ok())
21335 {
21336 sleep(d).await;
21337 continue;
21338 }
21339
21340 dlg.finished(false);
21341
21342 return Err(match error {
21343 Ok(value) => common::Error::BadRequest(value),
21344 _ => common::Error::Failure(response),
21345 });
21346 }
21347 let response = {
21348 let bytes = common::to_bytes(body).await.unwrap_or_default();
21349 let encoded = common::to_string(&bytes);
21350 match serde_json::from_str(&encoded) {
21351 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21352 Err(error) => {
21353 dlg.response_json_decode_error(&encoded, &error);
21354 return Err(common::Error::JsonDecodeError(
21355 encoded.to_string(),
21356 error,
21357 ));
21358 }
21359 }
21360 };
21361
21362 dlg.finished(true);
21363 return Ok(response);
21364 }
21365 }
21366 }
21367 }
21368
21369 ///
21370 /// Sets the *request* property to the given value.
21371 ///
21372 /// Even though the property as already been set when instantiating this call,
21373 /// we provide this method for API completeness.
21374 pub fn request(mut self, new_value: HttpBody) -> ProjectLocationTriggerWebhookCall<'a, C> {
21375 self._request = new_value;
21376 self
21377 }
21378 /// The name of the `ReceiveTriggerWebhook` to retrieve. Format: `projects/{project}/locations/{location}/triggers/{trigger}`
21379 ///
21380 /// Sets the *name* path property to the given value.
21381 ///
21382 /// Even though the property as already been set when instantiating this call,
21383 /// we provide this method for API completeness.
21384 pub fn name(mut self, new_value: &str) -> ProjectLocationTriggerWebhookCall<'a, C> {
21385 self._name = new_value.to_string();
21386 self
21387 }
21388 /// Name of the trigger to run the payload against
21389 ///
21390 /// Sets the *trigger* query property to the given value.
21391 pub fn trigger(mut self, new_value: &str) -> ProjectLocationTriggerWebhookCall<'a, C> {
21392 self._trigger = Some(new_value.to_string());
21393 self
21394 }
21395 /// Secret token used for authorization if an OAuth token isn't provided.
21396 ///
21397 /// Sets the *secret* query property to the given value.
21398 pub fn secret(mut self, new_value: &str) -> ProjectLocationTriggerWebhookCall<'a, C> {
21399 self._secret = Some(new_value.to_string());
21400 self
21401 }
21402 /// Project in which the specified trigger lives
21403 ///
21404 /// Sets the *project id* query property to the given value.
21405 pub fn project_id(mut self, new_value: &str) -> ProjectLocationTriggerWebhookCall<'a, C> {
21406 self._project_id = Some(new_value.to_string());
21407 self
21408 }
21409 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21410 /// while executing the actual API request.
21411 ///
21412 /// ````text
21413 /// It should be used to handle progress information, and to implement a certain level of resilience.
21414 /// ````
21415 ///
21416 /// Sets the *delegate* property to the given value.
21417 pub fn delegate(
21418 mut self,
21419 new_value: &'a mut dyn common::Delegate,
21420 ) -> ProjectLocationTriggerWebhookCall<'a, C> {
21421 self._delegate = Some(new_value);
21422 self
21423 }
21424
21425 /// Set any additional parameter of the query string used in the request.
21426 /// It should be used to set parameters which are not yet available through their own
21427 /// setters.
21428 ///
21429 /// Please note that this method must not be used to set any of the known parameters
21430 /// which have their own setter method. If done anyway, the request will fail.
21431 ///
21432 /// # Additional Parameters
21433 ///
21434 /// * *$.xgafv* (query-string) - V1 error format.
21435 /// * *access_token* (query-string) - OAuth access token.
21436 /// * *alt* (query-string) - Data format for response.
21437 /// * *callback* (query-string) - JSONP
21438 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21439 /// * *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.
21440 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21441 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21442 /// * *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.
21443 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21444 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21445 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationTriggerWebhookCall<'a, C>
21446 where
21447 T: AsRef<str>,
21448 {
21449 self._additional_params
21450 .insert(name.as_ref().to_string(), value.as_ref().to_string());
21451 self
21452 }
21453}
21454
21455/// Creates a `WorkerPool`.
21456///
21457/// A builder for the *locations.workerPools.create* method supported by a *project* resource.
21458/// It is not used directly, but through a [`ProjectMethods`] instance.
21459///
21460/// # Example
21461///
21462/// Instantiate a resource method builder
21463///
21464/// ```test_harness,no_run
21465/// # extern crate hyper;
21466/// # extern crate hyper_rustls;
21467/// # extern crate google_cloudbuild1 as cloudbuild1;
21468/// use cloudbuild1::api::WorkerPool;
21469/// # async fn dox() {
21470/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21471///
21472/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21473/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
21474/// # .with_native_roots()
21475/// # .unwrap()
21476/// # .https_only()
21477/// # .enable_http2()
21478/// # .build();
21479///
21480/// # let executor = hyper_util::rt::TokioExecutor::new();
21481/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
21482/// # secret,
21483/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21484/// # yup_oauth2::client::CustomHyperClientBuilder::from(
21485/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
21486/// # ),
21487/// # ).build().await.unwrap();
21488///
21489/// # let client = hyper_util::client::legacy::Client::builder(
21490/// # hyper_util::rt::TokioExecutor::new()
21491/// # )
21492/// # .build(
21493/// # hyper_rustls::HttpsConnectorBuilder::new()
21494/// # .with_native_roots()
21495/// # .unwrap()
21496/// # .https_or_http()
21497/// # .enable_http2()
21498/// # .build()
21499/// # );
21500/// # let mut hub = CloudBuild::new(client, auth);
21501/// // As the method needs a request, you would usually fill it with the desired information
21502/// // into the respective structure. Some of the parts shown here might not be applicable !
21503/// // Values shown here are possibly random and not representative !
21504/// let mut req = WorkerPool::default();
21505///
21506/// // You can configure optional parameters by calling the respective setters at will, and
21507/// // execute the final call using `doit()`.
21508/// // Values shown here are possibly random and not representative !
21509/// let result = hub.projects().locations_worker_pools_create(req, "parent")
21510/// .worker_pool_id("dolores")
21511/// .validate_only(true)
21512/// .doit().await;
21513/// # }
21514/// ```
21515pub struct ProjectLocationWorkerPoolCreateCall<'a, C>
21516where
21517 C: 'a,
21518{
21519 hub: &'a CloudBuild<C>,
21520 _request: WorkerPool,
21521 _parent: String,
21522 _worker_pool_id: Option<String>,
21523 _validate_only: Option<bool>,
21524 _delegate: Option<&'a mut dyn common::Delegate>,
21525 _additional_params: HashMap<String, String>,
21526 _scopes: BTreeSet<String>,
21527}
21528
21529impl<'a, C> common::CallBuilder for ProjectLocationWorkerPoolCreateCall<'a, C> {}
21530
21531impl<'a, C> ProjectLocationWorkerPoolCreateCall<'a, C>
21532where
21533 C: common::Connector,
21534{
21535 /// Perform the operation you have build so far.
21536 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
21537 use std::borrow::Cow;
21538 use std::io::{Read, Seek};
21539
21540 use common::{url::Params, ToParts};
21541 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21542
21543 let mut dd = common::DefaultDelegate;
21544 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21545 dlg.begin(common::MethodInfo {
21546 id: "cloudbuild.projects.locations.workerPools.create",
21547 http_method: hyper::Method::POST,
21548 });
21549
21550 for &field in ["alt", "parent", "workerPoolId", "validateOnly"].iter() {
21551 if self._additional_params.contains_key(field) {
21552 dlg.finished(false);
21553 return Err(common::Error::FieldClash(field));
21554 }
21555 }
21556
21557 let mut params = Params::with_capacity(6 + self._additional_params.len());
21558 params.push("parent", self._parent);
21559 if let Some(value) = self._worker_pool_id.as_ref() {
21560 params.push("workerPoolId", value);
21561 }
21562 if let Some(value) = self._validate_only.as_ref() {
21563 params.push("validateOnly", value.to_string());
21564 }
21565
21566 params.extend(self._additional_params.iter());
21567
21568 params.push("alt", "json");
21569 let mut url = self.hub._base_url.clone() + "v1/{+parent}/workerPools";
21570 if self._scopes.is_empty() {
21571 self._scopes
21572 .insert(Scope::CloudPlatform.as_ref().to_string());
21573 }
21574
21575 #[allow(clippy::single_element_loop)]
21576 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
21577 url = params.uri_replacement(url, param_name, find_this, true);
21578 }
21579 {
21580 let to_remove = ["parent"];
21581 params.remove_params(&to_remove);
21582 }
21583
21584 let url = params.parse_with_url(&url);
21585
21586 let mut json_mime_type = mime::APPLICATION_JSON;
21587 let mut request_value_reader = {
21588 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
21589 common::remove_json_null_values(&mut value);
21590 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
21591 serde_json::to_writer(&mut dst, &value).unwrap();
21592 dst
21593 };
21594 let request_size = request_value_reader
21595 .seek(std::io::SeekFrom::End(0))
21596 .unwrap();
21597 request_value_reader
21598 .seek(std::io::SeekFrom::Start(0))
21599 .unwrap();
21600
21601 loop {
21602 let token = match self
21603 .hub
21604 .auth
21605 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21606 .await
21607 {
21608 Ok(token) => token,
21609 Err(e) => match dlg.token(e) {
21610 Ok(token) => token,
21611 Err(e) => {
21612 dlg.finished(false);
21613 return Err(common::Error::MissingToken(e));
21614 }
21615 },
21616 };
21617 request_value_reader
21618 .seek(std::io::SeekFrom::Start(0))
21619 .unwrap();
21620 let mut req_result = {
21621 let client = &self.hub.client;
21622 dlg.pre_request();
21623 let mut req_builder = hyper::Request::builder()
21624 .method(hyper::Method::POST)
21625 .uri(url.as_str())
21626 .header(USER_AGENT, self.hub._user_agent.clone());
21627
21628 if let Some(token) = token.as_ref() {
21629 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21630 }
21631
21632 let request = req_builder
21633 .header(CONTENT_TYPE, json_mime_type.to_string())
21634 .header(CONTENT_LENGTH, request_size as u64)
21635 .body(common::to_body(
21636 request_value_reader.get_ref().clone().into(),
21637 ));
21638
21639 client.request(request.unwrap()).await
21640 };
21641
21642 match req_result {
21643 Err(err) => {
21644 if let common::Retry::After(d) = dlg.http_error(&err) {
21645 sleep(d).await;
21646 continue;
21647 }
21648 dlg.finished(false);
21649 return Err(common::Error::HttpError(err));
21650 }
21651 Ok(res) => {
21652 let (mut parts, body) = res.into_parts();
21653 let mut body = common::Body::new(body);
21654 if !parts.status.is_success() {
21655 let bytes = common::to_bytes(body).await.unwrap_or_default();
21656 let error = serde_json::from_str(&common::to_string(&bytes));
21657 let response = common::to_response(parts, bytes.into());
21658
21659 if let common::Retry::After(d) =
21660 dlg.http_failure(&response, error.as_ref().ok())
21661 {
21662 sleep(d).await;
21663 continue;
21664 }
21665
21666 dlg.finished(false);
21667
21668 return Err(match error {
21669 Ok(value) => common::Error::BadRequest(value),
21670 _ => common::Error::Failure(response),
21671 });
21672 }
21673 let response = {
21674 let bytes = common::to_bytes(body).await.unwrap_or_default();
21675 let encoded = common::to_string(&bytes);
21676 match serde_json::from_str(&encoded) {
21677 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
21678 Err(error) => {
21679 dlg.response_json_decode_error(&encoded, &error);
21680 return Err(common::Error::JsonDecodeError(
21681 encoded.to_string(),
21682 error,
21683 ));
21684 }
21685 }
21686 };
21687
21688 dlg.finished(true);
21689 return Ok(response);
21690 }
21691 }
21692 }
21693 }
21694
21695 ///
21696 /// Sets the *request* property to the given value.
21697 ///
21698 /// Even though the property as already been set when instantiating this call,
21699 /// we provide this method for API completeness.
21700 pub fn request(mut self, new_value: WorkerPool) -> ProjectLocationWorkerPoolCreateCall<'a, C> {
21701 self._request = new_value;
21702 self
21703 }
21704 /// Required. The parent resource where this worker pool will be created. Format: `projects/{project}/locations/{location}`.
21705 ///
21706 /// Sets the *parent* path property to the given value.
21707 ///
21708 /// Even though the property as already been set when instantiating this call,
21709 /// we provide this method for API completeness.
21710 pub fn parent(mut self, new_value: &str) -> ProjectLocationWorkerPoolCreateCall<'a, C> {
21711 self._parent = new_value.to_string();
21712 self
21713 }
21714 /// 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-/.
21715 ///
21716 /// Sets the *worker pool id* query property to the given value.
21717 pub fn worker_pool_id(mut self, new_value: &str) -> ProjectLocationWorkerPoolCreateCall<'a, C> {
21718 self._worker_pool_id = Some(new_value.to_string());
21719 self
21720 }
21721 /// If set, validate the request and preview the response, but do not actually post it.
21722 ///
21723 /// Sets the *validate only* query property to the given value.
21724 pub fn validate_only(mut self, new_value: bool) -> ProjectLocationWorkerPoolCreateCall<'a, C> {
21725 self._validate_only = Some(new_value);
21726 self
21727 }
21728 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
21729 /// while executing the actual API request.
21730 ///
21731 /// ````text
21732 /// It should be used to handle progress information, and to implement a certain level of resilience.
21733 /// ````
21734 ///
21735 /// Sets the *delegate* property to the given value.
21736 pub fn delegate(
21737 mut self,
21738 new_value: &'a mut dyn common::Delegate,
21739 ) -> ProjectLocationWorkerPoolCreateCall<'a, C> {
21740 self._delegate = Some(new_value);
21741 self
21742 }
21743
21744 /// Set any additional parameter of the query string used in the request.
21745 /// It should be used to set parameters which are not yet available through their own
21746 /// setters.
21747 ///
21748 /// Please note that this method must not be used to set any of the known parameters
21749 /// which have their own setter method. If done anyway, the request will fail.
21750 ///
21751 /// # Additional Parameters
21752 ///
21753 /// * *$.xgafv* (query-string) - V1 error format.
21754 /// * *access_token* (query-string) - OAuth access token.
21755 /// * *alt* (query-string) - Data format for response.
21756 /// * *callback* (query-string) - JSONP
21757 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
21758 /// * *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.
21759 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
21760 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
21761 /// * *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.
21762 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
21763 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
21764 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationWorkerPoolCreateCall<'a, C>
21765 where
21766 T: AsRef<str>,
21767 {
21768 self._additional_params
21769 .insert(name.as_ref().to_string(), value.as_ref().to_string());
21770 self
21771 }
21772
21773 /// Identifies the authorization scope for the method you are building.
21774 ///
21775 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
21776 /// [`Scope::CloudPlatform`].
21777 ///
21778 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
21779 /// tokens for more than one scope.
21780 ///
21781 /// Usually there is more than one suitable scope to authorize an operation, some of which may
21782 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
21783 /// sufficient, a read-write scope will do as well.
21784 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationWorkerPoolCreateCall<'a, C>
21785 where
21786 St: AsRef<str>,
21787 {
21788 self._scopes.insert(String::from(scope.as_ref()));
21789 self
21790 }
21791 /// Identifies the authorization scope(s) for the method you are building.
21792 ///
21793 /// See [`Self::add_scope()`] for details.
21794 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationWorkerPoolCreateCall<'a, C>
21795 where
21796 I: IntoIterator<Item = St>,
21797 St: AsRef<str>,
21798 {
21799 self._scopes
21800 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
21801 self
21802 }
21803
21804 /// Removes all scopes, and no default scope will be used either.
21805 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
21806 /// for details).
21807 pub fn clear_scopes(mut self) -> ProjectLocationWorkerPoolCreateCall<'a, C> {
21808 self._scopes.clear();
21809 self
21810 }
21811}
21812
21813/// Deletes a `WorkerPool`.
21814///
21815/// A builder for the *locations.workerPools.delete* method supported by a *project* resource.
21816/// It is not used directly, but through a [`ProjectMethods`] instance.
21817///
21818/// # Example
21819///
21820/// Instantiate a resource method builder
21821///
21822/// ```test_harness,no_run
21823/// # extern crate hyper;
21824/// # extern crate hyper_rustls;
21825/// # extern crate google_cloudbuild1 as cloudbuild1;
21826/// # async fn dox() {
21827/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
21828///
21829/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
21830/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
21831/// # .with_native_roots()
21832/// # .unwrap()
21833/// # .https_only()
21834/// # .enable_http2()
21835/// # .build();
21836///
21837/// # let executor = hyper_util::rt::TokioExecutor::new();
21838/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
21839/// # secret,
21840/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
21841/// # yup_oauth2::client::CustomHyperClientBuilder::from(
21842/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
21843/// # ),
21844/// # ).build().await.unwrap();
21845///
21846/// # let client = hyper_util::client::legacy::Client::builder(
21847/// # hyper_util::rt::TokioExecutor::new()
21848/// # )
21849/// # .build(
21850/// # hyper_rustls::HttpsConnectorBuilder::new()
21851/// # .with_native_roots()
21852/// # .unwrap()
21853/// # .https_or_http()
21854/// # .enable_http2()
21855/// # .build()
21856/// # );
21857/// # let mut hub = CloudBuild::new(client, auth);
21858/// // You can configure optional parameters by calling the respective setters at will, and
21859/// // execute the final call using `doit()`.
21860/// // Values shown here are possibly random and not representative !
21861/// let result = hub.projects().locations_worker_pools_delete("name")
21862/// .validate_only(false)
21863/// .etag("elitr")
21864/// .allow_missing(false)
21865/// .doit().await;
21866/// # }
21867/// ```
21868pub struct ProjectLocationWorkerPoolDeleteCall<'a, C>
21869where
21870 C: 'a,
21871{
21872 hub: &'a CloudBuild<C>,
21873 _name: String,
21874 _validate_only: Option<bool>,
21875 _etag: Option<String>,
21876 _allow_missing: Option<bool>,
21877 _delegate: Option<&'a mut dyn common::Delegate>,
21878 _additional_params: HashMap<String, String>,
21879 _scopes: BTreeSet<String>,
21880}
21881
21882impl<'a, C> common::CallBuilder for ProjectLocationWorkerPoolDeleteCall<'a, C> {}
21883
21884impl<'a, C> ProjectLocationWorkerPoolDeleteCall<'a, C>
21885where
21886 C: common::Connector,
21887{
21888 /// Perform the operation you have build so far.
21889 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
21890 use std::borrow::Cow;
21891 use std::io::{Read, Seek};
21892
21893 use common::{url::Params, ToParts};
21894 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
21895
21896 let mut dd = common::DefaultDelegate;
21897 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
21898 dlg.begin(common::MethodInfo {
21899 id: "cloudbuild.projects.locations.workerPools.delete",
21900 http_method: hyper::Method::DELETE,
21901 });
21902
21903 for &field in ["alt", "name", "validateOnly", "etag", "allowMissing"].iter() {
21904 if self._additional_params.contains_key(field) {
21905 dlg.finished(false);
21906 return Err(common::Error::FieldClash(field));
21907 }
21908 }
21909
21910 let mut params = Params::with_capacity(6 + self._additional_params.len());
21911 params.push("name", self._name);
21912 if let Some(value) = self._validate_only.as_ref() {
21913 params.push("validateOnly", value.to_string());
21914 }
21915 if let Some(value) = self._etag.as_ref() {
21916 params.push("etag", value);
21917 }
21918 if let Some(value) = self._allow_missing.as_ref() {
21919 params.push("allowMissing", value.to_string());
21920 }
21921
21922 params.extend(self._additional_params.iter());
21923
21924 params.push("alt", "json");
21925 let mut url = self.hub._base_url.clone() + "v1/{+name}";
21926 if self._scopes.is_empty() {
21927 self._scopes
21928 .insert(Scope::CloudPlatform.as_ref().to_string());
21929 }
21930
21931 #[allow(clippy::single_element_loop)]
21932 for &(find_this, param_name) in [("{+name}", "name")].iter() {
21933 url = params.uri_replacement(url, param_name, find_this, true);
21934 }
21935 {
21936 let to_remove = ["name"];
21937 params.remove_params(&to_remove);
21938 }
21939
21940 let url = params.parse_with_url(&url);
21941
21942 loop {
21943 let token = match self
21944 .hub
21945 .auth
21946 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
21947 .await
21948 {
21949 Ok(token) => token,
21950 Err(e) => match dlg.token(e) {
21951 Ok(token) => token,
21952 Err(e) => {
21953 dlg.finished(false);
21954 return Err(common::Error::MissingToken(e));
21955 }
21956 },
21957 };
21958 let mut req_result = {
21959 let client = &self.hub.client;
21960 dlg.pre_request();
21961 let mut req_builder = hyper::Request::builder()
21962 .method(hyper::Method::DELETE)
21963 .uri(url.as_str())
21964 .header(USER_AGENT, self.hub._user_agent.clone());
21965
21966 if let Some(token) = token.as_ref() {
21967 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
21968 }
21969
21970 let request = req_builder
21971 .header(CONTENT_LENGTH, 0_u64)
21972 .body(common::to_body::<String>(None));
21973
21974 client.request(request.unwrap()).await
21975 };
21976
21977 match req_result {
21978 Err(err) => {
21979 if let common::Retry::After(d) = dlg.http_error(&err) {
21980 sleep(d).await;
21981 continue;
21982 }
21983 dlg.finished(false);
21984 return Err(common::Error::HttpError(err));
21985 }
21986 Ok(res) => {
21987 let (mut parts, body) = res.into_parts();
21988 let mut body = common::Body::new(body);
21989 if !parts.status.is_success() {
21990 let bytes = common::to_bytes(body).await.unwrap_or_default();
21991 let error = serde_json::from_str(&common::to_string(&bytes));
21992 let response = common::to_response(parts, bytes.into());
21993
21994 if let common::Retry::After(d) =
21995 dlg.http_failure(&response, error.as_ref().ok())
21996 {
21997 sleep(d).await;
21998 continue;
21999 }
22000
22001 dlg.finished(false);
22002
22003 return Err(match error {
22004 Ok(value) => common::Error::BadRequest(value),
22005 _ => common::Error::Failure(response),
22006 });
22007 }
22008 let response = {
22009 let bytes = common::to_bytes(body).await.unwrap_or_default();
22010 let encoded = common::to_string(&bytes);
22011 match serde_json::from_str(&encoded) {
22012 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22013 Err(error) => {
22014 dlg.response_json_decode_error(&encoded, &error);
22015 return Err(common::Error::JsonDecodeError(
22016 encoded.to_string(),
22017 error,
22018 ));
22019 }
22020 }
22021 };
22022
22023 dlg.finished(true);
22024 return Ok(response);
22025 }
22026 }
22027 }
22028 }
22029
22030 /// Required. The name of the `WorkerPool` to delete. Format: `projects/{project}/locations/{location}/workerPools/{workerPool}`.
22031 ///
22032 /// Sets the *name* path property to the given value.
22033 ///
22034 /// Even though the property as already been set when instantiating this call,
22035 /// we provide this method for API completeness.
22036 pub fn name(mut self, new_value: &str) -> ProjectLocationWorkerPoolDeleteCall<'a, C> {
22037 self._name = new_value.to_string();
22038 self
22039 }
22040 /// If set, validate the request and preview the response, but do not actually post it.
22041 ///
22042 /// Sets the *validate only* query property to the given value.
22043 pub fn validate_only(mut self, new_value: bool) -> ProjectLocationWorkerPoolDeleteCall<'a, C> {
22044 self._validate_only = Some(new_value);
22045 self
22046 }
22047 /// Optional. If provided, it must match the server's etag on the workerpool for the request to be processed.
22048 ///
22049 /// Sets the *etag* query property to the given value.
22050 pub fn etag(mut self, new_value: &str) -> ProjectLocationWorkerPoolDeleteCall<'a, C> {
22051 self._etag = Some(new_value.to_string());
22052 self
22053 }
22054 /// If set to true, and the `WorkerPool` is not found, the request will succeed but no action will be taken on the server.
22055 ///
22056 /// Sets the *allow missing* query property to the given value.
22057 pub fn allow_missing(mut self, new_value: bool) -> ProjectLocationWorkerPoolDeleteCall<'a, C> {
22058 self._allow_missing = Some(new_value);
22059 self
22060 }
22061 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22062 /// while executing the actual API request.
22063 ///
22064 /// ````text
22065 /// It should be used to handle progress information, and to implement a certain level of resilience.
22066 /// ````
22067 ///
22068 /// Sets the *delegate* property to the given value.
22069 pub fn delegate(
22070 mut self,
22071 new_value: &'a mut dyn common::Delegate,
22072 ) -> ProjectLocationWorkerPoolDeleteCall<'a, C> {
22073 self._delegate = Some(new_value);
22074 self
22075 }
22076
22077 /// Set any additional parameter of the query string used in the request.
22078 /// It should be used to set parameters which are not yet available through their own
22079 /// setters.
22080 ///
22081 /// Please note that this method must not be used to set any of the known parameters
22082 /// which have their own setter method. If done anyway, the request will fail.
22083 ///
22084 /// # Additional Parameters
22085 ///
22086 /// * *$.xgafv* (query-string) - V1 error format.
22087 /// * *access_token* (query-string) - OAuth access token.
22088 /// * *alt* (query-string) - Data format for response.
22089 /// * *callback* (query-string) - JSONP
22090 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22091 /// * *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.
22092 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22093 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22094 /// * *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.
22095 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22096 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22097 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationWorkerPoolDeleteCall<'a, C>
22098 where
22099 T: AsRef<str>,
22100 {
22101 self._additional_params
22102 .insert(name.as_ref().to_string(), value.as_ref().to_string());
22103 self
22104 }
22105
22106 /// Identifies the authorization scope for the method you are building.
22107 ///
22108 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22109 /// [`Scope::CloudPlatform`].
22110 ///
22111 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22112 /// tokens for more than one scope.
22113 ///
22114 /// Usually there is more than one suitable scope to authorize an operation, some of which may
22115 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22116 /// sufficient, a read-write scope will do as well.
22117 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationWorkerPoolDeleteCall<'a, C>
22118 where
22119 St: AsRef<str>,
22120 {
22121 self._scopes.insert(String::from(scope.as_ref()));
22122 self
22123 }
22124 /// Identifies the authorization scope(s) for the method you are building.
22125 ///
22126 /// See [`Self::add_scope()`] for details.
22127 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationWorkerPoolDeleteCall<'a, C>
22128 where
22129 I: IntoIterator<Item = St>,
22130 St: AsRef<str>,
22131 {
22132 self._scopes
22133 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22134 self
22135 }
22136
22137 /// Removes all scopes, and no default scope will be used either.
22138 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22139 /// for details).
22140 pub fn clear_scopes(mut self) -> ProjectLocationWorkerPoolDeleteCall<'a, C> {
22141 self._scopes.clear();
22142 self
22143 }
22144}
22145
22146/// Returns details of a `WorkerPool`.
22147///
22148/// A builder for the *locations.workerPools.get* method supported by a *project* resource.
22149/// It is not used directly, but through a [`ProjectMethods`] instance.
22150///
22151/// # Example
22152///
22153/// Instantiate a resource method builder
22154///
22155/// ```test_harness,no_run
22156/// # extern crate hyper;
22157/// # extern crate hyper_rustls;
22158/// # extern crate google_cloudbuild1 as cloudbuild1;
22159/// # async fn dox() {
22160/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22161///
22162/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22163/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
22164/// # .with_native_roots()
22165/// # .unwrap()
22166/// # .https_only()
22167/// # .enable_http2()
22168/// # .build();
22169///
22170/// # let executor = hyper_util::rt::TokioExecutor::new();
22171/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
22172/// # secret,
22173/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22174/// # yup_oauth2::client::CustomHyperClientBuilder::from(
22175/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
22176/// # ),
22177/// # ).build().await.unwrap();
22178///
22179/// # let client = hyper_util::client::legacy::Client::builder(
22180/// # hyper_util::rt::TokioExecutor::new()
22181/// # )
22182/// # .build(
22183/// # hyper_rustls::HttpsConnectorBuilder::new()
22184/// # .with_native_roots()
22185/// # .unwrap()
22186/// # .https_or_http()
22187/// # .enable_http2()
22188/// # .build()
22189/// # );
22190/// # let mut hub = CloudBuild::new(client, auth);
22191/// // You can configure optional parameters by calling the respective setters at will, and
22192/// // execute the final call using `doit()`.
22193/// // Values shown here are possibly random and not representative !
22194/// let result = hub.projects().locations_worker_pools_get("name")
22195/// .doit().await;
22196/// # }
22197/// ```
22198pub struct ProjectLocationWorkerPoolGetCall<'a, C>
22199where
22200 C: 'a,
22201{
22202 hub: &'a CloudBuild<C>,
22203 _name: String,
22204 _delegate: Option<&'a mut dyn common::Delegate>,
22205 _additional_params: HashMap<String, String>,
22206 _scopes: BTreeSet<String>,
22207}
22208
22209impl<'a, C> common::CallBuilder for ProjectLocationWorkerPoolGetCall<'a, C> {}
22210
22211impl<'a, C> ProjectLocationWorkerPoolGetCall<'a, C>
22212where
22213 C: common::Connector,
22214{
22215 /// Perform the operation you have build so far.
22216 pub async fn doit(mut self) -> common::Result<(common::Response, WorkerPool)> {
22217 use std::borrow::Cow;
22218 use std::io::{Read, Seek};
22219
22220 use common::{url::Params, ToParts};
22221 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22222
22223 let mut dd = common::DefaultDelegate;
22224 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22225 dlg.begin(common::MethodInfo {
22226 id: "cloudbuild.projects.locations.workerPools.get",
22227 http_method: hyper::Method::GET,
22228 });
22229
22230 for &field in ["alt", "name"].iter() {
22231 if self._additional_params.contains_key(field) {
22232 dlg.finished(false);
22233 return Err(common::Error::FieldClash(field));
22234 }
22235 }
22236
22237 let mut params = Params::with_capacity(3 + self._additional_params.len());
22238 params.push("name", self._name);
22239
22240 params.extend(self._additional_params.iter());
22241
22242 params.push("alt", "json");
22243 let mut url = self.hub._base_url.clone() + "v1/{+name}";
22244 if self._scopes.is_empty() {
22245 self._scopes
22246 .insert(Scope::CloudPlatform.as_ref().to_string());
22247 }
22248
22249 #[allow(clippy::single_element_loop)]
22250 for &(find_this, param_name) in [("{+name}", "name")].iter() {
22251 url = params.uri_replacement(url, param_name, find_this, true);
22252 }
22253 {
22254 let to_remove = ["name"];
22255 params.remove_params(&to_remove);
22256 }
22257
22258 let url = params.parse_with_url(&url);
22259
22260 loop {
22261 let token = match self
22262 .hub
22263 .auth
22264 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22265 .await
22266 {
22267 Ok(token) => token,
22268 Err(e) => match dlg.token(e) {
22269 Ok(token) => token,
22270 Err(e) => {
22271 dlg.finished(false);
22272 return Err(common::Error::MissingToken(e));
22273 }
22274 },
22275 };
22276 let mut req_result = {
22277 let client = &self.hub.client;
22278 dlg.pre_request();
22279 let mut req_builder = hyper::Request::builder()
22280 .method(hyper::Method::GET)
22281 .uri(url.as_str())
22282 .header(USER_AGENT, self.hub._user_agent.clone());
22283
22284 if let Some(token) = token.as_ref() {
22285 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22286 }
22287
22288 let request = req_builder
22289 .header(CONTENT_LENGTH, 0_u64)
22290 .body(common::to_body::<String>(None));
22291
22292 client.request(request.unwrap()).await
22293 };
22294
22295 match req_result {
22296 Err(err) => {
22297 if let common::Retry::After(d) = dlg.http_error(&err) {
22298 sleep(d).await;
22299 continue;
22300 }
22301 dlg.finished(false);
22302 return Err(common::Error::HttpError(err));
22303 }
22304 Ok(res) => {
22305 let (mut parts, body) = res.into_parts();
22306 let mut body = common::Body::new(body);
22307 if !parts.status.is_success() {
22308 let bytes = common::to_bytes(body).await.unwrap_or_default();
22309 let error = serde_json::from_str(&common::to_string(&bytes));
22310 let response = common::to_response(parts, bytes.into());
22311
22312 if let common::Retry::After(d) =
22313 dlg.http_failure(&response, error.as_ref().ok())
22314 {
22315 sleep(d).await;
22316 continue;
22317 }
22318
22319 dlg.finished(false);
22320
22321 return Err(match error {
22322 Ok(value) => common::Error::BadRequest(value),
22323 _ => common::Error::Failure(response),
22324 });
22325 }
22326 let response = {
22327 let bytes = common::to_bytes(body).await.unwrap_or_default();
22328 let encoded = common::to_string(&bytes);
22329 match serde_json::from_str(&encoded) {
22330 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22331 Err(error) => {
22332 dlg.response_json_decode_error(&encoded, &error);
22333 return Err(common::Error::JsonDecodeError(
22334 encoded.to_string(),
22335 error,
22336 ));
22337 }
22338 }
22339 };
22340
22341 dlg.finished(true);
22342 return Ok(response);
22343 }
22344 }
22345 }
22346 }
22347
22348 /// Required. The name of the `WorkerPool` to retrieve. Format: `projects/{project}/locations/{location}/workerPools/{workerPool}`.
22349 ///
22350 /// Sets the *name* path property to the given value.
22351 ///
22352 /// Even though the property as already been set when instantiating this call,
22353 /// we provide this method for API completeness.
22354 pub fn name(mut self, new_value: &str) -> ProjectLocationWorkerPoolGetCall<'a, C> {
22355 self._name = new_value.to_string();
22356 self
22357 }
22358 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22359 /// while executing the actual API request.
22360 ///
22361 /// ````text
22362 /// It should be used to handle progress information, and to implement a certain level of resilience.
22363 /// ````
22364 ///
22365 /// Sets the *delegate* property to the given value.
22366 pub fn delegate(
22367 mut self,
22368 new_value: &'a mut dyn common::Delegate,
22369 ) -> ProjectLocationWorkerPoolGetCall<'a, C> {
22370 self._delegate = Some(new_value);
22371 self
22372 }
22373
22374 /// Set any additional parameter of the query string used in the request.
22375 /// It should be used to set parameters which are not yet available through their own
22376 /// setters.
22377 ///
22378 /// Please note that this method must not be used to set any of the known parameters
22379 /// which have their own setter method. If done anyway, the request will fail.
22380 ///
22381 /// # Additional Parameters
22382 ///
22383 /// * *$.xgafv* (query-string) - V1 error format.
22384 /// * *access_token* (query-string) - OAuth access token.
22385 /// * *alt* (query-string) - Data format for response.
22386 /// * *callback* (query-string) - JSONP
22387 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22388 /// * *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.
22389 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22390 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22391 /// * *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.
22392 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22393 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22394 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationWorkerPoolGetCall<'a, C>
22395 where
22396 T: AsRef<str>,
22397 {
22398 self._additional_params
22399 .insert(name.as_ref().to_string(), value.as_ref().to_string());
22400 self
22401 }
22402
22403 /// Identifies the authorization scope for the method you are building.
22404 ///
22405 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22406 /// [`Scope::CloudPlatform`].
22407 ///
22408 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22409 /// tokens for more than one scope.
22410 ///
22411 /// Usually there is more than one suitable scope to authorize an operation, some of which may
22412 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22413 /// sufficient, a read-write scope will do as well.
22414 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationWorkerPoolGetCall<'a, C>
22415 where
22416 St: AsRef<str>,
22417 {
22418 self._scopes.insert(String::from(scope.as_ref()));
22419 self
22420 }
22421 /// Identifies the authorization scope(s) for the method you are building.
22422 ///
22423 /// See [`Self::add_scope()`] for details.
22424 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationWorkerPoolGetCall<'a, C>
22425 where
22426 I: IntoIterator<Item = St>,
22427 St: AsRef<str>,
22428 {
22429 self._scopes
22430 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22431 self
22432 }
22433
22434 /// Removes all scopes, and no default scope will be used either.
22435 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22436 /// for details).
22437 pub fn clear_scopes(mut self) -> ProjectLocationWorkerPoolGetCall<'a, C> {
22438 self._scopes.clear();
22439 self
22440 }
22441}
22442
22443/// Lists `WorkerPool`s.
22444///
22445/// A builder for the *locations.workerPools.list* method supported by a *project* resource.
22446/// It is not used directly, but through a [`ProjectMethods`] instance.
22447///
22448/// # Example
22449///
22450/// Instantiate a resource method builder
22451///
22452/// ```test_harness,no_run
22453/// # extern crate hyper;
22454/// # extern crate hyper_rustls;
22455/// # extern crate google_cloudbuild1 as cloudbuild1;
22456/// # async fn dox() {
22457/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22458///
22459/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22460/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
22461/// # .with_native_roots()
22462/// # .unwrap()
22463/// # .https_only()
22464/// # .enable_http2()
22465/// # .build();
22466///
22467/// # let executor = hyper_util::rt::TokioExecutor::new();
22468/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
22469/// # secret,
22470/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22471/// # yup_oauth2::client::CustomHyperClientBuilder::from(
22472/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
22473/// # ),
22474/// # ).build().await.unwrap();
22475///
22476/// # let client = hyper_util::client::legacy::Client::builder(
22477/// # hyper_util::rt::TokioExecutor::new()
22478/// # )
22479/// # .build(
22480/// # hyper_rustls::HttpsConnectorBuilder::new()
22481/// # .with_native_roots()
22482/// # .unwrap()
22483/// # .https_or_http()
22484/// # .enable_http2()
22485/// # .build()
22486/// # );
22487/// # let mut hub = CloudBuild::new(client, auth);
22488/// // You can configure optional parameters by calling the respective setters at will, and
22489/// // execute the final call using `doit()`.
22490/// // Values shown here are possibly random and not representative !
22491/// let result = hub.projects().locations_worker_pools_list("parent")
22492/// .page_token("At")
22493/// .page_size(-45)
22494/// .doit().await;
22495/// # }
22496/// ```
22497pub struct ProjectLocationWorkerPoolListCall<'a, C>
22498where
22499 C: 'a,
22500{
22501 hub: &'a CloudBuild<C>,
22502 _parent: String,
22503 _page_token: Option<String>,
22504 _page_size: Option<i32>,
22505 _delegate: Option<&'a mut dyn common::Delegate>,
22506 _additional_params: HashMap<String, String>,
22507 _scopes: BTreeSet<String>,
22508}
22509
22510impl<'a, C> common::CallBuilder for ProjectLocationWorkerPoolListCall<'a, C> {}
22511
22512impl<'a, C> ProjectLocationWorkerPoolListCall<'a, C>
22513where
22514 C: common::Connector,
22515{
22516 /// Perform the operation you have build so far.
22517 pub async fn doit(mut self) -> common::Result<(common::Response, ListWorkerPoolsResponse)> {
22518 use std::borrow::Cow;
22519 use std::io::{Read, Seek};
22520
22521 use common::{url::Params, ToParts};
22522 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22523
22524 let mut dd = common::DefaultDelegate;
22525 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22526 dlg.begin(common::MethodInfo {
22527 id: "cloudbuild.projects.locations.workerPools.list",
22528 http_method: hyper::Method::GET,
22529 });
22530
22531 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
22532 if self._additional_params.contains_key(field) {
22533 dlg.finished(false);
22534 return Err(common::Error::FieldClash(field));
22535 }
22536 }
22537
22538 let mut params = Params::with_capacity(5 + self._additional_params.len());
22539 params.push("parent", self._parent);
22540 if let Some(value) = self._page_token.as_ref() {
22541 params.push("pageToken", value);
22542 }
22543 if let Some(value) = self._page_size.as_ref() {
22544 params.push("pageSize", value.to_string());
22545 }
22546
22547 params.extend(self._additional_params.iter());
22548
22549 params.push("alt", "json");
22550 let mut url = self.hub._base_url.clone() + "v1/{+parent}/workerPools";
22551 if self._scopes.is_empty() {
22552 self._scopes
22553 .insert(Scope::CloudPlatform.as_ref().to_string());
22554 }
22555
22556 #[allow(clippy::single_element_loop)]
22557 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
22558 url = params.uri_replacement(url, param_name, find_this, true);
22559 }
22560 {
22561 let to_remove = ["parent"];
22562 params.remove_params(&to_remove);
22563 }
22564
22565 let url = params.parse_with_url(&url);
22566
22567 loop {
22568 let token = match self
22569 .hub
22570 .auth
22571 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22572 .await
22573 {
22574 Ok(token) => token,
22575 Err(e) => match dlg.token(e) {
22576 Ok(token) => token,
22577 Err(e) => {
22578 dlg.finished(false);
22579 return Err(common::Error::MissingToken(e));
22580 }
22581 },
22582 };
22583 let mut req_result = {
22584 let client = &self.hub.client;
22585 dlg.pre_request();
22586 let mut req_builder = hyper::Request::builder()
22587 .method(hyper::Method::GET)
22588 .uri(url.as_str())
22589 .header(USER_AGENT, self.hub._user_agent.clone());
22590
22591 if let Some(token) = token.as_ref() {
22592 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22593 }
22594
22595 let request = req_builder
22596 .header(CONTENT_LENGTH, 0_u64)
22597 .body(common::to_body::<String>(None));
22598
22599 client.request(request.unwrap()).await
22600 };
22601
22602 match req_result {
22603 Err(err) => {
22604 if let common::Retry::After(d) = dlg.http_error(&err) {
22605 sleep(d).await;
22606 continue;
22607 }
22608 dlg.finished(false);
22609 return Err(common::Error::HttpError(err));
22610 }
22611 Ok(res) => {
22612 let (mut parts, body) = res.into_parts();
22613 let mut body = common::Body::new(body);
22614 if !parts.status.is_success() {
22615 let bytes = common::to_bytes(body).await.unwrap_or_default();
22616 let error = serde_json::from_str(&common::to_string(&bytes));
22617 let response = common::to_response(parts, bytes.into());
22618
22619 if let common::Retry::After(d) =
22620 dlg.http_failure(&response, error.as_ref().ok())
22621 {
22622 sleep(d).await;
22623 continue;
22624 }
22625
22626 dlg.finished(false);
22627
22628 return Err(match error {
22629 Ok(value) => common::Error::BadRequest(value),
22630 _ => common::Error::Failure(response),
22631 });
22632 }
22633 let response = {
22634 let bytes = common::to_bytes(body).await.unwrap_or_default();
22635 let encoded = common::to_string(&bytes);
22636 match serde_json::from_str(&encoded) {
22637 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22638 Err(error) => {
22639 dlg.response_json_decode_error(&encoded, &error);
22640 return Err(common::Error::JsonDecodeError(
22641 encoded.to_string(),
22642 error,
22643 ));
22644 }
22645 }
22646 };
22647
22648 dlg.finished(true);
22649 return Ok(response);
22650 }
22651 }
22652 }
22653 }
22654
22655 /// Required. The parent of the collection of `WorkerPools`. Format: `projects/{project}/locations/{location}`.
22656 ///
22657 /// Sets the *parent* path property to the given value.
22658 ///
22659 /// Even though the property as already been set when instantiating this call,
22660 /// we provide this method for API completeness.
22661 pub fn parent(mut self, new_value: &str) -> ProjectLocationWorkerPoolListCall<'a, C> {
22662 self._parent = new_value.to_string();
22663 self
22664 }
22665 /// A page token, received from a previous `ListWorkerPools` call. Provide this to retrieve the subsequent page.
22666 ///
22667 /// Sets the *page token* query property to the given value.
22668 pub fn page_token(mut self, new_value: &str) -> ProjectLocationWorkerPoolListCall<'a, C> {
22669 self._page_token = Some(new_value.to_string());
22670 self
22671 }
22672 /// 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.
22673 ///
22674 /// Sets the *page size* query property to the given value.
22675 pub fn page_size(mut self, new_value: i32) -> ProjectLocationWorkerPoolListCall<'a, C> {
22676 self._page_size = Some(new_value);
22677 self
22678 }
22679 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
22680 /// while executing the actual API request.
22681 ///
22682 /// ````text
22683 /// It should be used to handle progress information, and to implement a certain level of resilience.
22684 /// ````
22685 ///
22686 /// Sets the *delegate* property to the given value.
22687 pub fn delegate(
22688 mut self,
22689 new_value: &'a mut dyn common::Delegate,
22690 ) -> ProjectLocationWorkerPoolListCall<'a, C> {
22691 self._delegate = Some(new_value);
22692 self
22693 }
22694
22695 /// Set any additional parameter of the query string used in the request.
22696 /// It should be used to set parameters which are not yet available through their own
22697 /// setters.
22698 ///
22699 /// Please note that this method must not be used to set any of the known parameters
22700 /// which have their own setter method. If done anyway, the request will fail.
22701 ///
22702 /// # Additional Parameters
22703 ///
22704 /// * *$.xgafv* (query-string) - V1 error format.
22705 /// * *access_token* (query-string) - OAuth access token.
22706 /// * *alt* (query-string) - Data format for response.
22707 /// * *callback* (query-string) - JSONP
22708 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
22709 /// * *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.
22710 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
22711 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
22712 /// * *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.
22713 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
22714 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
22715 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationWorkerPoolListCall<'a, C>
22716 where
22717 T: AsRef<str>,
22718 {
22719 self._additional_params
22720 .insert(name.as_ref().to_string(), value.as_ref().to_string());
22721 self
22722 }
22723
22724 /// Identifies the authorization scope for the method you are building.
22725 ///
22726 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
22727 /// [`Scope::CloudPlatform`].
22728 ///
22729 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
22730 /// tokens for more than one scope.
22731 ///
22732 /// Usually there is more than one suitable scope to authorize an operation, some of which may
22733 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
22734 /// sufficient, a read-write scope will do as well.
22735 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationWorkerPoolListCall<'a, C>
22736 where
22737 St: AsRef<str>,
22738 {
22739 self._scopes.insert(String::from(scope.as_ref()));
22740 self
22741 }
22742 /// Identifies the authorization scope(s) for the method you are building.
22743 ///
22744 /// See [`Self::add_scope()`] for details.
22745 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationWorkerPoolListCall<'a, C>
22746 where
22747 I: IntoIterator<Item = St>,
22748 St: AsRef<str>,
22749 {
22750 self._scopes
22751 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
22752 self
22753 }
22754
22755 /// Removes all scopes, and no default scope will be used either.
22756 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
22757 /// for details).
22758 pub fn clear_scopes(mut self) -> ProjectLocationWorkerPoolListCall<'a, C> {
22759 self._scopes.clear();
22760 self
22761 }
22762}
22763
22764/// Updates a `WorkerPool`.
22765///
22766/// A builder for the *locations.workerPools.patch* method supported by a *project* resource.
22767/// It is not used directly, but through a [`ProjectMethods`] instance.
22768///
22769/// # Example
22770///
22771/// Instantiate a resource method builder
22772///
22773/// ```test_harness,no_run
22774/// # extern crate hyper;
22775/// # extern crate hyper_rustls;
22776/// # extern crate google_cloudbuild1 as cloudbuild1;
22777/// use cloudbuild1::api::WorkerPool;
22778/// # async fn dox() {
22779/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
22780///
22781/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
22782/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
22783/// # .with_native_roots()
22784/// # .unwrap()
22785/// # .https_only()
22786/// # .enable_http2()
22787/// # .build();
22788///
22789/// # let executor = hyper_util::rt::TokioExecutor::new();
22790/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
22791/// # secret,
22792/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
22793/// # yup_oauth2::client::CustomHyperClientBuilder::from(
22794/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
22795/// # ),
22796/// # ).build().await.unwrap();
22797///
22798/// # let client = hyper_util::client::legacy::Client::builder(
22799/// # hyper_util::rt::TokioExecutor::new()
22800/// # )
22801/// # .build(
22802/// # hyper_rustls::HttpsConnectorBuilder::new()
22803/// # .with_native_roots()
22804/// # .unwrap()
22805/// # .https_or_http()
22806/// # .enable_http2()
22807/// # .build()
22808/// # );
22809/// # let mut hub = CloudBuild::new(client, auth);
22810/// // As the method needs a request, you would usually fill it with the desired information
22811/// // into the respective structure. Some of the parts shown here might not be applicable !
22812/// // Values shown here are possibly random and not representative !
22813/// let mut req = WorkerPool::default();
22814///
22815/// // You can configure optional parameters by calling the respective setters at will, and
22816/// // execute the final call using `doit()`.
22817/// // Values shown here are possibly random and not representative !
22818/// let result = hub.projects().locations_worker_pools_patch(req, "name")
22819/// .validate_only(true)
22820/// .update_mask(FieldMask::new::<&str>(&[]))
22821/// .doit().await;
22822/// # }
22823/// ```
22824pub struct ProjectLocationWorkerPoolPatchCall<'a, C>
22825where
22826 C: 'a,
22827{
22828 hub: &'a CloudBuild<C>,
22829 _request: WorkerPool,
22830 _name: String,
22831 _validate_only: Option<bool>,
22832 _update_mask: Option<common::FieldMask>,
22833 _delegate: Option<&'a mut dyn common::Delegate>,
22834 _additional_params: HashMap<String, String>,
22835 _scopes: BTreeSet<String>,
22836}
22837
22838impl<'a, C> common::CallBuilder for ProjectLocationWorkerPoolPatchCall<'a, C> {}
22839
22840impl<'a, C> ProjectLocationWorkerPoolPatchCall<'a, C>
22841where
22842 C: common::Connector,
22843{
22844 /// Perform the operation you have build so far.
22845 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
22846 use std::borrow::Cow;
22847 use std::io::{Read, Seek};
22848
22849 use common::{url::Params, ToParts};
22850 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
22851
22852 let mut dd = common::DefaultDelegate;
22853 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
22854 dlg.begin(common::MethodInfo {
22855 id: "cloudbuild.projects.locations.workerPools.patch",
22856 http_method: hyper::Method::PATCH,
22857 });
22858
22859 for &field in ["alt", "name", "validateOnly", "updateMask"].iter() {
22860 if self._additional_params.contains_key(field) {
22861 dlg.finished(false);
22862 return Err(common::Error::FieldClash(field));
22863 }
22864 }
22865
22866 let mut params = Params::with_capacity(6 + self._additional_params.len());
22867 params.push("name", self._name);
22868 if let Some(value) = self._validate_only.as_ref() {
22869 params.push("validateOnly", value.to_string());
22870 }
22871 if let Some(value) = self._update_mask.as_ref() {
22872 params.push("updateMask", value.to_string());
22873 }
22874
22875 params.extend(self._additional_params.iter());
22876
22877 params.push("alt", "json");
22878 let mut url = self.hub._base_url.clone() + "v1/{+name}";
22879 if self._scopes.is_empty() {
22880 self._scopes
22881 .insert(Scope::CloudPlatform.as_ref().to_string());
22882 }
22883
22884 #[allow(clippy::single_element_loop)]
22885 for &(find_this, param_name) in [("{+name}", "name")].iter() {
22886 url = params.uri_replacement(url, param_name, find_this, true);
22887 }
22888 {
22889 let to_remove = ["name"];
22890 params.remove_params(&to_remove);
22891 }
22892
22893 let url = params.parse_with_url(&url);
22894
22895 let mut json_mime_type = mime::APPLICATION_JSON;
22896 let mut request_value_reader = {
22897 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
22898 common::remove_json_null_values(&mut value);
22899 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
22900 serde_json::to_writer(&mut dst, &value).unwrap();
22901 dst
22902 };
22903 let request_size = request_value_reader
22904 .seek(std::io::SeekFrom::End(0))
22905 .unwrap();
22906 request_value_reader
22907 .seek(std::io::SeekFrom::Start(0))
22908 .unwrap();
22909
22910 loop {
22911 let token = match self
22912 .hub
22913 .auth
22914 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
22915 .await
22916 {
22917 Ok(token) => token,
22918 Err(e) => match dlg.token(e) {
22919 Ok(token) => token,
22920 Err(e) => {
22921 dlg.finished(false);
22922 return Err(common::Error::MissingToken(e));
22923 }
22924 },
22925 };
22926 request_value_reader
22927 .seek(std::io::SeekFrom::Start(0))
22928 .unwrap();
22929 let mut req_result = {
22930 let client = &self.hub.client;
22931 dlg.pre_request();
22932 let mut req_builder = hyper::Request::builder()
22933 .method(hyper::Method::PATCH)
22934 .uri(url.as_str())
22935 .header(USER_AGENT, self.hub._user_agent.clone());
22936
22937 if let Some(token) = token.as_ref() {
22938 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
22939 }
22940
22941 let request = req_builder
22942 .header(CONTENT_TYPE, json_mime_type.to_string())
22943 .header(CONTENT_LENGTH, request_size as u64)
22944 .body(common::to_body(
22945 request_value_reader.get_ref().clone().into(),
22946 ));
22947
22948 client.request(request.unwrap()).await
22949 };
22950
22951 match req_result {
22952 Err(err) => {
22953 if let common::Retry::After(d) = dlg.http_error(&err) {
22954 sleep(d).await;
22955 continue;
22956 }
22957 dlg.finished(false);
22958 return Err(common::Error::HttpError(err));
22959 }
22960 Ok(res) => {
22961 let (mut parts, body) = res.into_parts();
22962 let mut body = common::Body::new(body);
22963 if !parts.status.is_success() {
22964 let bytes = common::to_bytes(body).await.unwrap_or_default();
22965 let error = serde_json::from_str(&common::to_string(&bytes));
22966 let response = common::to_response(parts, bytes.into());
22967
22968 if let common::Retry::After(d) =
22969 dlg.http_failure(&response, error.as_ref().ok())
22970 {
22971 sleep(d).await;
22972 continue;
22973 }
22974
22975 dlg.finished(false);
22976
22977 return Err(match error {
22978 Ok(value) => common::Error::BadRequest(value),
22979 _ => common::Error::Failure(response),
22980 });
22981 }
22982 let response = {
22983 let bytes = common::to_bytes(body).await.unwrap_or_default();
22984 let encoded = common::to_string(&bytes);
22985 match serde_json::from_str(&encoded) {
22986 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
22987 Err(error) => {
22988 dlg.response_json_decode_error(&encoded, &error);
22989 return Err(common::Error::JsonDecodeError(
22990 encoded.to_string(),
22991 error,
22992 ));
22993 }
22994 }
22995 };
22996
22997 dlg.finished(true);
22998 return Ok(response);
22999 }
23000 }
23001 }
23002 }
23003
23004 ///
23005 /// Sets the *request* property to the given value.
23006 ///
23007 /// Even though the property as already been set when instantiating this call,
23008 /// we provide this method for API completeness.
23009 pub fn request(mut self, new_value: WorkerPool) -> ProjectLocationWorkerPoolPatchCall<'a, C> {
23010 self._request = new_value;
23011 self
23012 }
23013 /// 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.
23014 ///
23015 /// Sets the *name* path property to the given value.
23016 ///
23017 /// Even though the property as already been set when instantiating this call,
23018 /// we provide this method for API completeness.
23019 pub fn name(mut self, new_value: &str) -> ProjectLocationWorkerPoolPatchCall<'a, C> {
23020 self._name = new_value.to_string();
23021 self
23022 }
23023 /// If set, validate the request and preview the response, but do not actually post it.
23024 ///
23025 /// Sets the *validate only* query property to the given value.
23026 pub fn validate_only(mut self, new_value: bool) -> ProjectLocationWorkerPoolPatchCall<'a, C> {
23027 self._validate_only = Some(new_value);
23028 self
23029 }
23030 /// Optional. A mask specifying which fields in `worker_pool` to update.
23031 ///
23032 /// Sets the *update mask* query property to the given value.
23033 pub fn update_mask(
23034 mut self,
23035 new_value: common::FieldMask,
23036 ) -> ProjectLocationWorkerPoolPatchCall<'a, C> {
23037 self._update_mask = Some(new_value);
23038 self
23039 }
23040 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23041 /// while executing the actual API request.
23042 ///
23043 /// ````text
23044 /// It should be used to handle progress information, and to implement a certain level of resilience.
23045 /// ````
23046 ///
23047 /// Sets the *delegate* property to the given value.
23048 pub fn delegate(
23049 mut self,
23050 new_value: &'a mut dyn common::Delegate,
23051 ) -> ProjectLocationWorkerPoolPatchCall<'a, C> {
23052 self._delegate = Some(new_value);
23053 self
23054 }
23055
23056 /// Set any additional parameter of the query string used in the request.
23057 /// It should be used to set parameters which are not yet available through their own
23058 /// setters.
23059 ///
23060 /// Please note that this method must not be used to set any of the known parameters
23061 /// which have their own setter method. If done anyway, the request will fail.
23062 ///
23063 /// # Additional Parameters
23064 ///
23065 /// * *$.xgafv* (query-string) - V1 error format.
23066 /// * *access_token* (query-string) - OAuth access token.
23067 /// * *alt* (query-string) - Data format for response.
23068 /// * *callback* (query-string) - JSONP
23069 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23070 /// * *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.
23071 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23072 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23073 /// * *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.
23074 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
23075 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
23076 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationWorkerPoolPatchCall<'a, C>
23077 where
23078 T: AsRef<str>,
23079 {
23080 self._additional_params
23081 .insert(name.as_ref().to_string(), value.as_ref().to_string());
23082 self
23083 }
23084
23085 /// Identifies the authorization scope for the method you are building.
23086 ///
23087 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23088 /// [`Scope::CloudPlatform`].
23089 ///
23090 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23091 /// tokens for more than one scope.
23092 ///
23093 /// Usually there is more than one suitable scope to authorize an operation, some of which may
23094 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23095 /// sufficient, a read-write scope will do as well.
23096 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationWorkerPoolPatchCall<'a, C>
23097 where
23098 St: AsRef<str>,
23099 {
23100 self._scopes.insert(String::from(scope.as_ref()));
23101 self
23102 }
23103 /// Identifies the authorization scope(s) for the method you are building.
23104 ///
23105 /// See [`Self::add_scope()`] for details.
23106 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationWorkerPoolPatchCall<'a, C>
23107 where
23108 I: IntoIterator<Item = St>,
23109 St: AsRef<str>,
23110 {
23111 self._scopes
23112 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23113 self
23114 }
23115
23116 /// Removes all scopes, and no default scope will be used either.
23117 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23118 /// for details).
23119 pub fn clear_scopes(mut self) -> ProjectLocationWorkerPoolPatchCall<'a, C> {
23120 self._scopes.clear();
23121 self
23122 }
23123}
23124
23125/// Returns the `DefaultServiceAccount` used by the project.
23126///
23127/// A builder for the *locations.getDefaultServiceAccount* method supported by a *project* resource.
23128/// It is not used directly, but through a [`ProjectMethods`] instance.
23129///
23130/// # Example
23131///
23132/// Instantiate a resource method builder
23133///
23134/// ```test_harness,no_run
23135/// # extern crate hyper;
23136/// # extern crate hyper_rustls;
23137/// # extern crate google_cloudbuild1 as cloudbuild1;
23138/// # async fn dox() {
23139/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23140///
23141/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23142/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
23143/// # .with_native_roots()
23144/// # .unwrap()
23145/// # .https_only()
23146/// # .enable_http2()
23147/// # .build();
23148///
23149/// # let executor = hyper_util::rt::TokioExecutor::new();
23150/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
23151/// # secret,
23152/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23153/// # yup_oauth2::client::CustomHyperClientBuilder::from(
23154/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
23155/// # ),
23156/// # ).build().await.unwrap();
23157///
23158/// # let client = hyper_util::client::legacy::Client::builder(
23159/// # hyper_util::rt::TokioExecutor::new()
23160/// # )
23161/// # .build(
23162/// # hyper_rustls::HttpsConnectorBuilder::new()
23163/// # .with_native_roots()
23164/// # .unwrap()
23165/// # .https_or_http()
23166/// # .enable_http2()
23167/// # .build()
23168/// # );
23169/// # let mut hub = CloudBuild::new(client, auth);
23170/// // You can configure optional parameters by calling the respective setters at will, and
23171/// // execute the final call using `doit()`.
23172/// // Values shown here are possibly random and not representative !
23173/// let result = hub.projects().locations_get_default_service_account("name")
23174/// .doit().await;
23175/// # }
23176/// ```
23177pub struct ProjectLocationGetDefaultServiceAccountCall<'a, C>
23178where
23179 C: 'a,
23180{
23181 hub: &'a CloudBuild<C>,
23182 _name: String,
23183 _delegate: Option<&'a mut dyn common::Delegate>,
23184 _additional_params: HashMap<String, String>,
23185 _scopes: BTreeSet<String>,
23186}
23187
23188impl<'a, C> common::CallBuilder for ProjectLocationGetDefaultServiceAccountCall<'a, C> {}
23189
23190impl<'a, C> ProjectLocationGetDefaultServiceAccountCall<'a, C>
23191where
23192 C: common::Connector,
23193{
23194 /// Perform the operation you have build so far.
23195 pub async fn doit(mut self) -> common::Result<(common::Response, DefaultServiceAccount)> {
23196 use std::borrow::Cow;
23197 use std::io::{Read, Seek};
23198
23199 use common::{url::Params, ToParts};
23200 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23201
23202 let mut dd = common::DefaultDelegate;
23203 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23204 dlg.begin(common::MethodInfo {
23205 id: "cloudbuild.projects.locations.getDefaultServiceAccount",
23206 http_method: hyper::Method::GET,
23207 });
23208
23209 for &field in ["alt", "name"].iter() {
23210 if self._additional_params.contains_key(field) {
23211 dlg.finished(false);
23212 return Err(common::Error::FieldClash(field));
23213 }
23214 }
23215
23216 let mut params = Params::with_capacity(3 + self._additional_params.len());
23217 params.push("name", self._name);
23218
23219 params.extend(self._additional_params.iter());
23220
23221 params.push("alt", "json");
23222 let mut url = self.hub._base_url.clone() + "v1/{+name}";
23223 if self._scopes.is_empty() {
23224 self._scopes
23225 .insert(Scope::CloudPlatform.as_ref().to_string());
23226 }
23227
23228 #[allow(clippy::single_element_loop)]
23229 for &(find_this, param_name) in [("{+name}", "name")].iter() {
23230 url = params.uri_replacement(url, param_name, find_this, true);
23231 }
23232 {
23233 let to_remove = ["name"];
23234 params.remove_params(&to_remove);
23235 }
23236
23237 let url = params.parse_with_url(&url);
23238
23239 loop {
23240 let token = match self
23241 .hub
23242 .auth
23243 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23244 .await
23245 {
23246 Ok(token) => token,
23247 Err(e) => match dlg.token(e) {
23248 Ok(token) => token,
23249 Err(e) => {
23250 dlg.finished(false);
23251 return Err(common::Error::MissingToken(e));
23252 }
23253 },
23254 };
23255 let mut req_result = {
23256 let client = &self.hub.client;
23257 dlg.pre_request();
23258 let mut req_builder = hyper::Request::builder()
23259 .method(hyper::Method::GET)
23260 .uri(url.as_str())
23261 .header(USER_AGENT, self.hub._user_agent.clone());
23262
23263 if let Some(token) = token.as_ref() {
23264 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23265 }
23266
23267 let request = req_builder
23268 .header(CONTENT_LENGTH, 0_u64)
23269 .body(common::to_body::<String>(None));
23270
23271 client.request(request.unwrap()).await
23272 };
23273
23274 match req_result {
23275 Err(err) => {
23276 if let common::Retry::After(d) = dlg.http_error(&err) {
23277 sleep(d).await;
23278 continue;
23279 }
23280 dlg.finished(false);
23281 return Err(common::Error::HttpError(err));
23282 }
23283 Ok(res) => {
23284 let (mut parts, body) = res.into_parts();
23285 let mut body = common::Body::new(body);
23286 if !parts.status.is_success() {
23287 let bytes = common::to_bytes(body).await.unwrap_or_default();
23288 let error = serde_json::from_str(&common::to_string(&bytes));
23289 let response = common::to_response(parts, bytes.into());
23290
23291 if let common::Retry::After(d) =
23292 dlg.http_failure(&response, error.as_ref().ok())
23293 {
23294 sleep(d).await;
23295 continue;
23296 }
23297
23298 dlg.finished(false);
23299
23300 return Err(match error {
23301 Ok(value) => common::Error::BadRequest(value),
23302 _ => common::Error::Failure(response),
23303 });
23304 }
23305 let response = {
23306 let bytes = common::to_bytes(body).await.unwrap_or_default();
23307 let encoded = common::to_string(&bytes);
23308 match serde_json::from_str(&encoded) {
23309 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23310 Err(error) => {
23311 dlg.response_json_decode_error(&encoded, &error);
23312 return Err(common::Error::JsonDecodeError(
23313 encoded.to_string(),
23314 error,
23315 ));
23316 }
23317 }
23318 };
23319
23320 dlg.finished(true);
23321 return Ok(response);
23322 }
23323 }
23324 }
23325 }
23326
23327 /// Required. The name of the `DefaultServiceAccount` to retrieve. Format: `projects/{project}/locations/{location}/defaultServiceAccount`
23328 ///
23329 /// Sets the *name* path property to the given value.
23330 ///
23331 /// Even though the property as already been set when instantiating this call,
23332 /// we provide this method for API completeness.
23333 pub fn name(mut self, new_value: &str) -> ProjectLocationGetDefaultServiceAccountCall<'a, C> {
23334 self._name = new_value.to_string();
23335 self
23336 }
23337 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23338 /// while executing the actual API request.
23339 ///
23340 /// ````text
23341 /// It should be used to handle progress information, and to implement a certain level of resilience.
23342 /// ````
23343 ///
23344 /// Sets the *delegate* property to the given value.
23345 pub fn delegate(
23346 mut self,
23347 new_value: &'a mut dyn common::Delegate,
23348 ) -> ProjectLocationGetDefaultServiceAccountCall<'a, C> {
23349 self._delegate = Some(new_value);
23350 self
23351 }
23352
23353 /// Set any additional parameter of the query string used in the request.
23354 /// It should be used to set parameters which are not yet available through their own
23355 /// setters.
23356 ///
23357 /// Please note that this method must not be used to set any of the known parameters
23358 /// which have their own setter method. If done anyway, the request will fail.
23359 ///
23360 /// # Additional Parameters
23361 ///
23362 /// * *$.xgafv* (query-string) - V1 error format.
23363 /// * *access_token* (query-string) - OAuth access token.
23364 /// * *alt* (query-string) - Data format for response.
23365 /// * *callback* (query-string) - JSONP
23366 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23367 /// * *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.
23368 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23369 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23370 /// * *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.
23371 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
23372 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
23373 pub fn param<T>(
23374 mut self,
23375 name: T,
23376 value: T,
23377 ) -> ProjectLocationGetDefaultServiceAccountCall<'a, C>
23378 where
23379 T: AsRef<str>,
23380 {
23381 self._additional_params
23382 .insert(name.as_ref().to_string(), value.as_ref().to_string());
23383 self
23384 }
23385
23386 /// Identifies the authorization scope for the method you are building.
23387 ///
23388 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23389 /// [`Scope::CloudPlatform`].
23390 ///
23391 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23392 /// tokens for more than one scope.
23393 ///
23394 /// Usually there is more than one suitable scope to authorize an operation, some of which may
23395 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23396 /// sufficient, a read-write scope will do as well.
23397 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGetDefaultServiceAccountCall<'a, C>
23398 where
23399 St: AsRef<str>,
23400 {
23401 self._scopes.insert(String::from(scope.as_ref()));
23402 self
23403 }
23404 /// Identifies the authorization scope(s) for the method you are building.
23405 ///
23406 /// See [`Self::add_scope()`] for details.
23407 pub fn add_scopes<I, St>(
23408 mut self,
23409 scopes: I,
23410 ) -> ProjectLocationGetDefaultServiceAccountCall<'a, C>
23411 where
23412 I: IntoIterator<Item = St>,
23413 St: AsRef<str>,
23414 {
23415 self._scopes
23416 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23417 self
23418 }
23419
23420 /// Removes all scopes, and no default scope will be used either.
23421 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23422 /// for details).
23423 pub fn clear_scopes(mut self) -> ProjectLocationGetDefaultServiceAccountCall<'a, C> {
23424 self._scopes.clear();
23425 self
23426 }
23427}
23428
23429/// Creates a new `BuildTrigger`.
23430///
23431/// A builder for the *triggers.create* method supported by a *project* resource.
23432/// It is not used directly, but through a [`ProjectMethods`] instance.
23433///
23434/// # Example
23435///
23436/// Instantiate a resource method builder
23437///
23438/// ```test_harness,no_run
23439/// # extern crate hyper;
23440/// # extern crate hyper_rustls;
23441/// # extern crate google_cloudbuild1 as cloudbuild1;
23442/// use cloudbuild1::api::BuildTrigger;
23443/// # async fn dox() {
23444/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23445///
23446/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23447/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
23448/// # .with_native_roots()
23449/// # .unwrap()
23450/// # .https_only()
23451/// # .enable_http2()
23452/// # .build();
23453///
23454/// # let executor = hyper_util::rt::TokioExecutor::new();
23455/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
23456/// # secret,
23457/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23458/// # yup_oauth2::client::CustomHyperClientBuilder::from(
23459/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
23460/// # ),
23461/// # ).build().await.unwrap();
23462///
23463/// # let client = hyper_util::client::legacy::Client::builder(
23464/// # hyper_util::rt::TokioExecutor::new()
23465/// # )
23466/// # .build(
23467/// # hyper_rustls::HttpsConnectorBuilder::new()
23468/// # .with_native_roots()
23469/// # .unwrap()
23470/// # .https_or_http()
23471/// # .enable_http2()
23472/// # .build()
23473/// # );
23474/// # let mut hub = CloudBuild::new(client, auth);
23475/// // As the method needs a request, you would usually fill it with the desired information
23476/// // into the respective structure. Some of the parts shown here might not be applicable !
23477/// // Values shown here are possibly random and not representative !
23478/// let mut req = BuildTrigger::default();
23479///
23480/// // You can configure optional parameters by calling the respective setters at will, and
23481/// // execute the final call using `doit()`.
23482/// // Values shown here are possibly random and not representative !
23483/// let result = hub.projects().triggers_create(req, "projectId")
23484/// .parent("aliquyam")
23485/// .doit().await;
23486/// # }
23487/// ```
23488pub struct ProjectTriggerCreateCall<'a, C>
23489where
23490 C: 'a,
23491{
23492 hub: &'a CloudBuild<C>,
23493 _request: BuildTrigger,
23494 _project_id: String,
23495 _parent: Option<String>,
23496 _delegate: Option<&'a mut dyn common::Delegate>,
23497 _additional_params: HashMap<String, String>,
23498 _scopes: BTreeSet<String>,
23499}
23500
23501impl<'a, C> common::CallBuilder for ProjectTriggerCreateCall<'a, C> {}
23502
23503impl<'a, C> ProjectTriggerCreateCall<'a, C>
23504where
23505 C: common::Connector,
23506{
23507 /// Perform the operation you have build so far.
23508 pub async fn doit(mut self) -> common::Result<(common::Response, BuildTrigger)> {
23509 use std::borrow::Cow;
23510 use std::io::{Read, Seek};
23511
23512 use common::{url::Params, ToParts};
23513 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23514
23515 let mut dd = common::DefaultDelegate;
23516 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23517 dlg.begin(common::MethodInfo {
23518 id: "cloudbuild.projects.triggers.create",
23519 http_method: hyper::Method::POST,
23520 });
23521
23522 for &field in ["alt", "projectId", "parent"].iter() {
23523 if self._additional_params.contains_key(field) {
23524 dlg.finished(false);
23525 return Err(common::Error::FieldClash(field));
23526 }
23527 }
23528
23529 let mut params = Params::with_capacity(5 + self._additional_params.len());
23530 params.push("projectId", self._project_id);
23531 if let Some(value) = self._parent.as_ref() {
23532 params.push("parent", value);
23533 }
23534
23535 params.extend(self._additional_params.iter());
23536
23537 params.push("alt", "json");
23538 let mut url = self.hub._base_url.clone() + "v1/projects/{projectId}/triggers";
23539 if self._scopes.is_empty() {
23540 self._scopes
23541 .insert(Scope::CloudPlatform.as_ref().to_string());
23542 }
23543
23544 #[allow(clippy::single_element_loop)]
23545 for &(find_this, param_name) in [("{projectId}", "projectId")].iter() {
23546 url = params.uri_replacement(url, param_name, find_this, false);
23547 }
23548 {
23549 let to_remove = ["projectId"];
23550 params.remove_params(&to_remove);
23551 }
23552
23553 let url = params.parse_with_url(&url);
23554
23555 let mut json_mime_type = mime::APPLICATION_JSON;
23556 let mut request_value_reader = {
23557 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
23558 common::remove_json_null_values(&mut value);
23559 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
23560 serde_json::to_writer(&mut dst, &value).unwrap();
23561 dst
23562 };
23563 let request_size = request_value_reader
23564 .seek(std::io::SeekFrom::End(0))
23565 .unwrap();
23566 request_value_reader
23567 .seek(std::io::SeekFrom::Start(0))
23568 .unwrap();
23569
23570 loop {
23571 let token = match self
23572 .hub
23573 .auth
23574 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23575 .await
23576 {
23577 Ok(token) => token,
23578 Err(e) => match dlg.token(e) {
23579 Ok(token) => token,
23580 Err(e) => {
23581 dlg.finished(false);
23582 return Err(common::Error::MissingToken(e));
23583 }
23584 },
23585 };
23586 request_value_reader
23587 .seek(std::io::SeekFrom::Start(0))
23588 .unwrap();
23589 let mut req_result = {
23590 let client = &self.hub.client;
23591 dlg.pre_request();
23592 let mut req_builder = hyper::Request::builder()
23593 .method(hyper::Method::POST)
23594 .uri(url.as_str())
23595 .header(USER_AGENT, self.hub._user_agent.clone());
23596
23597 if let Some(token) = token.as_ref() {
23598 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23599 }
23600
23601 let request = req_builder
23602 .header(CONTENT_TYPE, json_mime_type.to_string())
23603 .header(CONTENT_LENGTH, request_size as u64)
23604 .body(common::to_body(
23605 request_value_reader.get_ref().clone().into(),
23606 ));
23607
23608 client.request(request.unwrap()).await
23609 };
23610
23611 match req_result {
23612 Err(err) => {
23613 if let common::Retry::After(d) = dlg.http_error(&err) {
23614 sleep(d).await;
23615 continue;
23616 }
23617 dlg.finished(false);
23618 return Err(common::Error::HttpError(err));
23619 }
23620 Ok(res) => {
23621 let (mut parts, body) = res.into_parts();
23622 let mut body = common::Body::new(body);
23623 if !parts.status.is_success() {
23624 let bytes = common::to_bytes(body).await.unwrap_or_default();
23625 let error = serde_json::from_str(&common::to_string(&bytes));
23626 let response = common::to_response(parts, bytes.into());
23627
23628 if let common::Retry::After(d) =
23629 dlg.http_failure(&response, error.as_ref().ok())
23630 {
23631 sleep(d).await;
23632 continue;
23633 }
23634
23635 dlg.finished(false);
23636
23637 return Err(match error {
23638 Ok(value) => common::Error::BadRequest(value),
23639 _ => common::Error::Failure(response),
23640 });
23641 }
23642 let response = {
23643 let bytes = common::to_bytes(body).await.unwrap_or_default();
23644 let encoded = common::to_string(&bytes);
23645 match serde_json::from_str(&encoded) {
23646 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23647 Err(error) => {
23648 dlg.response_json_decode_error(&encoded, &error);
23649 return Err(common::Error::JsonDecodeError(
23650 encoded.to_string(),
23651 error,
23652 ));
23653 }
23654 }
23655 };
23656
23657 dlg.finished(true);
23658 return Ok(response);
23659 }
23660 }
23661 }
23662 }
23663
23664 ///
23665 /// Sets the *request* property to the given value.
23666 ///
23667 /// Even though the property as already been set when instantiating this call,
23668 /// we provide this method for API completeness.
23669 pub fn request(mut self, new_value: BuildTrigger) -> ProjectTriggerCreateCall<'a, C> {
23670 self._request = new_value;
23671 self
23672 }
23673 /// Required. ID of the project for which to configure automatic builds.
23674 ///
23675 /// Sets the *project id* path property to the given value.
23676 ///
23677 /// Even though the property as already been set when instantiating this call,
23678 /// we provide this method for API completeness.
23679 pub fn project_id(mut self, new_value: &str) -> ProjectTriggerCreateCall<'a, C> {
23680 self._project_id = new_value.to_string();
23681 self
23682 }
23683 /// The parent resource where this trigger will be created. Format: `projects/{project}/locations/{location}`
23684 ///
23685 /// Sets the *parent* query property to the given value.
23686 pub fn parent(mut self, new_value: &str) -> ProjectTriggerCreateCall<'a, C> {
23687 self._parent = Some(new_value.to_string());
23688 self
23689 }
23690 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
23691 /// while executing the actual API request.
23692 ///
23693 /// ````text
23694 /// It should be used to handle progress information, and to implement a certain level of resilience.
23695 /// ````
23696 ///
23697 /// Sets the *delegate* property to the given value.
23698 pub fn delegate(
23699 mut self,
23700 new_value: &'a mut dyn common::Delegate,
23701 ) -> ProjectTriggerCreateCall<'a, C> {
23702 self._delegate = Some(new_value);
23703 self
23704 }
23705
23706 /// Set any additional parameter of the query string used in the request.
23707 /// It should be used to set parameters which are not yet available through their own
23708 /// setters.
23709 ///
23710 /// Please note that this method must not be used to set any of the known parameters
23711 /// which have their own setter method. If done anyway, the request will fail.
23712 ///
23713 /// # Additional Parameters
23714 ///
23715 /// * *$.xgafv* (query-string) - V1 error format.
23716 /// * *access_token* (query-string) - OAuth access token.
23717 /// * *alt* (query-string) - Data format for response.
23718 /// * *callback* (query-string) - JSONP
23719 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
23720 /// * *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.
23721 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
23722 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
23723 /// * *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.
23724 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
23725 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
23726 pub fn param<T>(mut self, name: T, value: T) -> ProjectTriggerCreateCall<'a, C>
23727 where
23728 T: AsRef<str>,
23729 {
23730 self._additional_params
23731 .insert(name.as_ref().to_string(), value.as_ref().to_string());
23732 self
23733 }
23734
23735 /// Identifies the authorization scope for the method you are building.
23736 ///
23737 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
23738 /// [`Scope::CloudPlatform`].
23739 ///
23740 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
23741 /// tokens for more than one scope.
23742 ///
23743 /// Usually there is more than one suitable scope to authorize an operation, some of which may
23744 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
23745 /// sufficient, a read-write scope will do as well.
23746 pub fn add_scope<St>(mut self, scope: St) -> ProjectTriggerCreateCall<'a, C>
23747 where
23748 St: AsRef<str>,
23749 {
23750 self._scopes.insert(String::from(scope.as_ref()));
23751 self
23752 }
23753 /// Identifies the authorization scope(s) for the method you are building.
23754 ///
23755 /// See [`Self::add_scope()`] for details.
23756 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectTriggerCreateCall<'a, C>
23757 where
23758 I: IntoIterator<Item = St>,
23759 St: AsRef<str>,
23760 {
23761 self._scopes
23762 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
23763 self
23764 }
23765
23766 /// Removes all scopes, and no default scope will be used either.
23767 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
23768 /// for details).
23769 pub fn clear_scopes(mut self) -> ProjectTriggerCreateCall<'a, C> {
23770 self._scopes.clear();
23771 self
23772 }
23773}
23774
23775/// Deletes a `BuildTrigger` by its project ID and trigger ID.
23776///
23777/// A builder for the *triggers.delete* method supported by a *project* resource.
23778/// It is not used directly, but through a [`ProjectMethods`] instance.
23779///
23780/// # Example
23781///
23782/// Instantiate a resource method builder
23783///
23784/// ```test_harness,no_run
23785/// # extern crate hyper;
23786/// # extern crate hyper_rustls;
23787/// # extern crate google_cloudbuild1 as cloudbuild1;
23788/// # async fn dox() {
23789/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
23790///
23791/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
23792/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
23793/// # .with_native_roots()
23794/// # .unwrap()
23795/// # .https_only()
23796/// # .enable_http2()
23797/// # .build();
23798///
23799/// # let executor = hyper_util::rt::TokioExecutor::new();
23800/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
23801/// # secret,
23802/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
23803/// # yup_oauth2::client::CustomHyperClientBuilder::from(
23804/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
23805/// # ),
23806/// # ).build().await.unwrap();
23807///
23808/// # let client = hyper_util::client::legacy::Client::builder(
23809/// # hyper_util::rt::TokioExecutor::new()
23810/// # )
23811/// # .build(
23812/// # hyper_rustls::HttpsConnectorBuilder::new()
23813/// # .with_native_roots()
23814/// # .unwrap()
23815/// # .https_or_http()
23816/// # .enable_http2()
23817/// # .build()
23818/// # );
23819/// # let mut hub = CloudBuild::new(client, auth);
23820/// // You can configure optional parameters by calling the respective setters at will, and
23821/// // execute the final call using `doit()`.
23822/// // Values shown here are possibly random and not representative !
23823/// let result = hub.projects().triggers_delete("projectId", "triggerId")
23824/// .name("et")
23825/// .doit().await;
23826/// # }
23827/// ```
23828pub struct ProjectTriggerDeleteCall<'a, C>
23829where
23830 C: 'a,
23831{
23832 hub: &'a CloudBuild<C>,
23833 _project_id: String,
23834 _trigger_id: String,
23835 _name: Option<String>,
23836 _delegate: Option<&'a mut dyn common::Delegate>,
23837 _additional_params: HashMap<String, String>,
23838 _scopes: BTreeSet<String>,
23839}
23840
23841impl<'a, C> common::CallBuilder for ProjectTriggerDeleteCall<'a, C> {}
23842
23843impl<'a, C> ProjectTriggerDeleteCall<'a, C>
23844where
23845 C: common::Connector,
23846{
23847 /// Perform the operation you have build so far.
23848 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
23849 use std::borrow::Cow;
23850 use std::io::{Read, Seek};
23851
23852 use common::{url::Params, ToParts};
23853 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
23854
23855 let mut dd = common::DefaultDelegate;
23856 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
23857 dlg.begin(common::MethodInfo {
23858 id: "cloudbuild.projects.triggers.delete",
23859 http_method: hyper::Method::DELETE,
23860 });
23861
23862 for &field in ["alt", "projectId", "triggerId", "name"].iter() {
23863 if self._additional_params.contains_key(field) {
23864 dlg.finished(false);
23865 return Err(common::Error::FieldClash(field));
23866 }
23867 }
23868
23869 let mut params = Params::with_capacity(5 + self._additional_params.len());
23870 params.push("projectId", self._project_id);
23871 params.push("triggerId", self._trigger_id);
23872 if let Some(value) = self._name.as_ref() {
23873 params.push("name", value);
23874 }
23875
23876 params.extend(self._additional_params.iter());
23877
23878 params.push("alt", "json");
23879 let mut url = self.hub._base_url.clone() + "v1/projects/{projectId}/triggers/{triggerId}";
23880 if self._scopes.is_empty() {
23881 self._scopes
23882 .insert(Scope::CloudPlatform.as_ref().to_string());
23883 }
23884
23885 #[allow(clippy::single_element_loop)]
23886 for &(find_this, param_name) in
23887 [("{projectId}", "projectId"), ("{triggerId}", "triggerId")].iter()
23888 {
23889 url = params.uri_replacement(url, param_name, find_this, false);
23890 }
23891 {
23892 let to_remove = ["triggerId", "projectId"];
23893 params.remove_params(&to_remove);
23894 }
23895
23896 let url = params.parse_with_url(&url);
23897
23898 loop {
23899 let token = match self
23900 .hub
23901 .auth
23902 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
23903 .await
23904 {
23905 Ok(token) => token,
23906 Err(e) => match dlg.token(e) {
23907 Ok(token) => token,
23908 Err(e) => {
23909 dlg.finished(false);
23910 return Err(common::Error::MissingToken(e));
23911 }
23912 },
23913 };
23914 let mut req_result = {
23915 let client = &self.hub.client;
23916 dlg.pre_request();
23917 let mut req_builder = hyper::Request::builder()
23918 .method(hyper::Method::DELETE)
23919 .uri(url.as_str())
23920 .header(USER_AGENT, self.hub._user_agent.clone());
23921
23922 if let Some(token) = token.as_ref() {
23923 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
23924 }
23925
23926 let request = req_builder
23927 .header(CONTENT_LENGTH, 0_u64)
23928 .body(common::to_body::<String>(None));
23929
23930 client.request(request.unwrap()).await
23931 };
23932
23933 match req_result {
23934 Err(err) => {
23935 if let common::Retry::After(d) = dlg.http_error(&err) {
23936 sleep(d).await;
23937 continue;
23938 }
23939 dlg.finished(false);
23940 return Err(common::Error::HttpError(err));
23941 }
23942 Ok(res) => {
23943 let (mut parts, body) = res.into_parts();
23944 let mut body = common::Body::new(body);
23945 if !parts.status.is_success() {
23946 let bytes = common::to_bytes(body).await.unwrap_or_default();
23947 let error = serde_json::from_str(&common::to_string(&bytes));
23948 let response = common::to_response(parts, bytes.into());
23949
23950 if let common::Retry::After(d) =
23951 dlg.http_failure(&response, error.as_ref().ok())
23952 {
23953 sleep(d).await;
23954 continue;
23955 }
23956
23957 dlg.finished(false);
23958
23959 return Err(match error {
23960 Ok(value) => common::Error::BadRequest(value),
23961 _ => common::Error::Failure(response),
23962 });
23963 }
23964 let response = {
23965 let bytes = common::to_bytes(body).await.unwrap_or_default();
23966 let encoded = common::to_string(&bytes);
23967 match serde_json::from_str(&encoded) {
23968 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
23969 Err(error) => {
23970 dlg.response_json_decode_error(&encoded, &error);
23971 return Err(common::Error::JsonDecodeError(
23972 encoded.to_string(),
23973 error,
23974 ));
23975 }
23976 }
23977 };
23978
23979 dlg.finished(true);
23980 return Ok(response);
23981 }
23982 }
23983 }
23984 }
23985
23986 /// Required. ID of the project that owns the trigger.
23987 ///
23988 /// Sets the *project id* path property to the given value.
23989 ///
23990 /// Even though the property as already been set when instantiating this call,
23991 /// we provide this method for API completeness.
23992 pub fn project_id(mut self, new_value: &str) -> ProjectTriggerDeleteCall<'a, C> {
23993 self._project_id = new_value.to_string();
23994 self
23995 }
23996 /// Required. ID of the `BuildTrigger` to delete.
23997 ///
23998 /// Sets the *trigger id* path property to the given value.
23999 ///
24000 /// Even though the property as already been set when instantiating this call,
24001 /// we provide this method for API completeness.
24002 pub fn trigger_id(mut self, new_value: &str) -> ProjectTriggerDeleteCall<'a, C> {
24003 self._trigger_id = new_value.to_string();
24004 self
24005 }
24006 /// The name of the `Trigger` to delete. Format: `projects/{project}/locations/{location}/triggers/{trigger}`
24007 ///
24008 /// Sets the *name* query property to the given value.
24009 pub fn name(mut self, new_value: &str) -> ProjectTriggerDeleteCall<'a, C> {
24010 self._name = Some(new_value.to_string());
24011 self
24012 }
24013 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24014 /// while executing the actual API request.
24015 ///
24016 /// ````text
24017 /// It should be used to handle progress information, and to implement a certain level of resilience.
24018 /// ````
24019 ///
24020 /// Sets the *delegate* property to the given value.
24021 pub fn delegate(
24022 mut self,
24023 new_value: &'a mut dyn common::Delegate,
24024 ) -> ProjectTriggerDeleteCall<'a, C> {
24025 self._delegate = Some(new_value);
24026 self
24027 }
24028
24029 /// Set any additional parameter of the query string used in the request.
24030 /// It should be used to set parameters which are not yet available through their own
24031 /// setters.
24032 ///
24033 /// Please note that this method must not be used to set any of the known parameters
24034 /// which have their own setter method. If done anyway, the request will fail.
24035 ///
24036 /// # Additional Parameters
24037 ///
24038 /// * *$.xgafv* (query-string) - V1 error format.
24039 /// * *access_token* (query-string) - OAuth access token.
24040 /// * *alt* (query-string) - Data format for response.
24041 /// * *callback* (query-string) - JSONP
24042 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24043 /// * *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.
24044 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24045 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24046 /// * *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.
24047 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
24048 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
24049 pub fn param<T>(mut self, name: T, value: T) -> ProjectTriggerDeleteCall<'a, C>
24050 where
24051 T: AsRef<str>,
24052 {
24053 self._additional_params
24054 .insert(name.as_ref().to_string(), value.as_ref().to_string());
24055 self
24056 }
24057
24058 /// Identifies the authorization scope for the method you are building.
24059 ///
24060 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24061 /// [`Scope::CloudPlatform`].
24062 ///
24063 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24064 /// tokens for more than one scope.
24065 ///
24066 /// Usually there is more than one suitable scope to authorize an operation, some of which may
24067 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24068 /// sufficient, a read-write scope will do as well.
24069 pub fn add_scope<St>(mut self, scope: St) -> ProjectTriggerDeleteCall<'a, C>
24070 where
24071 St: AsRef<str>,
24072 {
24073 self._scopes.insert(String::from(scope.as_ref()));
24074 self
24075 }
24076 /// Identifies the authorization scope(s) for the method you are building.
24077 ///
24078 /// See [`Self::add_scope()`] for details.
24079 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectTriggerDeleteCall<'a, C>
24080 where
24081 I: IntoIterator<Item = St>,
24082 St: AsRef<str>,
24083 {
24084 self._scopes
24085 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24086 self
24087 }
24088
24089 /// Removes all scopes, and no default scope will be used either.
24090 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24091 /// for details).
24092 pub fn clear_scopes(mut self) -> ProjectTriggerDeleteCall<'a, C> {
24093 self._scopes.clear();
24094 self
24095 }
24096}
24097
24098/// Returns information about a `BuildTrigger`.
24099///
24100/// A builder for the *triggers.get* method supported by a *project* resource.
24101/// It is not used directly, but through a [`ProjectMethods`] instance.
24102///
24103/// # Example
24104///
24105/// Instantiate a resource method builder
24106///
24107/// ```test_harness,no_run
24108/// # extern crate hyper;
24109/// # extern crate hyper_rustls;
24110/// # extern crate google_cloudbuild1 as cloudbuild1;
24111/// # async fn dox() {
24112/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24113///
24114/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
24115/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
24116/// # .with_native_roots()
24117/// # .unwrap()
24118/// # .https_only()
24119/// # .enable_http2()
24120/// # .build();
24121///
24122/// # let executor = hyper_util::rt::TokioExecutor::new();
24123/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
24124/// # secret,
24125/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24126/// # yup_oauth2::client::CustomHyperClientBuilder::from(
24127/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
24128/// # ),
24129/// # ).build().await.unwrap();
24130///
24131/// # let client = hyper_util::client::legacy::Client::builder(
24132/// # hyper_util::rt::TokioExecutor::new()
24133/// # )
24134/// # .build(
24135/// # hyper_rustls::HttpsConnectorBuilder::new()
24136/// # .with_native_roots()
24137/// # .unwrap()
24138/// # .https_or_http()
24139/// # .enable_http2()
24140/// # .build()
24141/// # );
24142/// # let mut hub = CloudBuild::new(client, auth);
24143/// // You can configure optional parameters by calling the respective setters at will, and
24144/// // execute the final call using `doit()`.
24145/// // Values shown here are possibly random and not representative !
24146/// let result = hub.projects().triggers_get("projectId", "triggerId")
24147/// .name("consetetur")
24148/// .doit().await;
24149/// # }
24150/// ```
24151pub struct ProjectTriggerGetCall<'a, C>
24152where
24153 C: 'a,
24154{
24155 hub: &'a CloudBuild<C>,
24156 _project_id: String,
24157 _trigger_id: String,
24158 _name: Option<String>,
24159 _delegate: Option<&'a mut dyn common::Delegate>,
24160 _additional_params: HashMap<String, String>,
24161 _scopes: BTreeSet<String>,
24162}
24163
24164impl<'a, C> common::CallBuilder for ProjectTriggerGetCall<'a, C> {}
24165
24166impl<'a, C> ProjectTriggerGetCall<'a, C>
24167where
24168 C: common::Connector,
24169{
24170 /// Perform the operation you have build so far.
24171 pub async fn doit(mut self) -> common::Result<(common::Response, BuildTrigger)> {
24172 use std::borrow::Cow;
24173 use std::io::{Read, Seek};
24174
24175 use common::{url::Params, ToParts};
24176 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24177
24178 let mut dd = common::DefaultDelegate;
24179 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24180 dlg.begin(common::MethodInfo {
24181 id: "cloudbuild.projects.triggers.get",
24182 http_method: hyper::Method::GET,
24183 });
24184
24185 for &field in ["alt", "projectId", "triggerId", "name"].iter() {
24186 if self._additional_params.contains_key(field) {
24187 dlg.finished(false);
24188 return Err(common::Error::FieldClash(field));
24189 }
24190 }
24191
24192 let mut params = Params::with_capacity(5 + self._additional_params.len());
24193 params.push("projectId", self._project_id);
24194 params.push("triggerId", self._trigger_id);
24195 if let Some(value) = self._name.as_ref() {
24196 params.push("name", value);
24197 }
24198
24199 params.extend(self._additional_params.iter());
24200
24201 params.push("alt", "json");
24202 let mut url = self.hub._base_url.clone() + "v1/projects/{projectId}/triggers/{triggerId}";
24203 if self._scopes.is_empty() {
24204 self._scopes
24205 .insert(Scope::CloudPlatform.as_ref().to_string());
24206 }
24207
24208 #[allow(clippy::single_element_loop)]
24209 for &(find_this, param_name) in
24210 [("{projectId}", "projectId"), ("{triggerId}", "triggerId")].iter()
24211 {
24212 url = params.uri_replacement(url, param_name, find_this, false);
24213 }
24214 {
24215 let to_remove = ["triggerId", "projectId"];
24216 params.remove_params(&to_remove);
24217 }
24218
24219 let url = params.parse_with_url(&url);
24220
24221 loop {
24222 let token = match self
24223 .hub
24224 .auth
24225 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24226 .await
24227 {
24228 Ok(token) => token,
24229 Err(e) => match dlg.token(e) {
24230 Ok(token) => token,
24231 Err(e) => {
24232 dlg.finished(false);
24233 return Err(common::Error::MissingToken(e));
24234 }
24235 },
24236 };
24237 let mut req_result = {
24238 let client = &self.hub.client;
24239 dlg.pre_request();
24240 let mut req_builder = hyper::Request::builder()
24241 .method(hyper::Method::GET)
24242 .uri(url.as_str())
24243 .header(USER_AGENT, self.hub._user_agent.clone());
24244
24245 if let Some(token) = token.as_ref() {
24246 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24247 }
24248
24249 let request = req_builder
24250 .header(CONTENT_LENGTH, 0_u64)
24251 .body(common::to_body::<String>(None));
24252
24253 client.request(request.unwrap()).await
24254 };
24255
24256 match req_result {
24257 Err(err) => {
24258 if let common::Retry::After(d) = dlg.http_error(&err) {
24259 sleep(d).await;
24260 continue;
24261 }
24262 dlg.finished(false);
24263 return Err(common::Error::HttpError(err));
24264 }
24265 Ok(res) => {
24266 let (mut parts, body) = res.into_parts();
24267 let mut body = common::Body::new(body);
24268 if !parts.status.is_success() {
24269 let bytes = common::to_bytes(body).await.unwrap_or_default();
24270 let error = serde_json::from_str(&common::to_string(&bytes));
24271 let response = common::to_response(parts, bytes.into());
24272
24273 if let common::Retry::After(d) =
24274 dlg.http_failure(&response, error.as_ref().ok())
24275 {
24276 sleep(d).await;
24277 continue;
24278 }
24279
24280 dlg.finished(false);
24281
24282 return Err(match error {
24283 Ok(value) => common::Error::BadRequest(value),
24284 _ => common::Error::Failure(response),
24285 });
24286 }
24287 let response = {
24288 let bytes = common::to_bytes(body).await.unwrap_or_default();
24289 let encoded = common::to_string(&bytes);
24290 match serde_json::from_str(&encoded) {
24291 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24292 Err(error) => {
24293 dlg.response_json_decode_error(&encoded, &error);
24294 return Err(common::Error::JsonDecodeError(
24295 encoded.to_string(),
24296 error,
24297 ));
24298 }
24299 }
24300 };
24301
24302 dlg.finished(true);
24303 return Ok(response);
24304 }
24305 }
24306 }
24307 }
24308
24309 /// Required. ID of the project that owns the trigger.
24310 ///
24311 /// Sets the *project id* path property to the given value.
24312 ///
24313 /// Even though the property as already been set when instantiating this call,
24314 /// we provide this method for API completeness.
24315 pub fn project_id(mut self, new_value: &str) -> ProjectTriggerGetCall<'a, C> {
24316 self._project_id = new_value.to_string();
24317 self
24318 }
24319 /// Required. Identifier (`id` or `name`) of the `BuildTrigger` to get.
24320 ///
24321 /// Sets the *trigger id* path property to the given value.
24322 ///
24323 /// Even though the property as already been set when instantiating this call,
24324 /// we provide this method for API completeness.
24325 pub fn trigger_id(mut self, new_value: &str) -> ProjectTriggerGetCall<'a, C> {
24326 self._trigger_id = new_value.to_string();
24327 self
24328 }
24329 /// The name of the `Trigger` to retrieve. Format: `projects/{project}/locations/{location}/triggers/{trigger}`
24330 ///
24331 /// Sets the *name* query property to the given value.
24332 pub fn name(mut self, new_value: &str) -> ProjectTriggerGetCall<'a, C> {
24333 self._name = Some(new_value.to_string());
24334 self
24335 }
24336 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24337 /// while executing the actual API request.
24338 ///
24339 /// ````text
24340 /// It should be used to handle progress information, and to implement a certain level of resilience.
24341 /// ````
24342 ///
24343 /// Sets the *delegate* property to the given value.
24344 pub fn delegate(
24345 mut self,
24346 new_value: &'a mut dyn common::Delegate,
24347 ) -> ProjectTriggerGetCall<'a, C> {
24348 self._delegate = Some(new_value);
24349 self
24350 }
24351
24352 /// Set any additional parameter of the query string used in the request.
24353 /// It should be used to set parameters which are not yet available through their own
24354 /// setters.
24355 ///
24356 /// Please note that this method must not be used to set any of the known parameters
24357 /// which have their own setter method. If done anyway, the request will fail.
24358 ///
24359 /// # Additional Parameters
24360 ///
24361 /// * *$.xgafv* (query-string) - V1 error format.
24362 /// * *access_token* (query-string) - OAuth access token.
24363 /// * *alt* (query-string) - Data format for response.
24364 /// * *callback* (query-string) - JSONP
24365 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24366 /// * *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.
24367 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24368 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24369 /// * *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.
24370 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
24371 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
24372 pub fn param<T>(mut self, name: T, value: T) -> ProjectTriggerGetCall<'a, C>
24373 where
24374 T: AsRef<str>,
24375 {
24376 self._additional_params
24377 .insert(name.as_ref().to_string(), value.as_ref().to_string());
24378 self
24379 }
24380
24381 /// Identifies the authorization scope for the method you are building.
24382 ///
24383 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24384 /// [`Scope::CloudPlatform`].
24385 ///
24386 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24387 /// tokens for more than one scope.
24388 ///
24389 /// Usually there is more than one suitable scope to authorize an operation, some of which may
24390 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24391 /// sufficient, a read-write scope will do as well.
24392 pub fn add_scope<St>(mut self, scope: St) -> ProjectTriggerGetCall<'a, C>
24393 where
24394 St: AsRef<str>,
24395 {
24396 self._scopes.insert(String::from(scope.as_ref()));
24397 self
24398 }
24399 /// Identifies the authorization scope(s) for the method you are building.
24400 ///
24401 /// See [`Self::add_scope()`] for details.
24402 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectTriggerGetCall<'a, C>
24403 where
24404 I: IntoIterator<Item = St>,
24405 St: AsRef<str>,
24406 {
24407 self._scopes
24408 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24409 self
24410 }
24411
24412 /// Removes all scopes, and no default scope will be used either.
24413 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24414 /// for details).
24415 pub fn clear_scopes(mut self) -> ProjectTriggerGetCall<'a, C> {
24416 self._scopes.clear();
24417 self
24418 }
24419}
24420
24421/// Lists existing `BuildTrigger`s.
24422///
24423/// A builder for the *triggers.list* method supported by a *project* resource.
24424/// It is not used directly, but through a [`ProjectMethods`] instance.
24425///
24426/// # Example
24427///
24428/// Instantiate a resource method builder
24429///
24430/// ```test_harness,no_run
24431/// # extern crate hyper;
24432/// # extern crate hyper_rustls;
24433/// # extern crate google_cloudbuild1 as cloudbuild1;
24434/// # async fn dox() {
24435/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24436///
24437/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
24438/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
24439/// # .with_native_roots()
24440/// # .unwrap()
24441/// # .https_only()
24442/// # .enable_http2()
24443/// # .build();
24444///
24445/// # let executor = hyper_util::rt::TokioExecutor::new();
24446/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
24447/// # secret,
24448/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24449/// # yup_oauth2::client::CustomHyperClientBuilder::from(
24450/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
24451/// # ),
24452/// # ).build().await.unwrap();
24453///
24454/// # let client = hyper_util::client::legacy::Client::builder(
24455/// # hyper_util::rt::TokioExecutor::new()
24456/// # )
24457/// # .build(
24458/// # hyper_rustls::HttpsConnectorBuilder::new()
24459/// # .with_native_roots()
24460/// # .unwrap()
24461/// # .https_or_http()
24462/// # .enable_http2()
24463/// # .build()
24464/// # );
24465/// # let mut hub = CloudBuild::new(client, auth);
24466/// // You can configure optional parameters by calling the respective setters at will, and
24467/// // execute the final call using `doit()`.
24468/// // Values shown here are possibly random and not representative !
24469/// let result = hub.projects().triggers_list("projectId")
24470/// .parent("est")
24471/// .page_token("aliquyam")
24472/// .page_size(-94)
24473/// .doit().await;
24474/// # }
24475/// ```
24476pub struct ProjectTriggerListCall<'a, C>
24477where
24478 C: 'a,
24479{
24480 hub: &'a CloudBuild<C>,
24481 _project_id: String,
24482 _parent: Option<String>,
24483 _page_token: Option<String>,
24484 _page_size: Option<i32>,
24485 _delegate: Option<&'a mut dyn common::Delegate>,
24486 _additional_params: HashMap<String, String>,
24487 _scopes: BTreeSet<String>,
24488}
24489
24490impl<'a, C> common::CallBuilder for ProjectTriggerListCall<'a, C> {}
24491
24492impl<'a, C> ProjectTriggerListCall<'a, C>
24493where
24494 C: common::Connector,
24495{
24496 /// Perform the operation you have build so far.
24497 pub async fn doit(mut self) -> common::Result<(common::Response, ListBuildTriggersResponse)> {
24498 use std::borrow::Cow;
24499 use std::io::{Read, Seek};
24500
24501 use common::{url::Params, ToParts};
24502 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24503
24504 let mut dd = common::DefaultDelegate;
24505 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24506 dlg.begin(common::MethodInfo {
24507 id: "cloudbuild.projects.triggers.list",
24508 http_method: hyper::Method::GET,
24509 });
24510
24511 for &field in ["alt", "projectId", "parent", "pageToken", "pageSize"].iter() {
24512 if self._additional_params.contains_key(field) {
24513 dlg.finished(false);
24514 return Err(common::Error::FieldClash(field));
24515 }
24516 }
24517
24518 let mut params = Params::with_capacity(6 + self._additional_params.len());
24519 params.push("projectId", self._project_id);
24520 if let Some(value) = self._parent.as_ref() {
24521 params.push("parent", value);
24522 }
24523 if let Some(value) = self._page_token.as_ref() {
24524 params.push("pageToken", value);
24525 }
24526 if let Some(value) = self._page_size.as_ref() {
24527 params.push("pageSize", value.to_string());
24528 }
24529
24530 params.extend(self._additional_params.iter());
24531
24532 params.push("alt", "json");
24533 let mut url = self.hub._base_url.clone() + "v1/projects/{projectId}/triggers";
24534 if self._scopes.is_empty() {
24535 self._scopes
24536 .insert(Scope::CloudPlatform.as_ref().to_string());
24537 }
24538
24539 #[allow(clippy::single_element_loop)]
24540 for &(find_this, param_name) in [("{projectId}", "projectId")].iter() {
24541 url = params.uri_replacement(url, param_name, find_this, false);
24542 }
24543 {
24544 let to_remove = ["projectId"];
24545 params.remove_params(&to_remove);
24546 }
24547
24548 let url = params.parse_with_url(&url);
24549
24550 loop {
24551 let token = match self
24552 .hub
24553 .auth
24554 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24555 .await
24556 {
24557 Ok(token) => token,
24558 Err(e) => match dlg.token(e) {
24559 Ok(token) => token,
24560 Err(e) => {
24561 dlg.finished(false);
24562 return Err(common::Error::MissingToken(e));
24563 }
24564 },
24565 };
24566 let mut req_result = {
24567 let client = &self.hub.client;
24568 dlg.pre_request();
24569 let mut req_builder = hyper::Request::builder()
24570 .method(hyper::Method::GET)
24571 .uri(url.as_str())
24572 .header(USER_AGENT, self.hub._user_agent.clone());
24573
24574 if let Some(token) = token.as_ref() {
24575 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24576 }
24577
24578 let request = req_builder
24579 .header(CONTENT_LENGTH, 0_u64)
24580 .body(common::to_body::<String>(None));
24581
24582 client.request(request.unwrap()).await
24583 };
24584
24585 match req_result {
24586 Err(err) => {
24587 if let common::Retry::After(d) = dlg.http_error(&err) {
24588 sleep(d).await;
24589 continue;
24590 }
24591 dlg.finished(false);
24592 return Err(common::Error::HttpError(err));
24593 }
24594 Ok(res) => {
24595 let (mut parts, body) = res.into_parts();
24596 let mut body = common::Body::new(body);
24597 if !parts.status.is_success() {
24598 let bytes = common::to_bytes(body).await.unwrap_or_default();
24599 let error = serde_json::from_str(&common::to_string(&bytes));
24600 let response = common::to_response(parts, bytes.into());
24601
24602 if let common::Retry::After(d) =
24603 dlg.http_failure(&response, error.as_ref().ok())
24604 {
24605 sleep(d).await;
24606 continue;
24607 }
24608
24609 dlg.finished(false);
24610
24611 return Err(match error {
24612 Ok(value) => common::Error::BadRequest(value),
24613 _ => common::Error::Failure(response),
24614 });
24615 }
24616 let response = {
24617 let bytes = common::to_bytes(body).await.unwrap_or_default();
24618 let encoded = common::to_string(&bytes);
24619 match serde_json::from_str(&encoded) {
24620 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24621 Err(error) => {
24622 dlg.response_json_decode_error(&encoded, &error);
24623 return Err(common::Error::JsonDecodeError(
24624 encoded.to_string(),
24625 error,
24626 ));
24627 }
24628 }
24629 };
24630
24631 dlg.finished(true);
24632 return Ok(response);
24633 }
24634 }
24635 }
24636 }
24637
24638 /// Required. ID of the project for which to list BuildTriggers.
24639 ///
24640 /// Sets the *project id* path property to the given value.
24641 ///
24642 /// Even though the property as already been set when instantiating this call,
24643 /// we provide this method for API completeness.
24644 pub fn project_id(mut self, new_value: &str) -> ProjectTriggerListCall<'a, C> {
24645 self._project_id = new_value.to_string();
24646 self
24647 }
24648 /// The parent of the collection of `Triggers`. Format: `projects/{project}/locations/{location}`
24649 ///
24650 /// Sets the *parent* query property to the given value.
24651 pub fn parent(mut self, new_value: &str) -> ProjectTriggerListCall<'a, C> {
24652 self._parent = Some(new_value.to_string());
24653 self
24654 }
24655 /// Token to provide to skip to a particular spot in the list.
24656 ///
24657 /// Sets the *page token* query property to the given value.
24658 pub fn page_token(mut self, new_value: &str) -> ProjectTriggerListCall<'a, C> {
24659 self._page_token = Some(new_value.to_string());
24660 self
24661 }
24662 /// Number of results to return in the list.
24663 ///
24664 /// Sets the *page size* query property to the given value.
24665 pub fn page_size(mut self, new_value: i32) -> ProjectTriggerListCall<'a, C> {
24666 self._page_size = Some(new_value);
24667 self
24668 }
24669 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
24670 /// while executing the actual API request.
24671 ///
24672 /// ````text
24673 /// It should be used to handle progress information, and to implement a certain level of resilience.
24674 /// ````
24675 ///
24676 /// Sets the *delegate* property to the given value.
24677 pub fn delegate(
24678 mut self,
24679 new_value: &'a mut dyn common::Delegate,
24680 ) -> ProjectTriggerListCall<'a, C> {
24681 self._delegate = Some(new_value);
24682 self
24683 }
24684
24685 /// Set any additional parameter of the query string used in the request.
24686 /// It should be used to set parameters which are not yet available through their own
24687 /// setters.
24688 ///
24689 /// Please note that this method must not be used to set any of the known parameters
24690 /// which have their own setter method. If done anyway, the request will fail.
24691 ///
24692 /// # Additional Parameters
24693 ///
24694 /// * *$.xgafv* (query-string) - V1 error format.
24695 /// * *access_token* (query-string) - OAuth access token.
24696 /// * *alt* (query-string) - Data format for response.
24697 /// * *callback* (query-string) - JSONP
24698 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
24699 /// * *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.
24700 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
24701 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
24702 /// * *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.
24703 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
24704 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
24705 pub fn param<T>(mut self, name: T, value: T) -> ProjectTriggerListCall<'a, C>
24706 where
24707 T: AsRef<str>,
24708 {
24709 self._additional_params
24710 .insert(name.as_ref().to_string(), value.as_ref().to_string());
24711 self
24712 }
24713
24714 /// Identifies the authorization scope for the method you are building.
24715 ///
24716 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
24717 /// [`Scope::CloudPlatform`].
24718 ///
24719 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
24720 /// tokens for more than one scope.
24721 ///
24722 /// Usually there is more than one suitable scope to authorize an operation, some of which may
24723 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
24724 /// sufficient, a read-write scope will do as well.
24725 pub fn add_scope<St>(mut self, scope: St) -> ProjectTriggerListCall<'a, C>
24726 where
24727 St: AsRef<str>,
24728 {
24729 self._scopes.insert(String::from(scope.as_ref()));
24730 self
24731 }
24732 /// Identifies the authorization scope(s) for the method you are building.
24733 ///
24734 /// See [`Self::add_scope()`] for details.
24735 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectTriggerListCall<'a, C>
24736 where
24737 I: IntoIterator<Item = St>,
24738 St: AsRef<str>,
24739 {
24740 self._scopes
24741 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
24742 self
24743 }
24744
24745 /// Removes all scopes, and no default scope will be used either.
24746 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
24747 /// for details).
24748 pub fn clear_scopes(mut self) -> ProjectTriggerListCall<'a, C> {
24749 self._scopes.clear();
24750 self
24751 }
24752}
24753
24754/// Updates a `BuildTrigger` by its project ID and trigger ID.
24755///
24756/// A builder for the *triggers.patch* method supported by a *project* resource.
24757/// It is not used directly, but through a [`ProjectMethods`] instance.
24758///
24759/// # Example
24760///
24761/// Instantiate a resource method builder
24762///
24763/// ```test_harness,no_run
24764/// # extern crate hyper;
24765/// # extern crate hyper_rustls;
24766/// # extern crate google_cloudbuild1 as cloudbuild1;
24767/// use cloudbuild1::api::BuildTrigger;
24768/// # async fn dox() {
24769/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
24770///
24771/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
24772/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
24773/// # .with_native_roots()
24774/// # .unwrap()
24775/// # .https_only()
24776/// # .enable_http2()
24777/// # .build();
24778///
24779/// # let executor = hyper_util::rt::TokioExecutor::new();
24780/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
24781/// # secret,
24782/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
24783/// # yup_oauth2::client::CustomHyperClientBuilder::from(
24784/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
24785/// # ),
24786/// # ).build().await.unwrap();
24787///
24788/// # let client = hyper_util::client::legacy::Client::builder(
24789/// # hyper_util::rt::TokioExecutor::new()
24790/// # )
24791/// # .build(
24792/// # hyper_rustls::HttpsConnectorBuilder::new()
24793/// # .with_native_roots()
24794/// # .unwrap()
24795/// # .https_or_http()
24796/// # .enable_http2()
24797/// # .build()
24798/// # );
24799/// # let mut hub = CloudBuild::new(client, auth);
24800/// // As the method needs a request, you would usually fill it with the desired information
24801/// // into the respective structure. Some of the parts shown here might not be applicable !
24802/// // Values shown here are possibly random and not representative !
24803/// let mut req = BuildTrigger::default();
24804///
24805/// // You can configure optional parameters by calling the respective setters at will, and
24806/// // execute the final call using `doit()`.
24807/// // Values shown here are possibly random and not representative !
24808/// let result = hub.projects().triggers_patch(req, "projectId", "triggerId")
24809/// .update_mask(FieldMask::new::<&str>(&[]))
24810/// .doit().await;
24811/// # }
24812/// ```
24813pub struct ProjectTriggerPatchCall<'a, C>
24814where
24815 C: 'a,
24816{
24817 hub: &'a CloudBuild<C>,
24818 _request: BuildTrigger,
24819 _project_id: String,
24820 _trigger_id: String,
24821 _update_mask: Option<common::FieldMask>,
24822 _delegate: Option<&'a mut dyn common::Delegate>,
24823 _additional_params: HashMap<String, String>,
24824 _scopes: BTreeSet<String>,
24825}
24826
24827impl<'a, C> common::CallBuilder for ProjectTriggerPatchCall<'a, C> {}
24828
24829impl<'a, C> ProjectTriggerPatchCall<'a, C>
24830where
24831 C: common::Connector,
24832{
24833 /// Perform the operation you have build so far.
24834 pub async fn doit(mut self) -> common::Result<(common::Response, BuildTrigger)> {
24835 use std::borrow::Cow;
24836 use std::io::{Read, Seek};
24837
24838 use common::{url::Params, ToParts};
24839 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
24840
24841 let mut dd = common::DefaultDelegate;
24842 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
24843 dlg.begin(common::MethodInfo {
24844 id: "cloudbuild.projects.triggers.patch",
24845 http_method: hyper::Method::PATCH,
24846 });
24847
24848 for &field in ["alt", "projectId", "triggerId", "updateMask"].iter() {
24849 if self._additional_params.contains_key(field) {
24850 dlg.finished(false);
24851 return Err(common::Error::FieldClash(field));
24852 }
24853 }
24854
24855 let mut params = Params::with_capacity(6 + self._additional_params.len());
24856 params.push("projectId", self._project_id);
24857 params.push("triggerId", self._trigger_id);
24858 if let Some(value) = self._update_mask.as_ref() {
24859 params.push("updateMask", value.to_string());
24860 }
24861
24862 params.extend(self._additional_params.iter());
24863
24864 params.push("alt", "json");
24865 let mut url = self.hub._base_url.clone() + "v1/projects/{projectId}/triggers/{triggerId}";
24866 if self._scopes.is_empty() {
24867 self._scopes
24868 .insert(Scope::CloudPlatform.as_ref().to_string());
24869 }
24870
24871 #[allow(clippy::single_element_loop)]
24872 for &(find_this, param_name) in
24873 [("{projectId}", "projectId"), ("{triggerId}", "triggerId")].iter()
24874 {
24875 url = params.uri_replacement(url, param_name, find_this, false);
24876 }
24877 {
24878 let to_remove = ["triggerId", "projectId"];
24879 params.remove_params(&to_remove);
24880 }
24881
24882 let url = params.parse_with_url(&url);
24883
24884 let mut json_mime_type = mime::APPLICATION_JSON;
24885 let mut request_value_reader = {
24886 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
24887 common::remove_json_null_values(&mut value);
24888 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
24889 serde_json::to_writer(&mut dst, &value).unwrap();
24890 dst
24891 };
24892 let request_size = request_value_reader
24893 .seek(std::io::SeekFrom::End(0))
24894 .unwrap();
24895 request_value_reader
24896 .seek(std::io::SeekFrom::Start(0))
24897 .unwrap();
24898
24899 loop {
24900 let token = match self
24901 .hub
24902 .auth
24903 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
24904 .await
24905 {
24906 Ok(token) => token,
24907 Err(e) => match dlg.token(e) {
24908 Ok(token) => token,
24909 Err(e) => {
24910 dlg.finished(false);
24911 return Err(common::Error::MissingToken(e));
24912 }
24913 },
24914 };
24915 request_value_reader
24916 .seek(std::io::SeekFrom::Start(0))
24917 .unwrap();
24918 let mut req_result = {
24919 let client = &self.hub.client;
24920 dlg.pre_request();
24921 let mut req_builder = hyper::Request::builder()
24922 .method(hyper::Method::PATCH)
24923 .uri(url.as_str())
24924 .header(USER_AGENT, self.hub._user_agent.clone());
24925
24926 if let Some(token) = token.as_ref() {
24927 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
24928 }
24929
24930 let request = req_builder
24931 .header(CONTENT_TYPE, json_mime_type.to_string())
24932 .header(CONTENT_LENGTH, request_size as u64)
24933 .body(common::to_body(
24934 request_value_reader.get_ref().clone().into(),
24935 ));
24936
24937 client.request(request.unwrap()).await
24938 };
24939
24940 match req_result {
24941 Err(err) => {
24942 if let common::Retry::After(d) = dlg.http_error(&err) {
24943 sleep(d).await;
24944 continue;
24945 }
24946 dlg.finished(false);
24947 return Err(common::Error::HttpError(err));
24948 }
24949 Ok(res) => {
24950 let (mut parts, body) = res.into_parts();
24951 let mut body = common::Body::new(body);
24952 if !parts.status.is_success() {
24953 let bytes = common::to_bytes(body).await.unwrap_or_default();
24954 let error = serde_json::from_str(&common::to_string(&bytes));
24955 let response = common::to_response(parts, bytes.into());
24956
24957 if let common::Retry::After(d) =
24958 dlg.http_failure(&response, error.as_ref().ok())
24959 {
24960 sleep(d).await;
24961 continue;
24962 }
24963
24964 dlg.finished(false);
24965
24966 return Err(match error {
24967 Ok(value) => common::Error::BadRequest(value),
24968 _ => common::Error::Failure(response),
24969 });
24970 }
24971 let response = {
24972 let bytes = common::to_bytes(body).await.unwrap_or_default();
24973 let encoded = common::to_string(&bytes);
24974 match serde_json::from_str(&encoded) {
24975 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
24976 Err(error) => {
24977 dlg.response_json_decode_error(&encoded, &error);
24978 return Err(common::Error::JsonDecodeError(
24979 encoded.to_string(),
24980 error,
24981 ));
24982 }
24983 }
24984 };
24985
24986 dlg.finished(true);
24987 return Ok(response);
24988 }
24989 }
24990 }
24991 }
24992
24993 ///
24994 /// Sets the *request* property to the given value.
24995 ///
24996 /// Even though the property as already been set when instantiating this call,
24997 /// we provide this method for API completeness.
24998 pub fn request(mut self, new_value: BuildTrigger) -> ProjectTriggerPatchCall<'a, C> {
24999 self._request = new_value;
25000 self
25001 }
25002 /// Required. ID of the project that owns the trigger.
25003 ///
25004 /// Sets the *project id* path property to the given value.
25005 ///
25006 /// Even though the property as already been set when instantiating this call,
25007 /// we provide this method for API completeness.
25008 pub fn project_id(mut self, new_value: &str) -> ProjectTriggerPatchCall<'a, C> {
25009 self._project_id = new_value.to_string();
25010 self
25011 }
25012 /// Required. ID of the `BuildTrigger` to update.
25013 ///
25014 /// Sets the *trigger id* path property to the given value.
25015 ///
25016 /// Even though the property as already been set when instantiating this call,
25017 /// we provide this method for API completeness.
25018 pub fn trigger_id(mut self, new_value: &str) -> ProjectTriggerPatchCall<'a, C> {
25019 self._trigger_id = new_value.to_string();
25020 self
25021 }
25022 /// 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.
25023 ///
25024 /// Sets the *update mask* query property to the given value.
25025 pub fn update_mask(mut self, new_value: common::FieldMask) -> ProjectTriggerPatchCall<'a, C> {
25026 self._update_mask = Some(new_value);
25027 self
25028 }
25029 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25030 /// while executing the actual API request.
25031 ///
25032 /// ````text
25033 /// It should be used to handle progress information, and to implement a certain level of resilience.
25034 /// ````
25035 ///
25036 /// Sets the *delegate* property to the given value.
25037 pub fn delegate(
25038 mut self,
25039 new_value: &'a mut dyn common::Delegate,
25040 ) -> ProjectTriggerPatchCall<'a, C> {
25041 self._delegate = Some(new_value);
25042 self
25043 }
25044
25045 /// Set any additional parameter of the query string used in the request.
25046 /// It should be used to set parameters which are not yet available through their own
25047 /// setters.
25048 ///
25049 /// Please note that this method must not be used to set any of the known parameters
25050 /// which have their own setter method. If done anyway, the request will fail.
25051 ///
25052 /// # Additional Parameters
25053 ///
25054 /// * *$.xgafv* (query-string) - V1 error format.
25055 /// * *access_token* (query-string) - OAuth access token.
25056 /// * *alt* (query-string) - Data format for response.
25057 /// * *callback* (query-string) - JSONP
25058 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25059 /// * *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.
25060 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25061 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25062 /// * *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.
25063 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
25064 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
25065 pub fn param<T>(mut self, name: T, value: T) -> ProjectTriggerPatchCall<'a, C>
25066 where
25067 T: AsRef<str>,
25068 {
25069 self._additional_params
25070 .insert(name.as_ref().to_string(), value.as_ref().to_string());
25071 self
25072 }
25073
25074 /// Identifies the authorization scope for the method you are building.
25075 ///
25076 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
25077 /// [`Scope::CloudPlatform`].
25078 ///
25079 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25080 /// tokens for more than one scope.
25081 ///
25082 /// Usually there is more than one suitable scope to authorize an operation, some of which may
25083 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25084 /// sufficient, a read-write scope will do as well.
25085 pub fn add_scope<St>(mut self, scope: St) -> ProjectTriggerPatchCall<'a, C>
25086 where
25087 St: AsRef<str>,
25088 {
25089 self._scopes.insert(String::from(scope.as_ref()));
25090 self
25091 }
25092 /// Identifies the authorization scope(s) for the method you are building.
25093 ///
25094 /// See [`Self::add_scope()`] for details.
25095 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectTriggerPatchCall<'a, C>
25096 where
25097 I: IntoIterator<Item = St>,
25098 St: AsRef<str>,
25099 {
25100 self._scopes
25101 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
25102 self
25103 }
25104
25105 /// Removes all scopes, and no default scope will be used either.
25106 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
25107 /// for details).
25108 pub fn clear_scopes(mut self) -> ProjectTriggerPatchCall<'a, C> {
25109 self._scopes.clear();
25110 self
25111 }
25112}
25113
25114/// 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.
25115///
25116/// A builder for the *triggers.run* method supported by a *project* resource.
25117/// It is not used directly, but through a [`ProjectMethods`] instance.
25118///
25119/// # Example
25120///
25121/// Instantiate a resource method builder
25122///
25123/// ```test_harness,no_run
25124/// # extern crate hyper;
25125/// # extern crate hyper_rustls;
25126/// # extern crate google_cloudbuild1 as cloudbuild1;
25127/// use cloudbuild1::api::RepoSource;
25128/// # async fn dox() {
25129/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
25130///
25131/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
25132/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
25133/// # .with_native_roots()
25134/// # .unwrap()
25135/// # .https_only()
25136/// # .enable_http2()
25137/// # .build();
25138///
25139/// # let executor = hyper_util::rt::TokioExecutor::new();
25140/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
25141/// # secret,
25142/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
25143/// # yup_oauth2::client::CustomHyperClientBuilder::from(
25144/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
25145/// # ),
25146/// # ).build().await.unwrap();
25147///
25148/// # let client = hyper_util::client::legacy::Client::builder(
25149/// # hyper_util::rt::TokioExecutor::new()
25150/// # )
25151/// # .build(
25152/// # hyper_rustls::HttpsConnectorBuilder::new()
25153/// # .with_native_roots()
25154/// # .unwrap()
25155/// # .https_or_http()
25156/// # .enable_http2()
25157/// # .build()
25158/// # );
25159/// # let mut hub = CloudBuild::new(client, auth);
25160/// // As the method needs a request, you would usually fill it with the desired information
25161/// // into the respective structure. Some of the parts shown here might not be applicable !
25162/// // Values shown here are possibly random and not representative !
25163/// let mut req = RepoSource::default();
25164///
25165/// // You can configure optional parameters by calling the respective setters at will, and
25166/// // execute the final call using `doit()`.
25167/// // Values shown here are possibly random and not representative !
25168/// let result = hub.projects().triggers_run(req, "projectId", "triggerId")
25169/// .name("sed")
25170/// .doit().await;
25171/// # }
25172/// ```
25173pub struct ProjectTriggerRunCall<'a, C>
25174where
25175 C: 'a,
25176{
25177 hub: &'a CloudBuild<C>,
25178 _request: RepoSource,
25179 _project_id: String,
25180 _trigger_id: String,
25181 _name: Option<String>,
25182 _delegate: Option<&'a mut dyn common::Delegate>,
25183 _additional_params: HashMap<String, String>,
25184 _scopes: BTreeSet<String>,
25185}
25186
25187impl<'a, C> common::CallBuilder for ProjectTriggerRunCall<'a, C> {}
25188
25189impl<'a, C> ProjectTriggerRunCall<'a, C>
25190where
25191 C: common::Connector,
25192{
25193 /// Perform the operation you have build so far.
25194 pub async fn doit(mut self) -> common::Result<(common::Response, Operation)> {
25195 use std::borrow::Cow;
25196 use std::io::{Read, Seek};
25197
25198 use common::{url::Params, ToParts};
25199 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
25200
25201 let mut dd = common::DefaultDelegate;
25202 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
25203 dlg.begin(common::MethodInfo {
25204 id: "cloudbuild.projects.triggers.run",
25205 http_method: hyper::Method::POST,
25206 });
25207
25208 for &field in ["alt", "projectId", "triggerId", "name"].iter() {
25209 if self._additional_params.contains_key(field) {
25210 dlg.finished(false);
25211 return Err(common::Error::FieldClash(field));
25212 }
25213 }
25214
25215 let mut params = Params::with_capacity(6 + self._additional_params.len());
25216 params.push("projectId", self._project_id);
25217 params.push("triggerId", self._trigger_id);
25218 if let Some(value) = self._name.as_ref() {
25219 params.push("name", value);
25220 }
25221
25222 params.extend(self._additional_params.iter());
25223
25224 params.push("alt", "json");
25225 let mut url =
25226 self.hub._base_url.clone() + "v1/projects/{projectId}/triggers/{triggerId}:run";
25227 if self._scopes.is_empty() {
25228 self._scopes
25229 .insert(Scope::CloudPlatform.as_ref().to_string());
25230 }
25231
25232 #[allow(clippy::single_element_loop)]
25233 for &(find_this, param_name) in
25234 [("{projectId}", "projectId"), ("{triggerId}", "triggerId")].iter()
25235 {
25236 url = params.uri_replacement(url, param_name, find_this, false);
25237 }
25238 {
25239 let to_remove = ["triggerId", "projectId"];
25240 params.remove_params(&to_remove);
25241 }
25242
25243 let url = params.parse_with_url(&url);
25244
25245 let mut json_mime_type = mime::APPLICATION_JSON;
25246 let mut request_value_reader = {
25247 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
25248 common::remove_json_null_values(&mut value);
25249 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
25250 serde_json::to_writer(&mut dst, &value).unwrap();
25251 dst
25252 };
25253 let request_size = request_value_reader
25254 .seek(std::io::SeekFrom::End(0))
25255 .unwrap();
25256 request_value_reader
25257 .seek(std::io::SeekFrom::Start(0))
25258 .unwrap();
25259
25260 loop {
25261 let token = match self
25262 .hub
25263 .auth
25264 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
25265 .await
25266 {
25267 Ok(token) => token,
25268 Err(e) => match dlg.token(e) {
25269 Ok(token) => token,
25270 Err(e) => {
25271 dlg.finished(false);
25272 return Err(common::Error::MissingToken(e));
25273 }
25274 },
25275 };
25276 request_value_reader
25277 .seek(std::io::SeekFrom::Start(0))
25278 .unwrap();
25279 let mut req_result = {
25280 let client = &self.hub.client;
25281 dlg.pre_request();
25282 let mut req_builder = hyper::Request::builder()
25283 .method(hyper::Method::POST)
25284 .uri(url.as_str())
25285 .header(USER_AGENT, self.hub._user_agent.clone());
25286
25287 if let Some(token) = token.as_ref() {
25288 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
25289 }
25290
25291 let request = req_builder
25292 .header(CONTENT_TYPE, json_mime_type.to_string())
25293 .header(CONTENT_LENGTH, request_size as u64)
25294 .body(common::to_body(
25295 request_value_reader.get_ref().clone().into(),
25296 ));
25297
25298 client.request(request.unwrap()).await
25299 };
25300
25301 match req_result {
25302 Err(err) => {
25303 if let common::Retry::After(d) = dlg.http_error(&err) {
25304 sleep(d).await;
25305 continue;
25306 }
25307 dlg.finished(false);
25308 return Err(common::Error::HttpError(err));
25309 }
25310 Ok(res) => {
25311 let (mut parts, body) = res.into_parts();
25312 let mut body = common::Body::new(body);
25313 if !parts.status.is_success() {
25314 let bytes = common::to_bytes(body).await.unwrap_or_default();
25315 let error = serde_json::from_str(&common::to_string(&bytes));
25316 let response = common::to_response(parts, bytes.into());
25317
25318 if let common::Retry::After(d) =
25319 dlg.http_failure(&response, error.as_ref().ok())
25320 {
25321 sleep(d).await;
25322 continue;
25323 }
25324
25325 dlg.finished(false);
25326
25327 return Err(match error {
25328 Ok(value) => common::Error::BadRequest(value),
25329 _ => common::Error::Failure(response),
25330 });
25331 }
25332 let response = {
25333 let bytes = common::to_bytes(body).await.unwrap_or_default();
25334 let encoded = common::to_string(&bytes);
25335 match serde_json::from_str(&encoded) {
25336 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
25337 Err(error) => {
25338 dlg.response_json_decode_error(&encoded, &error);
25339 return Err(common::Error::JsonDecodeError(
25340 encoded.to_string(),
25341 error,
25342 ));
25343 }
25344 }
25345 };
25346
25347 dlg.finished(true);
25348 return Ok(response);
25349 }
25350 }
25351 }
25352 }
25353
25354 ///
25355 /// Sets the *request* property to the given value.
25356 ///
25357 /// Even though the property as already been set when instantiating this call,
25358 /// we provide this method for API completeness.
25359 pub fn request(mut self, new_value: RepoSource) -> ProjectTriggerRunCall<'a, C> {
25360 self._request = new_value;
25361 self
25362 }
25363 /// Required. ID of the project.
25364 ///
25365 /// Sets the *project id* path property to the given value.
25366 ///
25367 /// Even though the property as already been set when instantiating this call,
25368 /// we provide this method for API completeness.
25369 pub fn project_id(mut self, new_value: &str) -> ProjectTriggerRunCall<'a, C> {
25370 self._project_id = new_value.to_string();
25371 self
25372 }
25373 /// Required. ID of the trigger.
25374 ///
25375 /// Sets the *trigger id* path property to the given value.
25376 ///
25377 /// Even though the property as already been set when instantiating this call,
25378 /// we provide this method for API completeness.
25379 pub fn trigger_id(mut self, new_value: &str) -> ProjectTriggerRunCall<'a, C> {
25380 self._trigger_id = new_value.to_string();
25381 self
25382 }
25383 /// The name of the `Trigger` to run. Format: `projects/{project}/locations/{location}/triggers/{trigger}`
25384 ///
25385 /// Sets the *name* query property to the given value.
25386 pub fn name(mut self, new_value: &str) -> ProjectTriggerRunCall<'a, C> {
25387 self._name = Some(new_value.to_string());
25388 self
25389 }
25390 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25391 /// while executing the actual API request.
25392 ///
25393 /// ````text
25394 /// It should be used to handle progress information, and to implement a certain level of resilience.
25395 /// ````
25396 ///
25397 /// Sets the *delegate* property to the given value.
25398 pub fn delegate(
25399 mut self,
25400 new_value: &'a mut dyn common::Delegate,
25401 ) -> ProjectTriggerRunCall<'a, C> {
25402 self._delegate = Some(new_value);
25403 self
25404 }
25405
25406 /// Set any additional parameter of the query string used in the request.
25407 /// It should be used to set parameters which are not yet available through their own
25408 /// setters.
25409 ///
25410 /// Please note that this method must not be used to set any of the known parameters
25411 /// which have their own setter method. If done anyway, the request will fail.
25412 ///
25413 /// # Additional Parameters
25414 ///
25415 /// * *$.xgafv* (query-string) - V1 error format.
25416 /// * *access_token* (query-string) - OAuth access token.
25417 /// * *alt* (query-string) - Data format for response.
25418 /// * *callback* (query-string) - JSONP
25419 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25420 /// * *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.
25421 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25422 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25423 /// * *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.
25424 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
25425 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
25426 pub fn param<T>(mut self, name: T, value: T) -> ProjectTriggerRunCall<'a, C>
25427 where
25428 T: AsRef<str>,
25429 {
25430 self._additional_params
25431 .insert(name.as_ref().to_string(), value.as_ref().to_string());
25432 self
25433 }
25434
25435 /// Identifies the authorization scope for the method you are building.
25436 ///
25437 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
25438 /// [`Scope::CloudPlatform`].
25439 ///
25440 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
25441 /// tokens for more than one scope.
25442 ///
25443 /// Usually there is more than one suitable scope to authorize an operation, some of which may
25444 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
25445 /// sufficient, a read-write scope will do as well.
25446 pub fn add_scope<St>(mut self, scope: St) -> ProjectTriggerRunCall<'a, C>
25447 where
25448 St: AsRef<str>,
25449 {
25450 self._scopes.insert(String::from(scope.as_ref()));
25451 self
25452 }
25453 /// Identifies the authorization scope(s) for the method you are building.
25454 ///
25455 /// See [`Self::add_scope()`] for details.
25456 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectTriggerRunCall<'a, C>
25457 where
25458 I: IntoIterator<Item = St>,
25459 St: AsRef<str>,
25460 {
25461 self._scopes
25462 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
25463 self
25464 }
25465
25466 /// Removes all scopes, and no default scope will be used either.
25467 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
25468 /// for details).
25469 pub fn clear_scopes(mut self) -> ProjectTriggerRunCall<'a, C> {
25470 self._scopes.clear();
25471 self
25472 }
25473}
25474
25475/// ReceiveTriggerWebhook [Experimental] is called when the API receives a webhook request targeted at a specific trigger.
25476///
25477/// A builder for the *triggers.webhook* method supported by a *project* resource.
25478/// It is not used directly, but through a [`ProjectMethods`] instance.
25479///
25480/// # Example
25481///
25482/// Instantiate a resource method builder
25483///
25484/// ```test_harness,no_run
25485/// # extern crate hyper;
25486/// # extern crate hyper_rustls;
25487/// # extern crate google_cloudbuild1 as cloudbuild1;
25488/// use cloudbuild1::api::HttpBody;
25489/// # async fn dox() {
25490/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
25491///
25492/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
25493/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
25494/// # .with_native_roots()
25495/// # .unwrap()
25496/// # .https_only()
25497/// # .enable_http2()
25498/// # .build();
25499///
25500/// # let executor = hyper_util::rt::TokioExecutor::new();
25501/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
25502/// # secret,
25503/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
25504/// # yup_oauth2::client::CustomHyperClientBuilder::from(
25505/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
25506/// # ),
25507/// # ).build().await.unwrap();
25508///
25509/// # let client = hyper_util::client::legacy::Client::builder(
25510/// # hyper_util::rt::TokioExecutor::new()
25511/// # )
25512/// # .build(
25513/// # hyper_rustls::HttpsConnectorBuilder::new()
25514/// # .with_native_roots()
25515/// # .unwrap()
25516/// # .https_or_http()
25517/// # .enable_http2()
25518/// # .build()
25519/// # );
25520/// # let mut hub = CloudBuild::new(client, auth);
25521/// // As the method needs a request, you would usually fill it with the desired information
25522/// // into the respective structure. Some of the parts shown here might not be applicable !
25523/// // Values shown here are possibly random and not representative !
25524/// let mut req = HttpBody::default();
25525///
25526/// // You can configure optional parameters by calling the respective setters at will, and
25527/// // execute the final call using `doit()`.
25528/// // Values shown here are possibly random and not representative !
25529/// let result = hub.projects().triggers_webhook(req, "projectId", "trigger")
25530/// .secret("ea")
25531/// .name("Stet")
25532/// .doit().await;
25533/// # }
25534/// ```
25535pub struct ProjectTriggerWebhookCall<'a, C>
25536where
25537 C: 'a,
25538{
25539 hub: &'a CloudBuild<C>,
25540 _request: HttpBody,
25541 _project_id: String,
25542 _trigger: String,
25543 _secret: Option<String>,
25544 _name: Option<String>,
25545 _delegate: Option<&'a mut dyn common::Delegate>,
25546 _additional_params: HashMap<String, String>,
25547}
25548
25549impl<'a, C> common::CallBuilder for ProjectTriggerWebhookCall<'a, C> {}
25550
25551impl<'a, C> ProjectTriggerWebhookCall<'a, C>
25552where
25553 C: common::Connector,
25554{
25555 /// Perform the operation you have build so far.
25556 pub async fn doit(
25557 mut self,
25558 ) -> common::Result<(common::Response, ReceiveTriggerWebhookResponse)> {
25559 use std::borrow::Cow;
25560 use std::io::{Read, Seek};
25561
25562 use common::{url::Params, ToParts};
25563 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
25564
25565 let mut dd = common::DefaultDelegate;
25566 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
25567 dlg.begin(common::MethodInfo {
25568 id: "cloudbuild.projects.triggers.webhook",
25569 http_method: hyper::Method::POST,
25570 });
25571
25572 for &field in ["alt", "projectId", "trigger", "secret", "name"].iter() {
25573 if self._additional_params.contains_key(field) {
25574 dlg.finished(false);
25575 return Err(common::Error::FieldClash(field));
25576 }
25577 }
25578
25579 let mut params = Params::with_capacity(7 + self._additional_params.len());
25580 params.push("projectId", self._project_id);
25581 params.push("trigger", self._trigger);
25582 if let Some(value) = self._secret.as_ref() {
25583 params.push("secret", value);
25584 }
25585 if let Some(value) = self._name.as_ref() {
25586 params.push("name", value);
25587 }
25588
25589 params.extend(self._additional_params.iter());
25590
25591 params.push("alt", "json");
25592 let mut url =
25593 self.hub._base_url.clone() + "v1/projects/{projectId}/triggers/{trigger}:webhook";
25594
25595 match dlg.api_key() {
25596 Some(value) => params.push("key", value),
25597 None => {
25598 dlg.finished(false);
25599 return Err(common::Error::MissingAPIKey);
25600 }
25601 }
25602
25603 #[allow(clippy::single_element_loop)]
25604 for &(find_this, param_name) in
25605 [("{projectId}", "projectId"), ("{trigger}", "trigger")].iter()
25606 {
25607 url = params.uri_replacement(url, param_name, find_this, false);
25608 }
25609 {
25610 let to_remove = ["trigger", "projectId"];
25611 params.remove_params(&to_remove);
25612 }
25613
25614 let url = params.parse_with_url(&url);
25615
25616 let mut json_mime_type = mime::APPLICATION_JSON;
25617 let mut request_value_reader = {
25618 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
25619 common::remove_json_null_values(&mut value);
25620 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
25621 serde_json::to_writer(&mut dst, &value).unwrap();
25622 dst
25623 };
25624 let request_size = request_value_reader
25625 .seek(std::io::SeekFrom::End(0))
25626 .unwrap();
25627 request_value_reader
25628 .seek(std::io::SeekFrom::Start(0))
25629 .unwrap();
25630
25631 loop {
25632 request_value_reader
25633 .seek(std::io::SeekFrom::Start(0))
25634 .unwrap();
25635 let mut req_result = {
25636 let client = &self.hub.client;
25637 dlg.pre_request();
25638 let mut req_builder = hyper::Request::builder()
25639 .method(hyper::Method::POST)
25640 .uri(url.as_str())
25641 .header(USER_AGENT, self.hub._user_agent.clone());
25642
25643 let request = req_builder
25644 .header(CONTENT_TYPE, json_mime_type.to_string())
25645 .header(CONTENT_LENGTH, request_size as u64)
25646 .body(common::to_body(
25647 request_value_reader.get_ref().clone().into(),
25648 ));
25649
25650 client.request(request.unwrap()).await
25651 };
25652
25653 match req_result {
25654 Err(err) => {
25655 if let common::Retry::After(d) = dlg.http_error(&err) {
25656 sleep(d).await;
25657 continue;
25658 }
25659 dlg.finished(false);
25660 return Err(common::Error::HttpError(err));
25661 }
25662 Ok(res) => {
25663 let (mut parts, body) = res.into_parts();
25664 let mut body = common::Body::new(body);
25665 if !parts.status.is_success() {
25666 let bytes = common::to_bytes(body).await.unwrap_or_default();
25667 let error = serde_json::from_str(&common::to_string(&bytes));
25668 let response = common::to_response(parts, bytes.into());
25669
25670 if let common::Retry::After(d) =
25671 dlg.http_failure(&response, error.as_ref().ok())
25672 {
25673 sleep(d).await;
25674 continue;
25675 }
25676
25677 dlg.finished(false);
25678
25679 return Err(match error {
25680 Ok(value) => common::Error::BadRequest(value),
25681 _ => common::Error::Failure(response),
25682 });
25683 }
25684 let response = {
25685 let bytes = common::to_bytes(body).await.unwrap_or_default();
25686 let encoded = common::to_string(&bytes);
25687 match serde_json::from_str(&encoded) {
25688 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
25689 Err(error) => {
25690 dlg.response_json_decode_error(&encoded, &error);
25691 return Err(common::Error::JsonDecodeError(
25692 encoded.to_string(),
25693 error,
25694 ));
25695 }
25696 }
25697 };
25698
25699 dlg.finished(true);
25700 return Ok(response);
25701 }
25702 }
25703 }
25704 }
25705
25706 ///
25707 /// Sets the *request* property to the given value.
25708 ///
25709 /// Even though the property as already been set when instantiating this call,
25710 /// we provide this method for API completeness.
25711 pub fn request(mut self, new_value: HttpBody) -> ProjectTriggerWebhookCall<'a, C> {
25712 self._request = new_value;
25713 self
25714 }
25715 /// Project in which the specified trigger lives
25716 ///
25717 /// Sets the *project id* path property to the given value.
25718 ///
25719 /// Even though the property as already been set when instantiating this call,
25720 /// we provide this method for API completeness.
25721 pub fn project_id(mut self, new_value: &str) -> ProjectTriggerWebhookCall<'a, C> {
25722 self._project_id = new_value.to_string();
25723 self
25724 }
25725 /// Name of the trigger to run the payload against
25726 ///
25727 /// Sets the *trigger* path property to the given value.
25728 ///
25729 /// Even though the property as already been set when instantiating this call,
25730 /// we provide this method for API completeness.
25731 pub fn trigger(mut self, new_value: &str) -> ProjectTriggerWebhookCall<'a, C> {
25732 self._trigger = new_value.to_string();
25733 self
25734 }
25735 /// Secret token used for authorization if an OAuth token isn't provided.
25736 ///
25737 /// Sets the *secret* query property to the given value.
25738 pub fn secret(mut self, new_value: &str) -> ProjectTriggerWebhookCall<'a, C> {
25739 self._secret = Some(new_value.to_string());
25740 self
25741 }
25742 /// The name of the `ReceiveTriggerWebhook` to retrieve. Format: `projects/{project}/locations/{location}/triggers/{trigger}`
25743 ///
25744 /// Sets the *name* query property to the given value.
25745 pub fn name(mut self, new_value: &str) -> ProjectTriggerWebhookCall<'a, C> {
25746 self._name = Some(new_value.to_string());
25747 self
25748 }
25749 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
25750 /// while executing the actual API request.
25751 ///
25752 /// ````text
25753 /// It should be used to handle progress information, and to implement a certain level of resilience.
25754 /// ````
25755 ///
25756 /// Sets the *delegate* property to the given value.
25757 pub fn delegate(
25758 mut self,
25759 new_value: &'a mut dyn common::Delegate,
25760 ) -> ProjectTriggerWebhookCall<'a, C> {
25761 self._delegate = Some(new_value);
25762 self
25763 }
25764
25765 /// Set any additional parameter of the query string used in the request.
25766 /// It should be used to set parameters which are not yet available through their own
25767 /// setters.
25768 ///
25769 /// Please note that this method must not be used to set any of the known parameters
25770 /// which have their own setter method. If done anyway, the request will fail.
25771 ///
25772 /// # Additional Parameters
25773 ///
25774 /// * *$.xgafv* (query-string) - V1 error format.
25775 /// * *access_token* (query-string) - OAuth access token.
25776 /// * *alt* (query-string) - Data format for response.
25777 /// * *callback* (query-string) - JSONP
25778 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
25779 /// * *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.
25780 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
25781 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
25782 /// * *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.
25783 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
25784 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
25785 pub fn param<T>(mut self, name: T, value: T) -> ProjectTriggerWebhookCall<'a, C>
25786 where
25787 T: AsRef<str>,
25788 {
25789 self._additional_params
25790 .insert(name.as_ref().to_string(), value.as_ref().to_string());
25791 self
25792 }
25793}
25794
25795/// ReceiveWebhook is called when the API receives a GitHub webhook.
25796///
25797/// A builder for the *webhook* method.
25798/// It is not used directly, but through a [`MethodMethods`] instance.
25799///
25800/// # Example
25801///
25802/// Instantiate a resource method builder
25803///
25804/// ```test_harness,no_run
25805/// # extern crate hyper;
25806/// # extern crate hyper_rustls;
25807/// # extern crate google_cloudbuild1 as cloudbuild1;
25808/// use cloudbuild1::api::HttpBody;
25809/// # async fn dox() {
25810/// # use cloudbuild1::{CloudBuild, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
25811///
25812/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
25813/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
25814/// # .with_native_roots()
25815/// # .unwrap()
25816/// # .https_only()
25817/// # .enable_http2()
25818/// # .build();
25819///
25820/// # let executor = hyper_util::rt::TokioExecutor::new();
25821/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
25822/// # secret,
25823/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
25824/// # yup_oauth2::client::CustomHyperClientBuilder::from(
25825/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
25826/// # ),
25827/// # ).build().await.unwrap();
25828///
25829/// # let client = hyper_util::client::legacy::Client::builder(
25830/// # hyper_util::rt::TokioExecutor::new()
25831/// # )
25832/// # .build(
25833/// # hyper_rustls::HttpsConnectorBuilder::new()
25834/// # .with_native_roots()
25835/// # .unwrap()
25836/// # .https_or_http()
25837/// # .enable_http2()
25838/// # .build()
25839/// # );
25840/// # let mut hub = CloudBuild::new(client, auth);
25841/// // As the method needs a request, you would usually fill it with the desired information
25842/// // into the respective structure. Some of the parts shown here might not be applicable !
25843/// // Values shown here are possibly random and not representative !
25844/// let mut req = HttpBody::default();
25845///
25846/// // You can configure optional parameters by calling the respective setters at will, and
25847/// // execute the final call using `doit()`.
25848/// // Values shown here are possibly random and not representative !
25849/// let result = hub.methods().webhook(req)
25850/// .webhook_key("dolores")
25851/// .doit().await;
25852/// # }
25853/// ```
25854pub struct MethodWebhookCall<'a, C>
25855where
25856 C: 'a,
25857{
25858 hub: &'a CloudBuild<C>,
25859 _request: HttpBody,
25860 _webhook_key: Option<String>,
25861 _delegate: Option<&'a mut dyn common::Delegate>,
25862 _additional_params: HashMap<String, String>,
25863}
25864
25865impl<'a, C> common::CallBuilder for MethodWebhookCall<'a, C> {}
25866
25867impl<'a, C> MethodWebhookCall<'a, C>
25868where
25869 C: common::Connector,
25870{
25871 /// Perform the operation you have build so far.
25872 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
25873 use std::borrow::Cow;
25874 use std::io::{Read, Seek};
25875
25876 use common::{url::Params, ToParts};
25877 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
25878
25879 let mut dd = common::DefaultDelegate;
25880 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
25881 dlg.begin(common::MethodInfo {
25882 id: "cloudbuild.webhook",
25883 http_method: hyper::Method::POST,
25884 });
25885
25886 for &field in ["alt", "webhookKey"].iter() {
25887 if self._additional_params.contains_key(field) {
25888 dlg.finished(false);
25889 return Err(common::Error::FieldClash(field));
25890 }
25891 }
25892
25893 let mut params = Params::with_capacity(4 + self._additional_params.len());
25894 if let Some(value) = self._webhook_key.as_ref() {
25895 params.push("webhookKey", value);
25896 }
25897
25898 params.extend(self._additional_params.iter());
25899
25900 params.push("alt", "json");
25901 let mut url = self.hub._base_url.clone() + "v1/webhook";
25902
25903 match dlg.api_key() {
25904 Some(value) => params.push("key", value),
25905 None => {
25906 dlg.finished(false);
25907 return Err(common::Error::MissingAPIKey);
25908 }
25909 }
25910
25911 let url = params.parse_with_url(&url);
25912
25913 let mut json_mime_type = mime::APPLICATION_JSON;
25914 let mut request_value_reader = {
25915 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
25916 common::remove_json_null_values(&mut value);
25917 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
25918 serde_json::to_writer(&mut dst, &value).unwrap();
25919 dst
25920 };
25921 let request_size = request_value_reader
25922 .seek(std::io::SeekFrom::End(0))
25923 .unwrap();
25924 request_value_reader
25925 .seek(std::io::SeekFrom::Start(0))
25926 .unwrap();
25927
25928 loop {
25929 request_value_reader
25930 .seek(std::io::SeekFrom::Start(0))
25931 .unwrap();
25932 let mut req_result = {
25933 let client = &self.hub.client;
25934 dlg.pre_request();
25935 let mut req_builder = hyper::Request::builder()
25936 .method(hyper::Method::POST)
25937 .uri(url.as_str())
25938 .header(USER_AGENT, self.hub._user_agent.clone());
25939
25940 let request = req_builder
25941 .header(CONTENT_TYPE, json_mime_type.to_string())
25942 .header(CONTENT_LENGTH, request_size as u64)
25943 .body(common::to_body(
25944 request_value_reader.get_ref().clone().into(),
25945 ));
25946
25947 client.request(request.unwrap()).await
25948 };
25949
25950 match req_result {
25951 Err(err) => {
25952 if let common::Retry::After(d) = dlg.http_error(&err) {
25953 sleep(d).await;
25954 continue;
25955 }
25956 dlg.finished(false);
25957 return Err(common::Error::HttpError(err));
25958 }
25959 Ok(res) => {
25960 let (mut parts, body) = res.into_parts();
25961 let mut body = common::Body::new(body);
25962 if !parts.status.is_success() {
25963 let bytes = common::to_bytes(body).await.unwrap_or_default();
25964 let error = serde_json::from_str(&common::to_string(&bytes));
25965 let response = common::to_response(parts, bytes.into());
25966
25967 if let common::Retry::After(d) =
25968 dlg.http_failure(&response, error.as_ref().ok())
25969 {
25970 sleep(d).await;
25971 continue;
25972 }
25973
25974 dlg.finished(false);
25975
25976 return Err(match error {
25977 Ok(value) => common::Error::BadRequest(value),
25978 _ => common::Error::Failure(response),
25979 });
25980 }
25981 let response = {
25982 let bytes = common::to_bytes(body).await.unwrap_or_default();
25983 let encoded = common::to_string(&bytes);
25984 match serde_json::from_str(&encoded) {
25985 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
25986 Err(error) => {
25987 dlg.response_json_decode_error(&encoded, &error);
25988 return Err(common::Error::JsonDecodeError(
25989 encoded.to_string(),
25990 error,
25991 ));
25992 }
25993 }
25994 };
25995
25996 dlg.finished(true);
25997 return Ok(response);
25998 }
25999 }
26000 }
26001 }
26002
26003 ///
26004 /// Sets the *request* property to the given value.
26005 ///
26006 /// Even though the property as already been set when instantiating this call,
26007 /// we provide this method for API completeness.
26008 pub fn request(mut self, new_value: HttpBody) -> MethodWebhookCall<'a, C> {
26009 self._request = new_value;
26010 self
26011 }
26012 /// For GitHub Enterprise webhooks, this key is used to associate the webhook request with the GitHubEnterpriseConfig to use for validation.
26013 ///
26014 /// Sets the *webhook key* query property to the given value.
26015 pub fn webhook_key(mut self, new_value: &str) -> MethodWebhookCall<'a, C> {
26016 self._webhook_key = Some(new_value.to_string());
26017 self
26018 }
26019 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
26020 /// while executing the actual API request.
26021 ///
26022 /// ````text
26023 /// It should be used to handle progress information, and to implement a certain level of resilience.
26024 /// ````
26025 ///
26026 /// Sets the *delegate* property to the given value.
26027 pub fn delegate(mut self, new_value: &'a mut dyn common::Delegate) -> MethodWebhookCall<'a, C> {
26028 self._delegate = Some(new_value);
26029 self
26030 }
26031
26032 /// Set any additional parameter of the query string used in the request.
26033 /// It should be used to set parameters which are not yet available through their own
26034 /// setters.
26035 ///
26036 /// Please note that this method must not be used to set any of the known parameters
26037 /// which have their own setter method. If done anyway, the request will fail.
26038 ///
26039 /// # Additional Parameters
26040 ///
26041 /// * *$.xgafv* (query-string) - V1 error format.
26042 /// * *access_token* (query-string) - OAuth access token.
26043 /// * *alt* (query-string) - Data format for response.
26044 /// * *callback* (query-string) - JSONP
26045 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
26046 /// * *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.
26047 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
26048 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
26049 /// * *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.
26050 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
26051 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
26052 pub fn param<T>(mut self, name: T, value: T) -> MethodWebhookCall<'a, C>
26053 where
26054 T: AsRef<str>,
26055 {
26056 self._additional_params
26057 .insert(name.as_ref().to_string(), value.as_ref().to_string());
26058 self
26059 }
26060}