google_containeranalysis1/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 ContainerAnalysis 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_containeranalysis1 as containeranalysis1;
49/// use containeranalysis1::api::Note;
50/// use containeranalysis1::{Result, Error};
51/// # async fn dox() {
52/// use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
53///
54/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
55/// // `client_secret`, among other things.
56/// let secret: yup_oauth2::ApplicationSecret = Default::default();
57/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
58/// // unless you replace `None` with the desired Flow.
59/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
60/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
61/// // retrieve them from storage.
62/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
63/// secret,
64/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
65/// ).build().await.unwrap();
66///
67/// let client = hyper_util::client::legacy::Client::builder(
68/// hyper_util::rt::TokioExecutor::new()
69/// )
70/// .build(
71/// hyper_rustls::HttpsConnectorBuilder::new()
72/// .with_native_roots()
73/// .unwrap()
74/// .https_or_http()
75/// .enable_http1()
76/// .build()
77/// );
78/// let mut hub = ContainerAnalysis::new(client, auth);
79/// // As the method needs a request, you would usually fill it with the desired information
80/// // into the respective structure. Some of the parts shown here might not be applicable !
81/// // Values shown here are possibly random and not representative !
82/// let mut req = Note::default();
83///
84/// // You can configure optional parameters by calling the respective setters at will, and
85/// // execute the final call using `doit()`.
86/// // Values shown here are possibly random and not representative !
87/// let result = hub.projects().notes_create(req, "parent")
88/// .note_id("At")
89/// .doit().await;
90///
91/// match result {
92/// Err(e) => match e {
93/// // The Error enum provides details about what exactly happened.
94/// // You can also just use its `Debug`, `Display` or `Error` traits
95/// Error::HttpError(_)
96/// |Error::Io(_)
97/// |Error::MissingAPIKey
98/// |Error::MissingToken(_)
99/// |Error::Cancelled
100/// |Error::UploadSizeLimitExceeded(_, _)
101/// |Error::Failure(_)
102/// |Error::BadRequest(_)
103/// |Error::FieldClash(_)
104/// |Error::JsonDecodeError(_, _) => println!("{}", e),
105/// },
106/// Ok(res) => println!("Success: {:?}", res),
107/// }
108/// # }
109/// ```
110#[derive(Clone)]
111pub struct ContainerAnalysis<C> {
112 pub client: common::Client<C>,
113 pub auth: Box<dyn common::GetToken>,
114 _user_agent: String,
115 _base_url: String,
116 _root_url: String,
117}
118
119impl<C> common::Hub for ContainerAnalysis<C> {}
120
121impl<'a, C> ContainerAnalysis<C> {
122 pub fn new<A: 'static + common::GetToken>(
123 client: common::Client<C>,
124 auth: A,
125 ) -> ContainerAnalysis<C> {
126 ContainerAnalysis {
127 client,
128 auth: Box::new(auth),
129 _user_agent: "google-api-rust-client/6.0.0".to_string(),
130 _base_url: "https://containeranalysis.googleapis.com/".to_string(),
131 _root_url: "https://containeranalysis.googleapis.com/".to_string(),
132 }
133 }
134
135 pub fn projects(&'a self) -> ProjectMethods<'a, C> {
136 ProjectMethods { hub: self }
137 }
138
139 /// Set the user-agent header field to use in all requests to the server.
140 /// It defaults to `google-api-rust-client/6.0.0`.
141 ///
142 /// Returns the previously set user-agent.
143 pub fn user_agent(&mut self, agent_name: String) -> String {
144 std::mem::replace(&mut self._user_agent, agent_name)
145 }
146
147 /// Set the base url to use in all requests to the server.
148 /// It defaults to `https://containeranalysis.googleapis.com/`.
149 ///
150 /// Returns the previously set base url.
151 pub fn base_url(&mut self, new_base_url: String) -> String {
152 std::mem::replace(&mut self._base_url, new_base_url)
153 }
154
155 /// Set the root url to use in all requests to the server.
156 /// It defaults to `https://containeranalysis.googleapis.com/`.
157 ///
158 /// Returns the previously set root url.
159 pub fn root_url(&mut self, new_root_url: String) -> String {
160 std::mem::replace(&mut self._root_url, new_root_url)
161 }
162}
163
164// ############
165// SCHEMAS ###
166// ##########
167/// An alias to a repo revision.
168///
169/// This type is not used in any activity, and only used as *part* of another schema.
170///
171#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
172#[serde_with::serde_as]
173#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
174pub struct AliasContext {
175 /// The alias kind.
176 pub kind: Option<String>,
177 /// The alias name.
178 pub name: Option<String>,
179}
180
181impl common::Part for AliasContext {}
182
183/// Indicates which analysis completed successfully. Multiple types of analysis can be performed on a single resource.
184///
185/// This type is not used in any activity, and only used as *part* of another schema.
186///
187#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
188#[serde_with::serde_as]
189#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
190pub struct AnalysisCompleted {
191 /// no description provided
192 #[serde(rename = "analysisType")]
193 pub analysis_type: Option<Vec<String>>,
194}
195
196impl common::Part for AnalysisCompleted {}
197
198/// Artifact describes a build product.
199///
200/// This type is not used in any activity, and only used as *part* of another schema.
201///
202#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
203#[serde_with::serde_as]
204#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
205pub struct Artifact {
206 /// Hash or checksum value of a binary, or Docker Registry 2.0 digest of a container.
207 pub checksum: Option<String>,
208 /// Artifact ID, if any; for container images, this will be a URL by digest like `gcr.io/projectID/imagename@sha256:123456`.
209 pub id: Option<String>,
210 /// Related artifact names. This may be the path to a binary or jar file, or in the case of a container build, the name used to push the container image to Google Container Registry, as presented to `docker push`. Note that a single Artifact ID can have multiple names, for example if two tags are applied to one image.
211 pub names: Option<Vec<String>>,
212}
213
214impl common::Part for Artifact {}
215
216/// Assessment provides all information that is related to a single vulnerability for this product.
217///
218/// This type is not used in any activity, and only used as *part* of another schema.
219///
220#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
221#[serde_with::serde_as]
222#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
223pub struct Assessment {
224 /// Holds the MITRE standard Common Vulnerabilities and Exposures (CVE) tracking number for the vulnerability. Deprecated: Use vulnerability_id instead to denote CVEs.
225 pub cve: Option<String>,
226 /// Contains information about the impact of this vulnerability, this will change with time.
227 pub impacts: Option<Vec<String>>,
228 /// Justification provides the justification when the state of the assessment if NOT_AFFECTED.
229 pub justification: Option<Justification>,
230 /// A detailed description of this Vex.
231 #[serde(rename = "longDescription")]
232 pub long_description: Option<String>,
233 /// Holds a list of references associated with this vulnerability item and assessment. These uris have additional information about the vulnerability and the assessment itself. E.g. Link to a document which details how this assessment concluded the state of this vulnerability.
234 #[serde(rename = "relatedUris")]
235 pub related_uris: Option<Vec<RelatedUrl>>,
236 /// Specifies details on how to handle (and presumably, fix) a vulnerability.
237 pub remediations: Option<Vec<Remediation>>,
238 /// A one sentence description of this Vex.
239 #[serde(rename = "shortDescription")]
240 pub short_description: Option<String>,
241 /// Provides the state of this Vulnerability assessment.
242 pub state: Option<String>,
243 /// The vulnerability identifier for this Assessment. Will hold one of common identifiers e.g. CVE, GHSA etc.
244 #[serde(rename = "vulnerabilityId")]
245 pub vulnerability_id: Option<String>,
246}
247
248impl common::Part for Assessment {}
249
250/// Note kind that represents a logical attestation "role" or "authority". For example, an organization might have one `Authority` for "QA" and one for "build". This note is intended to act strictly as a grouping mechanism for the attached occurrences (Attestations). This grouping mechanism also provides a security boundary, since IAM ACLs gate the ability for a principle to attach an occurrence to a given note. It also provides a single point of lookup to find all attached attestation occurrences, even if they don't all live in the same project.
251///
252/// This type is not used in any activity, and only used as *part* of another schema.
253///
254#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
255#[serde_with::serde_as]
256#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
257pub struct AttestationNote {
258 /// Hint hints at the purpose of the attestation authority.
259 pub hint: Option<Hint>,
260}
261
262impl common::Part for AttestationNote {}
263
264/// Occurrence that represents a single "attestation". The authenticity of an attestation can be verified using the attached signature. If the verifier trusts the public key of the signer, then verifying the signature is sufficient to establish trust. In this circumstance, the authority to which this attestation is attached is primarily useful for lookup (how to find this attestation if you already know the authority and artifact to be verified) and intent (for which authority this attestation was intended to sign.
265///
266/// This type is not used in any activity, and only used as *part* of another schema.
267///
268#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
269#[serde_with::serde_as]
270#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
271pub struct AttestationOccurrence {
272 /// One or more JWTs encoding a self-contained attestation. Each JWT encodes the payload that it verifies within the JWT itself. Verifier implementation SHOULD ignore the `serialized_payload` field when verifying these JWTs. If only JWTs are present on this AttestationOccurrence, then the `serialized_payload` SHOULD be left empty. Each JWT SHOULD encode a claim specific to the `resource_uri` of this Occurrence, but this is not validated by Grafeas metadata API implementations. The JWT itself is opaque to Grafeas.
273 pub jwts: Option<Vec<Jwt>>,
274 /// Required. The serialized payload that is verified by one or more `signatures`.
275 #[serde(rename = "serializedPayload")]
276 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
277 pub serialized_payload: Option<Vec<u8>>,
278 /// One or more signatures over `serialized_payload`. Verifier implementations should consider this attestation message verified if at least one `signature` verifies `serialized_payload`. See `Signature` in common.proto for more details on signature structure and verification.
279 pub signatures: Option<Vec<Signature>>,
280}
281
282impl common::Part for AttestationOccurrence {}
283
284/// Request to create notes in batch.
285///
286/// # Activities
287///
288/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
289/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
290///
291/// * [notes batch create projects](ProjectNoteBatchCreateCall) (request)
292#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
293#[serde_with::serde_as]
294#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
295pub struct BatchCreateNotesRequest {
296 /// Required. The notes to create. Max allowed length is 1000.
297 pub notes: Option<HashMap<String, Note>>,
298}
299
300impl common::RequestValue for BatchCreateNotesRequest {}
301
302/// Response for creating notes in batch.
303///
304/// # Activities
305///
306/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
307/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
308///
309/// * [notes batch create projects](ProjectNoteBatchCreateCall) (response)
310#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
311#[serde_with::serde_as]
312#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
313pub struct BatchCreateNotesResponse {
314 /// The notes that were created.
315 pub notes: Option<Vec<Note>>,
316}
317
318impl common::ResponseResult for BatchCreateNotesResponse {}
319
320/// Request to create occurrences in batch.
321///
322/// # Activities
323///
324/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
325/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
326///
327/// * [occurrences batch create projects](ProjectOccurrenceBatchCreateCall) (request)
328#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
329#[serde_with::serde_as]
330#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
331pub struct BatchCreateOccurrencesRequest {
332 /// Required. The occurrences to create. Max allowed length is 1000.
333 pub occurrences: Option<Vec<Occurrence>>,
334}
335
336impl common::RequestValue for BatchCreateOccurrencesRequest {}
337
338/// Response for creating occurrences in batch.
339///
340/// # Activities
341///
342/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
343/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
344///
345/// * [occurrences batch create projects](ProjectOccurrenceBatchCreateCall) (response)
346#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
347#[serde_with::serde_as]
348#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
349pub struct BatchCreateOccurrencesResponse {
350 /// The occurrences that were created.
351 pub occurrences: Option<Vec<Occurrence>>,
352}
353
354impl common::ResponseResult for BatchCreateOccurrencesResponse {}
355
356/// Associates `members`, or principals, with a `role`.
357///
358/// This type is not used in any activity, and only used as *part* of another schema.
359///
360#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
361#[serde_with::serde_as]
362#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
363pub struct Binding {
364 /// The condition that is associated with this binding. If the condition evaluates to `true`, then this binding applies to the current request. If the condition evaluates to `false`, then this binding does not apply to the current request. However, a different role binding might grant the same role to one or more of the principals in this binding. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
365 pub condition: Option<Expr>,
366 /// Specifies the principals requesting access for a Google Cloud resource. `members` can have the following values: * `allUsers`: A special identifier that represents anyone who is on the internet; with or without a Google account. * `allAuthenticatedUsers`: A special identifier that represents anyone who is authenticated with a Google account or a service account. Does not include identities that come from external identity providers (IdPs) through identity federation. * `user:{emailid}`: An email address that represents a specific Google account. For example, `alice@example.com` . * `serviceAccount:{emailid}`: An email address that represents a Google service account. For example, `my-other-app@appspot.gserviceaccount.com`. * `serviceAccount:{projectid}.svc.id.goog[{namespace}/{kubernetes-sa}]`: An identifier for a [Kubernetes service account](https://cloud.google.com/kubernetes-engine/docs/how-to/kubernetes-service-accounts). For example, `my-project.svc.id.goog[my-namespace/my-kubernetes-sa]`. * `group:{emailid}`: An email address that represents a Google group. For example, `admins@example.com`. * `domain:{domain}`: The G Suite domain (primary) that represents all the users of that domain. For example, `google.com` or `example.com`. * `principal://iam.googleapis.com/locations/global/workforcePools/{pool_id}/subject/{subject_attribute_value}`: A single identity in a workforce identity pool. * `principalSet://iam.googleapis.com/locations/global/workforcePools/{pool_id}/group/{group_id}`: All workforce identities in a group. * `principalSet://iam.googleapis.com/locations/global/workforcePools/{pool_id}/attribute.{attribute_name}/{attribute_value}`: All workforce identities with a specific attribute value. * `principalSet://iam.googleapis.com/locations/global/workforcePools/{pool_id}/*`: All identities in a workforce identity pool. * `principal://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/subject/{subject_attribute_value}`: A single identity in a workload identity pool. * `principalSet://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/group/{group_id}`: A workload identity pool group. * `principalSet://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/attribute.{attribute_name}/{attribute_value}`: All identities in a workload identity pool with a certain attribute. * `principalSet://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/*`: All identities in a workload identity pool. * `deleted:user:{emailid}?uid={uniqueid}`: An email address (plus unique identifier) representing a user that has been recently deleted. For example, `alice@example.com?uid=123456789012345678901`. If the user is recovered, this value reverts to `user:{emailid}` and the recovered user retains the role in the binding. * `deleted:serviceAccount:{emailid}?uid={uniqueid}`: An email address (plus unique identifier) representing a service account that has been recently deleted. For example, `my-other-app@appspot.gserviceaccount.com?uid=123456789012345678901`. If the service account is undeleted, this value reverts to `serviceAccount:{emailid}` and the undeleted service account retains the role in the binding. * `deleted:group:{emailid}?uid={uniqueid}`: An email address (plus unique identifier) representing a Google group that has been recently deleted. For example, `admins@example.com?uid=123456789012345678901`. If the group is recovered, this value reverts to `group:{emailid}` and the recovered group retains the role in the binding. * `deleted:principal://iam.googleapis.com/locations/global/workforcePools/{pool_id}/subject/{subject_attribute_value}`: Deleted single identity in a workforce identity pool. For example, `deleted:principal://iam.googleapis.com/locations/global/workforcePools/my-pool-id/subject/my-subject-attribute-value`.
367 pub members: Option<Vec<String>>,
368 /// Role that is assigned to the list of `members`, or principals. For example, `roles/viewer`, `roles/editor`, or `roles/owner`. For an overview of the IAM roles and permissions, see the [IAM documentation](https://cloud.google.com/iam/docs/roles-overview). For a list of the available pre-defined roles, see [here](https://cloud.google.com/iam/docs/understanding-roles).
369 pub role: Option<String>,
370}
371
372impl common::Part for Binding {}
373
374/// There is no detailed description.
375///
376/// This type is not used in any activity, and only used as *part* of another schema.
377///
378#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
379#[serde_with::serde_as]
380#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
381pub struct BuildDefinition {
382 /// no description provided
383 #[serde(rename = "buildType")]
384 pub build_type: Option<String>,
385 /// no description provided
386 #[serde(rename = "externalParameters")]
387 pub external_parameters: Option<HashMap<String, serde_json::Value>>,
388 /// no description provided
389 #[serde(rename = "internalParameters")]
390 pub internal_parameters: Option<HashMap<String, serde_json::Value>>,
391 /// no description provided
392 #[serde(rename = "resolvedDependencies")]
393 pub resolved_dependencies: Option<Vec<ResourceDescriptor>>,
394}
395
396impl common::Part for BuildDefinition {}
397
398/// There is no detailed description.
399///
400/// This type is not used in any activity, and only used as *part* of another schema.
401///
402#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
403#[serde_with::serde_as]
404#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
405pub struct BuildMetadata {
406 /// no description provided
407 #[serde(rename = "finishedOn")]
408 pub finished_on: Option<chrono::DateTime<chrono::offset::Utc>>,
409 /// no description provided
410 #[serde(rename = "invocationId")]
411 pub invocation_id: Option<String>,
412 /// no description provided
413 #[serde(rename = "startedOn")]
414 pub started_on: Option<chrono::DateTime<chrono::offset::Utc>>,
415}
416
417impl common::Part for BuildMetadata {}
418
419/// Note holding the version of the provider's builder and the signature of the provenance message in the build details occurrence.
420///
421/// This type is not used in any activity, and only used as *part* of another schema.
422///
423#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
424#[serde_with::serde_as]
425#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
426pub struct BuildNote {
427 /// Required. Immutable. Version of the builder which produced this build.
428 #[serde(rename = "builderVersion")]
429 pub builder_version: Option<String>,
430}
431
432impl common::Part for BuildNote {}
433
434/// Details of a build occurrence.
435///
436/// This type is not used in any activity, and only used as *part* of another schema.
437///
438#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
439#[serde_with::serde_as]
440#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
441pub struct BuildOccurrence {
442 /// In-Toto Slsa Provenance V1 represents a slsa provenance meeting the slsa spec, wrapped in an in-toto statement. This allows for direct jsonification of a to-spec in-toto slsa statement with a to-spec slsa provenance.
443 #[serde(rename = "inTotoSlsaProvenanceV1")]
444 pub in_toto_slsa_provenance_v1: Option<InTotoSlsaProvenanceV1>,
445 /// Deprecated. See InTotoStatement for the replacement. In-toto Provenance representation as defined in spec.
446 #[serde(rename = "intotoProvenance")]
447 pub intoto_provenance: Option<InTotoProvenance>,
448 /// In-toto Statement representation as defined in spec. The intoto_statement can contain any type of provenance. The serialized payload of the statement can be stored and signed in the Occurrence's envelope.
449 #[serde(rename = "intotoStatement")]
450 pub intoto_statement: Option<InTotoStatement>,
451 /// The actual provenance for the build.
452 pub provenance: Option<BuildProvenance>,
453 /// Serialized JSON representation of the provenance, used in generating the build signature in the corresponding build note. After verifying the signature, `provenance_bytes` can be unmarshalled and compared to the provenance to confirm that it is unchanged. A base64-encoded string representation of the provenance bytes is used for the signature in order to interoperate with openssl which expects this format for signature verification. The serialized form is captured both to avoid ambiguity in how the provenance is marshalled to json as well to prevent incompatibilities with future changes.
454 #[serde(rename = "provenanceBytes")]
455 pub provenance_bytes: Option<String>,
456}
457
458impl common::Part for BuildOccurrence {}
459
460/// Provenance of a build. Contains all information needed to verify the full details about the build from source to completion.
461///
462/// This type is not used in any activity, and only used as *part* of another schema.
463///
464#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
465#[serde_with::serde_as]
466#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
467pub struct BuildProvenance {
468 /// Special options applied to this build. This is a catch-all field where build providers can enter any desired additional details.
469 #[serde(rename = "buildOptions")]
470 pub build_options: Option<HashMap<String, String>>,
471 /// Version string of the builder at the time this build was executed.
472 #[serde(rename = "builderVersion")]
473 pub builder_version: Option<String>,
474 /// Output of the build.
475 #[serde(rename = "builtArtifacts")]
476 pub built_artifacts: Option<Vec<Artifact>>,
477 /// Commands requested by the build.
478 pub commands: Option<Vec<Command>>,
479 /// Time at which the build was created.
480 #[serde(rename = "createTime")]
481 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
482 /// E-mail address of the user who initiated this build. Note that this was the user's e-mail address at the time the build was initiated; this address may not represent the same end-user for all time.
483 pub creator: Option<String>,
484 /// Time at which execution of the build was finished.
485 #[serde(rename = "endTime")]
486 pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
487 /// Required. Unique identifier of the build.
488 pub id: Option<String>,
489 /// URI where any logs for this provenance were written.
490 #[serde(rename = "logsUri")]
491 pub logs_uri: Option<String>,
492 /// ID of the project.
493 #[serde(rename = "projectId")]
494 pub project_id: Option<String>,
495 /// Details of the Source input to the build.
496 #[serde(rename = "sourceProvenance")]
497 pub source_provenance: Option<Source>,
498 /// Time at which execution of the build was started.
499 #[serde(rename = "startTime")]
500 pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
501 /// Trigger identifier if the build was triggered automatically; empty if not.
502 #[serde(rename = "triggerId")]
503 pub trigger_id: Option<String>,
504}
505
506impl common::Part for BuildProvenance {}
507
508/// There is no detailed description.
509///
510/// This type is not used in any activity, and only used as *part* of another schema.
511///
512#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
513#[serde_with::serde_as]
514#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
515pub struct BuilderConfig {
516 /// no description provided
517 pub id: Option<String>,
518}
519
520impl common::Part for BuilderConfig {}
521
522/// Common Vulnerability Scoring System. For details, see https://www.first.org/cvss/specification-document This is a message we will try to use for storing various versions of CVSS rather than making a separate proto for storing a specific version.
523///
524/// This type is not used in any activity, and only used as *part* of another schema.
525///
526#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
527#[serde_with::serde_as]
528#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
529pub struct CVSS {
530 /// no description provided
531 #[serde(rename = "attackComplexity")]
532 pub attack_complexity: Option<String>,
533 /// Base Metrics Represents the intrinsic characteristics of a vulnerability that are constant over time and across user environments.
534 #[serde(rename = "attackVector")]
535 pub attack_vector: Option<String>,
536 /// no description provided
537 pub authentication: Option<String>,
538 /// no description provided
539 #[serde(rename = "availabilityImpact")]
540 pub availability_impact: Option<String>,
541 /// The base score is a function of the base metric scores.
542 #[serde(rename = "baseScore")]
543 pub base_score: Option<f32>,
544 /// no description provided
545 #[serde(rename = "confidentialityImpact")]
546 pub confidentiality_impact: Option<String>,
547 /// no description provided
548 #[serde(rename = "exploitabilityScore")]
549 pub exploitability_score: Option<f32>,
550 /// no description provided
551 #[serde(rename = "impactScore")]
552 pub impact_score: Option<f32>,
553 /// no description provided
554 #[serde(rename = "integrityImpact")]
555 pub integrity_impact: Option<String>,
556 /// no description provided
557 #[serde(rename = "privilegesRequired")]
558 pub privileges_required: Option<String>,
559 /// no description provided
560 pub scope: Option<String>,
561 /// no description provided
562 #[serde(rename = "userInteraction")]
563 pub user_interaction: Option<String>,
564}
565
566impl common::Part for CVSS {}
567
568/// Common Vulnerability Scoring System version 3. For details, see https://www.first.org/cvss/specification-document
569///
570/// This type is not used in any activity, and only used as *part* of another schema.
571///
572#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
573#[serde_with::serde_as]
574#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
575pub struct CVSSv3 {
576 /// no description provided
577 #[serde(rename = "attackComplexity")]
578 pub attack_complexity: Option<String>,
579 /// Base Metrics Represents the intrinsic characteristics of a vulnerability that are constant over time and across user environments.
580 #[serde(rename = "attackVector")]
581 pub attack_vector: Option<String>,
582 /// no description provided
583 #[serde(rename = "availabilityImpact")]
584 pub availability_impact: Option<String>,
585 /// The base score is a function of the base metric scores.
586 #[serde(rename = "baseScore")]
587 pub base_score: Option<f32>,
588 /// no description provided
589 #[serde(rename = "confidentialityImpact")]
590 pub confidentiality_impact: Option<String>,
591 /// no description provided
592 #[serde(rename = "exploitabilityScore")]
593 pub exploitability_score: Option<f32>,
594 /// no description provided
595 #[serde(rename = "impactScore")]
596 pub impact_score: Option<f32>,
597 /// no description provided
598 #[serde(rename = "integrityImpact")]
599 pub integrity_impact: Option<String>,
600 /// no description provided
601 #[serde(rename = "privilegesRequired")]
602 pub privileges_required: Option<String>,
603 /// no description provided
604 pub scope: Option<String>,
605 /// no description provided
606 #[serde(rename = "userInteraction")]
607 pub user_interaction: Option<String>,
608}
609
610impl common::Part for CVSSv3 {}
611
612/// The category to which the update belongs.
613///
614/// This type is not used in any activity, and only used as *part* of another schema.
615///
616#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
617#[serde_with::serde_as]
618#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
619pub struct Category {
620 /// The identifier of the category.
621 #[serde(rename = "categoryId")]
622 pub category_id: Option<String>,
623 /// The localized name of the category.
624 pub name: Option<String>,
625}
626
627impl common::Part for Category {}
628
629/// A compliance check that is a CIS benchmark.
630///
631/// This type is not used in any activity, and only used as *part* of another schema.
632///
633#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
634#[serde_with::serde_as]
635#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
636pub struct CisBenchmark {
637 /// no description provided
638 #[serde(rename = "profileLevel")]
639 pub profile_level: Option<i32>,
640 /// no description provided
641 pub severity: Option<String>,
642}
643
644impl common::Part for CisBenchmark {}
645
646/// A CloudRepoSourceContext denotes a particular revision in a Google Cloud Source Repo.
647///
648/// This type is not used in any activity, and only used as *part* of another schema.
649///
650#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
651#[serde_with::serde_as]
652#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
653pub struct CloudRepoSourceContext {
654 /// An alias, which may be a branch or tag.
655 #[serde(rename = "aliasContext")]
656 pub alias_context: Option<AliasContext>,
657 /// The ID of the repo.
658 #[serde(rename = "repoId")]
659 pub repo_id: Option<RepoId>,
660 /// A revision ID.
661 #[serde(rename = "revisionId")]
662 pub revision_id: Option<String>,
663}
664
665impl common::Part for CloudRepoSourceContext {}
666
667/// Empty placeholder to denote that this is a Google Cloud Storage export request.
668///
669/// This type is not used in any activity, and only used as *part* of another schema.
670///
671#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
672#[serde_with::serde_as]
673#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
674pub struct CloudStorageLocation {
675 _never_set: Option<bool>,
676}
677
678impl common::Part for CloudStorageLocation {}
679
680/// Command describes a step performed as part of the build pipeline.
681///
682/// This type is not used in any activity, and only used as *part* of another schema.
683///
684#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
685#[serde_with::serde_as]
686#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
687pub struct Command {
688 /// Command-line arguments used when executing this command.
689 pub args: Option<Vec<String>>,
690 /// Working directory (relative to project source root) used when running this command.
691 pub dir: Option<String>,
692 /// Environment variables set before running this command.
693 pub env: Option<Vec<String>>,
694 /// Optional unique identifier for this command, used in wait_for to reference this command as a dependency.
695 pub id: Option<String>,
696 /// Required. Name of the command, as presented on the command line, or if the command is packaged as a Docker container, as presented to `docker pull`.
697 pub name: Option<String>,
698 /// The ID(s) of the command(s) that this command depends on.
699 #[serde(rename = "waitFor")]
700 pub wait_for: Option<Vec<String>>,
701}
702
703impl common::Part for Command {}
704
705/// Indicates that the builder claims certain fields in this message to be complete.
706///
707/// This type is not used in any activity, and only used as *part* of another schema.
708///
709#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
710#[serde_with::serde_as]
711#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
712pub struct Completeness {
713 /// If true, the builder claims that recipe.arguments is complete, meaning that all external inputs are properly captured in the recipe.
714 pub arguments: Option<bool>,
715 /// If true, the builder claims that recipe.environment is claimed to be complete.
716 pub environment: Option<bool>,
717 /// If true, the builder claims that materials are complete, usually through some controls to prevent network access. Sometimes called "hermetic".
718 pub materials: Option<bool>,
719}
720
721impl common::Part for Completeness {}
722
723/// There is no detailed description.
724///
725/// This type is not used in any activity, and only used as *part* of another schema.
726///
727#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
728#[serde_with::serde_as]
729#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
730pub struct ComplianceNote {
731 /// no description provided
732 #[serde(rename = "cisBenchmark")]
733 pub cis_benchmark: Option<CisBenchmark>,
734 /// A description about this compliance check.
735 pub description: Option<String>,
736 /// no description provided
737 pub impact: Option<String>,
738 /// A rationale for the existence of this compliance check.
739 pub rationale: Option<String>,
740 /// A description of remediation steps if the compliance check fails.
741 pub remediation: Option<String>,
742 /// Serialized scan instructions with a predefined format.
743 #[serde(rename = "scanInstructions")]
744 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
745 pub scan_instructions: Option<Vec<u8>>,
746 /// The title that identifies this compliance check.
747 pub title: Option<String>,
748 /// The OS and config versions the benchmark applies to.
749 pub version: Option<Vec<ComplianceVersion>>,
750}
751
752impl common::Part for ComplianceNote {}
753
754/// An indication that the compliance checks in the associated ComplianceNote were not satisfied for particular resources or a specified reason.
755///
756/// This type is not used in any activity, and only used as *part* of another schema.
757///
758#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
759#[serde_with::serde_as]
760#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
761pub struct ComplianceOccurrence {
762 /// no description provided
763 #[serde(rename = "nonComplianceReason")]
764 pub non_compliance_reason: Option<String>,
765 /// no description provided
766 #[serde(rename = "nonCompliantFiles")]
767 pub non_compliant_files: Option<Vec<NonCompliantFile>>,
768 /// The OS and config version the benchmark was run on.
769 pub version: Option<ComplianceVersion>,
770}
771
772impl common::Part for ComplianceOccurrence {}
773
774/// Describes the CIS benchmark version that is applicable to a given OS and os version.
775///
776/// This type is not used in any activity, and only used as *part* of another schema.
777///
778#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
779#[serde_with::serde_as]
780#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
781pub struct ComplianceVersion {
782 /// The name of the document that defines this benchmark, e.g. "CIS Container-Optimized OS".
783 #[serde(rename = "benchmarkDocument")]
784 pub benchmark_document: Option<String>,
785 /// The CPE URI (https://cpe.mitre.org/specification/) this benchmark is applicable to.
786 #[serde(rename = "cpeUri")]
787 pub cpe_uri: Option<String>,
788 /// The version of the benchmark. This is set to the version of the OS-specific CIS document the benchmark is defined in.
789 pub version: Option<String>,
790}
791
792impl common::Part for ComplianceVersion {}
793
794/// There is no detailed description.
795///
796/// This type is not used in any activity, and only used as *part* of another schema.
797///
798#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
799#[serde_with::serde_as]
800#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
801pub struct DSSEAttestationNote {
802 /// DSSEHint hints at the purpose of the attestation authority.
803 pub hint: Option<DSSEHint>,
804}
805
806impl common::Part for DSSEAttestationNote {}
807
808/// Deprecated. Prefer to use a regular Occurrence, and populate the Envelope at the top level of the Occurrence.
809///
810/// This type is not used in any activity, and only used as *part* of another schema.
811///
812#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
813#[serde_with::serde_as]
814#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
815pub struct DSSEAttestationOccurrence {
816 /// If doing something security critical, make sure to verify the signatures in this metadata.
817 pub envelope: Option<Envelope>,
818 /// no description provided
819 pub statement: Option<InTotoStatement>,
820}
821
822impl common::Part for DSSEAttestationOccurrence {}
823
824/// This submessage provides human-readable hints about the purpose of the authority. Because the name of a note acts as its resource reference, it is important to disambiguate the canonical name of the Note (which might be a UUID for security purposes) from "readable" names more suitable for debug output. Note that these hints should not be used to look up authorities in security sensitive contexts, such as when looking up attestations to verify.
825///
826/// This type is not used in any activity, and only used as *part* of another schema.
827///
828#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
829#[serde_with::serde_as]
830#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
831pub struct DSSEHint {
832 /// Required. The human readable name of this attestation authority, for example "cloudbuild-prod".
833 #[serde(rename = "humanReadableName")]
834 pub human_readable_name: Option<String>,
835}
836
837impl common::Part for DSSEHint {}
838
839/// An artifact that can be deployed in some runtime.
840///
841/// This type is not used in any activity, and only used as *part* of another schema.
842///
843#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
844#[serde_with::serde_as]
845#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
846pub struct DeploymentNote {
847 /// Required. Resource URI for the artifact being deployed.
848 #[serde(rename = "resourceUri")]
849 pub resource_uri: Option<Vec<String>>,
850}
851
852impl common::Part for DeploymentNote {}
853
854/// The period during which some deployable was active in a runtime.
855///
856/// This type is not used in any activity, and only used as *part* of another schema.
857///
858#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
859#[serde_with::serde_as]
860#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
861pub struct DeploymentOccurrence {
862 /// Address of the runtime element hosting this deployment.
863 pub address: Option<String>,
864 /// Configuration used to create this deployment.
865 pub config: Option<String>,
866 /// Required. Beginning of the lifetime of this deployment.
867 #[serde(rename = "deployTime")]
868 pub deploy_time: Option<chrono::DateTime<chrono::offset::Utc>>,
869 /// Platform hosting this deployment.
870 pub platform: Option<String>,
871 /// Output only. Resource URI for the artifact being deployed taken from the deployable field with the same name.
872 #[serde(rename = "resourceUri")]
873 pub resource_uri: Option<Vec<String>>,
874 /// End of the lifetime of this deployment.
875 #[serde(rename = "undeployTime")]
876 pub undeploy_time: Option<chrono::DateTime<chrono::offset::Utc>>,
877 /// Identity of the user that triggered this deployment.
878 #[serde(rename = "userEmail")]
879 pub user_email: Option<String>,
880}
881
882impl common::Part for DeploymentOccurrence {}
883
884/// A detail for a distro and package affected by this vulnerability and its associated fix (if one is available).
885///
886/// This type is not used in any activity, and only used as *part* of another schema.
887///
888#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
889#[serde_with::serde_as]
890#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
891pub struct Detail {
892 /// Required. The [CPE URI](https://cpe.mitre.org/specification/) this vulnerability affects.
893 #[serde(rename = "affectedCpeUri")]
894 pub affected_cpe_uri: Option<String>,
895 /// Required. The package this vulnerability affects.
896 #[serde(rename = "affectedPackage")]
897 pub affected_package: Option<String>,
898 /// The version number at the end of an interval in which this vulnerability exists. A vulnerability can affect a package between version numbers that are disjoint sets of intervals (example: [1.0.0-1.1.0], [2.4.6-2.4.8] and [4.5.6-4.6.8]) each of which will be represented in its own Detail. If a specific affected version is provided by a vulnerability database, affected_version_start and affected_version_end will be the same in that Detail.
899 #[serde(rename = "affectedVersionEnd")]
900 pub affected_version_end: Option<Version>,
901 /// The version number at the start of an interval in which this vulnerability exists. A vulnerability can affect a package between version numbers that are disjoint sets of intervals (example: [1.0.0-1.1.0], [2.4.6-2.4.8] and [4.5.6-4.6.8]) each of which will be represented in its own Detail. If a specific affected version is provided by a vulnerability database, affected_version_start and affected_version_end will be the same in that Detail.
902 #[serde(rename = "affectedVersionStart")]
903 pub affected_version_start: Option<Version>,
904 /// A vendor-specific description of this vulnerability.
905 pub description: Option<String>,
906 /// The distro recommended [CPE URI](https://cpe.mitre.org/specification/) to update to that contains a fix for this vulnerability. It is possible for this to be different from the affected_cpe_uri.
907 #[serde(rename = "fixedCpeUri")]
908 pub fixed_cpe_uri: Option<String>,
909 /// The distro recommended package to update to that contains a fix for this vulnerability. It is possible for this to be different from the affected_package.
910 #[serde(rename = "fixedPackage")]
911 pub fixed_package: Option<String>,
912 /// The distro recommended version to update to that contains a fix for this vulnerability. Setting this to VersionKind.MAXIMUM means no such version is yet available.
913 #[serde(rename = "fixedVersion")]
914 pub fixed_version: Option<Version>,
915 /// Whether this detail is obsolete. Occurrences are expected not to point to obsolete details.
916 #[serde(rename = "isObsolete")]
917 pub is_obsolete: Option<bool>,
918 /// The type of package; whether native or non native (e.g., ruby gems, node.js packages, etc.).
919 #[serde(rename = "packageType")]
920 pub package_type: Option<String>,
921 /// The distro assigned severity of this vulnerability.
922 #[serde(rename = "severityName")]
923 pub severity_name: Option<String>,
924 /// The source from which the information in this Detail was obtained.
925 pub source: Option<String>,
926 /// The time this information was last changed at the source. This is an upstream timestamp from the underlying information source - e.g. Ubuntu security tracker.
927 #[serde(rename = "sourceUpdateTime")]
928 pub source_update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
929 /// The name of the vendor of the product.
930 pub vendor: Option<String>,
931}
932
933impl common::Part for Detail {}
934
935/// Digest information.
936///
937/// This type is not used in any activity, and only used as *part* of another schema.
938///
939#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
940#[serde_with::serde_as]
941#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
942pub struct Digest {
943 /// `SHA1`, `SHA512` etc.
944 pub algo: Option<String>,
945 /// Value of the digest.
946 #[serde(rename = "digestBytes")]
947 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
948 pub digest_bytes: Option<Vec<u8>>,
949}
950
951impl common::Part for Digest {}
952
953/// A note that indicates a type of analysis a provider would perform. This note exists in a provider's project. A `Discovery` occurrence is created in a consumer's project at the start of analysis.
954///
955/// This type is not used in any activity, and only used as *part* of another schema.
956///
957#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
958#[serde_with::serde_as]
959#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
960pub struct DiscoveryNote {
961 /// Required. Immutable. The kind of analysis that is handled by this discovery.
962 #[serde(rename = "analysisKind")]
963 pub analysis_kind: Option<String>,
964}
965
966impl common::Part for DiscoveryNote {}
967
968/// Provides information about the analysis status of a discovered resource.
969///
970/// This type is not used in any activity, and only used as *part* of another schema.
971///
972#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
973#[serde_with::serde_as]
974#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
975pub struct DiscoveryOccurrence {
976 /// no description provided
977 #[serde(rename = "analysisCompleted")]
978 pub analysis_completed: Option<AnalysisCompleted>,
979 /// Indicates any errors encountered during analysis of a resource. There could be 0 or more of these errors.
980 #[serde(rename = "analysisError")]
981 pub analysis_error: Option<Vec<Status>>,
982 /// The status of discovery for the resource.
983 #[serde(rename = "analysisStatus")]
984 pub analysis_status: Option<String>,
985 /// When an error is encountered this will contain a LocalizedMessage under details to show to the user. The LocalizedMessage is output only and populated by the API.
986 #[serde(rename = "analysisStatusError")]
987 pub analysis_status_error: Option<Status>,
988 /// Output only. The time occurrences related to this discovery occurrence were archived.
989 #[serde(rename = "archiveTime")]
990 pub archive_time: Option<chrono::DateTime<chrono::offset::Utc>>,
991 /// Whether the resource is continuously analyzed.
992 #[serde(rename = "continuousAnalysis")]
993 pub continuous_analysis: Option<String>,
994 /// The CPE of the resource being scanned.
995 pub cpe: Option<String>,
996 /// The last time this resource was scanned.
997 #[serde(rename = "lastScanTime")]
998 pub last_scan_time: Option<chrono::DateTime<chrono::offset::Utc>>,
999 /// The status of an SBOM generation.
1000 #[serde(rename = "sbomStatus")]
1001 pub sbom_status: Option<SBOMStatus>,
1002 /// The status of an vulnerability attestation generation.
1003 #[serde(rename = "vulnerabilityAttestation")]
1004 pub vulnerability_attestation: Option<VulnerabilityAttestation>,
1005}
1006
1007impl common::Part for DiscoveryOccurrence {}
1008
1009/// This represents a particular channel of distribution for a given package. E.g., Debian's jessie-backports dpkg mirror.
1010///
1011/// This type is not used in any activity, and only used as *part* of another schema.
1012///
1013#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1014#[serde_with::serde_as]
1015#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1016pub struct Distribution {
1017 /// The CPU architecture for which packages in this distribution channel were built.
1018 pub architecture: Option<String>,
1019 /// Required. The cpe_uri in [CPE format](https://cpe.mitre.org/specification/) denoting the package manager version distributing a package.
1020 #[serde(rename = "cpeUri")]
1021 pub cpe_uri: Option<String>,
1022 /// The distribution channel-specific description of this package.
1023 pub description: Option<String>,
1024 /// The latest available version of this package in this distribution channel.
1025 #[serde(rename = "latestVersion")]
1026 pub latest_version: Option<Version>,
1027 /// A freeform string denoting the maintainer of this package.
1028 pub maintainer: Option<String>,
1029 /// The distribution channel-specific homepage for this package.
1030 pub url: Option<String>,
1031}
1032
1033impl common::Part for Distribution {}
1034
1035/// 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); }
1036///
1037/// # Activities
1038///
1039/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1040/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1041///
1042/// * [notes delete projects](ProjectNoteDeleteCall) (response)
1043/// * [occurrences delete projects](ProjectOccurrenceDeleteCall) (response)
1044#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1045#[serde_with::serde_as]
1046#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1047pub struct Empty {
1048 _never_set: Option<bool>,
1049}
1050
1051impl common::ResponseResult for Empty {}
1052
1053/// MUST match https://github.com/secure-systems-lab/dsse/blob/master/envelope.proto. An authenticated message of arbitrary type.
1054///
1055/// This type is not used in any activity, and only used as *part* of another schema.
1056///
1057#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1058#[serde_with::serde_as]
1059#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1060pub struct Envelope {
1061 /// no description provided
1062 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1063 pub payload: Option<Vec<u8>>,
1064 /// no description provided
1065 #[serde(rename = "payloadType")]
1066 pub payload_type: Option<String>,
1067 /// no description provided
1068 pub signatures: Option<Vec<EnvelopeSignature>>,
1069}
1070
1071impl common::Part for Envelope {}
1072
1073/// There is no detailed description.
1074///
1075/// This type is not used in any activity, and only used as *part* of another schema.
1076///
1077#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1078#[serde_with::serde_as]
1079#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1080pub struct EnvelopeSignature {
1081 /// no description provided
1082 pub keyid: Option<String>,
1083 /// no description provided
1084 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1085 pub sig: Option<Vec<u8>>,
1086}
1087
1088impl common::Part for EnvelopeSignature {}
1089
1090/// The request to generate and export SBOM. Target must be specified for the request.
1091///
1092/// # Activities
1093///
1094/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1095/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1096///
1097/// * [locations resources export sbom projects](ProjectLocationResourceExportSBOMCall) (request)
1098/// * [resources export sbom projects](ProjectResourceExportSBOMCall) (request)
1099#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1100#[serde_with::serde_as]
1101#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1102pub struct ExportSBOMRequest {
1103 /// Empty placeholder to denote that this is a Google Cloud Storage export request.
1104 #[serde(rename = "cloudStorageLocation")]
1105 pub cloud_storage_location: Option<CloudStorageLocation>,
1106}
1107
1108impl common::RequestValue for ExportSBOMRequest {}
1109
1110/// The response from a call to ExportSBOM.
1111///
1112/// # Activities
1113///
1114/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1115/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1116///
1117/// * [locations resources export sbom projects](ProjectLocationResourceExportSBOMCall) (response)
1118/// * [resources export sbom projects](ProjectResourceExportSBOMCall) (response)
1119#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1120#[serde_with::serde_as]
1121#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1122pub struct ExportSBOMResponse {
1123 /// The name of the discovery occurrence in the form "projects/{project_id}/occurrences/{OCCURRENCE_ID} It can be used to track the progress of the SBOM export.
1124 #[serde(rename = "discoveryOccurrence")]
1125 pub discovery_occurrence: Option<String>,
1126}
1127
1128impl common::ResponseResult for ExportSBOMResponse {}
1129
1130/// Represents a textual expression in the Common Expression Language (CEL) syntax. CEL is a C-like expression language. The syntax and semantics of CEL are documented at https://github.com/google/cel-spec. Example (Comparison): title: "Summary size limit" description: "Determines if a summary is less than 100 chars" expression: "document.summary.size() < 100" Example (Equality): title: "Requestor is owner" description: "Determines if requestor is the document owner" expression: "document.owner == request.auth.claims.email" Example (Logic): title: "Public documents" description: "Determine whether the document should be publicly visible" expression: "document.type != 'private' && document.type != 'internal'" Example (Data Manipulation): title: "Notification string" description: "Create a notification string with a timestamp." expression: "'New message received at ' + string(document.create_time)" The exact variables and functions that may be referenced within an expression are determined by the service that evaluates it. See the service documentation for additional information.
1131///
1132/// This type is not used in any activity, and only used as *part* of another schema.
1133///
1134#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1135#[serde_with::serde_as]
1136#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1137pub struct Expr {
1138 /// Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.
1139 pub description: Option<String>,
1140 /// Textual representation of an expression in Common Expression Language syntax.
1141 pub expression: Option<String>,
1142 /// Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.
1143 pub location: Option<String>,
1144 /// Optional. Title for the expression, i.e. a short string describing its purpose. This can be used e.g. in UIs which allow to enter the expression.
1145 pub title: Option<String>,
1146}
1147
1148impl common::Part for Expr {}
1149
1150/// Container message for hashes of byte content of files, used in source messages to verify integrity of source input to the build.
1151///
1152/// This type is not used in any activity, and only used as *part* of another schema.
1153///
1154#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1155#[serde_with::serde_as]
1156#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1157pub struct FileHashes {
1158 /// Required. Collection of file hashes.
1159 #[serde(rename = "fileHash")]
1160 pub file_hash: Option<Vec<Hash>>,
1161}
1162
1163impl common::Part for FileHashes {}
1164
1165/// A set of properties that uniquely identify a given Docker image.
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 Fingerprint {
1173 /// Required. The layer ID of the final layer in the Docker image's v1 representation.
1174 #[serde(rename = "v1Name")]
1175 pub v1_name: Option<String>,
1176 /// Required. The ordered list of v2 blobs that represent a given image.
1177 #[serde(rename = "v2Blob")]
1178 pub v2_blob: Option<Vec<String>>,
1179 /// Output only. The name of the image's v2 blobs computed via: [bottom] := v2_blobbottom := sha256(v2_blob[N] + " " + v2_name[N+1]) Only the name of the final blob is kept.
1180 #[serde(rename = "v2Name")]
1181 pub v2_name: Option<String>,
1182}
1183
1184impl common::Part for Fingerprint {}
1185
1186/// Per resource and severity counts of fixable and total vulnerabilities.
1187///
1188/// This type is not used in any activity, and only used as *part* of another schema.
1189///
1190#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1191#[serde_with::serde_as]
1192#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1193pub struct FixableTotalByDigest {
1194 /// The number of fixable vulnerabilities associated with this resource.
1195 #[serde(rename = "fixableCount")]
1196 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1197 pub fixable_count: Option<i64>,
1198 /// The affected resource.
1199 #[serde(rename = "resourceUri")]
1200 pub resource_uri: Option<String>,
1201 /// The severity for this count. SEVERITY_UNSPECIFIED indicates total across all severities.
1202 pub severity: Option<String>,
1203 /// The total number of vulnerabilities associated with this resource.
1204 #[serde(rename = "totalCount")]
1205 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1206 pub total_count: Option<i64>,
1207}
1208
1209impl common::Part for FixableTotalByDigest {}
1210
1211/// A SourceContext referring to a Gerrit project.
1212///
1213/// This type is not used in any activity, and only used as *part* of another schema.
1214///
1215#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1216#[serde_with::serde_as]
1217#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1218pub struct GerritSourceContext {
1219 /// An alias, which may be a branch or tag.
1220 #[serde(rename = "aliasContext")]
1221 pub alias_context: Option<AliasContext>,
1222 /// The full project name within the host. Projects may be nested, so "project/subproject" is a valid project name. The "repo name" is the hostURI/project.
1223 #[serde(rename = "gerritProject")]
1224 pub gerrit_project: Option<String>,
1225 /// The URI of a running Gerrit instance.
1226 #[serde(rename = "hostUri")]
1227 pub host_uri: Option<String>,
1228 /// A revision (commit) ID.
1229 #[serde(rename = "revisionId")]
1230 pub revision_id: Option<String>,
1231}
1232
1233impl common::Part for GerritSourceContext {}
1234
1235/// Request message for `GetIamPolicy` method.
1236///
1237/// # Activities
1238///
1239/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1240/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1241///
1242/// * [notes get iam policy projects](ProjectNoteGetIamPolicyCall) (request)
1243/// * [occurrences get iam policy projects](ProjectOccurrenceGetIamPolicyCall) (request)
1244#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1245#[serde_with::serde_as]
1246#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1247pub struct GetIamPolicyRequest {
1248 /// OPTIONAL: A `GetPolicyOptions` object for specifying options to `GetIamPolicy`.
1249 pub options: Option<GetPolicyOptions>,
1250}
1251
1252impl common::RequestValue for GetIamPolicyRequest {}
1253
1254/// Encapsulates settings provided to GetIamPolicy.
1255///
1256/// This type is not used in any activity, and only used as *part* of another schema.
1257///
1258#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1259#[serde_with::serde_as]
1260#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1261pub struct GetPolicyOptions {
1262 /// Optional. The maximum policy version that will be used to format the policy. Valid values are 0, 1, and 3. Requests specifying an invalid value will be rejected. Requests for policies with any conditional role bindings must specify version 3. Policies with no conditional role bindings may specify any valid value or leave the field unset. The policy in the response might use the policy version that you specified, or it might use a lower policy version. For example, if you specify version 3, but the policy has no conditional role bindings, the response uses version 1. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
1263 #[serde(rename = "requestedPolicyVersion")]
1264 pub requested_policy_version: Option<i32>,
1265}
1266
1267impl common::Part for GetPolicyOptions {}
1268
1269/// A GitSourceContext denotes a particular revision in a third party Git repository (e.g., GitHub).
1270///
1271/// This type is not used in any activity, and only used as *part* of another schema.
1272///
1273#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1274#[serde_with::serde_as]
1275#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1276pub struct GitSourceContext {
1277 /// Git commit hash.
1278 #[serde(rename = "revisionId")]
1279 pub revision_id: Option<String>,
1280 /// Git repository URL.
1281 pub url: Option<String>,
1282}
1283
1284impl common::Part for GitSourceContext {}
1285
1286/// Indicates the location at which a package was found.
1287///
1288/// This type is not used in any activity, and only used as *part* of another schema.
1289///
1290#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1291#[serde_with::serde_as]
1292#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1293pub struct GrafeasV1FileLocation {
1294 /// For jars that are contained inside .war files, this filepath can indicate the path to war file combined with the path to jar file.
1295 #[serde(rename = "filePath")]
1296 pub file_path: Option<String>,
1297}
1298
1299impl common::Part for GrafeasV1FileLocation {}
1300
1301/// Identifies the entity that executed the recipe, which is trusted to have correctly performed the operation and populated this provenance.
1302///
1303/// This type is not used in any activity, and only used as *part* of another schema.
1304///
1305#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1306#[serde_with::serde_as]
1307#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1308pub struct GrafeasV1SlsaProvenanceZeroTwoSlsaBuilder {
1309 /// no description provided
1310 pub id: Option<String>,
1311}
1312
1313impl common::Part for GrafeasV1SlsaProvenanceZeroTwoSlsaBuilder {}
1314
1315/// Indicates that the builder claims certain fields in this message to be complete.
1316///
1317/// This type is not used in any activity, and only used as *part* of another schema.
1318///
1319#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1320#[serde_with::serde_as]
1321#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1322pub struct GrafeasV1SlsaProvenanceZeroTwoSlsaCompleteness {
1323 /// no description provided
1324 pub environment: Option<bool>,
1325 /// no description provided
1326 pub materials: Option<bool>,
1327 /// no description provided
1328 pub parameters: Option<bool>,
1329}
1330
1331impl common::Part for GrafeasV1SlsaProvenanceZeroTwoSlsaCompleteness {}
1332
1333/// Describes where the config file that kicked off the build came from. This is effectively a pointer to the source where buildConfig came from.
1334///
1335/// This type is not used in any activity, and only used as *part* of another schema.
1336///
1337#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1338#[serde_with::serde_as]
1339#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1340pub struct GrafeasV1SlsaProvenanceZeroTwoSlsaConfigSource {
1341 /// no description provided
1342 pub digest: Option<HashMap<String, String>>,
1343 /// no description provided
1344 #[serde(rename = "entryPoint")]
1345 pub entry_point: Option<String>,
1346 /// no description provided
1347 pub uri: Option<String>,
1348}
1349
1350impl common::Part for GrafeasV1SlsaProvenanceZeroTwoSlsaConfigSource {}
1351
1352/// Identifies the event that kicked off the build.
1353///
1354/// This type is not used in any activity, and only used as *part* of another schema.
1355///
1356#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1357#[serde_with::serde_as]
1358#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1359pub struct GrafeasV1SlsaProvenanceZeroTwoSlsaInvocation {
1360 /// no description provided
1361 #[serde(rename = "configSource")]
1362 pub config_source: Option<GrafeasV1SlsaProvenanceZeroTwoSlsaConfigSource>,
1363 /// no description provided
1364 pub environment: Option<HashMap<String, serde_json::Value>>,
1365 /// no description provided
1366 pub parameters: Option<HashMap<String, serde_json::Value>>,
1367}
1368
1369impl common::Part for GrafeasV1SlsaProvenanceZeroTwoSlsaInvocation {}
1370
1371/// The collection of artifacts that influenced the build including sources, dependencies, build tools, base images, and so on.
1372///
1373/// This type is not used in any activity, and only used as *part* of another schema.
1374///
1375#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1376#[serde_with::serde_as]
1377#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1378pub struct GrafeasV1SlsaProvenanceZeroTwoSlsaMaterial {
1379 /// no description provided
1380 pub digest: Option<HashMap<String, String>>,
1381 /// no description provided
1382 pub uri: Option<String>,
1383}
1384
1385impl common::Part for GrafeasV1SlsaProvenanceZeroTwoSlsaMaterial {}
1386
1387/// Other properties of the build.
1388///
1389/// This type is not used in any activity, and only used as *part* of another schema.
1390///
1391#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1392#[serde_with::serde_as]
1393#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1394pub struct GrafeasV1SlsaProvenanceZeroTwoSlsaMetadata {
1395 /// no description provided
1396 #[serde(rename = "buildFinishedOn")]
1397 pub build_finished_on: Option<chrono::DateTime<chrono::offset::Utc>>,
1398 /// no description provided
1399 #[serde(rename = "buildInvocationId")]
1400 pub build_invocation_id: Option<String>,
1401 /// no description provided
1402 #[serde(rename = "buildStartedOn")]
1403 pub build_started_on: Option<chrono::DateTime<chrono::offset::Utc>>,
1404 /// no description provided
1405 pub completeness: Option<GrafeasV1SlsaProvenanceZeroTwoSlsaCompleteness>,
1406 /// no description provided
1407 pub reproducible: Option<bool>,
1408}
1409
1410impl common::Part for GrafeasV1SlsaProvenanceZeroTwoSlsaMetadata {}
1411
1412/// Container message for hash values.
1413///
1414/// This type is not used in any activity, and only used as *part* of another schema.
1415///
1416#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1417#[serde_with::serde_as]
1418#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1419pub struct Hash {
1420 /// Required. The type of hash that was performed, e.g. "SHA-256".
1421 #[serde(rename = "type")]
1422 pub type_: Option<String>,
1423 /// Required. The hash value.
1424 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1425 pub value: Option<Vec<u8>>,
1426}
1427
1428impl common::Part for Hash {}
1429
1430/// This submessage provides human-readable hints about the purpose of the authority. Because the name of a note acts as its resource reference, it is important to disambiguate the canonical name of the Note (which might be a UUID for security purposes) from "readable" names more suitable for debug output. Note that these hints should not be used to look up authorities in security sensitive contexts, such as when looking up attestations to verify.
1431///
1432/// This type is not used in any activity, and only used as *part* of another schema.
1433///
1434#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1435#[serde_with::serde_as]
1436#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1437pub struct Hint {
1438 /// Required. The human readable name of this attestation authority, for example "qa".
1439 #[serde(rename = "humanReadableName")]
1440 pub human_readable_name: Option<String>,
1441}
1442
1443impl common::Part for Hint {}
1444
1445/// The unique identifier of the update.
1446///
1447/// This type is not used in any activity, and only used as *part* of another schema.
1448///
1449#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1450#[serde_with::serde_as]
1451#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1452pub struct Identity {
1453 /// The revision number of the update.
1454 pub revision: Option<i32>,
1455 /// The revision independent identifier of the update.
1456 #[serde(rename = "updateId")]
1457 pub update_id: Option<String>,
1458}
1459
1460impl common::Part for Identity {}
1461
1462/// Basis describes the base image portion (Note) of the DockerImage relationship. Linked occurrences are derived from this or an equivalent image via: FROM Or an equivalent reference, e.g., a tag of the resource_url.
1463///
1464/// This type is not used in any activity, and only used as *part* of another schema.
1465///
1466#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1467#[serde_with::serde_as]
1468#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1469pub struct ImageNote {
1470 /// Required. Immutable. The fingerprint of the base image.
1471 pub fingerprint: Option<Fingerprint>,
1472 /// Required. Immutable. The resource_url for the resource representing the basis of associated occurrence images.
1473 #[serde(rename = "resourceUrl")]
1474 pub resource_url: Option<String>,
1475}
1476
1477impl common::Part for ImageNote {}
1478
1479/// Details of the derived image portion of the DockerImage relationship. This image would be produced from a Dockerfile with FROM .
1480///
1481/// This type is not used in any activity, and only used as *part* of another schema.
1482///
1483#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1484#[serde_with::serde_as]
1485#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1486pub struct ImageOccurrence {
1487 /// Output only. This contains the base image URL for the derived image occurrence.
1488 #[serde(rename = "baseResourceUrl")]
1489 pub base_resource_url: Option<String>,
1490 /// Output only. The number of layers by which this image differs from the associated image basis.
1491 pub distance: Option<i32>,
1492 /// Required. The fingerprint of the derived image.
1493 pub fingerprint: Option<Fingerprint>,
1494 /// This contains layer-specific metadata, if populated it has length "distance" and is ordered with [distance] being the layer immediately following the base image and [1] being the final layer.
1495 #[serde(rename = "layerInfo")]
1496 pub layer_info: Option<Vec<Layer>>,
1497}
1498
1499impl common::Part for ImageOccurrence {}
1500
1501/// There is no detailed description.
1502///
1503/// This type is not used in any activity, and only used as *part* of another schema.
1504///
1505#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1506#[serde_with::serde_as]
1507#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1508pub struct InTotoProvenance {
1509 /// required
1510 #[serde(rename = "builderConfig")]
1511 pub builder_config: Option<BuilderConfig>,
1512 /// The collection of artifacts that influenced the build including sources, dependencies, build tools, base images, and so on. This is considered to be incomplete unless metadata.completeness.materials is true. Unset or null is equivalent to empty.
1513 pub materials: Option<Vec<String>>,
1514 /// no description provided
1515 pub metadata: Option<Metadata>,
1516 /// Identifies the configuration used for the build. When combined with materials, this SHOULD fully describe the build, such that re-running this recipe results in bit-for-bit identical output (if the build is reproducible). required
1517 pub recipe: Option<Recipe>,
1518}
1519
1520impl common::Part for InTotoProvenance {}
1521
1522/// There is no detailed description.
1523///
1524/// This type is not used in any activity, and only used as *part* of another schema.
1525///
1526#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1527#[serde_with::serde_as]
1528#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1529pub struct InTotoSlsaProvenanceV1 {
1530 /// InToto spec defined at https://github.com/in-toto/attestation/tree/main/spec#statement
1531 pub _type: Option<String>,
1532 /// no description provided
1533 pub predicate: Option<SlsaProvenanceV1>,
1534 /// no description provided
1535 #[serde(rename = "predicateType")]
1536 pub predicate_type: Option<String>,
1537 /// no description provided
1538 pub subject: Option<Vec<Subject>>,
1539}
1540
1541impl common::Part for InTotoSlsaProvenanceV1 {}
1542
1543/// Spec defined at https://github.com/in-toto/attestation/tree/main/spec#statement The serialized InTotoStatement will be stored as Envelope.payload. Envelope.payloadType is always "application/vnd.in-toto+json".
1544///
1545/// This type is not used in any activity, and only used as *part* of another schema.
1546///
1547#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1548#[serde_with::serde_as]
1549#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1550pub struct InTotoStatement {
1551 /// Always `https://in-toto.io/Statement/v0.1`.
1552 pub _type: Option<String>,
1553 /// `https://slsa.dev/provenance/v0.1` for SlsaProvenance.
1554 #[serde(rename = "predicateType")]
1555 pub predicate_type: Option<String>,
1556 /// no description provided
1557 pub provenance: Option<InTotoProvenance>,
1558 /// no description provided
1559 #[serde(rename = "slsaProvenance")]
1560 pub slsa_provenance: Option<SlsaProvenance>,
1561 /// no description provided
1562 #[serde(rename = "slsaProvenanceZeroTwo")]
1563 pub slsa_provenance_zero_two: Option<SlsaProvenanceZeroTwo>,
1564 /// no description provided
1565 pub subject: Option<Vec<Subject>>,
1566}
1567
1568impl common::Part for InTotoStatement {}
1569
1570/// Justification provides the justification when the state of the assessment if NOT_AFFECTED.
1571///
1572/// This type is not used in any activity, and only used as *part* of another schema.
1573///
1574#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1575#[serde_with::serde_as]
1576#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1577pub struct Justification {
1578 /// Additional details on why this justification was chosen.
1579 pub details: Option<String>,
1580 /// The justification type for this vulnerability.
1581 #[serde(rename = "justificationType")]
1582 pub justification_type: Option<String>,
1583}
1584
1585impl common::Part for Justification {}
1586
1587/// There is no detailed description.
1588///
1589/// This type is not used in any activity, and only used as *part* of another schema.
1590///
1591#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1592#[serde_with::serde_as]
1593#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1594pub struct Jwt {
1595 /// The compact encoding of a JWS, which is always three base64 encoded strings joined by periods. For details, see: https://tools.ietf.org/html/rfc7515.html#section-3.1
1596 #[serde(rename = "compactJwt")]
1597 pub compact_jwt: Option<String>,
1598}
1599
1600impl common::Part for Jwt {}
1601
1602/// There is no detailed description.
1603///
1604/// This type is not used in any activity, and only used as *part* of another schema.
1605///
1606#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1607#[serde_with::serde_as]
1608#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1609pub struct KnowledgeBase {
1610 /// The KB name (generally of the form KB[0-9]+ (e.g., KB123456)).
1611 pub name: Option<String>,
1612 /// A link to the KB in the [Windows update catalog] (https://www.catalog.update.microsoft.com/).
1613 pub url: Option<String>,
1614}
1615
1616impl common::Part for KnowledgeBase {}
1617
1618/// Layer holds metadata specific to a layer of a Docker image.
1619///
1620/// This type is not used in any activity, and only used as *part* of another schema.
1621///
1622#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1623#[serde_with::serde_as]
1624#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1625pub struct Layer {
1626 /// The recovered arguments to the Dockerfile directive.
1627 pub arguments: Option<String>,
1628 /// Required. The recovered Dockerfile directive used to construct this layer. See https://docs.docker.com/engine/reference/builder/ for more information.
1629 pub directive: Option<String>,
1630}
1631
1632impl common::Part for Layer {}
1633
1634/// License information.
1635///
1636/// This type is not used in any activity, and only used as *part* of another schema.
1637///
1638#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1639#[serde_with::serde_as]
1640#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1641pub struct License {
1642 /// Comments
1643 pub comments: Option<String>,
1644 /// Often a single license can be used to represent the licensing terms. Sometimes it is necessary to include a choice of one or more licenses or some combination of license identifiers. Examples: "LGPL-2.1-only OR MIT", "LGPL-2.1-only AND MIT", "GPL-2.0-or-later WITH Bison-exception-2.2".
1645 pub expression: Option<String>,
1646}
1647
1648impl common::Part for License {}
1649
1650/// Response for listing occurrences for a note.
1651///
1652/// # Activities
1653///
1654/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1655/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1656///
1657/// * [locations notes occurrences list projects](ProjectLocationNoteOccurrenceListCall) (response)
1658/// * [notes occurrences list projects](ProjectNoteOccurrenceListCall) (response)
1659#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1660#[serde_with::serde_as]
1661#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1662pub struct ListNoteOccurrencesResponse {
1663 /// Token to provide to skip to a particular spot in the list.
1664 #[serde(rename = "nextPageToken")]
1665 pub next_page_token: Option<String>,
1666 /// The occurrences attached to the specified note.
1667 pub occurrences: Option<Vec<Occurrence>>,
1668}
1669
1670impl common::ResponseResult for ListNoteOccurrencesResponse {}
1671
1672/// Response for listing notes.
1673///
1674/// # Activities
1675///
1676/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1677/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1678///
1679/// * [locations notes list projects](ProjectLocationNoteListCall) (response)
1680/// * [notes list projects](ProjectNoteListCall) (response)
1681#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1682#[serde_with::serde_as]
1683#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1684pub struct ListNotesResponse {
1685 /// The next pagination token in the list response. It should be used as `page_token` for the following request. An empty value means no more results.
1686 #[serde(rename = "nextPageToken")]
1687 pub next_page_token: Option<String>,
1688 /// The notes requested.
1689 pub notes: Option<Vec<Note>>,
1690}
1691
1692impl common::ResponseResult for ListNotesResponse {}
1693
1694/// Response for listing occurrences.
1695///
1696/// # Activities
1697///
1698/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1699/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1700///
1701/// * [locations occurrences list projects](ProjectLocationOccurrenceListCall) (response)
1702/// * [occurrences list projects](ProjectOccurrenceListCall) (response)
1703#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1704#[serde_with::serde_as]
1705#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1706pub struct ListOccurrencesResponse {
1707 /// The next pagination token in the list response. It should be used as `page_token` for the following request. An empty value means no more results.
1708 #[serde(rename = "nextPageToken")]
1709 pub next_page_token: Option<String>,
1710 /// The occurrences requested.
1711 pub occurrences: Option<Vec<Occurrence>>,
1712}
1713
1714impl common::ResponseResult for ListOccurrencesResponse {}
1715
1716/// An occurrence of a particular package installation found within a system's filesystem. E.g., glibc was found in `/var/lib/dpkg/status`.
1717///
1718/// This type is not used in any activity, and only used as *part* of another schema.
1719///
1720#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1721#[serde_with::serde_as]
1722#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1723pub struct Location {
1724 /// Deprecated. The CPE URI in [CPE format](https://cpe.mitre.org/specification/)
1725 #[serde(rename = "cpeUri")]
1726 pub cpe_uri: Option<String>,
1727 /// The path from which we gathered that this package/version is installed.
1728 pub path: Option<String>,
1729 /// Deprecated. The version installed at this location.
1730 pub version: Option<Version>,
1731}
1732
1733impl common::Part for Location {}
1734
1735/// There is no detailed description.
1736///
1737/// This type is not used in any activity, and only used as *part* of another schema.
1738///
1739#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1740#[serde_with::serde_as]
1741#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1742pub struct Material {
1743 /// no description provided
1744 pub digest: Option<HashMap<String, String>>,
1745 /// no description provided
1746 pub uri: Option<String>,
1747}
1748
1749impl common::Part for Material {}
1750
1751/// Other properties of the build.
1752///
1753/// This type is not used in any activity, and only used as *part* of another schema.
1754///
1755#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1756#[serde_with::serde_as]
1757#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1758pub struct Metadata {
1759 /// The timestamp of when the build completed.
1760 #[serde(rename = "buildFinishedOn")]
1761 pub build_finished_on: Option<chrono::DateTime<chrono::offset::Utc>>,
1762 /// Identifies the particular build invocation, which can be useful for finding associated logs or other ad-hoc analysis. The value SHOULD be globally unique, per in-toto Provenance spec.
1763 #[serde(rename = "buildInvocationId")]
1764 pub build_invocation_id: Option<String>,
1765 /// The timestamp of when the build started.
1766 #[serde(rename = "buildStartedOn")]
1767 pub build_started_on: Option<chrono::DateTime<chrono::offset::Utc>>,
1768 /// Indicates that the builder claims certain fields in this message to be complete.
1769 pub completeness: Option<Completeness>,
1770 /// If true, the builder claims that running the recipe on materials will produce bit-for-bit identical output.
1771 pub reproducible: Option<bool>,
1772}
1773
1774impl common::Part for Metadata {}
1775
1776/// Details about files that caused a compliance check to fail. display_command is a single command that can be used to display a list of non compliant files. When there is no such command, we can also iterate a list of non compliant file using 'path'.
1777///
1778/// This type is not used in any activity, and only used as *part* of another schema.
1779///
1780#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1781#[serde_with::serde_as]
1782#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1783pub struct NonCompliantFile {
1784 /// Command to display the non-compliant files.
1785 #[serde(rename = "displayCommand")]
1786 pub display_command: Option<String>,
1787 /// Empty if `display_command` is set.
1788 pub path: Option<String>,
1789 /// Explains why a file is non compliant for a CIS check.
1790 pub reason: Option<String>,
1791}
1792
1793impl common::Part for NonCompliantFile {}
1794
1795/// A type of analysis that can be done for a resource.
1796///
1797/// # Activities
1798///
1799/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1800/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1801///
1802/// * [locations notes get projects](ProjectLocationNoteGetCall) (response)
1803/// * [locations occurrences get notes projects](ProjectLocationOccurrenceGetNoteCall) (response)
1804/// * [notes create projects](ProjectNoteCreateCall) (request|response)
1805/// * [notes get projects](ProjectNoteGetCall) (response)
1806/// * [notes patch projects](ProjectNotePatchCall) (request|response)
1807/// * [occurrences get notes projects](ProjectOccurrenceGetNoteCall) (response)
1808#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1809#[serde_with::serde_as]
1810#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1811pub struct Note {
1812 /// A note describing an attestation role.
1813 pub attestation: Option<AttestationNote>,
1814 /// A note describing build provenance for a verifiable build.
1815 pub build: Option<BuildNote>,
1816 /// A note describing a compliance check.
1817 pub compliance: Option<ComplianceNote>,
1818 /// Output only. The time this note was created. This field can be used as a filter in list requests.
1819 #[serde(rename = "createTime")]
1820 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1821 /// A note describing something that can be deployed.
1822 pub deployment: Option<DeploymentNote>,
1823 /// A note describing the initial analysis of a resource.
1824 pub discovery: Option<DiscoveryNote>,
1825 /// A note describing a dsse attestation note.
1826 #[serde(rename = "dsseAttestation")]
1827 pub dsse_attestation: Option<DSSEAttestationNote>,
1828 /// Time of expiration for this note. Empty if note does not expire.
1829 #[serde(rename = "expirationTime")]
1830 pub expiration_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1831 /// A note describing a base image.
1832 pub image: Option<ImageNote>,
1833 /// Output only. The type of analysis. This field can be used as a filter in list requests.
1834 pub kind: Option<String>,
1835 /// A detailed description of this note.
1836 #[serde(rename = "longDescription")]
1837 pub long_description: Option<String>,
1838 /// Output only. The name of the note in the form of `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.
1839 pub name: Option<String>,
1840 /// A note describing a package hosted by various package managers.
1841 pub package: Option<PackageNote>,
1842 /// Other notes related to this note.
1843 #[serde(rename = "relatedNoteNames")]
1844 pub related_note_names: Option<Vec<String>>,
1845 /// URLs associated with this note.
1846 #[serde(rename = "relatedUrl")]
1847 pub related_url: Option<Vec<RelatedUrl>>,
1848 /// A note describing an SBOM reference.
1849 #[serde(rename = "sbomReference")]
1850 pub sbom_reference: Option<SBOMReferenceNote>,
1851 /// A one sentence description of this note.
1852 #[serde(rename = "shortDescription")]
1853 pub short_description: Option<String>,
1854 /// Output only. The time this note was last updated. This field can be used as a filter in list requests.
1855 #[serde(rename = "updateTime")]
1856 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1857 /// A note describing available package upgrades.
1858 pub upgrade: Option<UpgradeNote>,
1859 /// A note describing a package vulnerability.
1860 pub vulnerability: Option<VulnerabilityNote>,
1861 /// A note describing a vulnerability assessment.
1862 #[serde(rename = "vulnerabilityAssessment")]
1863 pub vulnerability_assessment: Option<VulnerabilityAssessmentNote>,
1864}
1865
1866impl common::RequestValue for Note {}
1867impl common::ResponseResult for Note {}
1868
1869/// An instance of an analysis type that has been found on a resource.
1870///
1871/// # Activities
1872///
1873/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1874/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1875///
1876/// * [locations occurrences get projects](ProjectLocationOccurrenceGetCall) (response)
1877/// * [occurrences create projects](ProjectOccurrenceCreateCall) (request|response)
1878/// * [occurrences get projects](ProjectOccurrenceGetCall) (response)
1879/// * [occurrences patch projects](ProjectOccurrencePatchCall) (request|response)
1880#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1881#[serde_with::serde_as]
1882#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1883pub struct Occurrence {
1884 /// Describes an attestation of an artifact.
1885 pub attestation: Option<AttestationOccurrence>,
1886 /// Describes a verifiable build.
1887 pub build: Option<BuildOccurrence>,
1888 /// Describes a compliance violation on a linked resource.
1889 pub compliance: Option<ComplianceOccurrence>,
1890 /// Output only. The time this occurrence was created.
1891 #[serde(rename = "createTime")]
1892 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1893 /// Describes the deployment of an artifact on a runtime.
1894 pub deployment: Option<DeploymentOccurrence>,
1895 /// Describes when a resource was discovered.
1896 pub discovery: Option<DiscoveryOccurrence>,
1897 /// Describes an attestation of an artifact using dsse.
1898 #[serde(rename = "dsseAttestation")]
1899 pub dsse_attestation: Option<DSSEAttestationOccurrence>,
1900 /// https://github.com/secure-systems-lab/dsse
1901 pub envelope: Option<Envelope>,
1902 /// Describes how this resource derives from the basis in the associated note.
1903 pub image: Option<ImageOccurrence>,
1904 /// Output only. This explicitly denotes which of the occurrence details are specified. This field can be used as a filter in list requests.
1905 pub kind: Option<String>,
1906 /// Output only. The name of the occurrence in the form of `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.
1907 pub name: Option<String>,
1908 /// Required. Immutable. The analysis note associated with this occurrence, in the form of `projects/[PROVIDER_ID]/notes/[NOTE_ID]`. This field can be used as a filter in list requests.
1909 #[serde(rename = "noteName")]
1910 pub note_name: Option<String>,
1911 /// Describes the installation of a package on the linked resource.
1912 pub package: Option<PackageOccurrence>,
1913 /// A description of actions that can be taken to remedy the note.
1914 pub remediation: Option<String>,
1915 /// Required. Immutable. A URI that represents the resource for which the occurrence applies. For example, `https://gcr.io/project/image@sha256:123abc` for a Docker image.
1916 #[serde(rename = "resourceUri")]
1917 pub resource_uri: Option<String>,
1918 /// Describes a specific SBOM reference occurrences.
1919 #[serde(rename = "sbomReference")]
1920 pub sbom_reference: Option<SBOMReferenceOccurrence>,
1921 /// Output only. The time this occurrence was last updated.
1922 #[serde(rename = "updateTime")]
1923 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1924 /// Describes an available package upgrade on the linked resource.
1925 pub upgrade: Option<UpgradeOccurrence>,
1926 /// Describes a security vulnerability.
1927 pub vulnerability: Option<VulnerabilityOccurrence>,
1928}
1929
1930impl common::RequestValue for Occurrence {}
1931impl common::ResponseResult for Occurrence {}
1932
1933/// A detail for a distro and package this vulnerability occurrence was found in and its associated fix (if one is available).
1934///
1935/// This type is not used in any activity, and only used as *part* of another schema.
1936///
1937#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1938#[serde_with::serde_as]
1939#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1940pub struct PackageIssue {
1941 /// Required. The [CPE URI](https://cpe.mitre.org/specification/) this vulnerability was found in.
1942 #[serde(rename = "affectedCpeUri")]
1943 pub affected_cpe_uri: Option<String>,
1944 /// Required. The package this vulnerability was found in.
1945 #[serde(rename = "affectedPackage")]
1946 pub affected_package: Option<String>,
1947 /// Required. The version of the package that is installed on the resource affected by this vulnerability.
1948 #[serde(rename = "affectedVersion")]
1949 pub affected_version: Option<Version>,
1950 /// Output only. The distro or language system assigned severity for this vulnerability when that is available and note provider assigned severity when it is not available.
1951 #[serde(rename = "effectiveSeverity")]
1952 pub effective_severity: Option<String>,
1953 /// The location at which this package was found.
1954 #[serde(rename = "fileLocation")]
1955 pub file_location: Option<Vec<GrafeasV1FileLocation>>,
1956 /// Output only. Whether a fix is available for this package.
1957 #[serde(rename = "fixAvailable")]
1958 pub fix_available: Option<bool>,
1959 /// The [CPE URI](https://cpe.mitre.org/specification/) this vulnerability was fixed in. It is possible for this to be different from the affected_cpe_uri.
1960 #[serde(rename = "fixedCpeUri")]
1961 pub fixed_cpe_uri: Option<String>,
1962 /// The package this vulnerability was fixed in. It is possible for this to be different from the affected_package.
1963 #[serde(rename = "fixedPackage")]
1964 pub fixed_package: Option<String>,
1965 /// Required. The version of the package this vulnerability was fixed in. Setting this to VersionKind.MAXIMUM means no fix is yet available.
1966 #[serde(rename = "fixedVersion")]
1967 pub fixed_version: Option<Version>,
1968 /// The type of package (e.g. OS, MAVEN, GO).
1969 #[serde(rename = "packageType")]
1970 pub package_type: Option<String>,
1971}
1972
1973impl common::Part for PackageIssue {}
1974
1975/// PackageNote represents a particular package version.
1976///
1977/// This type is not used in any activity, and only used as *part* of another schema.
1978///
1979#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1980#[serde_with::serde_as]
1981#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1982pub struct PackageNote {
1983 /// The CPU architecture for which packages in this distribution channel were built. Architecture will be blank for language packages.
1984 pub architecture: Option<String>,
1985 /// The cpe_uri in [CPE format](https://cpe.mitre.org/specification/) denoting the package manager version distributing a package. The cpe_uri will be blank for language packages.
1986 #[serde(rename = "cpeUri")]
1987 pub cpe_uri: Option<String>,
1988 /// The description of this package.
1989 pub description: Option<String>,
1990 /// Hash value, typically a file digest, that allows unique identification a specific package.
1991 pub digest: Option<Vec<Digest>>,
1992 /// Deprecated. The various channels by which a package is distributed.
1993 pub distribution: Option<Vec<Distribution>>,
1994 /// Licenses that have been declared by the authors of the package.
1995 pub license: Option<License>,
1996 /// A freeform text denoting the maintainer of this package.
1997 pub maintainer: Option<String>,
1998 /// Required. Immutable. The name of the package.
1999 pub name: Option<String>,
2000 /// The type of package; whether native or non native (e.g., ruby gems, node.js packages, etc.).
2001 #[serde(rename = "packageType")]
2002 pub package_type: Option<String>,
2003 /// The homepage for this package.
2004 pub url: Option<String>,
2005 /// The version of the package.
2006 pub version: Option<Version>,
2007}
2008
2009impl common::Part for PackageNote {}
2010
2011/// Details on how a particular software package was installed on a system.
2012///
2013/// This type is not used in any activity, and only used as *part* of another schema.
2014///
2015#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2016#[serde_with::serde_as]
2017#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2018pub struct PackageOccurrence {
2019 /// Output only. The CPU architecture for which packages in this distribution channel were built. Architecture will be blank for language packages.
2020 pub architecture: Option<String>,
2021 /// Output only. The cpe_uri in [CPE format](https://cpe.mitre.org/specification/) denoting the package manager version distributing a package. The cpe_uri will be blank for language packages.
2022 #[serde(rename = "cpeUri")]
2023 pub cpe_uri: Option<String>,
2024 /// Licenses that have been declared by the authors of the package.
2025 pub license: Option<License>,
2026 /// All of the places within the filesystem versions of this package have been found.
2027 pub location: Option<Vec<Location>>,
2028 /// Required. Output only. The name of the installed package.
2029 pub name: Option<String>,
2030 /// Output only. The type of package; whether native or non native (e.g., ruby gems, node.js packages, etc.).
2031 #[serde(rename = "packageType")]
2032 pub package_type: Option<String>,
2033 /// Output only. The version of the package.
2034 pub version: Option<Version>,
2035}
2036
2037impl common::Part for PackageOccurrence {}
2038
2039/// An Identity and Access Management (IAM) policy, which specifies access controls for Google Cloud resources. A `Policy` is a collection of `bindings`. A `binding` binds one or more `members`, or principals, to a single `role`. Principals can be user accounts, service accounts, Google groups, and domains (such as G Suite). A `role` is a named list of permissions; each `role` can be an IAM predefined role or a user-created custom role. For some types of Google Cloud resources, a `binding` can also specify a `condition`, which is a logical expression that allows access to a resource only if the expression evaluates to `true`. A condition can add constraints based on attributes of the request, the resource, or both. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies). **JSON example:** `{ "bindings": [ { "role": "roles/resourcemanager.organizationAdmin", "members": [ "user:mike@example.com", "group:admins@example.com", "domain:google.com", "serviceAccount:my-project-id@appspot.gserviceaccount.com" ] }, { "role": "roles/resourcemanager.organizationViewer", "members": [ "user:eve@example.com" ], "condition": { "title": "expirable access", "description": "Does not grant access after Sep 2020", "expression": "request.time < timestamp('2020-10-01T00:00:00.000Z')", } } ], "etag": "BwWWja0YfJA=", "version": 3 }` **YAML example:** `bindings: - members: - user:mike@example.com - group:admins@example.com - domain:google.com - serviceAccount:my-project-id@appspot.gserviceaccount.com role: roles/resourcemanager.organizationAdmin - members: - user:eve@example.com role: roles/resourcemanager.organizationViewer condition: title: expirable access description: Does not grant access after Sep 2020 expression: request.time < timestamp('2020-10-01T00:00:00.000Z') etag: BwWWja0YfJA= version: 3` For a description of IAM and its features, see the [IAM documentation](https://cloud.google.com/iam/docs/).
2040///
2041/// # Activities
2042///
2043/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2044/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2045///
2046/// * [notes get iam policy projects](ProjectNoteGetIamPolicyCall) (response)
2047/// * [notes set iam policy projects](ProjectNoteSetIamPolicyCall) (response)
2048/// * [occurrences get iam policy projects](ProjectOccurrenceGetIamPolicyCall) (response)
2049/// * [occurrences set iam policy projects](ProjectOccurrenceSetIamPolicyCall) (response)
2050#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2051#[serde_with::serde_as]
2052#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2053pub struct Policy {
2054 /// Associates a list of `members`, or principals, with a `role`. Optionally, may specify a `condition` that determines how and when the `bindings` are applied. Each of the `bindings` must contain at least one principal. The `bindings` in a `Policy` can refer to up to 1,500 principals; up to 250 of these principals can be Google groups. Each occurrence of a principal counts towards these limits. For example, if the `bindings` grant 50 different roles to `user:alice@example.com`, and not to any other principal, then you can add another 1,450 principals to the `bindings` in the `Policy`.
2055 pub bindings: Option<Vec<Binding>>,
2056 /// `etag` is used for optimistic concurrency control as a way to help prevent simultaneous updates of a policy from overwriting each other. It is strongly suggested that systems make use of the `etag` in the read-modify-write cycle to perform policy updates in order to avoid race conditions: An `etag` is returned in the response to `getIamPolicy`, and systems are expected to put that etag in the request to `setIamPolicy` to ensure that their change will be applied to the same version of the policy. **Important:** If you use IAM Conditions, you must include the `etag` field whenever you call `setIamPolicy`. If you omit this field, then IAM allows you to overwrite a version `3` policy with a version `1` policy, and all of the conditions in the version `3` policy are lost.
2057 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
2058 pub etag: Option<Vec<u8>>,
2059 /// Specifies the format of the policy. Valid values are `0`, `1`, and `3`. Requests that specify an invalid value are rejected. Any operation that affects conditional role bindings must specify version `3`. This requirement applies to the following operations: * Getting a policy that includes a conditional role binding * Adding a conditional role binding to a policy * Changing a conditional role binding in a policy * Removing any role binding, with or without a condition, from a policy that includes conditions **Important:** If you use IAM Conditions, you must include the `etag` field whenever you call `setIamPolicy`. If you omit this field, then IAM allows you to overwrite a version `3` policy with a version `1` policy, and all of the conditions in the version `3` policy are lost. If a policy does not include any conditions, operations on that policy may specify any valid version or leave the field unset. To learn which resources support conditions in their IAM policies, see the [IAM documentation](https://cloud.google.com/iam/help/conditions/resource-policies).
2060 pub version: Option<i32>,
2061}
2062
2063impl common::ResponseResult for Policy {}
2064
2065/// Product contains information about a product and how to uniquely identify it.
2066///
2067/// This type is not used in any activity, and only used as *part* of another schema.
2068///
2069#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2070#[serde_with::serde_as]
2071#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2072pub struct Product {
2073 /// Contains a URI which is vendor-specific. Example: The artifact repository URL of an image.
2074 #[serde(rename = "genericUri")]
2075 pub generic_uri: Option<String>,
2076 /// Token that identifies a product so that it can be referred to from other parts in the document. There is no predefined format as long as it uniquely identifies a group in the context of the current document.
2077 pub id: Option<String>,
2078 /// Name of the product.
2079 pub name: Option<String>,
2080}
2081
2082impl common::Part for Product {}
2083
2084/// Selects a repo using a Google Cloud Platform project ID (e.g., winged-cargo-31) and a repo name within that project.
2085///
2086/// This type is not used in any activity, and only used as *part* of another schema.
2087///
2088#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2089#[serde_with::serde_as]
2090#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2091pub struct ProjectRepoId {
2092 /// The ID of the project.
2093 #[serde(rename = "projectId")]
2094 pub project_id: Option<String>,
2095 /// The name of the repo. Leave empty for the default repo.
2096 #[serde(rename = "repoName")]
2097 pub repo_name: Option<String>,
2098}
2099
2100impl common::Part for ProjectRepoId {}
2101
2102/// There is no detailed description.
2103///
2104/// This type is not used in any activity, and only used as *part* of another schema.
2105///
2106#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2107#[serde_with::serde_as]
2108#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2109pub struct ProvenanceBuilder {
2110 /// no description provided
2111 #[serde(rename = "builderDependencies")]
2112 pub builder_dependencies: Option<Vec<ResourceDescriptor>>,
2113 /// no description provided
2114 pub id: Option<String>,
2115 /// no description provided
2116 pub version: Option<HashMap<String, String>>,
2117}
2118
2119impl common::Part for ProvenanceBuilder {}
2120
2121/// Publisher contains information about the publisher of this Note.
2122///
2123/// This type is not used in any activity, and only used as *part* of another schema.
2124///
2125#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2126#[serde_with::serde_as]
2127#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2128pub struct Publisher {
2129 /// Provides information about the authority of the issuing party to release the document, in particular, the party's constituency and responsibilities or other obligations.
2130 #[serde(rename = "issuingAuthority")]
2131 pub issuing_authority: Option<String>,
2132 /// Name of the publisher. Examples: 'Google', 'Google Cloud Platform'.
2133 pub name: Option<String>,
2134 /// The context or namespace. Contains a URL which is under control of the issuing party and can be used as a globally unique identifier for that issuing party. Example: https://csaf.io
2135 #[serde(rename = "publisherNamespace")]
2136 pub publisher_namespace: Option<String>,
2137}
2138
2139impl common::Part for Publisher {}
2140
2141/// Steps taken to build the artifact. For a TaskRun, typically each container corresponds to one step in the recipe.
2142///
2143/// This type is not used in any activity, and only used as *part* of another schema.
2144///
2145#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2146#[serde_with::serde_as]
2147#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2148pub struct Recipe {
2149 /// Collection of all external inputs that influenced the build on top of recipe.definedInMaterial and recipe.entryPoint. For example, if the recipe type were "make", then this might be the flags passed to make aside from the target, which is captured in recipe.entryPoint. Since the arguments field can greatly vary in structure, depending on the builder and recipe type, this is of form "Any".
2150 pub arguments: Option<Vec<HashMap<String, serde_json::Value>>>,
2151 /// Index in materials containing the recipe steps that are not implied by recipe.type. For example, if the recipe type were "make", then this would point to the source containing the Makefile, not the make program itself. Set to -1 if the recipe doesn't come from a material, as zero is default unset value for int64.
2152 #[serde(rename = "definedInMaterial")]
2153 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2154 pub defined_in_material: Option<i64>,
2155 /// String identifying the entry point into the build. This is often a path to a configuration file and/or a target label within that file. The syntax and meaning are defined by recipe.type. For example, if the recipe type were "make", then this would reference the directory in which to run make as well as which target to use.
2156 #[serde(rename = "entryPoint")]
2157 pub entry_point: Option<String>,
2158 /// Any other builder-controlled inputs necessary for correctly evaluating the recipe. Usually only needed for reproducing the build but not evaluated as part of policy. Since the environment field can greatly vary in structure, depending on the builder and recipe type, this is of form "Any".
2159 pub environment: Option<Vec<HashMap<String, serde_json::Value>>>,
2160 /// URI indicating what type of recipe was performed. It determines the meaning of recipe.entryPoint, recipe.arguments, recipe.environment, and materials.
2161 #[serde(rename = "type")]
2162 pub type_: Option<String>,
2163}
2164
2165impl common::Part for Recipe {}
2166
2167/// Metadata for any related URL information.
2168///
2169/// This type is not used in any activity, and only used as *part* of another schema.
2170///
2171#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2172#[serde_with::serde_as]
2173#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2174pub struct RelatedUrl {
2175 /// Label to describe usage of the URL.
2176 pub label: Option<String>,
2177 /// Specific URL associated with the resource.
2178 pub url: Option<String>,
2179}
2180
2181impl common::Part for RelatedUrl {}
2182
2183/// Specifies details on how to handle (and presumably, fix) a vulnerability.
2184///
2185/// This type is not used in any activity, and only used as *part* of another schema.
2186///
2187#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2188#[serde_with::serde_as]
2189#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2190pub struct Remediation {
2191 /// Contains a comprehensive human-readable discussion of the remediation.
2192 pub details: Option<String>,
2193 /// The type of remediation that can be applied.
2194 #[serde(rename = "remediationType")]
2195 pub remediation_type: Option<String>,
2196 /// Contains the URL where to obtain the remediation.
2197 #[serde(rename = "remediationUri")]
2198 pub remediation_uri: Option<RelatedUrl>,
2199}
2200
2201impl common::Part for Remediation {}
2202
2203/// A unique identifier for a Cloud Repo.
2204///
2205/// This type is not used in any activity, and only used as *part* of another schema.
2206///
2207#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2208#[serde_with::serde_as]
2209#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2210pub struct RepoId {
2211 /// A combination of a project ID and a repo name.
2212 #[serde(rename = "projectRepoId")]
2213 pub project_repo_id: Option<ProjectRepoId>,
2214 /// A server-assigned, globally unique identifier.
2215 pub uid: Option<String>,
2216}
2217
2218impl common::Part for RepoId {}
2219
2220/// There is no detailed description.
2221///
2222/// This type is not used in any activity, and only used as *part* of another schema.
2223///
2224#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2225#[serde_with::serde_as]
2226#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2227pub struct ResourceDescriptor {
2228 /// no description provided
2229 pub annotations: Option<HashMap<String, serde_json::Value>>,
2230 /// no description provided
2231 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
2232 pub content: Option<Vec<u8>>,
2233 /// no description provided
2234 pub digest: Option<HashMap<String, String>>,
2235 /// no description provided
2236 #[serde(rename = "downloadLocation")]
2237 pub download_location: Option<String>,
2238 /// no description provided
2239 #[serde(rename = "mediaType")]
2240 pub media_type: Option<String>,
2241 /// no description provided
2242 pub name: Option<String>,
2243 /// no description provided
2244 pub uri: Option<String>,
2245}
2246
2247impl common::Part for ResourceDescriptor {}
2248
2249/// There is no detailed description.
2250///
2251/// This type is not used in any activity, and only used as *part* of another schema.
2252///
2253#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2254#[serde_with::serde_as]
2255#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2256pub struct RunDetails {
2257 /// no description provided
2258 pub builder: Option<ProvenanceBuilder>,
2259 /// no description provided
2260 pub byproducts: Option<Vec<ResourceDescriptor>>,
2261 /// no description provided
2262 pub metadata: Option<BuildMetadata>,
2263}
2264
2265impl common::Part for RunDetails {}
2266
2267/// The note representing an SBOM reference.
2268///
2269/// This type is not used in any activity, and only used as *part* of another schema.
2270///
2271#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2272#[serde_with::serde_as]
2273#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2274pub struct SBOMReferenceNote {
2275 /// The format that SBOM takes. E.g. may be spdx, cyclonedx, etc...
2276 pub format: Option<String>,
2277 /// The version of the format that the SBOM takes. E.g. if the format is spdx, the version may be 2.3.
2278 pub version: Option<String>,
2279}
2280
2281impl common::Part for SBOMReferenceNote {}
2282
2283/// The occurrence representing an SBOM reference as applied to a specific resource. The occurrence follows the DSSE specification. See https://github.com/secure-systems-lab/dsse/blob/master/envelope.md for more details.
2284///
2285/// This type is not used in any activity, and only used as *part* of another schema.
2286///
2287#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2288#[serde_with::serde_as]
2289#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2290pub struct SBOMReferenceOccurrence {
2291 /// The actual payload that contains the SBOM reference data.
2292 pub payload: Option<SbomReferenceIntotoPayload>,
2293 /// The kind of payload that SbomReferenceIntotoPayload takes. Since it's in the intoto format, this value is expected to be 'application/vnd.in-toto+json'.
2294 #[serde(rename = "payloadType")]
2295 pub payload_type: Option<String>,
2296 /// The signatures over the payload.
2297 pub signatures: Option<Vec<EnvelopeSignature>>,
2298}
2299
2300impl common::Part for SBOMReferenceOccurrence {}
2301
2302/// The status of an SBOM generation.
2303///
2304/// This type is not used in any activity, and only used as *part* of another schema.
2305///
2306#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2307#[serde_with::serde_as]
2308#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2309pub struct SBOMStatus {
2310 /// If there was an error generating an SBOM, this will indicate what that error was.
2311 pub error: Option<String>,
2312 /// The progress of the SBOM generation.
2313 #[serde(rename = "sbomState")]
2314 pub sbom_state: Option<String>,
2315}
2316
2317impl common::Part for SBOMStatus {}
2318
2319/// The actual payload that contains the SBOM Reference data. The payload follows the intoto statement specification. See https://github.com/in-toto/attestation/blob/main/spec/v1.0/statement.md for more details.
2320///
2321/// This type is not used in any activity, and only used as *part* of another schema.
2322///
2323#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2324#[serde_with::serde_as]
2325#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2326pub struct SbomReferenceIntotoPayload {
2327 /// Identifier for the schema of the Statement.
2328 pub _type: Option<String>,
2329 /// Additional parameters of the Predicate. Includes the actual data about the SBOM.
2330 pub predicate: Option<SbomReferenceIntotoPredicate>,
2331 /// URI identifying the type of the Predicate.
2332 #[serde(rename = "predicateType")]
2333 pub predicate_type: Option<String>,
2334 /// Set of software artifacts that the attestation applies to. Each element represents a single software artifact.
2335 pub subject: Option<Vec<Subject>>,
2336}
2337
2338impl common::Part for SbomReferenceIntotoPayload {}
2339
2340/// A predicate which describes the SBOM being referenced.
2341///
2342/// This type is not used in any activity, and only used as *part* of another schema.
2343///
2344#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2345#[serde_with::serde_as]
2346#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2347pub struct SbomReferenceIntotoPredicate {
2348 /// A map of algorithm to digest of the contents of the SBOM.
2349 pub digest: Option<HashMap<String, String>>,
2350 /// The location of the SBOM.
2351 pub location: Option<String>,
2352 /// The mime type of the SBOM.
2353 #[serde(rename = "mimeType")]
2354 pub mime_type: Option<String>,
2355 /// The person or system referring this predicate to the consumer.
2356 #[serde(rename = "referrerId")]
2357 pub referrer_id: Option<String>,
2358}
2359
2360impl common::Part for SbomReferenceIntotoPredicate {}
2361
2362/// Request message for `SetIamPolicy` method.
2363///
2364/// # Activities
2365///
2366/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2367/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2368///
2369/// * [notes set iam policy projects](ProjectNoteSetIamPolicyCall) (request)
2370/// * [occurrences set iam policy projects](ProjectOccurrenceSetIamPolicyCall) (request)
2371#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2372#[serde_with::serde_as]
2373#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2374pub struct SetIamPolicyRequest {
2375 /// REQUIRED: The complete policy to be applied to the `resource`. The size of the policy is limited to a few 10s of KB. An empty policy is a valid policy but certain Google Cloud services (such as Projects) might reject them.
2376 pub policy: Option<Policy>,
2377}
2378
2379impl common::RequestValue for SetIamPolicyRequest {}
2380
2381/// Verifiers (e.g. Kritis implementations) MUST verify signatures with respect to the trust anchors defined in policy (e.g. a Kritis policy). Typically this means that the verifier has been configured with a map from `public_key_id` to public key material (and any required parameters, e.g. signing algorithm). In particular, verification implementations MUST NOT treat the signature `public_key_id` as anything more than a key lookup hint. The `public_key_id` DOES NOT validate or authenticate a public key; it only provides a mechanism for quickly selecting a public key ALREADY CONFIGURED on the verifier through a trusted channel. Verification implementations MUST reject signatures in any of the following circumstances: * The `public_key_id` is not recognized by the verifier. * The public key that `public_key_id` refers to does not verify the signature with respect to the payload. The `signature` contents SHOULD NOT be "attached" (where the payload is included with the serialized `signature` bytes). Verifiers MUST ignore any "attached" payload and only verify signatures with respect to explicitly provided payload (e.g. a `payload` field on the proto message that holds this Signature, or the canonical serialization of the proto message that holds this signature).
2382///
2383/// This type is not used in any activity, and only used as *part* of another schema.
2384///
2385#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2386#[serde_with::serde_as]
2387#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2388pub struct Signature {
2389 /// The identifier for the public key that verifies this signature. * The `public_key_id` is required. * The `public_key_id` SHOULD be an RFC3986 conformant URI. * When possible, the `public_key_id` SHOULD be an immutable reference, such as a cryptographic digest. Examples of valid `public_key_id`s: OpenPGP V4 public key fingerprint: * "openpgp4fpr:74FAF3B861BDA0870C7B6DEF607E48D2A663AEEA" See https://www.iana.org/assignments/uri-schemes/prov/openpgp4fpr for more details on this scheme. RFC6920 digest-named SubjectPublicKeyInfo (digest of the DER serialization): * "ni:///sha-256;cD9o9Cq6LG3jD0iKXqEi_vdjJGecm_iXkbqVoScViaU" * "nih:///sha-256;703f68f42aba2c6de30f488a5ea122fef76324679c9bf89791ba95a1271589a5"
2390 #[serde(rename = "publicKeyId")]
2391 pub public_key_id: Option<String>,
2392 /// The content of the signature, an opaque bytestring. The payload that this signature verifies MUST be unambiguously provided with the Signature during verification. A wrapper message might provide the payload explicitly. Alternatively, a message might have a canonical serialization that can always be unambiguously computed to derive the payload.
2393 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
2394 pub signature: Option<Vec<u8>>,
2395}
2396
2397impl common::Part for Signature {}
2398
2399/// There is no detailed description.
2400///
2401/// This type is not used in any activity, and only used as *part* of another schema.
2402///
2403#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2404#[serde_with::serde_as]
2405#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2406pub struct SlsaBuilder {
2407 /// no description provided
2408 pub id: Option<String>,
2409}
2410
2411impl common::Part for SlsaBuilder {}
2412
2413/// Indicates that the builder claims certain fields in this message to be complete.
2414///
2415/// This type is not used in any activity, and only used as *part* of another schema.
2416///
2417#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2418#[serde_with::serde_as]
2419#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2420pub struct SlsaCompleteness {
2421 /// If true, the builder claims that recipe.arguments is complete, meaning that all external inputs are properly captured in the recipe.
2422 pub arguments: Option<bool>,
2423 /// If true, the builder claims that recipe.environment is claimed to be complete.
2424 pub environment: Option<bool>,
2425 /// If true, the builder claims that materials are complete, usually through some controls to prevent network access. Sometimes called "hermetic".
2426 pub materials: Option<bool>,
2427}
2428
2429impl common::Part for SlsaCompleteness {}
2430
2431/// Other properties of the build.
2432///
2433/// This type is not used in any activity, and only used as *part* of another schema.
2434///
2435#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2436#[serde_with::serde_as]
2437#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2438pub struct SlsaMetadata {
2439 /// The timestamp of when the build completed.
2440 #[serde(rename = "buildFinishedOn")]
2441 pub build_finished_on: Option<chrono::DateTime<chrono::offset::Utc>>,
2442 /// Identifies the particular build invocation, which can be useful for finding associated logs or other ad-hoc analysis. The value SHOULD be globally unique, per in-toto Provenance spec.
2443 #[serde(rename = "buildInvocationId")]
2444 pub build_invocation_id: Option<String>,
2445 /// The timestamp of when the build started.
2446 #[serde(rename = "buildStartedOn")]
2447 pub build_started_on: Option<chrono::DateTime<chrono::offset::Utc>>,
2448 /// Indicates that the builder claims certain fields in this message to be complete.
2449 pub completeness: Option<SlsaCompleteness>,
2450 /// If true, the builder claims that running the recipe on materials will produce bit-for-bit identical output.
2451 pub reproducible: Option<bool>,
2452}
2453
2454impl common::Part for SlsaMetadata {}
2455
2456/// There is no detailed description.
2457///
2458/// This type is not used in any activity, and only used as *part* of another schema.
2459///
2460#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2461#[serde_with::serde_as]
2462#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2463pub struct SlsaProvenance {
2464 /// required
2465 pub builder: Option<SlsaBuilder>,
2466 /// The collection of artifacts that influenced the build including sources, dependencies, build tools, base images, and so on. This is considered to be incomplete unless metadata.completeness.materials is true. Unset or null is equivalent to empty.
2467 pub materials: Option<Vec<Material>>,
2468 /// no description provided
2469 pub metadata: Option<SlsaMetadata>,
2470 /// Identifies the configuration used for the build. When combined with materials, this SHOULD fully describe the build, such that re-running this recipe results in bit-for-bit identical output (if the build is reproducible). required
2471 pub recipe: Option<SlsaRecipe>,
2472}
2473
2474impl common::Part for SlsaProvenance {}
2475
2476/// Keep in sync with schema at https://github.com/slsa-framework/slsa/blob/main/docs/provenance/schema/v1/provenance.proto Builder renamed to ProvenanceBuilder because of Java conflicts.
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 SlsaProvenanceV1 {
2484 /// no description provided
2485 #[serde(rename = "buildDefinition")]
2486 pub build_definition: Option<BuildDefinition>,
2487 /// no description provided
2488 #[serde(rename = "runDetails")]
2489 pub run_details: Option<RunDetails>,
2490}
2491
2492impl common::Part for SlsaProvenanceV1 {}
2493
2494/// See full explanation of fields at slsa.dev/provenance/v0.2.
2495///
2496/// This type is not used in any activity, and only used as *part* of another schema.
2497///
2498#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2499#[serde_with::serde_as]
2500#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2501pub struct SlsaProvenanceZeroTwo {
2502 /// no description provided
2503 #[serde(rename = "buildConfig")]
2504 pub build_config: Option<HashMap<String, serde_json::Value>>,
2505 /// no description provided
2506 #[serde(rename = "buildType")]
2507 pub build_type: Option<String>,
2508 /// no description provided
2509 pub builder: Option<GrafeasV1SlsaProvenanceZeroTwoSlsaBuilder>,
2510 /// no description provided
2511 pub invocation: Option<GrafeasV1SlsaProvenanceZeroTwoSlsaInvocation>,
2512 /// no description provided
2513 pub materials: Option<Vec<GrafeasV1SlsaProvenanceZeroTwoSlsaMaterial>>,
2514 /// no description provided
2515 pub metadata: Option<GrafeasV1SlsaProvenanceZeroTwoSlsaMetadata>,
2516}
2517
2518impl common::Part for SlsaProvenanceZeroTwo {}
2519
2520/// Steps taken to build the artifact. For a TaskRun, typically each container corresponds to one step in the recipe.
2521///
2522/// This type is not used in any activity, and only used as *part* of another schema.
2523///
2524#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2525#[serde_with::serde_as]
2526#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2527pub struct SlsaRecipe {
2528 /// Collection of all external inputs that influenced the build on top of recipe.definedInMaterial and recipe.entryPoint. For example, if the recipe type were "make", then this might be the flags passed to make aside from the target, which is captured in recipe.entryPoint. Depending on the recipe Type, the structure may be different.
2529 pub arguments: Option<HashMap<String, serde_json::Value>>,
2530 /// Index in materials containing the recipe steps that are not implied by recipe.type. For example, if the recipe type were "make", then this would point to the source containing the Makefile, not the make program itself. Set to -1 if the recipe doesn't come from a material, as zero is default unset value for int64.
2531 #[serde(rename = "definedInMaterial")]
2532 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2533 pub defined_in_material: Option<i64>,
2534 /// String identifying the entry point into the build. This is often a path to a configuration file and/or a target label within that file. The syntax and meaning are defined by recipe.type. For example, if the recipe type were "make", then this would reference the directory in which to run make as well as which target to use.
2535 #[serde(rename = "entryPoint")]
2536 pub entry_point: Option<String>,
2537 /// Any other builder-controlled inputs necessary for correctly evaluating the recipe. Usually only needed for reproducing the build but not evaluated as part of policy. Depending on the recipe Type, the structure may be different.
2538 pub environment: Option<HashMap<String, serde_json::Value>>,
2539 /// URI indicating what type of recipe was performed. It determines the meaning of recipe.entryPoint, recipe.arguments, recipe.environment, and materials.
2540 #[serde(rename = "type")]
2541 pub type_: Option<String>,
2542}
2543
2544impl common::Part for SlsaRecipe {}
2545
2546/// Source describes the location of the source used for the build.
2547///
2548/// This type is not used in any activity, and only used as *part* of another schema.
2549///
2550#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2551#[serde_with::serde_as]
2552#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2553pub struct Source {
2554 /// If provided, some of the source code used for the build may be found in these locations, in the case where the source repository had multiple remotes or submodules. This list will not include the context specified in the context field.
2555 #[serde(rename = "additionalContexts")]
2556 pub additional_contexts: Option<Vec<SourceContext>>,
2557 /// If provided, the input binary artifacts for the build came from this location.
2558 #[serde(rename = "artifactStorageSourceUri")]
2559 pub artifact_storage_source_uri: Option<String>,
2560 /// If provided, the source code used for the build came from this location.
2561 pub context: Option<SourceContext>,
2562 /// Hash(es) of the build source, which can be used to verify that the original source integrity was maintained in the build. 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.
2563 #[serde(rename = "fileHashes")]
2564 pub file_hashes: Option<HashMap<String, FileHashes>>,
2565}
2566
2567impl common::Part for Source {}
2568
2569/// A SourceContext is a reference to a tree of files. A SourceContext together with a path point to a unique revision of a single file or directory.
2570///
2571/// This type is not used in any activity, and only used as *part* of another schema.
2572///
2573#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2574#[serde_with::serde_as]
2575#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2576pub struct SourceContext {
2577 /// A SourceContext referring to a revision in a Google Cloud Source Repo.
2578 #[serde(rename = "cloudRepo")]
2579 pub cloud_repo: Option<CloudRepoSourceContext>,
2580 /// A SourceContext referring to a Gerrit project.
2581 pub gerrit: Option<GerritSourceContext>,
2582 /// A SourceContext referring to any third party Git repo (e.g., GitHub).
2583 pub git: Option<GitSourceContext>,
2584 /// Labels with user defined metadata.
2585 pub labels: Option<HashMap<String, String>>,
2586}
2587
2588impl common::Part for SourceContext {}
2589
2590/// 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).
2591///
2592/// This type is not used in any activity, and only used as *part* of another schema.
2593///
2594#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2595#[serde_with::serde_as]
2596#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2597pub struct Status {
2598 /// The status code, which should be an enum value of google.rpc.Code.
2599 pub code: Option<i32>,
2600 /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
2601 pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
2602 /// 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.
2603 pub message: Option<String>,
2604}
2605
2606impl common::Part for Status {}
2607
2608/// There is no detailed description.
2609///
2610/// This type is not used in any activity, and only used as *part* of another schema.
2611///
2612#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2613#[serde_with::serde_as]
2614#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2615pub struct Subject {
2616 /// `"": ""` Algorithms can be e.g. sha256, sha512 See https://github.com/in-toto/attestation/blob/main/spec/field_types.md#DigestSet
2617 pub digest: Option<HashMap<String, String>>,
2618 /// no description provided
2619 pub name: Option<String>,
2620}
2621
2622impl common::Part for Subject {}
2623
2624/// Request message for `TestIamPermissions` method.
2625///
2626/// # Activities
2627///
2628/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2629/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2630///
2631/// * [notes test iam permissions projects](ProjectNoteTestIamPermissionCall) (request)
2632/// * [occurrences test iam permissions projects](ProjectOccurrenceTestIamPermissionCall) (request)
2633#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2634#[serde_with::serde_as]
2635#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2636pub struct TestIamPermissionsRequest {
2637 /// The set of permissions to check for the `resource`. Permissions with wildcards (such as `*` or `storage.*`) are not allowed. For more information see [IAM Overview](https://cloud.google.com/iam/docs/overview#permissions).
2638 pub permissions: Option<Vec<String>>,
2639}
2640
2641impl common::RequestValue for TestIamPermissionsRequest {}
2642
2643/// Response message for `TestIamPermissions` method.
2644///
2645/// # Activities
2646///
2647/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2648/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2649///
2650/// * [notes test iam permissions projects](ProjectNoteTestIamPermissionCall) (response)
2651/// * [occurrences test iam permissions projects](ProjectOccurrenceTestIamPermissionCall) (response)
2652#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2653#[serde_with::serde_as]
2654#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2655pub struct TestIamPermissionsResponse {
2656 /// A subset of `TestPermissionsRequest.permissions` that the caller is allowed.
2657 pub permissions: Option<Vec<String>>,
2658}
2659
2660impl common::ResponseResult for TestIamPermissionsResponse {}
2661
2662/// The Upgrade Distribution represents metadata about the Upgrade for each operating system (CPE). Some distributions have additional metadata around updates, classifying them into various categories and severities.
2663///
2664/// This type is not used in any activity, and only used as *part* of another schema.
2665///
2666#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2667#[serde_with::serde_as]
2668#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2669pub struct UpgradeDistribution {
2670 /// The operating system classification of this Upgrade, as specified by the upstream operating system upgrade feed. For Windows the classification is one of the category_ids listed at https://docs.microsoft.com/en-us/previous-versions/windows/desktop/ff357803(v=vs.85)
2671 pub classification: Option<String>,
2672 /// Required - The specific operating system this metadata applies to. See https://cpe.mitre.org/specification/.
2673 #[serde(rename = "cpeUri")]
2674 pub cpe_uri: Option<String>,
2675 /// The cve tied to this Upgrade.
2676 pub cve: Option<Vec<String>>,
2677 /// The severity as specified by the upstream operating system.
2678 pub severity: Option<String>,
2679}
2680
2681impl common::Part for UpgradeDistribution {}
2682
2683/// An Upgrade Note represents a potential upgrade of a package to a given version. For each package version combination (i.e. bash 4.0, bash 4.1, bash 4.1.2), there will be an Upgrade Note. For Windows, windows_update field represents the information related to the update.
2684///
2685/// This type is not used in any activity, and only used as *part* of another schema.
2686///
2687#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2688#[serde_with::serde_as]
2689#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2690pub struct UpgradeNote {
2691 /// Metadata about the upgrade for each specific operating system.
2692 pub distributions: Option<Vec<UpgradeDistribution>>,
2693 /// Required for non-Windows OS. The package this Upgrade is for.
2694 pub package: Option<String>,
2695 /// Required for non-Windows OS. The version of the package in machine + human readable form.
2696 pub version: Option<Version>,
2697 /// Required for Windows OS. Represents the metadata about the Windows update.
2698 #[serde(rename = "windowsUpdate")]
2699 pub windows_update: Option<WindowsUpdate>,
2700}
2701
2702impl common::Part for UpgradeNote {}
2703
2704/// An Upgrade Occurrence represents that a specific resource_url could install a specific upgrade. This presence is supplied via local sources (i.e. it is present in the mirror and the running system has noticed its availability). For Windows, both distribution and windows_update contain information for the Windows update.
2705///
2706/// This type is not used in any activity, and only used as *part* of another schema.
2707///
2708#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2709#[serde_with::serde_as]
2710#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2711pub struct UpgradeOccurrence {
2712 /// Metadata about the upgrade for available for the specific operating system for the resource_url. This allows efficient filtering, as well as making it easier to use the occurrence.
2713 pub distribution: Option<UpgradeDistribution>,
2714 /// Required for non-Windows OS. The package this Upgrade is for.
2715 pub package: Option<String>,
2716 /// Required for non-Windows OS. The version of the package in a machine + human readable form.
2717 #[serde(rename = "parsedVersion")]
2718 pub parsed_version: Option<Version>,
2719 /// Required for Windows OS. Represents the metadata about the Windows update.
2720 #[serde(rename = "windowsUpdate")]
2721 pub windows_update: Option<WindowsUpdate>,
2722}
2723
2724impl common::Part for UpgradeOccurrence {}
2725
2726/// Version contains structured information about the version of a package.
2727///
2728/// This type is not used in any activity, and only used as *part* of another schema.
2729///
2730#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2731#[serde_with::serde_as]
2732#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2733pub struct Version {
2734 /// Used to correct mistakes in the version numbering scheme.
2735 pub epoch: Option<i32>,
2736 /// Human readable version string. This string is of the form :- and is only set when kind is NORMAL.
2737 #[serde(rename = "fullName")]
2738 pub full_name: Option<String>,
2739 /// Whether this version is specifying part of an inclusive range. Grafeas does not have the capability to specify version ranges; instead we have fields that specify start version and end versions. At times this is insufficient - we also need to specify whether the version is included in the range or is excluded from the range. This boolean is expected to be set to true when the version is included in a range.
2740 pub inclusive: Option<bool>,
2741 /// Required. Distinguishes between sentinel MIN/MAX versions and normal versions.
2742 pub kind: Option<String>,
2743 /// Required only when version kind is NORMAL. The main part of the version name.
2744 pub name: Option<String>,
2745 /// The iteration of the package build from the above version.
2746 pub revision: Option<String>,
2747}
2748
2749impl common::Part for Version {}
2750
2751/// VexAssessment provides all publisher provided Vex information that is related to this vulnerability.
2752///
2753/// This type is not used in any activity, and only used as *part* of another schema.
2754///
2755#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2756#[serde_with::serde_as]
2757#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2758pub struct VexAssessment {
2759 /// Holds the MITRE standard Common Vulnerabilities and Exposures (CVE) tracking number for the vulnerability. Deprecated: Use vulnerability_id instead to denote CVEs.
2760 pub cve: Option<String>,
2761 /// Contains information about the impact of this vulnerability, this will change with time.
2762 pub impacts: Option<Vec<String>>,
2763 /// Justification provides the justification when the state of the assessment if NOT_AFFECTED.
2764 pub justification: Option<Justification>,
2765 /// The VulnerabilityAssessment note from which this VexAssessment was generated. This will be of the form: `projects/[PROJECT_ID]/notes/[NOTE_ID]`.
2766 #[serde(rename = "noteName")]
2767 pub note_name: Option<String>,
2768 /// Holds a list of references associated with this vulnerability item and assessment.
2769 #[serde(rename = "relatedUris")]
2770 pub related_uris: Option<Vec<RelatedUrl>>,
2771 /// Specifies details on how to handle (and presumably, fix) a vulnerability.
2772 pub remediations: Option<Vec<Remediation>>,
2773 /// Provides the state of this Vulnerability assessment.
2774 pub state: Option<String>,
2775 /// The vulnerability identifier for this Assessment. Will hold one of common identifiers e.g. CVE, GHSA etc.
2776 #[serde(rename = "vulnerabilityId")]
2777 pub vulnerability_id: Option<String>,
2778}
2779
2780impl common::Part for VexAssessment {}
2781
2782/// A single VulnerabilityAssessmentNote represents one particular product's vulnerability assessment for one CVE.
2783///
2784/// This type is not used in any activity, and only used as *part* of another schema.
2785///
2786#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2787#[serde_with::serde_as]
2788#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2789pub struct VulnerabilityAssessmentNote {
2790 /// Represents a vulnerability assessment for the product.
2791 pub assessment: Option<Assessment>,
2792 /// Identifies the language used by this document, corresponding to IETF BCP 47 / RFC 5646.
2793 #[serde(rename = "languageCode")]
2794 pub language_code: Option<String>,
2795 /// A detailed description of this Vex.
2796 #[serde(rename = "longDescription")]
2797 pub long_description: Option<String>,
2798 /// The product affected by this vex.
2799 pub product: Option<Product>,
2800 /// Publisher details of this Note.
2801 pub publisher: Option<Publisher>,
2802 /// A one sentence description of this Vex.
2803 #[serde(rename = "shortDescription")]
2804 pub short_description: Option<String>,
2805 /// The title of the note. E.g. `Vex-Debian-11.4`
2806 pub title: Option<String>,
2807}
2808
2809impl common::Part for VulnerabilityAssessmentNote {}
2810
2811/// The status of an vulnerability attestation generation.
2812///
2813/// This type is not used in any activity, and only used as *part* of another schema.
2814///
2815#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2816#[serde_with::serde_as]
2817#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2818pub struct VulnerabilityAttestation {
2819 /// If failure, the error reason for why the attestation generation failed.
2820 pub error: Option<String>,
2821 /// The last time we attempted to generate an attestation.
2822 #[serde(rename = "lastAttemptTime")]
2823 pub last_attempt_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2824 /// The success/failure state of the latest attestation attempt.
2825 pub state: Option<String>,
2826}
2827
2828impl common::Part for VulnerabilityAttestation {}
2829
2830/// A security vulnerability that can be found in resources.
2831///
2832/// This type is not used in any activity, and only used as *part* of another schema.
2833///
2834#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2835#[serde_with::serde_as]
2836#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2837pub struct VulnerabilityNote {
2838 /// The CVSS score of this vulnerability. CVSS score is on a scale of 0 - 10 where 0 indicates low severity and 10 indicates high severity.
2839 #[serde(rename = "cvssScore")]
2840 pub cvss_score: Option<f32>,
2841 /// The full description of the v2 CVSS for this vulnerability.
2842 #[serde(rename = "cvssV2")]
2843 pub cvss_v2: Option<CVSS>,
2844 /// The full description of the CVSSv3 for this vulnerability.
2845 #[serde(rename = "cvssV3")]
2846 pub cvss_v3: Option<CVSSv3>,
2847 /// CVSS version used to populate cvss_score and severity.
2848 #[serde(rename = "cvssVersion")]
2849 pub cvss_version: Option<String>,
2850 /// Details of all known distros and packages affected by this vulnerability.
2851 pub details: Option<Vec<Detail>>,
2852 /// The note provider assigned severity of this vulnerability.
2853 pub severity: Option<String>,
2854 /// The time this information was last changed at the source. This is an upstream timestamp from the underlying information source - e.g. Ubuntu security tracker.
2855 #[serde(rename = "sourceUpdateTime")]
2856 pub source_update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2857 /// Windows details get their own format because the information format and model don't match a normal detail. Specifically Windows updates are done as patches, thus Windows vulnerabilities really are a missing package, rather than a package being at an incorrect version.
2858 #[serde(rename = "windowsDetails")]
2859 pub windows_details: Option<Vec<WindowsDetail>>,
2860}
2861
2862impl common::Part for VulnerabilityNote {}
2863
2864/// An occurrence of a severity vulnerability on a resource.
2865///
2866/// This type is not used in any activity, and only used as *part* of another schema.
2867///
2868#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2869#[serde_with::serde_as]
2870#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2871pub struct VulnerabilityOccurrence {
2872 /// Output only. The CVSS score of this vulnerability. CVSS score is on a scale of 0 - 10 where 0 indicates low severity and 10 indicates high severity.
2873 #[serde(rename = "cvssScore")]
2874 pub cvss_score: Option<f32>,
2875 /// The cvss v2 score for the vulnerability.
2876 #[serde(rename = "cvssV2")]
2877 pub cvss_v2: Option<CVSS>,
2878 /// Output only. CVSS version used to populate cvss_score and severity.
2879 #[serde(rename = "cvssVersion")]
2880 pub cvss_version: Option<String>,
2881 /// The cvss v3 score for the vulnerability.
2882 pub cvssv3: Option<CVSS>,
2883 /// The distro assigned severity for this vulnerability when it is available, otherwise this is the note provider assigned severity. When there are multiple PackageIssues for this vulnerability, they can have different effective severities because some might be provided by the distro while others are provided by the language ecosystem for a language pack. For this reason, it is advised to use the effective severity on the PackageIssue level. In the case where multiple PackageIssues have differing effective severities, this field should be the highest severity for any of the PackageIssues.
2884 #[serde(rename = "effectiveSeverity")]
2885 pub effective_severity: Option<String>,
2886 /// Occurrence-specific extra details about the vulnerability.
2887 #[serde(rename = "extraDetails")]
2888 pub extra_details: Option<String>,
2889 /// Output only. Whether at least one of the affected packages has a fix available.
2890 #[serde(rename = "fixAvailable")]
2891 pub fix_available: Option<bool>,
2892 /// Output only. A detailed description of this vulnerability.
2893 #[serde(rename = "longDescription")]
2894 pub long_description: Option<String>,
2895 /// Required. The set of affected locations and their fixes (if available) within the associated resource.
2896 #[serde(rename = "packageIssue")]
2897 pub package_issue: Option<Vec<PackageIssue>>,
2898 /// Output only. URLs related to this vulnerability.
2899 #[serde(rename = "relatedUrls")]
2900 pub related_urls: Option<Vec<RelatedUrl>>,
2901 /// Output only. The note provider assigned severity of this vulnerability.
2902 pub severity: Option<String>,
2903 /// Output only. A one sentence description of this vulnerability.
2904 #[serde(rename = "shortDescription")]
2905 pub short_description: Option<String>,
2906 /// The type of package; whether native or non native (e.g., ruby gems, node.js packages, etc.).
2907 #[serde(rename = "type")]
2908 pub type_: Option<String>,
2909 /// no description provided
2910 #[serde(rename = "vexAssessment")]
2911 pub vex_assessment: Option<VexAssessment>,
2912}
2913
2914impl common::Part for VulnerabilityOccurrence {}
2915
2916/// A summary of how many vulnerability occurrences there are per resource and severity type.
2917///
2918/// # Activities
2919///
2920/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2921/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2922///
2923/// * [locations occurrences get vulnerability summary projects](ProjectLocationOccurrenceGetVulnerabilitySummaryCall) (response)
2924/// * [occurrences get vulnerability summary projects](ProjectOccurrenceGetVulnerabilitySummaryCall) (response)
2925#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2926#[serde_with::serde_as]
2927#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2928pub struct VulnerabilityOccurrencesSummary {
2929 /// A listing by resource of the number of fixable and total vulnerabilities.
2930 pub counts: Option<Vec<FixableTotalByDigest>>,
2931}
2932
2933impl common::ResponseResult for VulnerabilityOccurrencesSummary {}
2934
2935/// There is no detailed description.
2936///
2937/// This type is not used in any activity, and only used as *part* of another schema.
2938///
2939#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2940#[serde_with::serde_as]
2941#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2942pub struct WindowsDetail {
2943 /// Required. The [CPE URI](https://cpe.mitre.org/specification/) this vulnerability affects.
2944 #[serde(rename = "cpeUri")]
2945 pub cpe_uri: Option<String>,
2946 /// The description of this vulnerability.
2947 pub description: Option<String>,
2948 /// Required. The names of the KBs which have hotfixes to mitigate this vulnerability. Note that there may be multiple hotfixes (and thus multiple KBs) that mitigate a given vulnerability. Currently any listed KBs presence is considered a fix.
2949 #[serde(rename = "fixingKbs")]
2950 pub fixing_kbs: Option<Vec<KnowledgeBase>>,
2951 /// Required. The name of this vulnerability.
2952 pub name: Option<String>,
2953}
2954
2955impl common::Part for WindowsDetail {}
2956
2957/// Windows Update represents the metadata about the update for the Windows operating system. The fields in this message come from the Windows Update API documented at https://docs.microsoft.com/en-us/windows/win32/api/wuapi/nn-wuapi-iupdate.
2958///
2959/// This type is not used in any activity, and only used as *part* of another schema.
2960///
2961#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2962#[serde_with::serde_as]
2963#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2964pub struct WindowsUpdate {
2965 /// The list of categories to which the update belongs.
2966 pub categories: Option<Vec<Category>>,
2967 /// The localized description of the update.
2968 pub description: Option<String>,
2969 /// Required - The unique identifier for the update.
2970 pub identity: Option<Identity>,
2971 /// The Microsoft Knowledge Base article IDs that are associated with the update.
2972 #[serde(rename = "kbArticleIds")]
2973 pub kb_article_ids: Option<Vec<String>>,
2974 /// The last published timestamp of the update.
2975 #[serde(rename = "lastPublishedTimestamp")]
2976 pub last_published_timestamp: Option<chrono::DateTime<chrono::offset::Utc>>,
2977 /// The hyperlink to the support information for the update.
2978 #[serde(rename = "supportUrl")]
2979 pub support_url: Option<String>,
2980 /// The localized title of the update.
2981 pub title: Option<String>,
2982}
2983
2984impl common::Part for WindowsUpdate {}
2985
2986// ###################
2987// MethodBuilders ###
2988// #################
2989
2990/// A builder providing access to all methods supported on *project* resources.
2991/// It is not used directly, but through the [`ContainerAnalysis`] hub.
2992///
2993/// # Example
2994///
2995/// Instantiate a resource builder
2996///
2997/// ```test_harness,no_run
2998/// extern crate hyper;
2999/// extern crate hyper_rustls;
3000/// extern crate google_containeranalysis1 as containeranalysis1;
3001///
3002/// # async fn dox() {
3003/// use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3004///
3005/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3006/// let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3007/// secret,
3008/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3009/// ).build().await.unwrap();
3010///
3011/// let client = hyper_util::client::legacy::Client::builder(
3012/// hyper_util::rt::TokioExecutor::new()
3013/// )
3014/// .build(
3015/// hyper_rustls::HttpsConnectorBuilder::new()
3016/// .with_native_roots()
3017/// .unwrap()
3018/// .https_or_http()
3019/// .enable_http1()
3020/// .build()
3021/// );
3022/// let mut hub = ContainerAnalysis::new(client, auth);
3023/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3024/// // like `locations_notes_get(...)`, `locations_notes_list(...)`, `locations_notes_occurrences_list(...)`, `locations_occurrences_get(...)`, `locations_occurrences_get_notes(...)`, `locations_occurrences_get_vulnerability_summary(...)`, `locations_occurrences_list(...)`, `locations_resources_export_sbom(...)`, `notes_batch_create(...)`, `notes_create(...)`, `notes_delete(...)`, `notes_get(...)`, `notes_get_iam_policy(...)`, `notes_list(...)`, `notes_occurrences_list(...)`, `notes_patch(...)`, `notes_set_iam_policy(...)`, `notes_test_iam_permissions(...)`, `occurrences_batch_create(...)`, `occurrences_create(...)`, `occurrences_delete(...)`, `occurrences_get(...)`, `occurrences_get_iam_policy(...)`, `occurrences_get_notes(...)`, `occurrences_get_vulnerability_summary(...)`, `occurrences_list(...)`, `occurrences_patch(...)`, `occurrences_set_iam_policy(...)`, `occurrences_test_iam_permissions(...)` and `resources_export_sbom(...)`
3025/// // to build up your call.
3026/// let rb = hub.projects();
3027/// # }
3028/// ```
3029pub struct ProjectMethods<'a, C>
3030where
3031 C: 'a,
3032{
3033 hub: &'a ContainerAnalysis<C>,
3034}
3035
3036impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
3037
3038impl<'a, C> ProjectMethods<'a, C> {
3039 /// Create a builder to help you perform the following task:
3040 ///
3041 /// Lists occurrences referencing the specified note. Provider projects can use this method to get all occurrences across consumer projects referencing the specified note.
3042 ///
3043 /// # Arguments
3044 ///
3045 /// * `name` - Required. The name of the note to list occurrences for in the form of `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.
3046 pub fn locations_notes_occurrences_list(
3047 &self,
3048 name: &str,
3049 ) -> ProjectLocationNoteOccurrenceListCall<'a, C> {
3050 ProjectLocationNoteOccurrenceListCall {
3051 hub: self.hub,
3052 _name: name.to_string(),
3053 _page_token: Default::default(),
3054 _page_size: Default::default(),
3055 _filter: Default::default(),
3056 _delegate: Default::default(),
3057 _additional_params: Default::default(),
3058 _scopes: Default::default(),
3059 }
3060 }
3061
3062 /// Create a builder to help you perform the following task:
3063 ///
3064 /// Gets the specified note.
3065 ///
3066 /// # Arguments
3067 ///
3068 /// * `name` - Required. The name of the note in the form of `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.
3069 pub fn locations_notes_get(&self, name: &str) -> ProjectLocationNoteGetCall<'a, C> {
3070 ProjectLocationNoteGetCall {
3071 hub: self.hub,
3072 _name: name.to_string(),
3073 _delegate: Default::default(),
3074 _additional_params: Default::default(),
3075 _scopes: Default::default(),
3076 }
3077 }
3078
3079 /// Create a builder to help you perform the following task:
3080 ///
3081 /// Lists notes for the specified project.
3082 ///
3083 /// # Arguments
3084 ///
3085 /// * `parent` - Required. The name of the project to list notes for in the form of `projects/[PROJECT_ID]`.
3086 pub fn locations_notes_list(&self, parent: &str) -> ProjectLocationNoteListCall<'a, C> {
3087 ProjectLocationNoteListCall {
3088 hub: self.hub,
3089 _parent: parent.to_string(),
3090 _page_token: Default::default(),
3091 _page_size: Default::default(),
3092 _filter: Default::default(),
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 /// Gets the specified occurrence.
3102 ///
3103 /// # Arguments
3104 ///
3105 /// * `name` - Required. The name of the occurrence in the form of `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.
3106 pub fn locations_occurrences_get(&self, name: &str) -> ProjectLocationOccurrenceGetCall<'a, C> {
3107 ProjectLocationOccurrenceGetCall {
3108 hub: self.hub,
3109 _name: name.to_string(),
3110 _delegate: Default::default(),
3111 _additional_params: Default::default(),
3112 _scopes: Default::default(),
3113 }
3114 }
3115
3116 /// Create a builder to help you perform the following task:
3117 ///
3118 /// Gets the note attached to the specified occurrence. Consumer projects can use this method to get a note that belongs to a provider project.
3119 ///
3120 /// # Arguments
3121 ///
3122 /// * `name` - Required. The name of the occurrence in the form of `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.
3123 pub fn locations_occurrences_get_notes(
3124 &self,
3125 name: &str,
3126 ) -> ProjectLocationOccurrenceGetNoteCall<'a, C> {
3127 ProjectLocationOccurrenceGetNoteCall {
3128 hub: self.hub,
3129 _name: name.to_string(),
3130 _delegate: Default::default(),
3131 _additional_params: Default::default(),
3132 _scopes: Default::default(),
3133 }
3134 }
3135
3136 /// Create a builder to help you perform the following task:
3137 ///
3138 /// Gets a summary of the number and severity of occurrences.
3139 ///
3140 /// # Arguments
3141 ///
3142 /// * `parent` - Required. The name of the project to get a vulnerability summary for in the form of `projects/[PROJECT_ID]`.
3143 pub fn locations_occurrences_get_vulnerability_summary(
3144 &self,
3145 parent: &str,
3146 ) -> ProjectLocationOccurrenceGetVulnerabilitySummaryCall<'a, C> {
3147 ProjectLocationOccurrenceGetVulnerabilitySummaryCall {
3148 hub: self.hub,
3149 _parent: parent.to_string(),
3150 _filter: Default::default(),
3151 _delegate: Default::default(),
3152 _additional_params: Default::default(),
3153 _scopes: Default::default(),
3154 }
3155 }
3156
3157 /// Create a builder to help you perform the following task:
3158 ///
3159 /// Lists occurrences for the specified project.
3160 ///
3161 /// # Arguments
3162 ///
3163 /// * `parent` - Required. The name of the project to list occurrences for in the form of `projects/[PROJECT_ID]`.
3164 pub fn locations_occurrences_list(
3165 &self,
3166 parent: &str,
3167 ) -> ProjectLocationOccurrenceListCall<'a, C> {
3168 ProjectLocationOccurrenceListCall {
3169 hub: self.hub,
3170 _parent: parent.to_string(),
3171 _page_token: Default::default(),
3172 _page_size: Default::default(),
3173 _filter: Default::default(),
3174 _delegate: Default::default(),
3175 _additional_params: Default::default(),
3176 _scopes: Default::default(),
3177 }
3178 }
3179
3180 /// Create a builder to help you perform the following task:
3181 ///
3182 /// Generates an SBOM for the given resource.
3183 ///
3184 /// # Arguments
3185 ///
3186 /// * `request` - No description provided.
3187 /// * `name` - Required. The name of the resource in the form of `projects/[PROJECT_ID]/resources/[RESOURCE_URL]`.
3188 pub fn locations_resources_export_sbom(
3189 &self,
3190 request: ExportSBOMRequest,
3191 name: &str,
3192 ) -> ProjectLocationResourceExportSBOMCall<'a, C> {
3193 ProjectLocationResourceExportSBOMCall {
3194 hub: self.hub,
3195 _request: request,
3196 _name: name.to_string(),
3197 _delegate: Default::default(),
3198 _additional_params: Default::default(),
3199 _scopes: Default::default(),
3200 }
3201 }
3202
3203 /// Create a builder to help you perform the following task:
3204 ///
3205 /// Lists occurrences referencing the specified note. Provider projects can use this method to get all occurrences across consumer projects referencing the specified note.
3206 ///
3207 /// # Arguments
3208 ///
3209 /// * `name` - Required. The name of the note to list occurrences for in the form of `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.
3210 pub fn notes_occurrences_list(&self, name: &str) -> ProjectNoteOccurrenceListCall<'a, C> {
3211 ProjectNoteOccurrenceListCall {
3212 hub: self.hub,
3213 _name: name.to_string(),
3214 _page_token: Default::default(),
3215 _page_size: Default::default(),
3216 _filter: Default::default(),
3217 _delegate: Default::default(),
3218 _additional_params: Default::default(),
3219 _scopes: Default::default(),
3220 }
3221 }
3222
3223 /// Create a builder to help you perform the following task:
3224 ///
3225 /// Creates new notes in batch.
3226 ///
3227 /// # Arguments
3228 ///
3229 /// * `request` - No description provided.
3230 /// * `parent` - Required. The name of the project in the form of `projects/[PROJECT_ID]`, under which the notes are to be created.
3231 pub fn notes_batch_create(
3232 &self,
3233 request: BatchCreateNotesRequest,
3234 parent: &str,
3235 ) -> ProjectNoteBatchCreateCall<'a, C> {
3236 ProjectNoteBatchCreateCall {
3237 hub: self.hub,
3238 _request: request,
3239 _parent: parent.to_string(),
3240 _delegate: Default::default(),
3241 _additional_params: Default::default(),
3242 _scopes: Default::default(),
3243 }
3244 }
3245
3246 /// Create a builder to help you perform the following task:
3247 ///
3248 /// Creates a new note.
3249 ///
3250 /// # Arguments
3251 ///
3252 /// * `request` - No description provided.
3253 /// * `parent` - Required. The name of the project in the form of `projects/[PROJECT_ID]`, under which the note is to be created.
3254 pub fn notes_create(&self, request: Note, parent: &str) -> ProjectNoteCreateCall<'a, C> {
3255 ProjectNoteCreateCall {
3256 hub: self.hub,
3257 _request: request,
3258 _parent: parent.to_string(),
3259 _note_id: Default::default(),
3260 _delegate: Default::default(),
3261 _additional_params: Default::default(),
3262 _scopes: Default::default(),
3263 }
3264 }
3265
3266 /// Create a builder to help you perform the following task:
3267 ///
3268 /// Deletes the specified note.
3269 ///
3270 /// # Arguments
3271 ///
3272 /// * `name` - Required. The name of the note in the form of `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.
3273 pub fn notes_delete(&self, name: &str) -> ProjectNoteDeleteCall<'a, C> {
3274 ProjectNoteDeleteCall {
3275 hub: self.hub,
3276 _name: name.to_string(),
3277 _delegate: Default::default(),
3278 _additional_params: Default::default(),
3279 _scopes: Default::default(),
3280 }
3281 }
3282
3283 /// Create a builder to help you perform the following task:
3284 ///
3285 /// Gets the specified note.
3286 ///
3287 /// # Arguments
3288 ///
3289 /// * `name` - Required. The name of the note in the form of `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.
3290 pub fn notes_get(&self, name: &str) -> ProjectNoteGetCall<'a, C> {
3291 ProjectNoteGetCall {
3292 hub: self.hub,
3293 _name: name.to_string(),
3294 _delegate: Default::default(),
3295 _additional_params: Default::default(),
3296 _scopes: Default::default(),
3297 }
3298 }
3299
3300 /// Create a builder to help you perform the following task:
3301 ///
3302 /// Gets the access control policy for a note or an occurrence resource. Requires `containeranalysis.notes.setIamPolicy` or `containeranalysis.occurrences.setIamPolicy` permission if the resource is a note or occurrence, respectively. The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
3303 ///
3304 /// # Arguments
3305 ///
3306 /// * `request` - No description provided.
3307 /// * `resource` - REQUIRED: The resource for which the policy is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
3308 pub fn notes_get_iam_policy(
3309 &self,
3310 request: GetIamPolicyRequest,
3311 resource: &str,
3312 ) -> ProjectNoteGetIamPolicyCall<'a, C> {
3313 ProjectNoteGetIamPolicyCall {
3314 hub: self.hub,
3315 _request: request,
3316 _resource: resource.to_string(),
3317 _delegate: Default::default(),
3318 _additional_params: Default::default(),
3319 _scopes: Default::default(),
3320 }
3321 }
3322
3323 /// Create a builder to help you perform the following task:
3324 ///
3325 /// Lists notes for the specified project.
3326 ///
3327 /// # Arguments
3328 ///
3329 /// * `parent` - Required. The name of the project to list notes for in the form of `projects/[PROJECT_ID]`.
3330 pub fn notes_list(&self, parent: &str) -> ProjectNoteListCall<'a, C> {
3331 ProjectNoteListCall {
3332 hub: self.hub,
3333 _parent: parent.to_string(),
3334 _page_token: Default::default(),
3335 _page_size: Default::default(),
3336 _filter: Default::default(),
3337 _delegate: Default::default(),
3338 _additional_params: Default::default(),
3339 _scopes: Default::default(),
3340 }
3341 }
3342
3343 /// Create a builder to help you perform the following task:
3344 ///
3345 /// Updates the specified note.
3346 ///
3347 /// # Arguments
3348 ///
3349 /// * `request` - No description provided.
3350 /// * `name` - Required. The name of the note in the form of `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.
3351 pub fn notes_patch(&self, request: Note, name: &str) -> ProjectNotePatchCall<'a, C> {
3352 ProjectNotePatchCall {
3353 hub: self.hub,
3354 _request: request,
3355 _name: name.to_string(),
3356 _update_mask: Default::default(),
3357 _delegate: Default::default(),
3358 _additional_params: Default::default(),
3359 _scopes: Default::default(),
3360 }
3361 }
3362
3363 /// Create a builder to help you perform the following task:
3364 ///
3365 /// Sets the access control policy on the specified note or occurrence. Requires `containeranalysis.notes.setIamPolicy` or `containeranalysis.occurrences.setIamPolicy` permission if the resource is a note or an occurrence, respectively. The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
3366 ///
3367 /// # Arguments
3368 ///
3369 /// * `request` - No description provided.
3370 /// * `resource` - REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
3371 pub fn notes_set_iam_policy(
3372 &self,
3373 request: SetIamPolicyRequest,
3374 resource: &str,
3375 ) -> ProjectNoteSetIamPolicyCall<'a, C> {
3376 ProjectNoteSetIamPolicyCall {
3377 hub: self.hub,
3378 _request: request,
3379 _resource: resource.to_string(),
3380 _delegate: Default::default(),
3381 _additional_params: Default::default(),
3382 _scopes: Default::default(),
3383 }
3384 }
3385
3386 /// Create a builder to help you perform the following task:
3387 ///
3388 /// Returns the permissions that a caller has on the specified note or occurrence. Requires list permission on the project (for example, `containeranalysis.notes.list`). The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
3389 ///
3390 /// # Arguments
3391 ///
3392 /// * `request` - No description provided.
3393 /// * `resource` - REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
3394 pub fn notes_test_iam_permissions(
3395 &self,
3396 request: TestIamPermissionsRequest,
3397 resource: &str,
3398 ) -> ProjectNoteTestIamPermissionCall<'a, C> {
3399 ProjectNoteTestIamPermissionCall {
3400 hub: self.hub,
3401 _request: request,
3402 _resource: resource.to_string(),
3403 _delegate: Default::default(),
3404 _additional_params: Default::default(),
3405 _scopes: Default::default(),
3406 }
3407 }
3408
3409 /// Create a builder to help you perform the following task:
3410 ///
3411 /// Creates new occurrences in batch.
3412 ///
3413 /// # Arguments
3414 ///
3415 /// * `request` - No description provided.
3416 /// * `parent` - Required. The name of the project in the form of `projects/[PROJECT_ID]`, under which the occurrences are to be created.
3417 pub fn occurrences_batch_create(
3418 &self,
3419 request: BatchCreateOccurrencesRequest,
3420 parent: &str,
3421 ) -> ProjectOccurrenceBatchCreateCall<'a, C> {
3422 ProjectOccurrenceBatchCreateCall {
3423 hub: self.hub,
3424 _request: request,
3425 _parent: parent.to_string(),
3426 _delegate: Default::default(),
3427 _additional_params: Default::default(),
3428 _scopes: Default::default(),
3429 }
3430 }
3431
3432 /// Create a builder to help you perform the following task:
3433 ///
3434 /// Creates a new occurrence.
3435 ///
3436 /// # Arguments
3437 ///
3438 /// * `request` - No description provided.
3439 /// * `parent` - Required. The name of the project in the form of `projects/[PROJECT_ID]`, under which the occurrence is to be created.
3440 pub fn occurrences_create(
3441 &self,
3442 request: Occurrence,
3443 parent: &str,
3444 ) -> ProjectOccurrenceCreateCall<'a, C> {
3445 ProjectOccurrenceCreateCall {
3446 hub: self.hub,
3447 _request: request,
3448 _parent: parent.to_string(),
3449 _delegate: Default::default(),
3450 _additional_params: Default::default(),
3451 _scopes: Default::default(),
3452 }
3453 }
3454
3455 /// Create a builder to help you perform the following task:
3456 ///
3457 /// Deletes the specified occurrence. For example, use this method to delete an occurrence when the occurrence is no longer applicable for the given resource.
3458 ///
3459 /// # Arguments
3460 ///
3461 /// * `name` - Required. The name of the occurrence in the form of `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.
3462 pub fn occurrences_delete(&self, name: &str) -> ProjectOccurrenceDeleteCall<'a, C> {
3463 ProjectOccurrenceDeleteCall {
3464 hub: self.hub,
3465 _name: name.to_string(),
3466 _delegate: Default::default(),
3467 _additional_params: Default::default(),
3468 _scopes: Default::default(),
3469 }
3470 }
3471
3472 /// Create a builder to help you perform the following task:
3473 ///
3474 /// Gets the specified occurrence.
3475 ///
3476 /// # Arguments
3477 ///
3478 /// * `name` - Required. The name of the occurrence in the form of `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.
3479 pub fn occurrences_get(&self, name: &str) -> ProjectOccurrenceGetCall<'a, C> {
3480 ProjectOccurrenceGetCall {
3481 hub: self.hub,
3482 _name: name.to_string(),
3483 _delegate: Default::default(),
3484 _additional_params: Default::default(),
3485 _scopes: Default::default(),
3486 }
3487 }
3488
3489 /// Create a builder to help you perform the following task:
3490 ///
3491 /// Gets the access control policy for a note or an occurrence resource. Requires `containeranalysis.notes.setIamPolicy` or `containeranalysis.occurrences.setIamPolicy` permission if the resource is a note or occurrence, respectively. The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
3492 ///
3493 /// # Arguments
3494 ///
3495 /// * `request` - No description provided.
3496 /// * `resource` - REQUIRED: The resource for which the policy is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
3497 pub fn occurrences_get_iam_policy(
3498 &self,
3499 request: GetIamPolicyRequest,
3500 resource: &str,
3501 ) -> ProjectOccurrenceGetIamPolicyCall<'a, C> {
3502 ProjectOccurrenceGetIamPolicyCall {
3503 hub: self.hub,
3504 _request: request,
3505 _resource: resource.to_string(),
3506 _delegate: Default::default(),
3507 _additional_params: Default::default(),
3508 _scopes: Default::default(),
3509 }
3510 }
3511
3512 /// Create a builder to help you perform the following task:
3513 ///
3514 /// Gets the note attached to the specified occurrence. Consumer projects can use this method to get a note that belongs to a provider project.
3515 ///
3516 /// # Arguments
3517 ///
3518 /// * `name` - Required. The name of the occurrence in the form of `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.
3519 pub fn occurrences_get_notes(&self, name: &str) -> ProjectOccurrenceGetNoteCall<'a, C> {
3520 ProjectOccurrenceGetNoteCall {
3521 hub: self.hub,
3522 _name: name.to_string(),
3523 _delegate: Default::default(),
3524 _additional_params: Default::default(),
3525 _scopes: Default::default(),
3526 }
3527 }
3528
3529 /// Create a builder to help you perform the following task:
3530 ///
3531 /// Gets a summary of the number and severity of occurrences.
3532 ///
3533 /// # Arguments
3534 ///
3535 /// * `parent` - Required. The name of the project to get a vulnerability summary for in the form of `projects/[PROJECT_ID]`.
3536 pub fn occurrences_get_vulnerability_summary(
3537 &self,
3538 parent: &str,
3539 ) -> ProjectOccurrenceGetVulnerabilitySummaryCall<'a, C> {
3540 ProjectOccurrenceGetVulnerabilitySummaryCall {
3541 hub: self.hub,
3542 _parent: parent.to_string(),
3543 _filter: Default::default(),
3544 _delegate: Default::default(),
3545 _additional_params: Default::default(),
3546 _scopes: Default::default(),
3547 }
3548 }
3549
3550 /// Create a builder to help you perform the following task:
3551 ///
3552 /// Lists occurrences for the specified project.
3553 ///
3554 /// # Arguments
3555 ///
3556 /// * `parent` - Required. The name of the project to list occurrences for in the form of `projects/[PROJECT_ID]`.
3557 pub fn occurrences_list(&self, parent: &str) -> ProjectOccurrenceListCall<'a, C> {
3558 ProjectOccurrenceListCall {
3559 hub: self.hub,
3560 _parent: parent.to_string(),
3561 _page_token: Default::default(),
3562 _page_size: Default::default(),
3563 _filter: 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 /// Updates the specified occurrence.
3573 ///
3574 /// # Arguments
3575 ///
3576 /// * `request` - No description provided.
3577 /// * `name` - Required. The name of the occurrence in the form of `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.
3578 pub fn occurrences_patch(
3579 &self,
3580 request: Occurrence,
3581 name: &str,
3582 ) -> ProjectOccurrencePatchCall<'a, C> {
3583 ProjectOccurrencePatchCall {
3584 hub: self.hub,
3585 _request: request,
3586 _name: name.to_string(),
3587 _update_mask: 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 /// Sets the access control policy on the specified note or occurrence. Requires `containeranalysis.notes.setIamPolicy` or `containeranalysis.occurrences.setIamPolicy` permission if the resource is a note or an occurrence, respectively. The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
3597 ///
3598 /// # Arguments
3599 ///
3600 /// * `request` - No description provided.
3601 /// * `resource` - REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
3602 pub fn occurrences_set_iam_policy(
3603 &self,
3604 request: SetIamPolicyRequest,
3605 resource: &str,
3606 ) -> ProjectOccurrenceSetIamPolicyCall<'a, C> {
3607 ProjectOccurrenceSetIamPolicyCall {
3608 hub: self.hub,
3609 _request: request,
3610 _resource: resource.to_string(),
3611 _delegate: Default::default(),
3612 _additional_params: Default::default(),
3613 _scopes: Default::default(),
3614 }
3615 }
3616
3617 /// Create a builder to help you perform the following task:
3618 ///
3619 /// Returns the permissions that a caller has on the specified note or occurrence. Requires list permission on the project (for example, `containeranalysis.notes.list`). The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
3620 ///
3621 /// # Arguments
3622 ///
3623 /// * `request` - No description provided.
3624 /// * `resource` - REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
3625 pub fn occurrences_test_iam_permissions(
3626 &self,
3627 request: TestIamPermissionsRequest,
3628 resource: &str,
3629 ) -> ProjectOccurrenceTestIamPermissionCall<'a, C> {
3630 ProjectOccurrenceTestIamPermissionCall {
3631 hub: self.hub,
3632 _request: request,
3633 _resource: resource.to_string(),
3634 _delegate: Default::default(),
3635 _additional_params: Default::default(),
3636 _scopes: Default::default(),
3637 }
3638 }
3639
3640 /// Create a builder to help you perform the following task:
3641 ///
3642 /// Generates an SBOM for the given resource.
3643 ///
3644 /// # Arguments
3645 ///
3646 /// * `request` - No description provided.
3647 /// * `name` - Required. The name of the resource in the form of `projects/[PROJECT_ID]/resources/[RESOURCE_URL]`.
3648 pub fn resources_export_sbom(
3649 &self,
3650 request: ExportSBOMRequest,
3651 name: &str,
3652 ) -> ProjectResourceExportSBOMCall<'a, C> {
3653 ProjectResourceExportSBOMCall {
3654 hub: self.hub,
3655 _request: request,
3656 _name: name.to_string(),
3657 _delegate: Default::default(),
3658 _additional_params: Default::default(),
3659 _scopes: Default::default(),
3660 }
3661 }
3662}
3663
3664// ###################
3665// CallBuilders ###
3666// #################
3667
3668/// Lists occurrences referencing the specified note. Provider projects can use this method to get all occurrences across consumer projects referencing the specified note.
3669///
3670/// A builder for the *locations.notes.occurrences.list* method supported by a *project* resource.
3671/// It is not used directly, but through a [`ProjectMethods`] instance.
3672///
3673/// # Example
3674///
3675/// Instantiate a resource method builder
3676///
3677/// ```test_harness,no_run
3678/// # extern crate hyper;
3679/// # extern crate hyper_rustls;
3680/// # extern crate google_containeranalysis1 as containeranalysis1;
3681/// # async fn dox() {
3682/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3683///
3684/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3685/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
3686/// # secret,
3687/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3688/// # ).build().await.unwrap();
3689///
3690/// # let client = hyper_util::client::legacy::Client::builder(
3691/// # hyper_util::rt::TokioExecutor::new()
3692/// # )
3693/// # .build(
3694/// # hyper_rustls::HttpsConnectorBuilder::new()
3695/// # .with_native_roots()
3696/// # .unwrap()
3697/// # .https_or_http()
3698/// # .enable_http1()
3699/// # .build()
3700/// # );
3701/// # let mut hub = ContainerAnalysis::new(client, auth);
3702/// // You can configure optional parameters by calling the respective setters at will, and
3703/// // execute the final call using `doit()`.
3704/// // Values shown here are possibly random and not representative !
3705/// let result = hub.projects().locations_notes_occurrences_list("name")
3706/// .page_token("sed")
3707/// .page_size(-2)
3708/// .filter("takimata")
3709/// .doit().await;
3710/// # }
3711/// ```
3712pub struct ProjectLocationNoteOccurrenceListCall<'a, C>
3713where
3714 C: 'a,
3715{
3716 hub: &'a ContainerAnalysis<C>,
3717 _name: String,
3718 _page_token: Option<String>,
3719 _page_size: Option<i32>,
3720 _filter: Option<String>,
3721 _delegate: Option<&'a mut dyn common::Delegate>,
3722 _additional_params: HashMap<String, String>,
3723 _scopes: BTreeSet<String>,
3724}
3725
3726impl<'a, C> common::CallBuilder for ProjectLocationNoteOccurrenceListCall<'a, C> {}
3727
3728impl<'a, C> ProjectLocationNoteOccurrenceListCall<'a, C>
3729where
3730 C: common::Connector,
3731{
3732 /// Perform the operation you have build so far.
3733 pub async fn doit(mut self) -> common::Result<(common::Response, ListNoteOccurrencesResponse)> {
3734 use std::borrow::Cow;
3735 use std::io::{Read, Seek};
3736
3737 use common::{url::Params, ToParts};
3738 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3739
3740 let mut dd = common::DefaultDelegate;
3741 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3742 dlg.begin(common::MethodInfo {
3743 id: "containeranalysis.projects.locations.notes.occurrences.list",
3744 http_method: hyper::Method::GET,
3745 });
3746
3747 for &field in ["alt", "name", "pageToken", "pageSize", "filter"].iter() {
3748 if self._additional_params.contains_key(field) {
3749 dlg.finished(false);
3750 return Err(common::Error::FieldClash(field));
3751 }
3752 }
3753
3754 let mut params = Params::with_capacity(6 + self._additional_params.len());
3755 params.push("name", self._name);
3756 if let Some(value) = self._page_token.as_ref() {
3757 params.push("pageToken", value);
3758 }
3759 if let Some(value) = self._page_size.as_ref() {
3760 params.push("pageSize", value.to_string());
3761 }
3762 if let Some(value) = self._filter.as_ref() {
3763 params.push("filter", value);
3764 }
3765
3766 params.extend(self._additional_params.iter());
3767
3768 params.push("alt", "json");
3769 let mut url = self.hub._base_url.clone() + "v1/{+name}/occurrences";
3770 if self._scopes.is_empty() {
3771 self._scopes
3772 .insert(Scope::CloudPlatform.as_ref().to_string());
3773 }
3774
3775 #[allow(clippy::single_element_loop)]
3776 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3777 url = params.uri_replacement(url, param_name, find_this, true);
3778 }
3779 {
3780 let to_remove = ["name"];
3781 params.remove_params(&to_remove);
3782 }
3783
3784 let url = params.parse_with_url(&url);
3785
3786 loop {
3787 let token = match self
3788 .hub
3789 .auth
3790 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3791 .await
3792 {
3793 Ok(token) => token,
3794 Err(e) => match dlg.token(e) {
3795 Ok(token) => token,
3796 Err(e) => {
3797 dlg.finished(false);
3798 return Err(common::Error::MissingToken(e));
3799 }
3800 },
3801 };
3802 let mut req_result = {
3803 let client = &self.hub.client;
3804 dlg.pre_request();
3805 let mut req_builder = hyper::Request::builder()
3806 .method(hyper::Method::GET)
3807 .uri(url.as_str())
3808 .header(USER_AGENT, self.hub._user_agent.clone());
3809
3810 if let Some(token) = token.as_ref() {
3811 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3812 }
3813
3814 let request = req_builder
3815 .header(CONTENT_LENGTH, 0_u64)
3816 .body(common::to_body::<String>(None));
3817
3818 client.request(request.unwrap()).await
3819 };
3820
3821 match req_result {
3822 Err(err) => {
3823 if let common::Retry::After(d) = dlg.http_error(&err) {
3824 sleep(d).await;
3825 continue;
3826 }
3827 dlg.finished(false);
3828 return Err(common::Error::HttpError(err));
3829 }
3830 Ok(res) => {
3831 let (mut parts, body) = res.into_parts();
3832 let mut body = common::Body::new(body);
3833 if !parts.status.is_success() {
3834 let bytes = common::to_bytes(body).await.unwrap_or_default();
3835 let error = serde_json::from_str(&common::to_string(&bytes));
3836 let response = common::to_response(parts, bytes.into());
3837
3838 if let common::Retry::After(d) =
3839 dlg.http_failure(&response, error.as_ref().ok())
3840 {
3841 sleep(d).await;
3842 continue;
3843 }
3844
3845 dlg.finished(false);
3846
3847 return Err(match error {
3848 Ok(value) => common::Error::BadRequest(value),
3849 _ => common::Error::Failure(response),
3850 });
3851 }
3852 let response = {
3853 let bytes = common::to_bytes(body).await.unwrap_or_default();
3854 let encoded = common::to_string(&bytes);
3855 match serde_json::from_str(&encoded) {
3856 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3857 Err(error) => {
3858 dlg.response_json_decode_error(&encoded, &error);
3859 return Err(common::Error::JsonDecodeError(
3860 encoded.to_string(),
3861 error,
3862 ));
3863 }
3864 }
3865 };
3866
3867 dlg.finished(true);
3868 return Ok(response);
3869 }
3870 }
3871 }
3872 }
3873
3874 /// Required. The name of the note to list occurrences for in the form of `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.
3875 ///
3876 /// Sets the *name* path property to the given value.
3877 ///
3878 /// Even though the property as already been set when instantiating this call,
3879 /// we provide this method for API completeness.
3880 pub fn name(mut self, new_value: &str) -> ProjectLocationNoteOccurrenceListCall<'a, C> {
3881 self._name = new_value.to_string();
3882 self
3883 }
3884 /// Token to provide to skip to a particular spot in the list.
3885 ///
3886 /// Sets the *page token* query property to the given value.
3887 pub fn page_token(mut self, new_value: &str) -> ProjectLocationNoteOccurrenceListCall<'a, C> {
3888 self._page_token = Some(new_value.to_string());
3889 self
3890 }
3891 /// Number of occurrences to return in the list.
3892 ///
3893 /// Sets the *page size* query property to the given value.
3894 pub fn page_size(mut self, new_value: i32) -> ProjectLocationNoteOccurrenceListCall<'a, C> {
3895 self._page_size = Some(new_value);
3896 self
3897 }
3898 /// The filter expression.
3899 ///
3900 /// Sets the *filter* query property to the given value.
3901 pub fn filter(mut self, new_value: &str) -> ProjectLocationNoteOccurrenceListCall<'a, C> {
3902 self._filter = Some(new_value.to_string());
3903 self
3904 }
3905 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3906 /// while executing the actual API request.
3907 ///
3908 /// ````text
3909 /// It should be used to handle progress information, and to implement a certain level of resilience.
3910 /// ````
3911 ///
3912 /// Sets the *delegate* property to the given value.
3913 pub fn delegate(
3914 mut self,
3915 new_value: &'a mut dyn common::Delegate,
3916 ) -> ProjectLocationNoteOccurrenceListCall<'a, C> {
3917 self._delegate = Some(new_value);
3918 self
3919 }
3920
3921 /// Set any additional parameter of the query string used in the request.
3922 /// It should be used to set parameters which are not yet available through their own
3923 /// setters.
3924 ///
3925 /// Please note that this method must not be used to set any of the known parameters
3926 /// which have their own setter method. If done anyway, the request will fail.
3927 ///
3928 /// # Additional Parameters
3929 ///
3930 /// * *$.xgafv* (query-string) - V1 error format.
3931 /// * *access_token* (query-string) - OAuth access token.
3932 /// * *alt* (query-string) - Data format for response.
3933 /// * *callback* (query-string) - JSONP
3934 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3935 /// * *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.
3936 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3937 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3938 /// * *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.
3939 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3940 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3941 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNoteOccurrenceListCall<'a, C>
3942 where
3943 T: AsRef<str>,
3944 {
3945 self._additional_params
3946 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3947 self
3948 }
3949
3950 /// Identifies the authorization scope for the method you are building.
3951 ///
3952 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3953 /// [`Scope::CloudPlatform`].
3954 ///
3955 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3956 /// tokens for more than one scope.
3957 ///
3958 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3959 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3960 /// sufficient, a read-write scope will do as well.
3961 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNoteOccurrenceListCall<'a, C>
3962 where
3963 St: AsRef<str>,
3964 {
3965 self._scopes.insert(String::from(scope.as_ref()));
3966 self
3967 }
3968 /// Identifies the authorization scope(s) for the method you are building.
3969 ///
3970 /// See [`Self::add_scope()`] for details.
3971 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNoteOccurrenceListCall<'a, C>
3972 where
3973 I: IntoIterator<Item = St>,
3974 St: AsRef<str>,
3975 {
3976 self._scopes
3977 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3978 self
3979 }
3980
3981 /// Removes all scopes, and no default scope will be used either.
3982 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3983 /// for details).
3984 pub fn clear_scopes(mut self) -> ProjectLocationNoteOccurrenceListCall<'a, C> {
3985 self._scopes.clear();
3986 self
3987 }
3988}
3989
3990/// Gets the specified note.
3991///
3992/// A builder for the *locations.notes.get* method supported by a *project* resource.
3993/// It is not used directly, but through a [`ProjectMethods`] instance.
3994///
3995/// # Example
3996///
3997/// Instantiate a resource method builder
3998///
3999/// ```test_harness,no_run
4000/// # extern crate hyper;
4001/// # extern crate hyper_rustls;
4002/// # extern crate google_containeranalysis1 as containeranalysis1;
4003/// # async fn dox() {
4004/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4005///
4006/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4007/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4008/// # secret,
4009/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4010/// # ).build().await.unwrap();
4011///
4012/// # let client = hyper_util::client::legacy::Client::builder(
4013/// # hyper_util::rt::TokioExecutor::new()
4014/// # )
4015/// # .build(
4016/// # hyper_rustls::HttpsConnectorBuilder::new()
4017/// # .with_native_roots()
4018/// # .unwrap()
4019/// # .https_or_http()
4020/// # .enable_http1()
4021/// # .build()
4022/// # );
4023/// # let mut hub = ContainerAnalysis::new(client, auth);
4024/// // You can configure optional parameters by calling the respective setters at will, and
4025/// // execute the final call using `doit()`.
4026/// // Values shown here are possibly random and not representative !
4027/// let result = hub.projects().locations_notes_get("name")
4028/// .doit().await;
4029/// # }
4030/// ```
4031pub struct ProjectLocationNoteGetCall<'a, C>
4032where
4033 C: 'a,
4034{
4035 hub: &'a ContainerAnalysis<C>,
4036 _name: String,
4037 _delegate: Option<&'a mut dyn common::Delegate>,
4038 _additional_params: HashMap<String, String>,
4039 _scopes: BTreeSet<String>,
4040}
4041
4042impl<'a, C> common::CallBuilder for ProjectLocationNoteGetCall<'a, C> {}
4043
4044impl<'a, C> ProjectLocationNoteGetCall<'a, C>
4045where
4046 C: common::Connector,
4047{
4048 /// Perform the operation you have build so far.
4049 pub async fn doit(mut self) -> common::Result<(common::Response, Note)> {
4050 use std::borrow::Cow;
4051 use std::io::{Read, Seek};
4052
4053 use common::{url::Params, ToParts};
4054 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4055
4056 let mut dd = common::DefaultDelegate;
4057 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4058 dlg.begin(common::MethodInfo {
4059 id: "containeranalysis.projects.locations.notes.get",
4060 http_method: hyper::Method::GET,
4061 });
4062
4063 for &field in ["alt", "name"].iter() {
4064 if self._additional_params.contains_key(field) {
4065 dlg.finished(false);
4066 return Err(common::Error::FieldClash(field));
4067 }
4068 }
4069
4070 let mut params = Params::with_capacity(3 + self._additional_params.len());
4071 params.push("name", self._name);
4072
4073 params.extend(self._additional_params.iter());
4074
4075 params.push("alt", "json");
4076 let mut url = self.hub._base_url.clone() + "v1/{+name}";
4077 if self._scopes.is_empty() {
4078 self._scopes
4079 .insert(Scope::CloudPlatform.as_ref().to_string());
4080 }
4081
4082 #[allow(clippy::single_element_loop)]
4083 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4084 url = params.uri_replacement(url, param_name, find_this, true);
4085 }
4086 {
4087 let to_remove = ["name"];
4088 params.remove_params(&to_remove);
4089 }
4090
4091 let url = params.parse_with_url(&url);
4092
4093 loop {
4094 let token = match self
4095 .hub
4096 .auth
4097 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4098 .await
4099 {
4100 Ok(token) => token,
4101 Err(e) => match dlg.token(e) {
4102 Ok(token) => token,
4103 Err(e) => {
4104 dlg.finished(false);
4105 return Err(common::Error::MissingToken(e));
4106 }
4107 },
4108 };
4109 let mut req_result = {
4110 let client = &self.hub.client;
4111 dlg.pre_request();
4112 let mut req_builder = hyper::Request::builder()
4113 .method(hyper::Method::GET)
4114 .uri(url.as_str())
4115 .header(USER_AGENT, self.hub._user_agent.clone());
4116
4117 if let Some(token) = token.as_ref() {
4118 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4119 }
4120
4121 let request = req_builder
4122 .header(CONTENT_LENGTH, 0_u64)
4123 .body(common::to_body::<String>(None));
4124
4125 client.request(request.unwrap()).await
4126 };
4127
4128 match req_result {
4129 Err(err) => {
4130 if let common::Retry::After(d) = dlg.http_error(&err) {
4131 sleep(d).await;
4132 continue;
4133 }
4134 dlg.finished(false);
4135 return Err(common::Error::HttpError(err));
4136 }
4137 Ok(res) => {
4138 let (mut parts, body) = res.into_parts();
4139 let mut body = common::Body::new(body);
4140 if !parts.status.is_success() {
4141 let bytes = common::to_bytes(body).await.unwrap_or_default();
4142 let error = serde_json::from_str(&common::to_string(&bytes));
4143 let response = common::to_response(parts, bytes.into());
4144
4145 if let common::Retry::After(d) =
4146 dlg.http_failure(&response, error.as_ref().ok())
4147 {
4148 sleep(d).await;
4149 continue;
4150 }
4151
4152 dlg.finished(false);
4153
4154 return Err(match error {
4155 Ok(value) => common::Error::BadRequest(value),
4156 _ => common::Error::Failure(response),
4157 });
4158 }
4159 let response = {
4160 let bytes = common::to_bytes(body).await.unwrap_or_default();
4161 let encoded = common::to_string(&bytes);
4162 match serde_json::from_str(&encoded) {
4163 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4164 Err(error) => {
4165 dlg.response_json_decode_error(&encoded, &error);
4166 return Err(common::Error::JsonDecodeError(
4167 encoded.to_string(),
4168 error,
4169 ));
4170 }
4171 }
4172 };
4173
4174 dlg.finished(true);
4175 return Ok(response);
4176 }
4177 }
4178 }
4179 }
4180
4181 /// Required. The name of the note in the form of `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.
4182 ///
4183 /// Sets the *name* path property to the given value.
4184 ///
4185 /// Even though the property as already been set when instantiating this call,
4186 /// we provide this method for API completeness.
4187 pub fn name(mut self, new_value: &str) -> ProjectLocationNoteGetCall<'a, C> {
4188 self._name = new_value.to_string();
4189 self
4190 }
4191 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4192 /// while executing the actual API request.
4193 ///
4194 /// ````text
4195 /// It should be used to handle progress information, and to implement a certain level of resilience.
4196 /// ````
4197 ///
4198 /// Sets the *delegate* property to the given value.
4199 pub fn delegate(
4200 mut self,
4201 new_value: &'a mut dyn common::Delegate,
4202 ) -> ProjectLocationNoteGetCall<'a, C> {
4203 self._delegate = Some(new_value);
4204 self
4205 }
4206
4207 /// Set any additional parameter of the query string used in the request.
4208 /// It should be used to set parameters which are not yet available through their own
4209 /// setters.
4210 ///
4211 /// Please note that this method must not be used to set any of the known parameters
4212 /// which have their own setter method. If done anyway, the request will fail.
4213 ///
4214 /// # Additional Parameters
4215 ///
4216 /// * *$.xgafv* (query-string) - V1 error format.
4217 /// * *access_token* (query-string) - OAuth access token.
4218 /// * *alt* (query-string) - Data format for response.
4219 /// * *callback* (query-string) - JSONP
4220 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4221 /// * *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.
4222 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4223 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4224 /// * *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.
4225 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4226 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4227 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNoteGetCall<'a, C>
4228 where
4229 T: AsRef<str>,
4230 {
4231 self._additional_params
4232 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4233 self
4234 }
4235
4236 /// Identifies the authorization scope for the method you are building.
4237 ///
4238 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4239 /// [`Scope::CloudPlatform`].
4240 ///
4241 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4242 /// tokens for more than one scope.
4243 ///
4244 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4245 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4246 /// sufficient, a read-write scope will do as well.
4247 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNoteGetCall<'a, C>
4248 where
4249 St: AsRef<str>,
4250 {
4251 self._scopes.insert(String::from(scope.as_ref()));
4252 self
4253 }
4254 /// Identifies the authorization scope(s) for the method you are building.
4255 ///
4256 /// See [`Self::add_scope()`] for details.
4257 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNoteGetCall<'a, C>
4258 where
4259 I: IntoIterator<Item = St>,
4260 St: AsRef<str>,
4261 {
4262 self._scopes
4263 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4264 self
4265 }
4266
4267 /// Removes all scopes, and no default scope will be used either.
4268 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4269 /// for details).
4270 pub fn clear_scopes(mut self) -> ProjectLocationNoteGetCall<'a, C> {
4271 self._scopes.clear();
4272 self
4273 }
4274}
4275
4276/// Lists notes for the specified project.
4277///
4278/// A builder for the *locations.notes.list* method supported by a *project* resource.
4279/// It is not used directly, but through a [`ProjectMethods`] instance.
4280///
4281/// # Example
4282///
4283/// Instantiate a resource method builder
4284///
4285/// ```test_harness,no_run
4286/// # extern crate hyper;
4287/// # extern crate hyper_rustls;
4288/// # extern crate google_containeranalysis1 as containeranalysis1;
4289/// # async fn dox() {
4290/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4291///
4292/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4293/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4294/// # secret,
4295/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4296/// # ).build().await.unwrap();
4297///
4298/// # let client = hyper_util::client::legacy::Client::builder(
4299/// # hyper_util::rt::TokioExecutor::new()
4300/// # )
4301/// # .build(
4302/// # hyper_rustls::HttpsConnectorBuilder::new()
4303/// # .with_native_roots()
4304/// # .unwrap()
4305/// # .https_or_http()
4306/// # .enable_http1()
4307/// # .build()
4308/// # );
4309/// # let mut hub = ContainerAnalysis::new(client, auth);
4310/// // You can configure optional parameters by calling the respective setters at will, and
4311/// // execute the final call using `doit()`.
4312/// // Values shown here are possibly random and not representative !
4313/// let result = hub.projects().locations_notes_list("parent")
4314/// .page_token("ipsum")
4315/// .page_size(-62)
4316/// .filter("Lorem")
4317/// .doit().await;
4318/// # }
4319/// ```
4320pub struct ProjectLocationNoteListCall<'a, C>
4321where
4322 C: 'a,
4323{
4324 hub: &'a ContainerAnalysis<C>,
4325 _parent: String,
4326 _page_token: Option<String>,
4327 _page_size: Option<i32>,
4328 _filter: Option<String>,
4329 _delegate: Option<&'a mut dyn common::Delegate>,
4330 _additional_params: HashMap<String, String>,
4331 _scopes: BTreeSet<String>,
4332}
4333
4334impl<'a, C> common::CallBuilder for ProjectLocationNoteListCall<'a, C> {}
4335
4336impl<'a, C> ProjectLocationNoteListCall<'a, C>
4337where
4338 C: common::Connector,
4339{
4340 /// Perform the operation you have build so far.
4341 pub async fn doit(mut self) -> common::Result<(common::Response, ListNotesResponse)> {
4342 use std::borrow::Cow;
4343 use std::io::{Read, Seek};
4344
4345 use common::{url::Params, ToParts};
4346 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4347
4348 let mut dd = common::DefaultDelegate;
4349 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4350 dlg.begin(common::MethodInfo {
4351 id: "containeranalysis.projects.locations.notes.list",
4352 http_method: hyper::Method::GET,
4353 });
4354
4355 for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
4356 if self._additional_params.contains_key(field) {
4357 dlg.finished(false);
4358 return Err(common::Error::FieldClash(field));
4359 }
4360 }
4361
4362 let mut params = Params::with_capacity(6 + self._additional_params.len());
4363 params.push("parent", self._parent);
4364 if let Some(value) = self._page_token.as_ref() {
4365 params.push("pageToken", value);
4366 }
4367 if let Some(value) = self._page_size.as_ref() {
4368 params.push("pageSize", value.to_string());
4369 }
4370 if let Some(value) = self._filter.as_ref() {
4371 params.push("filter", value);
4372 }
4373
4374 params.extend(self._additional_params.iter());
4375
4376 params.push("alt", "json");
4377 let mut url = self.hub._base_url.clone() + "v1/{+parent}/notes";
4378 if self._scopes.is_empty() {
4379 self._scopes
4380 .insert(Scope::CloudPlatform.as_ref().to_string());
4381 }
4382
4383 #[allow(clippy::single_element_loop)]
4384 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4385 url = params.uri_replacement(url, param_name, find_this, true);
4386 }
4387 {
4388 let to_remove = ["parent"];
4389 params.remove_params(&to_remove);
4390 }
4391
4392 let url = params.parse_with_url(&url);
4393
4394 loop {
4395 let token = match self
4396 .hub
4397 .auth
4398 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4399 .await
4400 {
4401 Ok(token) => token,
4402 Err(e) => match dlg.token(e) {
4403 Ok(token) => token,
4404 Err(e) => {
4405 dlg.finished(false);
4406 return Err(common::Error::MissingToken(e));
4407 }
4408 },
4409 };
4410 let mut req_result = {
4411 let client = &self.hub.client;
4412 dlg.pre_request();
4413 let mut req_builder = hyper::Request::builder()
4414 .method(hyper::Method::GET)
4415 .uri(url.as_str())
4416 .header(USER_AGENT, self.hub._user_agent.clone());
4417
4418 if let Some(token) = token.as_ref() {
4419 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4420 }
4421
4422 let request = req_builder
4423 .header(CONTENT_LENGTH, 0_u64)
4424 .body(common::to_body::<String>(None));
4425
4426 client.request(request.unwrap()).await
4427 };
4428
4429 match req_result {
4430 Err(err) => {
4431 if let common::Retry::After(d) = dlg.http_error(&err) {
4432 sleep(d).await;
4433 continue;
4434 }
4435 dlg.finished(false);
4436 return Err(common::Error::HttpError(err));
4437 }
4438 Ok(res) => {
4439 let (mut parts, body) = res.into_parts();
4440 let mut body = common::Body::new(body);
4441 if !parts.status.is_success() {
4442 let bytes = common::to_bytes(body).await.unwrap_or_default();
4443 let error = serde_json::from_str(&common::to_string(&bytes));
4444 let response = common::to_response(parts, bytes.into());
4445
4446 if let common::Retry::After(d) =
4447 dlg.http_failure(&response, error.as_ref().ok())
4448 {
4449 sleep(d).await;
4450 continue;
4451 }
4452
4453 dlg.finished(false);
4454
4455 return Err(match error {
4456 Ok(value) => common::Error::BadRequest(value),
4457 _ => common::Error::Failure(response),
4458 });
4459 }
4460 let response = {
4461 let bytes = common::to_bytes(body).await.unwrap_or_default();
4462 let encoded = common::to_string(&bytes);
4463 match serde_json::from_str(&encoded) {
4464 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4465 Err(error) => {
4466 dlg.response_json_decode_error(&encoded, &error);
4467 return Err(common::Error::JsonDecodeError(
4468 encoded.to_string(),
4469 error,
4470 ));
4471 }
4472 }
4473 };
4474
4475 dlg.finished(true);
4476 return Ok(response);
4477 }
4478 }
4479 }
4480 }
4481
4482 /// Required. The name of the project to list notes for in the form of `projects/[PROJECT_ID]`.
4483 ///
4484 /// Sets the *parent* path property to the given value.
4485 ///
4486 /// Even though the property as already been set when instantiating this call,
4487 /// we provide this method for API completeness.
4488 pub fn parent(mut self, new_value: &str) -> ProjectLocationNoteListCall<'a, C> {
4489 self._parent = new_value.to_string();
4490 self
4491 }
4492 /// Token to provide to skip to a particular spot in the list.
4493 ///
4494 /// Sets the *page token* query property to the given value.
4495 pub fn page_token(mut self, new_value: &str) -> ProjectLocationNoteListCall<'a, C> {
4496 self._page_token = Some(new_value.to_string());
4497 self
4498 }
4499 /// Number of notes to return in the list. Must be positive. Max allowed page size is 1000. If not specified, page size defaults to 20.
4500 ///
4501 /// Sets the *page size* query property to the given value.
4502 pub fn page_size(mut self, new_value: i32) -> ProjectLocationNoteListCall<'a, C> {
4503 self._page_size = Some(new_value);
4504 self
4505 }
4506 /// The filter expression.
4507 ///
4508 /// Sets the *filter* query property to the given value.
4509 pub fn filter(mut self, new_value: &str) -> ProjectLocationNoteListCall<'a, C> {
4510 self._filter = Some(new_value.to_string());
4511 self
4512 }
4513 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4514 /// while executing the actual API request.
4515 ///
4516 /// ````text
4517 /// It should be used to handle progress information, and to implement a certain level of resilience.
4518 /// ````
4519 ///
4520 /// Sets the *delegate* property to the given value.
4521 pub fn delegate(
4522 mut self,
4523 new_value: &'a mut dyn common::Delegate,
4524 ) -> ProjectLocationNoteListCall<'a, C> {
4525 self._delegate = Some(new_value);
4526 self
4527 }
4528
4529 /// Set any additional parameter of the query string used in the request.
4530 /// It should be used to set parameters which are not yet available through their own
4531 /// setters.
4532 ///
4533 /// Please note that this method must not be used to set any of the known parameters
4534 /// which have their own setter method. If done anyway, the request will fail.
4535 ///
4536 /// # Additional Parameters
4537 ///
4538 /// * *$.xgafv* (query-string) - V1 error format.
4539 /// * *access_token* (query-string) - OAuth access token.
4540 /// * *alt* (query-string) - Data format for response.
4541 /// * *callback* (query-string) - JSONP
4542 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4543 /// * *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.
4544 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4545 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4546 /// * *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.
4547 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4548 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4549 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNoteListCall<'a, C>
4550 where
4551 T: AsRef<str>,
4552 {
4553 self._additional_params
4554 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4555 self
4556 }
4557
4558 /// Identifies the authorization scope for the method you are building.
4559 ///
4560 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4561 /// [`Scope::CloudPlatform`].
4562 ///
4563 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4564 /// tokens for more than one scope.
4565 ///
4566 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4567 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4568 /// sufficient, a read-write scope will do as well.
4569 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNoteListCall<'a, C>
4570 where
4571 St: AsRef<str>,
4572 {
4573 self._scopes.insert(String::from(scope.as_ref()));
4574 self
4575 }
4576 /// Identifies the authorization scope(s) for the method you are building.
4577 ///
4578 /// See [`Self::add_scope()`] for details.
4579 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNoteListCall<'a, C>
4580 where
4581 I: IntoIterator<Item = St>,
4582 St: AsRef<str>,
4583 {
4584 self._scopes
4585 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4586 self
4587 }
4588
4589 /// Removes all scopes, and no default scope will be used either.
4590 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4591 /// for details).
4592 pub fn clear_scopes(mut self) -> ProjectLocationNoteListCall<'a, C> {
4593 self._scopes.clear();
4594 self
4595 }
4596}
4597
4598/// Gets the specified occurrence.
4599///
4600/// A builder for the *locations.occurrences.get* method supported by a *project* resource.
4601/// It is not used directly, but through a [`ProjectMethods`] instance.
4602///
4603/// # Example
4604///
4605/// Instantiate a resource method builder
4606///
4607/// ```test_harness,no_run
4608/// # extern crate hyper;
4609/// # extern crate hyper_rustls;
4610/// # extern crate google_containeranalysis1 as containeranalysis1;
4611/// # async fn dox() {
4612/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4613///
4614/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4615/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4616/// # secret,
4617/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4618/// # ).build().await.unwrap();
4619///
4620/// # let client = hyper_util::client::legacy::Client::builder(
4621/// # hyper_util::rt::TokioExecutor::new()
4622/// # )
4623/// # .build(
4624/// # hyper_rustls::HttpsConnectorBuilder::new()
4625/// # .with_native_roots()
4626/// # .unwrap()
4627/// # .https_or_http()
4628/// # .enable_http1()
4629/// # .build()
4630/// # );
4631/// # let mut hub = ContainerAnalysis::new(client, auth);
4632/// // You can configure optional parameters by calling the respective setters at will, and
4633/// // execute the final call using `doit()`.
4634/// // Values shown here are possibly random and not representative !
4635/// let result = hub.projects().locations_occurrences_get("name")
4636/// .doit().await;
4637/// # }
4638/// ```
4639pub struct ProjectLocationOccurrenceGetCall<'a, C>
4640where
4641 C: 'a,
4642{
4643 hub: &'a ContainerAnalysis<C>,
4644 _name: String,
4645 _delegate: Option<&'a mut dyn common::Delegate>,
4646 _additional_params: HashMap<String, String>,
4647 _scopes: BTreeSet<String>,
4648}
4649
4650impl<'a, C> common::CallBuilder for ProjectLocationOccurrenceGetCall<'a, C> {}
4651
4652impl<'a, C> ProjectLocationOccurrenceGetCall<'a, C>
4653where
4654 C: common::Connector,
4655{
4656 /// Perform the operation you have build so far.
4657 pub async fn doit(mut self) -> common::Result<(common::Response, Occurrence)> {
4658 use std::borrow::Cow;
4659 use std::io::{Read, Seek};
4660
4661 use common::{url::Params, ToParts};
4662 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4663
4664 let mut dd = common::DefaultDelegate;
4665 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4666 dlg.begin(common::MethodInfo {
4667 id: "containeranalysis.projects.locations.occurrences.get",
4668 http_method: hyper::Method::GET,
4669 });
4670
4671 for &field in ["alt", "name"].iter() {
4672 if self._additional_params.contains_key(field) {
4673 dlg.finished(false);
4674 return Err(common::Error::FieldClash(field));
4675 }
4676 }
4677
4678 let mut params = Params::with_capacity(3 + self._additional_params.len());
4679 params.push("name", self._name);
4680
4681 params.extend(self._additional_params.iter());
4682
4683 params.push("alt", "json");
4684 let mut url = self.hub._base_url.clone() + "v1/{+name}";
4685 if self._scopes.is_empty() {
4686 self._scopes
4687 .insert(Scope::CloudPlatform.as_ref().to_string());
4688 }
4689
4690 #[allow(clippy::single_element_loop)]
4691 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4692 url = params.uri_replacement(url, param_name, find_this, true);
4693 }
4694 {
4695 let to_remove = ["name"];
4696 params.remove_params(&to_remove);
4697 }
4698
4699 let url = params.parse_with_url(&url);
4700
4701 loop {
4702 let token = match self
4703 .hub
4704 .auth
4705 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4706 .await
4707 {
4708 Ok(token) => token,
4709 Err(e) => match dlg.token(e) {
4710 Ok(token) => token,
4711 Err(e) => {
4712 dlg.finished(false);
4713 return Err(common::Error::MissingToken(e));
4714 }
4715 },
4716 };
4717 let mut req_result = {
4718 let client = &self.hub.client;
4719 dlg.pre_request();
4720 let mut req_builder = hyper::Request::builder()
4721 .method(hyper::Method::GET)
4722 .uri(url.as_str())
4723 .header(USER_AGENT, self.hub._user_agent.clone());
4724
4725 if let Some(token) = token.as_ref() {
4726 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4727 }
4728
4729 let request = req_builder
4730 .header(CONTENT_LENGTH, 0_u64)
4731 .body(common::to_body::<String>(None));
4732
4733 client.request(request.unwrap()).await
4734 };
4735
4736 match req_result {
4737 Err(err) => {
4738 if let common::Retry::After(d) = dlg.http_error(&err) {
4739 sleep(d).await;
4740 continue;
4741 }
4742 dlg.finished(false);
4743 return Err(common::Error::HttpError(err));
4744 }
4745 Ok(res) => {
4746 let (mut parts, body) = res.into_parts();
4747 let mut body = common::Body::new(body);
4748 if !parts.status.is_success() {
4749 let bytes = common::to_bytes(body).await.unwrap_or_default();
4750 let error = serde_json::from_str(&common::to_string(&bytes));
4751 let response = common::to_response(parts, bytes.into());
4752
4753 if let common::Retry::After(d) =
4754 dlg.http_failure(&response, error.as_ref().ok())
4755 {
4756 sleep(d).await;
4757 continue;
4758 }
4759
4760 dlg.finished(false);
4761
4762 return Err(match error {
4763 Ok(value) => common::Error::BadRequest(value),
4764 _ => common::Error::Failure(response),
4765 });
4766 }
4767 let response = {
4768 let bytes = common::to_bytes(body).await.unwrap_or_default();
4769 let encoded = common::to_string(&bytes);
4770 match serde_json::from_str(&encoded) {
4771 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4772 Err(error) => {
4773 dlg.response_json_decode_error(&encoded, &error);
4774 return Err(common::Error::JsonDecodeError(
4775 encoded.to_string(),
4776 error,
4777 ));
4778 }
4779 }
4780 };
4781
4782 dlg.finished(true);
4783 return Ok(response);
4784 }
4785 }
4786 }
4787 }
4788
4789 /// Required. The name of the occurrence in the form of `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.
4790 ///
4791 /// Sets the *name* path property to the given value.
4792 ///
4793 /// Even though the property as already been set when instantiating this call,
4794 /// we provide this method for API completeness.
4795 pub fn name(mut self, new_value: &str) -> ProjectLocationOccurrenceGetCall<'a, C> {
4796 self._name = new_value.to_string();
4797 self
4798 }
4799 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4800 /// while executing the actual API request.
4801 ///
4802 /// ````text
4803 /// It should be used to handle progress information, and to implement a certain level of resilience.
4804 /// ````
4805 ///
4806 /// Sets the *delegate* property to the given value.
4807 pub fn delegate(
4808 mut self,
4809 new_value: &'a mut dyn common::Delegate,
4810 ) -> ProjectLocationOccurrenceGetCall<'a, C> {
4811 self._delegate = Some(new_value);
4812 self
4813 }
4814
4815 /// Set any additional parameter of the query string used in the request.
4816 /// It should be used to set parameters which are not yet available through their own
4817 /// setters.
4818 ///
4819 /// Please note that this method must not be used to set any of the known parameters
4820 /// which have their own setter method. If done anyway, the request will fail.
4821 ///
4822 /// # Additional Parameters
4823 ///
4824 /// * *$.xgafv* (query-string) - V1 error format.
4825 /// * *access_token* (query-string) - OAuth access token.
4826 /// * *alt* (query-string) - Data format for response.
4827 /// * *callback* (query-string) - JSONP
4828 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4829 /// * *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.
4830 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4831 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4832 /// * *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.
4833 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4834 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4835 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOccurrenceGetCall<'a, C>
4836 where
4837 T: AsRef<str>,
4838 {
4839 self._additional_params
4840 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4841 self
4842 }
4843
4844 /// Identifies the authorization scope for the method you are building.
4845 ///
4846 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4847 /// [`Scope::CloudPlatform`].
4848 ///
4849 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4850 /// tokens for more than one scope.
4851 ///
4852 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4853 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4854 /// sufficient, a read-write scope will do as well.
4855 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOccurrenceGetCall<'a, C>
4856 where
4857 St: AsRef<str>,
4858 {
4859 self._scopes.insert(String::from(scope.as_ref()));
4860 self
4861 }
4862 /// Identifies the authorization scope(s) for the method you are building.
4863 ///
4864 /// See [`Self::add_scope()`] for details.
4865 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOccurrenceGetCall<'a, C>
4866 where
4867 I: IntoIterator<Item = St>,
4868 St: AsRef<str>,
4869 {
4870 self._scopes
4871 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4872 self
4873 }
4874
4875 /// Removes all scopes, and no default scope will be used either.
4876 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4877 /// for details).
4878 pub fn clear_scopes(mut self) -> ProjectLocationOccurrenceGetCall<'a, C> {
4879 self._scopes.clear();
4880 self
4881 }
4882}
4883
4884/// Gets the note attached to the specified occurrence. Consumer projects can use this method to get a note that belongs to a provider project.
4885///
4886/// A builder for the *locations.occurrences.getNotes* method supported by a *project* resource.
4887/// It is not used directly, but through a [`ProjectMethods`] instance.
4888///
4889/// # Example
4890///
4891/// Instantiate a resource method builder
4892///
4893/// ```test_harness,no_run
4894/// # extern crate hyper;
4895/// # extern crate hyper_rustls;
4896/// # extern crate google_containeranalysis1 as containeranalysis1;
4897/// # async fn dox() {
4898/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4899///
4900/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4901/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
4902/// # secret,
4903/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4904/// # ).build().await.unwrap();
4905///
4906/// # let client = hyper_util::client::legacy::Client::builder(
4907/// # hyper_util::rt::TokioExecutor::new()
4908/// # )
4909/// # .build(
4910/// # hyper_rustls::HttpsConnectorBuilder::new()
4911/// # .with_native_roots()
4912/// # .unwrap()
4913/// # .https_or_http()
4914/// # .enable_http1()
4915/// # .build()
4916/// # );
4917/// # let mut hub = ContainerAnalysis::new(client, auth);
4918/// // You can configure optional parameters by calling the respective setters at will, and
4919/// // execute the final call using `doit()`.
4920/// // Values shown here are possibly random and not representative !
4921/// let result = hub.projects().locations_occurrences_get_notes("name")
4922/// .doit().await;
4923/// # }
4924/// ```
4925pub struct ProjectLocationOccurrenceGetNoteCall<'a, C>
4926where
4927 C: 'a,
4928{
4929 hub: &'a ContainerAnalysis<C>,
4930 _name: String,
4931 _delegate: Option<&'a mut dyn common::Delegate>,
4932 _additional_params: HashMap<String, String>,
4933 _scopes: BTreeSet<String>,
4934}
4935
4936impl<'a, C> common::CallBuilder for ProjectLocationOccurrenceGetNoteCall<'a, C> {}
4937
4938impl<'a, C> ProjectLocationOccurrenceGetNoteCall<'a, C>
4939where
4940 C: common::Connector,
4941{
4942 /// Perform the operation you have build so far.
4943 pub async fn doit(mut self) -> common::Result<(common::Response, Note)> {
4944 use std::borrow::Cow;
4945 use std::io::{Read, Seek};
4946
4947 use common::{url::Params, ToParts};
4948 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4949
4950 let mut dd = common::DefaultDelegate;
4951 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4952 dlg.begin(common::MethodInfo {
4953 id: "containeranalysis.projects.locations.occurrences.getNotes",
4954 http_method: hyper::Method::GET,
4955 });
4956
4957 for &field in ["alt", "name"].iter() {
4958 if self._additional_params.contains_key(field) {
4959 dlg.finished(false);
4960 return Err(common::Error::FieldClash(field));
4961 }
4962 }
4963
4964 let mut params = Params::with_capacity(3 + self._additional_params.len());
4965 params.push("name", self._name);
4966
4967 params.extend(self._additional_params.iter());
4968
4969 params.push("alt", "json");
4970 let mut url = self.hub._base_url.clone() + "v1/{+name}/notes";
4971 if self._scopes.is_empty() {
4972 self._scopes
4973 .insert(Scope::CloudPlatform.as_ref().to_string());
4974 }
4975
4976 #[allow(clippy::single_element_loop)]
4977 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4978 url = params.uri_replacement(url, param_name, find_this, true);
4979 }
4980 {
4981 let to_remove = ["name"];
4982 params.remove_params(&to_remove);
4983 }
4984
4985 let url = params.parse_with_url(&url);
4986
4987 loop {
4988 let token = match self
4989 .hub
4990 .auth
4991 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4992 .await
4993 {
4994 Ok(token) => token,
4995 Err(e) => match dlg.token(e) {
4996 Ok(token) => token,
4997 Err(e) => {
4998 dlg.finished(false);
4999 return Err(common::Error::MissingToken(e));
5000 }
5001 },
5002 };
5003 let mut req_result = {
5004 let client = &self.hub.client;
5005 dlg.pre_request();
5006 let mut req_builder = hyper::Request::builder()
5007 .method(hyper::Method::GET)
5008 .uri(url.as_str())
5009 .header(USER_AGENT, self.hub._user_agent.clone());
5010
5011 if let Some(token) = token.as_ref() {
5012 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5013 }
5014
5015 let request = req_builder
5016 .header(CONTENT_LENGTH, 0_u64)
5017 .body(common::to_body::<String>(None));
5018
5019 client.request(request.unwrap()).await
5020 };
5021
5022 match req_result {
5023 Err(err) => {
5024 if let common::Retry::After(d) = dlg.http_error(&err) {
5025 sleep(d).await;
5026 continue;
5027 }
5028 dlg.finished(false);
5029 return Err(common::Error::HttpError(err));
5030 }
5031 Ok(res) => {
5032 let (mut parts, body) = res.into_parts();
5033 let mut body = common::Body::new(body);
5034 if !parts.status.is_success() {
5035 let bytes = common::to_bytes(body).await.unwrap_or_default();
5036 let error = serde_json::from_str(&common::to_string(&bytes));
5037 let response = common::to_response(parts, bytes.into());
5038
5039 if let common::Retry::After(d) =
5040 dlg.http_failure(&response, error.as_ref().ok())
5041 {
5042 sleep(d).await;
5043 continue;
5044 }
5045
5046 dlg.finished(false);
5047
5048 return Err(match error {
5049 Ok(value) => common::Error::BadRequest(value),
5050 _ => common::Error::Failure(response),
5051 });
5052 }
5053 let response = {
5054 let bytes = common::to_bytes(body).await.unwrap_or_default();
5055 let encoded = common::to_string(&bytes);
5056 match serde_json::from_str(&encoded) {
5057 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5058 Err(error) => {
5059 dlg.response_json_decode_error(&encoded, &error);
5060 return Err(common::Error::JsonDecodeError(
5061 encoded.to_string(),
5062 error,
5063 ));
5064 }
5065 }
5066 };
5067
5068 dlg.finished(true);
5069 return Ok(response);
5070 }
5071 }
5072 }
5073 }
5074
5075 /// Required. The name of the occurrence in the form of `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.
5076 ///
5077 /// Sets the *name* path property to the given value.
5078 ///
5079 /// Even though the property as already been set when instantiating this call,
5080 /// we provide this method for API completeness.
5081 pub fn name(mut self, new_value: &str) -> ProjectLocationOccurrenceGetNoteCall<'a, C> {
5082 self._name = new_value.to_string();
5083 self
5084 }
5085 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5086 /// while executing the actual API request.
5087 ///
5088 /// ````text
5089 /// It should be used to handle progress information, and to implement a certain level of resilience.
5090 /// ````
5091 ///
5092 /// Sets the *delegate* property to the given value.
5093 pub fn delegate(
5094 mut self,
5095 new_value: &'a mut dyn common::Delegate,
5096 ) -> ProjectLocationOccurrenceGetNoteCall<'a, C> {
5097 self._delegate = Some(new_value);
5098 self
5099 }
5100
5101 /// Set any additional parameter of the query string used in the request.
5102 /// It should be used to set parameters which are not yet available through their own
5103 /// setters.
5104 ///
5105 /// Please note that this method must not be used to set any of the known parameters
5106 /// which have their own setter method. If done anyway, the request will fail.
5107 ///
5108 /// # Additional Parameters
5109 ///
5110 /// * *$.xgafv* (query-string) - V1 error format.
5111 /// * *access_token* (query-string) - OAuth access token.
5112 /// * *alt* (query-string) - Data format for response.
5113 /// * *callback* (query-string) - JSONP
5114 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5115 /// * *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.
5116 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5117 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5118 /// * *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.
5119 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5120 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5121 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOccurrenceGetNoteCall<'a, C>
5122 where
5123 T: AsRef<str>,
5124 {
5125 self._additional_params
5126 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5127 self
5128 }
5129
5130 /// Identifies the authorization scope for the method you are building.
5131 ///
5132 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5133 /// [`Scope::CloudPlatform`].
5134 ///
5135 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5136 /// tokens for more than one scope.
5137 ///
5138 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5139 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5140 /// sufficient, a read-write scope will do as well.
5141 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOccurrenceGetNoteCall<'a, C>
5142 where
5143 St: AsRef<str>,
5144 {
5145 self._scopes.insert(String::from(scope.as_ref()));
5146 self
5147 }
5148 /// Identifies the authorization scope(s) for the method you are building.
5149 ///
5150 /// See [`Self::add_scope()`] for details.
5151 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOccurrenceGetNoteCall<'a, C>
5152 where
5153 I: IntoIterator<Item = St>,
5154 St: AsRef<str>,
5155 {
5156 self._scopes
5157 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5158 self
5159 }
5160
5161 /// Removes all scopes, and no default scope will be used either.
5162 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5163 /// for details).
5164 pub fn clear_scopes(mut self) -> ProjectLocationOccurrenceGetNoteCall<'a, C> {
5165 self._scopes.clear();
5166 self
5167 }
5168}
5169
5170/// Gets a summary of the number and severity of occurrences.
5171///
5172/// A builder for the *locations.occurrences.getVulnerabilitySummary* method supported by a *project* resource.
5173/// It is not used directly, but through a [`ProjectMethods`] instance.
5174///
5175/// # Example
5176///
5177/// Instantiate a resource method builder
5178///
5179/// ```test_harness,no_run
5180/// # extern crate hyper;
5181/// # extern crate hyper_rustls;
5182/// # extern crate google_containeranalysis1 as containeranalysis1;
5183/// # async fn dox() {
5184/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5185///
5186/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5187/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5188/// # secret,
5189/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5190/// # ).build().await.unwrap();
5191///
5192/// # let client = hyper_util::client::legacy::Client::builder(
5193/// # hyper_util::rt::TokioExecutor::new()
5194/// # )
5195/// # .build(
5196/// # hyper_rustls::HttpsConnectorBuilder::new()
5197/// # .with_native_roots()
5198/// # .unwrap()
5199/// # .https_or_http()
5200/// # .enable_http1()
5201/// # .build()
5202/// # );
5203/// # let mut hub = ContainerAnalysis::new(client, auth);
5204/// // You can configure optional parameters by calling the respective setters at will, and
5205/// // execute the final call using `doit()`.
5206/// // Values shown here are possibly random and not representative !
5207/// let result = hub.projects().locations_occurrences_get_vulnerability_summary("parent")
5208/// .filter("ea")
5209/// .doit().await;
5210/// # }
5211/// ```
5212pub struct ProjectLocationOccurrenceGetVulnerabilitySummaryCall<'a, C>
5213where
5214 C: 'a,
5215{
5216 hub: &'a ContainerAnalysis<C>,
5217 _parent: String,
5218 _filter: Option<String>,
5219 _delegate: Option<&'a mut dyn common::Delegate>,
5220 _additional_params: HashMap<String, String>,
5221 _scopes: BTreeSet<String>,
5222}
5223
5224impl<'a, C> common::CallBuilder for ProjectLocationOccurrenceGetVulnerabilitySummaryCall<'a, C> {}
5225
5226impl<'a, C> ProjectLocationOccurrenceGetVulnerabilitySummaryCall<'a, C>
5227where
5228 C: common::Connector,
5229{
5230 /// Perform the operation you have build so far.
5231 pub async fn doit(
5232 mut self,
5233 ) -> common::Result<(common::Response, VulnerabilityOccurrencesSummary)> {
5234 use std::borrow::Cow;
5235 use std::io::{Read, Seek};
5236
5237 use common::{url::Params, ToParts};
5238 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5239
5240 let mut dd = common::DefaultDelegate;
5241 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5242 dlg.begin(common::MethodInfo {
5243 id: "containeranalysis.projects.locations.occurrences.getVulnerabilitySummary",
5244 http_method: hyper::Method::GET,
5245 });
5246
5247 for &field in ["alt", "parent", "filter"].iter() {
5248 if self._additional_params.contains_key(field) {
5249 dlg.finished(false);
5250 return Err(common::Error::FieldClash(field));
5251 }
5252 }
5253
5254 let mut params = Params::with_capacity(4 + self._additional_params.len());
5255 params.push("parent", self._parent);
5256 if let Some(value) = self._filter.as_ref() {
5257 params.push("filter", value);
5258 }
5259
5260 params.extend(self._additional_params.iter());
5261
5262 params.push("alt", "json");
5263 let mut url = self.hub._base_url.clone() + "v1/{+parent}/occurrences:vulnerabilitySummary";
5264 if self._scopes.is_empty() {
5265 self._scopes
5266 .insert(Scope::CloudPlatform.as_ref().to_string());
5267 }
5268
5269 #[allow(clippy::single_element_loop)]
5270 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
5271 url = params.uri_replacement(url, param_name, find_this, true);
5272 }
5273 {
5274 let to_remove = ["parent"];
5275 params.remove_params(&to_remove);
5276 }
5277
5278 let url = params.parse_with_url(&url);
5279
5280 loop {
5281 let token = match self
5282 .hub
5283 .auth
5284 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5285 .await
5286 {
5287 Ok(token) => token,
5288 Err(e) => match dlg.token(e) {
5289 Ok(token) => token,
5290 Err(e) => {
5291 dlg.finished(false);
5292 return Err(common::Error::MissingToken(e));
5293 }
5294 },
5295 };
5296 let mut req_result = {
5297 let client = &self.hub.client;
5298 dlg.pre_request();
5299 let mut req_builder = hyper::Request::builder()
5300 .method(hyper::Method::GET)
5301 .uri(url.as_str())
5302 .header(USER_AGENT, self.hub._user_agent.clone());
5303
5304 if let Some(token) = token.as_ref() {
5305 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5306 }
5307
5308 let request = req_builder
5309 .header(CONTENT_LENGTH, 0_u64)
5310 .body(common::to_body::<String>(None));
5311
5312 client.request(request.unwrap()).await
5313 };
5314
5315 match req_result {
5316 Err(err) => {
5317 if let common::Retry::After(d) = dlg.http_error(&err) {
5318 sleep(d).await;
5319 continue;
5320 }
5321 dlg.finished(false);
5322 return Err(common::Error::HttpError(err));
5323 }
5324 Ok(res) => {
5325 let (mut parts, body) = res.into_parts();
5326 let mut body = common::Body::new(body);
5327 if !parts.status.is_success() {
5328 let bytes = common::to_bytes(body).await.unwrap_or_default();
5329 let error = serde_json::from_str(&common::to_string(&bytes));
5330 let response = common::to_response(parts, bytes.into());
5331
5332 if let common::Retry::After(d) =
5333 dlg.http_failure(&response, error.as_ref().ok())
5334 {
5335 sleep(d).await;
5336 continue;
5337 }
5338
5339 dlg.finished(false);
5340
5341 return Err(match error {
5342 Ok(value) => common::Error::BadRequest(value),
5343 _ => common::Error::Failure(response),
5344 });
5345 }
5346 let response = {
5347 let bytes = common::to_bytes(body).await.unwrap_or_default();
5348 let encoded = common::to_string(&bytes);
5349 match serde_json::from_str(&encoded) {
5350 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5351 Err(error) => {
5352 dlg.response_json_decode_error(&encoded, &error);
5353 return Err(common::Error::JsonDecodeError(
5354 encoded.to_string(),
5355 error,
5356 ));
5357 }
5358 }
5359 };
5360
5361 dlg.finished(true);
5362 return Ok(response);
5363 }
5364 }
5365 }
5366 }
5367
5368 /// Required. The name of the project to get a vulnerability summary for in the form of `projects/[PROJECT_ID]`.
5369 ///
5370 /// Sets the *parent* path property to the given value.
5371 ///
5372 /// Even though the property as already been set when instantiating this call,
5373 /// we provide this method for API completeness.
5374 pub fn parent(
5375 mut self,
5376 new_value: &str,
5377 ) -> ProjectLocationOccurrenceGetVulnerabilitySummaryCall<'a, C> {
5378 self._parent = new_value.to_string();
5379 self
5380 }
5381 /// The filter expression.
5382 ///
5383 /// Sets the *filter* query property to the given value.
5384 pub fn filter(
5385 mut self,
5386 new_value: &str,
5387 ) -> ProjectLocationOccurrenceGetVulnerabilitySummaryCall<'a, C> {
5388 self._filter = Some(new_value.to_string());
5389 self
5390 }
5391 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5392 /// while executing the actual API request.
5393 ///
5394 /// ````text
5395 /// It should be used to handle progress information, and to implement a certain level of resilience.
5396 /// ````
5397 ///
5398 /// Sets the *delegate* property to the given value.
5399 pub fn delegate(
5400 mut self,
5401 new_value: &'a mut dyn common::Delegate,
5402 ) -> ProjectLocationOccurrenceGetVulnerabilitySummaryCall<'a, C> {
5403 self._delegate = Some(new_value);
5404 self
5405 }
5406
5407 /// Set any additional parameter of the query string used in the request.
5408 /// It should be used to set parameters which are not yet available through their own
5409 /// setters.
5410 ///
5411 /// Please note that this method must not be used to set any of the known parameters
5412 /// which have their own setter method. If done anyway, the request will fail.
5413 ///
5414 /// # Additional Parameters
5415 ///
5416 /// * *$.xgafv* (query-string) - V1 error format.
5417 /// * *access_token* (query-string) - OAuth access token.
5418 /// * *alt* (query-string) - Data format for response.
5419 /// * *callback* (query-string) - JSONP
5420 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5421 /// * *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.
5422 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5423 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5424 /// * *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.
5425 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5426 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5427 pub fn param<T>(
5428 mut self,
5429 name: T,
5430 value: T,
5431 ) -> ProjectLocationOccurrenceGetVulnerabilitySummaryCall<'a, C>
5432 where
5433 T: AsRef<str>,
5434 {
5435 self._additional_params
5436 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5437 self
5438 }
5439
5440 /// Identifies the authorization scope for the method you are building.
5441 ///
5442 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5443 /// [`Scope::CloudPlatform`].
5444 ///
5445 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5446 /// tokens for more than one scope.
5447 ///
5448 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5449 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5450 /// sufficient, a read-write scope will do as well.
5451 pub fn add_scope<St>(
5452 mut self,
5453 scope: St,
5454 ) -> ProjectLocationOccurrenceGetVulnerabilitySummaryCall<'a, C>
5455 where
5456 St: AsRef<str>,
5457 {
5458 self._scopes.insert(String::from(scope.as_ref()));
5459 self
5460 }
5461 /// Identifies the authorization scope(s) for the method you are building.
5462 ///
5463 /// See [`Self::add_scope()`] for details.
5464 pub fn add_scopes<I, St>(
5465 mut self,
5466 scopes: I,
5467 ) -> ProjectLocationOccurrenceGetVulnerabilitySummaryCall<'a, C>
5468 where
5469 I: IntoIterator<Item = St>,
5470 St: AsRef<str>,
5471 {
5472 self._scopes
5473 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5474 self
5475 }
5476
5477 /// Removes all scopes, and no default scope will be used either.
5478 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5479 /// for details).
5480 pub fn clear_scopes(mut self) -> ProjectLocationOccurrenceGetVulnerabilitySummaryCall<'a, C> {
5481 self._scopes.clear();
5482 self
5483 }
5484}
5485
5486/// Lists occurrences for the specified project.
5487///
5488/// A builder for the *locations.occurrences.list* method supported by a *project* resource.
5489/// It is not used directly, but through a [`ProjectMethods`] instance.
5490///
5491/// # Example
5492///
5493/// Instantiate a resource method builder
5494///
5495/// ```test_harness,no_run
5496/// # extern crate hyper;
5497/// # extern crate hyper_rustls;
5498/// # extern crate google_containeranalysis1 as containeranalysis1;
5499/// # async fn dox() {
5500/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5501///
5502/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5503/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5504/// # secret,
5505/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5506/// # ).build().await.unwrap();
5507///
5508/// # let client = hyper_util::client::legacy::Client::builder(
5509/// # hyper_util::rt::TokioExecutor::new()
5510/// # )
5511/// # .build(
5512/// # hyper_rustls::HttpsConnectorBuilder::new()
5513/// # .with_native_roots()
5514/// # .unwrap()
5515/// # .https_or_http()
5516/// # .enable_http1()
5517/// # .build()
5518/// # );
5519/// # let mut hub = ContainerAnalysis::new(client, auth);
5520/// // You can configure optional parameters by calling the respective setters at will, and
5521/// // execute the final call using `doit()`.
5522/// // Values shown here are possibly random and not representative !
5523/// let result = hub.projects().locations_occurrences_list("parent")
5524/// .page_token("invidunt")
5525/// .page_size(-47)
5526/// .filter("duo")
5527/// .doit().await;
5528/// # }
5529/// ```
5530pub struct ProjectLocationOccurrenceListCall<'a, C>
5531where
5532 C: 'a,
5533{
5534 hub: &'a ContainerAnalysis<C>,
5535 _parent: String,
5536 _page_token: Option<String>,
5537 _page_size: Option<i32>,
5538 _filter: Option<String>,
5539 _delegate: Option<&'a mut dyn common::Delegate>,
5540 _additional_params: HashMap<String, String>,
5541 _scopes: BTreeSet<String>,
5542}
5543
5544impl<'a, C> common::CallBuilder for ProjectLocationOccurrenceListCall<'a, C> {}
5545
5546impl<'a, C> ProjectLocationOccurrenceListCall<'a, C>
5547where
5548 C: common::Connector,
5549{
5550 /// Perform the operation you have build so far.
5551 pub async fn doit(mut self) -> common::Result<(common::Response, ListOccurrencesResponse)> {
5552 use std::borrow::Cow;
5553 use std::io::{Read, Seek};
5554
5555 use common::{url::Params, ToParts};
5556 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5557
5558 let mut dd = common::DefaultDelegate;
5559 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5560 dlg.begin(common::MethodInfo {
5561 id: "containeranalysis.projects.locations.occurrences.list",
5562 http_method: hyper::Method::GET,
5563 });
5564
5565 for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
5566 if self._additional_params.contains_key(field) {
5567 dlg.finished(false);
5568 return Err(common::Error::FieldClash(field));
5569 }
5570 }
5571
5572 let mut params = Params::with_capacity(6 + self._additional_params.len());
5573 params.push("parent", self._parent);
5574 if let Some(value) = self._page_token.as_ref() {
5575 params.push("pageToken", value);
5576 }
5577 if let Some(value) = self._page_size.as_ref() {
5578 params.push("pageSize", value.to_string());
5579 }
5580 if let Some(value) = self._filter.as_ref() {
5581 params.push("filter", value);
5582 }
5583
5584 params.extend(self._additional_params.iter());
5585
5586 params.push("alt", "json");
5587 let mut url = self.hub._base_url.clone() + "v1/{+parent}/occurrences";
5588 if self._scopes.is_empty() {
5589 self._scopes
5590 .insert(Scope::CloudPlatform.as_ref().to_string());
5591 }
5592
5593 #[allow(clippy::single_element_loop)]
5594 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
5595 url = params.uri_replacement(url, param_name, find_this, true);
5596 }
5597 {
5598 let to_remove = ["parent"];
5599 params.remove_params(&to_remove);
5600 }
5601
5602 let url = params.parse_with_url(&url);
5603
5604 loop {
5605 let token = match self
5606 .hub
5607 .auth
5608 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5609 .await
5610 {
5611 Ok(token) => token,
5612 Err(e) => match dlg.token(e) {
5613 Ok(token) => token,
5614 Err(e) => {
5615 dlg.finished(false);
5616 return Err(common::Error::MissingToken(e));
5617 }
5618 },
5619 };
5620 let mut req_result = {
5621 let client = &self.hub.client;
5622 dlg.pre_request();
5623 let mut req_builder = hyper::Request::builder()
5624 .method(hyper::Method::GET)
5625 .uri(url.as_str())
5626 .header(USER_AGENT, self.hub._user_agent.clone());
5627
5628 if let Some(token) = token.as_ref() {
5629 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5630 }
5631
5632 let request = req_builder
5633 .header(CONTENT_LENGTH, 0_u64)
5634 .body(common::to_body::<String>(None));
5635
5636 client.request(request.unwrap()).await
5637 };
5638
5639 match req_result {
5640 Err(err) => {
5641 if let common::Retry::After(d) = dlg.http_error(&err) {
5642 sleep(d).await;
5643 continue;
5644 }
5645 dlg.finished(false);
5646 return Err(common::Error::HttpError(err));
5647 }
5648 Ok(res) => {
5649 let (mut parts, body) = res.into_parts();
5650 let mut body = common::Body::new(body);
5651 if !parts.status.is_success() {
5652 let bytes = common::to_bytes(body).await.unwrap_or_default();
5653 let error = serde_json::from_str(&common::to_string(&bytes));
5654 let response = common::to_response(parts, bytes.into());
5655
5656 if let common::Retry::After(d) =
5657 dlg.http_failure(&response, error.as_ref().ok())
5658 {
5659 sleep(d).await;
5660 continue;
5661 }
5662
5663 dlg.finished(false);
5664
5665 return Err(match error {
5666 Ok(value) => common::Error::BadRequest(value),
5667 _ => common::Error::Failure(response),
5668 });
5669 }
5670 let response = {
5671 let bytes = common::to_bytes(body).await.unwrap_or_default();
5672 let encoded = common::to_string(&bytes);
5673 match serde_json::from_str(&encoded) {
5674 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5675 Err(error) => {
5676 dlg.response_json_decode_error(&encoded, &error);
5677 return Err(common::Error::JsonDecodeError(
5678 encoded.to_string(),
5679 error,
5680 ));
5681 }
5682 }
5683 };
5684
5685 dlg.finished(true);
5686 return Ok(response);
5687 }
5688 }
5689 }
5690 }
5691
5692 /// Required. The name of the project to list occurrences for in the form of `projects/[PROJECT_ID]`.
5693 ///
5694 /// Sets the *parent* path property to the given value.
5695 ///
5696 /// Even though the property as already been set when instantiating this call,
5697 /// we provide this method for API completeness.
5698 pub fn parent(mut self, new_value: &str) -> ProjectLocationOccurrenceListCall<'a, C> {
5699 self._parent = new_value.to_string();
5700 self
5701 }
5702 /// Token to provide to skip to a particular spot in the list.
5703 ///
5704 /// Sets the *page token* query property to the given value.
5705 pub fn page_token(mut self, new_value: &str) -> ProjectLocationOccurrenceListCall<'a, C> {
5706 self._page_token = Some(new_value.to_string());
5707 self
5708 }
5709 /// Number of occurrences to return in the list. Must be positive. Max allowed page size is 1000. If not specified, page size defaults to 20.
5710 ///
5711 /// Sets the *page size* query property to the given value.
5712 pub fn page_size(mut self, new_value: i32) -> ProjectLocationOccurrenceListCall<'a, C> {
5713 self._page_size = Some(new_value);
5714 self
5715 }
5716 /// The filter expression.
5717 ///
5718 /// Sets the *filter* query property to the given value.
5719 pub fn filter(mut self, new_value: &str) -> ProjectLocationOccurrenceListCall<'a, C> {
5720 self._filter = Some(new_value.to_string());
5721 self
5722 }
5723 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5724 /// while executing the actual API request.
5725 ///
5726 /// ````text
5727 /// It should be used to handle progress information, and to implement a certain level of resilience.
5728 /// ````
5729 ///
5730 /// Sets the *delegate* property to the given value.
5731 pub fn delegate(
5732 mut self,
5733 new_value: &'a mut dyn common::Delegate,
5734 ) -> ProjectLocationOccurrenceListCall<'a, C> {
5735 self._delegate = Some(new_value);
5736 self
5737 }
5738
5739 /// Set any additional parameter of the query string used in the request.
5740 /// It should be used to set parameters which are not yet available through their own
5741 /// setters.
5742 ///
5743 /// Please note that this method must not be used to set any of the known parameters
5744 /// which have their own setter method. If done anyway, the request will fail.
5745 ///
5746 /// # Additional Parameters
5747 ///
5748 /// * *$.xgafv* (query-string) - V1 error format.
5749 /// * *access_token* (query-string) - OAuth access token.
5750 /// * *alt* (query-string) - Data format for response.
5751 /// * *callback* (query-string) - JSONP
5752 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5753 /// * *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.
5754 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5755 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5756 /// * *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.
5757 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5758 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5759 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOccurrenceListCall<'a, C>
5760 where
5761 T: AsRef<str>,
5762 {
5763 self._additional_params
5764 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5765 self
5766 }
5767
5768 /// Identifies the authorization scope for the method you are building.
5769 ///
5770 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5771 /// [`Scope::CloudPlatform`].
5772 ///
5773 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5774 /// tokens for more than one scope.
5775 ///
5776 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5777 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5778 /// sufficient, a read-write scope will do as well.
5779 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOccurrenceListCall<'a, C>
5780 where
5781 St: AsRef<str>,
5782 {
5783 self._scopes.insert(String::from(scope.as_ref()));
5784 self
5785 }
5786 /// Identifies the authorization scope(s) for the method you are building.
5787 ///
5788 /// See [`Self::add_scope()`] for details.
5789 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOccurrenceListCall<'a, C>
5790 where
5791 I: IntoIterator<Item = St>,
5792 St: AsRef<str>,
5793 {
5794 self._scopes
5795 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5796 self
5797 }
5798
5799 /// Removes all scopes, and no default scope will be used either.
5800 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5801 /// for details).
5802 pub fn clear_scopes(mut self) -> ProjectLocationOccurrenceListCall<'a, C> {
5803 self._scopes.clear();
5804 self
5805 }
5806}
5807
5808/// Generates an SBOM for the given resource.
5809///
5810/// A builder for the *locations.resources.exportSBOM* method supported by a *project* resource.
5811/// It is not used directly, but through a [`ProjectMethods`] instance.
5812///
5813/// # Example
5814///
5815/// Instantiate a resource method builder
5816///
5817/// ```test_harness,no_run
5818/// # extern crate hyper;
5819/// # extern crate hyper_rustls;
5820/// # extern crate google_containeranalysis1 as containeranalysis1;
5821/// use containeranalysis1::api::ExportSBOMRequest;
5822/// # async fn dox() {
5823/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5824///
5825/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5826/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
5827/// # secret,
5828/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5829/// # ).build().await.unwrap();
5830///
5831/// # let client = hyper_util::client::legacy::Client::builder(
5832/// # hyper_util::rt::TokioExecutor::new()
5833/// # )
5834/// # .build(
5835/// # hyper_rustls::HttpsConnectorBuilder::new()
5836/// # .with_native_roots()
5837/// # .unwrap()
5838/// # .https_or_http()
5839/// # .enable_http1()
5840/// # .build()
5841/// # );
5842/// # let mut hub = ContainerAnalysis::new(client, auth);
5843/// // As the method needs a request, you would usually fill it with the desired information
5844/// // into the respective structure. Some of the parts shown here might not be applicable !
5845/// // Values shown here are possibly random and not representative !
5846/// let mut req = ExportSBOMRequest::default();
5847///
5848/// // You can configure optional parameters by calling the respective setters at will, and
5849/// // execute the final call using `doit()`.
5850/// // Values shown here are possibly random and not representative !
5851/// let result = hub.projects().locations_resources_export_sbom(req, "name")
5852/// .doit().await;
5853/// # }
5854/// ```
5855pub struct ProjectLocationResourceExportSBOMCall<'a, C>
5856where
5857 C: 'a,
5858{
5859 hub: &'a ContainerAnalysis<C>,
5860 _request: ExportSBOMRequest,
5861 _name: String,
5862 _delegate: Option<&'a mut dyn common::Delegate>,
5863 _additional_params: HashMap<String, String>,
5864 _scopes: BTreeSet<String>,
5865}
5866
5867impl<'a, C> common::CallBuilder for ProjectLocationResourceExportSBOMCall<'a, C> {}
5868
5869impl<'a, C> ProjectLocationResourceExportSBOMCall<'a, C>
5870where
5871 C: common::Connector,
5872{
5873 /// Perform the operation you have build so far.
5874 pub async fn doit(mut self) -> common::Result<(common::Response, ExportSBOMResponse)> {
5875 use std::borrow::Cow;
5876 use std::io::{Read, Seek};
5877
5878 use common::{url::Params, ToParts};
5879 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5880
5881 let mut dd = common::DefaultDelegate;
5882 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5883 dlg.begin(common::MethodInfo {
5884 id: "containeranalysis.projects.locations.resources.exportSBOM",
5885 http_method: hyper::Method::POST,
5886 });
5887
5888 for &field in ["alt", "name"].iter() {
5889 if self._additional_params.contains_key(field) {
5890 dlg.finished(false);
5891 return Err(common::Error::FieldClash(field));
5892 }
5893 }
5894
5895 let mut params = Params::with_capacity(4 + self._additional_params.len());
5896 params.push("name", self._name);
5897
5898 params.extend(self._additional_params.iter());
5899
5900 params.push("alt", "json");
5901 let mut url = self.hub._base_url.clone() + "v1/{+name}:exportSBOM";
5902 if self._scopes.is_empty() {
5903 self._scopes
5904 .insert(Scope::CloudPlatform.as_ref().to_string());
5905 }
5906
5907 #[allow(clippy::single_element_loop)]
5908 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5909 url = params.uri_replacement(url, param_name, find_this, true);
5910 }
5911 {
5912 let to_remove = ["name"];
5913 params.remove_params(&to_remove);
5914 }
5915
5916 let url = params.parse_with_url(&url);
5917
5918 let mut json_mime_type = mime::APPLICATION_JSON;
5919 let mut request_value_reader = {
5920 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5921 common::remove_json_null_values(&mut value);
5922 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5923 serde_json::to_writer(&mut dst, &value).unwrap();
5924 dst
5925 };
5926 let request_size = request_value_reader
5927 .seek(std::io::SeekFrom::End(0))
5928 .unwrap();
5929 request_value_reader
5930 .seek(std::io::SeekFrom::Start(0))
5931 .unwrap();
5932
5933 loop {
5934 let token = match self
5935 .hub
5936 .auth
5937 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5938 .await
5939 {
5940 Ok(token) => token,
5941 Err(e) => match dlg.token(e) {
5942 Ok(token) => token,
5943 Err(e) => {
5944 dlg.finished(false);
5945 return Err(common::Error::MissingToken(e));
5946 }
5947 },
5948 };
5949 request_value_reader
5950 .seek(std::io::SeekFrom::Start(0))
5951 .unwrap();
5952 let mut req_result = {
5953 let client = &self.hub.client;
5954 dlg.pre_request();
5955 let mut req_builder = hyper::Request::builder()
5956 .method(hyper::Method::POST)
5957 .uri(url.as_str())
5958 .header(USER_AGENT, self.hub._user_agent.clone());
5959
5960 if let Some(token) = token.as_ref() {
5961 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5962 }
5963
5964 let request = req_builder
5965 .header(CONTENT_TYPE, json_mime_type.to_string())
5966 .header(CONTENT_LENGTH, request_size as u64)
5967 .body(common::to_body(
5968 request_value_reader.get_ref().clone().into(),
5969 ));
5970
5971 client.request(request.unwrap()).await
5972 };
5973
5974 match req_result {
5975 Err(err) => {
5976 if let common::Retry::After(d) = dlg.http_error(&err) {
5977 sleep(d).await;
5978 continue;
5979 }
5980 dlg.finished(false);
5981 return Err(common::Error::HttpError(err));
5982 }
5983 Ok(res) => {
5984 let (mut parts, body) = res.into_parts();
5985 let mut body = common::Body::new(body);
5986 if !parts.status.is_success() {
5987 let bytes = common::to_bytes(body).await.unwrap_or_default();
5988 let error = serde_json::from_str(&common::to_string(&bytes));
5989 let response = common::to_response(parts, bytes.into());
5990
5991 if let common::Retry::After(d) =
5992 dlg.http_failure(&response, error.as_ref().ok())
5993 {
5994 sleep(d).await;
5995 continue;
5996 }
5997
5998 dlg.finished(false);
5999
6000 return Err(match error {
6001 Ok(value) => common::Error::BadRequest(value),
6002 _ => common::Error::Failure(response),
6003 });
6004 }
6005 let response = {
6006 let bytes = common::to_bytes(body).await.unwrap_or_default();
6007 let encoded = common::to_string(&bytes);
6008 match serde_json::from_str(&encoded) {
6009 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6010 Err(error) => {
6011 dlg.response_json_decode_error(&encoded, &error);
6012 return Err(common::Error::JsonDecodeError(
6013 encoded.to_string(),
6014 error,
6015 ));
6016 }
6017 }
6018 };
6019
6020 dlg.finished(true);
6021 return Ok(response);
6022 }
6023 }
6024 }
6025 }
6026
6027 ///
6028 /// Sets the *request* property to the given value.
6029 ///
6030 /// Even though the property as already been set when instantiating this call,
6031 /// we provide this method for API completeness.
6032 pub fn request(
6033 mut self,
6034 new_value: ExportSBOMRequest,
6035 ) -> ProjectLocationResourceExportSBOMCall<'a, C> {
6036 self._request = new_value;
6037 self
6038 }
6039 /// Required. The name of the resource in the form of `projects/[PROJECT_ID]/resources/[RESOURCE_URL]`.
6040 ///
6041 /// Sets the *name* path property to the given value.
6042 ///
6043 /// Even though the property as already been set when instantiating this call,
6044 /// we provide this method for API completeness.
6045 pub fn name(mut self, new_value: &str) -> ProjectLocationResourceExportSBOMCall<'a, C> {
6046 self._name = new_value.to_string();
6047 self
6048 }
6049 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6050 /// while executing the actual API request.
6051 ///
6052 /// ````text
6053 /// It should be used to handle progress information, and to implement a certain level of resilience.
6054 /// ````
6055 ///
6056 /// Sets the *delegate* property to the given value.
6057 pub fn delegate(
6058 mut self,
6059 new_value: &'a mut dyn common::Delegate,
6060 ) -> ProjectLocationResourceExportSBOMCall<'a, C> {
6061 self._delegate = Some(new_value);
6062 self
6063 }
6064
6065 /// Set any additional parameter of the query string used in the request.
6066 /// It should be used to set parameters which are not yet available through their own
6067 /// setters.
6068 ///
6069 /// Please note that this method must not be used to set any of the known parameters
6070 /// which have their own setter method. If done anyway, the request will fail.
6071 ///
6072 /// # Additional Parameters
6073 ///
6074 /// * *$.xgafv* (query-string) - V1 error format.
6075 /// * *access_token* (query-string) - OAuth access token.
6076 /// * *alt* (query-string) - Data format for response.
6077 /// * *callback* (query-string) - JSONP
6078 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6079 /// * *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.
6080 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6081 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6082 /// * *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.
6083 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6084 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6085 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationResourceExportSBOMCall<'a, C>
6086 where
6087 T: AsRef<str>,
6088 {
6089 self._additional_params
6090 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6091 self
6092 }
6093
6094 /// Identifies the authorization scope for the method you are building.
6095 ///
6096 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6097 /// [`Scope::CloudPlatform`].
6098 ///
6099 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6100 /// tokens for more than one scope.
6101 ///
6102 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6103 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6104 /// sufficient, a read-write scope will do as well.
6105 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationResourceExportSBOMCall<'a, C>
6106 where
6107 St: AsRef<str>,
6108 {
6109 self._scopes.insert(String::from(scope.as_ref()));
6110 self
6111 }
6112 /// Identifies the authorization scope(s) for the method you are building.
6113 ///
6114 /// See [`Self::add_scope()`] for details.
6115 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationResourceExportSBOMCall<'a, C>
6116 where
6117 I: IntoIterator<Item = St>,
6118 St: AsRef<str>,
6119 {
6120 self._scopes
6121 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6122 self
6123 }
6124
6125 /// Removes all scopes, and no default scope will be used either.
6126 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6127 /// for details).
6128 pub fn clear_scopes(mut self) -> ProjectLocationResourceExportSBOMCall<'a, C> {
6129 self._scopes.clear();
6130 self
6131 }
6132}
6133
6134/// Lists occurrences referencing the specified note. Provider projects can use this method to get all occurrences across consumer projects referencing the specified note.
6135///
6136/// A builder for the *notes.occurrences.list* method supported by a *project* resource.
6137/// It is not used directly, but through a [`ProjectMethods`] instance.
6138///
6139/// # Example
6140///
6141/// Instantiate a resource method builder
6142///
6143/// ```test_harness,no_run
6144/// # extern crate hyper;
6145/// # extern crate hyper_rustls;
6146/// # extern crate google_containeranalysis1 as containeranalysis1;
6147/// # async fn dox() {
6148/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6149///
6150/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6151/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6152/// # secret,
6153/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6154/// # ).build().await.unwrap();
6155///
6156/// # let client = hyper_util::client::legacy::Client::builder(
6157/// # hyper_util::rt::TokioExecutor::new()
6158/// # )
6159/// # .build(
6160/// # hyper_rustls::HttpsConnectorBuilder::new()
6161/// # .with_native_roots()
6162/// # .unwrap()
6163/// # .https_or_http()
6164/// # .enable_http1()
6165/// # .build()
6166/// # );
6167/// # let mut hub = ContainerAnalysis::new(client, auth);
6168/// // You can configure optional parameters by calling the respective setters at will, and
6169/// // execute the final call using `doit()`.
6170/// // Values shown here are possibly random and not representative !
6171/// let result = hub.projects().notes_occurrences_list("name")
6172/// .page_token("ut")
6173/// .page_size(-12)
6174/// .filter("rebum.")
6175/// .doit().await;
6176/// # }
6177/// ```
6178pub struct ProjectNoteOccurrenceListCall<'a, C>
6179where
6180 C: 'a,
6181{
6182 hub: &'a ContainerAnalysis<C>,
6183 _name: String,
6184 _page_token: Option<String>,
6185 _page_size: Option<i32>,
6186 _filter: Option<String>,
6187 _delegate: Option<&'a mut dyn common::Delegate>,
6188 _additional_params: HashMap<String, String>,
6189 _scopes: BTreeSet<String>,
6190}
6191
6192impl<'a, C> common::CallBuilder for ProjectNoteOccurrenceListCall<'a, C> {}
6193
6194impl<'a, C> ProjectNoteOccurrenceListCall<'a, C>
6195where
6196 C: common::Connector,
6197{
6198 /// Perform the operation you have build so far.
6199 pub async fn doit(mut self) -> common::Result<(common::Response, ListNoteOccurrencesResponse)> {
6200 use std::borrow::Cow;
6201 use std::io::{Read, Seek};
6202
6203 use common::{url::Params, ToParts};
6204 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6205
6206 let mut dd = common::DefaultDelegate;
6207 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6208 dlg.begin(common::MethodInfo {
6209 id: "containeranalysis.projects.notes.occurrences.list",
6210 http_method: hyper::Method::GET,
6211 });
6212
6213 for &field in ["alt", "name", "pageToken", "pageSize", "filter"].iter() {
6214 if self._additional_params.contains_key(field) {
6215 dlg.finished(false);
6216 return Err(common::Error::FieldClash(field));
6217 }
6218 }
6219
6220 let mut params = Params::with_capacity(6 + self._additional_params.len());
6221 params.push("name", self._name);
6222 if let Some(value) = self._page_token.as_ref() {
6223 params.push("pageToken", value);
6224 }
6225 if let Some(value) = self._page_size.as_ref() {
6226 params.push("pageSize", value.to_string());
6227 }
6228 if let Some(value) = self._filter.as_ref() {
6229 params.push("filter", value);
6230 }
6231
6232 params.extend(self._additional_params.iter());
6233
6234 params.push("alt", "json");
6235 let mut url = self.hub._base_url.clone() + "v1/{+name}/occurrences";
6236 if self._scopes.is_empty() {
6237 self._scopes
6238 .insert(Scope::CloudPlatform.as_ref().to_string());
6239 }
6240
6241 #[allow(clippy::single_element_loop)]
6242 for &(find_this, param_name) in [("{+name}", "name")].iter() {
6243 url = params.uri_replacement(url, param_name, find_this, true);
6244 }
6245 {
6246 let to_remove = ["name"];
6247 params.remove_params(&to_remove);
6248 }
6249
6250 let url = params.parse_with_url(&url);
6251
6252 loop {
6253 let token = match self
6254 .hub
6255 .auth
6256 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6257 .await
6258 {
6259 Ok(token) => token,
6260 Err(e) => match dlg.token(e) {
6261 Ok(token) => token,
6262 Err(e) => {
6263 dlg.finished(false);
6264 return Err(common::Error::MissingToken(e));
6265 }
6266 },
6267 };
6268 let mut req_result = {
6269 let client = &self.hub.client;
6270 dlg.pre_request();
6271 let mut req_builder = hyper::Request::builder()
6272 .method(hyper::Method::GET)
6273 .uri(url.as_str())
6274 .header(USER_AGENT, self.hub._user_agent.clone());
6275
6276 if let Some(token) = token.as_ref() {
6277 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6278 }
6279
6280 let request = req_builder
6281 .header(CONTENT_LENGTH, 0_u64)
6282 .body(common::to_body::<String>(None));
6283
6284 client.request(request.unwrap()).await
6285 };
6286
6287 match req_result {
6288 Err(err) => {
6289 if let common::Retry::After(d) = dlg.http_error(&err) {
6290 sleep(d).await;
6291 continue;
6292 }
6293 dlg.finished(false);
6294 return Err(common::Error::HttpError(err));
6295 }
6296 Ok(res) => {
6297 let (mut parts, body) = res.into_parts();
6298 let mut body = common::Body::new(body);
6299 if !parts.status.is_success() {
6300 let bytes = common::to_bytes(body).await.unwrap_or_default();
6301 let error = serde_json::from_str(&common::to_string(&bytes));
6302 let response = common::to_response(parts, bytes.into());
6303
6304 if let common::Retry::After(d) =
6305 dlg.http_failure(&response, error.as_ref().ok())
6306 {
6307 sleep(d).await;
6308 continue;
6309 }
6310
6311 dlg.finished(false);
6312
6313 return Err(match error {
6314 Ok(value) => common::Error::BadRequest(value),
6315 _ => common::Error::Failure(response),
6316 });
6317 }
6318 let response = {
6319 let bytes = common::to_bytes(body).await.unwrap_or_default();
6320 let encoded = common::to_string(&bytes);
6321 match serde_json::from_str(&encoded) {
6322 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6323 Err(error) => {
6324 dlg.response_json_decode_error(&encoded, &error);
6325 return Err(common::Error::JsonDecodeError(
6326 encoded.to_string(),
6327 error,
6328 ));
6329 }
6330 }
6331 };
6332
6333 dlg.finished(true);
6334 return Ok(response);
6335 }
6336 }
6337 }
6338 }
6339
6340 /// Required. The name of the note to list occurrences for in the form of `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.
6341 ///
6342 /// Sets the *name* path property to the given value.
6343 ///
6344 /// Even though the property as already been set when instantiating this call,
6345 /// we provide this method for API completeness.
6346 pub fn name(mut self, new_value: &str) -> ProjectNoteOccurrenceListCall<'a, C> {
6347 self._name = new_value.to_string();
6348 self
6349 }
6350 /// Token to provide to skip to a particular spot in the list.
6351 ///
6352 /// Sets the *page token* query property to the given value.
6353 pub fn page_token(mut self, new_value: &str) -> ProjectNoteOccurrenceListCall<'a, C> {
6354 self._page_token = Some(new_value.to_string());
6355 self
6356 }
6357 /// Number of occurrences to return in the list.
6358 ///
6359 /// Sets the *page size* query property to the given value.
6360 pub fn page_size(mut self, new_value: i32) -> ProjectNoteOccurrenceListCall<'a, C> {
6361 self._page_size = Some(new_value);
6362 self
6363 }
6364 /// The filter expression.
6365 ///
6366 /// Sets the *filter* query property to the given value.
6367 pub fn filter(mut self, new_value: &str) -> ProjectNoteOccurrenceListCall<'a, C> {
6368 self._filter = Some(new_value.to_string());
6369 self
6370 }
6371 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6372 /// while executing the actual API request.
6373 ///
6374 /// ````text
6375 /// It should be used to handle progress information, and to implement a certain level of resilience.
6376 /// ````
6377 ///
6378 /// Sets the *delegate* property to the given value.
6379 pub fn delegate(
6380 mut self,
6381 new_value: &'a mut dyn common::Delegate,
6382 ) -> ProjectNoteOccurrenceListCall<'a, C> {
6383 self._delegate = Some(new_value);
6384 self
6385 }
6386
6387 /// Set any additional parameter of the query string used in the request.
6388 /// It should be used to set parameters which are not yet available through their own
6389 /// setters.
6390 ///
6391 /// Please note that this method must not be used to set any of the known parameters
6392 /// which have their own setter method. If done anyway, the request will fail.
6393 ///
6394 /// # Additional Parameters
6395 ///
6396 /// * *$.xgafv* (query-string) - V1 error format.
6397 /// * *access_token* (query-string) - OAuth access token.
6398 /// * *alt* (query-string) - Data format for response.
6399 /// * *callback* (query-string) - JSONP
6400 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6401 /// * *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.
6402 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6403 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6404 /// * *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.
6405 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6406 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6407 pub fn param<T>(mut self, name: T, value: T) -> ProjectNoteOccurrenceListCall<'a, C>
6408 where
6409 T: AsRef<str>,
6410 {
6411 self._additional_params
6412 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6413 self
6414 }
6415
6416 /// Identifies the authorization scope for the method you are building.
6417 ///
6418 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6419 /// [`Scope::CloudPlatform`].
6420 ///
6421 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6422 /// tokens for more than one scope.
6423 ///
6424 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6425 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6426 /// sufficient, a read-write scope will do as well.
6427 pub fn add_scope<St>(mut self, scope: St) -> ProjectNoteOccurrenceListCall<'a, C>
6428 where
6429 St: AsRef<str>,
6430 {
6431 self._scopes.insert(String::from(scope.as_ref()));
6432 self
6433 }
6434 /// Identifies the authorization scope(s) for the method you are building.
6435 ///
6436 /// See [`Self::add_scope()`] for details.
6437 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectNoteOccurrenceListCall<'a, C>
6438 where
6439 I: IntoIterator<Item = St>,
6440 St: AsRef<str>,
6441 {
6442 self._scopes
6443 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6444 self
6445 }
6446
6447 /// Removes all scopes, and no default scope will be used either.
6448 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6449 /// for details).
6450 pub fn clear_scopes(mut self) -> ProjectNoteOccurrenceListCall<'a, C> {
6451 self._scopes.clear();
6452 self
6453 }
6454}
6455
6456/// Creates new notes in batch.
6457///
6458/// A builder for the *notes.batchCreate* method supported by a *project* resource.
6459/// It is not used directly, but through a [`ProjectMethods`] instance.
6460///
6461/// # Example
6462///
6463/// Instantiate a resource method builder
6464///
6465/// ```test_harness,no_run
6466/// # extern crate hyper;
6467/// # extern crate hyper_rustls;
6468/// # extern crate google_containeranalysis1 as containeranalysis1;
6469/// use containeranalysis1::api::BatchCreateNotesRequest;
6470/// # async fn dox() {
6471/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6472///
6473/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6474/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6475/// # secret,
6476/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6477/// # ).build().await.unwrap();
6478///
6479/// # let client = hyper_util::client::legacy::Client::builder(
6480/// # hyper_util::rt::TokioExecutor::new()
6481/// # )
6482/// # .build(
6483/// # hyper_rustls::HttpsConnectorBuilder::new()
6484/// # .with_native_roots()
6485/// # .unwrap()
6486/// # .https_or_http()
6487/// # .enable_http1()
6488/// # .build()
6489/// # );
6490/// # let mut hub = ContainerAnalysis::new(client, auth);
6491/// // As the method needs a request, you would usually fill it with the desired information
6492/// // into the respective structure. Some of the parts shown here might not be applicable !
6493/// // Values shown here are possibly random and not representative !
6494/// let mut req = BatchCreateNotesRequest::default();
6495///
6496/// // You can configure optional parameters by calling the respective setters at will, and
6497/// // execute the final call using `doit()`.
6498/// // Values shown here are possibly random and not representative !
6499/// let result = hub.projects().notes_batch_create(req, "parent")
6500/// .doit().await;
6501/// # }
6502/// ```
6503pub struct ProjectNoteBatchCreateCall<'a, C>
6504where
6505 C: 'a,
6506{
6507 hub: &'a ContainerAnalysis<C>,
6508 _request: BatchCreateNotesRequest,
6509 _parent: String,
6510 _delegate: Option<&'a mut dyn common::Delegate>,
6511 _additional_params: HashMap<String, String>,
6512 _scopes: BTreeSet<String>,
6513}
6514
6515impl<'a, C> common::CallBuilder for ProjectNoteBatchCreateCall<'a, C> {}
6516
6517impl<'a, C> ProjectNoteBatchCreateCall<'a, C>
6518where
6519 C: common::Connector,
6520{
6521 /// Perform the operation you have build so far.
6522 pub async fn doit(mut self) -> common::Result<(common::Response, BatchCreateNotesResponse)> {
6523 use std::borrow::Cow;
6524 use std::io::{Read, Seek};
6525
6526 use common::{url::Params, ToParts};
6527 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6528
6529 let mut dd = common::DefaultDelegate;
6530 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6531 dlg.begin(common::MethodInfo {
6532 id: "containeranalysis.projects.notes.batchCreate",
6533 http_method: hyper::Method::POST,
6534 });
6535
6536 for &field in ["alt", "parent"].iter() {
6537 if self._additional_params.contains_key(field) {
6538 dlg.finished(false);
6539 return Err(common::Error::FieldClash(field));
6540 }
6541 }
6542
6543 let mut params = Params::with_capacity(4 + self._additional_params.len());
6544 params.push("parent", self._parent);
6545
6546 params.extend(self._additional_params.iter());
6547
6548 params.push("alt", "json");
6549 let mut url = self.hub._base_url.clone() + "v1/{+parent}/notes:batchCreate";
6550 if self._scopes.is_empty() {
6551 self._scopes
6552 .insert(Scope::CloudPlatform.as_ref().to_string());
6553 }
6554
6555 #[allow(clippy::single_element_loop)]
6556 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6557 url = params.uri_replacement(url, param_name, find_this, true);
6558 }
6559 {
6560 let to_remove = ["parent"];
6561 params.remove_params(&to_remove);
6562 }
6563
6564 let url = params.parse_with_url(&url);
6565
6566 let mut json_mime_type = mime::APPLICATION_JSON;
6567 let mut request_value_reader = {
6568 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6569 common::remove_json_null_values(&mut value);
6570 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6571 serde_json::to_writer(&mut dst, &value).unwrap();
6572 dst
6573 };
6574 let request_size = request_value_reader
6575 .seek(std::io::SeekFrom::End(0))
6576 .unwrap();
6577 request_value_reader
6578 .seek(std::io::SeekFrom::Start(0))
6579 .unwrap();
6580
6581 loop {
6582 let token = match self
6583 .hub
6584 .auth
6585 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6586 .await
6587 {
6588 Ok(token) => token,
6589 Err(e) => match dlg.token(e) {
6590 Ok(token) => token,
6591 Err(e) => {
6592 dlg.finished(false);
6593 return Err(common::Error::MissingToken(e));
6594 }
6595 },
6596 };
6597 request_value_reader
6598 .seek(std::io::SeekFrom::Start(0))
6599 .unwrap();
6600 let mut req_result = {
6601 let client = &self.hub.client;
6602 dlg.pre_request();
6603 let mut req_builder = hyper::Request::builder()
6604 .method(hyper::Method::POST)
6605 .uri(url.as_str())
6606 .header(USER_AGENT, self.hub._user_agent.clone());
6607
6608 if let Some(token) = token.as_ref() {
6609 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6610 }
6611
6612 let request = req_builder
6613 .header(CONTENT_TYPE, json_mime_type.to_string())
6614 .header(CONTENT_LENGTH, request_size as u64)
6615 .body(common::to_body(
6616 request_value_reader.get_ref().clone().into(),
6617 ));
6618
6619 client.request(request.unwrap()).await
6620 };
6621
6622 match req_result {
6623 Err(err) => {
6624 if let common::Retry::After(d) = dlg.http_error(&err) {
6625 sleep(d).await;
6626 continue;
6627 }
6628 dlg.finished(false);
6629 return Err(common::Error::HttpError(err));
6630 }
6631 Ok(res) => {
6632 let (mut parts, body) = res.into_parts();
6633 let mut body = common::Body::new(body);
6634 if !parts.status.is_success() {
6635 let bytes = common::to_bytes(body).await.unwrap_or_default();
6636 let error = serde_json::from_str(&common::to_string(&bytes));
6637 let response = common::to_response(parts, bytes.into());
6638
6639 if let common::Retry::After(d) =
6640 dlg.http_failure(&response, error.as_ref().ok())
6641 {
6642 sleep(d).await;
6643 continue;
6644 }
6645
6646 dlg.finished(false);
6647
6648 return Err(match error {
6649 Ok(value) => common::Error::BadRequest(value),
6650 _ => common::Error::Failure(response),
6651 });
6652 }
6653 let response = {
6654 let bytes = common::to_bytes(body).await.unwrap_or_default();
6655 let encoded = common::to_string(&bytes);
6656 match serde_json::from_str(&encoded) {
6657 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6658 Err(error) => {
6659 dlg.response_json_decode_error(&encoded, &error);
6660 return Err(common::Error::JsonDecodeError(
6661 encoded.to_string(),
6662 error,
6663 ));
6664 }
6665 }
6666 };
6667
6668 dlg.finished(true);
6669 return Ok(response);
6670 }
6671 }
6672 }
6673 }
6674
6675 ///
6676 /// Sets the *request* property to the given value.
6677 ///
6678 /// Even though the property as already been set when instantiating this call,
6679 /// we provide this method for API completeness.
6680 pub fn request(
6681 mut self,
6682 new_value: BatchCreateNotesRequest,
6683 ) -> ProjectNoteBatchCreateCall<'a, C> {
6684 self._request = new_value;
6685 self
6686 }
6687 /// Required. The name of the project in the form of `projects/[PROJECT_ID]`, under which the notes are to be created.
6688 ///
6689 /// Sets the *parent* path property to the given value.
6690 ///
6691 /// Even though the property as already been set when instantiating this call,
6692 /// we provide this method for API completeness.
6693 pub fn parent(mut self, new_value: &str) -> ProjectNoteBatchCreateCall<'a, C> {
6694 self._parent = new_value.to_string();
6695 self
6696 }
6697 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6698 /// while executing the actual API request.
6699 ///
6700 /// ````text
6701 /// It should be used to handle progress information, and to implement a certain level of resilience.
6702 /// ````
6703 ///
6704 /// Sets the *delegate* property to the given value.
6705 pub fn delegate(
6706 mut self,
6707 new_value: &'a mut dyn common::Delegate,
6708 ) -> ProjectNoteBatchCreateCall<'a, C> {
6709 self._delegate = Some(new_value);
6710 self
6711 }
6712
6713 /// Set any additional parameter of the query string used in the request.
6714 /// It should be used to set parameters which are not yet available through their own
6715 /// setters.
6716 ///
6717 /// Please note that this method must not be used to set any of the known parameters
6718 /// which have their own setter method. If done anyway, the request will fail.
6719 ///
6720 /// # Additional Parameters
6721 ///
6722 /// * *$.xgafv* (query-string) - V1 error format.
6723 /// * *access_token* (query-string) - OAuth access token.
6724 /// * *alt* (query-string) - Data format for response.
6725 /// * *callback* (query-string) - JSONP
6726 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6727 /// * *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.
6728 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6729 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6730 /// * *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.
6731 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6732 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6733 pub fn param<T>(mut self, name: T, value: T) -> ProjectNoteBatchCreateCall<'a, C>
6734 where
6735 T: AsRef<str>,
6736 {
6737 self._additional_params
6738 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6739 self
6740 }
6741
6742 /// Identifies the authorization scope for the method you are building.
6743 ///
6744 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6745 /// [`Scope::CloudPlatform`].
6746 ///
6747 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6748 /// tokens for more than one scope.
6749 ///
6750 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6751 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6752 /// sufficient, a read-write scope will do as well.
6753 pub fn add_scope<St>(mut self, scope: St) -> ProjectNoteBatchCreateCall<'a, C>
6754 where
6755 St: AsRef<str>,
6756 {
6757 self._scopes.insert(String::from(scope.as_ref()));
6758 self
6759 }
6760 /// Identifies the authorization scope(s) for the method you are building.
6761 ///
6762 /// See [`Self::add_scope()`] for details.
6763 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectNoteBatchCreateCall<'a, C>
6764 where
6765 I: IntoIterator<Item = St>,
6766 St: AsRef<str>,
6767 {
6768 self._scopes
6769 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6770 self
6771 }
6772
6773 /// Removes all scopes, and no default scope will be used either.
6774 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6775 /// for details).
6776 pub fn clear_scopes(mut self) -> ProjectNoteBatchCreateCall<'a, C> {
6777 self._scopes.clear();
6778 self
6779 }
6780}
6781
6782/// Creates a new note.
6783///
6784/// A builder for the *notes.create* method supported by a *project* resource.
6785/// It is not used directly, but through a [`ProjectMethods`] instance.
6786///
6787/// # Example
6788///
6789/// Instantiate a resource method builder
6790///
6791/// ```test_harness,no_run
6792/// # extern crate hyper;
6793/// # extern crate hyper_rustls;
6794/// # extern crate google_containeranalysis1 as containeranalysis1;
6795/// use containeranalysis1::api::Note;
6796/// # async fn dox() {
6797/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6798///
6799/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6800/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
6801/// # secret,
6802/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6803/// # ).build().await.unwrap();
6804///
6805/// # let client = hyper_util::client::legacy::Client::builder(
6806/// # hyper_util::rt::TokioExecutor::new()
6807/// # )
6808/// # .build(
6809/// # hyper_rustls::HttpsConnectorBuilder::new()
6810/// # .with_native_roots()
6811/// # .unwrap()
6812/// # .https_or_http()
6813/// # .enable_http1()
6814/// # .build()
6815/// # );
6816/// # let mut hub = ContainerAnalysis::new(client, auth);
6817/// // As the method needs a request, you would usually fill it with the desired information
6818/// // into the respective structure. Some of the parts shown here might not be applicable !
6819/// // Values shown here are possibly random and not representative !
6820/// let mut req = Note::default();
6821///
6822/// // You can configure optional parameters by calling the respective setters at will, and
6823/// // execute the final call using `doit()`.
6824/// // Values shown here are possibly random and not representative !
6825/// let result = hub.projects().notes_create(req, "parent")
6826/// .note_id("ipsum")
6827/// .doit().await;
6828/// # }
6829/// ```
6830pub struct ProjectNoteCreateCall<'a, C>
6831where
6832 C: 'a,
6833{
6834 hub: &'a ContainerAnalysis<C>,
6835 _request: Note,
6836 _parent: String,
6837 _note_id: Option<String>,
6838 _delegate: Option<&'a mut dyn common::Delegate>,
6839 _additional_params: HashMap<String, String>,
6840 _scopes: BTreeSet<String>,
6841}
6842
6843impl<'a, C> common::CallBuilder for ProjectNoteCreateCall<'a, C> {}
6844
6845impl<'a, C> ProjectNoteCreateCall<'a, C>
6846where
6847 C: common::Connector,
6848{
6849 /// Perform the operation you have build so far.
6850 pub async fn doit(mut self) -> common::Result<(common::Response, Note)> {
6851 use std::borrow::Cow;
6852 use std::io::{Read, Seek};
6853
6854 use common::{url::Params, ToParts};
6855 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6856
6857 let mut dd = common::DefaultDelegate;
6858 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6859 dlg.begin(common::MethodInfo {
6860 id: "containeranalysis.projects.notes.create",
6861 http_method: hyper::Method::POST,
6862 });
6863
6864 for &field in ["alt", "parent", "noteId"].iter() {
6865 if self._additional_params.contains_key(field) {
6866 dlg.finished(false);
6867 return Err(common::Error::FieldClash(field));
6868 }
6869 }
6870
6871 let mut params = Params::with_capacity(5 + self._additional_params.len());
6872 params.push("parent", self._parent);
6873 if let Some(value) = self._note_id.as_ref() {
6874 params.push("noteId", value);
6875 }
6876
6877 params.extend(self._additional_params.iter());
6878
6879 params.push("alt", "json");
6880 let mut url = self.hub._base_url.clone() + "v1/{+parent}/notes";
6881 if self._scopes.is_empty() {
6882 self._scopes
6883 .insert(Scope::CloudPlatform.as_ref().to_string());
6884 }
6885
6886 #[allow(clippy::single_element_loop)]
6887 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6888 url = params.uri_replacement(url, param_name, find_this, true);
6889 }
6890 {
6891 let to_remove = ["parent"];
6892 params.remove_params(&to_remove);
6893 }
6894
6895 let url = params.parse_with_url(&url);
6896
6897 let mut json_mime_type = mime::APPLICATION_JSON;
6898 let mut request_value_reader = {
6899 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6900 common::remove_json_null_values(&mut value);
6901 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6902 serde_json::to_writer(&mut dst, &value).unwrap();
6903 dst
6904 };
6905 let request_size = request_value_reader
6906 .seek(std::io::SeekFrom::End(0))
6907 .unwrap();
6908 request_value_reader
6909 .seek(std::io::SeekFrom::Start(0))
6910 .unwrap();
6911
6912 loop {
6913 let token = match self
6914 .hub
6915 .auth
6916 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6917 .await
6918 {
6919 Ok(token) => token,
6920 Err(e) => match dlg.token(e) {
6921 Ok(token) => token,
6922 Err(e) => {
6923 dlg.finished(false);
6924 return Err(common::Error::MissingToken(e));
6925 }
6926 },
6927 };
6928 request_value_reader
6929 .seek(std::io::SeekFrom::Start(0))
6930 .unwrap();
6931 let mut req_result = {
6932 let client = &self.hub.client;
6933 dlg.pre_request();
6934 let mut req_builder = hyper::Request::builder()
6935 .method(hyper::Method::POST)
6936 .uri(url.as_str())
6937 .header(USER_AGENT, self.hub._user_agent.clone());
6938
6939 if let Some(token) = token.as_ref() {
6940 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6941 }
6942
6943 let request = req_builder
6944 .header(CONTENT_TYPE, json_mime_type.to_string())
6945 .header(CONTENT_LENGTH, request_size as u64)
6946 .body(common::to_body(
6947 request_value_reader.get_ref().clone().into(),
6948 ));
6949
6950 client.request(request.unwrap()).await
6951 };
6952
6953 match req_result {
6954 Err(err) => {
6955 if let common::Retry::After(d) = dlg.http_error(&err) {
6956 sleep(d).await;
6957 continue;
6958 }
6959 dlg.finished(false);
6960 return Err(common::Error::HttpError(err));
6961 }
6962 Ok(res) => {
6963 let (mut parts, body) = res.into_parts();
6964 let mut body = common::Body::new(body);
6965 if !parts.status.is_success() {
6966 let bytes = common::to_bytes(body).await.unwrap_or_default();
6967 let error = serde_json::from_str(&common::to_string(&bytes));
6968 let response = common::to_response(parts, bytes.into());
6969
6970 if let common::Retry::After(d) =
6971 dlg.http_failure(&response, error.as_ref().ok())
6972 {
6973 sleep(d).await;
6974 continue;
6975 }
6976
6977 dlg.finished(false);
6978
6979 return Err(match error {
6980 Ok(value) => common::Error::BadRequest(value),
6981 _ => common::Error::Failure(response),
6982 });
6983 }
6984 let response = {
6985 let bytes = common::to_bytes(body).await.unwrap_or_default();
6986 let encoded = common::to_string(&bytes);
6987 match serde_json::from_str(&encoded) {
6988 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6989 Err(error) => {
6990 dlg.response_json_decode_error(&encoded, &error);
6991 return Err(common::Error::JsonDecodeError(
6992 encoded.to_string(),
6993 error,
6994 ));
6995 }
6996 }
6997 };
6998
6999 dlg.finished(true);
7000 return Ok(response);
7001 }
7002 }
7003 }
7004 }
7005
7006 ///
7007 /// Sets the *request* property to the given value.
7008 ///
7009 /// Even though the property as already been set when instantiating this call,
7010 /// we provide this method for API completeness.
7011 pub fn request(mut self, new_value: Note) -> ProjectNoteCreateCall<'a, C> {
7012 self._request = new_value;
7013 self
7014 }
7015 /// Required. The name of the project in the form of `projects/[PROJECT_ID]`, under which the note is to be created.
7016 ///
7017 /// Sets the *parent* path property to the given value.
7018 ///
7019 /// Even though the property as already been set when instantiating this call,
7020 /// we provide this method for API completeness.
7021 pub fn parent(mut self, new_value: &str) -> ProjectNoteCreateCall<'a, C> {
7022 self._parent = new_value.to_string();
7023 self
7024 }
7025 /// Required. The ID to use for this note.
7026 ///
7027 /// Sets the *note id* query property to the given value.
7028 pub fn note_id(mut self, new_value: &str) -> ProjectNoteCreateCall<'a, C> {
7029 self._note_id = Some(new_value.to_string());
7030 self
7031 }
7032 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7033 /// while executing the actual API request.
7034 ///
7035 /// ````text
7036 /// It should be used to handle progress information, and to implement a certain level of resilience.
7037 /// ````
7038 ///
7039 /// Sets the *delegate* property to the given value.
7040 pub fn delegate(
7041 mut self,
7042 new_value: &'a mut dyn common::Delegate,
7043 ) -> ProjectNoteCreateCall<'a, C> {
7044 self._delegate = Some(new_value);
7045 self
7046 }
7047
7048 /// Set any additional parameter of the query string used in the request.
7049 /// It should be used to set parameters which are not yet available through their own
7050 /// setters.
7051 ///
7052 /// Please note that this method must not be used to set any of the known parameters
7053 /// which have their own setter method. If done anyway, the request will fail.
7054 ///
7055 /// # Additional Parameters
7056 ///
7057 /// * *$.xgafv* (query-string) - V1 error format.
7058 /// * *access_token* (query-string) - OAuth access token.
7059 /// * *alt* (query-string) - Data format for response.
7060 /// * *callback* (query-string) - JSONP
7061 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7062 /// * *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.
7063 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7064 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7065 /// * *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.
7066 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7067 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7068 pub fn param<T>(mut self, name: T, value: T) -> ProjectNoteCreateCall<'a, C>
7069 where
7070 T: AsRef<str>,
7071 {
7072 self._additional_params
7073 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7074 self
7075 }
7076
7077 /// Identifies the authorization scope for the method you are building.
7078 ///
7079 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7080 /// [`Scope::CloudPlatform`].
7081 ///
7082 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7083 /// tokens for more than one scope.
7084 ///
7085 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7086 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7087 /// sufficient, a read-write scope will do as well.
7088 pub fn add_scope<St>(mut self, scope: St) -> ProjectNoteCreateCall<'a, C>
7089 where
7090 St: AsRef<str>,
7091 {
7092 self._scopes.insert(String::from(scope.as_ref()));
7093 self
7094 }
7095 /// Identifies the authorization scope(s) for the method you are building.
7096 ///
7097 /// See [`Self::add_scope()`] for details.
7098 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectNoteCreateCall<'a, C>
7099 where
7100 I: IntoIterator<Item = St>,
7101 St: AsRef<str>,
7102 {
7103 self._scopes
7104 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7105 self
7106 }
7107
7108 /// Removes all scopes, and no default scope will be used either.
7109 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7110 /// for details).
7111 pub fn clear_scopes(mut self) -> ProjectNoteCreateCall<'a, C> {
7112 self._scopes.clear();
7113 self
7114 }
7115}
7116
7117/// Deletes the specified note.
7118///
7119/// A builder for the *notes.delete* method supported by a *project* resource.
7120/// It is not used directly, but through a [`ProjectMethods`] instance.
7121///
7122/// # Example
7123///
7124/// Instantiate a resource method builder
7125///
7126/// ```test_harness,no_run
7127/// # extern crate hyper;
7128/// # extern crate hyper_rustls;
7129/// # extern crate google_containeranalysis1 as containeranalysis1;
7130/// # async fn dox() {
7131/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7132///
7133/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7134/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7135/// # secret,
7136/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7137/// # ).build().await.unwrap();
7138///
7139/// # let client = hyper_util::client::legacy::Client::builder(
7140/// # hyper_util::rt::TokioExecutor::new()
7141/// # )
7142/// # .build(
7143/// # hyper_rustls::HttpsConnectorBuilder::new()
7144/// # .with_native_roots()
7145/// # .unwrap()
7146/// # .https_or_http()
7147/// # .enable_http1()
7148/// # .build()
7149/// # );
7150/// # let mut hub = ContainerAnalysis::new(client, auth);
7151/// // You can configure optional parameters by calling the respective setters at will, and
7152/// // execute the final call using `doit()`.
7153/// // Values shown here are possibly random and not representative !
7154/// let result = hub.projects().notes_delete("name")
7155/// .doit().await;
7156/// # }
7157/// ```
7158pub struct ProjectNoteDeleteCall<'a, C>
7159where
7160 C: 'a,
7161{
7162 hub: &'a ContainerAnalysis<C>,
7163 _name: String,
7164 _delegate: Option<&'a mut dyn common::Delegate>,
7165 _additional_params: HashMap<String, String>,
7166 _scopes: BTreeSet<String>,
7167}
7168
7169impl<'a, C> common::CallBuilder for ProjectNoteDeleteCall<'a, C> {}
7170
7171impl<'a, C> ProjectNoteDeleteCall<'a, C>
7172where
7173 C: common::Connector,
7174{
7175 /// Perform the operation you have build so far.
7176 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
7177 use std::borrow::Cow;
7178 use std::io::{Read, Seek};
7179
7180 use common::{url::Params, ToParts};
7181 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7182
7183 let mut dd = common::DefaultDelegate;
7184 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7185 dlg.begin(common::MethodInfo {
7186 id: "containeranalysis.projects.notes.delete",
7187 http_method: hyper::Method::DELETE,
7188 });
7189
7190 for &field in ["alt", "name"].iter() {
7191 if self._additional_params.contains_key(field) {
7192 dlg.finished(false);
7193 return Err(common::Error::FieldClash(field));
7194 }
7195 }
7196
7197 let mut params = Params::with_capacity(3 + self._additional_params.len());
7198 params.push("name", self._name);
7199
7200 params.extend(self._additional_params.iter());
7201
7202 params.push("alt", "json");
7203 let mut url = self.hub._base_url.clone() + "v1/{+name}";
7204 if self._scopes.is_empty() {
7205 self._scopes
7206 .insert(Scope::CloudPlatform.as_ref().to_string());
7207 }
7208
7209 #[allow(clippy::single_element_loop)]
7210 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7211 url = params.uri_replacement(url, param_name, find_this, true);
7212 }
7213 {
7214 let to_remove = ["name"];
7215 params.remove_params(&to_remove);
7216 }
7217
7218 let url = params.parse_with_url(&url);
7219
7220 loop {
7221 let token = match self
7222 .hub
7223 .auth
7224 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7225 .await
7226 {
7227 Ok(token) => token,
7228 Err(e) => match dlg.token(e) {
7229 Ok(token) => token,
7230 Err(e) => {
7231 dlg.finished(false);
7232 return Err(common::Error::MissingToken(e));
7233 }
7234 },
7235 };
7236 let mut req_result = {
7237 let client = &self.hub.client;
7238 dlg.pre_request();
7239 let mut req_builder = hyper::Request::builder()
7240 .method(hyper::Method::DELETE)
7241 .uri(url.as_str())
7242 .header(USER_AGENT, self.hub._user_agent.clone());
7243
7244 if let Some(token) = token.as_ref() {
7245 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7246 }
7247
7248 let request = req_builder
7249 .header(CONTENT_LENGTH, 0_u64)
7250 .body(common::to_body::<String>(None));
7251
7252 client.request(request.unwrap()).await
7253 };
7254
7255 match req_result {
7256 Err(err) => {
7257 if let common::Retry::After(d) = dlg.http_error(&err) {
7258 sleep(d).await;
7259 continue;
7260 }
7261 dlg.finished(false);
7262 return Err(common::Error::HttpError(err));
7263 }
7264 Ok(res) => {
7265 let (mut parts, body) = res.into_parts();
7266 let mut body = common::Body::new(body);
7267 if !parts.status.is_success() {
7268 let bytes = common::to_bytes(body).await.unwrap_or_default();
7269 let error = serde_json::from_str(&common::to_string(&bytes));
7270 let response = common::to_response(parts, bytes.into());
7271
7272 if let common::Retry::After(d) =
7273 dlg.http_failure(&response, error.as_ref().ok())
7274 {
7275 sleep(d).await;
7276 continue;
7277 }
7278
7279 dlg.finished(false);
7280
7281 return Err(match error {
7282 Ok(value) => common::Error::BadRequest(value),
7283 _ => common::Error::Failure(response),
7284 });
7285 }
7286 let response = {
7287 let bytes = common::to_bytes(body).await.unwrap_or_default();
7288 let encoded = common::to_string(&bytes);
7289 match serde_json::from_str(&encoded) {
7290 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7291 Err(error) => {
7292 dlg.response_json_decode_error(&encoded, &error);
7293 return Err(common::Error::JsonDecodeError(
7294 encoded.to_string(),
7295 error,
7296 ));
7297 }
7298 }
7299 };
7300
7301 dlg.finished(true);
7302 return Ok(response);
7303 }
7304 }
7305 }
7306 }
7307
7308 /// Required. The name of the note in the form of `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.
7309 ///
7310 /// Sets the *name* path property to the given value.
7311 ///
7312 /// Even though the property as already been set when instantiating this call,
7313 /// we provide this method for API completeness.
7314 pub fn name(mut self, new_value: &str) -> ProjectNoteDeleteCall<'a, C> {
7315 self._name = new_value.to_string();
7316 self
7317 }
7318 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7319 /// while executing the actual API request.
7320 ///
7321 /// ````text
7322 /// It should be used to handle progress information, and to implement a certain level of resilience.
7323 /// ````
7324 ///
7325 /// Sets the *delegate* property to the given value.
7326 pub fn delegate(
7327 mut self,
7328 new_value: &'a mut dyn common::Delegate,
7329 ) -> ProjectNoteDeleteCall<'a, C> {
7330 self._delegate = Some(new_value);
7331 self
7332 }
7333
7334 /// Set any additional parameter of the query string used in the request.
7335 /// It should be used to set parameters which are not yet available through their own
7336 /// setters.
7337 ///
7338 /// Please note that this method must not be used to set any of the known parameters
7339 /// which have their own setter method. If done anyway, the request will fail.
7340 ///
7341 /// # Additional Parameters
7342 ///
7343 /// * *$.xgafv* (query-string) - V1 error format.
7344 /// * *access_token* (query-string) - OAuth access token.
7345 /// * *alt* (query-string) - Data format for response.
7346 /// * *callback* (query-string) - JSONP
7347 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7348 /// * *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.
7349 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7350 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7351 /// * *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.
7352 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7353 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7354 pub fn param<T>(mut self, name: T, value: T) -> ProjectNoteDeleteCall<'a, C>
7355 where
7356 T: AsRef<str>,
7357 {
7358 self._additional_params
7359 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7360 self
7361 }
7362
7363 /// Identifies the authorization scope for the method you are building.
7364 ///
7365 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7366 /// [`Scope::CloudPlatform`].
7367 ///
7368 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7369 /// tokens for more than one scope.
7370 ///
7371 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7372 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7373 /// sufficient, a read-write scope will do as well.
7374 pub fn add_scope<St>(mut self, scope: St) -> ProjectNoteDeleteCall<'a, C>
7375 where
7376 St: AsRef<str>,
7377 {
7378 self._scopes.insert(String::from(scope.as_ref()));
7379 self
7380 }
7381 /// Identifies the authorization scope(s) for the method you are building.
7382 ///
7383 /// See [`Self::add_scope()`] for details.
7384 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectNoteDeleteCall<'a, C>
7385 where
7386 I: IntoIterator<Item = St>,
7387 St: AsRef<str>,
7388 {
7389 self._scopes
7390 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7391 self
7392 }
7393
7394 /// Removes all scopes, and no default scope will be used either.
7395 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7396 /// for details).
7397 pub fn clear_scopes(mut self) -> ProjectNoteDeleteCall<'a, C> {
7398 self._scopes.clear();
7399 self
7400 }
7401}
7402
7403/// Gets the specified note.
7404///
7405/// A builder for the *notes.get* method supported by a *project* resource.
7406/// It is not used directly, but through a [`ProjectMethods`] instance.
7407///
7408/// # Example
7409///
7410/// Instantiate a resource method builder
7411///
7412/// ```test_harness,no_run
7413/// # extern crate hyper;
7414/// # extern crate hyper_rustls;
7415/// # extern crate google_containeranalysis1 as containeranalysis1;
7416/// # async fn dox() {
7417/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7418///
7419/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7420/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7421/// # secret,
7422/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7423/// # ).build().await.unwrap();
7424///
7425/// # let client = hyper_util::client::legacy::Client::builder(
7426/// # hyper_util::rt::TokioExecutor::new()
7427/// # )
7428/// # .build(
7429/// # hyper_rustls::HttpsConnectorBuilder::new()
7430/// # .with_native_roots()
7431/// # .unwrap()
7432/// # .https_or_http()
7433/// # .enable_http1()
7434/// # .build()
7435/// # );
7436/// # let mut hub = ContainerAnalysis::new(client, auth);
7437/// // You can configure optional parameters by calling the respective setters at will, and
7438/// // execute the final call using `doit()`.
7439/// // Values shown here are possibly random and not representative !
7440/// let result = hub.projects().notes_get("name")
7441/// .doit().await;
7442/// # }
7443/// ```
7444pub struct ProjectNoteGetCall<'a, C>
7445where
7446 C: 'a,
7447{
7448 hub: &'a ContainerAnalysis<C>,
7449 _name: String,
7450 _delegate: Option<&'a mut dyn common::Delegate>,
7451 _additional_params: HashMap<String, String>,
7452 _scopes: BTreeSet<String>,
7453}
7454
7455impl<'a, C> common::CallBuilder for ProjectNoteGetCall<'a, C> {}
7456
7457impl<'a, C> ProjectNoteGetCall<'a, C>
7458where
7459 C: common::Connector,
7460{
7461 /// Perform the operation you have build so far.
7462 pub async fn doit(mut self) -> common::Result<(common::Response, Note)> {
7463 use std::borrow::Cow;
7464 use std::io::{Read, Seek};
7465
7466 use common::{url::Params, ToParts};
7467 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7468
7469 let mut dd = common::DefaultDelegate;
7470 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7471 dlg.begin(common::MethodInfo {
7472 id: "containeranalysis.projects.notes.get",
7473 http_method: hyper::Method::GET,
7474 });
7475
7476 for &field in ["alt", "name"].iter() {
7477 if self._additional_params.contains_key(field) {
7478 dlg.finished(false);
7479 return Err(common::Error::FieldClash(field));
7480 }
7481 }
7482
7483 let mut params = Params::with_capacity(3 + self._additional_params.len());
7484 params.push("name", self._name);
7485
7486 params.extend(self._additional_params.iter());
7487
7488 params.push("alt", "json");
7489 let mut url = self.hub._base_url.clone() + "v1/{+name}";
7490 if self._scopes.is_empty() {
7491 self._scopes
7492 .insert(Scope::CloudPlatform.as_ref().to_string());
7493 }
7494
7495 #[allow(clippy::single_element_loop)]
7496 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7497 url = params.uri_replacement(url, param_name, find_this, true);
7498 }
7499 {
7500 let to_remove = ["name"];
7501 params.remove_params(&to_remove);
7502 }
7503
7504 let url = params.parse_with_url(&url);
7505
7506 loop {
7507 let token = match self
7508 .hub
7509 .auth
7510 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7511 .await
7512 {
7513 Ok(token) => token,
7514 Err(e) => match dlg.token(e) {
7515 Ok(token) => token,
7516 Err(e) => {
7517 dlg.finished(false);
7518 return Err(common::Error::MissingToken(e));
7519 }
7520 },
7521 };
7522 let mut req_result = {
7523 let client = &self.hub.client;
7524 dlg.pre_request();
7525 let mut req_builder = hyper::Request::builder()
7526 .method(hyper::Method::GET)
7527 .uri(url.as_str())
7528 .header(USER_AGENT, self.hub._user_agent.clone());
7529
7530 if let Some(token) = token.as_ref() {
7531 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7532 }
7533
7534 let request = req_builder
7535 .header(CONTENT_LENGTH, 0_u64)
7536 .body(common::to_body::<String>(None));
7537
7538 client.request(request.unwrap()).await
7539 };
7540
7541 match req_result {
7542 Err(err) => {
7543 if let common::Retry::After(d) = dlg.http_error(&err) {
7544 sleep(d).await;
7545 continue;
7546 }
7547 dlg.finished(false);
7548 return Err(common::Error::HttpError(err));
7549 }
7550 Ok(res) => {
7551 let (mut parts, body) = res.into_parts();
7552 let mut body = common::Body::new(body);
7553 if !parts.status.is_success() {
7554 let bytes = common::to_bytes(body).await.unwrap_or_default();
7555 let error = serde_json::from_str(&common::to_string(&bytes));
7556 let response = common::to_response(parts, bytes.into());
7557
7558 if let common::Retry::After(d) =
7559 dlg.http_failure(&response, error.as_ref().ok())
7560 {
7561 sleep(d).await;
7562 continue;
7563 }
7564
7565 dlg.finished(false);
7566
7567 return Err(match error {
7568 Ok(value) => common::Error::BadRequest(value),
7569 _ => common::Error::Failure(response),
7570 });
7571 }
7572 let response = {
7573 let bytes = common::to_bytes(body).await.unwrap_or_default();
7574 let encoded = common::to_string(&bytes);
7575 match serde_json::from_str(&encoded) {
7576 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7577 Err(error) => {
7578 dlg.response_json_decode_error(&encoded, &error);
7579 return Err(common::Error::JsonDecodeError(
7580 encoded.to_string(),
7581 error,
7582 ));
7583 }
7584 }
7585 };
7586
7587 dlg.finished(true);
7588 return Ok(response);
7589 }
7590 }
7591 }
7592 }
7593
7594 /// Required. The name of the note in the form of `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.
7595 ///
7596 /// Sets the *name* path property to the given value.
7597 ///
7598 /// Even though the property as already been set when instantiating this call,
7599 /// we provide this method for API completeness.
7600 pub fn name(mut self, new_value: &str) -> ProjectNoteGetCall<'a, C> {
7601 self._name = new_value.to_string();
7602 self
7603 }
7604 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7605 /// while executing the actual API request.
7606 ///
7607 /// ````text
7608 /// It should be used to handle progress information, and to implement a certain level of resilience.
7609 /// ````
7610 ///
7611 /// Sets the *delegate* property to the given value.
7612 pub fn delegate(
7613 mut self,
7614 new_value: &'a mut dyn common::Delegate,
7615 ) -> ProjectNoteGetCall<'a, C> {
7616 self._delegate = Some(new_value);
7617 self
7618 }
7619
7620 /// Set any additional parameter of the query string used in the request.
7621 /// It should be used to set parameters which are not yet available through their own
7622 /// setters.
7623 ///
7624 /// Please note that this method must not be used to set any of the known parameters
7625 /// which have their own setter method. If done anyway, the request will fail.
7626 ///
7627 /// # Additional Parameters
7628 ///
7629 /// * *$.xgafv* (query-string) - V1 error format.
7630 /// * *access_token* (query-string) - OAuth access token.
7631 /// * *alt* (query-string) - Data format for response.
7632 /// * *callback* (query-string) - JSONP
7633 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7634 /// * *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.
7635 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7636 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7637 /// * *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.
7638 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7639 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7640 pub fn param<T>(mut self, name: T, value: T) -> ProjectNoteGetCall<'a, C>
7641 where
7642 T: AsRef<str>,
7643 {
7644 self._additional_params
7645 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7646 self
7647 }
7648
7649 /// Identifies the authorization scope for the method you are building.
7650 ///
7651 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7652 /// [`Scope::CloudPlatform`].
7653 ///
7654 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7655 /// tokens for more than one scope.
7656 ///
7657 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7658 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7659 /// sufficient, a read-write scope will do as well.
7660 pub fn add_scope<St>(mut self, scope: St) -> ProjectNoteGetCall<'a, C>
7661 where
7662 St: AsRef<str>,
7663 {
7664 self._scopes.insert(String::from(scope.as_ref()));
7665 self
7666 }
7667 /// Identifies the authorization scope(s) for the method you are building.
7668 ///
7669 /// See [`Self::add_scope()`] for details.
7670 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectNoteGetCall<'a, C>
7671 where
7672 I: IntoIterator<Item = St>,
7673 St: AsRef<str>,
7674 {
7675 self._scopes
7676 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7677 self
7678 }
7679
7680 /// Removes all scopes, and no default scope will be used either.
7681 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7682 /// for details).
7683 pub fn clear_scopes(mut self) -> ProjectNoteGetCall<'a, C> {
7684 self._scopes.clear();
7685 self
7686 }
7687}
7688
7689/// Gets the access control policy for a note or an occurrence resource. Requires `containeranalysis.notes.setIamPolicy` or `containeranalysis.occurrences.setIamPolicy` permission if the resource is a note or occurrence, respectively. The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
7690///
7691/// A builder for the *notes.getIamPolicy* method supported by a *project* resource.
7692/// It is not used directly, but through a [`ProjectMethods`] instance.
7693///
7694/// # Example
7695///
7696/// Instantiate a resource method builder
7697///
7698/// ```test_harness,no_run
7699/// # extern crate hyper;
7700/// # extern crate hyper_rustls;
7701/// # extern crate google_containeranalysis1 as containeranalysis1;
7702/// use containeranalysis1::api::GetIamPolicyRequest;
7703/// # async fn dox() {
7704/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7705///
7706/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7707/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
7708/// # secret,
7709/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7710/// # ).build().await.unwrap();
7711///
7712/// # let client = hyper_util::client::legacy::Client::builder(
7713/// # hyper_util::rt::TokioExecutor::new()
7714/// # )
7715/// # .build(
7716/// # hyper_rustls::HttpsConnectorBuilder::new()
7717/// # .with_native_roots()
7718/// # .unwrap()
7719/// # .https_or_http()
7720/// # .enable_http1()
7721/// # .build()
7722/// # );
7723/// # let mut hub = ContainerAnalysis::new(client, auth);
7724/// // As the method needs a request, you would usually fill it with the desired information
7725/// // into the respective structure. Some of the parts shown here might not be applicable !
7726/// // Values shown here are possibly random and not representative !
7727/// let mut req = GetIamPolicyRequest::default();
7728///
7729/// // You can configure optional parameters by calling the respective setters at will, and
7730/// // execute the final call using `doit()`.
7731/// // Values shown here are possibly random and not representative !
7732/// let result = hub.projects().notes_get_iam_policy(req, "resource")
7733/// .doit().await;
7734/// # }
7735/// ```
7736pub struct ProjectNoteGetIamPolicyCall<'a, C>
7737where
7738 C: 'a,
7739{
7740 hub: &'a ContainerAnalysis<C>,
7741 _request: GetIamPolicyRequest,
7742 _resource: String,
7743 _delegate: Option<&'a mut dyn common::Delegate>,
7744 _additional_params: HashMap<String, String>,
7745 _scopes: BTreeSet<String>,
7746}
7747
7748impl<'a, C> common::CallBuilder for ProjectNoteGetIamPolicyCall<'a, C> {}
7749
7750impl<'a, C> ProjectNoteGetIamPolicyCall<'a, C>
7751where
7752 C: common::Connector,
7753{
7754 /// Perform the operation you have build so far.
7755 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
7756 use std::borrow::Cow;
7757 use std::io::{Read, Seek};
7758
7759 use common::{url::Params, ToParts};
7760 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7761
7762 let mut dd = common::DefaultDelegate;
7763 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7764 dlg.begin(common::MethodInfo {
7765 id: "containeranalysis.projects.notes.getIamPolicy",
7766 http_method: hyper::Method::POST,
7767 });
7768
7769 for &field in ["alt", "resource"].iter() {
7770 if self._additional_params.contains_key(field) {
7771 dlg.finished(false);
7772 return Err(common::Error::FieldClash(field));
7773 }
7774 }
7775
7776 let mut params = Params::with_capacity(4 + self._additional_params.len());
7777 params.push("resource", self._resource);
7778
7779 params.extend(self._additional_params.iter());
7780
7781 params.push("alt", "json");
7782 let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
7783 if self._scopes.is_empty() {
7784 self._scopes
7785 .insert(Scope::CloudPlatform.as_ref().to_string());
7786 }
7787
7788 #[allow(clippy::single_element_loop)]
7789 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
7790 url = params.uri_replacement(url, param_name, find_this, true);
7791 }
7792 {
7793 let to_remove = ["resource"];
7794 params.remove_params(&to_remove);
7795 }
7796
7797 let url = params.parse_with_url(&url);
7798
7799 let mut json_mime_type = mime::APPLICATION_JSON;
7800 let mut request_value_reader = {
7801 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7802 common::remove_json_null_values(&mut value);
7803 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7804 serde_json::to_writer(&mut dst, &value).unwrap();
7805 dst
7806 };
7807 let request_size = request_value_reader
7808 .seek(std::io::SeekFrom::End(0))
7809 .unwrap();
7810 request_value_reader
7811 .seek(std::io::SeekFrom::Start(0))
7812 .unwrap();
7813
7814 loop {
7815 let token = match self
7816 .hub
7817 .auth
7818 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7819 .await
7820 {
7821 Ok(token) => token,
7822 Err(e) => match dlg.token(e) {
7823 Ok(token) => token,
7824 Err(e) => {
7825 dlg.finished(false);
7826 return Err(common::Error::MissingToken(e));
7827 }
7828 },
7829 };
7830 request_value_reader
7831 .seek(std::io::SeekFrom::Start(0))
7832 .unwrap();
7833 let mut req_result = {
7834 let client = &self.hub.client;
7835 dlg.pre_request();
7836 let mut req_builder = hyper::Request::builder()
7837 .method(hyper::Method::POST)
7838 .uri(url.as_str())
7839 .header(USER_AGENT, self.hub._user_agent.clone());
7840
7841 if let Some(token) = token.as_ref() {
7842 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7843 }
7844
7845 let request = req_builder
7846 .header(CONTENT_TYPE, json_mime_type.to_string())
7847 .header(CONTENT_LENGTH, request_size as u64)
7848 .body(common::to_body(
7849 request_value_reader.get_ref().clone().into(),
7850 ));
7851
7852 client.request(request.unwrap()).await
7853 };
7854
7855 match req_result {
7856 Err(err) => {
7857 if let common::Retry::After(d) = dlg.http_error(&err) {
7858 sleep(d).await;
7859 continue;
7860 }
7861 dlg.finished(false);
7862 return Err(common::Error::HttpError(err));
7863 }
7864 Ok(res) => {
7865 let (mut parts, body) = res.into_parts();
7866 let mut body = common::Body::new(body);
7867 if !parts.status.is_success() {
7868 let bytes = common::to_bytes(body).await.unwrap_or_default();
7869 let error = serde_json::from_str(&common::to_string(&bytes));
7870 let response = common::to_response(parts, bytes.into());
7871
7872 if let common::Retry::After(d) =
7873 dlg.http_failure(&response, error.as_ref().ok())
7874 {
7875 sleep(d).await;
7876 continue;
7877 }
7878
7879 dlg.finished(false);
7880
7881 return Err(match error {
7882 Ok(value) => common::Error::BadRequest(value),
7883 _ => common::Error::Failure(response),
7884 });
7885 }
7886 let response = {
7887 let bytes = common::to_bytes(body).await.unwrap_or_default();
7888 let encoded = common::to_string(&bytes);
7889 match serde_json::from_str(&encoded) {
7890 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7891 Err(error) => {
7892 dlg.response_json_decode_error(&encoded, &error);
7893 return Err(common::Error::JsonDecodeError(
7894 encoded.to_string(),
7895 error,
7896 ));
7897 }
7898 }
7899 };
7900
7901 dlg.finished(true);
7902 return Ok(response);
7903 }
7904 }
7905 }
7906 }
7907
7908 ///
7909 /// Sets the *request* property to the given value.
7910 ///
7911 /// Even though the property as already been set when instantiating this call,
7912 /// we provide this method for API completeness.
7913 pub fn request(mut self, new_value: GetIamPolicyRequest) -> ProjectNoteGetIamPolicyCall<'a, C> {
7914 self._request = new_value;
7915 self
7916 }
7917 /// REQUIRED: The resource for which the policy is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
7918 ///
7919 /// Sets the *resource* path property to the given value.
7920 ///
7921 /// Even though the property as already been set when instantiating this call,
7922 /// we provide this method for API completeness.
7923 pub fn resource(mut self, new_value: &str) -> ProjectNoteGetIamPolicyCall<'a, C> {
7924 self._resource = new_value.to_string();
7925 self
7926 }
7927 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7928 /// while executing the actual API request.
7929 ///
7930 /// ````text
7931 /// It should be used to handle progress information, and to implement a certain level of resilience.
7932 /// ````
7933 ///
7934 /// Sets the *delegate* property to the given value.
7935 pub fn delegate(
7936 mut self,
7937 new_value: &'a mut dyn common::Delegate,
7938 ) -> ProjectNoteGetIamPolicyCall<'a, C> {
7939 self._delegate = Some(new_value);
7940 self
7941 }
7942
7943 /// Set any additional parameter of the query string used in the request.
7944 /// It should be used to set parameters which are not yet available through their own
7945 /// setters.
7946 ///
7947 /// Please note that this method must not be used to set any of the known parameters
7948 /// which have their own setter method. If done anyway, the request will fail.
7949 ///
7950 /// # Additional Parameters
7951 ///
7952 /// * *$.xgafv* (query-string) - V1 error format.
7953 /// * *access_token* (query-string) - OAuth access token.
7954 /// * *alt* (query-string) - Data format for response.
7955 /// * *callback* (query-string) - JSONP
7956 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7957 /// * *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.
7958 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7959 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7960 /// * *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.
7961 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7962 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7963 pub fn param<T>(mut self, name: T, value: T) -> ProjectNoteGetIamPolicyCall<'a, C>
7964 where
7965 T: AsRef<str>,
7966 {
7967 self._additional_params
7968 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7969 self
7970 }
7971
7972 /// Identifies the authorization scope for the method you are building.
7973 ///
7974 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7975 /// [`Scope::CloudPlatform`].
7976 ///
7977 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7978 /// tokens for more than one scope.
7979 ///
7980 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7981 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7982 /// sufficient, a read-write scope will do as well.
7983 pub fn add_scope<St>(mut self, scope: St) -> ProjectNoteGetIamPolicyCall<'a, C>
7984 where
7985 St: AsRef<str>,
7986 {
7987 self._scopes.insert(String::from(scope.as_ref()));
7988 self
7989 }
7990 /// Identifies the authorization scope(s) for the method you are building.
7991 ///
7992 /// See [`Self::add_scope()`] for details.
7993 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectNoteGetIamPolicyCall<'a, C>
7994 where
7995 I: IntoIterator<Item = St>,
7996 St: AsRef<str>,
7997 {
7998 self._scopes
7999 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8000 self
8001 }
8002
8003 /// Removes all scopes, and no default scope will be used either.
8004 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8005 /// for details).
8006 pub fn clear_scopes(mut self) -> ProjectNoteGetIamPolicyCall<'a, C> {
8007 self._scopes.clear();
8008 self
8009 }
8010}
8011
8012/// Lists notes for the specified project.
8013///
8014/// A builder for the *notes.list* method supported by a *project* resource.
8015/// It is not used directly, but through a [`ProjectMethods`] instance.
8016///
8017/// # Example
8018///
8019/// Instantiate a resource method builder
8020///
8021/// ```test_harness,no_run
8022/// # extern crate hyper;
8023/// # extern crate hyper_rustls;
8024/// # extern crate google_containeranalysis1 as containeranalysis1;
8025/// # async fn dox() {
8026/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8027///
8028/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8029/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8030/// # secret,
8031/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8032/// # ).build().await.unwrap();
8033///
8034/// # let client = hyper_util::client::legacy::Client::builder(
8035/// # hyper_util::rt::TokioExecutor::new()
8036/// # )
8037/// # .build(
8038/// # hyper_rustls::HttpsConnectorBuilder::new()
8039/// # .with_native_roots()
8040/// # .unwrap()
8041/// # .https_or_http()
8042/// # .enable_http1()
8043/// # .build()
8044/// # );
8045/// # let mut hub = ContainerAnalysis::new(client, auth);
8046/// // You can configure optional parameters by calling the respective setters at will, and
8047/// // execute the final call using `doit()`.
8048/// // Values shown here are possibly random and not representative !
8049/// let result = hub.projects().notes_list("parent")
8050/// .page_token("Lorem")
8051/// .page_size(-25)
8052/// .filter("labore")
8053/// .doit().await;
8054/// # }
8055/// ```
8056pub struct ProjectNoteListCall<'a, C>
8057where
8058 C: 'a,
8059{
8060 hub: &'a ContainerAnalysis<C>,
8061 _parent: String,
8062 _page_token: Option<String>,
8063 _page_size: Option<i32>,
8064 _filter: Option<String>,
8065 _delegate: Option<&'a mut dyn common::Delegate>,
8066 _additional_params: HashMap<String, String>,
8067 _scopes: BTreeSet<String>,
8068}
8069
8070impl<'a, C> common::CallBuilder for ProjectNoteListCall<'a, C> {}
8071
8072impl<'a, C> ProjectNoteListCall<'a, C>
8073where
8074 C: common::Connector,
8075{
8076 /// Perform the operation you have build so far.
8077 pub async fn doit(mut self) -> common::Result<(common::Response, ListNotesResponse)> {
8078 use std::borrow::Cow;
8079 use std::io::{Read, Seek};
8080
8081 use common::{url::Params, ToParts};
8082 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8083
8084 let mut dd = common::DefaultDelegate;
8085 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8086 dlg.begin(common::MethodInfo {
8087 id: "containeranalysis.projects.notes.list",
8088 http_method: hyper::Method::GET,
8089 });
8090
8091 for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
8092 if self._additional_params.contains_key(field) {
8093 dlg.finished(false);
8094 return Err(common::Error::FieldClash(field));
8095 }
8096 }
8097
8098 let mut params = Params::with_capacity(6 + self._additional_params.len());
8099 params.push("parent", self._parent);
8100 if let Some(value) = self._page_token.as_ref() {
8101 params.push("pageToken", value);
8102 }
8103 if let Some(value) = self._page_size.as_ref() {
8104 params.push("pageSize", value.to_string());
8105 }
8106 if let Some(value) = self._filter.as_ref() {
8107 params.push("filter", value);
8108 }
8109
8110 params.extend(self._additional_params.iter());
8111
8112 params.push("alt", "json");
8113 let mut url = self.hub._base_url.clone() + "v1/{+parent}/notes";
8114 if self._scopes.is_empty() {
8115 self._scopes
8116 .insert(Scope::CloudPlatform.as_ref().to_string());
8117 }
8118
8119 #[allow(clippy::single_element_loop)]
8120 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
8121 url = params.uri_replacement(url, param_name, find_this, true);
8122 }
8123 {
8124 let to_remove = ["parent"];
8125 params.remove_params(&to_remove);
8126 }
8127
8128 let url = params.parse_with_url(&url);
8129
8130 loop {
8131 let token = match self
8132 .hub
8133 .auth
8134 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8135 .await
8136 {
8137 Ok(token) => token,
8138 Err(e) => match dlg.token(e) {
8139 Ok(token) => token,
8140 Err(e) => {
8141 dlg.finished(false);
8142 return Err(common::Error::MissingToken(e));
8143 }
8144 },
8145 };
8146 let mut req_result = {
8147 let client = &self.hub.client;
8148 dlg.pre_request();
8149 let mut req_builder = hyper::Request::builder()
8150 .method(hyper::Method::GET)
8151 .uri(url.as_str())
8152 .header(USER_AGENT, self.hub._user_agent.clone());
8153
8154 if let Some(token) = token.as_ref() {
8155 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8156 }
8157
8158 let request = req_builder
8159 .header(CONTENT_LENGTH, 0_u64)
8160 .body(common::to_body::<String>(None));
8161
8162 client.request(request.unwrap()).await
8163 };
8164
8165 match req_result {
8166 Err(err) => {
8167 if let common::Retry::After(d) = dlg.http_error(&err) {
8168 sleep(d).await;
8169 continue;
8170 }
8171 dlg.finished(false);
8172 return Err(common::Error::HttpError(err));
8173 }
8174 Ok(res) => {
8175 let (mut parts, body) = res.into_parts();
8176 let mut body = common::Body::new(body);
8177 if !parts.status.is_success() {
8178 let bytes = common::to_bytes(body).await.unwrap_or_default();
8179 let error = serde_json::from_str(&common::to_string(&bytes));
8180 let response = common::to_response(parts, bytes.into());
8181
8182 if let common::Retry::After(d) =
8183 dlg.http_failure(&response, error.as_ref().ok())
8184 {
8185 sleep(d).await;
8186 continue;
8187 }
8188
8189 dlg.finished(false);
8190
8191 return Err(match error {
8192 Ok(value) => common::Error::BadRequest(value),
8193 _ => common::Error::Failure(response),
8194 });
8195 }
8196 let response = {
8197 let bytes = common::to_bytes(body).await.unwrap_or_default();
8198 let encoded = common::to_string(&bytes);
8199 match serde_json::from_str(&encoded) {
8200 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8201 Err(error) => {
8202 dlg.response_json_decode_error(&encoded, &error);
8203 return Err(common::Error::JsonDecodeError(
8204 encoded.to_string(),
8205 error,
8206 ));
8207 }
8208 }
8209 };
8210
8211 dlg.finished(true);
8212 return Ok(response);
8213 }
8214 }
8215 }
8216 }
8217
8218 /// Required. The name of the project to list notes for in the form of `projects/[PROJECT_ID]`.
8219 ///
8220 /// Sets the *parent* path property to the given value.
8221 ///
8222 /// Even though the property as already been set when instantiating this call,
8223 /// we provide this method for API completeness.
8224 pub fn parent(mut self, new_value: &str) -> ProjectNoteListCall<'a, C> {
8225 self._parent = new_value.to_string();
8226 self
8227 }
8228 /// Token to provide to skip to a particular spot in the list.
8229 ///
8230 /// Sets the *page token* query property to the given value.
8231 pub fn page_token(mut self, new_value: &str) -> ProjectNoteListCall<'a, C> {
8232 self._page_token = Some(new_value.to_string());
8233 self
8234 }
8235 /// Number of notes to return in the list. Must be positive. Max allowed page size is 1000. If not specified, page size defaults to 20.
8236 ///
8237 /// Sets the *page size* query property to the given value.
8238 pub fn page_size(mut self, new_value: i32) -> ProjectNoteListCall<'a, C> {
8239 self._page_size = Some(new_value);
8240 self
8241 }
8242 /// The filter expression.
8243 ///
8244 /// Sets the *filter* query property to the given value.
8245 pub fn filter(mut self, new_value: &str) -> ProjectNoteListCall<'a, C> {
8246 self._filter = Some(new_value.to_string());
8247 self
8248 }
8249 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8250 /// while executing the actual API request.
8251 ///
8252 /// ````text
8253 /// It should be used to handle progress information, and to implement a certain level of resilience.
8254 /// ````
8255 ///
8256 /// Sets the *delegate* property to the given value.
8257 pub fn delegate(
8258 mut self,
8259 new_value: &'a mut dyn common::Delegate,
8260 ) -> ProjectNoteListCall<'a, C> {
8261 self._delegate = Some(new_value);
8262 self
8263 }
8264
8265 /// Set any additional parameter of the query string used in the request.
8266 /// It should be used to set parameters which are not yet available through their own
8267 /// setters.
8268 ///
8269 /// Please note that this method must not be used to set any of the known parameters
8270 /// which have their own setter method. If done anyway, the request will fail.
8271 ///
8272 /// # Additional Parameters
8273 ///
8274 /// * *$.xgafv* (query-string) - V1 error format.
8275 /// * *access_token* (query-string) - OAuth access token.
8276 /// * *alt* (query-string) - Data format for response.
8277 /// * *callback* (query-string) - JSONP
8278 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8279 /// * *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.
8280 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8281 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8282 /// * *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.
8283 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8284 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8285 pub fn param<T>(mut self, name: T, value: T) -> ProjectNoteListCall<'a, C>
8286 where
8287 T: AsRef<str>,
8288 {
8289 self._additional_params
8290 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8291 self
8292 }
8293
8294 /// Identifies the authorization scope for the method you are building.
8295 ///
8296 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8297 /// [`Scope::CloudPlatform`].
8298 ///
8299 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8300 /// tokens for more than one scope.
8301 ///
8302 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8303 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8304 /// sufficient, a read-write scope will do as well.
8305 pub fn add_scope<St>(mut self, scope: St) -> ProjectNoteListCall<'a, C>
8306 where
8307 St: AsRef<str>,
8308 {
8309 self._scopes.insert(String::from(scope.as_ref()));
8310 self
8311 }
8312 /// Identifies the authorization scope(s) for the method you are building.
8313 ///
8314 /// See [`Self::add_scope()`] for details.
8315 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectNoteListCall<'a, C>
8316 where
8317 I: IntoIterator<Item = St>,
8318 St: AsRef<str>,
8319 {
8320 self._scopes
8321 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8322 self
8323 }
8324
8325 /// Removes all scopes, and no default scope will be used either.
8326 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8327 /// for details).
8328 pub fn clear_scopes(mut self) -> ProjectNoteListCall<'a, C> {
8329 self._scopes.clear();
8330 self
8331 }
8332}
8333
8334/// Updates the specified note.
8335///
8336/// A builder for the *notes.patch* method supported by a *project* resource.
8337/// It is not used directly, but through a [`ProjectMethods`] instance.
8338///
8339/// # Example
8340///
8341/// Instantiate a resource method builder
8342///
8343/// ```test_harness,no_run
8344/// # extern crate hyper;
8345/// # extern crate hyper_rustls;
8346/// # extern crate google_containeranalysis1 as containeranalysis1;
8347/// use containeranalysis1::api::Note;
8348/// # async fn dox() {
8349/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8350///
8351/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8352/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8353/// # secret,
8354/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8355/// # ).build().await.unwrap();
8356///
8357/// # let client = hyper_util::client::legacy::Client::builder(
8358/// # hyper_util::rt::TokioExecutor::new()
8359/// # )
8360/// # .build(
8361/// # hyper_rustls::HttpsConnectorBuilder::new()
8362/// # .with_native_roots()
8363/// # .unwrap()
8364/// # .https_or_http()
8365/// # .enable_http1()
8366/// # .build()
8367/// # );
8368/// # let mut hub = ContainerAnalysis::new(client, auth);
8369/// // As the method needs a request, you would usually fill it with the desired information
8370/// // into the respective structure. Some of the parts shown here might not be applicable !
8371/// // Values shown here are possibly random and not representative !
8372/// let mut req = Note::default();
8373///
8374/// // You can configure optional parameters by calling the respective setters at will, and
8375/// // execute the final call using `doit()`.
8376/// // Values shown here are possibly random and not representative !
8377/// let result = hub.projects().notes_patch(req, "name")
8378/// .update_mask(FieldMask::new::<&str>(&[]))
8379/// .doit().await;
8380/// # }
8381/// ```
8382pub struct ProjectNotePatchCall<'a, C>
8383where
8384 C: 'a,
8385{
8386 hub: &'a ContainerAnalysis<C>,
8387 _request: Note,
8388 _name: String,
8389 _update_mask: Option<common::FieldMask>,
8390 _delegate: Option<&'a mut dyn common::Delegate>,
8391 _additional_params: HashMap<String, String>,
8392 _scopes: BTreeSet<String>,
8393}
8394
8395impl<'a, C> common::CallBuilder for ProjectNotePatchCall<'a, C> {}
8396
8397impl<'a, C> ProjectNotePatchCall<'a, C>
8398where
8399 C: common::Connector,
8400{
8401 /// Perform the operation you have build so far.
8402 pub async fn doit(mut self) -> common::Result<(common::Response, Note)> {
8403 use std::borrow::Cow;
8404 use std::io::{Read, Seek};
8405
8406 use common::{url::Params, ToParts};
8407 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8408
8409 let mut dd = common::DefaultDelegate;
8410 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8411 dlg.begin(common::MethodInfo {
8412 id: "containeranalysis.projects.notes.patch",
8413 http_method: hyper::Method::PATCH,
8414 });
8415
8416 for &field in ["alt", "name", "updateMask"].iter() {
8417 if self._additional_params.contains_key(field) {
8418 dlg.finished(false);
8419 return Err(common::Error::FieldClash(field));
8420 }
8421 }
8422
8423 let mut params = Params::with_capacity(5 + self._additional_params.len());
8424 params.push("name", self._name);
8425 if let Some(value) = self._update_mask.as_ref() {
8426 params.push("updateMask", value.to_string());
8427 }
8428
8429 params.extend(self._additional_params.iter());
8430
8431 params.push("alt", "json");
8432 let mut url = self.hub._base_url.clone() + "v1/{+name}";
8433 if self._scopes.is_empty() {
8434 self._scopes
8435 .insert(Scope::CloudPlatform.as_ref().to_string());
8436 }
8437
8438 #[allow(clippy::single_element_loop)]
8439 for &(find_this, param_name) in [("{+name}", "name")].iter() {
8440 url = params.uri_replacement(url, param_name, find_this, true);
8441 }
8442 {
8443 let to_remove = ["name"];
8444 params.remove_params(&to_remove);
8445 }
8446
8447 let url = params.parse_with_url(&url);
8448
8449 let mut json_mime_type = mime::APPLICATION_JSON;
8450 let mut request_value_reader = {
8451 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8452 common::remove_json_null_values(&mut value);
8453 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8454 serde_json::to_writer(&mut dst, &value).unwrap();
8455 dst
8456 };
8457 let request_size = request_value_reader
8458 .seek(std::io::SeekFrom::End(0))
8459 .unwrap();
8460 request_value_reader
8461 .seek(std::io::SeekFrom::Start(0))
8462 .unwrap();
8463
8464 loop {
8465 let token = match self
8466 .hub
8467 .auth
8468 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8469 .await
8470 {
8471 Ok(token) => token,
8472 Err(e) => match dlg.token(e) {
8473 Ok(token) => token,
8474 Err(e) => {
8475 dlg.finished(false);
8476 return Err(common::Error::MissingToken(e));
8477 }
8478 },
8479 };
8480 request_value_reader
8481 .seek(std::io::SeekFrom::Start(0))
8482 .unwrap();
8483 let mut req_result = {
8484 let client = &self.hub.client;
8485 dlg.pre_request();
8486 let mut req_builder = hyper::Request::builder()
8487 .method(hyper::Method::PATCH)
8488 .uri(url.as_str())
8489 .header(USER_AGENT, self.hub._user_agent.clone());
8490
8491 if let Some(token) = token.as_ref() {
8492 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8493 }
8494
8495 let request = req_builder
8496 .header(CONTENT_TYPE, json_mime_type.to_string())
8497 .header(CONTENT_LENGTH, request_size as u64)
8498 .body(common::to_body(
8499 request_value_reader.get_ref().clone().into(),
8500 ));
8501
8502 client.request(request.unwrap()).await
8503 };
8504
8505 match req_result {
8506 Err(err) => {
8507 if let common::Retry::After(d) = dlg.http_error(&err) {
8508 sleep(d).await;
8509 continue;
8510 }
8511 dlg.finished(false);
8512 return Err(common::Error::HttpError(err));
8513 }
8514 Ok(res) => {
8515 let (mut parts, body) = res.into_parts();
8516 let mut body = common::Body::new(body);
8517 if !parts.status.is_success() {
8518 let bytes = common::to_bytes(body).await.unwrap_or_default();
8519 let error = serde_json::from_str(&common::to_string(&bytes));
8520 let response = common::to_response(parts, bytes.into());
8521
8522 if let common::Retry::After(d) =
8523 dlg.http_failure(&response, error.as_ref().ok())
8524 {
8525 sleep(d).await;
8526 continue;
8527 }
8528
8529 dlg.finished(false);
8530
8531 return Err(match error {
8532 Ok(value) => common::Error::BadRequest(value),
8533 _ => common::Error::Failure(response),
8534 });
8535 }
8536 let response = {
8537 let bytes = common::to_bytes(body).await.unwrap_or_default();
8538 let encoded = common::to_string(&bytes);
8539 match serde_json::from_str(&encoded) {
8540 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8541 Err(error) => {
8542 dlg.response_json_decode_error(&encoded, &error);
8543 return Err(common::Error::JsonDecodeError(
8544 encoded.to_string(),
8545 error,
8546 ));
8547 }
8548 }
8549 };
8550
8551 dlg.finished(true);
8552 return Ok(response);
8553 }
8554 }
8555 }
8556 }
8557
8558 ///
8559 /// Sets the *request* property to the given value.
8560 ///
8561 /// Even though the property as already been set when instantiating this call,
8562 /// we provide this method for API completeness.
8563 pub fn request(mut self, new_value: Note) -> ProjectNotePatchCall<'a, C> {
8564 self._request = new_value;
8565 self
8566 }
8567 /// Required. The name of the note in the form of `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.
8568 ///
8569 /// Sets the *name* path property to the given value.
8570 ///
8571 /// Even though the property as already been set when instantiating this call,
8572 /// we provide this method for API completeness.
8573 pub fn name(mut self, new_value: &str) -> ProjectNotePatchCall<'a, C> {
8574 self._name = new_value.to_string();
8575 self
8576 }
8577 /// The fields to update.
8578 ///
8579 /// Sets the *update mask* query property to the given value.
8580 pub fn update_mask(mut self, new_value: common::FieldMask) -> ProjectNotePatchCall<'a, C> {
8581 self._update_mask = Some(new_value);
8582 self
8583 }
8584 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8585 /// while executing the actual API request.
8586 ///
8587 /// ````text
8588 /// It should be used to handle progress information, and to implement a certain level of resilience.
8589 /// ````
8590 ///
8591 /// Sets the *delegate* property to the given value.
8592 pub fn delegate(
8593 mut self,
8594 new_value: &'a mut dyn common::Delegate,
8595 ) -> ProjectNotePatchCall<'a, C> {
8596 self._delegate = Some(new_value);
8597 self
8598 }
8599
8600 /// Set any additional parameter of the query string used in the request.
8601 /// It should be used to set parameters which are not yet available through their own
8602 /// setters.
8603 ///
8604 /// Please note that this method must not be used to set any of the known parameters
8605 /// which have their own setter method. If done anyway, the request will fail.
8606 ///
8607 /// # Additional Parameters
8608 ///
8609 /// * *$.xgafv* (query-string) - V1 error format.
8610 /// * *access_token* (query-string) - OAuth access token.
8611 /// * *alt* (query-string) - Data format for response.
8612 /// * *callback* (query-string) - JSONP
8613 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8614 /// * *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.
8615 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8616 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8617 /// * *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.
8618 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8619 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8620 pub fn param<T>(mut self, name: T, value: T) -> ProjectNotePatchCall<'a, C>
8621 where
8622 T: AsRef<str>,
8623 {
8624 self._additional_params
8625 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8626 self
8627 }
8628
8629 /// Identifies the authorization scope for the method you are building.
8630 ///
8631 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8632 /// [`Scope::CloudPlatform`].
8633 ///
8634 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8635 /// tokens for more than one scope.
8636 ///
8637 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8638 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8639 /// sufficient, a read-write scope will do as well.
8640 pub fn add_scope<St>(mut self, scope: St) -> ProjectNotePatchCall<'a, C>
8641 where
8642 St: AsRef<str>,
8643 {
8644 self._scopes.insert(String::from(scope.as_ref()));
8645 self
8646 }
8647 /// Identifies the authorization scope(s) for the method you are building.
8648 ///
8649 /// See [`Self::add_scope()`] for details.
8650 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectNotePatchCall<'a, C>
8651 where
8652 I: IntoIterator<Item = St>,
8653 St: AsRef<str>,
8654 {
8655 self._scopes
8656 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8657 self
8658 }
8659
8660 /// Removes all scopes, and no default scope will be used either.
8661 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8662 /// for details).
8663 pub fn clear_scopes(mut self) -> ProjectNotePatchCall<'a, C> {
8664 self._scopes.clear();
8665 self
8666 }
8667}
8668
8669/// Sets the access control policy on the specified note or occurrence. Requires `containeranalysis.notes.setIamPolicy` or `containeranalysis.occurrences.setIamPolicy` permission if the resource is a note or an occurrence, respectively. The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
8670///
8671/// A builder for the *notes.setIamPolicy* method supported by a *project* resource.
8672/// It is not used directly, but through a [`ProjectMethods`] instance.
8673///
8674/// # Example
8675///
8676/// Instantiate a resource method builder
8677///
8678/// ```test_harness,no_run
8679/// # extern crate hyper;
8680/// # extern crate hyper_rustls;
8681/// # extern crate google_containeranalysis1 as containeranalysis1;
8682/// use containeranalysis1::api::SetIamPolicyRequest;
8683/// # async fn dox() {
8684/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8685///
8686/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8687/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
8688/// # secret,
8689/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8690/// # ).build().await.unwrap();
8691///
8692/// # let client = hyper_util::client::legacy::Client::builder(
8693/// # hyper_util::rt::TokioExecutor::new()
8694/// # )
8695/// # .build(
8696/// # hyper_rustls::HttpsConnectorBuilder::new()
8697/// # .with_native_roots()
8698/// # .unwrap()
8699/// # .https_or_http()
8700/// # .enable_http1()
8701/// # .build()
8702/// # );
8703/// # let mut hub = ContainerAnalysis::new(client, auth);
8704/// // As the method needs a request, you would usually fill it with the desired information
8705/// // into the respective structure. Some of the parts shown here might not be applicable !
8706/// // Values shown here are possibly random and not representative !
8707/// let mut req = SetIamPolicyRequest::default();
8708///
8709/// // You can configure optional parameters by calling the respective setters at will, and
8710/// // execute the final call using `doit()`.
8711/// // Values shown here are possibly random and not representative !
8712/// let result = hub.projects().notes_set_iam_policy(req, "resource")
8713/// .doit().await;
8714/// # }
8715/// ```
8716pub struct ProjectNoteSetIamPolicyCall<'a, C>
8717where
8718 C: 'a,
8719{
8720 hub: &'a ContainerAnalysis<C>,
8721 _request: SetIamPolicyRequest,
8722 _resource: String,
8723 _delegate: Option<&'a mut dyn common::Delegate>,
8724 _additional_params: HashMap<String, String>,
8725 _scopes: BTreeSet<String>,
8726}
8727
8728impl<'a, C> common::CallBuilder for ProjectNoteSetIamPolicyCall<'a, C> {}
8729
8730impl<'a, C> ProjectNoteSetIamPolicyCall<'a, C>
8731where
8732 C: common::Connector,
8733{
8734 /// Perform the operation you have build so far.
8735 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
8736 use std::borrow::Cow;
8737 use std::io::{Read, Seek};
8738
8739 use common::{url::Params, ToParts};
8740 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8741
8742 let mut dd = common::DefaultDelegate;
8743 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8744 dlg.begin(common::MethodInfo {
8745 id: "containeranalysis.projects.notes.setIamPolicy",
8746 http_method: hyper::Method::POST,
8747 });
8748
8749 for &field in ["alt", "resource"].iter() {
8750 if self._additional_params.contains_key(field) {
8751 dlg.finished(false);
8752 return Err(common::Error::FieldClash(field));
8753 }
8754 }
8755
8756 let mut params = Params::with_capacity(4 + self._additional_params.len());
8757 params.push("resource", self._resource);
8758
8759 params.extend(self._additional_params.iter());
8760
8761 params.push("alt", "json");
8762 let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
8763 if self._scopes.is_empty() {
8764 self._scopes
8765 .insert(Scope::CloudPlatform.as_ref().to_string());
8766 }
8767
8768 #[allow(clippy::single_element_loop)]
8769 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
8770 url = params.uri_replacement(url, param_name, find_this, true);
8771 }
8772 {
8773 let to_remove = ["resource"];
8774 params.remove_params(&to_remove);
8775 }
8776
8777 let url = params.parse_with_url(&url);
8778
8779 let mut json_mime_type = mime::APPLICATION_JSON;
8780 let mut request_value_reader = {
8781 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8782 common::remove_json_null_values(&mut value);
8783 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8784 serde_json::to_writer(&mut dst, &value).unwrap();
8785 dst
8786 };
8787 let request_size = request_value_reader
8788 .seek(std::io::SeekFrom::End(0))
8789 .unwrap();
8790 request_value_reader
8791 .seek(std::io::SeekFrom::Start(0))
8792 .unwrap();
8793
8794 loop {
8795 let token = match self
8796 .hub
8797 .auth
8798 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8799 .await
8800 {
8801 Ok(token) => token,
8802 Err(e) => match dlg.token(e) {
8803 Ok(token) => token,
8804 Err(e) => {
8805 dlg.finished(false);
8806 return Err(common::Error::MissingToken(e));
8807 }
8808 },
8809 };
8810 request_value_reader
8811 .seek(std::io::SeekFrom::Start(0))
8812 .unwrap();
8813 let mut req_result = {
8814 let client = &self.hub.client;
8815 dlg.pre_request();
8816 let mut req_builder = hyper::Request::builder()
8817 .method(hyper::Method::POST)
8818 .uri(url.as_str())
8819 .header(USER_AGENT, self.hub._user_agent.clone());
8820
8821 if let Some(token) = token.as_ref() {
8822 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8823 }
8824
8825 let request = req_builder
8826 .header(CONTENT_TYPE, json_mime_type.to_string())
8827 .header(CONTENT_LENGTH, request_size as u64)
8828 .body(common::to_body(
8829 request_value_reader.get_ref().clone().into(),
8830 ));
8831
8832 client.request(request.unwrap()).await
8833 };
8834
8835 match req_result {
8836 Err(err) => {
8837 if let common::Retry::After(d) = dlg.http_error(&err) {
8838 sleep(d).await;
8839 continue;
8840 }
8841 dlg.finished(false);
8842 return Err(common::Error::HttpError(err));
8843 }
8844 Ok(res) => {
8845 let (mut parts, body) = res.into_parts();
8846 let mut body = common::Body::new(body);
8847 if !parts.status.is_success() {
8848 let bytes = common::to_bytes(body).await.unwrap_or_default();
8849 let error = serde_json::from_str(&common::to_string(&bytes));
8850 let response = common::to_response(parts, bytes.into());
8851
8852 if let common::Retry::After(d) =
8853 dlg.http_failure(&response, error.as_ref().ok())
8854 {
8855 sleep(d).await;
8856 continue;
8857 }
8858
8859 dlg.finished(false);
8860
8861 return Err(match error {
8862 Ok(value) => common::Error::BadRequest(value),
8863 _ => common::Error::Failure(response),
8864 });
8865 }
8866 let response = {
8867 let bytes = common::to_bytes(body).await.unwrap_or_default();
8868 let encoded = common::to_string(&bytes);
8869 match serde_json::from_str(&encoded) {
8870 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8871 Err(error) => {
8872 dlg.response_json_decode_error(&encoded, &error);
8873 return Err(common::Error::JsonDecodeError(
8874 encoded.to_string(),
8875 error,
8876 ));
8877 }
8878 }
8879 };
8880
8881 dlg.finished(true);
8882 return Ok(response);
8883 }
8884 }
8885 }
8886 }
8887
8888 ///
8889 /// Sets the *request* property to the given value.
8890 ///
8891 /// Even though the property as already been set when instantiating this call,
8892 /// we provide this method for API completeness.
8893 pub fn request(mut self, new_value: SetIamPolicyRequest) -> ProjectNoteSetIamPolicyCall<'a, C> {
8894 self._request = new_value;
8895 self
8896 }
8897 /// REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
8898 ///
8899 /// Sets the *resource* path property to the given value.
8900 ///
8901 /// Even though the property as already been set when instantiating this call,
8902 /// we provide this method for API completeness.
8903 pub fn resource(mut self, new_value: &str) -> ProjectNoteSetIamPolicyCall<'a, C> {
8904 self._resource = new_value.to_string();
8905 self
8906 }
8907 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8908 /// while executing the actual API request.
8909 ///
8910 /// ````text
8911 /// It should be used to handle progress information, and to implement a certain level of resilience.
8912 /// ````
8913 ///
8914 /// Sets the *delegate* property to the given value.
8915 pub fn delegate(
8916 mut self,
8917 new_value: &'a mut dyn common::Delegate,
8918 ) -> ProjectNoteSetIamPolicyCall<'a, C> {
8919 self._delegate = Some(new_value);
8920 self
8921 }
8922
8923 /// Set any additional parameter of the query string used in the request.
8924 /// It should be used to set parameters which are not yet available through their own
8925 /// setters.
8926 ///
8927 /// Please note that this method must not be used to set any of the known parameters
8928 /// which have their own setter method. If done anyway, the request will fail.
8929 ///
8930 /// # Additional Parameters
8931 ///
8932 /// * *$.xgafv* (query-string) - V1 error format.
8933 /// * *access_token* (query-string) - OAuth access token.
8934 /// * *alt* (query-string) - Data format for response.
8935 /// * *callback* (query-string) - JSONP
8936 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8937 /// * *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.
8938 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8939 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8940 /// * *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.
8941 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8942 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8943 pub fn param<T>(mut self, name: T, value: T) -> ProjectNoteSetIamPolicyCall<'a, C>
8944 where
8945 T: AsRef<str>,
8946 {
8947 self._additional_params
8948 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8949 self
8950 }
8951
8952 /// Identifies the authorization scope for the method you are building.
8953 ///
8954 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8955 /// [`Scope::CloudPlatform`].
8956 ///
8957 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8958 /// tokens for more than one scope.
8959 ///
8960 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8961 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8962 /// sufficient, a read-write scope will do as well.
8963 pub fn add_scope<St>(mut self, scope: St) -> ProjectNoteSetIamPolicyCall<'a, C>
8964 where
8965 St: AsRef<str>,
8966 {
8967 self._scopes.insert(String::from(scope.as_ref()));
8968 self
8969 }
8970 /// Identifies the authorization scope(s) for the method you are building.
8971 ///
8972 /// See [`Self::add_scope()`] for details.
8973 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectNoteSetIamPolicyCall<'a, C>
8974 where
8975 I: IntoIterator<Item = St>,
8976 St: AsRef<str>,
8977 {
8978 self._scopes
8979 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8980 self
8981 }
8982
8983 /// Removes all scopes, and no default scope will be used either.
8984 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8985 /// for details).
8986 pub fn clear_scopes(mut self) -> ProjectNoteSetIamPolicyCall<'a, C> {
8987 self._scopes.clear();
8988 self
8989 }
8990}
8991
8992/// Returns the permissions that a caller has on the specified note or occurrence. Requires list permission on the project (for example, `containeranalysis.notes.list`). The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
8993///
8994/// A builder for the *notes.testIamPermissions* method supported by a *project* resource.
8995/// It is not used directly, but through a [`ProjectMethods`] instance.
8996///
8997/// # Example
8998///
8999/// Instantiate a resource method builder
9000///
9001/// ```test_harness,no_run
9002/// # extern crate hyper;
9003/// # extern crate hyper_rustls;
9004/// # extern crate google_containeranalysis1 as containeranalysis1;
9005/// use containeranalysis1::api::TestIamPermissionsRequest;
9006/// # async fn dox() {
9007/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9008///
9009/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9010/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9011/// # secret,
9012/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9013/// # ).build().await.unwrap();
9014///
9015/// # let client = hyper_util::client::legacy::Client::builder(
9016/// # hyper_util::rt::TokioExecutor::new()
9017/// # )
9018/// # .build(
9019/// # hyper_rustls::HttpsConnectorBuilder::new()
9020/// # .with_native_roots()
9021/// # .unwrap()
9022/// # .https_or_http()
9023/// # .enable_http1()
9024/// # .build()
9025/// # );
9026/// # let mut hub = ContainerAnalysis::new(client, auth);
9027/// // As the method needs a request, you would usually fill it with the desired information
9028/// // into the respective structure. Some of the parts shown here might not be applicable !
9029/// // Values shown here are possibly random and not representative !
9030/// let mut req = TestIamPermissionsRequest::default();
9031///
9032/// // You can configure optional parameters by calling the respective setters at will, and
9033/// // execute the final call using `doit()`.
9034/// // Values shown here are possibly random and not representative !
9035/// let result = hub.projects().notes_test_iam_permissions(req, "resource")
9036/// .doit().await;
9037/// # }
9038/// ```
9039pub struct ProjectNoteTestIamPermissionCall<'a, C>
9040where
9041 C: 'a,
9042{
9043 hub: &'a ContainerAnalysis<C>,
9044 _request: TestIamPermissionsRequest,
9045 _resource: String,
9046 _delegate: Option<&'a mut dyn common::Delegate>,
9047 _additional_params: HashMap<String, String>,
9048 _scopes: BTreeSet<String>,
9049}
9050
9051impl<'a, C> common::CallBuilder for ProjectNoteTestIamPermissionCall<'a, C> {}
9052
9053impl<'a, C> ProjectNoteTestIamPermissionCall<'a, C>
9054where
9055 C: common::Connector,
9056{
9057 /// Perform the operation you have build so far.
9058 pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
9059 use std::borrow::Cow;
9060 use std::io::{Read, Seek};
9061
9062 use common::{url::Params, ToParts};
9063 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9064
9065 let mut dd = common::DefaultDelegate;
9066 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9067 dlg.begin(common::MethodInfo {
9068 id: "containeranalysis.projects.notes.testIamPermissions",
9069 http_method: hyper::Method::POST,
9070 });
9071
9072 for &field in ["alt", "resource"].iter() {
9073 if self._additional_params.contains_key(field) {
9074 dlg.finished(false);
9075 return Err(common::Error::FieldClash(field));
9076 }
9077 }
9078
9079 let mut params = Params::with_capacity(4 + self._additional_params.len());
9080 params.push("resource", self._resource);
9081
9082 params.extend(self._additional_params.iter());
9083
9084 params.push("alt", "json");
9085 let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
9086 if self._scopes.is_empty() {
9087 self._scopes
9088 .insert(Scope::CloudPlatform.as_ref().to_string());
9089 }
9090
9091 #[allow(clippy::single_element_loop)]
9092 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
9093 url = params.uri_replacement(url, param_name, find_this, true);
9094 }
9095 {
9096 let to_remove = ["resource"];
9097 params.remove_params(&to_remove);
9098 }
9099
9100 let url = params.parse_with_url(&url);
9101
9102 let mut json_mime_type = mime::APPLICATION_JSON;
9103 let mut request_value_reader = {
9104 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9105 common::remove_json_null_values(&mut value);
9106 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9107 serde_json::to_writer(&mut dst, &value).unwrap();
9108 dst
9109 };
9110 let request_size = request_value_reader
9111 .seek(std::io::SeekFrom::End(0))
9112 .unwrap();
9113 request_value_reader
9114 .seek(std::io::SeekFrom::Start(0))
9115 .unwrap();
9116
9117 loop {
9118 let token = match self
9119 .hub
9120 .auth
9121 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9122 .await
9123 {
9124 Ok(token) => token,
9125 Err(e) => match dlg.token(e) {
9126 Ok(token) => token,
9127 Err(e) => {
9128 dlg.finished(false);
9129 return Err(common::Error::MissingToken(e));
9130 }
9131 },
9132 };
9133 request_value_reader
9134 .seek(std::io::SeekFrom::Start(0))
9135 .unwrap();
9136 let mut req_result = {
9137 let client = &self.hub.client;
9138 dlg.pre_request();
9139 let mut req_builder = hyper::Request::builder()
9140 .method(hyper::Method::POST)
9141 .uri(url.as_str())
9142 .header(USER_AGENT, self.hub._user_agent.clone());
9143
9144 if let Some(token) = token.as_ref() {
9145 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9146 }
9147
9148 let request = req_builder
9149 .header(CONTENT_TYPE, json_mime_type.to_string())
9150 .header(CONTENT_LENGTH, request_size as u64)
9151 .body(common::to_body(
9152 request_value_reader.get_ref().clone().into(),
9153 ));
9154
9155 client.request(request.unwrap()).await
9156 };
9157
9158 match req_result {
9159 Err(err) => {
9160 if let common::Retry::After(d) = dlg.http_error(&err) {
9161 sleep(d).await;
9162 continue;
9163 }
9164 dlg.finished(false);
9165 return Err(common::Error::HttpError(err));
9166 }
9167 Ok(res) => {
9168 let (mut parts, body) = res.into_parts();
9169 let mut body = common::Body::new(body);
9170 if !parts.status.is_success() {
9171 let bytes = common::to_bytes(body).await.unwrap_or_default();
9172 let error = serde_json::from_str(&common::to_string(&bytes));
9173 let response = common::to_response(parts, bytes.into());
9174
9175 if let common::Retry::After(d) =
9176 dlg.http_failure(&response, error.as_ref().ok())
9177 {
9178 sleep(d).await;
9179 continue;
9180 }
9181
9182 dlg.finished(false);
9183
9184 return Err(match error {
9185 Ok(value) => common::Error::BadRequest(value),
9186 _ => common::Error::Failure(response),
9187 });
9188 }
9189 let response = {
9190 let bytes = common::to_bytes(body).await.unwrap_or_default();
9191 let encoded = common::to_string(&bytes);
9192 match serde_json::from_str(&encoded) {
9193 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9194 Err(error) => {
9195 dlg.response_json_decode_error(&encoded, &error);
9196 return Err(common::Error::JsonDecodeError(
9197 encoded.to_string(),
9198 error,
9199 ));
9200 }
9201 }
9202 };
9203
9204 dlg.finished(true);
9205 return Ok(response);
9206 }
9207 }
9208 }
9209 }
9210
9211 ///
9212 /// Sets the *request* property to the given value.
9213 ///
9214 /// Even though the property as already been set when instantiating this call,
9215 /// we provide this method for API completeness.
9216 pub fn request(
9217 mut self,
9218 new_value: TestIamPermissionsRequest,
9219 ) -> ProjectNoteTestIamPermissionCall<'a, C> {
9220 self._request = new_value;
9221 self
9222 }
9223 /// REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
9224 ///
9225 /// Sets the *resource* path property to the given value.
9226 ///
9227 /// Even though the property as already been set when instantiating this call,
9228 /// we provide this method for API completeness.
9229 pub fn resource(mut self, new_value: &str) -> ProjectNoteTestIamPermissionCall<'a, C> {
9230 self._resource = new_value.to_string();
9231 self
9232 }
9233 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9234 /// while executing the actual API request.
9235 ///
9236 /// ````text
9237 /// It should be used to handle progress information, and to implement a certain level of resilience.
9238 /// ````
9239 ///
9240 /// Sets the *delegate* property to the given value.
9241 pub fn delegate(
9242 mut self,
9243 new_value: &'a mut dyn common::Delegate,
9244 ) -> ProjectNoteTestIamPermissionCall<'a, C> {
9245 self._delegate = Some(new_value);
9246 self
9247 }
9248
9249 /// Set any additional parameter of the query string used in the request.
9250 /// It should be used to set parameters which are not yet available through their own
9251 /// setters.
9252 ///
9253 /// Please note that this method must not be used to set any of the known parameters
9254 /// which have their own setter method. If done anyway, the request will fail.
9255 ///
9256 /// # Additional Parameters
9257 ///
9258 /// * *$.xgafv* (query-string) - V1 error format.
9259 /// * *access_token* (query-string) - OAuth access token.
9260 /// * *alt* (query-string) - Data format for response.
9261 /// * *callback* (query-string) - JSONP
9262 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9263 /// * *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.
9264 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9265 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9266 /// * *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.
9267 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9268 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9269 pub fn param<T>(mut self, name: T, value: T) -> ProjectNoteTestIamPermissionCall<'a, C>
9270 where
9271 T: AsRef<str>,
9272 {
9273 self._additional_params
9274 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9275 self
9276 }
9277
9278 /// Identifies the authorization scope for the method you are building.
9279 ///
9280 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9281 /// [`Scope::CloudPlatform`].
9282 ///
9283 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9284 /// tokens for more than one scope.
9285 ///
9286 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9287 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9288 /// sufficient, a read-write scope will do as well.
9289 pub fn add_scope<St>(mut self, scope: St) -> ProjectNoteTestIamPermissionCall<'a, C>
9290 where
9291 St: AsRef<str>,
9292 {
9293 self._scopes.insert(String::from(scope.as_ref()));
9294 self
9295 }
9296 /// Identifies the authorization scope(s) for the method you are building.
9297 ///
9298 /// See [`Self::add_scope()`] for details.
9299 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectNoteTestIamPermissionCall<'a, C>
9300 where
9301 I: IntoIterator<Item = St>,
9302 St: AsRef<str>,
9303 {
9304 self._scopes
9305 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9306 self
9307 }
9308
9309 /// Removes all scopes, and no default scope will be used either.
9310 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9311 /// for details).
9312 pub fn clear_scopes(mut self) -> ProjectNoteTestIamPermissionCall<'a, C> {
9313 self._scopes.clear();
9314 self
9315 }
9316}
9317
9318/// Creates new occurrences in batch.
9319///
9320/// A builder for the *occurrences.batchCreate* method supported by a *project* resource.
9321/// It is not used directly, but through a [`ProjectMethods`] instance.
9322///
9323/// # Example
9324///
9325/// Instantiate a resource method builder
9326///
9327/// ```test_harness,no_run
9328/// # extern crate hyper;
9329/// # extern crate hyper_rustls;
9330/// # extern crate google_containeranalysis1 as containeranalysis1;
9331/// use containeranalysis1::api::BatchCreateOccurrencesRequest;
9332/// # async fn dox() {
9333/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9334///
9335/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9336/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9337/// # secret,
9338/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9339/// # ).build().await.unwrap();
9340///
9341/// # let client = hyper_util::client::legacy::Client::builder(
9342/// # hyper_util::rt::TokioExecutor::new()
9343/// # )
9344/// # .build(
9345/// # hyper_rustls::HttpsConnectorBuilder::new()
9346/// # .with_native_roots()
9347/// # .unwrap()
9348/// # .https_or_http()
9349/// # .enable_http1()
9350/// # .build()
9351/// # );
9352/// # let mut hub = ContainerAnalysis::new(client, auth);
9353/// // As the method needs a request, you would usually fill it with the desired information
9354/// // into the respective structure. Some of the parts shown here might not be applicable !
9355/// // Values shown here are possibly random and not representative !
9356/// let mut req = BatchCreateOccurrencesRequest::default();
9357///
9358/// // You can configure optional parameters by calling the respective setters at will, and
9359/// // execute the final call using `doit()`.
9360/// // Values shown here are possibly random and not representative !
9361/// let result = hub.projects().occurrences_batch_create(req, "parent")
9362/// .doit().await;
9363/// # }
9364/// ```
9365pub struct ProjectOccurrenceBatchCreateCall<'a, C>
9366where
9367 C: 'a,
9368{
9369 hub: &'a ContainerAnalysis<C>,
9370 _request: BatchCreateOccurrencesRequest,
9371 _parent: String,
9372 _delegate: Option<&'a mut dyn common::Delegate>,
9373 _additional_params: HashMap<String, String>,
9374 _scopes: BTreeSet<String>,
9375}
9376
9377impl<'a, C> common::CallBuilder for ProjectOccurrenceBatchCreateCall<'a, C> {}
9378
9379impl<'a, C> ProjectOccurrenceBatchCreateCall<'a, C>
9380where
9381 C: common::Connector,
9382{
9383 /// Perform the operation you have build so far.
9384 pub async fn doit(
9385 mut self,
9386 ) -> common::Result<(common::Response, BatchCreateOccurrencesResponse)> {
9387 use std::borrow::Cow;
9388 use std::io::{Read, Seek};
9389
9390 use common::{url::Params, ToParts};
9391 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9392
9393 let mut dd = common::DefaultDelegate;
9394 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9395 dlg.begin(common::MethodInfo {
9396 id: "containeranalysis.projects.occurrences.batchCreate",
9397 http_method: hyper::Method::POST,
9398 });
9399
9400 for &field in ["alt", "parent"].iter() {
9401 if self._additional_params.contains_key(field) {
9402 dlg.finished(false);
9403 return Err(common::Error::FieldClash(field));
9404 }
9405 }
9406
9407 let mut params = Params::with_capacity(4 + self._additional_params.len());
9408 params.push("parent", self._parent);
9409
9410 params.extend(self._additional_params.iter());
9411
9412 params.push("alt", "json");
9413 let mut url = self.hub._base_url.clone() + "v1/{+parent}/occurrences:batchCreate";
9414 if self._scopes.is_empty() {
9415 self._scopes
9416 .insert(Scope::CloudPlatform.as_ref().to_string());
9417 }
9418
9419 #[allow(clippy::single_element_loop)]
9420 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
9421 url = params.uri_replacement(url, param_name, find_this, true);
9422 }
9423 {
9424 let to_remove = ["parent"];
9425 params.remove_params(&to_remove);
9426 }
9427
9428 let url = params.parse_with_url(&url);
9429
9430 let mut json_mime_type = mime::APPLICATION_JSON;
9431 let mut request_value_reader = {
9432 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9433 common::remove_json_null_values(&mut value);
9434 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9435 serde_json::to_writer(&mut dst, &value).unwrap();
9436 dst
9437 };
9438 let request_size = request_value_reader
9439 .seek(std::io::SeekFrom::End(0))
9440 .unwrap();
9441 request_value_reader
9442 .seek(std::io::SeekFrom::Start(0))
9443 .unwrap();
9444
9445 loop {
9446 let token = match self
9447 .hub
9448 .auth
9449 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9450 .await
9451 {
9452 Ok(token) => token,
9453 Err(e) => match dlg.token(e) {
9454 Ok(token) => token,
9455 Err(e) => {
9456 dlg.finished(false);
9457 return Err(common::Error::MissingToken(e));
9458 }
9459 },
9460 };
9461 request_value_reader
9462 .seek(std::io::SeekFrom::Start(0))
9463 .unwrap();
9464 let mut req_result = {
9465 let client = &self.hub.client;
9466 dlg.pre_request();
9467 let mut req_builder = hyper::Request::builder()
9468 .method(hyper::Method::POST)
9469 .uri(url.as_str())
9470 .header(USER_AGENT, self.hub._user_agent.clone());
9471
9472 if let Some(token) = token.as_ref() {
9473 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9474 }
9475
9476 let request = req_builder
9477 .header(CONTENT_TYPE, json_mime_type.to_string())
9478 .header(CONTENT_LENGTH, request_size as u64)
9479 .body(common::to_body(
9480 request_value_reader.get_ref().clone().into(),
9481 ));
9482
9483 client.request(request.unwrap()).await
9484 };
9485
9486 match req_result {
9487 Err(err) => {
9488 if let common::Retry::After(d) = dlg.http_error(&err) {
9489 sleep(d).await;
9490 continue;
9491 }
9492 dlg.finished(false);
9493 return Err(common::Error::HttpError(err));
9494 }
9495 Ok(res) => {
9496 let (mut parts, body) = res.into_parts();
9497 let mut body = common::Body::new(body);
9498 if !parts.status.is_success() {
9499 let bytes = common::to_bytes(body).await.unwrap_or_default();
9500 let error = serde_json::from_str(&common::to_string(&bytes));
9501 let response = common::to_response(parts, bytes.into());
9502
9503 if let common::Retry::After(d) =
9504 dlg.http_failure(&response, error.as_ref().ok())
9505 {
9506 sleep(d).await;
9507 continue;
9508 }
9509
9510 dlg.finished(false);
9511
9512 return Err(match error {
9513 Ok(value) => common::Error::BadRequest(value),
9514 _ => common::Error::Failure(response),
9515 });
9516 }
9517 let response = {
9518 let bytes = common::to_bytes(body).await.unwrap_or_default();
9519 let encoded = common::to_string(&bytes);
9520 match serde_json::from_str(&encoded) {
9521 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9522 Err(error) => {
9523 dlg.response_json_decode_error(&encoded, &error);
9524 return Err(common::Error::JsonDecodeError(
9525 encoded.to_string(),
9526 error,
9527 ));
9528 }
9529 }
9530 };
9531
9532 dlg.finished(true);
9533 return Ok(response);
9534 }
9535 }
9536 }
9537 }
9538
9539 ///
9540 /// Sets the *request* property to the given value.
9541 ///
9542 /// Even though the property as already been set when instantiating this call,
9543 /// we provide this method for API completeness.
9544 pub fn request(
9545 mut self,
9546 new_value: BatchCreateOccurrencesRequest,
9547 ) -> ProjectOccurrenceBatchCreateCall<'a, C> {
9548 self._request = new_value;
9549 self
9550 }
9551 /// Required. The name of the project in the form of `projects/[PROJECT_ID]`, under which the occurrences are to be created.
9552 ///
9553 /// Sets the *parent* path property to the given value.
9554 ///
9555 /// Even though the property as already been set when instantiating this call,
9556 /// we provide this method for API completeness.
9557 pub fn parent(mut self, new_value: &str) -> ProjectOccurrenceBatchCreateCall<'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 ) -> ProjectOccurrenceBatchCreateCall<'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>(mut self, name: T, value: T) -> ProjectOccurrenceBatchCreateCall<'a, C>
9598 where
9599 T: AsRef<str>,
9600 {
9601 self._additional_params
9602 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9603 self
9604 }
9605
9606 /// Identifies the authorization scope for the method you are building.
9607 ///
9608 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9609 /// [`Scope::CloudPlatform`].
9610 ///
9611 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9612 /// tokens for more than one scope.
9613 ///
9614 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9615 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9616 /// sufficient, a read-write scope will do as well.
9617 pub fn add_scope<St>(mut self, scope: St) -> ProjectOccurrenceBatchCreateCall<'a, C>
9618 where
9619 St: AsRef<str>,
9620 {
9621 self._scopes.insert(String::from(scope.as_ref()));
9622 self
9623 }
9624 /// Identifies the authorization scope(s) for the method you are building.
9625 ///
9626 /// See [`Self::add_scope()`] for details.
9627 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectOccurrenceBatchCreateCall<'a, C>
9628 where
9629 I: IntoIterator<Item = St>,
9630 St: AsRef<str>,
9631 {
9632 self._scopes
9633 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9634 self
9635 }
9636
9637 /// Removes all scopes, and no default scope will be used either.
9638 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9639 /// for details).
9640 pub fn clear_scopes(mut self) -> ProjectOccurrenceBatchCreateCall<'a, C> {
9641 self._scopes.clear();
9642 self
9643 }
9644}
9645
9646/// Creates a new occurrence.
9647///
9648/// A builder for the *occurrences.create* method supported by a *project* resource.
9649/// It is not used directly, but through a [`ProjectMethods`] instance.
9650///
9651/// # Example
9652///
9653/// Instantiate a resource method builder
9654///
9655/// ```test_harness,no_run
9656/// # extern crate hyper;
9657/// # extern crate hyper_rustls;
9658/// # extern crate google_containeranalysis1 as containeranalysis1;
9659/// use containeranalysis1::api::Occurrence;
9660/// # async fn dox() {
9661/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9662///
9663/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9664/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9665/// # secret,
9666/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9667/// # ).build().await.unwrap();
9668///
9669/// # let client = hyper_util::client::legacy::Client::builder(
9670/// # hyper_util::rt::TokioExecutor::new()
9671/// # )
9672/// # .build(
9673/// # hyper_rustls::HttpsConnectorBuilder::new()
9674/// # .with_native_roots()
9675/// # .unwrap()
9676/// # .https_or_http()
9677/// # .enable_http1()
9678/// # .build()
9679/// # );
9680/// # let mut hub = ContainerAnalysis::new(client, auth);
9681/// // As the method needs a request, you would usually fill it with the desired information
9682/// // into the respective structure. Some of the parts shown here might not be applicable !
9683/// // Values shown here are possibly random and not representative !
9684/// let mut req = Occurrence::default();
9685///
9686/// // You can configure optional parameters by calling the respective setters at will, and
9687/// // execute the final call using `doit()`.
9688/// // Values shown here are possibly random and not representative !
9689/// let result = hub.projects().occurrences_create(req, "parent")
9690/// .doit().await;
9691/// # }
9692/// ```
9693pub struct ProjectOccurrenceCreateCall<'a, C>
9694where
9695 C: 'a,
9696{
9697 hub: &'a ContainerAnalysis<C>,
9698 _request: Occurrence,
9699 _parent: String,
9700 _delegate: Option<&'a mut dyn common::Delegate>,
9701 _additional_params: HashMap<String, String>,
9702 _scopes: BTreeSet<String>,
9703}
9704
9705impl<'a, C> common::CallBuilder for ProjectOccurrenceCreateCall<'a, C> {}
9706
9707impl<'a, C> ProjectOccurrenceCreateCall<'a, C>
9708where
9709 C: common::Connector,
9710{
9711 /// Perform the operation you have build so far.
9712 pub async fn doit(mut self) -> common::Result<(common::Response, Occurrence)> {
9713 use std::borrow::Cow;
9714 use std::io::{Read, Seek};
9715
9716 use common::{url::Params, ToParts};
9717 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9718
9719 let mut dd = common::DefaultDelegate;
9720 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9721 dlg.begin(common::MethodInfo {
9722 id: "containeranalysis.projects.occurrences.create",
9723 http_method: hyper::Method::POST,
9724 });
9725
9726 for &field in ["alt", "parent"].iter() {
9727 if self._additional_params.contains_key(field) {
9728 dlg.finished(false);
9729 return Err(common::Error::FieldClash(field));
9730 }
9731 }
9732
9733 let mut params = Params::with_capacity(4 + self._additional_params.len());
9734 params.push("parent", self._parent);
9735
9736 params.extend(self._additional_params.iter());
9737
9738 params.push("alt", "json");
9739 let mut url = self.hub._base_url.clone() + "v1/{+parent}/occurrences";
9740 if self._scopes.is_empty() {
9741 self._scopes
9742 .insert(Scope::CloudPlatform.as_ref().to_string());
9743 }
9744
9745 #[allow(clippy::single_element_loop)]
9746 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
9747 url = params.uri_replacement(url, param_name, find_this, true);
9748 }
9749 {
9750 let to_remove = ["parent"];
9751 params.remove_params(&to_remove);
9752 }
9753
9754 let url = params.parse_with_url(&url);
9755
9756 let mut json_mime_type = mime::APPLICATION_JSON;
9757 let mut request_value_reader = {
9758 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
9759 common::remove_json_null_values(&mut value);
9760 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
9761 serde_json::to_writer(&mut dst, &value).unwrap();
9762 dst
9763 };
9764 let request_size = request_value_reader
9765 .seek(std::io::SeekFrom::End(0))
9766 .unwrap();
9767 request_value_reader
9768 .seek(std::io::SeekFrom::Start(0))
9769 .unwrap();
9770
9771 loop {
9772 let token = match self
9773 .hub
9774 .auth
9775 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9776 .await
9777 {
9778 Ok(token) => token,
9779 Err(e) => match dlg.token(e) {
9780 Ok(token) => token,
9781 Err(e) => {
9782 dlg.finished(false);
9783 return Err(common::Error::MissingToken(e));
9784 }
9785 },
9786 };
9787 request_value_reader
9788 .seek(std::io::SeekFrom::Start(0))
9789 .unwrap();
9790 let mut req_result = {
9791 let client = &self.hub.client;
9792 dlg.pre_request();
9793 let mut req_builder = hyper::Request::builder()
9794 .method(hyper::Method::POST)
9795 .uri(url.as_str())
9796 .header(USER_AGENT, self.hub._user_agent.clone());
9797
9798 if let Some(token) = token.as_ref() {
9799 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9800 }
9801
9802 let request = req_builder
9803 .header(CONTENT_TYPE, json_mime_type.to_string())
9804 .header(CONTENT_LENGTH, request_size as u64)
9805 .body(common::to_body(
9806 request_value_reader.get_ref().clone().into(),
9807 ));
9808
9809 client.request(request.unwrap()).await
9810 };
9811
9812 match req_result {
9813 Err(err) => {
9814 if let common::Retry::After(d) = dlg.http_error(&err) {
9815 sleep(d).await;
9816 continue;
9817 }
9818 dlg.finished(false);
9819 return Err(common::Error::HttpError(err));
9820 }
9821 Ok(res) => {
9822 let (mut parts, body) = res.into_parts();
9823 let mut body = common::Body::new(body);
9824 if !parts.status.is_success() {
9825 let bytes = common::to_bytes(body).await.unwrap_or_default();
9826 let error = serde_json::from_str(&common::to_string(&bytes));
9827 let response = common::to_response(parts, bytes.into());
9828
9829 if let common::Retry::After(d) =
9830 dlg.http_failure(&response, error.as_ref().ok())
9831 {
9832 sleep(d).await;
9833 continue;
9834 }
9835
9836 dlg.finished(false);
9837
9838 return Err(match error {
9839 Ok(value) => common::Error::BadRequest(value),
9840 _ => common::Error::Failure(response),
9841 });
9842 }
9843 let response = {
9844 let bytes = common::to_bytes(body).await.unwrap_or_default();
9845 let encoded = common::to_string(&bytes);
9846 match serde_json::from_str(&encoded) {
9847 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9848 Err(error) => {
9849 dlg.response_json_decode_error(&encoded, &error);
9850 return Err(common::Error::JsonDecodeError(
9851 encoded.to_string(),
9852 error,
9853 ));
9854 }
9855 }
9856 };
9857
9858 dlg.finished(true);
9859 return Ok(response);
9860 }
9861 }
9862 }
9863 }
9864
9865 ///
9866 /// Sets the *request* property to the given value.
9867 ///
9868 /// Even though the property as already been set when instantiating this call,
9869 /// we provide this method for API completeness.
9870 pub fn request(mut self, new_value: Occurrence) -> ProjectOccurrenceCreateCall<'a, C> {
9871 self._request = new_value;
9872 self
9873 }
9874 /// Required. The name of the project in the form of `projects/[PROJECT_ID]`, under which the occurrence is to be created.
9875 ///
9876 /// Sets the *parent* path property to the given value.
9877 ///
9878 /// Even though the property as already been set when instantiating this call,
9879 /// we provide this method for API completeness.
9880 pub fn parent(mut self, new_value: &str) -> ProjectOccurrenceCreateCall<'a, C> {
9881 self._parent = new_value.to_string();
9882 self
9883 }
9884 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9885 /// while executing the actual API request.
9886 ///
9887 /// ````text
9888 /// It should be used to handle progress information, and to implement a certain level of resilience.
9889 /// ````
9890 ///
9891 /// Sets the *delegate* property to the given value.
9892 pub fn delegate(
9893 mut self,
9894 new_value: &'a mut dyn common::Delegate,
9895 ) -> ProjectOccurrenceCreateCall<'a, C> {
9896 self._delegate = Some(new_value);
9897 self
9898 }
9899
9900 /// Set any additional parameter of the query string used in the request.
9901 /// It should be used to set parameters which are not yet available through their own
9902 /// setters.
9903 ///
9904 /// Please note that this method must not be used to set any of the known parameters
9905 /// which have their own setter method. If done anyway, the request will fail.
9906 ///
9907 /// # Additional Parameters
9908 ///
9909 /// * *$.xgafv* (query-string) - V1 error format.
9910 /// * *access_token* (query-string) - OAuth access token.
9911 /// * *alt* (query-string) - Data format for response.
9912 /// * *callback* (query-string) - JSONP
9913 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9914 /// * *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.
9915 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9916 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9917 /// * *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.
9918 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9919 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9920 pub fn param<T>(mut self, name: T, value: T) -> ProjectOccurrenceCreateCall<'a, C>
9921 where
9922 T: AsRef<str>,
9923 {
9924 self._additional_params
9925 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9926 self
9927 }
9928
9929 /// Identifies the authorization scope for the method you are building.
9930 ///
9931 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9932 /// [`Scope::CloudPlatform`].
9933 ///
9934 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9935 /// tokens for more than one scope.
9936 ///
9937 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9938 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9939 /// sufficient, a read-write scope will do as well.
9940 pub fn add_scope<St>(mut self, scope: St) -> ProjectOccurrenceCreateCall<'a, C>
9941 where
9942 St: AsRef<str>,
9943 {
9944 self._scopes.insert(String::from(scope.as_ref()));
9945 self
9946 }
9947 /// Identifies the authorization scope(s) for the method you are building.
9948 ///
9949 /// See [`Self::add_scope()`] for details.
9950 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectOccurrenceCreateCall<'a, C>
9951 where
9952 I: IntoIterator<Item = St>,
9953 St: AsRef<str>,
9954 {
9955 self._scopes
9956 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9957 self
9958 }
9959
9960 /// Removes all scopes, and no default scope will be used either.
9961 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9962 /// for details).
9963 pub fn clear_scopes(mut self) -> ProjectOccurrenceCreateCall<'a, C> {
9964 self._scopes.clear();
9965 self
9966 }
9967}
9968
9969/// Deletes the specified occurrence. For example, use this method to delete an occurrence when the occurrence is no longer applicable for the given resource.
9970///
9971/// A builder for the *occurrences.delete* method supported by a *project* resource.
9972/// It is not used directly, but through a [`ProjectMethods`] instance.
9973///
9974/// # Example
9975///
9976/// Instantiate a resource method builder
9977///
9978/// ```test_harness,no_run
9979/// # extern crate hyper;
9980/// # extern crate hyper_rustls;
9981/// # extern crate google_containeranalysis1 as containeranalysis1;
9982/// # async fn dox() {
9983/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9984///
9985/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9986/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
9987/// # secret,
9988/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9989/// # ).build().await.unwrap();
9990///
9991/// # let client = hyper_util::client::legacy::Client::builder(
9992/// # hyper_util::rt::TokioExecutor::new()
9993/// # )
9994/// # .build(
9995/// # hyper_rustls::HttpsConnectorBuilder::new()
9996/// # .with_native_roots()
9997/// # .unwrap()
9998/// # .https_or_http()
9999/// # .enable_http1()
10000/// # .build()
10001/// # );
10002/// # let mut hub = ContainerAnalysis::new(client, auth);
10003/// // You can configure optional parameters by calling the respective setters at will, and
10004/// // execute the final call using `doit()`.
10005/// // Values shown here are possibly random and not representative !
10006/// let result = hub.projects().occurrences_delete("name")
10007/// .doit().await;
10008/// # }
10009/// ```
10010pub struct ProjectOccurrenceDeleteCall<'a, C>
10011where
10012 C: 'a,
10013{
10014 hub: &'a ContainerAnalysis<C>,
10015 _name: String,
10016 _delegate: Option<&'a mut dyn common::Delegate>,
10017 _additional_params: HashMap<String, String>,
10018 _scopes: BTreeSet<String>,
10019}
10020
10021impl<'a, C> common::CallBuilder for ProjectOccurrenceDeleteCall<'a, C> {}
10022
10023impl<'a, C> ProjectOccurrenceDeleteCall<'a, C>
10024where
10025 C: common::Connector,
10026{
10027 /// Perform the operation you have build so far.
10028 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
10029 use std::borrow::Cow;
10030 use std::io::{Read, Seek};
10031
10032 use common::{url::Params, ToParts};
10033 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10034
10035 let mut dd = common::DefaultDelegate;
10036 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10037 dlg.begin(common::MethodInfo {
10038 id: "containeranalysis.projects.occurrences.delete",
10039 http_method: hyper::Method::DELETE,
10040 });
10041
10042 for &field in ["alt", "name"].iter() {
10043 if self._additional_params.contains_key(field) {
10044 dlg.finished(false);
10045 return Err(common::Error::FieldClash(field));
10046 }
10047 }
10048
10049 let mut params = Params::with_capacity(3 + self._additional_params.len());
10050 params.push("name", self._name);
10051
10052 params.extend(self._additional_params.iter());
10053
10054 params.push("alt", "json");
10055 let mut url = self.hub._base_url.clone() + "v1/{+name}";
10056 if self._scopes.is_empty() {
10057 self._scopes
10058 .insert(Scope::CloudPlatform.as_ref().to_string());
10059 }
10060
10061 #[allow(clippy::single_element_loop)]
10062 for &(find_this, param_name) in [("{+name}", "name")].iter() {
10063 url = params.uri_replacement(url, param_name, find_this, true);
10064 }
10065 {
10066 let to_remove = ["name"];
10067 params.remove_params(&to_remove);
10068 }
10069
10070 let url = params.parse_with_url(&url);
10071
10072 loop {
10073 let token = match self
10074 .hub
10075 .auth
10076 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10077 .await
10078 {
10079 Ok(token) => token,
10080 Err(e) => match dlg.token(e) {
10081 Ok(token) => token,
10082 Err(e) => {
10083 dlg.finished(false);
10084 return Err(common::Error::MissingToken(e));
10085 }
10086 },
10087 };
10088 let mut req_result = {
10089 let client = &self.hub.client;
10090 dlg.pre_request();
10091 let mut req_builder = hyper::Request::builder()
10092 .method(hyper::Method::DELETE)
10093 .uri(url.as_str())
10094 .header(USER_AGENT, self.hub._user_agent.clone());
10095
10096 if let Some(token) = token.as_ref() {
10097 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10098 }
10099
10100 let request = req_builder
10101 .header(CONTENT_LENGTH, 0_u64)
10102 .body(common::to_body::<String>(None));
10103
10104 client.request(request.unwrap()).await
10105 };
10106
10107 match req_result {
10108 Err(err) => {
10109 if let common::Retry::After(d) = dlg.http_error(&err) {
10110 sleep(d).await;
10111 continue;
10112 }
10113 dlg.finished(false);
10114 return Err(common::Error::HttpError(err));
10115 }
10116 Ok(res) => {
10117 let (mut parts, body) = res.into_parts();
10118 let mut body = common::Body::new(body);
10119 if !parts.status.is_success() {
10120 let bytes = common::to_bytes(body).await.unwrap_or_default();
10121 let error = serde_json::from_str(&common::to_string(&bytes));
10122 let response = common::to_response(parts, bytes.into());
10123
10124 if let common::Retry::After(d) =
10125 dlg.http_failure(&response, error.as_ref().ok())
10126 {
10127 sleep(d).await;
10128 continue;
10129 }
10130
10131 dlg.finished(false);
10132
10133 return Err(match error {
10134 Ok(value) => common::Error::BadRequest(value),
10135 _ => common::Error::Failure(response),
10136 });
10137 }
10138 let response = {
10139 let bytes = common::to_bytes(body).await.unwrap_or_default();
10140 let encoded = common::to_string(&bytes);
10141 match serde_json::from_str(&encoded) {
10142 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10143 Err(error) => {
10144 dlg.response_json_decode_error(&encoded, &error);
10145 return Err(common::Error::JsonDecodeError(
10146 encoded.to_string(),
10147 error,
10148 ));
10149 }
10150 }
10151 };
10152
10153 dlg.finished(true);
10154 return Ok(response);
10155 }
10156 }
10157 }
10158 }
10159
10160 /// Required. The name of the occurrence in the form of `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.
10161 ///
10162 /// Sets the *name* path property to the given value.
10163 ///
10164 /// Even though the property as already been set when instantiating this call,
10165 /// we provide this method for API completeness.
10166 pub fn name(mut self, new_value: &str) -> ProjectOccurrenceDeleteCall<'a, C> {
10167 self._name = new_value.to_string();
10168 self
10169 }
10170 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10171 /// while executing the actual API request.
10172 ///
10173 /// ````text
10174 /// It should be used to handle progress information, and to implement a certain level of resilience.
10175 /// ````
10176 ///
10177 /// Sets the *delegate* property to the given value.
10178 pub fn delegate(
10179 mut self,
10180 new_value: &'a mut dyn common::Delegate,
10181 ) -> ProjectOccurrenceDeleteCall<'a, C> {
10182 self._delegate = Some(new_value);
10183 self
10184 }
10185
10186 /// Set any additional parameter of the query string used in the request.
10187 /// It should be used to set parameters which are not yet available through their own
10188 /// setters.
10189 ///
10190 /// Please note that this method must not be used to set any of the known parameters
10191 /// which have their own setter method. If done anyway, the request will fail.
10192 ///
10193 /// # Additional Parameters
10194 ///
10195 /// * *$.xgafv* (query-string) - V1 error format.
10196 /// * *access_token* (query-string) - OAuth access token.
10197 /// * *alt* (query-string) - Data format for response.
10198 /// * *callback* (query-string) - JSONP
10199 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10200 /// * *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.
10201 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10202 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10203 /// * *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.
10204 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10205 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10206 pub fn param<T>(mut self, name: T, value: T) -> ProjectOccurrenceDeleteCall<'a, C>
10207 where
10208 T: AsRef<str>,
10209 {
10210 self._additional_params
10211 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10212 self
10213 }
10214
10215 /// Identifies the authorization scope for the method you are building.
10216 ///
10217 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10218 /// [`Scope::CloudPlatform`].
10219 ///
10220 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10221 /// tokens for more than one scope.
10222 ///
10223 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10224 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10225 /// sufficient, a read-write scope will do as well.
10226 pub fn add_scope<St>(mut self, scope: St) -> ProjectOccurrenceDeleteCall<'a, C>
10227 where
10228 St: AsRef<str>,
10229 {
10230 self._scopes.insert(String::from(scope.as_ref()));
10231 self
10232 }
10233 /// Identifies the authorization scope(s) for the method you are building.
10234 ///
10235 /// See [`Self::add_scope()`] for details.
10236 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectOccurrenceDeleteCall<'a, C>
10237 where
10238 I: IntoIterator<Item = St>,
10239 St: AsRef<str>,
10240 {
10241 self._scopes
10242 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10243 self
10244 }
10245
10246 /// Removes all scopes, and no default scope will be used either.
10247 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10248 /// for details).
10249 pub fn clear_scopes(mut self) -> ProjectOccurrenceDeleteCall<'a, C> {
10250 self._scopes.clear();
10251 self
10252 }
10253}
10254
10255/// Gets the specified occurrence.
10256///
10257/// A builder for the *occurrences.get* method supported by a *project* resource.
10258/// It is not used directly, but through a [`ProjectMethods`] instance.
10259///
10260/// # Example
10261///
10262/// Instantiate a resource method builder
10263///
10264/// ```test_harness,no_run
10265/// # extern crate hyper;
10266/// # extern crate hyper_rustls;
10267/// # extern crate google_containeranalysis1 as containeranalysis1;
10268/// # async fn dox() {
10269/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10270///
10271/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10272/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10273/// # secret,
10274/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10275/// # ).build().await.unwrap();
10276///
10277/// # let client = hyper_util::client::legacy::Client::builder(
10278/// # hyper_util::rt::TokioExecutor::new()
10279/// # )
10280/// # .build(
10281/// # hyper_rustls::HttpsConnectorBuilder::new()
10282/// # .with_native_roots()
10283/// # .unwrap()
10284/// # .https_or_http()
10285/// # .enable_http1()
10286/// # .build()
10287/// # );
10288/// # let mut hub = ContainerAnalysis::new(client, auth);
10289/// // You can configure optional parameters by calling the respective setters at will, and
10290/// // execute the final call using `doit()`.
10291/// // Values shown here are possibly random and not representative !
10292/// let result = hub.projects().occurrences_get("name")
10293/// .doit().await;
10294/// # }
10295/// ```
10296pub struct ProjectOccurrenceGetCall<'a, C>
10297where
10298 C: 'a,
10299{
10300 hub: &'a ContainerAnalysis<C>,
10301 _name: String,
10302 _delegate: Option<&'a mut dyn common::Delegate>,
10303 _additional_params: HashMap<String, String>,
10304 _scopes: BTreeSet<String>,
10305}
10306
10307impl<'a, C> common::CallBuilder for ProjectOccurrenceGetCall<'a, C> {}
10308
10309impl<'a, C> ProjectOccurrenceGetCall<'a, C>
10310where
10311 C: common::Connector,
10312{
10313 /// Perform the operation you have build so far.
10314 pub async fn doit(mut self) -> common::Result<(common::Response, Occurrence)> {
10315 use std::borrow::Cow;
10316 use std::io::{Read, Seek};
10317
10318 use common::{url::Params, ToParts};
10319 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10320
10321 let mut dd = common::DefaultDelegate;
10322 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10323 dlg.begin(common::MethodInfo {
10324 id: "containeranalysis.projects.occurrences.get",
10325 http_method: hyper::Method::GET,
10326 });
10327
10328 for &field in ["alt", "name"].iter() {
10329 if self._additional_params.contains_key(field) {
10330 dlg.finished(false);
10331 return Err(common::Error::FieldClash(field));
10332 }
10333 }
10334
10335 let mut params = Params::with_capacity(3 + self._additional_params.len());
10336 params.push("name", self._name);
10337
10338 params.extend(self._additional_params.iter());
10339
10340 params.push("alt", "json");
10341 let mut url = self.hub._base_url.clone() + "v1/{+name}";
10342 if self._scopes.is_empty() {
10343 self._scopes
10344 .insert(Scope::CloudPlatform.as_ref().to_string());
10345 }
10346
10347 #[allow(clippy::single_element_loop)]
10348 for &(find_this, param_name) in [("{+name}", "name")].iter() {
10349 url = params.uri_replacement(url, param_name, find_this, true);
10350 }
10351 {
10352 let to_remove = ["name"];
10353 params.remove_params(&to_remove);
10354 }
10355
10356 let url = params.parse_with_url(&url);
10357
10358 loop {
10359 let token = match self
10360 .hub
10361 .auth
10362 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10363 .await
10364 {
10365 Ok(token) => token,
10366 Err(e) => match dlg.token(e) {
10367 Ok(token) => token,
10368 Err(e) => {
10369 dlg.finished(false);
10370 return Err(common::Error::MissingToken(e));
10371 }
10372 },
10373 };
10374 let mut req_result = {
10375 let client = &self.hub.client;
10376 dlg.pre_request();
10377 let mut req_builder = hyper::Request::builder()
10378 .method(hyper::Method::GET)
10379 .uri(url.as_str())
10380 .header(USER_AGENT, self.hub._user_agent.clone());
10381
10382 if let Some(token) = token.as_ref() {
10383 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10384 }
10385
10386 let request = req_builder
10387 .header(CONTENT_LENGTH, 0_u64)
10388 .body(common::to_body::<String>(None));
10389
10390 client.request(request.unwrap()).await
10391 };
10392
10393 match req_result {
10394 Err(err) => {
10395 if let common::Retry::After(d) = dlg.http_error(&err) {
10396 sleep(d).await;
10397 continue;
10398 }
10399 dlg.finished(false);
10400 return Err(common::Error::HttpError(err));
10401 }
10402 Ok(res) => {
10403 let (mut parts, body) = res.into_parts();
10404 let mut body = common::Body::new(body);
10405 if !parts.status.is_success() {
10406 let bytes = common::to_bytes(body).await.unwrap_or_default();
10407 let error = serde_json::from_str(&common::to_string(&bytes));
10408 let response = common::to_response(parts, bytes.into());
10409
10410 if let common::Retry::After(d) =
10411 dlg.http_failure(&response, error.as_ref().ok())
10412 {
10413 sleep(d).await;
10414 continue;
10415 }
10416
10417 dlg.finished(false);
10418
10419 return Err(match error {
10420 Ok(value) => common::Error::BadRequest(value),
10421 _ => common::Error::Failure(response),
10422 });
10423 }
10424 let response = {
10425 let bytes = common::to_bytes(body).await.unwrap_or_default();
10426 let encoded = common::to_string(&bytes);
10427 match serde_json::from_str(&encoded) {
10428 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10429 Err(error) => {
10430 dlg.response_json_decode_error(&encoded, &error);
10431 return Err(common::Error::JsonDecodeError(
10432 encoded.to_string(),
10433 error,
10434 ));
10435 }
10436 }
10437 };
10438
10439 dlg.finished(true);
10440 return Ok(response);
10441 }
10442 }
10443 }
10444 }
10445
10446 /// Required. The name of the occurrence in the form of `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.
10447 ///
10448 /// Sets the *name* path property to the given value.
10449 ///
10450 /// Even though the property as already been set when instantiating this call,
10451 /// we provide this method for API completeness.
10452 pub fn name(mut self, new_value: &str) -> ProjectOccurrenceGetCall<'a, C> {
10453 self._name = new_value.to_string();
10454 self
10455 }
10456 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10457 /// while executing the actual API request.
10458 ///
10459 /// ````text
10460 /// It should be used to handle progress information, and to implement a certain level of resilience.
10461 /// ````
10462 ///
10463 /// Sets the *delegate* property to the given value.
10464 pub fn delegate(
10465 mut self,
10466 new_value: &'a mut dyn common::Delegate,
10467 ) -> ProjectOccurrenceGetCall<'a, C> {
10468 self._delegate = Some(new_value);
10469 self
10470 }
10471
10472 /// Set any additional parameter of the query string used in the request.
10473 /// It should be used to set parameters which are not yet available through their own
10474 /// setters.
10475 ///
10476 /// Please note that this method must not be used to set any of the known parameters
10477 /// which have their own setter method. If done anyway, the request will fail.
10478 ///
10479 /// # Additional Parameters
10480 ///
10481 /// * *$.xgafv* (query-string) - V1 error format.
10482 /// * *access_token* (query-string) - OAuth access token.
10483 /// * *alt* (query-string) - Data format for response.
10484 /// * *callback* (query-string) - JSONP
10485 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10486 /// * *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.
10487 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10488 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10489 /// * *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.
10490 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10491 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10492 pub fn param<T>(mut self, name: T, value: T) -> ProjectOccurrenceGetCall<'a, C>
10493 where
10494 T: AsRef<str>,
10495 {
10496 self._additional_params
10497 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10498 self
10499 }
10500
10501 /// Identifies the authorization scope for the method you are building.
10502 ///
10503 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10504 /// [`Scope::CloudPlatform`].
10505 ///
10506 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10507 /// tokens for more than one scope.
10508 ///
10509 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10510 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10511 /// sufficient, a read-write scope will do as well.
10512 pub fn add_scope<St>(mut self, scope: St) -> ProjectOccurrenceGetCall<'a, C>
10513 where
10514 St: AsRef<str>,
10515 {
10516 self._scopes.insert(String::from(scope.as_ref()));
10517 self
10518 }
10519 /// Identifies the authorization scope(s) for the method you are building.
10520 ///
10521 /// See [`Self::add_scope()`] for details.
10522 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectOccurrenceGetCall<'a, C>
10523 where
10524 I: IntoIterator<Item = St>,
10525 St: AsRef<str>,
10526 {
10527 self._scopes
10528 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10529 self
10530 }
10531
10532 /// Removes all scopes, and no default scope will be used either.
10533 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10534 /// for details).
10535 pub fn clear_scopes(mut self) -> ProjectOccurrenceGetCall<'a, C> {
10536 self._scopes.clear();
10537 self
10538 }
10539}
10540
10541/// Gets the access control policy for a note or an occurrence resource. Requires `containeranalysis.notes.setIamPolicy` or `containeranalysis.occurrences.setIamPolicy` permission if the resource is a note or occurrence, respectively. The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
10542///
10543/// A builder for the *occurrences.getIamPolicy* method supported by a *project* resource.
10544/// It is not used directly, but through a [`ProjectMethods`] instance.
10545///
10546/// # Example
10547///
10548/// Instantiate a resource method builder
10549///
10550/// ```test_harness,no_run
10551/// # extern crate hyper;
10552/// # extern crate hyper_rustls;
10553/// # extern crate google_containeranalysis1 as containeranalysis1;
10554/// use containeranalysis1::api::GetIamPolicyRequest;
10555/// # async fn dox() {
10556/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10557///
10558/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10559/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10560/// # secret,
10561/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10562/// # ).build().await.unwrap();
10563///
10564/// # let client = hyper_util::client::legacy::Client::builder(
10565/// # hyper_util::rt::TokioExecutor::new()
10566/// # )
10567/// # .build(
10568/// # hyper_rustls::HttpsConnectorBuilder::new()
10569/// # .with_native_roots()
10570/// # .unwrap()
10571/// # .https_or_http()
10572/// # .enable_http1()
10573/// # .build()
10574/// # );
10575/// # let mut hub = ContainerAnalysis::new(client, auth);
10576/// // As the method needs a request, you would usually fill it with the desired information
10577/// // into the respective structure. Some of the parts shown here might not be applicable !
10578/// // Values shown here are possibly random and not representative !
10579/// let mut req = GetIamPolicyRequest::default();
10580///
10581/// // You can configure optional parameters by calling the respective setters at will, and
10582/// // execute the final call using `doit()`.
10583/// // Values shown here are possibly random and not representative !
10584/// let result = hub.projects().occurrences_get_iam_policy(req, "resource")
10585/// .doit().await;
10586/// # }
10587/// ```
10588pub struct ProjectOccurrenceGetIamPolicyCall<'a, C>
10589where
10590 C: 'a,
10591{
10592 hub: &'a ContainerAnalysis<C>,
10593 _request: GetIamPolicyRequest,
10594 _resource: String,
10595 _delegate: Option<&'a mut dyn common::Delegate>,
10596 _additional_params: HashMap<String, String>,
10597 _scopes: BTreeSet<String>,
10598}
10599
10600impl<'a, C> common::CallBuilder for ProjectOccurrenceGetIamPolicyCall<'a, C> {}
10601
10602impl<'a, C> ProjectOccurrenceGetIamPolicyCall<'a, C>
10603where
10604 C: common::Connector,
10605{
10606 /// Perform the operation you have build so far.
10607 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
10608 use std::borrow::Cow;
10609 use std::io::{Read, Seek};
10610
10611 use common::{url::Params, ToParts};
10612 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10613
10614 let mut dd = common::DefaultDelegate;
10615 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10616 dlg.begin(common::MethodInfo {
10617 id: "containeranalysis.projects.occurrences.getIamPolicy",
10618 http_method: hyper::Method::POST,
10619 });
10620
10621 for &field in ["alt", "resource"].iter() {
10622 if self._additional_params.contains_key(field) {
10623 dlg.finished(false);
10624 return Err(common::Error::FieldClash(field));
10625 }
10626 }
10627
10628 let mut params = Params::with_capacity(4 + self._additional_params.len());
10629 params.push("resource", self._resource);
10630
10631 params.extend(self._additional_params.iter());
10632
10633 params.push("alt", "json");
10634 let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
10635 if self._scopes.is_empty() {
10636 self._scopes
10637 .insert(Scope::CloudPlatform.as_ref().to_string());
10638 }
10639
10640 #[allow(clippy::single_element_loop)]
10641 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
10642 url = params.uri_replacement(url, param_name, find_this, true);
10643 }
10644 {
10645 let to_remove = ["resource"];
10646 params.remove_params(&to_remove);
10647 }
10648
10649 let url = params.parse_with_url(&url);
10650
10651 let mut json_mime_type = mime::APPLICATION_JSON;
10652 let mut request_value_reader = {
10653 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10654 common::remove_json_null_values(&mut value);
10655 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10656 serde_json::to_writer(&mut dst, &value).unwrap();
10657 dst
10658 };
10659 let request_size = request_value_reader
10660 .seek(std::io::SeekFrom::End(0))
10661 .unwrap();
10662 request_value_reader
10663 .seek(std::io::SeekFrom::Start(0))
10664 .unwrap();
10665
10666 loop {
10667 let token = match self
10668 .hub
10669 .auth
10670 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10671 .await
10672 {
10673 Ok(token) => token,
10674 Err(e) => match dlg.token(e) {
10675 Ok(token) => token,
10676 Err(e) => {
10677 dlg.finished(false);
10678 return Err(common::Error::MissingToken(e));
10679 }
10680 },
10681 };
10682 request_value_reader
10683 .seek(std::io::SeekFrom::Start(0))
10684 .unwrap();
10685 let mut req_result = {
10686 let client = &self.hub.client;
10687 dlg.pre_request();
10688 let mut req_builder = hyper::Request::builder()
10689 .method(hyper::Method::POST)
10690 .uri(url.as_str())
10691 .header(USER_AGENT, self.hub._user_agent.clone());
10692
10693 if let Some(token) = token.as_ref() {
10694 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10695 }
10696
10697 let request = req_builder
10698 .header(CONTENT_TYPE, json_mime_type.to_string())
10699 .header(CONTENT_LENGTH, request_size as u64)
10700 .body(common::to_body(
10701 request_value_reader.get_ref().clone().into(),
10702 ));
10703
10704 client.request(request.unwrap()).await
10705 };
10706
10707 match req_result {
10708 Err(err) => {
10709 if let common::Retry::After(d) = dlg.http_error(&err) {
10710 sleep(d).await;
10711 continue;
10712 }
10713 dlg.finished(false);
10714 return Err(common::Error::HttpError(err));
10715 }
10716 Ok(res) => {
10717 let (mut parts, body) = res.into_parts();
10718 let mut body = common::Body::new(body);
10719 if !parts.status.is_success() {
10720 let bytes = common::to_bytes(body).await.unwrap_or_default();
10721 let error = serde_json::from_str(&common::to_string(&bytes));
10722 let response = common::to_response(parts, bytes.into());
10723
10724 if let common::Retry::After(d) =
10725 dlg.http_failure(&response, error.as_ref().ok())
10726 {
10727 sleep(d).await;
10728 continue;
10729 }
10730
10731 dlg.finished(false);
10732
10733 return Err(match error {
10734 Ok(value) => common::Error::BadRequest(value),
10735 _ => common::Error::Failure(response),
10736 });
10737 }
10738 let response = {
10739 let bytes = common::to_bytes(body).await.unwrap_or_default();
10740 let encoded = common::to_string(&bytes);
10741 match serde_json::from_str(&encoded) {
10742 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10743 Err(error) => {
10744 dlg.response_json_decode_error(&encoded, &error);
10745 return Err(common::Error::JsonDecodeError(
10746 encoded.to_string(),
10747 error,
10748 ));
10749 }
10750 }
10751 };
10752
10753 dlg.finished(true);
10754 return Ok(response);
10755 }
10756 }
10757 }
10758 }
10759
10760 ///
10761 /// Sets the *request* property to the given value.
10762 ///
10763 /// Even though the property as already been set when instantiating this call,
10764 /// we provide this method for API completeness.
10765 pub fn request(
10766 mut self,
10767 new_value: GetIamPolicyRequest,
10768 ) -> ProjectOccurrenceGetIamPolicyCall<'a, C> {
10769 self._request = new_value;
10770 self
10771 }
10772 /// REQUIRED: The resource for which the policy is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
10773 ///
10774 /// Sets the *resource* path property to the given value.
10775 ///
10776 /// Even though the property as already been set when instantiating this call,
10777 /// we provide this method for API completeness.
10778 pub fn resource(mut self, new_value: &str) -> ProjectOccurrenceGetIamPolicyCall<'a, C> {
10779 self._resource = new_value.to_string();
10780 self
10781 }
10782 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10783 /// while executing the actual API request.
10784 ///
10785 /// ````text
10786 /// It should be used to handle progress information, and to implement a certain level of resilience.
10787 /// ````
10788 ///
10789 /// Sets the *delegate* property to the given value.
10790 pub fn delegate(
10791 mut self,
10792 new_value: &'a mut dyn common::Delegate,
10793 ) -> ProjectOccurrenceGetIamPolicyCall<'a, C> {
10794 self._delegate = Some(new_value);
10795 self
10796 }
10797
10798 /// Set any additional parameter of the query string used in the request.
10799 /// It should be used to set parameters which are not yet available through their own
10800 /// setters.
10801 ///
10802 /// Please note that this method must not be used to set any of the known parameters
10803 /// which have their own setter method. If done anyway, the request will fail.
10804 ///
10805 /// # Additional Parameters
10806 ///
10807 /// * *$.xgafv* (query-string) - V1 error format.
10808 /// * *access_token* (query-string) - OAuth access token.
10809 /// * *alt* (query-string) - Data format for response.
10810 /// * *callback* (query-string) - JSONP
10811 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10812 /// * *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.
10813 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10814 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10815 /// * *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.
10816 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10817 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10818 pub fn param<T>(mut self, name: T, value: T) -> ProjectOccurrenceGetIamPolicyCall<'a, C>
10819 where
10820 T: AsRef<str>,
10821 {
10822 self._additional_params
10823 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10824 self
10825 }
10826
10827 /// Identifies the authorization scope for the method you are building.
10828 ///
10829 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10830 /// [`Scope::CloudPlatform`].
10831 ///
10832 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10833 /// tokens for more than one scope.
10834 ///
10835 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10836 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10837 /// sufficient, a read-write scope will do as well.
10838 pub fn add_scope<St>(mut self, scope: St) -> ProjectOccurrenceGetIamPolicyCall<'a, C>
10839 where
10840 St: AsRef<str>,
10841 {
10842 self._scopes.insert(String::from(scope.as_ref()));
10843 self
10844 }
10845 /// Identifies the authorization scope(s) for the method you are building.
10846 ///
10847 /// See [`Self::add_scope()`] for details.
10848 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectOccurrenceGetIamPolicyCall<'a, C>
10849 where
10850 I: IntoIterator<Item = St>,
10851 St: AsRef<str>,
10852 {
10853 self._scopes
10854 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10855 self
10856 }
10857
10858 /// Removes all scopes, and no default scope will be used either.
10859 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10860 /// for details).
10861 pub fn clear_scopes(mut self) -> ProjectOccurrenceGetIamPolicyCall<'a, C> {
10862 self._scopes.clear();
10863 self
10864 }
10865}
10866
10867/// Gets the note attached to the specified occurrence. Consumer projects can use this method to get a note that belongs to a provider project.
10868///
10869/// A builder for the *occurrences.getNotes* method supported by a *project* resource.
10870/// It is not used directly, but through a [`ProjectMethods`] instance.
10871///
10872/// # Example
10873///
10874/// Instantiate a resource method builder
10875///
10876/// ```test_harness,no_run
10877/// # extern crate hyper;
10878/// # extern crate hyper_rustls;
10879/// # extern crate google_containeranalysis1 as containeranalysis1;
10880/// # async fn dox() {
10881/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10882///
10883/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10884/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
10885/// # secret,
10886/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10887/// # ).build().await.unwrap();
10888///
10889/// # let client = hyper_util::client::legacy::Client::builder(
10890/// # hyper_util::rt::TokioExecutor::new()
10891/// # )
10892/// # .build(
10893/// # hyper_rustls::HttpsConnectorBuilder::new()
10894/// # .with_native_roots()
10895/// # .unwrap()
10896/// # .https_or_http()
10897/// # .enable_http1()
10898/// # .build()
10899/// # );
10900/// # let mut hub = ContainerAnalysis::new(client, auth);
10901/// // You can configure optional parameters by calling the respective setters at will, and
10902/// // execute the final call using `doit()`.
10903/// // Values shown here are possibly random and not representative !
10904/// let result = hub.projects().occurrences_get_notes("name")
10905/// .doit().await;
10906/// # }
10907/// ```
10908pub struct ProjectOccurrenceGetNoteCall<'a, C>
10909where
10910 C: 'a,
10911{
10912 hub: &'a ContainerAnalysis<C>,
10913 _name: String,
10914 _delegate: Option<&'a mut dyn common::Delegate>,
10915 _additional_params: HashMap<String, String>,
10916 _scopes: BTreeSet<String>,
10917}
10918
10919impl<'a, C> common::CallBuilder for ProjectOccurrenceGetNoteCall<'a, C> {}
10920
10921impl<'a, C> ProjectOccurrenceGetNoteCall<'a, C>
10922where
10923 C: common::Connector,
10924{
10925 /// Perform the operation you have build so far.
10926 pub async fn doit(mut self) -> common::Result<(common::Response, Note)> {
10927 use std::borrow::Cow;
10928 use std::io::{Read, Seek};
10929
10930 use common::{url::Params, ToParts};
10931 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10932
10933 let mut dd = common::DefaultDelegate;
10934 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10935 dlg.begin(common::MethodInfo {
10936 id: "containeranalysis.projects.occurrences.getNotes",
10937 http_method: hyper::Method::GET,
10938 });
10939
10940 for &field in ["alt", "name"].iter() {
10941 if self._additional_params.contains_key(field) {
10942 dlg.finished(false);
10943 return Err(common::Error::FieldClash(field));
10944 }
10945 }
10946
10947 let mut params = Params::with_capacity(3 + self._additional_params.len());
10948 params.push("name", self._name);
10949
10950 params.extend(self._additional_params.iter());
10951
10952 params.push("alt", "json");
10953 let mut url = self.hub._base_url.clone() + "v1/{+name}/notes";
10954 if self._scopes.is_empty() {
10955 self._scopes
10956 .insert(Scope::CloudPlatform.as_ref().to_string());
10957 }
10958
10959 #[allow(clippy::single_element_loop)]
10960 for &(find_this, param_name) in [("{+name}", "name")].iter() {
10961 url = params.uri_replacement(url, param_name, find_this, true);
10962 }
10963 {
10964 let to_remove = ["name"];
10965 params.remove_params(&to_remove);
10966 }
10967
10968 let url = params.parse_with_url(&url);
10969
10970 loop {
10971 let token = match self
10972 .hub
10973 .auth
10974 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10975 .await
10976 {
10977 Ok(token) => token,
10978 Err(e) => match dlg.token(e) {
10979 Ok(token) => token,
10980 Err(e) => {
10981 dlg.finished(false);
10982 return Err(common::Error::MissingToken(e));
10983 }
10984 },
10985 };
10986 let mut req_result = {
10987 let client = &self.hub.client;
10988 dlg.pre_request();
10989 let mut req_builder = hyper::Request::builder()
10990 .method(hyper::Method::GET)
10991 .uri(url.as_str())
10992 .header(USER_AGENT, self.hub._user_agent.clone());
10993
10994 if let Some(token) = token.as_ref() {
10995 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10996 }
10997
10998 let request = req_builder
10999 .header(CONTENT_LENGTH, 0_u64)
11000 .body(common::to_body::<String>(None));
11001
11002 client.request(request.unwrap()).await
11003 };
11004
11005 match req_result {
11006 Err(err) => {
11007 if let common::Retry::After(d) = dlg.http_error(&err) {
11008 sleep(d).await;
11009 continue;
11010 }
11011 dlg.finished(false);
11012 return Err(common::Error::HttpError(err));
11013 }
11014 Ok(res) => {
11015 let (mut parts, body) = res.into_parts();
11016 let mut body = common::Body::new(body);
11017 if !parts.status.is_success() {
11018 let bytes = common::to_bytes(body).await.unwrap_or_default();
11019 let error = serde_json::from_str(&common::to_string(&bytes));
11020 let response = common::to_response(parts, bytes.into());
11021
11022 if let common::Retry::After(d) =
11023 dlg.http_failure(&response, error.as_ref().ok())
11024 {
11025 sleep(d).await;
11026 continue;
11027 }
11028
11029 dlg.finished(false);
11030
11031 return Err(match error {
11032 Ok(value) => common::Error::BadRequest(value),
11033 _ => common::Error::Failure(response),
11034 });
11035 }
11036 let response = {
11037 let bytes = common::to_bytes(body).await.unwrap_or_default();
11038 let encoded = common::to_string(&bytes);
11039 match serde_json::from_str(&encoded) {
11040 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11041 Err(error) => {
11042 dlg.response_json_decode_error(&encoded, &error);
11043 return Err(common::Error::JsonDecodeError(
11044 encoded.to_string(),
11045 error,
11046 ));
11047 }
11048 }
11049 };
11050
11051 dlg.finished(true);
11052 return Ok(response);
11053 }
11054 }
11055 }
11056 }
11057
11058 /// Required. The name of the occurrence in the form of `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.
11059 ///
11060 /// Sets the *name* path property to the given value.
11061 ///
11062 /// Even though the property as already been set when instantiating this call,
11063 /// we provide this method for API completeness.
11064 pub fn name(mut self, new_value: &str) -> ProjectOccurrenceGetNoteCall<'a, C> {
11065 self._name = new_value.to_string();
11066 self
11067 }
11068 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11069 /// while executing the actual API request.
11070 ///
11071 /// ````text
11072 /// It should be used to handle progress information, and to implement a certain level of resilience.
11073 /// ````
11074 ///
11075 /// Sets the *delegate* property to the given value.
11076 pub fn delegate(
11077 mut self,
11078 new_value: &'a mut dyn common::Delegate,
11079 ) -> ProjectOccurrenceGetNoteCall<'a, C> {
11080 self._delegate = Some(new_value);
11081 self
11082 }
11083
11084 /// Set any additional parameter of the query string used in the request.
11085 /// It should be used to set parameters which are not yet available through their own
11086 /// setters.
11087 ///
11088 /// Please note that this method must not be used to set any of the known parameters
11089 /// which have their own setter method. If done anyway, the request will fail.
11090 ///
11091 /// # Additional Parameters
11092 ///
11093 /// * *$.xgafv* (query-string) - V1 error format.
11094 /// * *access_token* (query-string) - OAuth access token.
11095 /// * *alt* (query-string) - Data format for response.
11096 /// * *callback* (query-string) - JSONP
11097 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11098 /// * *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.
11099 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11100 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11101 /// * *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.
11102 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11103 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11104 pub fn param<T>(mut self, name: T, value: T) -> ProjectOccurrenceGetNoteCall<'a, C>
11105 where
11106 T: AsRef<str>,
11107 {
11108 self._additional_params
11109 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11110 self
11111 }
11112
11113 /// Identifies the authorization scope for the method you are building.
11114 ///
11115 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11116 /// [`Scope::CloudPlatform`].
11117 ///
11118 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11119 /// tokens for more than one scope.
11120 ///
11121 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11122 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11123 /// sufficient, a read-write scope will do as well.
11124 pub fn add_scope<St>(mut self, scope: St) -> ProjectOccurrenceGetNoteCall<'a, C>
11125 where
11126 St: AsRef<str>,
11127 {
11128 self._scopes.insert(String::from(scope.as_ref()));
11129 self
11130 }
11131 /// Identifies the authorization scope(s) for the method you are building.
11132 ///
11133 /// See [`Self::add_scope()`] for details.
11134 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectOccurrenceGetNoteCall<'a, C>
11135 where
11136 I: IntoIterator<Item = St>,
11137 St: AsRef<str>,
11138 {
11139 self._scopes
11140 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11141 self
11142 }
11143
11144 /// Removes all scopes, and no default scope will be used either.
11145 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11146 /// for details).
11147 pub fn clear_scopes(mut self) -> ProjectOccurrenceGetNoteCall<'a, C> {
11148 self._scopes.clear();
11149 self
11150 }
11151}
11152
11153/// Gets a summary of the number and severity of occurrences.
11154///
11155/// A builder for the *occurrences.getVulnerabilitySummary* method supported by a *project* resource.
11156/// It is not used directly, but through a [`ProjectMethods`] instance.
11157///
11158/// # Example
11159///
11160/// Instantiate a resource method builder
11161///
11162/// ```test_harness,no_run
11163/// # extern crate hyper;
11164/// # extern crate hyper_rustls;
11165/// # extern crate google_containeranalysis1 as containeranalysis1;
11166/// # async fn dox() {
11167/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11168///
11169/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11170/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11171/// # secret,
11172/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11173/// # ).build().await.unwrap();
11174///
11175/// # let client = hyper_util::client::legacy::Client::builder(
11176/// # hyper_util::rt::TokioExecutor::new()
11177/// # )
11178/// # .build(
11179/// # hyper_rustls::HttpsConnectorBuilder::new()
11180/// # .with_native_roots()
11181/// # .unwrap()
11182/// # .https_or_http()
11183/// # .enable_http1()
11184/// # .build()
11185/// # );
11186/// # let mut hub = ContainerAnalysis::new(client, auth);
11187/// // You can configure optional parameters by calling the respective setters at will, and
11188/// // execute the final call using `doit()`.
11189/// // Values shown here are possibly random and not representative !
11190/// let result = hub.projects().occurrences_get_vulnerability_summary("parent")
11191/// .filter("vero")
11192/// .doit().await;
11193/// # }
11194/// ```
11195pub struct ProjectOccurrenceGetVulnerabilitySummaryCall<'a, C>
11196where
11197 C: 'a,
11198{
11199 hub: &'a ContainerAnalysis<C>,
11200 _parent: String,
11201 _filter: Option<String>,
11202 _delegate: Option<&'a mut dyn common::Delegate>,
11203 _additional_params: HashMap<String, String>,
11204 _scopes: BTreeSet<String>,
11205}
11206
11207impl<'a, C> common::CallBuilder for ProjectOccurrenceGetVulnerabilitySummaryCall<'a, C> {}
11208
11209impl<'a, C> ProjectOccurrenceGetVulnerabilitySummaryCall<'a, C>
11210where
11211 C: common::Connector,
11212{
11213 /// Perform the operation you have build so far.
11214 pub async fn doit(
11215 mut self,
11216 ) -> common::Result<(common::Response, VulnerabilityOccurrencesSummary)> {
11217 use std::borrow::Cow;
11218 use std::io::{Read, Seek};
11219
11220 use common::{url::Params, ToParts};
11221 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11222
11223 let mut dd = common::DefaultDelegate;
11224 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11225 dlg.begin(common::MethodInfo {
11226 id: "containeranalysis.projects.occurrences.getVulnerabilitySummary",
11227 http_method: hyper::Method::GET,
11228 });
11229
11230 for &field in ["alt", "parent", "filter"].iter() {
11231 if self._additional_params.contains_key(field) {
11232 dlg.finished(false);
11233 return Err(common::Error::FieldClash(field));
11234 }
11235 }
11236
11237 let mut params = Params::with_capacity(4 + self._additional_params.len());
11238 params.push("parent", self._parent);
11239 if let Some(value) = self._filter.as_ref() {
11240 params.push("filter", value);
11241 }
11242
11243 params.extend(self._additional_params.iter());
11244
11245 params.push("alt", "json");
11246 let mut url = self.hub._base_url.clone() + "v1/{+parent}/occurrences:vulnerabilitySummary";
11247 if self._scopes.is_empty() {
11248 self._scopes
11249 .insert(Scope::CloudPlatform.as_ref().to_string());
11250 }
11251
11252 #[allow(clippy::single_element_loop)]
11253 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
11254 url = params.uri_replacement(url, param_name, find_this, true);
11255 }
11256 {
11257 let to_remove = ["parent"];
11258 params.remove_params(&to_remove);
11259 }
11260
11261 let url = params.parse_with_url(&url);
11262
11263 loop {
11264 let token = match self
11265 .hub
11266 .auth
11267 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11268 .await
11269 {
11270 Ok(token) => token,
11271 Err(e) => match dlg.token(e) {
11272 Ok(token) => token,
11273 Err(e) => {
11274 dlg.finished(false);
11275 return Err(common::Error::MissingToken(e));
11276 }
11277 },
11278 };
11279 let mut req_result = {
11280 let client = &self.hub.client;
11281 dlg.pre_request();
11282 let mut req_builder = hyper::Request::builder()
11283 .method(hyper::Method::GET)
11284 .uri(url.as_str())
11285 .header(USER_AGENT, self.hub._user_agent.clone());
11286
11287 if let Some(token) = token.as_ref() {
11288 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11289 }
11290
11291 let request = req_builder
11292 .header(CONTENT_LENGTH, 0_u64)
11293 .body(common::to_body::<String>(None));
11294
11295 client.request(request.unwrap()).await
11296 };
11297
11298 match req_result {
11299 Err(err) => {
11300 if let common::Retry::After(d) = dlg.http_error(&err) {
11301 sleep(d).await;
11302 continue;
11303 }
11304 dlg.finished(false);
11305 return Err(common::Error::HttpError(err));
11306 }
11307 Ok(res) => {
11308 let (mut parts, body) = res.into_parts();
11309 let mut body = common::Body::new(body);
11310 if !parts.status.is_success() {
11311 let bytes = common::to_bytes(body).await.unwrap_or_default();
11312 let error = serde_json::from_str(&common::to_string(&bytes));
11313 let response = common::to_response(parts, bytes.into());
11314
11315 if let common::Retry::After(d) =
11316 dlg.http_failure(&response, error.as_ref().ok())
11317 {
11318 sleep(d).await;
11319 continue;
11320 }
11321
11322 dlg.finished(false);
11323
11324 return Err(match error {
11325 Ok(value) => common::Error::BadRequest(value),
11326 _ => common::Error::Failure(response),
11327 });
11328 }
11329 let response = {
11330 let bytes = common::to_bytes(body).await.unwrap_or_default();
11331 let encoded = common::to_string(&bytes);
11332 match serde_json::from_str(&encoded) {
11333 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11334 Err(error) => {
11335 dlg.response_json_decode_error(&encoded, &error);
11336 return Err(common::Error::JsonDecodeError(
11337 encoded.to_string(),
11338 error,
11339 ));
11340 }
11341 }
11342 };
11343
11344 dlg.finished(true);
11345 return Ok(response);
11346 }
11347 }
11348 }
11349 }
11350
11351 /// Required. The name of the project to get a vulnerability summary for in the form of `projects/[PROJECT_ID]`.
11352 ///
11353 /// Sets the *parent* path property to the given value.
11354 ///
11355 /// Even though the property as already been set when instantiating this call,
11356 /// we provide this method for API completeness.
11357 pub fn parent(
11358 mut self,
11359 new_value: &str,
11360 ) -> ProjectOccurrenceGetVulnerabilitySummaryCall<'a, C> {
11361 self._parent = new_value.to_string();
11362 self
11363 }
11364 /// The filter expression.
11365 ///
11366 /// Sets the *filter* query property to the given value.
11367 pub fn filter(
11368 mut self,
11369 new_value: &str,
11370 ) -> ProjectOccurrenceGetVulnerabilitySummaryCall<'a, C> {
11371 self._filter = Some(new_value.to_string());
11372 self
11373 }
11374 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11375 /// while executing the actual API request.
11376 ///
11377 /// ````text
11378 /// It should be used to handle progress information, and to implement a certain level of resilience.
11379 /// ````
11380 ///
11381 /// Sets the *delegate* property to the given value.
11382 pub fn delegate(
11383 mut self,
11384 new_value: &'a mut dyn common::Delegate,
11385 ) -> ProjectOccurrenceGetVulnerabilitySummaryCall<'a, C> {
11386 self._delegate = Some(new_value);
11387 self
11388 }
11389
11390 /// Set any additional parameter of the query string used in the request.
11391 /// It should be used to set parameters which are not yet available through their own
11392 /// setters.
11393 ///
11394 /// Please note that this method must not be used to set any of the known parameters
11395 /// which have their own setter method. If done anyway, the request will fail.
11396 ///
11397 /// # Additional Parameters
11398 ///
11399 /// * *$.xgafv* (query-string) - V1 error format.
11400 /// * *access_token* (query-string) - OAuth access token.
11401 /// * *alt* (query-string) - Data format for response.
11402 /// * *callback* (query-string) - JSONP
11403 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11404 /// * *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.
11405 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11406 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11407 /// * *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.
11408 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11409 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11410 pub fn param<T>(
11411 mut self,
11412 name: T,
11413 value: T,
11414 ) -> ProjectOccurrenceGetVulnerabilitySummaryCall<'a, C>
11415 where
11416 T: AsRef<str>,
11417 {
11418 self._additional_params
11419 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11420 self
11421 }
11422
11423 /// Identifies the authorization scope for the method you are building.
11424 ///
11425 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11426 /// [`Scope::CloudPlatform`].
11427 ///
11428 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11429 /// tokens for more than one scope.
11430 ///
11431 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11432 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11433 /// sufficient, a read-write scope will do as well.
11434 pub fn add_scope<St>(mut self, scope: St) -> ProjectOccurrenceGetVulnerabilitySummaryCall<'a, C>
11435 where
11436 St: AsRef<str>,
11437 {
11438 self._scopes.insert(String::from(scope.as_ref()));
11439 self
11440 }
11441 /// Identifies the authorization scope(s) for the method you are building.
11442 ///
11443 /// See [`Self::add_scope()`] for details.
11444 pub fn add_scopes<I, St>(
11445 mut self,
11446 scopes: I,
11447 ) -> ProjectOccurrenceGetVulnerabilitySummaryCall<'a, C>
11448 where
11449 I: IntoIterator<Item = St>,
11450 St: AsRef<str>,
11451 {
11452 self._scopes
11453 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11454 self
11455 }
11456
11457 /// Removes all scopes, and no default scope will be used either.
11458 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11459 /// for details).
11460 pub fn clear_scopes(mut self) -> ProjectOccurrenceGetVulnerabilitySummaryCall<'a, C> {
11461 self._scopes.clear();
11462 self
11463 }
11464}
11465
11466/// Lists occurrences for the specified project.
11467///
11468/// A builder for the *occurrences.list* method supported by a *project* resource.
11469/// It is not used directly, but through a [`ProjectMethods`] instance.
11470///
11471/// # Example
11472///
11473/// Instantiate a resource method builder
11474///
11475/// ```test_harness,no_run
11476/// # extern crate hyper;
11477/// # extern crate hyper_rustls;
11478/// # extern crate google_containeranalysis1 as containeranalysis1;
11479/// # async fn dox() {
11480/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11481///
11482/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11483/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11484/// # secret,
11485/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11486/// # ).build().await.unwrap();
11487///
11488/// # let client = hyper_util::client::legacy::Client::builder(
11489/// # hyper_util::rt::TokioExecutor::new()
11490/// # )
11491/// # .build(
11492/// # hyper_rustls::HttpsConnectorBuilder::new()
11493/// # .with_native_roots()
11494/// # .unwrap()
11495/// # .https_or_http()
11496/// # .enable_http1()
11497/// # .build()
11498/// # );
11499/// # let mut hub = ContainerAnalysis::new(client, auth);
11500/// // You can configure optional parameters by calling the respective setters at will, and
11501/// // execute the final call using `doit()`.
11502/// // Values shown here are possibly random and not representative !
11503/// let result = hub.projects().occurrences_list("parent")
11504/// .page_token("sed")
11505/// .page_size(-20)
11506/// .filter("dolore")
11507/// .doit().await;
11508/// # }
11509/// ```
11510pub struct ProjectOccurrenceListCall<'a, C>
11511where
11512 C: 'a,
11513{
11514 hub: &'a ContainerAnalysis<C>,
11515 _parent: String,
11516 _page_token: Option<String>,
11517 _page_size: Option<i32>,
11518 _filter: Option<String>,
11519 _delegate: Option<&'a mut dyn common::Delegate>,
11520 _additional_params: HashMap<String, String>,
11521 _scopes: BTreeSet<String>,
11522}
11523
11524impl<'a, C> common::CallBuilder for ProjectOccurrenceListCall<'a, C> {}
11525
11526impl<'a, C> ProjectOccurrenceListCall<'a, C>
11527where
11528 C: common::Connector,
11529{
11530 /// Perform the operation you have build so far.
11531 pub async fn doit(mut self) -> common::Result<(common::Response, ListOccurrencesResponse)> {
11532 use std::borrow::Cow;
11533 use std::io::{Read, Seek};
11534
11535 use common::{url::Params, ToParts};
11536 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11537
11538 let mut dd = common::DefaultDelegate;
11539 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11540 dlg.begin(common::MethodInfo {
11541 id: "containeranalysis.projects.occurrences.list",
11542 http_method: hyper::Method::GET,
11543 });
11544
11545 for &field in ["alt", "parent", "pageToken", "pageSize", "filter"].iter() {
11546 if self._additional_params.contains_key(field) {
11547 dlg.finished(false);
11548 return Err(common::Error::FieldClash(field));
11549 }
11550 }
11551
11552 let mut params = Params::with_capacity(6 + self._additional_params.len());
11553 params.push("parent", self._parent);
11554 if let Some(value) = self._page_token.as_ref() {
11555 params.push("pageToken", value);
11556 }
11557 if let Some(value) = self._page_size.as_ref() {
11558 params.push("pageSize", value.to_string());
11559 }
11560 if let Some(value) = self._filter.as_ref() {
11561 params.push("filter", value);
11562 }
11563
11564 params.extend(self._additional_params.iter());
11565
11566 params.push("alt", "json");
11567 let mut url = self.hub._base_url.clone() + "v1/{+parent}/occurrences";
11568 if self._scopes.is_empty() {
11569 self._scopes
11570 .insert(Scope::CloudPlatform.as_ref().to_string());
11571 }
11572
11573 #[allow(clippy::single_element_loop)]
11574 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
11575 url = params.uri_replacement(url, param_name, find_this, true);
11576 }
11577 {
11578 let to_remove = ["parent"];
11579 params.remove_params(&to_remove);
11580 }
11581
11582 let url = params.parse_with_url(&url);
11583
11584 loop {
11585 let token = match self
11586 .hub
11587 .auth
11588 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11589 .await
11590 {
11591 Ok(token) => token,
11592 Err(e) => match dlg.token(e) {
11593 Ok(token) => token,
11594 Err(e) => {
11595 dlg.finished(false);
11596 return Err(common::Error::MissingToken(e));
11597 }
11598 },
11599 };
11600 let mut req_result = {
11601 let client = &self.hub.client;
11602 dlg.pre_request();
11603 let mut req_builder = hyper::Request::builder()
11604 .method(hyper::Method::GET)
11605 .uri(url.as_str())
11606 .header(USER_AGENT, self.hub._user_agent.clone());
11607
11608 if let Some(token) = token.as_ref() {
11609 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11610 }
11611
11612 let request = req_builder
11613 .header(CONTENT_LENGTH, 0_u64)
11614 .body(common::to_body::<String>(None));
11615
11616 client.request(request.unwrap()).await
11617 };
11618
11619 match req_result {
11620 Err(err) => {
11621 if let common::Retry::After(d) = dlg.http_error(&err) {
11622 sleep(d).await;
11623 continue;
11624 }
11625 dlg.finished(false);
11626 return Err(common::Error::HttpError(err));
11627 }
11628 Ok(res) => {
11629 let (mut parts, body) = res.into_parts();
11630 let mut body = common::Body::new(body);
11631 if !parts.status.is_success() {
11632 let bytes = common::to_bytes(body).await.unwrap_or_default();
11633 let error = serde_json::from_str(&common::to_string(&bytes));
11634 let response = common::to_response(parts, bytes.into());
11635
11636 if let common::Retry::After(d) =
11637 dlg.http_failure(&response, error.as_ref().ok())
11638 {
11639 sleep(d).await;
11640 continue;
11641 }
11642
11643 dlg.finished(false);
11644
11645 return Err(match error {
11646 Ok(value) => common::Error::BadRequest(value),
11647 _ => common::Error::Failure(response),
11648 });
11649 }
11650 let response = {
11651 let bytes = common::to_bytes(body).await.unwrap_or_default();
11652 let encoded = common::to_string(&bytes);
11653 match serde_json::from_str(&encoded) {
11654 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11655 Err(error) => {
11656 dlg.response_json_decode_error(&encoded, &error);
11657 return Err(common::Error::JsonDecodeError(
11658 encoded.to_string(),
11659 error,
11660 ));
11661 }
11662 }
11663 };
11664
11665 dlg.finished(true);
11666 return Ok(response);
11667 }
11668 }
11669 }
11670 }
11671
11672 /// Required. The name of the project to list occurrences for in the form of `projects/[PROJECT_ID]`.
11673 ///
11674 /// Sets the *parent* path property to the given value.
11675 ///
11676 /// Even though the property as already been set when instantiating this call,
11677 /// we provide this method for API completeness.
11678 pub fn parent(mut self, new_value: &str) -> ProjectOccurrenceListCall<'a, C> {
11679 self._parent = new_value.to_string();
11680 self
11681 }
11682 /// Token to provide to skip to a particular spot in the list.
11683 ///
11684 /// Sets the *page token* query property to the given value.
11685 pub fn page_token(mut self, new_value: &str) -> ProjectOccurrenceListCall<'a, C> {
11686 self._page_token = Some(new_value.to_string());
11687 self
11688 }
11689 /// Number of occurrences to return in the list. Must be positive. Max allowed page size is 1000. If not specified, page size defaults to 20.
11690 ///
11691 /// Sets the *page size* query property to the given value.
11692 pub fn page_size(mut self, new_value: i32) -> ProjectOccurrenceListCall<'a, C> {
11693 self._page_size = Some(new_value);
11694 self
11695 }
11696 /// The filter expression.
11697 ///
11698 /// Sets the *filter* query property to the given value.
11699 pub fn filter(mut self, new_value: &str) -> ProjectOccurrenceListCall<'a, C> {
11700 self._filter = Some(new_value.to_string());
11701 self
11702 }
11703 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11704 /// while executing the actual API request.
11705 ///
11706 /// ````text
11707 /// It should be used to handle progress information, and to implement a certain level of resilience.
11708 /// ````
11709 ///
11710 /// Sets the *delegate* property to the given value.
11711 pub fn delegate(
11712 mut self,
11713 new_value: &'a mut dyn common::Delegate,
11714 ) -> ProjectOccurrenceListCall<'a, C> {
11715 self._delegate = Some(new_value);
11716 self
11717 }
11718
11719 /// Set any additional parameter of the query string used in the request.
11720 /// It should be used to set parameters which are not yet available through their own
11721 /// setters.
11722 ///
11723 /// Please note that this method must not be used to set any of the known parameters
11724 /// which have their own setter method. If done anyway, the request will fail.
11725 ///
11726 /// # Additional Parameters
11727 ///
11728 /// * *$.xgafv* (query-string) - V1 error format.
11729 /// * *access_token* (query-string) - OAuth access token.
11730 /// * *alt* (query-string) - Data format for response.
11731 /// * *callback* (query-string) - JSONP
11732 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11733 /// * *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.
11734 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11735 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11736 /// * *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.
11737 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11738 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11739 pub fn param<T>(mut self, name: T, value: T) -> ProjectOccurrenceListCall<'a, C>
11740 where
11741 T: AsRef<str>,
11742 {
11743 self._additional_params
11744 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11745 self
11746 }
11747
11748 /// Identifies the authorization scope for the method you are building.
11749 ///
11750 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11751 /// [`Scope::CloudPlatform`].
11752 ///
11753 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11754 /// tokens for more than one scope.
11755 ///
11756 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11757 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11758 /// sufficient, a read-write scope will do as well.
11759 pub fn add_scope<St>(mut self, scope: St) -> ProjectOccurrenceListCall<'a, C>
11760 where
11761 St: AsRef<str>,
11762 {
11763 self._scopes.insert(String::from(scope.as_ref()));
11764 self
11765 }
11766 /// Identifies the authorization scope(s) for the method you are building.
11767 ///
11768 /// See [`Self::add_scope()`] for details.
11769 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectOccurrenceListCall<'a, C>
11770 where
11771 I: IntoIterator<Item = St>,
11772 St: AsRef<str>,
11773 {
11774 self._scopes
11775 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11776 self
11777 }
11778
11779 /// Removes all scopes, and no default scope will be used either.
11780 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11781 /// for details).
11782 pub fn clear_scopes(mut self) -> ProjectOccurrenceListCall<'a, C> {
11783 self._scopes.clear();
11784 self
11785 }
11786}
11787
11788/// Updates the specified occurrence.
11789///
11790/// A builder for the *occurrences.patch* method supported by a *project* resource.
11791/// It is not used directly, but through a [`ProjectMethods`] instance.
11792///
11793/// # Example
11794///
11795/// Instantiate a resource method builder
11796///
11797/// ```test_harness,no_run
11798/// # extern crate hyper;
11799/// # extern crate hyper_rustls;
11800/// # extern crate google_containeranalysis1 as containeranalysis1;
11801/// use containeranalysis1::api::Occurrence;
11802/// # async fn dox() {
11803/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11804///
11805/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11806/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
11807/// # secret,
11808/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11809/// # ).build().await.unwrap();
11810///
11811/// # let client = hyper_util::client::legacy::Client::builder(
11812/// # hyper_util::rt::TokioExecutor::new()
11813/// # )
11814/// # .build(
11815/// # hyper_rustls::HttpsConnectorBuilder::new()
11816/// # .with_native_roots()
11817/// # .unwrap()
11818/// # .https_or_http()
11819/// # .enable_http1()
11820/// # .build()
11821/// # );
11822/// # let mut hub = ContainerAnalysis::new(client, auth);
11823/// // As the method needs a request, you would usually fill it with the desired information
11824/// // into the respective structure. Some of the parts shown here might not be applicable !
11825/// // Values shown here are possibly random and not representative !
11826/// let mut req = Occurrence::default();
11827///
11828/// // You can configure optional parameters by calling the respective setters at will, and
11829/// // execute the final call using `doit()`.
11830/// // Values shown here are possibly random and not representative !
11831/// let result = hub.projects().occurrences_patch(req, "name")
11832/// .update_mask(FieldMask::new::<&str>(&[]))
11833/// .doit().await;
11834/// # }
11835/// ```
11836pub struct ProjectOccurrencePatchCall<'a, C>
11837where
11838 C: 'a,
11839{
11840 hub: &'a ContainerAnalysis<C>,
11841 _request: Occurrence,
11842 _name: String,
11843 _update_mask: Option<common::FieldMask>,
11844 _delegate: Option<&'a mut dyn common::Delegate>,
11845 _additional_params: HashMap<String, String>,
11846 _scopes: BTreeSet<String>,
11847}
11848
11849impl<'a, C> common::CallBuilder for ProjectOccurrencePatchCall<'a, C> {}
11850
11851impl<'a, C> ProjectOccurrencePatchCall<'a, C>
11852where
11853 C: common::Connector,
11854{
11855 /// Perform the operation you have build so far.
11856 pub async fn doit(mut self) -> common::Result<(common::Response, Occurrence)> {
11857 use std::borrow::Cow;
11858 use std::io::{Read, Seek};
11859
11860 use common::{url::Params, ToParts};
11861 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11862
11863 let mut dd = common::DefaultDelegate;
11864 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11865 dlg.begin(common::MethodInfo {
11866 id: "containeranalysis.projects.occurrences.patch",
11867 http_method: hyper::Method::PATCH,
11868 });
11869
11870 for &field in ["alt", "name", "updateMask"].iter() {
11871 if self._additional_params.contains_key(field) {
11872 dlg.finished(false);
11873 return Err(common::Error::FieldClash(field));
11874 }
11875 }
11876
11877 let mut params = Params::with_capacity(5 + self._additional_params.len());
11878 params.push("name", self._name);
11879 if let Some(value) = self._update_mask.as_ref() {
11880 params.push("updateMask", value.to_string());
11881 }
11882
11883 params.extend(self._additional_params.iter());
11884
11885 params.push("alt", "json");
11886 let mut url = self.hub._base_url.clone() + "v1/{+name}";
11887 if self._scopes.is_empty() {
11888 self._scopes
11889 .insert(Scope::CloudPlatform.as_ref().to_string());
11890 }
11891
11892 #[allow(clippy::single_element_loop)]
11893 for &(find_this, param_name) in [("{+name}", "name")].iter() {
11894 url = params.uri_replacement(url, param_name, find_this, true);
11895 }
11896 {
11897 let to_remove = ["name"];
11898 params.remove_params(&to_remove);
11899 }
11900
11901 let url = params.parse_with_url(&url);
11902
11903 let mut json_mime_type = mime::APPLICATION_JSON;
11904 let mut request_value_reader = {
11905 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11906 common::remove_json_null_values(&mut value);
11907 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11908 serde_json::to_writer(&mut dst, &value).unwrap();
11909 dst
11910 };
11911 let request_size = request_value_reader
11912 .seek(std::io::SeekFrom::End(0))
11913 .unwrap();
11914 request_value_reader
11915 .seek(std::io::SeekFrom::Start(0))
11916 .unwrap();
11917
11918 loop {
11919 let token = match self
11920 .hub
11921 .auth
11922 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11923 .await
11924 {
11925 Ok(token) => token,
11926 Err(e) => match dlg.token(e) {
11927 Ok(token) => token,
11928 Err(e) => {
11929 dlg.finished(false);
11930 return Err(common::Error::MissingToken(e));
11931 }
11932 },
11933 };
11934 request_value_reader
11935 .seek(std::io::SeekFrom::Start(0))
11936 .unwrap();
11937 let mut req_result = {
11938 let client = &self.hub.client;
11939 dlg.pre_request();
11940 let mut req_builder = hyper::Request::builder()
11941 .method(hyper::Method::PATCH)
11942 .uri(url.as_str())
11943 .header(USER_AGENT, self.hub._user_agent.clone());
11944
11945 if let Some(token) = token.as_ref() {
11946 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11947 }
11948
11949 let request = req_builder
11950 .header(CONTENT_TYPE, json_mime_type.to_string())
11951 .header(CONTENT_LENGTH, request_size as u64)
11952 .body(common::to_body(
11953 request_value_reader.get_ref().clone().into(),
11954 ));
11955
11956 client.request(request.unwrap()).await
11957 };
11958
11959 match req_result {
11960 Err(err) => {
11961 if let common::Retry::After(d) = dlg.http_error(&err) {
11962 sleep(d).await;
11963 continue;
11964 }
11965 dlg.finished(false);
11966 return Err(common::Error::HttpError(err));
11967 }
11968 Ok(res) => {
11969 let (mut parts, body) = res.into_parts();
11970 let mut body = common::Body::new(body);
11971 if !parts.status.is_success() {
11972 let bytes = common::to_bytes(body).await.unwrap_or_default();
11973 let error = serde_json::from_str(&common::to_string(&bytes));
11974 let response = common::to_response(parts, bytes.into());
11975
11976 if let common::Retry::After(d) =
11977 dlg.http_failure(&response, error.as_ref().ok())
11978 {
11979 sleep(d).await;
11980 continue;
11981 }
11982
11983 dlg.finished(false);
11984
11985 return Err(match error {
11986 Ok(value) => common::Error::BadRequest(value),
11987 _ => common::Error::Failure(response),
11988 });
11989 }
11990 let response = {
11991 let bytes = common::to_bytes(body).await.unwrap_or_default();
11992 let encoded = common::to_string(&bytes);
11993 match serde_json::from_str(&encoded) {
11994 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11995 Err(error) => {
11996 dlg.response_json_decode_error(&encoded, &error);
11997 return Err(common::Error::JsonDecodeError(
11998 encoded.to_string(),
11999 error,
12000 ));
12001 }
12002 }
12003 };
12004
12005 dlg.finished(true);
12006 return Ok(response);
12007 }
12008 }
12009 }
12010 }
12011
12012 ///
12013 /// Sets the *request* property to the given value.
12014 ///
12015 /// Even though the property as already been set when instantiating this call,
12016 /// we provide this method for API completeness.
12017 pub fn request(mut self, new_value: Occurrence) -> ProjectOccurrencePatchCall<'a, C> {
12018 self._request = new_value;
12019 self
12020 }
12021 /// Required. The name of the occurrence in the form of `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.
12022 ///
12023 /// Sets the *name* path property to the given value.
12024 ///
12025 /// Even though the property as already been set when instantiating this call,
12026 /// we provide this method for API completeness.
12027 pub fn name(mut self, new_value: &str) -> ProjectOccurrencePatchCall<'a, C> {
12028 self._name = new_value.to_string();
12029 self
12030 }
12031 /// The fields to update.
12032 ///
12033 /// Sets the *update mask* query property to the given value.
12034 pub fn update_mask(
12035 mut self,
12036 new_value: common::FieldMask,
12037 ) -> ProjectOccurrencePatchCall<'a, C> {
12038 self._update_mask = Some(new_value);
12039 self
12040 }
12041 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12042 /// while executing the actual API request.
12043 ///
12044 /// ````text
12045 /// It should be used to handle progress information, and to implement a certain level of resilience.
12046 /// ````
12047 ///
12048 /// Sets the *delegate* property to the given value.
12049 pub fn delegate(
12050 mut self,
12051 new_value: &'a mut dyn common::Delegate,
12052 ) -> ProjectOccurrencePatchCall<'a, C> {
12053 self._delegate = Some(new_value);
12054 self
12055 }
12056
12057 /// Set any additional parameter of the query string used in the request.
12058 /// It should be used to set parameters which are not yet available through their own
12059 /// setters.
12060 ///
12061 /// Please note that this method must not be used to set any of the known parameters
12062 /// which have their own setter method. If done anyway, the request will fail.
12063 ///
12064 /// # Additional Parameters
12065 ///
12066 /// * *$.xgafv* (query-string) - V1 error format.
12067 /// * *access_token* (query-string) - OAuth access token.
12068 /// * *alt* (query-string) - Data format for response.
12069 /// * *callback* (query-string) - JSONP
12070 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12071 /// * *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.
12072 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12073 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12074 /// * *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.
12075 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12076 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12077 pub fn param<T>(mut self, name: T, value: T) -> ProjectOccurrencePatchCall<'a, C>
12078 where
12079 T: AsRef<str>,
12080 {
12081 self._additional_params
12082 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12083 self
12084 }
12085
12086 /// Identifies the authorization scope for the method you are building.
12087 ///
12088 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12089 /// [`Scope::CloudPlatform`].
12090 ///
12091 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12092 /// tokens for more than one scope.
12093 ///
12094 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12095 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12096 /// sufficient, a read-write scope will do as well.
12097 pub fn add_scope<St>(mut self, scope: St) -> ProjectOccurrencePatchCall<'a, C>
12098 where
12099 St: AsRef<str>,
12100 {
12101 self._scopes.insert(String::from(scope.as_ref()));
12102 self
12103 }
12104 /// Identifies the authorization scope(s) for the method you are building.
12105 ///
12106 /// See [`Self::add_scope()`] for details.
12107 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectOccurrencePatchCall<'a, C>
12108 where
12109 I: IntoIterator<Item = St>,
12110 St: AsRef<str>,
12111 {
12112 self._scopes
12113 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12114 self
12115 }
12116
12117 /// Removes all scopes, and no default scope will be used either.
12118 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12119 /// for details).
12120 pub fn clear_scopes(mut self) -> ProjectOccurrencePatchCall<'a, C> {
12121 self._scopes.clear();
12122 self
12123 }
12124}
12125
12126/// Sets the access control policy on the specified note or occurrence. Requires `containeranalysis.notes.setIamPolicy` or `containeranalysis.occurrences.setIamPolicy` permission if the resource is a note or an occurrence, respectively. The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
12127///
12128/// A builder for the *occurrences.setIamPolicy* method supported by a *project* resource.
12129/// It is not used directly, but through a [`ProjectMethods`] instance.
12130///
12131/// # Example
12132///
12133/// Instantiate a resource method builder
12134///
12135/// ```test_harness,no_run
12136/// # extern crate hyper;
12137/// # extern crate hyper_rustls;
12138/// # extern crate google_containeranalysis1 as containeranalysis1;
12139/// use containeranalysis1::api::SetIamPolicyRequest;
12140/// # async fn dox() {
12141/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12142///
12143/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12144/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12145/// # secret,
12146/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12147/// # ).build().await.unwrap();
12148///
12149/// # let client = hyper_util::client::legacy::Client::builder(
12150/// # hyper_util::rt::TokioExecutor::new()
12151/// # )
12152/// # .build(
12153/// # hyper_rustls::HttpsConnectorBuilder::new()
12154/// # .with_native_roots()
12155/// # .unwrap()
12156/// # .https_or_http()
12157/// # .enable_http1()
12158/// # .build()
12159/// # );
12160/// # let mut hub = ContainerAnalysis::new(client, auth);
12161/// // As the method needs a request, you would usually fill it with the desired information
12162/// // into the respective structure. Some of the parts shown here might not be applicable !
12163/// // Values shown here are possibly random and not representative !
12164/// let mut req = SetIamPolicyRequest::default();
12165///
12166/// // You can configure optional parameters by calling the respective setters at will, and
12167/// // execute the final call using `doit()`.
12168/// // Values shown here are possibly random and not representative !
12169/// let result = hub.projects().occurrences_set_iam_policy(req, "resource")
12170/// .doit().await;
12171/// # }
12172/// ```
12173pub struct ProjectOccurrenceSetIamPolicyCall<'a, C>
12174where
12175 C: 'a,
12176{
12177 hub: &'a ContainerAnalysis<C>,
12178 _request: SetIamPolicyRequest,
12179 _resource: String,
12180 _delegate: Option<&'a mut dyn common::Delegate>,
12181 _additional_params: HashMap<String, String>,
12182 _scopes: BTreeSet<String>,
12183}
12184
12185impl<'a, C> common::CallBuilder for ProjectOccurrenceSetIamPolicyCall<'a, C> {}
12186
12187impl<'a, C> ProjectOccurrenceSetIamPolicyCall<'a, C>
12188where
12189 C: common::Connector,
12190{
12191 /// Perform the operation you have build so far.
12192 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
12193 use std::borrow::Cow;
12194 use std::io::{Read, Seek};
12195
12196 use common::{url::Params, ToParts};
12197 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12198
12199 let mut dd = common::DefaultDelegate;
12200 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12201 dlg.begin(common::MethodInfo {
12202 id: "containeranalysis.projects.occurrences.setIamPolicy",
12203 http_method: hyper::Method::POST,
12204 });
12205
12206 for &field in ["alt", "resource"].iter() {
12207 if self._additional_params.contains_key(field) {
12208 dlg.finished(false);
12209 return Err(common::Error::FieldClash(field));
12210 }
12211 }
12212
12213 let mut params = Params::with_capacity(4 + self._additional_params.len());
12214 params.push("resource", self._resource);
12215
12216 params.extend(self._additional_params.iter());
12217
12218 params.push("alt", "json");
12219 let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
12220 if self._scopes.is_empty() {
12221 self._scopes
12222 .insert(Scope::CloudPlatform.as_ref().to_string());
12223 }
12224
12225 #[allow(clippy::single_element_loop)]
12226 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
12227 url = params.uri_replacement(url, param_name, find_this, true);
12228 }
12229 {
12230 let to_remove = ["resource"];
12231 params.remove_params(&to_remove);
12232 }
12233
12234 let url = params.parse_with_url(&url);
12235
12236 let mut json_mime_type = mime::APPLICATION_JSON;
12237 let mut request_value_reader = {
12238 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12239 common::remove_json_null_values(&mut value);
12240 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12241 serde_json::to_writer(&mut dst, &value).unwrap();
12242 dst
12243 };
12244 let request_size = request_value_reader
12245 .seek(std::io::SeekFrom::End(0))
12246 .unwrap();
12247 request_value_reader
12248 .seek(std::io::SeekFrom::Start(0))
12249 .unwrap();
12250
12251 loop {
12252 let token = match self
12253 .hub
12254 .auth
12255 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12256 .await
12257 {
12258 Ok(token) => token,
12259 Err(e) => match dlg.token(e) {
12260 Ok(token) => token,
12261 Err(e) => {
12262 dlg.finished(false);
12263 return Err(common::Error::MissingToken(e));
12264 }
12265 },
12266 };
12267 request_value_reader
12268 .seek(std::io::SeekFrom::Start(0))
12269 .unwrap();
12270 let mut req_result = {
12271 let client = &self.hub.client;
12272 dlg.pre_request();
12273 let mut req_builder = hyper::Request::builder()
12274 .method(hyper::Method::POST)
12275 .uri(url.as_str())
12276 .header(USER_AGENT, self.hub._user_agent.clone());
12277
12278 if let Some(token) = token.as_ref() {
12279 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12280 }
12281
12282 let request = req_builder
12283 .header(CONTENT_TYPE, json_mime_type.to_string())
12284 .header(CONTENT_LENGTH, request_size as u64)
12285 .body(common::to_body(
12286 request_value_reader.get_ref().clone().into(),
12287 ));
12288
12289 client.request(request.unwrap()).await
12290 };
12291
12292 match req_result {
12293 Err(err) => {
12294 if let common::Retry::After(d) = dlg.http_error(&err) {
12295 sleep(d).await;
12296 continue;
12297 }
12298 dlg.finished(false);
12299 return Err(common::Error::HttpError(err));
12300 }
12301 Ok(res) => {
12302 let (mut parts, body) = res.into_parts();
12303 let mut body = common::Body::new(body);
12304 if !parts.status.is_success() {
12305 let bytes = common::to_bytes(body).await.unwrap_or_default();
12306 let error = serde_json::from_str(&common::to_string(&bytes));
12307 let response = common::to_response(parts, bytes.into());
12308
12309 if let common::Retry::After(d) =
12310 dlg.http_failure(&response, error.as_ref().ok())
12311 {
12312 sleep(d).await;
12313 continue;
12314 }
12315
12316 dlg.finished(false);
12317
12318 return Err(match error {
12319 Ok(value) => common::Error::BadRequest(value),
12320 _ => common::Error::Failure(response),
12321 });
12322 }
12323 let response = {
12324 let bytes = common::to_bytes(body).await.unwrap_or_default();
12325 let encoded = common::to_string(&bytes);
12326 match serde_json::from_str(&encoded) {
12327 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12328 Err(error) => {
12329 dlg.response_json_decode_error(&encoded, &error);
12330 return Err(common::Error::JsonDecodeError(
12331 encoded.to_string(),
12332 error,
12333 ));
12334 }
12335 }
12336 };
12337
12338 dlg.finished(true);
12339 return Ok(response);
12340 }
12341 }
12342 }
12343 }
12344
12345 ///
12346 /// Sets the *request* property to the given value.
12347 ///
12348 /// Even though the property as already been set when instantiating this call,
12349 /// we provide this method for API completeness.
12350 pub fn request(
12351 mut self,
12352 new_value: SetIamPolicyRequest,
12353 ) -> ProjectOccurrenceSetIamPolicyCall<'a, C> {
12354 self._request = new_value;
12355 self
12356 }
12357 /// REQUIRED: The resource for which the policy is being specified. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
12358 ///
12359 /// Sets the *resource* path property to the given value.
12360 ///
12361 /// Even though the property as already been set when instantiating this call,
12362 /// we provide this method for API completeness.
12363 pub fn resource(mut self, new_value: &str) -> ProjectOccurrenceSetIamPolicyCall<'a, C> {
12364 self._resource = new_value.to_string();
12365 self
12366 }
12367 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12368 /// while executing the actual API request.
12369 ///
12370 /// ````text
12371 /// It should be used to handle progress information, and to implement a certain level of resilience.
12372 /// ````
12373 ///
12374 /// Sets the *delegate* property to the given value.
12375 pub fn delegate(
12376 mut self,
12377 new_value: &'a mut dyn common::Delegate,
12378 ) -> ProjectOccurrenceSetIamPolicyCall<'a, C> {
12379 self._delegate = Some(new_value);
12380 self
12381 }
12382
12383 /// Set any additional parameter of the query string used in the request.
12384 /// It should be used to set parameters which are not yet available through their own
12385 /// setters.
12386 ///
12387 /// Please note that this method must not be used to set any of the known parameters
12388 /// which have their own setter method. If done anyway, the request will fail.
12389 ///
12390 /// # Additional Parameters
12391 ///
12392 /// * *$.xgafv* (query-string) - V1 error format.
12393 /// * *access_token* (query-string) - OAuth access token.
12394 /// * *alt* (query-string) - Data format for response.
12395 /// * *callback* (query-string) - JSONP
12396 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12397 /// * *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.
12398 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12399 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12400 /// * *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.
12401 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12402 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12403 pub fn param<T>(mut self, name: T, value: T) -> ProjectOccurrenceSetIamPolicyCall<'a, C>
12404 where
12405 T: AsRef<str>,
12406 {
12407 self._additional_params
12408 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12409 self
12410 }
12411
12412 /// Identifies the authorization scope for the method you are building.
12413 ///
12414 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12415 /// [`Scope::CloudPlatform`].
12416 ///
12417 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12418 /// tokens for more than one scope.
12419 ///
12420 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12421 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12422 /// sufficient, a read-write scope will do as well.
12423 pub fn add_scope<St>(mut self, scope: St) -> ProjectOccurrenceSetIamPolicyCall<'a, C>
12424 where
12425 St: AsRef<str>,
12426 {
12427 self._scopes.insert(String::from(scope.as_ref()));
12428 self
12429 }
12430 /// Identifies the authorization scope(s) for the method you are building.
12431 ///
12432 /// See [`Self::add_scope()`] for details.
12433 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectOccurrenceSetIamPolicyCall<'a, C>
12434 where
12435 I: IntoIterator<Item = St>,
12436 St: AsRef<str>,
12437 {
12438 self._scopes
12439 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12440 self
12441 }
12442
12443 /// Removes all scopes, and no default scope will be used either.
12444 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12445 /// for details).
12446 pub fn clear_scopes(mut self) -> ProjectOccurrenceSetIamPolicyCall<'a, C> {
12447 self._scopes.clear();
12448 self
12449 }
12450}
12451
12452/// Returns the permissions that a caller has on the specified note or occurrence. Requires list permission on the project (for example, `containeranalysis.notes.list`). The resource takes the format `projects/[PROJECT_ID]/notes/[NOTE_ID]` for notes and `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]` for occurrences.
12453///
12454/// A builder for the *occurrences.testIamPermissions* method supported by a *project* resource.
12455/// It is not used directly, but through a [`ProjectMethods`] instance.
12456///
12457/// # Example
12458///
12459/// Instantiate a resource method builder
12460///
12461/// ```test_harness,no_run
12462/// # extern crate hyper;
12463/// # extern crate hyper_rustls;
12464/// # extern crate google_containeranalysis1 as containeranalysis1;
12465/// use containeranalysis1::api::TestIamPermissionsRequest;
12466/// # async fn dox() {
12467/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12468///
12469/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12470/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12471/// # secret,
12472/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12473/// # ).build().await.unwrap();
12474///
12475/// # let client = hyper_util::client::legacy::Client::builder(
12476/// # hyper_util::rt::TokioExecutor::new()
12477/// # )
12478/// # .build(
12479/// # hyper_rustls::HttpsConnectorBuilder::new()
12480/// # .with_native_roots()
12481/// # .unwrap()
12482/// # .https_or_http()
12483/// # .enable_http1()
12484/// # .build()
12485/// # );
12486/// # let mut hub = ContainerAnalysis::new(client, auth);
12487/// // As the method needs a request, you would usually fill it with the desired information
12488/// // into the respective structure. Some of the parts shown here might not be applicable !
12489/// // Values shown here are possibly random and not representative !
12490/// let mut req = TestIamPermissionsRequest::default();
12491///
12492/// // You can configure optional parameters by calling the respective setters at will, and
12493/// // execute the final call using `doit()`.
12494/// // Values shown here are possibly random and not representative !
12495/// let result = hub.projects().occurrences_test_iam_permissions(req, "resource")
12496/// .doit().await;
12497/// # }
12498/// ```
12499pub struct ProjectOccurrenceTestIamPermissionCall<'a, C>
12500where
12501 C: 'a,
12502{
12503 hub: &'a ContainerAnalysis<C>,
12504 _request: TestIamPermissionsRequest,
12505 _resource: String,
12506 _delegate: Option<&'a mut dyn common::Delegate>,
12507 _additional_params: HashMap<String, String>,
12508 _scopes: BTreeSet<String>,
12509}
12510
12511impl<'a, C> common::CallBuilder for ProjectOccurrenceTestIamPermissionCall<'a, C> {}
12512
12513impl<'a, C> ProjectOccurrenceTestIamPermissionCall<'a, C>
12514where
12515 C: common::Connector,
12516{
12517 /// Perform the operation you have build so far.
12518 pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
12519 use std::borrow::Cow;
12520 use std::io::{Read, Seek};
12521
12522 use common::{url::Params, ToParts};
12523 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12524
12525 let mut dd = common::DefaultDelegate;
12526 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12527 dlg.begin(common::MethodInfo {
12528 id: "containeranalysis.projects.occurrences.testIamPermissions",
12529 http_method: hyper::Method::POST,
12530 });
12531
12532 for &field in ["alt", "resource"].iter() {
12533 if self._additional_params.contains_key(field) {
12534 dlg.finished(false);
12535 return Err(common::Error::FieldClash(field));
12536 }
12537 }
12538
12539 let mut params = Params::with_capacity(4 + self._additional_params.len());
12540 params.push("resource", self._resource);
12541
12542 params.extend(self._additional_params.iter());
12543
12544 params.push("alt", "json");
12545 let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
12546 if self._scopes.is_empty() {
12547 self._scopes
12548 .insert(Scope::CloudPlatform.as_ref().to_string());
12549 }
12550
12551 #[allow(clippy::single_element_loop)]
12552 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
12553 url = params.uri_replacement(url, param_name, find_this, true);
12554 }
12555 {
12556 let to_remove = ["resource"];
12557 params.remove_params(&to_remove);
12558 }
12559
12560 let url = params.parse_with_url(&url);
12561
12562 let mut json_mime_type = mime::APPLICATION_JSON;
12563 let mut request_value_reader = {
12564 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12565 common::remove_json_null_values(&mut value);
12566 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12567 serde_json::to_writer(&mut dst, &value).unwrap();
12568 dst
12569 };
12570 let request_size = request_value_reader
12571 .seek(std::io::SeekFrom::End(0))
12572 .unwrap();
12573 request_value_reader
12574 .seek(std::io::SeekFrom::Start(0))
12575 .unwrap();
12576
12577 loop {
12578 let token = match self
12579 .hub
12580 .auth
12581 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12582 .await
12583 {
12584 Ok(token) => token,
12585 Err(e) => match dlg.token(e) {
12586 Ok(token) => token,
12587 Err(e) => {
12588 dlg.finished(false);
12589 return Err(common::Error::MissingToken(e));
12590 }
12591 },
12592 };
12593 request_value_reader
12594 .seek(std::io::SeekFrom::Start(0))
12595 .unwrap();
12596 let mut req_result = {
12597 let client = &self.hub.client;
12598 dlg.pre_request();
12599 let mut req_builder = hyper::Request::builder()
12600 .method(hyper::Method::POST)
12601 .uri(url.as_str())
12602 .header(USER_AGENT, self.hub._user_agent.clone());
12603
12604 if let Some(token) = token.as_ref() {
12605 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12606 }
12607
12608 let request = req_builder
12609 .header(CONTENT_TYPE, json_mime_type.to_string())
12610 .header(CONTENT_LENGTH, request_size as u64)
12611 .body(common::to_body(
12612 request_value_reader.get_ref().clone().into(),
12613 ));
12614
12615 client.request(request.unwrap()).await
12616 };
12617
12618 match req_result {
12619 Err(err) => {
12620 if let common::Retry::After(d) = dlg.http_error(&err) {
12621 sleep(d).await;
12622 continue;
12623 }
12624 dlg.finished(false);
12625 return Err(common::Error::HttpError(err));
12626 }
12627 Ok(res) => {
12628 let (mut parts, body) = res.into_parts();
12629 let mut body = common::Body::new(body);
12630 if !parts.status.is_success() {
12631 let bytes = common::to_bytes(body).await.unwrap_or_default();
12632 let error = serde_json::from_str(&common::to_string(&bytes));
12633 let response = common::to_response(parts, bytes.into());
12634
12635 if let common::Retry::After(d) =
12636 dlg.http_failure(&response, error.as_ref().ok())
12637 {
12638 sleep(d).await;
12639 continue;
12640 }
12641
12642 dlg.finished(false);
12643
12644 return Err(match error {
12645 Ok(value) => common::Error::BadRequest(value),
12646 _ => common::Error::Failure(response),
12647 });
12648 }
12649 let response = {
12650 let bytes = common::to_bytes(body).await.unwrap_or_default();
12651 let encoded = common::to_string(&bytes);
12652 match serde_json::from_str(&encoded) {
12653 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12654 Err(error) => {
12655 dlg.response_json_decode_error(&encoded, &error);
12656 return Err(common::Error::JsonDecodeError(
12657 encoded.to_string(),
12658 error,
12659 ));
12660 }
12661 }
12662 };
12663
12664 dlg.finished(true);
12665 return Ok(response);
12666 }
12667 }
12668 }
12669 }
12670
12671 ///
12672 /// Sets the *request* property to the given value.
12673 ///
12674 /// Even though the property as already been set when instantiating this call,
12675 /// we provide this method for API completeness.
12676 pub fn request(
12677 mut self,
12678 new_value: TestIamPermissionsRequest,
12679 ) -> ProjectOccurrenceTestIamPermissionCall<'a, C> {
12680 self._request = new_value;
12681 self
12682 }
12683 /// REQUIRED: The resource for which the policy detail is being requested. See [Resource names](https://cloud.google.com/apis/design/resource_names) for the appropriate value for this field.
12684 ///
12685 /// Sets the *resource* path property to the given value.
12686 ///
12687 /// Even though the property as already been set when instantiating this call,
12688 /// we provide this method for API completeness.
12689 pub fn resource(mut self, new_value: &str) -> ProjectOccurrenceTestIamPermissionCall<'a, C> {
12690 self._resource = new_value.to_string();
12691 self
12692 }
12693 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12694 /// while executing the actual API request.
12695 ///
12696 /// ````text
12697 /// It should be used to handle progress information, and to implement a certain level of resilience.
12698 /// ````
12699 ///
12700 /// Sets the *delegate* property to the given value.
12701 pub fn delegate(
12702 mut self,
12703 new_value: &'a mut dyn common::Delegate,
12704 ) -> ProjectOccurrenceTestIamPermissionCall<'a, C> {
12705 self._delegate = Some(new_value);
12706 self
12707 }
12708
12709 /// Set any additional parameter of the query string used in the request.
12710 /// It should be used to set parameters which are not yet available through their own
12711 /// setters.
12712 ///
12713 /// Please note that this method must not be used to set any of the known parameters
12714 /// which have their own setter method. If done anyway, the request will fail.
12715 ///
12716 /// # Additional Parameters
12717 ///
12718 /// * *$.xgafv* (query-string) - V1 error format.
12719 /// * *access_token* (query-string) - OAuth access token.
12720 /// * *alt* (query-string) - Data format for response.
12721 /// * *callback* (query-string) - JSONP
12722 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12723 /// * *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.
12724 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12725 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12726 /// * *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.
12727 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12728 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12729 pub fn param<T>(mut self, name: T, value: T) -> ProjectOccurrenceTestIamPermissionCall<'a, C>
12730 where
12731 T: AsRef<str>,
12732 {
12733 self._additional_params
12734 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12735 self
12736 }
12737
12738 /// Identifies the authorization scope for the method you are building.
12739 ///
12740 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12741 /// [`Scope::CloudPlatform`].
12742 ///
12743 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12744 /// tokens for more than one scope.
12745 ///
12746 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12747 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12748 /// sufficient, a read-write scope will do as well.
12749 pub fn add_scope<St>(mut self, scope: St) -> ProjectOccurrenceTestIamPermissionCall<'a, C>
12750 where
12751 St: AsRef<str>,
12752 {
12753 self._scopes.insert(String::from(scope.as_ref()));
12754 self
12755 }
12756 /// Identifies the authorization scope(s) for the method you are building.
12757 ///
12758 /// See [`Self::add_scope()`] for details.
12759 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectOccurrenceTestIamPermissionCall<'a, C>
12760 where
12761 I: IntoIterator<Item = St>,
12762 St: AsRef<str>,
12763 {
12764 self._scopes
12765 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12766 self
12767 }
12768
12769 /// Removes all scopes, and no default scope will be used either.
12770 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12771 /// for details).
12772 pub fn clear_scopes(mut self) -> ProjectOccurrenceTestIamPermissionCall<'a, C> {
12773 self._scopes.clear();
12774 self
12775 }
12776}
12777
12778/// Generates an SBOM for the given resource.
12779///
12780/// A builder for the *resources.exportSBOM* method supported by a *project* resource.
12781/// It is not used directly, but through a [`ProjectMethods`] instance.
12782///
12783/// # Example
12784///
12785/// Instantiate a resource method builder
12786///
12787/// ```test_harness,no_run
12788/// # extern crate hyper;
12789/// # extern crate hyper_rustls;
12790/// # extern crate google_containeranalysis1 as containeranalysis1;
12791/// use containeranalysis1::api::ExportSBOMRequest;
12792/// # async fn dox() {
12793/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12794///
12795/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12796/// # let auth = yup_oauth2::InstalledFlowAuthenticator::builder(
12797/// # secret,
12798/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12799/// # ).build().await.unwrap();
12800///
12801/// # let client = hyper_util::client::legacy::Client::builder(
12802/// # hyper_util::rt::TokioExecutor::new()
12803/// # )
12804/// # .build(
12805/// # hyper_rustls::HttpsConnectorBuilder::new()
12806/// # .with_native_roots()
12807/// # .unwrap()
12808/// # .https_or_http()
12809/// # .enable_http1()
12810/// # .build()
12811/// # );
12812/// # let mut hub = ContainerAnalysis::new(client, auth);
12813/// // As the method needs a request, you would usually fill it with the desired information
12814/// // into the respective structure. Some of the parts shown here might not be applicable !
12815/// // Values shown here are possibly random and not representative !
12816/// let mut req = ExportSBOMRequest::default();
12817///
12818/// // You can configure optional parameters by calling the respective setters at will, and
12819/// // execute the final call using `doit()`.
12820/// // Values shown here are possibly random and not representative !
12821/// let result = hub.projects().resources_export_sbom(req, "name")
12822/// .doit().await;
12823/// # }
12824/// ```
12825pub struct ProjectResourceExportSBOMCall<'a, C>
12826where
12827 C: 'a,
12828{
12829 hub: &'a ContainerAnalysis<C>,
12830 _request: ExportSBOMRequest,
12831 _name: String,
12832 _delegate: Option<&'a mut dyn common::Delegate>,
12833 _additional_params: HashMap<String, String>,
12834 _scopes: BTreeSet<String>,
12835}
12836
12837impl<'a, C> common::CallBuilder for ProjectResourceExportSBOMCall<'a, C> {}
12838
12839impl<'a, C> ProjectResourceExportSBOMCall<'a, C>
12840where
12841 C: common::Connector,
12842{
12843 /// Perform the operation you have build so far.
12844 pub async fn doit(mut self) -> common::Result<(common::Response, ExportSBOMResponse)> {
12845 use std::borrow::Cow;
12846 use std::io::{Read, Seek};
12847
12848 use common::{url::Params, ToParts};
12849 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12850
12851 let mut dd = common::DefaultDelegate;
12852 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12853 dlg.begin(common::MethodInfo {
12854 id: "containeranalysis.projects.resources.exportSBOM",
12855 http_method: hyper::Method::POST,
12856 });
12857
12858 for &field in ["alt", "name"].iter() {
12859 if self._additional_params.contains_key(field) {
12860 dlg.finished(false);
12861 return Err(common::Error::FieldClash(field));
12862 }
12863 }
12864
12865 let mut params = Params::with_capacity(4 + self._additional_params.len());
12866 params.push("name", self._name);
12867
12868 params.extend(self._additional_params.iter());
12869
12870 params.push("alt", "json");
12871 let mut url = self.hub._base_url.clone() + "v1/{+name}:exportSBOM";
12872 if self._scopes.is_empty() {
12873 self._scopes
12874 .insert(Scope::CloudPlatform.as_ref().to_string());
12875 }
12876
12877 #[allow(clippy::single_element_loop)]
12878 for &(find_this, param_name) in [("{+name}", "name")].iter() {
12879 url = params.uri_replacement(url, param_name, find_this, true);
12880 }
12881 {
12882 let to_remove = ["name"];
12883 params.remove_params(&to_remove);
12884 }
12885
12886 let url = params.parse_with_url(&url);
12887
12888 let mut json_mime_type = mime::APPLICATION_JSON;
12889 let mut request_value_reader = {
12890 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12891 common::remove_json_null_values(&mut value);
12892 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12893 serde_json::to_writer(&mut dst, &value).unwrap();
12894 dst
12895 };
12896 let request_size = request_value_reader
12897 .seek(std::io::SeekFrom::End(0))
12898 .unwrap();
12899 request_value_reader
12900 .seek(std::io::SeekFrom::Start(0))
12901 .unwrap();
12902
12903 loop {
12904 let token = match self
12905 .hub
12906 .auth
12907 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12908 .await
12909 {
12910 Ok(token) => token,
12911 Err(e) => match dlg.token(e) {
12912 Ok(token) => token,
12913 Err(e) => {
12914 dlg.finished(false);
12915 return Err(common::Error::MissingToken(e));
12916 }
12917 },
12918 };
12919 request_value_reader
12920 .seek(std::io::SeekFrom::Start(0))
12921 .unwrap();
12922 let mut req_result = {
12923 let client = &self.hub.client;
12924 dlg.pre_request();
12925 let mut req_builder = hyper::Request::builder()
12926 .method(hyper::Method::POST)
12927 .uri(url.as_str())
12928 .header(USER_AGENT, self.hub._user_agent.clone());
12929
12930 if let Some(token) = token.as_ref() {
12931 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12932 }
12933
12934 let request = req_builder
12935 .header(CONTENT_TYPE, json_mime_type.to_string())
12936 .header(CONTENT_LENGTH, request_size as u64)
12937 .body(common::to_body(
12938 request_value_reader.get_ref().clone().into(),
12939 ));
12940
12941 client.request(request.unwrap()).await
12942 };
12943
12944 match req_result {
12945 Err(err) => {
12946 if let common::Retry::After(d) = dlg.http_error(&err) {
12947 sleep(d).await;
12948 continue;
12949 }
12950 dlg.finished(false);
12951 return Err(common::Error::HttpError(err));
12952 }
12953 Ok(res) => {
12954 let (mut parts, body) = res.into_parts();
12955 let mut body = common::Body::new(body);
12956 if !parts.status.is_success() {
12957 let bytes = common::to_bytes(body).await.unwrap_or_default();
12958 let error = serde_json::from_str(&common::to_string(&bytes));
12959 let response = common::to_response(parts, bytes.into());
12960
12961 if let common::Retry::After(d) =
12962 dlg.http_failure(&response, error.as_ref().ok())
12963 {
12964 sleep(d).await;
12965 continue;
12966 }
12967
12968 dlg.finished(false);
12969
12970 return Err(match error {
12971 Ok(value) => common::Error::BadRequest(value),
12972 _ => common::Error::Failure(response),
12973 });
12974 }
12975 let response = {
12976 let bytes = common::to_bytes(body).await.unwrap_or_default();
12977 let encoded = common::to_string(&bytes);
12978 match serde_json::from_str(&encoded) {
12979 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12980 Err(error) => {
12981 dlg.response_json_decode_error(&encoded, &error);
12982 return Err(common::Error::JsonDecodeError(
12983 encoded.to_string(),
12984 error,
12985 ));
12986 }
12987 }
12988 };
12989
12990 dlg.finished(true);
12991 return Ok(response);
12992 }
12993 }
12994 }
12995 }
12996
12997 ///
12998 /// Sets the *request* property to the given value.
12999 ///
13000 /// Even though the property as already been set when instantiating this call,
13001 /// we provide this method for API completeness.
13002 pub fn request(mut self, new_value: ExportSBOMRequest) -> ProjectResourceExportSBOMCall<'a, C> {
13003 self._request = new_value;
13004 self
13005 }
13006 /// Required. The name of the resource in the form of `projects/[PROJECT_ID]/resources/[RESOURCE_URL]`.
13007 ///
13008 /// Sets the *name* path property to the given value.
13009 ///
13010 /// Even though the property as already been set when instantiating this call,
13011 /// we provide this method for API completeness.
13012 pub fn name(mut self, new_value: &str) -> ProjectResourceExportSBOMCall<'a, C> {
13013 self._name = new_value.to_string();
13014 self
13015 }
13016 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13017 /// while executing the actual API request.
13018 ///
13019 /// ````text
13020 /// It should be used to handle progress information, and to implement a certain level of resilience.
13021 /// ````
13022 ///
13023 /// Sets the *delegate* property to the given value.
13024 pub fn delegate(
13025 mut self,
13026 new_value: &'a mut dyn common::Delegate,
13027 ) -> ProjectResourceExportSBOMCall<'a, C> {
13028 self._delegate = Some(new_value);
13029 self
13030 }
13031
13032 /// Set any additional parameter of the query string used in the request.
13033 /// It should be used to set parameters which are not yet available through their own
13034 /// setters.
13035 ///
13036 /// Please note that this method must not be used to set any of the known parameters
13037 /// which have their own setter method. If done anyway, the request will fail.
13038 ///
13039 /// # Additional Parameters
13040 ///
13041 /// * *$.xgafv* (query-string) - V1 error format.
13042 /// * *access_token* (query-string) - OAuth access token.
13043 /// * *alt* (query-string) - Data format for response.
13044 /// * *callback* (query-string) - JSONP
13045 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13046 /// * *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.
13047 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13048 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13049 /// * *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.
13050 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13051 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13052 pub fn param<T>(mut self, name: T, value: T) -> ProjectResourceExportSBOMCall<'a, C>
13053 where
13054 T: AsRef<str>,
13055 {
13056 self._additional_params
13057 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13058 self
13059 }
13060
13061 /// Identifies the authorization scope for the method you are building.
13062 ///
13063 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13064 /// [`Scope::CloudPlatform`].
13065 ///
13066 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13067 /// tokens for more than one scope.
13068 ///
13069 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13070 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13071 /// sufficient, a read-write scope will do as well.
13072 pub fn add_scope<St>(mut self, scope: St) -> ProjectResourceExportSBOMCall<'a, C>
13073 where
13074 St: AsRef<str>,
13075 {
13076 self._scopes.insert(String::from(scope.as_ref()));
13077 self
13078 }
13079 /// Identifies the authorization scope(s) for the method you are building.
13080 ///
13081 /// See [`Self::add_scope()`] for details.
13082 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectResourceExportSBOMCall<'a, C>
13083 where
13084 I: IntoIterator<Item = St>,
13085 St: AsRef<str>,
13086 {
13087 self._scopes
13088 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13089 self
13090 }
13091
13092 /// Removes all scopes, and no default scope will be used either.
13093 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13094 /// for details).
13095 pub fn clear_scopes(mut self) -> ProjectResourceExportSBOMCall<'a, C> {
13096 self._scopes.clear();
13097 self
13098 }
13099}