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 connector = hyper_rustls::HttpsConnectorBuilder::new()
63/// .with_native_roots()
64/// .unwrap()
65/// .https_only()
66/// .enable_http2()
67/// .build();
68///
69/// let executor = hyper_util::rt::TokioExecutor::new();
70/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
71/// secret,
72/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
73/// yup_oauth2::client::CustomHyperClientBuilder::from(
74/// hyper_util::client::legacy::Client::builder(executor).build(connector),
75/// ),
76/// ).build().await.unwrap();
77///
78/// let client = hyper_util::client::legacy::Client::builder(
79/// hyper_util::rt::TokioExecutor::new()
80/// )
81/// .build(
82/// hyper_rustls::HttpsConnectorBuilder::new()
83/// .with_native_roots()
84/// .unwrap()
85/// .https_or_http()
86/// .enable_http2()
87/// .build()
88/// );
89/// let mut hub = ContainerAnalysis::new(client, auth);
90/// // As the method needs a request, you would usually fill it with the desired information
91/// // into the respective structure. Some of the parts shown here might not be applicable !
92/// // Values shown here are possibly random and not representative !
93/// let mut req = Note::default();
94///
95/// // You can configure optional parameters by calling the respective setters at will, and
96/// // execute the final call using `doit()`.
97/// // Values shown here are possibly random and not representative !
98/// let result = hub.projects().locations_notes_create(req, "parent")
99/// .note_id("At")
100/// .doit().await;
101///
102/// match result {
103/// Err(e) => match e {
104/// // The Error enum provides details about what exactly happened.
105/// // You can also just use its `Debug`, `Display` or `Error` traits
106/// Error::HttpError(_)
107/// |Error::Io(_)
108/// |Error::MissingAPIKey
109/// |Error::MissingToken(_)
110/// |Error::Cancelled
111/// |Error::UploadSizeLimitExceeded(_, _)
112/// |Error::Failure(_)
113/// |Error::BadRequest(_)
114/// |Error::FieldClash(_)
115/// |Error::JsonDecodeError(_, _) => println!("{}", e),
116/// },
117/// Ok(res) => println!("Success: {:?}", res),
118/// }
119/// # }
120/// ```
121#[derive(Clone)]
122pub struct ContainerAnalysis<C> {
123 pub client: common::Client<C>,
124 pub auth: Box<dyn common::GetToken>,
125 _user_agent: String,
126 _base_url: String,
127 _root_url: String,
128}
129
130impl<C> common::Hub for ContainerAnalysis<C> {}
131
132impl<'a, C> ContainerAnalysis<C> {
133 pub fn new<A: 'static + common::GetToken>(
134 client: common::Client<C>,
135 auth: A,
136 ) -> ContainerAnalysis<C> {
137 ContainerAnalysis {
138 client,
139 auth: Box::new(auth),
140 _user_agent: "google-api-rust-client/7.0.0".to_string(),
141 _base_url: "https://containeranalysis.googleapis.com/".to_string(),
142 _root_url: "https://containeranalysis.googleapis.com/".to_string(),
143 }
144 }
145
146 pub fn projects(&'a self) -> ProjectMethods<'a, C> {
147 ProjectMethods { hub: self }
148 }
149
150 /// Set the user-agent header field to use in all requests to the server.
151 /// It defaults to `google-api-rust-client/7.0.0`.
152 ///
153 /// Returns the previously set user-agent.
154 pub fn user_agent(&mut self, agent_name: String) -> String {
155 std::mem::replace(&mut self._user_agent, agent_name)
156 }
157
158 /// Set the base url to use in all requests to the server.
159 /// It defaults to `https://containeranalysis.googleapis.com/`.
160 ///
161 /// Returns the previously set base url.
162 pub fn base_url(&mut self, new_base_url: String) -> String {
163 std::mem::replace(&mut self._base_url, new_base_url)
164 }
165
166 /// Set the root url to use in all requests to the server.
167 /// It defaults to `https://containeranalysis.googleapis.com/`.
168 ///
169 /// Returns the previously set root url.
170 pub fn root_url(&mut self, new_root_url: String) -> String {
171 std::mem::replace(&mut self._root_url, new_root_url)
172 }
173}
174
175// ############
176// SCHEMAS ###
177// ##########
178/// An alias to a repo revision.
179///
180/// This type is not used in any activity, and only used as *part* of another schema.
181///
182#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
183#[serde_with::serde_as]
184#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
185pub struct AliasContext {
186 /// The alias kind.
187 pub kind: Option<String>,
188 /// The alias name.
189 pub name: Option<String>,
190}
191
192impl common::Part for AliasContext {}
193
194/// Indicates which analysis completed successfully. Multiple types of analysis can be performed on a single resource.
195///
196/// This type is not used in any activity, and only used as *part* of another schema.
197///
198#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
199#[serde_with::serde_as]
200#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
201pub struct AnalysisCompleted {
202 /// no description provided
203 #[serde(rename = "analysisType")]
204 pub analysis_type: Option<Vec<String>>,
205}
206
207impl common::Part for AnalysisCompleted {}
208
209/// Artifact describes a build product.
210///
211/// This type is not used in any activity, and only used as *part* of another schema.
212///
213#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
214#[serde_with::serde_as]
215#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
216pub struct Artifact {
217 /// Hash or checksum value of a binary, or Docker Registry 2.0 digest of a container.
218 pub checksum: Option<String>,
219 /// Artifact ID, if any; for container images, this will be a URL by digest like `gcr.io/projectID/imagename@sha256:123456`.
220 pub id: Option<String>,
221 /// 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.
222 pub names: Option<Vec<String>>,
223}
224
225impl common::Part for Artifact {}
226
227/// Assessment provides all information that is related to a single vulnerability for this product.
228///
229/// This type is not used in any activity, and only used as *part* of another schema.
230///
231#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
232#[serde_with::serde_as]
233#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
234pub struct Assessment {
235 /// Holds the MITRE standard Common Vulnerabilities and Exposures (CVE) tracking number for the vulnerability. Deprecated: Use vulnerability_id instead to denote CVEs.
236 pub cve: Option<String>,
237 /// Contains information about the impact of this vulnerability, this will change with time.
238 pub impacts: Option<Vec<String>>,
239 /// Justification provides the justification when the state of the assessment if NOT_AFFECTED.
240 pub justification: Option<Justification>,
241 /// A detailed description of this Vex.
242 #[serde(rename = "longDescription")]
243 pub long_description: Option<String>,
244 /// 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.
245 #[serde(rename = "relatedUris")]
246 pub related_uris: Option<Vec<RelatedUrl>>,
247 /// Specifies details on how to handle (and presumably, fix) a vulnerability.
248 pub remediations: Option<Vec<Remediation>>,
249 /// A one sentence description of this Vex.
250 #[serde(rename = "shortDescription")]
251 pub short_description: Option<String>,
252 /// Provides the state of this Vulnerability assessment.
253 pub state: Option<String>,
254 /// The vulnerability identifier for this Assessment. Will hold one of common identifiers e.g. CVE, GHSA etc.
255 #[serde(rename = "vulnerabilityId")]
256 pub vulnerability_id: Option<String>,
257}
258
259impl common::Part for Assessment {}
260
261/// 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.
262///
263/// This type is not used in any activity, and only used as *part* of another schema.
264///
265#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
266#[serde_with::serde_as]
267#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
268pub struct AttestationNote {
269 /// Hint hints at the purpose of the attestation authority.
270 pub hint: Option<Hint>,
271}
272
273impl common::Part for AttestationNote {}
274
275/// 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.
276///
277/// This type is not used in any activity, and only used as *part* of another schema.
278///
279#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
280#[serde_with::serde_as]
281#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
282pub struct AttestationOccurrence {
283 /// 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.
284 pub jwts: Option<Vec<Jwt>>,
285 /// Required. The serialized payload that is verified by one or more `signatures`.
286 #[serde(rename = "serializedPayload")]
287 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
288 pub serialized_payload: Option<Vec<u8>>,
289 /// 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.
290 pub signatures: Option<Vec<Signature>>,
291}
292
293impl common::Part for AttestationOccurrence {}
294
295/// BaseImage describes a base image of a container image.
296///
297/// This type is not used in any activity, and only used as *part* of another schema.
298///
299#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
300#[serde_with::serde_as]
301#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
302pub struct BaseImage {
303 /// The number of layers that the base image is composed of.
304 #[serde(rename = "layerCount")]
305 pub layer_count: Option<i32>,
306 /// The name of the base image.
307 pub name: Option<String>,
308 /// The repository name in which the base image is from.
309 pub repository: Option<String>,
310}
311
312impl common::Part for BaseImage {}
313
314/// Request to create notes in batch.
315///
316/// # Activities
317///
318/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
319/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
320///
321/// * [locations notes batch create projects](ProjectLocationNoteBatchCreateCall) (request)
322/// * [notes batch create projects](ProjectNoteBatchCreateCall) (request)
323#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
324#[serde_with::serde_as]
325#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
326pub struct BatchCreateNotesRequest {
327 /// Required. The notes to create. Max allowed length is 1000.
328 pub notes: Option<HashMap<String, Note>>,
329}
330
331impl common::RequestValue for BatchCreateNotesRequest {}
332
333/// Response for creating notes in batch.
334///
335/// # Activities
336///
337/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
338/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
339///
340/// * [locations notes batch create projects](ProjectLocationNoteBatchCreateCall) (response)
341/// * [notes batch create projects](ProjectNoteBatchCreateCall) (response)
342#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
343#[serde_with::serde_as]
344#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
345pub struct BatchCreateNotesResponse {
346 /// The notes that were created.
347 pub notes: Option<Vec<Note>>,
348}
349
350impl common::ResponseResult for BatchCreateNotesResponse {}
351
352/// Request to create occurrences in batch.
353///
354/// # Activities
355///
356/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
357/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
358///
359/// * [locations occurrences batch create projects](ProjectLocationOccurrenceBatchCreateCall) (request)
360/// * [occurrences batch create projects](ProjectOccurrenceBatchCreateCall) (request)
361#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
362#[serde_with::serde_as]
363#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
364pub struct BatchCreateOccurrencesRequest {
365 /// Required. The occurrences to create. Max allowed length is 1000.
366 pub occurrences: Option<Vec<Occurrence>>,
367}
368
369impl common::RequestValue for BatchCreateOccurrencesRequest {}
370
371/// Response for creating occurrences in batch.
372///
373/// # Activities
374///
375/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
376/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
377///
378/// * [locations occurrences batch create projects](ProjectLocationOccurrenceBatchCreateCall) (response)
379/// * [occurrences batch create projects](ProjectOccurrenceBatchCreateCall) (response)
380#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
381#[serde_with::serde_as]
382#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
383pub struct BatchCreateOccurrencesResponse {
384 /// The occurrences that were created.
385 pub occurrences: Option<Vec<Occurrence>>,
386}
387
388impl common::ResponseResult for BatchCreateOccurrencesResponse {}
389
390/// Associates `members`, or principals, with a `role`.
391///
392/// This type is not used in any activity, and only used as *part* of another schema.
393///
394#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
395#[serde_with::serde_as]
396#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
397pub struct Binding {
398 /// 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).
399 pub condition: Option<Expr>,
400 /// 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`.
401 pub members: Option<Vec<String>>,
402 /// 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).
403 pub role: Option<String>,
404}
405
406impl common::Part for Binding {}
407
408/// There is no detailed description.
409///
410/// This type is not used in any activity, and only used as *part* of another schema.
411///
412#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
413#[serde_with::serde_as]
414#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
415pub struct BuildDefinition {
416 /// no description provided
417 #[serde(rename = "buildType")]
418 pub build_type: Option<String>,
419 /// no description provided
420 #[serde(rename = "externalParameters")]
421 pub external_parameters: Option<HashMap<String, serde_json::Value>>,
422 /// no description provided
423 #[serde(rename = "internalParameters")]
424 pub internal_parameters: Option<HashMap<String, serde_json::Value>>,
425 /// no description provided
426 #[serde(rename = "resolvedDependencies")]
427 pub resolved_dependencies: Option<Vec<ResourceDescriptor>>,
428}
429
430impl common::Part for BuildDefinition {}
431
432/// There is no detailed description.
433///
434/// This type is not used in any activity, and only used as *part* of another schema.
435///
436#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
437#[serde_with::serde_as]
438#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
439pub struct BuildMetadata {
440 /// no description provided
441 #[serde(rename = "finishedOn")]
442 pub finished_on: Option<chrono::DateTime<chrono::offset::Utc>>,
443 /// no description provided
444 #[serde(rename = "invocationId")]
445 pub invocation_id: Option<String>,
446 /// no description provided
447 #[serde(rename = "startedOn")]
448 pub started_on: Option<chrono::DateTime<chrono::offset::Utc>>,
449}
450
451impl common::Part for BuildMetadata {}
452
453/// Note holding the version of the provider's builder and the signature of the provenance message in the build details occurrence.
454///
455/// This type is not used in any activity, and only used as *part* of another schema.
456///
457#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
458#[serde_with::serde_as]
459#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
460pub struct BuildNote {
461 /// Required. Immutable. Version of the builder which produced this build.
462 #[serde(rename = "builderVersion")]
463 pub builder_version: Option<String>,
464}
465
466impl common::Part for BuildNote {}
467
468/// Details of a build occurrence.
469///
470/// This type is not used in any activity, and only used as *part* of another schema.
471///
472#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
473#[serde_with::serde_as]
474#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
475pub struct BuildOccurrence {
476 /// 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.
477 #[serde(rename = "inTotoSlsaProvenanceV1")]
478 pub in_toto_slsa_provenance_v1: Option<InTotoSlsaProvenanceV1>,
479 /// Deprecated. See InTotoStatement for the replacement. In-toto Provenance representation as defined in spec.
480 #[serde(rename = "intotoProvenance")]
481 pub intoto_provenance: Option<InTotoProvenance>,
482 /// 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.
483 #[serde(rename = "intotoStatement")]
484 pub intoto_statement: Option<InTotoStatement>,
485 /// The actual provenance for the build.
486 pub provenance: Option<BuildProvenance>,
487 /// 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.
488 #[serde(rename = "provenanceBytes")]
489 pub provenance_bytes: Option<String>,
490}
491
492impl common::Part for BuildOccurrence {}
493
494/// Provenance of a build. Contains all information needed to verify the full details about the build from source to completion.
495///
496/// This type is not used in any activity, and only used as *part* of another schema.
497///
498#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
499#[serde_with::serde_as]
500#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
501pub struct BuildProvenance {
502 /// Special options applied to this build. This is a catch-all field where build providers can enter any desired additional details.
503 #[serde(rename = "buildOptions")]
504 pub build_options: Option<HashMap<String, String>>,
505 /// Version string of the builder at the time this build was executed.
506 #[serde(rename = "builderVersion")]
507 pub builder_version: Option<String>,
508 /// Output of the build.
509 #[serde(rename = "builtArtifacts")]
510 pub built_artifacts: Option<Vec<Artifact>>,
511 /// Commands requested by the build.
512 pub commands: Option<Vec<Command>>,
513 /// Time at which the build was created.
514 #[serde(rename = "createTime")]
515 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
516 /// 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.
517 pub creator: Option<String>,
518 /// Time at which execution of the build was finished.
519 #[serde(rename = "endTime")]
520 pub end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
521 /// Required. Unique identifier of the build.
522 pub id: Option<String>,
523 /// URI where any logs for this provenance were written.
524 #[serde(rename = "logsUri")]
525 pub logs_uri: Option<String>,
526 /// ID of the project.
527 #[serde(rename = "projectId")]
528 pub project_id: Option<String>,
529 /// Details of the Source input to the build.
530 #[serde(rename = "sourceProvenance")]
531 pub source_provenance: Option<Source>,
532 /// Time at which execution of the build was started.
533 #[serde(rename = "startTime")]
534 pub start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
535 /// Trigger identifier if the build was triggered automatically; empty if not.
536 #[serde(rename = "triggerId")]
537 pub trigger_id: Option<String>,
538}
539
540impl common::Part for BuildProvenance {}
541
542/// There is no detailed description.
543///
544/// This type is not used in any activity, and only used as *part* of another schema.
545///
546#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
547#[serde_with::serde_as]
548#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
549pub struct BuilderConfig {
550 /// no description provided
551 pub id: Option<String>,
552}
553
554impl common::Part for BuilderConfig {}
555
556/// There is no detailed description.
557///
558/// This type is not used in any activity, and only used as *part* of another schema.
559///
560#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
561#[serde_with::serde_as]
562#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
563pub struct CISAKnownExploitedVulnerabilities {
564 /// Whether the vulnerability is known to have been leveraged as part of a ransomware campaign.
565 #[serde(rename = "knownRansomwareCampaignUse")]
566 pub known_ransomware_campaign_use: Option<String>,
567}
568
569impl common::Part for CISAKnownExploitedVulnerabilities {}
570
571/// 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.
572///
573/// This type is not used in any activity, and only used as *part* of another schema.
574///
575#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
576#[serde_with::serde_as]
577#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
578pub struct CVSS {
579 /// no description provided
580 #[serde(rename = "attackComplexity")]
581 pub attack_complexity: Option<String>,
582 /// Base Metrics Represents the intrinsic characteristics of a vulnerability that are constant over time and across user environments.
583 #[serde(rename = "attackVector")]
584 pub attack_vector: Option<String>,
585 /// no description provided
586 pub authentication: Option<String>,
587 /// no description provided
588 #[serde(rename = "availabilityImpact")]
589 pub availability_impact: Option<String>,
590 /// The base score is a function of the base metric scores.
591 #[serde(rename = "baseScore")]
592 pub base_score: Option<f32>,
593 /// no description provided
594 #[serde(rename = "confidentialityImpact")]
595 pub confidentiality_impact: Option<String>,
596 /// no description provided
597 #[serde(rename = "exploitabilityScore")]
598 pub exploitability_score: Option<f32>,
599 /// no description provided
600 #[serde(rename = "impactScore")]
601 pub impact_score: Option<f32>,
602 /// no description provided
603 #[serde(rename = "integrityImpact")]
604 pub integrity_impact: Option<String>,
605 /// no description provided
606 #[serde(rename = "privilegesRequired")]
607 pub privileges_required: Option<String>,
608 /// no description provided
609 pub scope: Option<String>,
610 /// no description provided
611 #[serde(rename = "userInteraction")]
612 pub user_interaction: Option<String>,
613}
614
615impl common::Part for CVSS {}
616
617/// Common Vulnerability Scoring System version 3. For details, see https://www.first.org/cvss/specification-document
618///
619/// This type is not used in any activity, and only used as *part* of another schema.
620///
621#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
622#[serde_with::serde_as]
623#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
624pub struct CVSSv3 {
625 /// no description provided
626 #[serde(rename = "attackComplexity")]
627 pub attack_complexity: Option<String>,
628 /// Base Metrics Represents the intrinsic characteristics of a vulnerability that are constant over time and across user environments.
629 #[serde(rename = "attackVector")]
630 pub attack_vector: Option<String>,
631 /// no description provided
632 #[serde(rename = "availabilityImpact")]
633 pub availability_impact: Option<String>,
634 /// The base score is a function of the base metric scores.
635 #[serde(rename = "baseScore")]
636 pub base_score: Option<f32>,
637 /// no description provided
638 #[serde(rename = "confidentialityImpact")]
639 pub confidentiality_impact: Option<String>,
640 /// no description provided
641 #[serde(rename = "exploitabilityScore")]
642 pub exploitability_score: Option<f32>,
643 /// no description provided
644 #[serde(rename = "impactScore")]
645 pub impact_score: Option<f32>,
646 /// no description provided
647 #[serde(rename = "integrityImpact")]
648 pub integrity_impact: Option<String>,
649 /// no description provided
650 #[serde(rename = "privilegesRequired")]
651 pub privileges_required: Option<String>,
652 /// no description provided
653 pub scope: Option<String>,
654 /// no description provided
655 #[serde(rename = "userInteraction")]
656 pub user_interaction: Option<String>,
657}
658
659impl common::Part for CVSSv3 {}
660
661/// The category to which the update belongs.
662///
663/// This type is not used in any activity, and only used as *part* of another schema.
664///
665#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
666#[serde_with::serde_as]
667#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
668pub struct Category {
669 /// The identifier of the category.
670 #[serde(rename = "categoryId")]
671 pub category_id: Option<String>,
672 /// The localized name of the category.
673 pub name: Option<String>,
674}
675
676impl common::Part for Category {}
677
678/// A compliance check that is a CIS benchmark.
679///
680/// This type is not used in any activity, and only used as *part* of another schema.
681///
682#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
683#[serde_with::serde_as]
684#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
685pub struct CisBenchmark {
686 /// no description provided
687 #[serde(rename = "profileLevel")]
688 pub profile_level: Option<i32>,
689 /// no description provided
690 pub severity: Option<String>,
691}
692
693impl common::Part for CisBenchmark {}
694
695/// A CloudRepoSourceContext denotes a particular revision in a Google Cloud Source Repo.
696///
697/// This type is not used in any activity, and only used as *part* of another schema.
698///
699#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
700#[serde_with::serde_as]
701#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
702pub struct CloudRepoSourceContext {
703 /// An alias, which may be a branch or tag.
704 #[serde(rename = "aliasContext")]
705 pub alias_context: Option<AliasContext>,
706 /// The ID of the repo.
707 #[serde(rename = "repoId")]
708 pub repo_id: Option<RepoId>,
709 /// A revision ID.
710 #[serde(rename = "revisionId")]
711 pub revision_id: Option<String>,
712}
713
714impl common::Part for CloudRepoSourceContext {}
715
716/// Empty placeholder to denote that this is a Google Cloud Storage export request.
717///
718/// This type is not used in any activity, and only used as *part* of another schema.
719///
720#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
721#[serde_with::serde_as]
722#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
723pub struct CloudStorageLocation {
724 _never_set: Option<bool>,
725}
726
727impl common::Part for CloudStorageLocation {}
728
729/// Command describes a step performed as part of the build pipeline.
730///
731/// This type is not used in any activity, and only used as *part* of another schema.
732///
733#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
734#[serde_with::serde_as]
735#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
736pub struct Command {
737 /// Command-line arguments used when executing this command.
738 pub args: Option<Vec<String>>,
739 /// Working directory (relative to project source root) used when running this command.
740 pub dir: Option<String>,
741 /// Environment variables set before running this command.
742 pub env: Option<Vec<String>>,
743 /// Optional unique identifier for this command, used in wait_for to reference this command as a dependency.
744 pub id: Option<String>,
745 /// 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`.
746 pub name: Option<String>,
747 /// The ID(s) of the command(s) that this command depends on.
748 #[serde(rename = "waitFor")]
749 pub wait_for: Option<Vec<String>>,
750}
751
752impl common::Part for Command {}
753
754/// Indicates that the builder claims certain fields in this message to be complete.
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 Completeness {
762 /// If true, the builder claims that recipe.arguments is complete, meaning that all external inputs are properly captured in the recipe.
763 pub arguments: Option<bool>,
764 /// If true, the builder claims that recipe.environment is claimed to be complete.
765 pub environment: Option<bool>,
766 /// If true, the builder claims that materials are complete, usually through some controls to prevent network access. Sometimes called "hermetic".
767 pub materials: Option<bool>,
768}
769
770impl common::Part for Completeness {}
771
772/// There is no detailed description.
773///
774/// This type is not used in any activity, and only used as *part* of another schema.
775///
776#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
777#[serde_with::serde_as]
778#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
779pub struct ComplianceNote {
780 /// no description provided
781 #[serde(rename = "cisBenchmark")]
782 pub cis_benchmark: Option<CisBenchmark>,
783 /// A description about this compliance check.
784 pub description: Option<String>,
785 /// no description provided
786 pub impact: Option<String>,
787 /// A rationale for the existence of this compliance check.
788 pub rationale: Option<String>,
789 /// A description of remediation steps if the compliance check fails.
790 pub remediation: Option<String>,
791 /// Serialized scan instructions with a predefined format.
792 #[serde(rename = "scanInstructions")]
793 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
794 pub scan_instructions: Option<Vec<u8>>,
795 /// The title that identifies this compliance check.
796 pub title: Option<String>,
797 /// The OS and config versions the benchmark applies to.
798 pub version: Option<Vec<ComplianceVersion>>,
799}
800
801impl common::Part for ComplianceNote {}
802
803/// An indication that the compliance checks in the associated ComplianceNote were not satisfied for particular resources or a specified reason.
804///
805/// This type is not used in any activity, and only used as *part* of another schema.
806///
807#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
808#[serde_with::serde_as]
809#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
810pub struct ComplianceOccurrence {
811 /// no description provided
812 #[serde(rename = "nonComplianceReason")]
813 pub non_compliance_reason: Option<String>,
814 /// no description provided
815 #[serde(rename = "nonCompliantFiles")]
816 pub non_compliant_files: Option<Vec<NonCompliantFile>>,
817 /// The OS and config version the benchmark was run on.
818 pub version: Option<ComplianceVersion>,
819}
820
821impl common::Part for ComplianceOccurrence {}
822
823/// Describes the CIS benchmark version that is applicable to a given OS and os version.
824///
825/// This type is not used in any activity, and only used as *part* of another schema.
826///
827#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
828#[serde_with::serde_as]
829#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
830pub struct ComplianceVersion {
831 /// The name of the document that defines this benchmark, e.g. "CIS Container-Optimized OS".
832 #[serde(rename = "benchmarkDocument")]
833 pub benchmark_document: Option<String>,
834 /// The CPE URI (https://cpe.mitre.org/specification/) this benchmark is applicable to.
835 #[serde(rename = "cpeUri")]
836 pub cpe_uri: Option<String>,
837 /// The version of the benchmark. This is set to the version of the OS-specific CIS document the benchmark is defined in.
838 pub version: Option<String>,
839}
840
841impl common::Part for ComplianceVersion {}
842
843/// There is no detailed description.
844///
845/// This type is not used in any activity, and only used as *part* of another schema.
846///
847#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
848#[serde_with::serde_as]
849#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
850pub struct DSSEAttestationNote {
851 /// DSSEHint hints at the purpose of the attestation authority.
852 pub hint: Option<DSSEHint>,
853}
854
855impl common::Part for DSSEAttestationNote {}
856
857/// Deprecated. Prefer to use a regular Occurrence, and populate the Envelope at the top level of the Occurrence.
858///
859/// This type is not used in any activity, and only used as *part* of another schema.
860///
861#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
862#[serde_with::serde_as]
863#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
864pub struct DSSEAttestationOccurrence {
865 /// If doing something security critical, make sure to verify the signatures in this metadata.
866 pub envelope: Option<Envelope>,
867 /// no description provided
868 pub statement: Option<InTotoStatement>,
869}
870
871impl common::Part for DSSEAttestationOccurrence {}
872
873/// 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.
874///
875/// This type is not used in any activity, and only used as *part* of another schema.
876///
877#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
878#[serde_with::serde_as]
879#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
880pub struct DSSEHint {
881 /// Required. The human readable name of this attestation authority, for example "cloudbuild-prod".
882 #[serde(rename = "humanReadableName")]
883 pub human_readable_name: Option<String>,
884}
885
886impl common::Part for DSSEHint {}
887
888/// An artifact that can be deployed in some runtime.
889///
890/// This type is not used in any activity, and only used as *part* of another schema.
891///
892#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
893#[serde_with::serde_as]
894#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
895pub struct DeploymentNote {
896 /// Required. Resource URI for the artifact being deployed.
897 #[serde(rename = "resourceUri")]
898 pub resource_uri: Option<Vec<String>>,
899}
900
901impl common::Part for DeploymentNote {}
902
903/// The period during which some deployable was active in a runtime.
904///
905/// This type is not used in any activity, and only used as *part* of another schema.
906///
907#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
908#[serde_with::serde_as]
909#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
910pub struct DeploymentOccurrence {
911 /// Address of the runtime element hosting this deployment.
912 pub address: Option<String>,
913 /// Configuration used to create this deployment.
914 pub config: Option<String>,
915 /// Required. Beginning of the lifetime of this deployment.
916 #[serde(rename = "deployTime")]
917 pub deploy_time: Option<chrono::DateTime<chrono::offset::Utc>>,
918 /// Platform hosting this deployment.
919 pub platform: Option<String>,
920 /// Output only. Resource URI for the artifact being deployed taken from the deployable field with the same name.
921 #[serde(rename = "resourceUri")]
922 pub resource_uri: Option<Vec<String>>,
923 /// End of the lifetime of this deployment.
924 #[serde(rename = "undeployTime")]
925 pub undeploy_time: Option<chrono::DateTime<chrono::offset::Utc>>,
926 /// Identity of the user that triggered this deployment.
927 #[serde(rename = "userEmail")]
928 pub user_email: Option<String>,
929}
930
931impl common::Part for DeploymentOccurrence {}
932
933/// A detail for a distro and package affected by this vulnerability and its associated fix (if one is available).
934///
935/// This type is not used in any activity, and only used as *part* of another schema.
936///
937#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
938#[serde_with::serde_as]
939#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
940pub struct Detail {
941 /// Required. The [CPE URI](https://cpe.mitre.org/specification/) this vulnerability affects.
942 #[serde(rename = "affectedCpeUri")]
943 pub affected_cpe_uri: Option<String>,
944 /// Required. The package this vulnerability affects.
945 #[serde(rename = "affectedPackage")]
946 pub affected_package: Option<String>,
947 /// 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.
948 #[serde(rename = "affectedVersionEnd")]
949 pub affected_version_end: Option<Version>,
950 /// 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.
951 #[serde(rename = "affectedVersionStart")]
952 pub affected_version_start: Option<Version>,
953 /// A vendor-specific description of this vulnerability.
954 pub description: Option<String>,
955 /// 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.
956 #[serde(rename = "fixedCpeUri")]
957 pub fixed_cpe_uri: Option<String>,
958 /// 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.
959 #[serde(rename = "fixedPackage")]
960 pub fixed_package: Option<String>,
961 /// 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.
962 #[serde(rename = "fixedVersion")]
963 pub fixed_version: Option<Version>,
964 /// Whether this detail is obsolete. Occurrences are expected not to point to obsolete details.
965 #[serde(rename = "isObsolete")]
966 pub is_obsolete: Option<bool>,
967 /// The type of package; whether native or non native (e.g., ruby gems, node.js packages, etc.).
968 #[serde(rename = "packageType")]
969 pub package_type: Option<String>,
970 /// The distro assigned severity of this vulnerability.
971 #[serde(rename = "severityName")]
972 pub severity_name: Option<String>,
973 /// The source from which the information in this Detail was obtained.
974 pub source: Option<String>,
975 /// 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.
976 #[serde(rename = "sourceUpdateTime")]
977 pub source_update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
978 /// The name of the vendor of the product.
979 pub vendor: Option<String>,
980}
981
982impl common::Part for Detail {}
983
984/// Digest information.
985///
986/// This type is not used in any activity, and only used as *part* of another schema.
987///
988#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
989#[serde_with::serde_as]
990#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
991pub struct Digest {
992 /// `SHA1`, `SHA512` etc.
993 pub algo: Option<String>,
994 /// Value of the digest.
995 #[serde(rename = "digestBytes")]
996 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
997 pub digest_bytes: Option<Vec<u8>>,
998}
999
1000impl common::Part for Digest {}
1001
1002/// 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.
1003///
1004/// This type is not used in any activity, and only used as *part* of another schema.
1005///
1006#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1007#[serde_with::serde_as]
1008#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1009pub struct DiscoveryNote {
1010 /// Required. Immutable. The kind of analysis that is handled by this discovery.
1011 #[serde(rename = "analysisKind")]
1012 pub analysis_kind: Option<String>,
1013}
1014
1015impl common::Part for DiscoveryNote {}
1016
1017/// Provides information about the analysis status of a discovered resource.
1018///
1019/// This type is not used in any activity, and only used as *part* of another schema.
1020///
1021#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1022#[serde_with::serde_as]
1023#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1024pub struct DiscoveryOccurrence {
1025 /// no description provided
1026 #[serde(rename = "analysisCompleted")]
1027 pub analysis_completed: Option<AnalysisCompleted>,
1028 /// Indicates any errors encountered during analysis of a resource. There could be 0 or more of these errors.
1029 #[serde(rename = "analysisError")]
1030 pub analysis_error: Option<Vec<Status>>,
1031 /// The status of discovery for the resource.
1032 #[serde(rename = "analysisStatus")]
1033 pub analysis_status: Option<String>,
1034 /// 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.
1035 #[serde(rename = "analysisStatusError")]
1036 pub analysis_status_error: Option<Status>,
1037 /// Output only. The time occurrences related to this discovery occurrence were archived.
1038 #[serde(rename = "archiveTime")]
1039 pub archive_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1040 /// Whether the resource is continuously analyzed.
1041 #[serde(rename = "continuousAnalysis")]
1042 pub continuous_analysis: Option<String>,
1043 /// The CPE of the resource being scanned.
1044 pub cpe: Option<String>,
1045 /// Files that make up the resource described by the occurrence.
1046 pub files: Option<Vec<File>>,
1047 /// The last time this resource was scanned.
1048 #[serde(rename = "lastScanTime")]
1049 pub last_scan_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1050 /// The status of an SBOM generation.
1051 #[serde(rename = "sbomStatus")]
1052 pub sbom_status: Option<SBOMStatus>,
1053}
1054
1055impl common::Part for DiscoveryOccurrence {}
1056
1057/// This represents a particular channel of distribution for a given package. E.g., Debian's jessie-backports dpkg mirror.
1058///
1059/// This type is not used in any activity, and only used as *part* of another schema.
1060///
1061#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1062#[serde_with::serde_as]
1063#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1064pub struct Distribution {
1065 /// The CPU architecture for which packages in this distribution channel were built.
1066 pub architecture: Option<String>,
1067 /// Required. The cpe_uri in [CPE format](https://cpe.mitre.org/specification/) denoting the package manager version distributing a package.
1068 #[serde(rename = "cpeUri")]
1069 pub cpe_uri: Option<String>,
1070 /// The distribution channel-specific description of this package.
1071 pub description: Option<String>,
1072 /// The latest available version of this package in this distribution channel.
1073 #[serde(rename = "latestVersion")]
1074 pub latest_version: Option<Version>,
1075 /// A freeform string denoting the maintainer of this package.
1076 pub maintainer: Option<String>,
1077 /// The distribution channel-specific homepage for this package.
1078 pub url: Option<String>,
1079}
1080
1081impl common::Part for Distribution {}
1082
1083/// 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); }
1084///
1085/// # Activities
1086///
1087/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1088/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1089///
1090/// * [locations notes delete projects](ProjectLocationNoteDeleteCall) (response)
1091/// * [locations occurrences delete projects](ProjectLocationOccurrenceDeleteCall) (response)
1092/// * [notes delete projects](ProjectNoteDeleteCall) (response)
1093/// * [occurrences delete projects](ProjectOccurrenceDeleteCall) (response)
1094#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1095#[serde_with::serde_as]
1096#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1097pub struct Empty {
1098 _never_set: Option<bool>,
1099}
1100
1101impl common::ResponseResult for Empty {}
1102
1103/// MUST match https://github.com/secure-systems-lab/dsse/blob/master/envelope.proto. An authenticated message of arbitrary type.
1104///
1105/// This type is not used in any activity, and only used as *part* of another schema.
1106///
1107#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1108#[serde_with::serde_as]
1109#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1110pub struct Envelope {
1111 /// no description provided
1112 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1113 pub payload: Option<Vec<u8>>,
1114 /// no description provided
1115 #[serde(rename = "payloadType")]
1116 pub payload_type: Option<String>,
1117 /// no description provided
1118 pub signatures: Option<Vec<EnvelopeSignature>>,
1119}
1120
1121impl common::Part for Envelope {}
1122
1123/// There is no detailed description.
1124///
1125/// This type is not used in any activity, and only used as *part* of another schema.
1126///
1127#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1128#[serde_with::serde_as]
1129#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1130pub struct EnvelopeSignature {
1131 /// no description provided
1132 pub keyid: Option<String>,
1133 /// no description provided
1134 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1135 pub sig: Option<Vec<u8>>,
1136}
1137
1138impl common::Part for EnvelopeSignature {}
1139
1140/// There is no detailed description.
1141///
1142/// This type is not used in any activity, and only used as *part* of another schema.
1143///
1144#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1145#[serde_with::serde_as]
1146#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1147pub struct ExploitPredictionScoringSystem {
1148 /// The percentile of the current score, the proportion of all scored vulnerabilities with the same or a lower EPSS score
1149 pub percentile: Option<f64>,
1150 /// The EPSS score representing the probability [0-1] of exploitation in the wild in the next 30 days
1151 pub score: Option<f64>,
1152}
1153
1154impl common::Part for ExploitPredictionScoringSystem {}
1155
1156/// The request to generate and export SBOM. Target must be specified for the request.
1157///
1158/// # Activities
1159///
1160/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1161/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1162///
1163/// * [locations resources export sbom projects](ProjectLocationResourceExportSBOMCall) (request)
1164/// * [resources export sbom projects](ProjectResourceExportSBOMCall) (request)
1165#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1166#[serde_with::serde_as]
1167#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1168pub struct ExportSBOMRequest {
1169 /// Optional. Empty placeholder to denote that this is a Google Cloud Storage export request.
1170 #[serde(rename = "cloudStorageLocation")]
1171 pub cloud_storage_location: Option<CloudStorageLocation>,
1172}
1173
1174impl common::RequestValue for ExportSBOMRequest {}
1175
1176/// The response from a call to ExportSBOM.
1177///
1178/// # Activities
1179///
1180/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1181/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1182///
1183/// * [locations resources export sbom projects](ProjectLocationResourceExportSBOMCall) (response)
1184/// * [resources export sbom projects](ProjectResourceExportSBOMCall) (response)
1185#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1186#[serde_with::serde_as]
1187#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1188pub struct ExportSBOMResponse {
1189 /// 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.
1190 #[serde(rename = "discoveryOccurrence")]
1191 pub discovery_occurrence: Option<String>,
1192}
1193
1194impl common::ResponseResult for ExportSBOMResponse {}
1195
1196/// 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.
1197///
1198/// This type is not used in any activity, and only used as *part* of another schema.
1199///
1200#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1201#[serde_with::serde_as]
1202#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1203pub struct Expr {
1204 /// Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.
1205 pub description: Option<String>,
1206 /// Textual representation of an expression in Common Expression Language syntax.
1207 pub expression: Option<String>,
1208 /// Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.
1209 pub location: Option<String>,
1210 /// 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.
1211 pub title: Option<String>,
1212}
1213
1214impl common::Part for Expr {}
1215
1216/// There is no detailed description.
1217///
1218/// This type is not used in any activity, and only used as *part* of another schema.
1219///
1220#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1221#[serde_with::serde_as]
1222#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1223pub struct File {
1224 /// no description provided
1225 pub digest: Option<HashMap<String, String>>,
1226 /// no description provided
1227 pub name: Option<String>,
1228}
1229
1230impl common::Part for File {}
1231
1232/// Container message for hashes of byte content of files, used in source messages to verify integrity of source input to the build.
1233///
1234/// This type is not used in any activity, and only used as *part* of another schema.
1235///
1236#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1237#[serde_with::serde_as]
1238#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1239pub struct FileHashes {
1240 /// Required. Collection of file hashes.
1241 #[serde(rename = "fileHash")]
1242 pub file_hash: Option<Vec<Hash>>,
1243}
1244
1245impl common::Part for FileHashes {}
1246
1247/// A set of properties that uniquely identify a given Docker image.
1248///
1249/// This type is not used in any activity, and only used as *part* of another schema.
1250///
1251#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1252#[serde_with::serde_as]
1253#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1254pub struct Fingerprint {
1255 /// Required. The layer ID of the final layer in the Docker image's v1 representation.
1256 #[serde(rename = "v1Name")]
1257 pub v1_name: Option<String>,
1258 /// Required. The ordered list of v2 blobs that represent a given image.
1259 #[serde(rename = "v2Blob")]
1260 pub v2_blob: Option<Vec<String>>,
1261 /// 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.
1262 #[serde(rename = "v2Name")]
1263 pub v2_name: Option<String>,
1264}
1265
1266impl common::Part for Fingerprint {}
1267
1268/// Per resource and severity counts of fixable and total vulnerabilities.
1269///
1270/// This type is not used in any activity, and only used as *part* of another schema.
1271///
1272#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1273#[serde_with::serde_as]
1274#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1275pub struct FixableTotalByDigest {
1276 /// The number of fixable vulnerabilities associated with this resource.
1277 #[serde(rename = "fixableCount")]
1278 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1279 pub fixable_count: Option<i64>,
1280 /// The affected resource.
1281 #[serde(rename = "resourceUri")]
1282 pub resource_uri: Option<String>,
1283 /// The severity for this count. SEVERITY_UNSPECIFIED indicates total across all severities.
1284 pub severity: Option<String>,
1285 /// The total number of vulnerabilities associated with this resource.
1286 #[serde(rename = "totalCount")]
1287 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
1288 pub total_count: Option<i64>,
1289}
1290
1291impl common::Part for FixableTotalByDigest {}
1292
1293/// A SourceContext referring to a Gerrit project.
1294///
1295/// This type is not used in any activity, and only used as *part* of another schema.
1296///
1297#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1298#[serde_with::serde_as]
1299#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1300pub struct GerritSourceContext {
1301 /// An alias, which may be a branch or tag.
1302 #[serde(rename = "aliasContext")]
1303 pub alias_context: Option<AliasContext>,
1304 /// 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.
1305 #[serde(rename = "gerritProject")]
1306 pub gerrit_project: Option<String>,
1307 /// The URI of a running Gerrit instance.
1308 #[serde(rename = "hostUri")]
1309 pub host_uri: Option<String>,
1310 /// A revision (commit) ID.
1311 #[serde(rename = "revisionId")]
1312 pub revision_id: Option<String>,
1313}
1314
1315impl common::Part for GerritSourceContext {}
1316
1317/// Request message for `GetIamPolicy` method.
1318///
1319/// # Activities
1320///
1321/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1322/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1323///
1324/// * [locations notes get iam policy projects](ProjectLocationNoteGetIamPolicyCall) (request)
1325/// * [locations occurrences get iam policy projects](ProjectLocationOccurrenceGetIamPolicyCall) (request)
1326/// * [notes get iam policy projects](ProjectNoteGetIamPolicyCall) (request)
1327/// * [occurrences get iam policy projects](ProjectOccurrenceGetIamPolicyCall) (request)
1328#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1329#[serde_with::serde_as]
1330#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1331pub struct GetIamPolicyRequest {
1332 /// OPTIONAL: A `GetPolicyOptions` object for specifying options to `GetIamPolicy`.
1333 pub options: Option<GetPolicyOptions>,
1334}
1335
1336impl common::RequestValue for GetIamPolicyRequest {}
1337
1338/// Encapsulates settings provided to GetIamPolicy.
1339///
1340/// This type is not used in any activity, and only used as *part* of another schema.
1341///
1342#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1343#[serde_with::serde_as]
1344#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1345pub struct GetPolicyOptions {
1346 /// 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).
1347 #[serde(rename = "requestedPolicyVersion")]
1348 pub requested_policy_version: Option<i32>,
1349}
1350
1351impl common::Part for GetPolicyOptions {}
1352
1353/// A GitSourceContext denotes a particular revision in a third party Git repository (e.g., GitHub).
1354///
1355/// This type is not used in any activity, and only used as *part* of another schema.
1356///
1357#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1358#[serde_with::serde_as]
1359#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1360pub struct GitSourceContext {
1361 /// Git commit hash.
1362 #[serde(rename = "revisionId")]
1363 pub revision_id: Option<String>,
1364 /// Git repository URL.
1365 pub url: Option<String>,
1366}
1367
1368impl common::Part for GitSourceContext {}
1369
1370/// Indicates the location at which a package was found.
1371///
1372/// This type is not used in any activity, and only used as *part* of another schema.
1373///
1374#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1375#[serde_with::serde_as]
1376#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1377pub struct GrafeasV1FileLocation {
1378 /// For jars that are contained inside .war files, this filepath can indicate the path to war file combined with the path to jar file.
1379 #[serde(rename = "filePath")]
1380 pub file_path: Option<String>,
1381 /// Each package found in a file should have its own layer metadata (that is, information from the origin layer of the package).
1382 #[serde(rename = "layerDetails")]
1383 pub layer_details: Option<LayerDetails>,
1384}
1385
1386impl common::Part for GrafeasV1FileLocation {}
1387
1388/// Identifies the entity that executed the recipe, which is trusted to have correctly performed the operation and populated this provenance.
1389///
1390/// This type is not used in any activity, and only used as *part* of another schema.
1391///
1392#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1393#[serde_with::serde_as]
1394#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1395pub struct GrafeasV1SlsaProvenanceZeroTwoSlsaBuilder {
1396 /// no description provided
1397 pub id: Option<String>,
1398}
1399
1400impl common::Part for GrafeasV1SlsaProvenanceZeroTwoSlsaBuilder {}
1401
1402/// Indicates that the builder claims certain fields in this message to be complete.
1403///
1404/// This type is not used in any activity, and only used as *part* of another schema.
1405///
1406#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1407#[serde_with::serde_as]
1408#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1409pub struct GrafeasV1SlsaProvenanceZeroTwoSlsaCompleteness {
1410 /// no description provided
1411 pub environment: Option<bool>,
1412 /// no description provided
1413 pub materials: Option<bool>,
1414 /// no description provided
1415 pub parameters: Option<bool>,
1416}
1417
1418impl common::Part for GrafeasV1SlsaProvenanceZeroTwoSlsaCompleteness {}
1419
1420/// Describes where the config file that kicked off the build came from. This is effectively a pointer to the source where buildConfig came from.
1421///
1422/// This type is not used in any activity, and only used as *part* of another schema.
1423///
1424#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1425#[serde_with::serde_as]
1426#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1427pub struct GrafeasV1SlsaProvenanceZeroTwoSlsaConfigSource {
1428 /// no description provided
1429 pub digest: Option<HashMap<String, String>>,
1430 /// no description provided
1431 #[serde(rename = "entryPoint")]
1432 pub entry_point: Option<String>,
1433 /// no description provided
1434 pub uri: Option<String>,
1435}
1436
1437impl common::Part for GrafeasV1SlsaProvenanceZeroTwoSlsaConfigSource {}
1438
1439/// Identifies the event that kicked off the build.
1440///
1441/// This type is not used in any activity, and only used as *part* of another schema.
1442///
1443#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1444#[serde_with::serde_as]
1445#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1446pub struct GrafeasV1SlsaProvenanceZeroTwoSlsaInvocation {
1447 /// no description provided
1448 #[serde(rename = "configSource")]
1449 pub config_source: Option<GrafeasV1SlsaProvenanceZeroTwoSlsaConfigSource>,
1450 /// no description provided
1451 pub environment: Option<HashMap<String, serde_json::Value>>,
1452 /// no description provided
1453 pub parameters: Option<HashMap<String, serde_json::Value>>,
1454}
1455
1456impl common::Part for GrafeasV1SlsaProvenanceZeroTwoSlsaInvocation {}
1457
1458/// The collection of artifacts that influenced the build including sources, dependencies, build tools, base images, and so on.
1459///
1460/// This type is not used in any activity, and only used as *part* of another schema.
1461///
1462#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1463#[serde_with::serde_as]
1464#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1465pub struct GrafeasV1SlsaProvenanceZeroTwoSlsaMaterial {
1466 /// no description provided
1467 pub digest: Option<HashMap<String, String>>,
1468 /// no description provided
1469 pub uri: Option<String>,
1470}
1471
1472impl common::Part for GrafeasV1SlsaProvenanceZeroTwoSlsaMaterial {}
1473
1474/// Other properties of the build.
1475///
1476/// This type is not used in any activity, and only used as *part* of another schema.
1477///
1478#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1479#[serde_with::serde_as]
1480#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1481pub struct GrafeasV1SlsaProvenanceZeroTwoSlsaMetadata {
1482 /// no description provided
1483 #[serde(rename = "buildFinishedOn")]
1484 pub build_finished_on: Option<chrono::DateTime<chrono::offset::Utc>>,
1485 /// no description provided
1486 #[serde(rename = "buildInvocationId")]
1487 pub build_invocation_id: Option<String>,
1488 /// no description provided
1489 #[serde(rename = "buildStartedOn")]
1490 pub build_started_on: Option<chrono::DateTime<chrono::offset::Utc>>,
1491 /// no description provided
1492 pub completeness: Option<GrafeasV1SlsaProvenanceZeroTwoSlsaCompleteness>,
1493 /// no description provided
1494 pub reproducible: Option<bool>,
1495}
1496
1497impl common::Part for GrafeasV1SlsaProvenanceZeroTwoSlsaMetadata {}
1498
1499/// Container message for hash values.
1500///
1501/// This type is not used in any activity, and only used as *part* of another schema.
1502///
1503#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1504#[serde_with::serde_as]
1505#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1506pub struct Hash {
1507 /// Required. The type of hash that was performed, e.g. "SHA-256".
1508 #[serde(rename = "type")]
1509 pub type_: Option<String>,
1510 /// Required. The hash value.
1511 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
1512 pub value: Option<Vec<u8>>,
1513}
1514
1515impl common::Part for Hash {}
1516
1517/// 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.
1518///
1519/// This type is not used in any activity, and only used as *part* of another schema.
1520///
1521#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1522#[serde_with::serde_as]
1523#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1524pub struct Hint {
1525 /// Required. The human readable name of this attestation authority, for example "qa".
1526 #[serde(rename = "humanReadableName")]
1527 pub human_readable_name: Option<String>,
1528}
1529
1530impl common::Part for Hint {}
1531
1532/// The unique identifier of the update.
1533///
1534/// This type is not used in any activity, and only used as *part* of another schema.
1535///
1536#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1537#[serde_with::serde_as]
1538#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1539pub struct Identity {
1540 /// The revision number of the update.
1541 pub revision: Option<i32>,
1542 /// The revision independent identifier of the update.
1543 #[serde(rename = "updateId")]
1544 pub update_id: Option<String>,
1545}
1546
1547impl common::Part for Identity {}
1548
1549/// 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.
1550///
1551/// This type is not used in any activity, and only used as *part* of another schema.
1552///
1553#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1554#[serde_with::serde_as]
1555#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1556pub struct ImageNote {
1557 /// Required. Immutable. The fingerprint of the base image.
1558 pub fingerprint: Option<Fingerprint>,
1559 /// Required. Immutable. The resource_url for the resource representing the basis of associated occurrence images.
1560 #[serde(rename = "resourceUrl")]
1561 pub resource_url: Option<String>,
1562}
1563
1564impl common::Part for ImageNote {}
1565
1566/// Details of the derived image portion of the DockerImage relationship. This image would be produced from a Dockerfile with FROM .
1567///
1568/// This type is not used in any activity, and only used as *part* of another schema.
1569///
1570#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1571#[serde_with::serde_as]
1572#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1573pub struct ImageOccurrence {
1574 /// Output only. This contains the base image URL for the derived image occurrence.
1575 #[serde(rename = "baseResourceUrl")]
1576 pub base_resource_url: Option<String>,
1577 /// Output only. The number of layers by which this image differs from the associated image basis.
1578 pub distance: Option<i32>,
1579 /// Required. The fingerprint of the derived image.
1580 pub fingerprint: Option<Fingerprint>,
1581 /// 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.
1582 #[serde(rename = "layerInfo")]
1583 pub layer_info: Option<Vec<Layer>>,
1584}
1585
1586impl common::Part for ImageOccurrence {}
1587
1588/// There is no detailed description.
1589///
1590/// This type is not used in any activity, and only used as *part* of another schema.
1591///
1592#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1593#[serde_with::serde_as]
1594#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1595pub struct InTotoProvenance {
1596 /// required
1597 #[serde(rename = "builderConfig")]
1598 pub builder_config: Option<BuilderConfig>,
1599 /// 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.
1600 pub materials: Option<Vec<String>>,
1601 /// no description provided
1602 pub metadata: Option<Metadata>,
1603 /// 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
1604 pub recipe: Option<Recipe>,
1605}
1606
1607impl common::Part for InTotoProvenance {}
1608
1609/// There is no detailed description.
1610///
1611/// This type is not used in any activity, and only used as *part* of another schema.
1612///
1613#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1614#[serde_with::serde_as]
1615#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1616pub struct InTotoSlsaProvenanceV1 {
1617 /// InToto spec defined at https://github.com/in-toto/attestation/tree/main/spec#statement
1618 pub _type: Option<String>,
1619 /// no description provided
1620 pub predicate: Option<SlsaProvenanceV1>,
1621 /// no description provided
1622 #[serde(rename = "predicateType")]
1623 pub predicate_type: Option<String>,
1624 /// no description provided
1625 pub subject: Option<Vec<Subject>>,
1626}
1627
1628impl common::Part for InTotoSlsaProvenanceV1 {}
1629
1630/// 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".
1631///
1632/// This type is not used in any activity, and only used as *part* of another schema.
1633///
1634#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1635#[serde_with::serde_as]
1636#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1637pub struct InTotoStatement {
1638 /// Always `https://in-toto.io/Statement/v0.1`.
1639 pub _type: Option<String>,
1640 /// `https://slsa.dev/provenance/v0.1` for SlsaProvenance.
1641 #[serde(rename = "predicateType")]
1642 pub predicate_type: Option<String>,
1643 /// no description provided
1644 pub provenance: Option<InTotoProvenance>,
1645 /// no description provided
1646 #[serde(rename = "slsaProvenance")]
1647 pub slsa_provenance: Option<SlsaProvenance>,
1648 /// no description provided
1649 #[serde(rename = "slsaProvenanceZeroTwo")]
1650 pub slsa_provenance_zero_two: Option<SlsaProvenanceZeroTwo>,
1651 /// no description provided
1652 pub subject: Option<Vec<Subject>>,
1653}
1654
1655impl common::Part for InTotoStatement {}
1656
1657/// Justification provides the justification when the state of the assessment if NOT_AFFECTED.
1658///
1659/// This type is not used in any activity, and only used as *part* of another schema.
1660///
1661#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1662#[serde_with::serde_as]
1663#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1664pub struct Justification {
1665 /// Additional details on why this justification was chosen.
1666 pub details: Option<String>,
1667 /// The justification type for this vulnerability.
1668 #[serde(rename = "justificationType")]
1669 pub justification_type: Option<String>,
1670}
1671
1672impl common::Part for Justification {}
1673
1674/// There is no detailed description.
1675///
1676/// This type is not used in any activity, and only used as *part* of another schema.
1677///
1678#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1679#[serde_with::serde_as]
1680#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1681pub struct Jwt {
1682 /// 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
1683 #[serde(rename = "compactJwt")]
1684 pub compact_jwt: Option<String>,
1685}
1686
1687impl common::Part for Jwt {}
1688
1689/// There is no detailed description.
1690///
1691/// This type is not used in any activity, and only used as *part* of another schema.
1692///
1693#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1694#[serde_with::serde_as]
1695#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1696pub struct KnowledgeBase {
1697 /// The KB name (generally of the form KB[0-9]+ (e.g., KB123456)).
1698 pub name: Option<String>,
1699 /// A link to the KB in the [Windows update catalog] (https://www.catalog.update.microsoft.com/).
1700 pub url: Option<String>,
1701}
1702
1703impl common::Part for KnowledgeBase {}
1704
1705/// Layer holds metadata specific to a layer of a Docker image.
1706///
1707/// This type is not used in any activity, and only used as *part* of another schema.
1708///
1709#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1710#[serde_with::serde_as]
1711#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1712pub struct Layer {
1713 /// The recovered arguments to the Dockerfile directive.
1714 pub arguments: Option<String>,
1715 /// Required. The recovered Dockerfile directive used to construct this layer. See https://docs.docker.com/engine/reference/builder/ for more information.
1716 pub directive: Option<String>,
1717}
1718
1719impl common::Part for Layer {}
1720
1721/// Details about the layer a package was found in.
1722///
1723/// This type is not used in any activity, and only used as *part* of another schema.
1724///
1725#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1726#[serde_with::serde_as]
1727#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1728pub struct LayerDetails {
1729 /// The base images the layer is found within.
1730 #[serde(rename = "baseImages")]
1731 pub base_images: Option<Vec<BaseImage>>,
1732 /// The layer chain ID (sha256 hash) of the layer in the container image. https://github.com/opencontainers/image-spec/blob/main/config.md#layer-chainid
1733 #[serde(rename = "chainId")]
1734 pub chain_id: Option<String>,
1735 /// The layer build command that was used to build the layer. This may not be found in all layers depending on how the container image is built.
1736 pub command: Option<String>,
1737 /// The diff ID (typically a sha256 hash) of the layer in the container image.
1738 #[serde(rename = "diffId")]
1739 pub diff_id: Option<String>,
1740 /// The index of the layer in the container image.
1741 pub index: Option<i32>,
1742}
1743
1744impl common::Part for LayerDetails {}
1745
1746/// License information.
1747///
1748/// This type is not used in any activity, and only used as *part* of another schema.
1749///
1750#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1751#[serde_with::serde_as]
1752#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1753pub struct License {
1754 /// Comments
1755 pub comments: Option<String>,
1756 /// 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".
1757 pub expression: Option<String>,
1758}
1759
1760impl common::Part for License {}
1761
1762/// Response for listing occurrences for a note.
1763///
1764/// # Activities
1765///
1766/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1767/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1768///
1769/// * [locations notes occurrences list projects](ProjectLocationNoteOccurrenceListCall) (response)
1770/// * [notes occurrences list projects](ProjectNoteOccurrenceListCall) (response)
1771#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1772#[serde_with::serde_as]
1773#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1774pub struct ListNoteOccurrencesResponse {
1775 /// Token to provide to skip to a particular spot in the list.
1776 #[serde(rename = "nextPageToken")]
1777 pub next_page_token: Option<String>,
1778 /// The occurrences attached to the specified note.
1779 pub occurrences: Option<Vec<Occurrence>>,
1780}
1781
1782impl common::ResponseResult for ListNoteOccurrencesResponse {}
1783
1784/// Response for listing notes.
1785///
1786/// # Activities
1787///
1788/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1789/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1790///
1791/// * [locations notes list projects](ProjectLocationNoteListCall) (response)
1792/// * [notes list projects](ProjectNoteListCall) (response)
1793#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1794#[serde_with::serde_as]
1795#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1796pub struct ListNotesResponse {
1797 /// 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.
1798 #[serde(rename = "nextPageToken")]
1799 pub next_page_token: Option<String>,
1800 /// The notes requested.
1801 pub notes: Option<Vec<Note>>,
1802 /// Unordered list. Unreachable regions. Populated for requests from the global region when `return_partial_success` is set. Format: `projects/[PROJECT_ID]/locations/[LOCATION]`
1803 pub unreachable: Option<Vec<String>>,
1804}
1805
1806impl common::ResponseResult for ListNotesResponse {}
1807
1808/// Response for listing occurrences.
1809///
1810/// # Activities
1811///
1812/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1813/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1814///
1815/// * [locations occurrences list projects](ProjectLocationOccurrenceListCall) (response)
1816/// * [occurrences list projects](ProjectOccurrenceListCall) (response)
1817#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1818#[serde_with::serde_as]
1819#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1820pub struct ListOccurrencesResponse {
1821 /// 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.
1822 #[serde(rename = "nextPageToken")]
1823 pub next_page_token: Option<String>,
1824 /// The occurrences requested.
1825 pub occurrences: Option<Vec<Occurrence>>,
1826 /// Unordered list. Unreachable regions. Populated for requests from the global region when `return_partial_success` is set. Format: `projects/[PROJECT_ID]/locations/[LOCATION]`
1827 pub unreachable: Option<Vec<String>>,
1828}
1829
1830impl common::ResponseResult for ListOccurrencesResponse {}
1831
1832/// An occurrence of a particular package installation found within a system's filesystem. E.g., glibc was found in `/var/lib/dpkg/status`.
1833///
1834/// This type is not used in any activity, and only used as *part* of another schema.
1835///
1836#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1837#[serde_with::serde_as]
1838#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1839pub struct Location {
1840 /// Deprecated. The CPE URI in [CPE format](https://cpe.mitre.org/specification/)
1841 #[serde(rename = "cpeUri")]
1842 pub cpe_uri: Option<String>,
1843 /// The path from which we gathered that this package/version is installed.
1844 pub path: Option<String>,
1845 /// Deprecated. The version installed at this location.
1846 pub version: Option<Version>,
1847}
1848
1849impl common::Part for Location {}
1850
1851/// There is no detailed description.
1852///
1853/// This type is not used in any activity, and only used as *part* of another schema.
1854///
1855#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1856#[serde_with::serde_as]
1857#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1858pub struct Material {
1859 /// no description provided
1860 pub digest: Option<HashMap<String, String>>,
1861 /// no description provided
1862 pub uri: Option<String>,
1863}
1864
1865impl common::Part for Material {}
1866
1867/// Other properties of the build.
1868///
1869/// This type is not used in any activity, and only used as *part* of another schema.
1870///
1871#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1872#[serde_with::serde_as]
1873#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1874pub struct Metadata {
1875 /// The timestamp of when the build completed.
1876 #[serde(rename = "buildFinishedOn")]
1877 pub build_finished_on: Option<chrono::DateTime<chrono::offset::Utc>>,
1878 /// 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.
1879 #[serde(rename = "buildInvocationId")]
1880 pub build_invocation_id: Option<String>,
1881 /// The timestamp of when the build started.
1882 #[serde(rename = "buildStartedOn")]
1883 pub build_started_on: Option<chrono::DateTime<chrono::offset::Utc>>,
1884 /// Indicates that the builder claims certain fields in this message to be complete.
1885 pub completeness: Option<Completeness>,
1886 /// If true, the builder claims that running the recipe on materials will produce bit-for-bit identical output.
1887 pub reproducible: Option<bool>,
1888}
1889
1890impl common::Part for Metadata {}
1891
1892/// 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'.
1893///
1894/// This type is not used in any activity, and only used as *part* of another schema.
1895///
1896#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1897#[serde_with::serde_as]
1898#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1899pub struct NonCompliantFile {
1900 /// Command to display the non-compliant files.
1901 #[serde(rename = "displayCommand")]
1902 pub display_command: Option<String>,
1903 /// Empty if `display_command` is set.
1904 pub path: Option<String>,
1905 /// Explains why a file is non compliant for a CIS check.
1906 pub reason: Option<String>,
1907}
1908
1909impl common::Part for NonCompliantFile {}
1910
1911/// A type of analysis that can be done for a resource.
1912///
1913/// # Activities
1914///
1915/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1916/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1917///
1918/// * [locations notes create projects](ProjectLocationNoteCreateCall) (request|response)
1919/// * [locations notes get projects](ProjectLocationNoteGetCall) (response)
1920/// * [locations notes patch projects](ProjectLocationNotePatchCall) (request|response)
1921/// * [locations occurrences get notes projects](ProjectLocationOccurrenceGetNoteCall) (response)
1922/// * [notes create projects](ProjectNoteCreateCall) (request|response)
1923/// * [notes get projects](ProjectNoteGetCall) (response)
1924/// * [notes patch projects](ProjectNotePatchCall) (request|response)
1925/// * [occurrences get notes projects](ProjectOccurrenceGetNoteCall) (response)
1926#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
1927#[serde_with::serde_as]
1928#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
1929pub struct Note {
1930 /// A note describing an attestation role.
1931 pub attestation: Option<AttestationNote>,
1932 /// A note describing build provenance for a verifiable build.
1933 pub build: Option<BuildNote>,
1934 /// A note describing a compliance check.
1935 pub compliance: Option<ComplianceNote>,
1936 /// Output only. The time this note was created. This field can be used as a filter in list requests.
1937 #[serde(rename = "createTime")]
1938 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1939 /// A note describing something that can be deployed.
1940 pub deployment: Option<DeploymentNote>,
1941 /// A note describing the initial analysis of a resource.
1942 pub discovery: Option<DiscoveryNote>,
1943 /// A note describing a dsse attestation note.
1944 #[serde(rename = "dsseAttestation")]
1945 pub dsse_attestation: Option<DSSEAttestationNote>,
1946 /// Time of expiration for this note. Empty if note does not expire.
1947 #[serde(rename = "expirationTime")]
1948 pub expiration_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1949 /// A note describing a base image.
1950 pub image: Option<ImageNote>,
1951 /// Output only. The type of analysis. This field can be used as a filter in list requests.
1952 pub kind: Option<String>,
1953 /// A detailed description of this note.
1954 #[serde(rename = "longDescription")]
1955 pub long_description: Option<String>,
1956 /// Output only. The name of the note in the form of `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.
1957 pub name: Option<String>,
1958 /// A note describing a package hosted by various package managers.
1959 pub package: Option<PackageNote>,
1960 /// Other notes related to this note.
1961 #[serde(rename = "relatedNoteNames")]
1962 pub related_note_names: Option<Vec<String>>,
1963 /// URLs associated with this note.
1964 #[serde(rename = "relatedUrl")]
1965 pub related_url: Option<Vec<RelatedUrl>>,
1966 /// A note describing an SBOM reference.
1967 #[serde(rename = "sbomReference")]
1968 pub sbom_reference: Option<SBOMReferenceNote>,
1969 /// A note describing a secret.
1970 pub secret: Option<SecretNote>,
1971 /// A one sentence description of this note.
1972 #[serde(rename = "shortDescription")]
1973 pub short_description: Option<String>,
1974 /// Output only. The time this note was last updated. This field can be used as a filter in list requests.
1975 #[serde(rename = "updateTime")]
1976 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
1977 /// A note describing available package upgrades.
1978 pub upgrade: Option<UpgradeNote>,
1979 /// A note describing a package vulnerability.
1980 pub vulnerability: Option<VulnerabilityNote>,
1981 /// A note describing a vulnerability assessment.
1982 #[serde(rename = "vulnerabilityAssessment")]
1983 pub vulnerability_assessment: Option<VulnerabilityAssessmentNote>,
1984}
1985
1986impl common::RequestValue for Note {}
1987impl common::ResponseResult for Note {}
1988
1989/// An instance of an analysis type that has been found on a resource.
1990///
1991/// # Activities
1992///
1993/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
1994/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
1995///
1996/// * [locations occurrences create projects](ProjectLocationOccurrenceCreateCall) (request|response)
1997/// * [locations occurrences get projects](ProjectLocationOccurrenceGetCall) (response)
1998/// * [locations occurrences patch projects](ProjectLocationOccurrencePatchCall) (request|response)
1999/// * [occurrences create projects](ProjectOccurrenceCreateCall) (request|response)
2000/// * [occurrences get projects](ProjectOccurrenceGetCall) (response)
2001/// * [occurrences patch projects](ProjectOccurrencePatchCall) (request|response)
2002#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2003#[serde_with::serde_as]
2004#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2005pub struct Occurrence {
2006 /// Describes an attestation of an artifact.
2007 pub attestation: Option<AttestationOccurrence>,
2008 /// Describes a verifiable build.
2009 pub build: Option<BuildOccurrence>,
2010 /// Describes a compliance violation on a linked resource.
2011 pub compliance: Option<ComplianceOccurrence>,
2012 /// Output only. The time this occurrence was created.
2013 #[serde(rename = "createTime")]
2014 pub create_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2015 /// Describes the deployment of an artifact on a runtime.
2016 pub deployment: Option<DeploymentOccurrence>,
2017 /// Describes when a resource was discovered.
2018 pub discovery: Option<DiscoveryOccurrence>,
2019 /// Describes an attestation of an artifact using dsse.
2020 #[serde(rename = "dsseAttestation")]
2021 pub dsse_attestation: Option<DSSEAttestationOccurrence>,
2022 /// https://github.com/secure-systems-lab/dsse
2023 pub envelope: Option<Envelope>,
2024 /// Describes how this resource derives from the basis in the associated note.
2025 pub image: Option<ImageOccurrence>,
2026 /// Output only. This explicitly denotes which of the occurrence details are specified. This field can be used as a filter in list requests.
2027 pub kind: Option<String>,
2028 /// Output only. The name of the occurrence in the form of `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.
2029 pub name: Option<String>,
2030 /// 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.
2031 #[serde(rename = "noteName")]
2032 pub note_name: Option<String>,
2033 /// Describes the installation of a package on the linked resource.
2034 pub package: Option<PackageOccurrence>,
2035 /// A description of actions that can be taken to remedy the note.
2036 pub remediation: Option<String>,
2037 /// 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.
2038 #[serde(rename = "resourceUri")]
2039 pub resource_uri: Option<String>,
2040 /// Describes a specific SBOM reference occurrences.
2041 #[serde(rename = "sbomReference")]
2042 pub sbom_reference: Option<SBOMReferenceOccurrence>,
2043 /// Describes a secret.
2044 pub secret: Option<SecretOccurrence>,
2045 /// Output only. The time this occurrence was last updated.
2046 #[serde(rename = "updateTime")]
2047 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2048 /// Describes an available package upgrade on the linked resource.
2049 pub upgrade: Option<UpgradeOccurrence>,
2050 /// Describes a security vulnerability.
2051 pub vulnerability: Option<VulnerabilityOccurrence>,
2052}
2053
2054impl common::RequestValue for Occurrence {}
2055impl common::ResponseResult for Occurrence {}
2056
2057/// A detail for a distro and package this vulnerability occurrence was found in and its associated fix (if one is available).
2058///
2059/// This type is not used in any activity, and only used as *part* of another schema.
2060///
2061#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2062#[serde_with::serde_as]
2063#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2064pub struct PackageIssue {
2065 /// Required. The [CPE URI](https://cpe.mitre.org/specification/) this vulnerability was found in.
2066 #[serde(rename = "affectedCpeUri")]
2067 pub affected_cpe_uri: Option<String>,
2068 /// Required. The package this vulnerability was found in.
2069 #[serde(rename = "affectedPackage")]
2070 pub affected_package: Option<String>,
2071 /// Required. The version of the package that is installed on the resource affected by this vulnerability.
2072 #[serde(rename = "affectedVersion")]
2073 pub affected_version: Option<Version>,
2074 /// 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.
2075 #[serde(rename = "effectiveSeverity")]
2076 pub effective_severity: Option<String>,
2077 /// The location at which this package was found.
2078 #[serde(rename = "fileLocation")]
2079 pub file_location: Option<Vec<GrafeasV1FileLocation>>,
2080 /// Output only. Whether a fix is available for this package.
2081 #[serde(rename = "fixAvailable")]
2082 pub fix_available: Option<bool>,
2083 /// 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.
2084 #[serde(rename = "fixedCpeUri")]
2085 pub fixed_cpe_uri: Option<String>,
2086 /// The package this vulnerability was fixed in. It is possible for this to be different from the affected_package.
2087 #[serde(rename = "fixedPackage")]
2088 pub fixed_package: Option<String>,
2089 /// Required. The version of the package this vulnerability was fixed in. Setting this to VersionKind.MAXIMUM means no fix is yet available.
2090 #[serde(rename = "fixedVersion")]
2091 pub fixed_version: Option<Version>,
2092 /// The type of package (e.g. OS, MAVEN, GO).
2093 #[serde(rename = "packageType")]
2094 pub package_type: Option<String>,
2095}
2096
2097impl common::Part for PackageIssue {}
2098
2099/// PackageNote represents a particular package version.
2100///
2101/// This type is not used in any activity, and only used as *part* of another schema.
2102///
2103#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2104#[serde_with::serde_as]
2105#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2106pub struct PackageNote {
2107 /// The CPU architecture for which packages in this distribution channel were built. Architecture will be blank for language packages.
2108 pub architecture: Option<String>,
2109 /// 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.
2110 #[serde(rename = "cpeUri")]
2111 pub cpe_uri: Option<String>,
2112 /// The description of this package.
2113 pub description: Option<String>,
2114 /// Hash value, typically a file digest, that allows unique identification a specific package.
2115 pub digest: Option<Vec<Digest>>,
2116 /// Deprecated. The various channels by which a package is distributed.
2117 pub distribution: Option<Vec<Distribution>>,
2118 /// Licenses that have been declared by the authors of the package.
2119 pub license: Option<License>,
2120 /// A freeform text denoting the maintainer of this package.
2121 pub maintainer: Option<String>,
2122 /// Required. Immutable. The name of the package.
2123 pub name: Option<String>,
2124 /// The type of package; whether native or non native (e.g., ruby gems, node.js packages, etc.).
2125 #[serde(rename = "packageType")]
2126 pub package_type: Option<String>,
2127 /// The homepage for this package.
2128 pub url: Option<String>,
2129 /// The version of the package.
2130 pub version: Option<Version>,
2131}
2132
2133impl common::Part for PackageNote {}
2134
2135/// Details on how a particular software package was installed on a system.
2136///
2137/// This type is not used in any activity, and only used as *part* of another schema.
2138///
2139#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2140#[serde_with::serde_as]
2141#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2142pub struct PackageOccurrence {
2143 /// Output only. The CPU architecture for which packages in this distribution channel were built. Architecture will be blank for language packages.
2144 pub architecture: Option<String>,
2145 /// 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.
2146 #[serde(rename = "cpeUri")]
2147 pub cpe_uri: Option<String>,
2148 /// Licenses that have been declared by the authors of the package.
2149 pub license: Option<License>,
2150 /// All of the places within the filesystem versions of this package have been found.
2151 pub location: Option<Vec<Location>>,
2152 /// Required. Output only. The name of the installed package.
2153 pub name: Option<String>,
2154 /// Output only. The type of package; whether native or non native (e.g., ruby gems, node.js packages, etc.).
2155 #[serde(rename = "packageType")]
2156 pub package_type: Option<String>,
2157 /// Output only. The version of the package.
2158 pub version: Option<Version>,
2159}
2160
2161impl common::Part for PackageOccurrence {}
2162
2163/// 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/).
2164///
2165/// # Activities
2166///
2167/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2168/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2169///
2170/// * [locations notes get iam policy projects](ProjectLocationNoteGetIamPolicyCall) (response)
2171/// * [locations notes set iam policy projects](ProjectLocationNoteSetIamPolicyCall) (response)
2172/// * [locations occurrences get iam policy projects](ProjectLocationOccurrenceGetIamPolicyCall) (response)
2173/// * [locations occurrences set iam policy projects](ProjectLocationOccurrenceSetIamPolicyCall) (response)
2174/// * [notes get iam policy projects](ProjectNoteGetIamPolicyCall) (response)
2175/// * [notes set iam policy projects](ProjectNoteSetIamPolicyCall) (response)
2176/// * [occurrences get iam policy projects](ProjectOccurrenceGetIamPolicyCall) (response)
2177/// * [occurrences set iam policy projects](ProjectOccurrenceSetIamPolicyCall) (response)
2178#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2179#[serde_with::serde_as]
2180#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2181pub struct Policy {
2182 /// 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`.
2183 pub bindings: Option<Vec<Binding>>,
2184 /// `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.
2185 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
2186 pub etag: Option<Vec<u8>>,
2187 /// 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).
2188 pub version: Option<i32>,
2189}
2190
2191impl common::ResponseResult for Policy {}
2192
2193/// Product contains information about a product and how to uniquely identify it.
2194///
2195/// This type is not used in any activity, and only used as *part* of another schema.
2196///
2197#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2198#[serde_with::serde_as]
2199#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2200pub struct Product {
2201 /// Contains a URI which is vendor-specific. Example: The artifact repository URL of an image.
2202 #[serde(rename = "genericUri")]
2203 pub generic_uri: Option<String>,
2204 /// 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.
2205 pub id: Option<String>,
2206 /// Name of the product.
2207 pub name: Option<String>,
2208}
2209
2210impl common::Part for Product {}
2211
2212/// Selects a repo using a Google Cloud Platform project ID (e.g., winged-cargo-31) and a repo name within that project.
2213///
2214/// This type is not used in any activity, and only used as *part* of another schema.
2215///
2216#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2217#[serde_with::serde_as]
2218#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2219pub struct ProjectRepoId {
2220 /// The ID of the project.
2221 #[serde(rename = "projectId")]
2222 pub project_id: Option<String>,
2223 /// The name of the repo. Leave empty for the default repo.
2224 #[serde(rename = "repoName")]
2225 pub repo_name: Option<String>,
2226}
2227
2228impl common::Part for ProjectRepoId {}
2229
2230/// There is no detailed description.
2231///
2232/// This type is not used in any activity, and only used as *part* of another schema.
2233///
2234#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2235#[serde_with::serde_as]
2236#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2237pub struct ProvenanceBuilder {
2238 /// no description provided
2239 #[serde(rename = "builderDependencies")]
2240 pub builder_dependencies: Option<Vec<ResourceDescriptor>>,
2241 /// no description provided
2242 pub id: Option<String>,
2243 /// no description provided
2244 pub version: Option<HashMap<String, String>>,
2245}
2246
2247impl common::Part for ProvenanceBuilder {}
2248
2249/// Publisher contains information about the publisher of this Note.
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 Publisher {
2257 /// Provides information about the authority of the issuing party to release the document, in particular, the party's constituency and responsibilities or other obligations.
2258 #[serde(rename = "issuingAuthority")]
2259 pub issuing_authority: Option<String>,
2260 /// Name of the publisher. Examples: 'Google', 'Google Cloud Platform'.
2261 pub name: Option<String>,
2262 /// 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
2263 #[serde(rename = "publisherNamespace")]
2264 pub publisher_namespace: Option<String>,
2265}
2266
2267impl common::Part for Publisher {}
2268
2269/// Steps taken to build the artifact. For a TaskRun, typically each container corresponds to one step in the recipe.
2270///
2271/// This type is not used in any activity, and only used as *part* of another schema.
2272///
2273#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2274#[serde_with::serde_as]
2275#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2276pub struct Recipe {
2277 /// 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".
2278 pub arguments: Option<Vec<HashMap<String, serde_json::Value>>>,
2279 /// 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.
2280 #[serde(rename = "definedInMaterial")]
2281 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2282 pub defined_in_material: Option<i64>,
2283 /// 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.
2284 #[serde(rename = "entryPoint")]
2285 pub entry_point: Option<String>,
2286 /// 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".
2287 pub environment: Option<Vec<HashMap<String, serde_json::Value>>>,
2288 /// URI indicating what type of recipe was performed. It determines the meaning of recipe.entryPoint, recipe.arguments, recipe.environment, and materials.
2289 #[serde(rename = "type")]
2290 pub type_: Option<String>,
2291}
2292
2293impl common::Part for Recipe {}
2294
2295/// Metadata for any related URL information.
2296///
2297/// This type is not used in any activity, and only used as *part* of another schema.
2298///
2299#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2300#[serde_with::serde_as]
2301#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2302pub struct RelatedUrl {
2303 /// Label to describe usage of the URL.
2304 pub label: Option<String>,
2305 /// Specific URL associated with the resource.
2306 pub url: Option<String>,
2307}
2308
2309impl common::Part for RelatedUrl {}
2310
2311/// Specifies details on how to handle (and presumably, fix) a vulnerability.
2312///
2313/// This type is not used in any activity, and only used as *part* of another schema.
2314///
2315#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2316#[serde_with::serde_as]
2317#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2318pub struct Remediation {
2319 /// Contains a comprehensive human-readable discussion of the remediation.
2320 pub details: Option<String>,
2321 /// The type of remediation that can be applied.
2322 #[serde(rename = "remediationType")]
2323 pub remediation_type: Option<String>,
2324 /// Contains the URL where to obtain the remediation.
2325 #[serde(rename = "remediationUri")]
2326 pub remediation_uri: Option<RelatedUrl>,
2327}
2328
2329impl common::Part for Remediation {}
2330
2331/// A unique identifier for a Cloud Repo.
2332///
2333/// This type is not used in any activity, and only used as *part* of another schema.
2334///
2335#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2336#[serde_with::serde_as]
2337#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2338pub struct RepoId {
2339 /// A combination of a project ID and a repo name.
2340 #[serde(rename = "projectRepoId")]
2341 pub project_repo_id: Option<ProjectRepoId>,
2342 /// A server-assigned, globally unique identifier.
2343 pub uid: Option<String>,
2344}
2345
2346impl common::Part for RepoId {}
2347
2348/// There is no detailed description.
2349///
2350/// This type is not used in any activity, and only used as *part* of another schema.
2351///
2352#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2353#[serde_with::serde_as]
2354#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2355pub struct ResourceDescriptor {
2356 /// no description provided
2357 pub annotations: Option<HashMap<String, serde_json::Value>>,
2358 /// no description provided
2359 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
2360 pub content: Option<Vec<u8>>,
2361 /// no description provided
2362 pub digest: Option<HashMap<String, String>>,
2363 /// no description provided
2364 #[serde(rename = "downloadLocation")]
2365 pub download_location: Option<String>,
2366 /// no description provided
2367 #[serde(rename = "mediaType")]
2368 pub media_type: Option<String>,
2369 /// no description provided
2370 pub name: Option<String>,
2371 /// no description provided
2372 pub uri: Option<String>,
2373}
2374
2375impl common::Part for ResourceDescriptor {}
2376
2377/// There is no detailed description.
2378///
2379/// This type is not used in any activity, and only used as *part* of another schema.
2380///
2381#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2382#[serde_with::serde_as]
2383#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2384pub struct Risk {
2385 /// CISA maintains the authoritative source of vulnerabilities that have been exploited in the wild.
2386 #[serde(rename = "cisaKev")]
2387 pub cisa_kev: Option<CISAKnownExploitedVulnerabilities>,
2388 /// The Exploit Prediction Scoring System (EPSS) estimates the likelihood (probability) that a software vulnerability will be exploited in the wild.
2389 pub epss: Option<ExploitPredictionScoringSystem>,
2390}
2391
2392impl common::Part for Risk {}
2393
2394/// There is no detailed description.
2395///
2396/// This type is not used in any activity, and only used as *part* of another schema.
2397///
2398#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2399#[serde_with::serde_as]
2400#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2401pub struct RunDetails {
2402 /// no description provided
2403 pub builder: Option<ProvenanceBuilder>,
2404 /// no description provided
2405 pub byproducts: Option<Vec<ResourceDescriptor>>,
2406 /// no description provided
2407 pub metadata: Option<BuildMetadata>,
2408}
2409
2410impl common::Part for RunDetails {}
2411
2412/// The note representing an SBOM reference.
2413///
2414/// This type is not used in any activity, and only used as *part* of another schema.
2415///
2416#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2417#[serde_with::serde_as]
2418#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2419pub struct SBOMReferenceNote {
2420 /// The format that SBOM takes. E.g. may be spdx, cyclonedx, etc...
2421 pub format: Option<String>,
2422 /// The version of the format that the SBOM takes. E.g. if the format is spdx, the version may be 2.3.
2423 pub version: Option<String>,
2424}
2425
2426impl common::Part for SBOMReferenceNote {}
2427
2428/// 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.
2429///
2430/// This type is not used in any activity, and only used as *part* of another schema.
2431///
2432#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2433#[serde_with::serde_as]
2434#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2435pub struct SBOMReferenceOccurrence {
2436 /// The actual payload that contains the SBOM reference data.
2437 pub payload: Option<SbomReferenceIntotoPayload>,
2438 /// 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'.
2439 #[serde(rename = "payloadType")]
2440 pub payload_type: Option<String>,
2441 /// The signatures over the payload.
2442 pub signatures: Option<Vec<EnvelopeSignature>>,
2443}
2444
2445impl common::Part for SBOMReferenceOccurrence {}
2446
2447/// The status of an SBOM generation.
2448///
2449/// This type is not used in any activity, and only used as *part* of another schema.
2450///
2451#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2452#[serde_with::serde_as]
2453#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2454pub struct SBOMStatus {
2455 /// If there was an error generating an SBOM, this will indicate what that error was.
2456 pub error: Option<String>,
2457 /// The progress of the SBOM generation.
2458 #[serde(rename = "sbomState")]
2459 pub sbom_state: Option<String>,
2460}
2461
2462impl common::Part for SBOMStatus {}
2463
2464/// 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.
2465///
2466/// This type is not used in any activity, and only used as *part* of another schema.
2467///
2468#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2469#[serde_with::serde_as]
2470#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2471pub struct SbomReferenceIntotoPayload {
2472 /// Identifier for the schema of the Statement.
2473 pub _type: Option<String>,
2474 /// Additional parameters of the Predicate. Includes the actual data about the SBOM.
2475 pub predicate: Option<SbomReferenceIntotoPredicate>,
2476 /// URI identifying the type of the Predicate.
2477 #[serde(rename = "predicateType")]
2478 pub predicate_type: Option<String>,
2479 /// Set of software artifacts that the attestation applies to. Each element represents a single software artifact.
2480 pub subject: Option<Vec<Subject>>,
2481}
2482
2483impl common::Part for SbomReferenceIntotoPayload {}
2484
2485/// A predicate which describes the SBOM being referenced.
2486///
2487/// This type is not used in any activity, and only used as *part* of another schema.
2488///
2489#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2490#[serde_with::serde_as]
2491#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2492pub struct SbomReferenceIntotoPredicate {
2493 /// A map of algorithm to digest of the contents of the SBOM.
2494 pub digest: Option<HashMap<String, String>>,
2495 /// The location of the SBOM.
2496 pub location: Option<String>,
2497 /// The mime type of the SBOM.
2498 #[serde(rename = "mimeType")]
2499 pub mime_type: Option<String>,
2500 /// The person or system referring this predicate to the consumer.
2501 #[serde(rename = "referrerId")]
2502 pub referrer_id: Option<String>,
2503}
2504
2505impl common::Part for SbomReferenceIntotoPredicate {}
2506
2507/// The location of the secret.
2508///
2509/// This type is not used in any activity, and only used as *part* of another schema.
2510///
2511#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2512#[serde_with::serde_as]
2513#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2514pub struct SecretLocation {
2515 /// The secret is found from a file.
2516 #[serde(rename = "fileLocation")]
2517 pub file_location: Option<GrafeasV1FileLocation>,
2518}
2519
2520impl common::Part for SecretLocation {}
2521
2522/// The note representing a secret.
2523///
2524/// This type is not used in any activity, and only used as *part* of another schema.
2525///
2526#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2527#[serde_with::serde_as]
2528#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2529pub struct SecretNote {
2530 _never_set: Option<bool>,
2531}
2532
2533impl common::Part for SecretNote {}
2534
2535/// The occurrence provides details of a secret.
2536///
2537/// This type is not used in any activity, and only used as *part* of another schema.
2538///
2539#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2540#[serde_with::serde_as]
2541#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2542pub struct SecretOccurrence {
2543 /// Required. Type of secret.
2544 pub kind: Option<String>,
2545 /// Optional. Locations where the secret is detected.
2546 pub locations: Option<Vec<SecretLocation>>,
2547 /// Optional. Status of the secret.
2548 pub statuses: Option<Vec<SecretStatus>>,
2549}
2550
2551impl common::Part for SecretOccurrence {}
2552
2553/// The status of the secret with a timestamp.
2554///
2555/// This type is not used in any activity, and only used as *part* of another schema.
2556///
2557#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2558#[serde_with::serde_as]
2559#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2560pub struct SecretStatus {
2561 /// Optional. Optional message about the status code.
2562 pub message: Option<String>,
2563 /// Optional. The status of the secret.
2564 pub status: Option<String>,
2565 /// Optional. The time the secret status was last updated.
2566 #[serde(rename = "updateTime")]
2567 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
2568}
2569
2570impl common::Part for SecretStatus {}
2571
2572/// Request message for `SetIamPolicy` method.
2573///
2574/// # Activities
2575///
2576/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2577/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2578///
2579/// * [locations notes set iam policy projects](ProjectLocationNoteSetIamPolicyCall) (request)
2580/// * [locations occurrences set iam policy projects](ProjectLocationOccurrenceSetIamPolicyCall) (request)
2581/// * [notes set iam policy projects](ProjectNoteSetIamPolicyCall) (request)
2582/// * [occurrences set iam policy projects](ProjectOccurrenceSetIamPolicyCall) (request)
2583#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2584#[serde_with::serde_as]
2585#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2586pub struct SetIamPolicyRequest {
2587 /// 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.
2588 pub policy: Option<Policy>,
2589}
2590
2591impl common::RequestValue for SetIamPolicyRequest {}
2592
2593/// 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).
2594///
2595/// This type is not used in any activity, and only used as *part* of another schema.
2596///
2597#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2598#[serde_with::serde_as]
2599#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2600pub struct Signature {
2601 /// 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"
2602 #[serde(rename = "publicKeyId")]
2603 pub public_key_id: Option<String>,
2604 /// 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.
2605 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
2606 pub signature: Option<Vec<u8>>,
2607}
2608
2609impl common::Part for Signature {}
2610
2611/// There is no detailed description.
2612///
2613/// This type is not used in any activity, and only used as *part* of another schema.
2614///
2615#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2616#[serde_with::serde_as]
2617#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2618pub struct SlsaBuilder {
2619 /// no description provided
2620 pub id: Option<String>,
2621}
2622
2623impl common::Part for SlsaBuilder {}
2624
2625/// Indicates that the builder claims certain fields in this message to be complete.
2626///
2627/// This type is not used in any activity, and only used as *part* of another schema.
2628///
2629#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2630#[serde_with::serde_as]
2631#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2632pub struct SlsaCompleteness {
2633 /// If true, the builder claims that recipe.arguments is complete, meaning that all external inputs are properly captured in the recipe.
2634 pub arguments: Option<bool>,
2635 /// If true, the builder claims that recipe.environment is claimed to be complete.
2636 pub environment: Option<bool>,
2637 /// If true, the builder claims that materials are complete, usually through some controls to prevent network access. Sometimes called "hermetic".
2638 pub materials: Option<bool>,
2639}
2640
2641impl common::Part for SlsaCompleteness {}
2642
2643/// Other properties of the build.
2644///
2645/// This type is not used in any activity, and only used as *part* of another schema.
2646///
2647#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2648#[serde_with::serde_as]
2649#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2650pub struct SlsaMetadata {
2651 /// The timestamp of when the build completed.
2652 #[serde(rename = "buildFinishedOn")]
2653 pub build_finished_on: Option<chrono::DateTime<chrono::offset::Utc>>,
2654 /// 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.
2655 #[serde(rename = "buildInvocationId")]
2656 pub build_invocation_id: Option<String>,
2657 /// The timestamp of when the build started.
2658 #[serde(rename = "buildStartedOn")]
2659 pub build_started_on: Option<chrono::DateTime<chrono::offset::Utc>>,
2660 /// Indicates that the builder claims certain fields in this message to be complete.
2661 pub completeness: Option<SlsaCompleteness>,
2662 /// If true, the builder claims that running the recipe on materials will produce bit-for-bit identical output.
2663 pub reproducible: Option<bool>,
2664}
2665
2666impl common::Part for SlsaMetadata {}
2667
2668/// There is no detailed description.
2669///
2670/// This type is not used in any activity, and only used as *part* of another schema.
2671///
2672#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2673#[serde_with::serde_as]
2674#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2675pub struct SlsaProvenance {
2676 /// required
2677 pub builder: Option<SlsaBuilder>,
2678 /// 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.
2679 pub materials: Option<Vec<Material>>,
2680 /// no description provided
2681 pub metadata: Option<SlsaMetadata>,
2682 /// 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
2683 pub recipe: Option<SlsaRecipe>,
2684}
2685
2686impl common::Part for SlsaProvenance {}
2687
2688/// 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.
2689///
2690/// This type is not used in any activity, and only used as *part* of another schema.
2691///
2692#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2693#[serde_with::serde_as]
2694#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2695pub struct SlsaProvenanceV1 {
2696 /// no description provided
2697 #[serde(rename = "buildDefinition")]
2698 pub build_definition: Option<BuildDefinition>,
2699 /// no description provided
2700 #[serde(rename = "runDetails")]
2701 pub run_details: Option<RunDetails>,
2702}
2703
2704impl common::Part for SlsaProvenanceV1 {}
2705
2706/// See full explanation of fields at slsa.dev/provenance/v0.2.
2707///
2708/// This type is not used in any activity, and only used as *part* of another schema.
2709///
2710#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2711#[serde_with::serde_as]
2712#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2713pub struct SlsaProvenanceZeroTwo {
2714 /// no description provided
2715 #[serde(rename = "buildConfig")]
2716 pub build_config: Option<HashMap<String, serde_json::Value>>,
2717 /// no description provided
2718 #[serde(rename = "buildType")]
2719 pub build_type: Option<String>,
2720 /// no description provided
2721 pub builder: Option<GrafeasV1SlsaProvenanceZeroTwoSlsaBuilder>,
2722 /// no description provided
2723 pub invocation: Option<GrafeasV1SlsaProvenanceZeroTwoSlsaInvocation>,
2724 /// no description provided
2725 pub materials: Option<Vec<GrafeasV1SlsaProvenanceZeroTwoSlsaMaterial>>,
2726 /// no description provided
2727 pub metadata: Option<GrafeasV1SlsaProvenanceZeroTwoSlsaMetadata>,
2728}
2729
2730impl common::Part for SlsaProvenanceZeroTwo {}
2731
2732/// Steps taken to build the artifact. For a TaskRun, typically each container corresponds to one step in the recipe.
2733///
2734/// This type is not used in any activity, and only used as *part* of another schema.
2735///
2736#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2737#[serde_with::serde_as]
2738#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2739pub struct SlsaRecipe {
2740 /// 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.
2741 pub arguments: Option<HashMap<String, serde_json::Value>>,
2742 /// 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.
2743 #[serde(rename = "definedInMaterial")]
2744 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
2745 pub defined_in_material: Option<i64>,
2746 /// 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.
2747 #[serde(rename = "entryPoint")]
2748 pub entry_point: Option<String>,
2749 /// 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.
2750 pub environment: Option<HashMap<String, serde_json::Value>>,
2751 /// URI indicating what type of recipe was performed. It determines the meaning of recipe.entryPoint, recipe.arguments, recipe.environment, and materials.
2752 #[serde(rename = "type")]
2753 pub type_: Option<String>,
2754}
2755
2756impl common::Part for SlsaRecipe {}
2757
2758/// Source describes the location of the source used for the build.
2759///
2760/// This type is not used in any activity, and only used as *part* of another schema.
2761///
2762#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2763#[serde_with::serde_as]
2764#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2765pub struct Source {
2766 /// 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.
2767 #[serde(rename = "additionalContexts")]
2768 pub additional_contexts: Option<Vec<SourceContext>>,
2769 /// If provided, the input binary artifacts for the build came from this location.
2770 #[serde(rename = "artifactStorageSourceUri")]
2771 pub artifact_storage_source_uri: Option<String>,
2772 /// If provided, the source code used for the build came from this location.
2773 pub context: Option<SourceContext>,
2774 /// 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.
2775 #[serde(rename = "fileHashes")]
2776 pub file_hashes: Option<HashMap<String, FileHashes>>,
2777}
2778
2779impl common::Part for Source {}
2780
2781/// 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.
2782///
2783/// This type is not used in any activity, and only used as *part* of another schema.
2784///
2785#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2786#[serde_with::serde_as]
2787#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2788pub struct SourceContext {
2789 /// A SourceContext referring to a revision in a Google Cloud Source Repo.
2790 #[serde(rename = "cloudRepo")]
2791 pub cloud_repo: Option<CloudRepoSourceContext>,
2792 /// A SourceContext referring to a Gerrit project.
2793 pub gerrit: Option<GerritSourceContext>,
2794 /// A SourceContext referring to any third party Git repo (e.g., GitHub).
2795 pub git: Option<GitSourceContext>,
2796 /// Labels with user defined metadata.
2797 pub labels: Option<HashMap<String, String>>,
2798}
2799
2800impl common::Part for SourceContext {}
2801
2802/// 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).
2803///
2804/// This type is not used in any activity, and only used as *part* of another schema.
2805///
2806#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2807#[serde_with::serde_as]
2808#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2809pub struct Status {
2810 /// The status code, which should be an enum value of google.rpc.Code.
2811 pub code: Option<i32>,
2812 /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
2813 pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
2814 /// 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.
2815 pub message: Option<String>,
2816}
2817
2818impl common::Part for Status {}
2819
2820/// There is no detailed description.
2821///
2822/// This type is not used in any activity, and only used as *part* of another schema.
2823///
2824#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2825#[serde_with::serde_as]
2826#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2827pub struct Subject {
2828 /// `"": ""` Algorithms can be e.g. sha256, sha512 See https://github.com/in-toto/attestation/blob/main/spec/field_types.md#DigestSet
2829 pub digest: Option<HashMap<String, String>>,
2830 /// no description provided
2831 pub name: Option<String>,
2832}
2833
2834impl common::Part for Subject {}
2835
2836/// Request message for `TestIamPermissions` method.
2837///
2838/// # Activities
2839///
2840/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2841/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2842///
2843/// * [locations notes test iam permissions projects](ProjectLocationNoteTestIamPermissionCall) (request)
2844/// * [locations occurrences test iam permissions projects](ProjectLocationOccurrenceTestIamPermissionCall) (request)
2845/// * [notes test iam permissions projects](ProjectNoteTestIamPermissionCall) (request)
2846/// * [occurrences test iam permissions projects](ProjectOccurrenceTestIamPermissionCall) (request)
2847#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2848#[serde_with::serde_as]
2849#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2850pub struct TestIamPermissionsRequest {
2851 /// 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).
2852 pub permissions: Option<Vec<String>>,
2853}
2854
2855impl common::RequestValue for TestIamPermissionsRequest {}
2856
2857/// Response message for `TestIamPermissions` method.
2858///
2859/// # Activities
2860///
2861/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
2862/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
2863///
2864/// * [locations notes test iam permissions projects](ProjectLocationNoteTestIamPermissionCall) (response)
2865/// * [locations occurrences test iam permissions projects](ProjectLocationOccurrenceTestIamPermissionCall) (response)
2866/// * [notes test iam permissions projects](ProjectNoteTestIamPermissionCall) (response)
2867/// * [occurrences test iam permissions projects](ProjectOccurrenceTestIamPermissionCall) (response)
2868#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2869#[serde_with::serde_as]
2870#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2871pub struct TestIamPermissionsResponse {
2872 /// A subset of `TestPermissionsRequest.permissions` that the caller is allowed.
2873 pub permissions: Option<Vec<String>>,
2874}
2875
2876impl common::ResponseResult for TestIamPermissionsResponse {}
2877
2878/// 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.
2879///
2880/// This type is not used in any activity, and only used as *part* of another schema.
2881///
2882#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2883#[serde_with::serde_as]
2884#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2885pub struct UpgradeDistribution {
2886 /// 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)
2887 pub classification: Option<String>,
2888 /// Required - The specific operating system this metadata applies to. See https://cpe.mitre.org/specification/.
2889 #[serde(rename = "cpeUri")]
2890 pub cpe_uri: Option<String>,
2891 /// The cve tied to this Upgrade.
2892 pub cve: Option<Vec<String>>,
2893 /// The severity as specified by the upstream operating system.
2894 pub severity: Option<String>,
2895}
2896
2897impl common::Part for UpgradeDistribution {}
2898
2899/// 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.
2900///
2901/// This type is not used in any activity, and only used as *part* of another schema.
2902///
2903#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2904#[serde_with::serde_as]
2905#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2906pub struct UpgradeNote {
2907 /// Metadata about the upgrade for each specific operating system.
2908 pub distributions: Option<Vec<UpgradeDistribution>>,
2909 /// Required for non-Windows OS. The package this Upgrade is for.
2910 pub package: Option<String>,
2911 /// Required for non-Windows OS. The version of the package in machine + human readable form.
2912 pub version: Option<Version>,
2913 /// Required for Windows OS. Represents the metadata about the Windows update.
2914 #[serde(rename = "windowsUpdate")]
2915 pub windows_update: Option<WindowsUpdate>,
2916}
2917
2918impl common::Part for UpgradeNote {}
2919
2920/// 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.
2921///
2922/// This type is not used in any activity, and only used as *part* of another schema.
2923///
2924#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2925#[serde_with::serde_as]
2926#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2927pub struct UpgradeOccurrence {
2928 /// 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.
2929 pub distribution: Option<UpgradeDistribution>,
2930 /// Required for non-Windows OS. The package this Upgrade is for.
2931 pub package: Option<String>,
2932 /// Required for non-Windows OS. The version of the package in a machine + human readable form.
2933 #[serde(rename = "parsedVersion")]
2934 pub parsed_version: Option<Version>,
2935 /// Required for Windows OS. Represents the metadata about the Windows update.
2936 #[serde(rename = "windowsUpdate")]
2937 pub windows_update: Option<WindowsUpdate>,
2938}
2939
2940impl common::Part for UpgradeOccurrence {}
2941
2942/// Version contains structured information about the version of a package.
2943///
2944/// This type is not used in any activity, and only used as *part* of another schema.
2945///
2946#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2947#[serde_with::serde_as]
2948#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2949pub struct Version {
2950 /// Used to correct mistakes in the version numbering scheme.
2951 pub epoch: Option<i32>,
2952 /// Human readable version string. This string is of the form :- and is only set when kind is NORMAL.
2953 #[serde(rename = "fullName")]
2954 pub full_name: Option<String>,
2955 /// 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.
2956 pub inclusive: Option<bool>,
2957 /// Required. Distinguishes between sentinel MIN/MAX versions and normal versions.
2958 pub kind: Option<String>,
2959 /// Required only when version kind is NORMAL. The main part of the version name.
2960 pub name: Option<String>,
2961 /// The iteration of the package build from the above version.
2962 pub revision: Option<String>,
2963}
2964
2965impl common::Part for Version {}
2966
2967/// VexAssessment provides all publisher provided Vex information that is related to this vulnerability.
2968///
2969/// This type is not used in any activity, and only used as *part* of another schema.
2970///
2971#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
2972#[serde_with::serde_as]
2973#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
2974pub struct VexAssessment {
2975 /// Holds the MITRE standard Common Vulnerabilities and Exposures (CVE) tracking number for the vulnerability. Deprecated: Use vulnerability_id instead to denote CVEs.
2976 pub cve: Option<String>,
2977 /// Contains information about the impact of this vulnerability, this will change with time.
2978 pub impacts: Option<Vec<String>>,
2979 /// Justification provides the justification when the state of the assessment if NOT_AFFECTED.
2980 pub justification: Option<Justification>,
2981 /// The VulnerabilityAssessment note from which this VexAssessment was generated. This will be of the form: `projects/[PROJECT_ID]/notes/[NOTE_ID]`.
2982 #[serde(rename = "noteName")]
2983 pub note_name: Option<String>,
2984 /// Holds a list of references associated with this vulnerability item and assessment.
2985 #[serde(rename = "relatedUris")]
2986 pub related_uris: Option<Vec<RelatedUrl>>,
2987 /// Specifies details on how to handle (and presumably, fix) a vulnerability.
2988 pub remediations: Option<Vec<Remediation>>,
2989 /// Provides the state of this Vulnerability assessment.
2990 pub state: Option<String>,
2991 /// The vulnerability identifier for this Assessment. Will hold one of common identifiers e.g. CVE, GHSA etc.
2992 #[serde(rename = "vulnerabilityId")]
2993 pub vulnerability_id: Option<String>,
2994}
2995
2996impl common::Part for VexAssessment {}
2997
2998/// A single VulnerabilityAssessmentNote represents one particular product's vulnerability assessment for one CVE.
2999///
3000/// This type is not used in any activity, and only used as *part* of another schema.
3001///
3002#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3003#[serde_with::serde_as]
3004#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3005pub struct VulnerabilityAssessmentNote {
3006 /// Represents a vulnerability assessment for the product.
3007 pub assessment: Option<Assessment>,
3008 /// Identifies the language used by this document, corresponding to IETF BCP 47 / RFC 5646.
3009 #[serde(rename = "languageCode")]
3010 pub language_code: Option<String>,
3011 /// A detailed description of this Vex.
3012 #[serde(rename = "longDescription")]
3013 pub long_description: Option<String>,
3014 /// The product affected by this vex.
3015 pub product: Option<Product>,
3016 /// Publisher details of this Note.
3017 pub publisher: Option<Publisher>,
3018 /// A one sentence description of this Vex.
3019 #[serde(rename = "shortDescription")]
3020 pub short_description: Option<String>,
3021 /// The title of the note. E.g. `Vex-Debian-11.4`
3022 pub title: Option<String>,
3023}
3024
3025impl common::Part for VulnerabilityAssessmentNote {}
3026
3027/// A security vulnerability that can be found in resources.
3028///
3029/// This type is not used in any activity, and only used as *part* of another schema.
3030///
3031#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3032#[serde_with::serde_as]
3033#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3034pub struct VulnerabilityNote {
3035 /// 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.
3036 #[serde(rename = "cvssScore")]
3037 pub cvss_score: Option<f32>,
3038 /// The full description of the v2 CVSS for this vulnerability.
3039 #[serde(rename = "cvssV2")]
3040 pub cvss_v2: Option<CVSS>,
3041 /// The full description of the CVSSv3 for this vulnerability.
3042 #[serde(rename = "cvssV3")]
3043 pub cvss_v3: Option<CVSSv3>,
3044 /// CVSS version used to populate cvss_score and severity.
3045 #[serde(rename = "cvssVersion")]
3046 pub cvss_version: Option<String>,
3047 /// Details of all known distros and packages affected by this vulnerability.
3048 pub details: Option<Vec<Detail>>,
3049 /// The note provider assigned severity of this vulnerability.
3050 pub severity: Option<String>,
3051 /// 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.
3052 #[serde(rename = "sourceUpdateTime")]
3053 pub source_update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
3054 /// 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.
3055 #[serde(rename = "windowsDetails")]
3056 pub windows_details: Option<Vec<WindowsDetail>>,
3057}
3058
3059impl common::Part for VulnerabilityNote {}
3060
3061/// An occurrence of a severity vulnerability on a resource.
3062///
3063/// This type is not used in any activity, and only used as *part* of another schema.
3064///
3065#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3066#[serde_with::serde_as]
3067#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3068pub struct VulnerabilityOccurrence {
3069 /// 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.
3070 #[serde(rename = "cvssScore")]
3071 pub cvss_score: Option<f32>,
3072 /// The cvss v2 score for the vulnerability.
3073 #[serde(rename = "cvssV2")]
3074 pub cvss_v2: Option<CVSS>,
3075 /// Output only. CVSS version used to populate cvss_score and severity.
3076 #[serde(rename = "cvssVersion")]
3077 pub cvss_version: Option<String>,
3078 /// The cvss v3 score for the vulnerability.
3079 pub cvssv3: Option<CVSS>,
3080 /// 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.
3081 #[serde(rename = "effectiveSeverity")]
3082 pub effective_severity: Option<String>,
3083 /// Occurrence-specific extra details about the vulnerability.
3084 #[serde(rename = "extraDetails")]
3085 pub extra_details: Option<String>,
3086 /// Output only. Whether at least one of the affected packages has a fix available.
3087 #[serde(rename = "fixAvailable")]
3088 pub fix_available: Option<bool>,
3089 /// Output only. A detailed description of this vulnerability.
3090 #[serde(rename = "longDescription")]
3091 pub long_description: Option<String>,
3092 /// Required. The set of affected locations and their fixes (if available) within the associated resource.
3093 #[serde(rename = "packageIssue")]
3094 pub package_issue: Option<Vec<PackageIssue>>,
3095 /// Output only. URLs related to this vulnerability.
3096 #[serde(rename = "relatedUrls")]
3097 pub related_urls: Option<Vec<RelatedUrl>>,
3098 /// Risk information about the vulnerability, such as CISA, EPSS, etc.
3099 pub risk: Option<Risk>,
3100 /// Output only. The note provider assigned severity of this vulnerability.
3101 pub severity: Option<String>,
3102 /// Output only. A one sentence description of this vulnerability.
3103 #[serde(rename = "shortDescription")]
3104 pub short_description: Option<String>,
3105 /// The type of package; whether native or non native (e.g., ruby gems, node.js packages, etc.).
3106 #[serde(rename = "type")]
3107 pub type_: Option<String>,
3108 /// no description provided
3109 #[serde(rename = "vexAssessment")]
3110 pub vex_assessment: Option<VexAssessment>,
3111}
3112
3113impl common::Part for VulnerabilityOccurrence {}
3114
3115/// A summary of how many vulnerability occurrences there are per resource and severity type.
3116///
3117/// # Activities
3118///
3119/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
3120/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
3121///
3122/// * [locations occurrences get vulnerability summary projects](ProjectLocationOccurrenceGetVulnerabilitySummaryCall) (response)
3123/// * [occurrences get vulnerability summary projects](ProjectOccurrenceGetVulnerabilitySummaryCall) (response)
3124#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3125#[serde_with::serde_as]
3126#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3127pub struct VulnerabilityOccurrencesSummary {
3128 /// A listing by resource of the number of fixable and total vulnerabilities.
3129 pub counts: Option<Vec<FixableTotalByDigest>>,
3130 /// Unordered list. Unreachable regions. Populated for requests from the global region when `return_partial_success` is set. Format: `projects/[PROJECT_ID]/locations/[LOCATION]`
3131 pub unreachable: Option<Vec<String>>,
3132}
3133
3134impl common::ResponseResult for VulnerabilityOccurrencesSummary {}
3135
3136/// There is no detailed description.
3137///
3138/// This type is not used in any activity, and only used as *part* of another schema.
3139///
3140#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3141#[serde_with::serde_as]
3142#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3143pub struct WindowsDetail {
3144 /// Required. The [CPE URI](https://cpe.mitre.org/specification/) this vulnerability affects.
3145 #[serde(rename = "cpeUri")]
3146 pub cpe_uri: Option<String>,
3147 /// The description of this vulnerability.
3148 pub description: Option<String>,
3149 /// 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.
3150 #[serde(rename = "fixingKbs")]
3151 pub fixing_kbs: Option<Vec<KnowledgeBase>>,
3152 /// Required. The name of this vulnerability.
3153 pub name: Option<String>,
3154}
3155
3156impl common::Part for WindowsDetail {}
3157
3158/// 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.
3159///
3160/// This type is not used in any activity, and only used as *part* of another schema.
3161///
3162#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
3163#[serde_with::serde_as]
3164#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
3165pub struct WindowsUpdate {
3166 /// The list of categories to which the update belongs.
3167 pub categories: Option<Vec<Category>>,
3168 /// The localized description of the update.
3169 pub description: Option<String>,
3170 /// Required - The unique identifier for the update.
3171 pub identity: Option<Identity>,
3172 /// The Microsoft Knowledge Base article IDs that are associated with the update.
3173 #[serde(rename = "kbArticleIds")]
3174 pub kb_article_ids: Option<Vec<String>>,
3175 /// The last published timestamp of the update.
3176 #[serde(rename = "lastPublishedTimestamp")]
3177 pub last_published_timestamp: Option<chrono::DateTime<chrono::offset::Utc>>,
3178 /// The hyperlink to the support information for the update.
3179 #[serde(rename = "supportUrl")]
3180 pub support_url: Option<String>,
3181 /// The localized title of the update.
3182 pub title: Option<String>,
3183}
3184
3185impl common::Part for WindowsUpdate {}
3186
3187// ###################
3188// MethodBuilders ###
3189// #################
3190
3191/// A builder providing access to all methods supported on *project* resources.
3192/// It is not used directly, but through the [`ContainerAnalysis`] hub.
3193///
3194/// # Example
3195///
3196/// Instantiate a resource builder
3197///
3198/// ```test_harness,no_run
3199/// extern crate hyper;
3200/// extern crate hyper_rustls;
3201/// extern crate google_containeranalysis1 as containeranalysis1;
3202///
3203/// # async fn dox() {
3204/// use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3205///
3206/// let secret: yup_oauth2::ApplicationSecret = Default::default();
3207/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
3208/// .with_native_roots()
3209/// .unwrap()
3210/// .https_only()
3211/// .enable_http2()
3212/// .build();
3213///
3214/// let executor = hyper_util::rt::TokioExecutor::new();
3215/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3216/// secret,
3217/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3218/// yup_oauth2::client::CustomHyperClientBuilder::from(
3219/// hyper_util::client::legacy::Client::builder(executor).build(connector),
3220/// ),
3221/// ).build().await.unwrap();
3222///
3223/// let client = hyper_util::client::legacy::Client::builder(
3224/// hyper_util::rt::TokioExecutor::new()
3225/// )
3226/// .build(
3227/// hyper_rustls::HttpsConnectorBuilder::new()
3228/// .with_native_roots()
3229/// .unwrap()
3230/// .https_or_http()
3231/// .enable_http2()
3232/// .build()
3233/// );
3234/// let mut hub = ContainerAnalysis::new(client, auth);
3235/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
3236/// // like `locations_notes_batch_create(...)`, `locations_notes_create(...)`, `locations_notes_delete(...)`, `locations_notes_get(...)`, `locations_notes_get_iam_policy(...)`, `locations_notes_list(...)`, `locations_notes_occurrences_list(...)`, `locations_notes_patch(...)`, `locations_notes_set_iam_policy(...)`, `locations_notes_test_iam_permissions(...)`, `locations_occurrences_batch_create(...)`, `locations_occurrences_create(...)`, `locations_occurrences_delete(...)`, `locations_occurrences_get(...)`, `locations_occurrences_get_iam_policy(...)`, `locations_occurrences_get_notes(...)`, `locations_occurrences_get_vulnerability_summary(...)`, `locations_occurrences_list(...)`, `locations_occurrences_patch(...)`, `locations_occurrences_set_iam_policy(...)`, `locations_occurrences_test_iam_permissions(...)`, `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(...)`
3237/// // to build up your call.
3238/// let rb = hub.projects();
3239/// # }
3240/// ```
3241pub struct ProjectMethods<'a, C>
3242where
3243 C: 'a,
3244{
3245 hub: &'a ContainerAnalysis<C>,
3246}
3247
3248impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
3249
3250impl<'a, C> ProjectMethods<'a, C> {
3251 /// Create a builder to help you perform the following task:
3252 ///
3253 /// Lists occurrences referencing the specified note. Provider projects can use this method to get all occurrences across consumer projects referencing the specified note.
3254 ///
3255 /// # Arguments
3256 ///
3257 /// * `name` - Required. The name of the note to list occurrences for in the form of `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.
3258 pub fn locations_notes_occurrences_list(
3259 &self,
3260 name: &str,
3261 ) -> ProjectLocationNoteOccurrenceListCall<'a, C> {
3262 ProjectLocationNoteOccurrenceListCall {
3263 hub: self.hub,
3264 _name: name.to_string(),
3265 _page_token: Default::default(),
3266 _page_size: Default::default(),
3267 _filter: Default::default(),
3268 _delegate: Default::default(),
3269 _additional_params: Default::default(),
3270 _scopes: Default::default(),
3271 }
3272 }
3273
3274 /// Create a builder to help you perform the following task:
3275 ///
3276 /// Creates new notes in batch.
3277 ///
3278 /// # Arguments
3279 ///
3280 /// * `request` - No description provided.
3281 /// * `parent` - Required. The name of the project in the form of `projects/[PROJECT_ID]`, under which the notes are to be created.
3282 pub fn locations_notes_batch_create(
3283 &self,
3284 request: BatchCreateNotesRequest,
3285 parent: &str,
3286 ) -> ProjectLocationNoteBatchCreateCall<'a, C> {
3287 ProjectLocationNoteBatchCreateCall {
3288 hub: self.hub,
3289 _request: request,
3290 _parent: parent.to_string(),
3291 _delegate: Default::default(),
3292 _additional_params: Default::default(),
3293 _scopes: Default::default(),
3294 }
3295 }
3296
3297 /// Create a builder to help you perform the following task:
3298 ///
3299 /// Creates a new note.
3300 ///
3301 /// # Arguments
3302 ///
3303 /// * `request` - No description provided.
3304 /// * `parent` - Required. The name of the project in the form of `projects/[PROJECT_ID]`, under which the note is to be created.
3305 pub fn locations_notes_create(
3306 &self,
3307 request: Note,
3308 parent: &str,
3309 ) -> ProjectLocationNoteCreateCall<'a, C> {
3310 ProjectLocationNoteCreateCall {
3311 hub: self.hub,
3312 _request: request,
3313 _parent: parent.to_string(),
3314 _note_id: Default::default(),
3315 _delegate: Default::default(),
3316 _additional_params: Default::default(),
3317 _scopes: Default::default(),
3318 }
3319 }
3320
3321 /// Create a builder to help you perform the following task:
3322 ///
3323 /// Deletes the specified note.
3324 ///
3325 /// # Arguments
3326 ///
3327 /// * `name` - Required. The name of the note in the form of `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.
3328 pub fn locations_notes_delete(&self, name: &str) -> ProjectLocationNoteDeleteCall<'a, C> {
3329 ProjectLocationNoteDeleteCall {
3330 hub: self.hub,
3331 _name: name.to_string(),
3332 _delegate: Default::default(),
3333 _additional_params: Default::default(),
3334 _scopes: Default::default(),
3335 }
3336 }
3337
3338 /// Create a builder to help you perform the following task:
3339 ///
3340 /// Gets the specified note.
3341 ///
3342 /// # Arguments
3343 ///
3344 /// * `name` - Required. The name of the note in the form of `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.
3345 pub fn locations_notes_get(&self, name: &str) -> ProjectLocationNoteGetCall<'a, C> {
3346 ProjectLocationNoteGetCall {
3347 hub: self.hub,
3348 _name: name.to_string(),
3349 _delegate: Default::default(),
3350 _additional_params: Default::default(),
3351 _scopes: Default::default(),
3352 }
3353 }
3354
3355 /// Create a builder to help you perform the following task:
3356 ///
3357 /// 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.
3358 ///
3359 /// # Arguments
3360 ///
3361 /// * `request` - No description provided.
3362 /// * `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.
3363 pub fn locations_notes_get_iam_policy(
3364 &self,
3365 request: GetIamPolicyRequest,
3366 resource: &str,
3367 ) -> ProjectLocationNoteGetIamPolicyCall<'a, C> {
3368 ProjectLocationNoteGetIamPolicyCall {
3369 hub: self.hub,
3370 _request: request,
3371 _resource: resource.to_string(),
3372 _delegate: Default::default(),
3373 _additional_params: Default::default(),
3374 _scopes: Default::default(),
3375 }
3376 }
3377
3378 /// Create a builder to help you perform the following task:
3379 ///
3380 /// Lists notes for the specified project.
3381 ///
3382 /// # Arguments
3383 ///
3384 /// * `parent` - Required. The name of the project to list notes for in the form of `projects/[PROJECT_ID]`.
3385 pub fn locations_notes_list(&self, parent: &str) -> ProjectLocationNoteListCall<'a, C> {
3386 ProjectLocationNoteListCall {
3387 hub: self.hub,
3388 _parent: parent.to_string(),
3389 _return_partial_success: Default::default(),
3390 _page_token: Default::default(),
3391 _page_size: Default::default(),
3392 _filter: Default::default(),
3393 _delegate: Default::default(),
3394 _additional_params: Default::default(),
3395 _scopes: Default::default(),
3396 }
3397 }
3398
3399 /// Create a builder to help you perform the following task:
3400 ///
3401 /// Updates the specified note.
3402 ///
3403 /// # Arguments
3404 ///
3405 /// * `request` - No description provided.
3406 /// * `name` - Required. The name of the note in the form of `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.
3407 pub fn locations_notes_patch(
3408 &self,
3409 request: Note,
3410 name: &str,
3411 ) -> ProjectLocationNotePatchCall<'a, C> {
3412 ProjectLocationNotePatchCall {
3413 hub: self.hub,
3414 _request: request,
3415 _name: name.to_string(),
3416 _update_mask: Default::default(),
3417 _delegate: Default::default(),
3418 _additional_params: Default::default(),
3419 _scopes: Default::default(),
3420 }
3421 }
3422
3423 /// Create a builder to help you perform the following task:
3424 ///
3425 /// 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.
3426 ///
3427 /// # Arguments
3428 ///
3429 /// * `request` - No description provided.
3430 /// * `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.
3431 pub fn locations_notes_set_iam_policy(
3432 &self,
3433 request: SetIamPolicyRequest,
3434 resource: &str,
3435 ) -> ProjectLocationNoteSetIamPolicyCall<'a, C> {
3436 ProjectLocationNoteSetIamPolicyCall {
3437 hub: self.hub,
3438 _request: request,
3439 _resource: resource.to_string(),
3440 _delegate: Default::default(),
3441 _additional_params: Default::default(),
3442 _scopes: Default::default(),
3443 }
3444 }
3445
3446 /// Create a builder to help you perform the following task:
3447 ///
3448 /// 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.
3449 ///
3450 /// # Arguments
3451 ///
3452 /// * `request` - No description provided.
3453 /// * `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.
3454 pub fn locations_notes_test_iam_permissions(
3455 &self,
3456 request: TestIamPermissionsRequest,
3457 resource: &str,
3458 ) -> ProjectLocationNoteTestIamPermissionCall<'a, C> {
3459 ProjectLocationNoteTestIamPermissionCall {
3460 hub: self.hub,
3461 _request: request,
3462 _resource: resource.to_string(),
3463 _delegate: Default::default(),
3464 _additional_params: Default::default(),
3465 _scopes: Default::default(),
3466 }
3467 }
3468
3469 /// Create a builder to help you perform the following task:
3470 ///
3471 /// Creates new occurrences in batch.
3472 ///
3473 /// # Arguments
3474 ///
3475 /// * `request` - No description provided.
3476 /// * `parent` - Required. The name of the project in the form of `projects/[PROJECT_ID]`, under which the occurrences are to be created.
3477 pub fn locations_occurrences_batch_create(
3478 &self,
3479 request: BatchCreateOccurrencesRequest,
3480 parent: &str,
3481 ) -> ProjectLocationOccurrenceBatchCreateCall<'a, C> {
3482 ProjectLocationOccurrenceBatchCreateCall {
3483 hub: self.hub,
3484 _request: request,
3485 _parent: parent.to_string(),
3486 _delegate: Default::default(),
3487 _additional_params: Default::default(),
3488 _scopes: Default::default(),
3489 }
3490 }
3491
3492 /// Create a builder to help you perform the following task:
3493 ///
3494 /// Creates a new occurrence.
3495 ///
3496 /// # Arguments
3497 ///
3498 /// * `request` - No description provided.
3499 /// * `parent` - Required. The name of the project in the form of `projects/[PROJECT_ID]`, under which the occurrence is to be created.
3500 pub fn locations_occurrences_create(
3501 &self,
3502 request: Occurrence,
3503 parent: &str,
3504 ) -> ProjectLocationOccurrenceCreateCall<'a, C> {
3505 ProjectLocationOccurrenceCreateCall {
3506 hub: self.hub,
3507 _request: request,
3508 _parent: parent.to_string(),
3509 _delegate: Default::default(),
3510 _additional_params: Default::default(),
3511 _scopes: Default::default(),
3512 }
3513 }
3514
3515 /// Create a builder to help you perform the following task:
3516 ///
3517 /// Deletes the specified occurrence. For example, use this method to delete an occurrence when the occurrence is no longer applicable for the given resource.
3518 ///
3519 /// # Arguments
3520 ///
3521 /// * `name` - Required. The name of the occurrence in the form of `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.
3522 pub fn locations_occurrences_delete(
3523 &self,
3524 name: &str,
3525 ) -> ProjectLocationOccurrenceDeleteCall<'a, C> {
3526 ProjectLocationOccurrenceDeleteCall {
3527 hub: self.hub,
3528 _name: name.to_string(),
3529 _delegate: Default::default(),
3530 _additional_params: Default::default(),
3531 _scopes: Default::default(),
3532 }
3533 }
3534
3535 /// Create a builder to help you perform the following task:
3536 ///
3537 /// Gets the specified occurrence.
3538 ///
3539 /// # Arguments
3540 ///
3541 /// * `name` - Required. The name of the occurrence in the form of `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.
3542 pub fn locations_occurrences_get(&self, name: &str) -> ProjectLocationOccurrenceGetCall<'a, C> {
3543 ProjectLocationOccurrenceGetCall {
3544 hub: self.hub,
3545 _name: name.to_string(),
3546 _delegate: Default::default(),
3547 _additional_params: Default::default(),
3548 _scopes: Default::default(),
3549 }
3550 }
3551
3552 /// Create a builder to help you perform the following task:
3553 ///
3554 /// 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.
3555 ///
3556 /// # Arguments
3557 ///
3558 /// * `request` - No description provided.
3559 /// * `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.
3560 pub fn locations_occurrences_get_iam_policy(
3561 &self,
3562 request: GetIamPolicyRequest,
3563 resource: &str,
3564 ) -> ProjectLocationOccurrenceGetIamPolicyCall<'a, C> {
3565 ProjectLocationOccurrenceGetIamPolicyCall {
3566 hub: self.hub,
3567 _request: request,
3568 _resource: resource.to_string(),
3569 _delegate: Default::default(),
3570 _additional_params: Default::default(),
3571 _scopes: Default::default(),
3572 }
3573 }
3574
3575 /// Create a builder to help you perform the following task:
3576 ///
3577 /// Gets the note attached to the specified occurrence. Consumer projects can use this method to get a note that belongs to a provider project.
3578 ///
3579 /// # Arguments
3580 ///
3581 /// * `name` - Required. The name of the occurrence in the form of `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.
3582 pub fn locations_occurrences_get_notes(
3583 &self,
3584 name: &str,
3585 ) -> ProjectLocationOccurrenceGetNoteCall<'a, C> {
3586 ProjectLocationOccurrenceGetNoteCall {
3587 hub: self.hub,
3588 _name: name.to_string(),
3589 _delegate: Default::default(),
3590 _additional_params: Default::default(),
3591 _scopes: Default::default(),
3592 }
3593 }
3594
3595 /// Create a builder to help you perform the following task:
3596 ///
3597 /// Gets a summary of the number and severity of occurrences.
3598 ///
3599 /// # Arguments
3600 ///
3601 /// * `parent` - Required. The name of the project to get a vulnerability summary for in the form of `projects/[PROJECT_ID]`.
3602 pub fn locations_occurrences_get_vulnerability_summary(
3603 &self,
3604 parent: &str,
3605 ) -> ProjectLocationOccurrenceGetVulnerabilitySummaryCall<'a, C> {
3606 ProjectLocationOccurrenceGetVulnerabilitySummaryCall {
3607 hub: self.hub,
3608 _parent: parent.to_string(),
3609 _return_partial_success: Default::default(),
3610 _filter: Default::default(),
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 /// Lists occurrences for the specified project.
3620 ///
3621 /// # Arguments
3622 ///
3623 /// * `parent` - Required. The name of the project to list occurrences for in the form of `projects/[PROJECT_ID]`.
3624 pub fn locations_occurrences_list(
3625 &self,
3626 parent: &str,
3627 ) -> ProjectLocationOccurrenceListCall<'a, C> {
3628 ProjectLocationOccurrenceListCall {
3629 hub: self.hub,
3630 _parent: parent.to_string(),
3631 _return_partial_success: Default::default(),
3632 _page_token: Default::default(),
3633 _page_size: Default::default(),
3634 _filter: Default::default(),
3635 _delegate: Default::default(),
3636 _additional_params: Default::default(),
3637 _scopes: Default::default(),
3638 }
3639 }
3640
3641 /// Create a builder to help you perform the following task:
3642 ///
3643 /// Updates the specified occurrence.
3644 ///
3645 /// # Arguments
3646 ///
3647 /// * `request` - No description provided.
3648 /// * `name` - Required. The name of the occurrence in the form of `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.
3649 pub fn locations_occurrences_patch(
3650 &self,
3651 request: Occurrence,
3652 name: &str,
3653 ) -> ProjectLocationOccurrencePatchCall<'a, C> {
3654 ProjectLocationOccurrencePatchCall {
3655 hub: self.hub,
3656 _request: request,
3657 _name: name.to_string(),
3658 _update_mask: Default::default(),
3659 _delegate: Default::default(),
3660 _additional_params: Default::default(),
3661 _scopes: Default::default(),
3662 }
3663 }
3664
3665 /// Create a builder to help you perform the following task:
3666 ///
3667 /// 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.
3668 ///
3669 /// # Arguments
3670 ///
3671 /// * `request` - No description provided.
3672 /// * `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.
3673 pub fn locations_occurrences_set_iam_policy(
3674 &self,
3675 request: SetIamPolicyRequest,
3676 resource: &str,
3677 ) -> ProjectLocationOccurrenceSetIamPolicyCall<'a, C> {
3678 ProjectLocationOccurrenceSetIamPolicyCall {
3679 hub: self.hub,
3680 _request: request,
3681 _resource: resource.to_string(),
3682 _delegate: Default::default(),
3683 _additional_params: Default::default(),
3684 _scopes: Default::default(),
3685 }
3686 }
3687
3688 /// Create a builder to help you perform the following task:
3689 ///
3690 /// 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.
3691 ///
3692 /// # Arguments
3693 ///
3694 /// * `request` - No description provided.
3695 /// * `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.
3696 pub fn locations_occurrences_test_iam_permissions(
3697 &self,
3698 request: TestIamPermissionsRequest,
3699 resource: &str,
3700 ) -> ProjectLocationOccurrenceTestIamPermissionCall<'a, C> {
3701 ProjectLocationOccurrenceTestIamPermissionCall {
3702 hub: self.hub,
3703 _request: request,
3704 _resource: resource.to_string(),
3705 _delegate: Default::default(),
3706 _additional_params: Default::default(),
3707 _scopes: Default::default(),
3708 }
3709 }
3710
3711 /// Create a builder to help you perform the following task:
3712 ///
3713 /// Generates an SBOM for the given resource.
3714 ///
3715 /// # Arguments
3716 ///
3717 /// * `request` - No description provided.
3718 /// * `name` - Required. The name of the resource in the form of `projects/[PROJECT_ID]/resources/[RESOURCE_URL]`.
3719 pub fn locations_resources_export_sbom(
3720 &self,
3721 request: ExportSBOMRequest,
3722 name: &str,
3723 ) -> ProjectLocationResourceExportSBOMCall<'a, C> {
3724 ProjectLocationResourceExportSBOMCall {
3725 hub: self.hub,
3726 _request: request,
3727 _name: name.to_string(),
3728 _delegate: Default::default(),
3729 _additional_params: Default::default(),
3730 _scopes: Default::default(),
3731 }
3732 }
3733
3734 /// Create a builder to help you perform the following task:
3735 ///
3736 /// Lists occurrences referencing the specified note. Provider projects can use this method to get all occurrences across consumer projects referencing the specified note.
3737 ///
3738 /// # Arguments
3739 ///
3740 /// * `name` - Required. The name of the note to list occurrences for in the form of `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.
3741 pub fn notes_occurrences_list(&self, name: &str) -> ProjectNoteOccurrenceListCall<'a, C> {
3742 ProjectNoteOccurrenceListCall {
3743 hub: self.hub,
3744 _name: name.to_string(),
3745 _page_token: Default::default(),
3746 _page_size: Default::default(),
3747 _filter: Default::default(),
3748 _delegate: Default::default(),
3749 _additional_params: Default::default(),
3750 _scopes: Default::default(),
3751 }
3752 }
3753
3754 /// Create a builder to help you perform the following task:
3755 ///
3756 /// Creates new notes in batch.
3757 ///
3758 /// # Arguments
3759 ///
3760 /// * `request` - No description provided.
3761 /// * `parent` - Required. The name of the project in the form of `projects/[PROJECT_ID]`, under which the notes are to be created.
3762 pub fn notes_batch_create(
3763 &self,
3764 request: BatchCreateNotesRequest,
3765 parent: &str,
3766 ) -> ProjectNoteBatchCreateCall<'a, C> {
3767 ProjectNoteBatchCreateCall {
3768 hub: self.hub,
3769 _request: request,
3770 _parent: parent.to_string(),
3771 _delegate: Default::default(),
3772 _additional_params: Default::default(),
3773 _scopes: Default::default(),
3774 }
3775 }
3776
3777 /// Create a builder to help you perform the following task:
3778 ///
3779 /// Creates a new note.
3780 ///
3781 /// # Arguments
3782 ///
3783 /// * `request` - No description provided.
3784 /// * `parent` - Required. The name of the project in the form of `projects/[PROJECT_ID]`, under which the note is to be created.
3785 pub fn notes_create(&self, request: Note, parent: &str) -> ProjectNoteCreateCall<'a, C> {
3786 ProjectNoteCreateCall {
3787 hub: self.hub,
3788 _request: request,
3789 _parent: parent.to_string(),
3790 _note_id: Default::default(),
3791 _delegate: Default::default(),
3792 _additional_params: Default::default(),
3793 _scopes: Default::default(),
3794 }
3795 }
3796
3797 /// Create a builder to help you perform the following task:
3798 ///
3799 /// Deletes the specified note.
3800 ///
3801 /// # Arguments
3802 ///
3803 /// * `name` - Required. The name of the note in the form of `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.
3804 pub fn notes_delete(&self, name: &str) -> ProjectNoteDeleteCall<'a, C> {
3805 ProjectNoteDeleteCall {
3806 hub: self.hub,
3807 _name: name.to_string(),
3808 _delegate: Default::default(),
3809 _additional_params: Default::default(),
3810 _scopes: Default::default(),
3811 }
3812 }
3813
3814 /// Create a builder to help you perform the following task:
3815 ///
3816 /// Gets the specified note.
3817 ///
3818 /// # Arguments
3819 ///
3820 /// * `name` - Required. The name of the note in the form of `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.
3821 pub fn notes_get(&self, name: &str) -> ProjectNoteGetCall<'a, C> {
3822 ProjectNoteGetCall {
3823 hub: self.hub,
3824 _name: name.to_string(),
3825 _delegate: Default::default(),
3826 _additional_params: Default::default(),
3827 _scopes: Default::default(),
3828 }
3829 }
3830
3831 /// Create a builder to help you perform the following task:
3832 ///
3833 /// 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.
3834 ///
3835 /// # Arguments
3836 ///
3837 /// * `request` - No description provided.
3838 /// * `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.
3839 pub fn notes_get_iam_policy(
3840 &self,
3841 request: GetIamPolicyRequest,
3842 resource: &str,
3843 ) -> ProjectNoteGetIamPolicyCall<'a, C> {
3844 ProjectNoteGetIamPolicyCall {
3845 hub: self.hub,
3846 _request: request,
3847 _resource: resource.to_string(),
3848 _delegate: Default::default(),
3849 _additional_params: Default::default(),
3850 _scopes: Default::default(),
3851 }
3852 }
3853
3854 /// Create a builder to help you perform the following task:
3855 ///
3856 /// Lists notes for the specified project.
3857 ///
3858 /// # Arguments
3859 ///
3860 /// * `parent` - Required. The name of the project to list notes for in the form of `projects/[PROJECT_ID]`.
3861 pub fn notes_list(&self, parent: &str) -> ProjectNoteListCall<'a, C> {
3862 ProjectNoteListCall {
3863 hub: self.hub,
3864 _parent: parent.to_string(),
3865 _return_partial_success: Default::default(),
3866 _page_token: Default::default(),
3867 _page_size: Default::default(),
3868 _filter: Default::default(),
3869 _delegate: Default::default(),
3870 _additional_params: Default::default(),
3871 _scopes: Default::default(),
3872 }
3873 }
3874
3875 /// Create a builder to help you perform the following task:
3876 ///
3877 /// Updates the specified note.
3878 ///
3879 /// # Arguments
3880 ///
3881 /// * `request` - No description provided.
3882 /// * `name` - Required. The name of the note in the form of `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.
3883 pub fn notes_patch(&self, request: Note, name: &str) -> ProjectNotePatchCall<'a, C> {
3884 ProjectNotePatchCall {
3885 hub: self.hub,
3886 _request: request,
3887 _name: name.to_string(),
3888 _update_mask: Default::default(),
3889 _delegate: Default::default(),
3890 _additional_params: Default::default(),
3891 _scopes: Default::default(),
3892 }
3893 }
3894
3895 /// Create a builder to help you perform the following task:
3896 ///
3897 /// 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.
3898 ///
3899 /// # Arguments
3900 ///
3901 /// * `request` - No description provided.
3902 /// * `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.
3903 pub fn notes_set_iam_policy(
3904 &self,
3905 request: SetIamPolicyRequest,
3906 resource: &str,
3907 ) -> ProjectNoteSetIamPolicyCall<'a, C> {
3908 ProjectNoteSetIamPolicyCall {
3909 hub: self.hub,
3910 _request: request,
3911 _resource: resource.to_string(),
3912 _delegate: Default::default(),
3913 _additional_params: Default::default(),
3914 _scopes: Default::default(),
3915 }
3916 }
3917
3918 /// Create a builder to help you perform the following task:
3919 ///
3920 /// 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.
3921 ///
3922 /// # Arguments
3923 ///
3924 /// * `request` - No description provided.
3925 /// * `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.
3926 pub fn notes_test_iam_permissions(
3927 &self,
3928 request: TestIamPermissionsRequest,
3929 resource: &str,
3930 ) -> ProjectNoteTestIamPermissionCall<'a, C> {
3931 ProjectNoteTestIamPermissionCall {
3932 hub: self.hub,
3933 _request: request,
3934 _resource: resource.to_string(),
3935 _delegate: Default::default(),
3936 _additional_params: Default::default(),
3937 _scopes: Default::default(),
3938 }
3939 }
3940
3941 /// Create a builder to help you perform the following task:
3942 ///
3943 /// Creates new occurrences in batch.
3944 ///
3945 /// # Arguments
3946 ///
3947 /// * `request` - No description provided.
3948 /// * `parent` - Required. The name of the project in the form of `projects/[PROJECT_ID]`, under which the occurrences are to be created.
3949 pub fn occurrences_batch_create(
3950 &self,
3951 request: BatchCreateOccurrencesRequest,
3952 parent: &str,
3953 ) -> ProjectOccurrenceBatchCreateCall<'a, C> {
3954 ProjectOccurrenceBatchCreateCall {
3955 hub: self.hub,
3956 _request: request,
3957 _parent: parent.to_string(),
3958 _delegate: Default::default(),
3959 _additional_params: Default::default(),
3960 _scopes: Default::default(),
3961 }
3962 }
3963
3964 /// Create a builder to help you perform the following task:
3965 ///
3966 /// Creates a new occurrence.
3967 ///
3968 /// # Arguments
3969 ///
3970 /// * `request` - No description provided.
3971 /// * `parent` - Required. The name of the project in the form of `projects/[PROJECT_ID]`, under which the occurrence is to be created.
3972 pub fn occurrences_create(
3973 &self,
3974 request: Occurrence,
3975 parent: &str,
3976 ) -> ProjectOccurrenceCreateCall<'a, C> {
3977 ProjectOccurrenceCreateCall {
3978 hub: self.hub,
3979 _request: request,
3980 _parent: parent.to_string(),
3981 _delegate: Default::default(),
3982 _additional_params: Default::default(),
3983 _scopes: Default::default(),
3984 }
3985 }
3986
3987 /// Create a builder to help you perform the following task:
3988 ///
3989 /// Deletes the specified occurrence. For example, use this method to delete an occurrence when the occurrence is no longer applicable for the given resource.
3990 ///
3991 /// # Arguments
3992 ///
3993 /// * `name` - Required. The name of the occurrence in the form of `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.
3994 pub fn occurrences_delete(&self, name: &str) -> ProjectOccurrenceDeleteCall<'a, C> {
3995 ProjectOccurrenceDeleteCall {
3996 hub: self.hub,
3997 _name: name.to_string(),
3998 _delegate: Default::default(),
3999 _additional_params: Default::default(),
4000 _scopes: Default::default(),
4001 }
4002 }
4003
4004 /// Create a builder to help you perform the following task:
4005 ///
4006 /// Gets the specified occurrence.
4007 ///
4008 /// # Arguments
4009 ///
4010 /// * `name` - Required. The name of the occurrence in the form of `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.
4011 pub fn occurrences_get(&self, name: &str) -> ProjectOccurrenceGetCall<'a, C> {
4012 ProjectOccurrenceGetCall {
4013 hub: self.hub,
4014 _name: name.to_string(),
4015 _delegate: Default::default(),
4016 _additional_params: Default::default(),
4017 _scopes: Default::default(),
4018 }
4019 }
4020
4021 /// Create a builder to help you perform the following task:
4022 ///
4023 /// 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.
4024 ///
4025 /// # Arguments
4026 ///
4027 /// * `request` - No description provided.
4028 /// * `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.
4029 pub fn occurrences_get_iam_policy(
4030 &self,
4031 request: GetIamPolicyRequest,
4032 resource: &str,
4033 ) -> ProjectOccurrenceGetIamPolicyCall<'a, C> {
4034 ProjectOccurrenceGetIamPolicyCall {
4035 hub: self.hub,
4036 _request: request,
4037 _resource: resource.to_string(),
4038 _delegate: Default::default(),
4039 _additional_params: Default::default(),
4040 _scopes: Default::default(),
4041 }
4042 }
4043
4044 /// Create a builder to help you perform the following task:
4045 ///
4046 /// Gets the note attached to the specified occurrence. Consumer projects can use this method to get a note that belongs to a provider project.
4047 ///
4048 /// # Arguments
4049 ///
4050 /// * `name` - Required. The name of the occurrence in the form of `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.
4051 pub fn occurrences_get_notes(&self, name: &str) -> ProjectOccurrenceGetNoteCall<'a, C> {
4052 ProjectOccurrenceGetNoteCall {
4053 hub: self.hub,
4054 _name: name.to_string(),
4055 _delegate: Default::default(),
4056 _additional_params: Default::default(),
4057 _scopes: Default::default(),
4058 }
4059 }
4060
4061 /// Create a builder to help you perform the following task:
4062 ///
4063 /// Gets a summary of the number and severity of occurrences.
4064 ///
4065 /// # Arguments
4066 ///
4067 /// * `parent` - Required. The name of the project to get a vulnerability summary for in the form of `projects/[PROJECT_ID]`.
4068 pub fn occurrences_get_vulnerability_summary(
4069 &self,
4070 parent: &str,
4071 ) -> ProjectOccurrenceGetVulnerabilitySummaryCall<'a, C> {
4072 ProjectOccurrenceGetVulnerabilitySummaryCall {
4073 hub: self.hub,
4074 _parent: parent.to_string(),
4075 _return_partial_success: Default::default(),
4076 _filter: Default::default(),
4077 _delegate: Default::default(),
4078 _additional_params: Default::default(),
4079 _scopes: Default::default(),
4080 }
4081 }
4082
4083 /// Create a builder to help you perform the following task:
4084 ///
4085 /// Lists occurrences for the specified project.
4086 ///
4087 /// # Arguments
4088 ///
4089 /// * `parent` - Required. The name of the project to list occurrences for in the form of `projects/[PROJECT_ID]`.
4090 pub fn occurrences_list(&self, parent: &str) -> ProjectOccurrenceListCall<'a, C> {
4091 ProjectOccurrenceListCall {
4092 hub: self.hub,
4093 _parent: parent.to_string(),
4094 _return_partial_success: Default::default(),
4095 _page_token: Default::default(),
4096 _page_size: Default::default(),
4097 _filter: Default::default(),
4098 _delegate: Default::default(),
4099 _additional_params: Default::default(),
4100 _scopes: Default::default(),
4101 }
4102 }
4103
4104 /// Create a builder to help you perform the following task:
4105 ///
4106 /// Updates the specified occurrence.
4107 ///
4108 /// # Arguments
4109 ///
4110 /// * `request` - No description provided.
4111 /// * `name` - Required. The name of the occurrence in the form of `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.
4112 pub fn occurrences_patch(
4113 &self,
4114 request: Occurrence,
4115 name: &str,
4116 ) -> ProjectOccurrencePatchCall<'a, C> {
4117 ProjectOccurrencePatchCall {
4118 hub: self.hub,
4119 _request: request,
4120 _name: name.to_string(),
4121 _update_mask: Default::default(),
4122 _delegate: Default::default(),
4123 _additional_params: Default::default(),
4124 _scopes: Default::default(),
4125 }
4126 }
4127
4128 /// Create a builder to help you perform the following task:
4129 ///
4130 /// 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.
4131 ///
4132 /// # Arguments
4133 ///
4134 /// * `request` - No description provided.
4135 /// * `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.
4136 pub fn occurrences_set_iam_policy(
4137 &self,
4138 request: SetIamPolicyRequest,
4139 resource: &str,
4140 ) -> ProjectOccurrenceSetIamPolicyCall<'a, C> {
4141 ProjectOccurrenceSetIamPolicyCall {
4142 hub: self.hub,
4143 _request: request,
4144 _resource: resource.to_string(),
4145 _delegate: Default::default(),
4146 _additional_params: Default::default(),
4147 _scopes: Default::default(),
4148 }
4149 }
4150
4151 /// Create a builder to help you perform the following task:
4152 ///
4153 /// 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.
4154 ///
4155 /// # Arguments
4156 ///
4157 /// * `request` - No description provided.
4158 /// * `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.
4159 pub fn occurrences_test_iam_permissions(
4160 &self,
4161 request: TestIamPermissionsRequest,
4162 resource: &str,
4163 ) -> ProjectOccurrenceTestIamPermissionCall<'a, C> {
4164 ProjectOccurrenceTestIamPermissionCall {
4165 hub: self.hub,
4166 _request: request,
4167 _resource: resource.to_string(),
4168 _delegate: Default::default(),
4169 _additional_params: Default::default(),
4170 _scopes: Default::default(),
4171 }
4172 }
4173
4174 /// Create a builder to help you perform the following task:
4175 ///
4176 /// Generates an SBOM for the given resource.
4177 ///
4178 /// # Arguments
4179 ///
4180 /// * `request` - No description provided.
4181 /// * `name` - Required. The name of the resource in the form of `projects/[PROJECT_ID]/resources/[RESOURCE_URL]`.
4182 pub fn resources_export_sbom(
4183 &self,
4184 request: ExportSBOMRequest,
4185 name: &str,
4186 ) -> ProjectResourceExportSBOMCall<'a, C> {
4187 ProjectResourceExportSBOMCall {
4188 hub: self.hub,
4189 _request: request,
4190 _name: name.to_string(),
4191 _delegate: Default::default(),
4192 _additional_params: Default::default(),
4193 _scopes: Default::default(),
4194 }
4195 }
4196}
4197
4198// ###################
4199// CallBuilders ###
4200// #################
4201
4202/// Lists occurrences referencing the specified note. Provider projects can use this method to get all occurrences across consumer projects referencing the specified note.
4203///
4204/// A builder for the *locations.notes.occurrences.list* method supported by a *project* resource.
4205/// It is not used directly, but through a [`ProjectMethods`] instance.
4206///
4207/// # Example
4208///
4209/// Instantiate a resource method builder
4210///
4211/// ```test_harness,no_run
4212/// # extern crate hyper;
4213/// # extern crate hyper_rustls;
4214/// # extern crate google_containeranalysis1 as containeranalysis1;
4215/// # async fn dox() {
4216/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4217///
4218/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4219/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4220/// # .with_native_roots()
4221/// # .unwrap()
4222/// # .https_only()
4223/// # .enable_http2()
4224/// # .build();
4225///
4226/// # let executor = hyper_util::rt::TokioExecutor::new();
4227/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4228/// # secret,
4229/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4230/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4231/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4232/// # ),
4233/// # ).build().await.unwrap();
4234///
4235/// # let client = hyper_util::client::legacy::Client::builder(
4236/// # hyper_util::rt::TokioExecutor::new()
4237/// # )
4238/// # .build(
4239/// # hyper_rustls::HttpsConnectorBuilder::new()
4240/// # .with_native_roots()
4241/// # .unwrap()
4242/// # .https_or_http()
4243/// # .enable_http2()
4244/// # .build()
4245/// # );
4246/// # let mut hub = ContainerAnalysis::new(client, auth);
4247/// // You can configure optional parameters by calling the respective setters at will, and
4248/// // execute the final call using `doit()`.
4249/// // Values shown here are possibly random and not representative !
4250/// let result = hub.projects().locations_notes_occurrences_list("name")
4251/// .page_token("sed")
4252/// .page_size(-2)
4253/// .filter("takimata")
4254/// .doit().await;
4255/// # }
4256/// ```
4257pub struct ProjectLocationNoteOccurrenceListCall<'a, C>
4258where
4259 C: 'a,
4260{
4261 hub: &'a ContainerAnalysis<C>,
4262 _name: String,
4263 _page_token: Option<String>,
4264 _page_size: Option<i32>,
4265 _filter: Option<String>,
4266 _delegate: Option<&'a mut dyn common::Delegate>,
4267 _additional_params: HashMap<String, String>,
4268 _scopes: BTreeSet<String>,
4269}
4270
4271impl<'a, C> common::CallBuilder for ProjectLocationNoteOccurrenceListCall<'a, C> {}
4272
4273impl<'a, C> ProjectLocationNoteOccurrenceListCall<'a, C>
4274where
4275 C: common::Connector,
4276{
4277 /// Perform the operation you have build so far.
4278 pub async fn doit(mut self) -> common::Result<(common::Response, ListNoteOccurrencesResponse)> {
4279 use std::borrow::Cow;
4280 use std::io::{Read, Seek};
4281
4282 use common::{url::Params, ToParts};
4283 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4284
4285 let mut dd = common::DefaultDelegate;
4286 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4287 dlg.begin(common::MethodInfo {
4288 id: "containeranalysis.projects.locations.notes.occurrences.list",
4289 http_method: hyper::Method::GET,
4290 });
4291
4292 for &field in ["alt", "name", "pageToken", "pageSize", "filter"].iter() {
4293 if self._additional_params.contains_key(field) {
4294 dlg.finished(false);
4295 return Err(common::Error::FieldClash(field));
4296 }
4297 }
4298
4299 let mut params = Params::with_capacity(6 + self._additional_params.len());
4300 params.push("name", self._name);
4301 if let Some(value) = self._page_token.as_ref() {
4302 params.push("pageToken", value);
4303 }
4304 if let Some(value) = self._page_size.as_ref() {
4305 params.push("pageSize", value.to_string());
4306 }
4307 if let Some(value) = self._filter.as_ref() {
4308 params.push("filter", value);
4309 }
4310
4311 params.extend(self._additional_params.iter());
4312
4313 params.push("alt", "json");
4314 let mut url = self.hub._base_url.clone() + "v1/{+name}/occurrences";
4315 if self._scopes.is_empty() {
4316 self._scopes
4317 .insert(Scope::CloudPlatform.as_ref().to_string());
4318 }
4319
4320 #[allow(clippy::single_element_loop)]
4321 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4322 url = params.uri_replacement(url, param_name, find_this, true);
4323 }
4324 {
4325 let to_remove = ["name"];
4326 params.remove_params(&to_remove);
4327 }
4328
4329 let url = params.parse_with_url(&url);
4330
4331 loop {
4332 let token = match self
4333 .hub
4334 .auth
4335 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4336 .await
4337 {
4338 Ok(token) => token,
4339 Err(e) => match dlg.token(e) {
4340 Ok(token) => token,
4341 Err(e) => {
4342 dlg.finished(false);
4343 return Err(common::Error::MissingToken(e));
4344 }
4345 },
4346 };
4347 let mut req_result = {
4348 let client = &self.hub.client;
4349 dlg.pre_request();
4350 let mut req_builder = hyper::Request::builder()
4351 .method(hyper::Method::GET)
4352 .uri(url.as_str())
4353 .header(USER_AGENT, self.hub._user_agent.clone());
4354
4355 if let Some(token) = token.as_ref() {
4356 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4357 }
4358
4359 let request = req_builder
4360 .header(CONTENT_LENGTH, 0_u64)
4361 .body(common::to_body::<String>(None));
4362
4363 client.request(request.unwrap()).await
4364 };
4365
4366 match req_result {
4367 Err(err) => {
4368 if let common::Retry::After(d) = dlg.http_error(&err) {
4369 sleep(d).await;
4370 continue;
4371 }
4372 dlg.finished(false);
4373 return Err(common::Error::HttpError(err));
4374 }
4375 Ok(res) => {
4376 let (mut parts, body) = res.into_parts();
4377 let mut body = common::Body::new(body);
4378 if !parts.status.is_success() {
4379 let bytes = common::to_bytes(body).await.unwrap_or_default();
4380 let error = serde_json::from_str(&common::to_string(&bytes));
4381 let response = common::to_response(parts, bytes.into());
4382
4383 if let common::Retry::After(d) =
4384 dlg.http_failure(&response, error.as_ref().ok())
4385 {
4386 sleep(d).await;
4387 continue;
4388 }
4389
4390 dlg.finished(false);
4391
4392 return Err(match error {
4393 Ok(value) => common::Error::BadRequest(value),
4394 _ => common::Error::Failure(response),
4395 });
4396 }
4397 let response = {
4398 let bytes = common::to_bytes(body).await.unwrap_or_default();
4399 let encoded = common::to_string(&bytes);
4400 match serde_json::from_str(&encoded) {
4401 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4402 Err(error) => {
4403 dlg.response_json_decode_error(&encoded, &error);
4404 return Err(common::Error::JsonDecodeError(
4405 encoded.to_string(),
4406 error,
4407 ));
4408 }
4409 }
4410 };
4411
4412 dlg.finished(true);
4413 return Ok(response);
4414 }
4415 }
4416 }
4417 }
4418
4419 /// Required. The name of the note to list occurrences for in the form of `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.
4420 ///
4421 /// Sets the *name* path property to the given value.
4422 ///
4423 /// Even though the property as already been set when instantiating this call,
4424 /// we provide this method for API completeness.
4425 pub fn name(mut self, new_value: &str) -> ProjectLocationNoteOccurrenceListCall<'a, C> {
4426 self._name = new_value.to_string();
4427 self
4428 }
4429 /// Token to provide to skip to a particular spot in the list.
4430 ///
4431 /// Sets the *page token* query property to the given value.
4432 pub fn page_token(mut self, new_value: &str) -> ProjectLocationNoteOccurrenceListCall<'a, C> {
4433 self._page_token = Some(new_value.to_string());
4434 self
4435 }
4436 /// Number of occurrences to return in the list.
4437 ///
4438 /// Sets the *page size* query property to the given value.
4439 pub fn page_size(mut self, new_value: i32) -> ProjectLocationNoteOccurrenceListCall<'a, C> {
4440 self._page_size = Some(new_value);
4441 self
4442 }
4443 /// The filter expression.
4444 ///
4445 /// Sets the *filter* query property to the given value.
4446 pub fn filter(mut self, new_value: &str) -> ProjectLocationNoteOccurrenceListCall<'a, C> {
4447 self._filter = Some(new_value.to_string());
4448 self
4449 }
4450 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4451 /// while executing the actual API request.
4452 ///
4453 /// ````text
4454 /// It should be used to handle progress information, and to implement a certain level of resilience.
4455 /// ````
4456 ///
4457 /// Sets the *delegate* property to the given value.
4458 pub fn delegate(
4459 mut self,
4460 new_value: &'a mut dyn common::Delegate,
4461 ) -> ProjectLocationNoteOccurrenceListCall<'a, C> {
4462 self._delegate = Some(new_value);
4463 self
4464 }
4465
4466 /// Set any additional parameter of the query string used in the request.
4467 /// It should be used to set parameters which are not yet available through their own
4468 /// setters.
4469 ///
4470 /// Please note that this method must not be used to set any of the known parameters
4471 /// which have their own setter method. If done anyway, the request will fail.
4472 ///
4473 /// # Additional Parameters
4474 ///
4475 /// * *$.xgafv* (query-string) - V1 error format.
4476 /// * *access_token* (query-string) - OAuth access token.
4477 /// * *alt* (query-string) - Data format for response.
4478 /// * *callback* (query-string) - JSONP
4479 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4480 /// * *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.
4481 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4482 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4483 /// * *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.
4484 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4485 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4486 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNoteOccurrenceListCall<'a, C>
4487 where
4488 T: AsRef<str>,
4489 {
4490 self._additional_params
4491 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4492 self
4493 }
4494
4495 /// Identifies the authorization scope for the method you are building.
4496 ///
4497 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4498 /// [`Scope::CloudPlatform`].
4499 ///
4500 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4501 /// tokens for more than one scope.
4502 ///
4503 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4504 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4505 /// sufficient, a read-write scope will do as well.
4506 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNoteOccurrenceListCall<'a, C>
4507 where
4508 St: AsRef<str>,
4509 {
4510 self._scopes.insert(String::from(scope.as_ref()));
4511 self
4512 }
4513 /// Identifies the authorization scope(s) for the method you are building.
4514 ///
4515 /// See [`Self::add_scope()`] for details.
4516 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNoteOccurrenceListCall<'a, C>
4517 where
4518 I: IntoIterator<Item = St>,
4519 St: AsRef<str>,
4520 {
4521 self._scopes
4522 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4523 self
4524 }
4525
4526 /// Removes all scopes, and no default scope will be used either.
4527 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4528 /// for details).
4529 pub fn clear_scopes(mut self) -> ProjectLocationNoteOccurrenceListCall<'a, C> {
4530 self._scopes.clear();
4531 self
4532 }
4533}
4534
4535/// Creates new notes in batch.
4536///
4537/// A builder for the *locations.notes.batchCreate* method supported by a *project* resource.
4538/// It is not used directly, but through a [`ProjectMethods`] instance.
4539///
4540/// # Example
4541///
4542/// Instantiate a resource method builder
4543///
4544/// ```test_harness,no_run
4545/// # extern crate hyper;
4546/// # extern crate hyper_rustls;
4547/// # extern crate google_containeranalysis1 as containeranalysis1;
4548/// use containeranalysis1::api::BatchCreateNotesRequest;
4549/// # async fn dox() {
4550/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4551///
4552/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4553/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4554/// # .with_native_roots()
4555/// # .unwrap()
4556/// # .https_only()
4557/// # .enable_http2()
4558/// # .build();
4559///
4560/// # let executor = hyper_util::rt::TokioExecutor::new();
4561/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4562/// # secret,
4563/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4564/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4565/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4566/// # ),
4567/// # ).build().await.unwrap();
4568///
4569/// # let client = hyper_util::client::legacy::Client::builder(
4570/// # hyper_util::rt::TokioExecutor::new()
4571/// # )
4572/// # .build(
4573/// # hyper_rustls::HttpsConnectorBuilder::new()
4574/// # .with_native_roots()
4575/// # .unwrap()
4576/// # .https_or_http()
4577/// # .enable_http2()
4578/// # .build()
4579/// # );
4580/// # let mut hub = ContainerAnalysis::new(client, auth);
4581/// // As the method needs a request, you would usually fill it with the desired information
4582/// // into the respective structure. Some of the parts shown here might not be applicable !
4583/// // Values shown here are possibly random and not representative !
4584/// let mut req = BatchCreateNotesRequest::default();
4585///
4586/// // You can configure optional parameters by calling the respective setters at will, and
4587/// // execute the final call using `doit()`.
4588/// // Values shown here are possibly random and not representative !
4589/// let result = hub.projects().locations_notes_batch_create(req, "parent")
4590/// .doit().await;
4591/// # }
4592/// ```
4593pub struct ProjectLocationNoteBatchCreateCall<'a, C>
4594where
4595 C: 'a,
4596{
4597 hub: &'a ContainerAnalysis<C>,
4598 _request: BatchCreateNotesRequest,
4599 _parent: String,
4600 _delegate: Option<&'a mut dyn common::Delegate>,
4601 _additional_params: HashMap<String, String>,
4602 _scopes: BTreeSet<String>,
4603}
4604
4605impl<'a, C> common::CallBuilder for ProjectLocationNoteBatchCreateCall<'a, C> {}
4606
4607impl<'a, C> ProjectLocationNoteBatchCreateCall<'a, C>
4608where
4609 C: common::Connector,
4610{
4611 /// Perform the operation you have build so far.
4612 pub async fn doit(mut self) -> common::Result<(common::Response, BatchCreateNotesResponse)> {
4613 use std::borrow::Cow;
4614 use std::io::{Read, Seek};
4615
4616 use common::{url::Params, ToParts};
4617 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4618
4619 let mut dd = common::DefaultDelegate;
4620 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4621 dlg.begin(common::MethodInfo {
4622 id: "containeranalysis.projects.locations.notes.batchCreate",
4623 http_method: hyper::Method::POST,
4624 });
4625
4626 for &field in ["alt", "parent"].iter() {
4627 if self._additional_params.contains_key(field) {
4628 dlg.finished(false);
4629 return Err(common::Error::FieldClash(field));
4630 }
4631 }
4632
4633 let mut params = Params::with_capacity(4 + self._additional_params.len());
4634 params.push("parent", self._parent);
4635
4636 params.extend(self._additional_params.iter());
4637
4638 params.push("alt", "json");
4639 let mut url = self.hub._base_url.clone() + "v1/{+parent}/notes:batchCreate";
4640 if self._scopes.is_empty() {
4641 self._scopes
4642 .insert(Scope::CloudPlatform.as_ref().to_string());
4643 }
4644
4645 #[allow(clippy::single_element_loop)]
4646 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4647 url = params.uri_replacement(url, param_name, find_this, true);
4648 }
4649 {
4650 let to_remove = ["parent"];
4651 params.remove_params(&to_remove);
4652 }
4653
4654 let url = params.parse_with_url(&url);
4655
4656 let mut json_mime_type = mime::APPLICATION_JSON;
4657 let mut request_value_reader = {
4658 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4659 common::remove_json_null_values(&mut value);
4660 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4661 serde_json::to_writer(&mut dst, &value).unwrap();
4662 dst
4663 };
4664 let request_size = request_value_reader
4665 .seek(std::io::SeekFrom::End(0))
4666 .unwrap();
4667 request_value_reader
4668 .seek(std::io::SeekFrom::Start(0))
4669 .unwrap();
4670
4671 loop {
4672 let token = match self
4673 .hub
4674 .auth
4675 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4676 .await
4677 {
4678 Ok(token) => token,
4679 Err(e) => match dlg.token(e) {
4680 Ok(token) => token,
4681 Err(e) => {
4682 dlg.finished(false);
4683 return Err(common::Error::MissingToken(e));
4684 }
4685 },
4686 };
4687 request_value_reader
4688 .seek(std::io::SeekFrom::Start(0))
4689 .unwrap();
4690 let mut req_result = {
4691 let client = &self.hub.client;
4692 dlg.pre_request();
4693 let mut req_builder = hyper::Request::builder()
4694 .method(hyper::Method::POST)
4695 .uri(url.as_str())
4696 .header(USER_AGENT, self.hub._user_agent.clone());
4697
4698 if let Some(token) = token.as_ref() {
4699 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4700 }
4701
4702 let request = req_builder
4703 .header(CONTENT_TYPE, json_mime_type.to_string())
4704 .header(CONTENT_LENGTH, request_size as u64)
4705 .body(common::to_body(
4706 request_value_reader.get_ref().clone().into(),
4707 ));
4708
4709 client.request(request.unwrap()).await
4710 };
4711
4712 match req_result {
4713 Err(err) => {
4714 if let common::Retry::After(d) = dlg.http_error(&err) {
4715 sleep(d).await;
4716 continue;
4717 }
4718 dlg.finished(false);
4719 return Err(common::Error::HttpError(err));
4720 }
4721 Ok(res) => {
4722 let (mut parts, body) = res.into_parts();
4723 let mut body = common::Body::new(body);
4724 if !parts.status.is_success() {
4725 let bytes = common::to_bytes(body).await.unwrap_or_default();
4726 let error = serde_json::from_str(&common::to_string(&bytes));
4727 let response = common::to_response(parts, bytes.into());
4728
4729 if let common::Retry::After(d) =
4730 dlg.http_failure(&response, error.as_ref().ok())
4731 {
4732 sleep(d).await;
4733 continue;
4734 }
4735
4736 dlg.finished(false);
4737
4738 return Err(match error {
4739 Ok(value) => common::Error::BadRequest(value),
4740 _ => common::Error::Failure(response),
4741 });
4742 }
4743 let response = {
4744 let bytes = common::to_bytes(body).await.unwrap_or_default();
4745 let encoded = common::to_string(&bytes);
4746 match serde_json::from_str(&encoded) {
4747 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4748 Err(error) => {
4749 dlg.response_json_decode_error(&encoded, &error);
4750 return Err(common::Error::JsonDecodeError(
4751 encoded.to_string(),
4752 error,
4753 ));
4754 }
4755 }
4756 };
4757
4758 dlg.finished(true);
4759 return Ok(response);
4760 }
4761 }
4762 }
4763 }
4764
4765 ///
4766 /// Sets the *request* property to the given value.
4767 ///
4768 /// Even though the property as already been set when instantiating this call,
4769 /// we provide this method for API completeness.
4770 pub fn request(
4771 mut self,
4772 new_value: BatchCreateNotesRequest,
4773 ) -> ProjectLocationNoteBatchCreateCall<'a, C> {
4774 self._request = new_value;
4775 self
4776 }
4777 /// Required. The name of the project in the form of `projects/[PROJECT_ID]`, under which the notes are to be created.
4778 ///
4779 /// Sets the *parent* path property to the given value.
4780 ///
4781 /// Even though the property as already been set when instantiating this call,
4782 /// we provide this method for API completeness.
4783 pub fn parent(mut self, new_value: &str) -> ProjectLocationNoteBatchCreateCall<'a, C> {
4784 self._parent = new_value.to_string();
4785 self
4786 }
4787 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4788 /// while executing the actual API request.
4789 ///
4790 /// ````text
4791 /// It should be used to handle progress information, and to implement a certain level of resilience.
4792 /// ````
4793 ///
4794 /// Sets the *delegate* property to the given value.
4795 pub fn delegate(
4796 mut self,
4797 new_value: &'a mut dyn common::Delegate,
4798 ) -> ProjectLocationNoteBatchCreateCall<'a, C> {
4799 self._delegate = Some(new_value);
4800 self
4801 }
4802
4803 /// Set any additional parameter of the query string used in the request.
4804 /// It should be used to set parameters which are not yet available through their own
4805 /// setters.
4806 ///
4807 /// Please note that this method must not be used to set any of the known parameters
4808 /// which have their own setter method. If done anyway, the request will fail.
4809 ///
4810 /// # Additional Parameters
4811 ///
4812 /// * *$.xgafv* (query-string) - V1 error format.
4813 /// * *access_token* (query-string) - OAuth access token.
4814 /// * *alt* (query-string) - Data format for response.
4815 /// * *callback* (query-string) - JSONP
4816 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4817 /// * *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.
4818 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4819 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4820 /// * *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.
4821 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4822 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4823 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNoteBatchCreateCall<'a, C>
4824 where
4825 T: AsRef<str>,
4826 {
4827 self._additional_params
4828 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4829 self
4830 }
4831
4832 /// Identifies the authorization scope for the method you are building.
4833 ///
4834 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4835 /// [`Scope::CloudPlatform`].
4836 ///
4837 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4838 /// tokens for more than one scope.
4839 ///
4840 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4841 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4842 /// sufficient, a read-write scope will do as well.
4843 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNoteBatchCreateCall<'a, C>
4844 where
4845 St: AsRef<str>,
4846 {
4847 self._scopes.insert(String::from(scope.as_ref()));
4848 self
4849 }
4850 /// Identifies the authorization scope(s) for the method you are building.
4851 ///
4852 /// See [`Self::add_scope()`] for details.
4853 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNoteBatchCreateCall<'a, C>
4854 where
4855 I: IntoIterator<Item = St>,
4856 St: AsRef<str>,
4857 {
4858 self._scopes
4859 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4860 self
4861 }
4862
4863 /// Removes all scopes, and no default scope will be used either.
4864 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4865 /// for details).
4866 pub fn clear_scopes(mut self) -> ProjectLocationNoteBatchCreateCall<'a, C> {
4867 self._scopes.clear();
4868 self
4869 }
4870}
4871
4872/// Creates a new note.
4873///
4874/// A builder for the *locations.notes.create* method supported by a *project* resource.
4875/// It is not used directly, but through a [`ProjectMethods`] instance.
4876///
4877/// # Example
4878///
4879/// Instantiate a resource method builder
4880///
4881/// ```test_harness,no_run
4882/// # extern crate hyper;
4883/// # extern crate hyper_rustls;
4884/// # extern crate google_containeranalysis1 as containeranalysis1;
4885/// use containeranalysis1::api::Note;
4886/// # async fn dox() {
4887/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4888///
4889/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4890/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4891/// # .with_native_roots()
4892/// # .unwrap()
4893/// # .https_only()
4894/// # .enable_http2()
4895/// # .build();
4896///
4897/// # let executor = hyper_util::rt::TokioExecutor::new();
4898/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4899/// # secret,
4900/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4901/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4902/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4903/// # ),
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_http2()
4915/// # .build()
4916/// # );
4917/// # let mut hub = ContainerAnalysis::new(client, auth);
4918/// // As the method needs a request, you would usually fill it with the desired information
4919/// // into the respective structure. Some of the parts shown here might not be applicable !
4920/// // Values shown here are possibly random and not representative !
4921/// let mut req = Note::default();
4922///
4923/// // You can configure optional parameters by calling the respective setters at will, and
4924/// // execute the final call using `doit()`.
4925/// // Values shown here are possibly random and not representative !
4926/// let result = hub.projects().locations_notes_create(req, "parent")
4927/// .note_id("ipsum")
4928/// .doit().await;
4929/// # }
4930/// ```
4931pub struct ProjectLocationNoteCreateCall<'a, C>
4932where
4933 C: 'a,
4934{
4935 hub: &'a ContainerAnalysis<C>,
4936 _request: Note,
4937 _parent: String,
4938 _note_id: Option<String>,
4939 _delegate: Option<&'a mut dyn common::Delegate>,
4940 _additional_params: HashMap<String, String>,
4941 _scopes: BTreeSet<String>,
4942}
4943
4944impl<'a, C> common::CallBuilder for ProjectLocationNoteCreateCall<'a, C> {}
4945
4946impl<'a, C> ProjectLocationNoteCreateCall<'a, C>
4947where
4948 C: common::Connector,
4949{
4950 /// Perform the operation you have build so far.
4951 pub async fn doit(mut self) -> common::Result<(common::Response, Note)> {
4952 use std::borrow::Cow;
4953 use std::io::{Read, Seek};
4954
4955 use common::{url::Params, ToParts};
4956 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4957
4958 let mut dd = common::DefaultDelegate;
4959 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4960 dlg.begin(common::MethodInfo {
4961 id: "containeranalysis.projects.locations.notes.create",
4962 http_method: hyper::Method::POST,
4963 });
4964
4965 for &field in ["alt", "parent", "noteId"].iter() {
4966 if self._additional_params.contains_key(field) {
4967 dlg.finished(false);
4968 return Err(common::Error::FieldClash(field));
4969 }
4970 }
4971
4972 let mut params = Params::with_capacity(5 + self._additional_params.len());
4973 params.push("parent", self._parent);
4974 if let Some(value) = self._note_id.as_ref() {
4975 params.push("noteId", value);
4976 }
4977
4978 params.extend(self._additional_params.iter());
4979
4980 params.push("alt", "json");
4981 let mut url = self.hub._base_url.clone() + "v1/{+parent}/notes";
4982 if self._scopes.is_empty() {
4983 self._scopes
4984 .insert(Scope::CloudPlatform.as_ref().to_string());
4985 }
4986
4987 #[allow(clippy::single_element_loop)]
4988 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4989 url = params.uri_replacement(url, param_name, find_this, true);
4990 }
4991 {
4992 let to_remove = ["parent"];
4993 params.remove_params(&to_remove);
4994 }
4995
4996 let url = params.parse_with_url(&url);
4997
4998 let mut json_mime_type = mime::APPLICATION_JSON;
4999 let mut request_value_reader = {
5000 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5001 common::remove_json_null_values(&mut value);
5002 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5003 serde_json::to_writer(&mut dst, &value).unwrap();
5004 dst
5005 };
5006 let request_size = request_value_reader
5007 .seek(std::io::SeekFrom::End(0))
5008 .unwrap();
5009 request_value_reader
5010 .seek(std::io::SeekFrom::Start(0))
5011 .unwrap();
5012
5013 loop {
5014 let token = match self
5015 .hub
5016 .auth
5017 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5018 .await
5019 {
5020 Ok(token) => token,
5021 Err(e) => match dlg.token(e) {
5022 Ok(token) => token,
5023 Err(e) => {
5024 dlg.finished(false);
5025 return Err(common::Error::MissingToken(e));
5026 }
5027 },
5028 };
5029 request_value_reader
5030 .seek(std::io::SeekFrom::Start(0))
5031 .unwrap();
5032 let mut req_result = {
5033 let client = &self.hub.client;
5034 dlg.pre_request();
5035 let mut req_builder = hyper::Request::builder()
5036 .method(hyper::Method::POST)
5037 .uri(url.as_str())
5038 .header(USER_AGENT, self.hub._user_agent.clone());
5039
5040 if let Some(token) = token.as_ref() {
5041 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5042 }
5043
5044 let request = req_builder
5045 .header(CONTENT_TYPE, json_mime_type.to_string())
5046 .header(CONTENT_LENGTH, request_size as u64)
5047 .body(common::to_body(
5048 request_value_reader.get_ref().clone().into(),
5049 ));
5050
5051 client.request(request.unwrap()).await
5052 };
5053
5054 match req_result {
5055 Err(err) => {
5056 if let common::Retry::After(d) = dlg.http_error(&err) {
5057 sleep(d).await;
5058 continue;
5059 }
5060 dlg.finished(false);
5061 return Err(common::Error::HttpError(err));
5062 }
5063 Ok(res) => {
5064 let (mut parts, body) = res.into_parts();
5065 let mut body = common::Body::new(body);
5066 if !parts.status.is_success() {
5067 let bytes = common::to_bytes(body).await.unwrap_or_default();
5068 let error = serde_json::from_str(&common::to_string(&bytes));
5069 let response = common::to_response(parts, bytes.into());
5070
5071 if let common::Retry::After(d) =
5072 dlg.http_failure(&response, error.as_ref().ok())
5073 {
5074 sleep(d).await;
5075 continue;
5076 }
5077
5078 dlg.finished(false);
5079
5080 return Err(match error {
5081 Ok(value) => common::Error::BadRequest(value),
5082 _ => common::Error::Failure(response),
5083 });
5084 }
5085 let response = {
5086 let bytes = common::to_bytes(body).await.unwrap_or_default();
5087 let encoded = common::to_string(&bytes);
5088 match serde_json::from_str(&encoded) {
5089 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5090 Err(error) => {
5091 dlg.response_json_decode_error(&encoded, &error);
5092 return Err(common::Error::JsonDecodeError(
5093 encoded.to_string(),
5094 error,
5095 ));
5096 }
5097 }
5098 };
5099
5100 dlg.finished(true);
5101 return Ok(response);
5102 }
5103 }
5104 }
5105 }
5106
5107 ///
5108 /// Sets the *request* property to the given value.
5109 ///
5110 /// Even though the property as already been set when instantiating this call,
5111 /// we provide this method for API completeness.
5112 pub fn request(mut self, new_value: Note) -> ProjectLocationNoteCreateCall<'a, C> {
5113 self._request = new_value;
5114 self
5115 }
5116 /// Required. The name of the project in the form of `projects/[PROJECT_ID]`, under which the note is to be created.
5117 ///
5118 /// Sets the *parent* path property to the given value.
5119 ///
5120 /// Even though the property as already been set when instantiating this call,
5121 /// we provide this method for API completeness.
5122 pub fn parent(mut self, new_value: &str) -> ProjectLocationNoteCreateCall<'a, C> {
5123 self._parent = new_value.to_string();
5124 self
5125 }
5126 /// Required. The ID to use for this note.
5127 ///
5128 /// Sets the *note id* query property to the given value.
5129 pub fn note_id(mut self, new_value: &str) -> ProjectLocationNoteCreateCall<'a, C> {
5130 self._note_id = Some(new_value.to_string());
5131 self
5132 }
5133 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5134 /// while executing the actual API request.
5135 ///
5136 /// ````text
5137 /// It should be used to handle progress information, and to implement a certain level of resilience.
5138 /// ````
5139 ///
5140 /// Sets the *delegate* property to the given value.
5141 pub fn delegate(
5142 mut self,
5143 new_value: &'a mut dyn common::Delegate,
5144 ) -> ProjectLocationNoteCreateCall<'a, C> {
5145 self._delegate = Some(new_value);
5146 self
5147 }
5148
5149 /// Set any additional parameter of the query string used in the request.
5150 /// It should be used to set parameters which are not yet available through their own
5151 /// setters.
5152 ///
5153 /// Please note that this method must not be used to set any of the known parameters
5154 /// which have their own setter method. If done anyway, the request will fail.
5155 ///
5156 /// # Additional Parameters
5157 ///
5158 /// * *$.xgafv* (query-string) - V1 error format.
5159 /// * *access_token* (query-string) - OAuth access token.
5160 /// * *alt* (query-string) - Data format for response.
5161 /// * *callback* (query-string) - JSONP
5162 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5163 /// * *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.
5164 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5165 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5166 /// * *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.
5167 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5168 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5169 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNoteCreateCall<'a, C>
5170 where
5171 T: AsRef<str>,
5172 {
5173 self._additional_params
5174 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5175 self
5176 }
5177
5178 /// Identifies the authorization scope for the method you are building.
5179 ///
5180 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5181 /// [`Scope::CloudPlatform`].
5182 ///
5183 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5184 /// tokens for more than one scope.
5185 ///
5186 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5187 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5188 /// sufficient, a read-write scope will do as well.
5189 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNoteCreateCall<'a, C>
5190 where
5191 St: AsRef<str>,
5192 {
5193 self._scopes.insert(String::from(scope.as_ref()));
5194 self
5195 }
5196 /// Identifies the authorization scope(s) for the method you are building.
5197 ///
5198 /// See [`Self::add_scope()`] for details.
5199 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNoteCreateCall<'a, C>
5200 where
5201 I: IntoIterator<Item = St>,
5202 St: AsRef<str>,
5203 {
5204 self._scopes
5205 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5206 self
5207 }
5208
5209 /// Removes all scopes, and no default scope will be used either.
5210 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5211 /// for details).
5212 pub fn clear_scopes(mut self) -> ProjectLocationNoteCreateCall<'a, C> {
5213 self._scopes.clear();
5214 self
5215 }
5216}
5217
5218/// Deletes the specified note.
5219///
5220/// A builder for the *locations.notes.delete* method supported by a *project* resource.
5221/// It is not used directly, but through a [`ProjectMethods`] instance.
5222///
5223/// # Example
5224///
5225/// Instantiate a resource method builder
5226///
5227/// ```test_harness,no_run
5228/// # extern crate hyper;
5229/// # extern crate hyper_rustls;
5230/// # extern crate google_containeranalysis1 as containeranalysis1;
5231/// # async fn dox() {
5232/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5233///
5234/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5235/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5236/// # .with_native_roots()
5237/// # .unwrap()
5238/// # .https_only()
5239/// # .enable_http2()
5240/// # .build();
5241///
5242/// # let executor = hyper_util::rt::TokioExecutor::new();
5243/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5244/// # secret,
5245/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5246/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5247/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5248/// # ),
5249/// # ).build().await.unwrap();
5250///
5251/// # let client = hyper_util::client::legacy::Client::builder(
5252/// # hyper_util::rt::TokioExecutor::new()
5253/// # )
5254/// # .build(
5255/// # hyper_rustls::HttpsConnectorBuilder::new()
5256/// # .with_native_roots()
5257/// # .unwrap()
5258/// # .https_or_http()
5259/// # .enable_http2()
5260/// # .build()
5261/// # );
5262/// # let mut hub = ContainerAnalysis::new(client, auth);
5263/// // You can configure optional parameters by calling the respective setters at will, and
5264/// // execute the final call using `doit()`.
5265/// // Values shown here are possibly random and not representative !
5266/// let result = hub.projects().locations_notes_delete("name")
5267/// .doit().await;
5268/// # }
5269/// ```
5270pub struct ProjectLocationNoteDeleteCall<'a, C>
5271where
5272 C: 'a,
5273{
5274 hub: &'a ContainerAnalysis<C>,
5275 _name: String,
5276 _delegate: Option<&'a mut dyn common::Delegate>,
5277 _additional_params: HashMap<String, String>,
5278 _scopes: BTreeSet<String>,
5279}
5280
5281impl<'a, C> common::CallBuilder for ProjectLocationNoteDeleteCall<'a, C> {}
5282
5283impl<'a, C> ProjectLocationNoteDeleteCall<'a, C>
5284where
5285 C: common::Connector,
5286{
5287 /// Perform the operation you have build so far.
5288 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
5289 use std::borrow::Cow;
5290 use std::io::{Read, Seek};
5291
5292 use common::{url::Params, ToParts};
5293 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5294
5295 let mut dd = common::DefaultDelegate;
5296 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5297 dlg.begin(common::MethodInfo {
5298 id: "containeranalysis.projects.locations.notes.delete",
5299 http_method: hyper::Method::DELETE,
5300 });
5301
5302 for &field in ["alt", "name"].iter() {
5303 if self._additional_params.contains_key(field) {
5304 dlg.finished(false);
5305 return Err(common::Error::FieldClash(field));
5306 }
5307 }
5308
5309 let mut params = Params::with_capacity(3 + self._additional_params.len());
5310 params.push("name", self._name);
5311
5312 params.extend(self._additional_params.iter());
5313
5314 params.push("alt", "json");
5315 let mut url = self.hub._base_url.clone() + "v1/{+name}";
5316 if self._scopes.is_empty() {
5317 self._scopes
5318 .insert(Scope::CloudPlatform.as_ref().to_string());
5319 }
5320
5321 #[allow(clippy::single_element_loop)]
5322 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5323 url = params.uri_replacement(url, param_name, find_this, true);
5324 }
5325 {
5326 let to_remove = ["name"];
5327 params.remove_params(&to_remove);
5328 }
5329
5330 let url = params.parse_with_url(&url);
5331
5332 loop {
5333 let token = match self
5334 .hub
5335 .auth
5336 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5337 .await
5338 {
5339 Ok(token) => token,
5340 Err(e) => match dlg.token(e) {
5341 Ok(token) => token,
5342 Err(e) => {
5343 dlg.finished(false);
5344 return Err(common::Error::MissingToken(e));
5345 }
5346 },
5347 };
5348 let mut req_result = {
5349 let client = &self.hub.client;
5350 dlg.pre_request();
5351 let mut req_builder = hyper::Request::builder()
5352 .method(hyper::Method::DELETE)
5353 .uri(url.as_str())
5354 .header(USER_AGENT, self.hub._user_agent.clone());
5355
5356 if let Some(token) = token.as_ref() {
5357 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5358 }
5359
5360 let request = req_builder
5361 .header(CONTENT_LENGTH, 0_u64)
5362 .body(common::to_body::<String>(None));
5363
5364 client.request(request.unwrap()).await
5365 };
5366
5367 match req_result {
5368 Err(err) => {
5369 if let common::Retry::After(d) = dlg.http_error(&err) {
5370 sleep(d).await;
5371 continue;
5372 }
5373 dlg.finished(false);
5374 return Err(common::Error::HttpError(err));
5375 }
5376 Ok(res) => {
5377 let (mut parts, body) = res.into_parts();
5378 let mut body = common::Body::new(body);
5379 if !parts.status.is_success() {
5380 let bytes = common::to_bytes(body).await.unwrap_or_default();
5381 let error = serde_json::from_str(&common::to_string(&bytes));
5382 let response = common::to_response(parts, bytes.into());
5383
5384 if let common::Retry::After(d) =
5385 dlg.http_failure(&response, error.as_ref().ok())
5386 {
5387 sleep(d).await;
5388 continue;
5389 }
5390
5391 dlg.finished(false);
5392
5393 return Err(match error {
5394 Ok(value) => common::Error::BadRequest(value),
5395 _ => common::Error::Failure(response),
5396 });
5397 }
5398 let response = {
5399 let bytes = common::to_bytes(body).await.unwrap_or_default();
5400 let encoded = common::to_string(&bytes);
5401 match serde_json::from_str(&encoded) {
5402 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5403 Err(error) => {
5404 dlg.response_json_decode_error(&encoded, &error);
5405 return Err(common::Error::JsonDecodeError(
5406 encoded.to_string(),
5407 error,
5408 ));
5409 }
5410 }
5411 };
5412
5413 dlg.finished(true);
5414 return Ok(response);
5415 }
5416 }
5417 }
5418 }
5419
5420 /// Required. The name of the note in the form of `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.
5421 ///
5422 /// Sets the *name* path property to the given value.
5423 ///
5424 /// Even though the property as already been set when instantiating this call,
5425 /// we provide this method for API completeness.
5426 pub fn name(mut self, new_value: &str) -> ProjectLocationNoteDeleteCall<'a, C> {
5427 self._name = new_value.to_string();
5428 self
5429 }
5430 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5431 /// while executing the actual API request.
5432 ///
5433 /// ````text
5434 /// It should be used to handle progress information, and to implement a certain level of resilience.
5435 /// ````
5436 ///
5437 /// Sets the *delegate* property to the given value.
5438 pub fn delegate(
5439 mut self,
5440 new_value: &'a mut dyn common::Delegate,
5441 ) -> ProjectLocationNoteDeleteCall<'a, C> {
5442 self._delegate = Some(new_value);
5443 self
5444 }
5445
5446 /// Set any additional parameter of the query string used in the request.
5447 /// It should be used to set parameters which are not yet available through their own
5448 /// setters.
5449 ///
5450 /// Please note that this method must not be used to set any of the known parameters
5451 /// which have their own setter method. If done anyway, the request will fail.
5452 ///
5453 /// # Additional Parameters
5454 ///
5455 /// * *$.xgafv* (query-string) - V1 error format.
5456 /// * *access_token* (query-string) - OAuth access token.
5457 /// * *alt* (query-string) - Data format for response.
5458 /// * *callback* (query-string) - JSONP
5459 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5460 /// * *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.
5461 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5462 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5463 /// * *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.
5464 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5465 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5466 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNoteDeleteCall<'a, C>
5467 where
5468 T: AsRef<str>,
5469 {
5470 self._additional_params
5471 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5472 self
5473 }
5474
5475 /// Identifies the authorization scope for the method you are building.
5476 ///
5477 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5478 /// [`Scope::CloudPlatform`].
5479 ///
5480 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5481 /// tokens for more than one scope.
5482 ///
5483 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5484 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5485 /// sufficient, a read-write scope will do as well.
5486 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNoteDeleteCall<'a, C>
5487 where
5488 St: AsRef<str>,
5489 {
5490 self._scopes.insert(String::from(scope.as_ref()));
5491 self
5492 }
5493 /// Identifies the authorization scope(s) for the method you are building.
5494 ///
5495 /// See [`Self::add_scope()`] for details.
5496 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNoteDeleteCall<'a, C>
5497 where
5498 I: IntoIterator<Item = St>,
5499 St: AsRef<str>,
5500 {
5501 self._scopes
5502 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5503 self
5504 }
5505
5506 /// Removes all scopes, and no default scope will be used either.
5507 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5508 /// for details).
5509 pub fn clear_scopes(mut self) -> ProjectLocationNoteDeleteCall<'a, C> {
5510 self._scopes.clear();
5511 self
5512 }
5513}
5514
5515/// Gets the specified note.
5516///
5517/// A builder for the *locations.notes.get* method supported by a *project* resource.
5518/// It is not used directly, but through a [`ProjectMethods`] instance.
5519///
5520/// # Example
5521///
5522/// Instantiate a resource method builder
5523///
5524/// ```test_harness,no_run
5525/// # extern crate hyper;
5526/// # extern crate hyper_rustls;
5527/// # extern crate google_containeranalysis1 as containeranalysis1;
5528/// # async fn dox() {
5529/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5530///
5531/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5532/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5533/// # .with_native_roots()
5534/// # .unwrap()
5535/// # .https_only()
5536/// # .enable_http2()
5537/// # .build();
5538///
5539/// # let executor = hyper_util::rt::TokioExecutor::new();
5540/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5541/// # secret,
5542/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5543/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5544/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5545/// # ),
5546/// # ).build().await.unwrap();
5547///
5548/// # let client = hyper_util::client::legacy::Client::builder(
5549/// # hyper_util::rt::TokioExecutor::new()
5550/// # )
5551/// # .build(
5552/// # hyper_rustls::HttpsConnectorBuilder::new()
5553/// # .with_native_roots()
5554/// # .unwrap()
5555/// # .https_or_http()
5556/// # .enable_http2()
5557/// # .build()
5558/// # );
5559/// # let mut hub = ContainerAnalysis::new(client, auth);
5560/// // You can configure optional parameters by calling the respective setters at will, and
5561/// // execute the final call using `doit()`.
5562/// // Values shown here are possibly random and not representative !
5563/// let result = hub.projects().locations_notes_get("name")
5564/// .doit().await;
5565/// # }
5566/// ```
5567pub struct ProjectLocationNoteGetCall<'a, C>
5568where
5569 C: 'a,
5570{
5571 hub: &'a ContainerAnalysis<C>,
5572 _name: String,
5573 _delegate: Option<&'a mut dyn common::Delegate>,
5574 _additional_params: HashMap<String, String>,
5575 _scopes: BTreeSet<String>,
5576}
5577
5578impl<'a, C> common::CallBuilder for ProjectLocationNoteGetCall<'a, C> {}
5579
5580impl<'a, C> ProjectLocationNoteGetCall<'a, C>
5581where
5582 C: common::Connector,
5583{
5584 /// Perform the operation you have build so far.
5585 pub async fn doit(mut self) -> common::Result<(common::Response, Note)> {
5586 use std::borrow::Cow;
5587 use std::io::{Read, Seek};
5588
5589 use common::{url::Params, ToParts};
5590 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5591
5592 let mut dd = common::DefaultDelegate;
5593 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5594 dlg.begin(common::MethodInfo {
5595 id: "containeranalysis.projects.locations.notes.get",
5596 http_method: hyper::Method::GET,
5597 });
5598
5599 for &field in ["alt", "name"].iter() {
5600 if self._additional_params.contains_key(field) {
5601 dlg.finished(false);
5602 return Err(common::Error::FieldClash(field));
5603 }
5604 }
5605
5606 let mut params = Params::with_capacity(3 + self._additional_params.len());
5607 params.push("name", self._name);
5608
5609 params.extend(self._additional_params.iter());
5610
5611 params.push("alt", "json");
5612 let mut url = self.hub._base_url.clone() + "v1/{+name}";
5613 if self._scopes.is_empty() {
5614 self._scopes
5615 .insert(Scope::CloudPlatform.as_ref().to_string());
5616 }
5617
5618 #[allow(clippy::single_element_loop)]
5619 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5620 url = params.uri_replacement(url, param_name, find_this, true);
5621 }
5622 {
5623 let to_remove = ["name"];
5624 params.remove_params(&to_remove);
5625 }
5626
5627 let url = params.parse_with_url(&url);
5628
5629 loop {
5630 let token = match self
5631 .hub
5632 .auth
5633 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5634 .await
5635 {
5636 Ok(token) => token,
5637 Err(e) => match dlg.token(e) {
5638 Ok(token) => token,
5639 Err(e) => {
5640 dlg.finished(false);
5641 return Err(common::Error::MissingToken(e));
5642 }
5643 },
5644 };
5645 let mut req_result = {
5646 let client = &self.hub.client;
5647 dlg.pre_request();
5648 let mut req_builder = hyper::Request::builder()
5649 .method(hyper::Method::GET)
5650 .uri(url.as_str())
5651 .header(USER_AGENT, self.hub._user_agent.clone());
5652
5653 if let Some(token) = token.as_ref() {
5654 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5655 }
5656
5657 let request = req_builder
5658 .header(CONTENT_LENGTH, 0_u64)
5659 .body(common::to_body::<String>(None));
5660
5661 client.request(request.unwrap()).await
5662 };
5663
5664 match req_result {
5665 Err(err) => {
5666 if let common::Retry::After(d) = dlg.http_error(&err) {
5667 sleep(d).await;
5668 continue;
5669 }
5670 dlg.finished(false);
5671 return Err(common::Error::HttpError(err));
5672 }
5673 Ok(res) => {
5674 let (mut parts, body) = res.into_parts();
5675 let mut body = common::Body::new(body);
5676 if !parts.status.is_success() {
5677 let bytes = common::to_bytes(body).await.unwrap_or_default();
5678 let error = serde_json::from_str(&common::to_string(&bytes));
5679 let response = common::to_response(parts, bytes.into());
5680
5681 if let common::Retry::After(d) =
5682 dlg.http_failure(&response, error.as_ref().ok())
5683 {
5684 sleep(d).await;
5685 continue;
5686 }
5687
5688 dlg.finished(false);
5689
5690 return Err(match error {
5691 Ok(value) => common::Error::BadRequest(value),
5692 _ => common::Error::Failure(response),
5693 });
5694 }
5695 let response = {
5696 let bytes = common::to_bytes(body).await.unwrap_or_default();
5697 let encoded = common::to_string(&bytes);
5698 match serde_json::from_str(&encoded) {
5699 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5700 Err(error) => {
5701 dlg.response_json_decode_error(&encoded, &error);
5702 return Err(common::Error::JsonDecodeError(
5703 encoded.to_string(),
5704 error,
5705 ));
5706 }
5707 }
5708 };
5709
5710 dlg.finished(true);
5711 return Ok(response);
5712 }
5713 }
5714 }
5715 }
5716
5717 /// Required. The name of the note in the form of `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.
5718 ///
5719 /// Sets the *name* path property to the given value.
5720 ///
5721 /// Even though the property as already been set when instantiating this call,
5722 /// we provide this method for API completeness.
5723 pub fn name(mut self, new_value: &str) -> ProjectLocationNoteGetCall<'a, C> {
5724 self._name = new_value.to_string();
5725 self
5726 }
5727 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5728 /// while executing the actual API request.
5729 ///
5730 /// ````text
5731 /// It should be used to handle progress information, and to implement a certain level of resilience.
5732 /// ````
5733 ///
5734 /// Sets the *delegate* property to the given value.
5735 pub fn delegate(
5736 mut self,
5737 new_value: &'a mut dyn common::Delegate,
5738 ) -> ProjectLocationNoteGetCall<'a, C> {
5739 self._delegate = Some(new_value);
5740 self
5741 }
5742
5743 /// Set any additional parameter of the query string used in the request.
5744 /// It should be used to set parameters which are not yet available through their own
5745 /// setters.
5746 ///
5747 /// Please note that this method must not be used to set any of the known parameters
5748 /// which have their own setter method. If done anyway, the request will fail.
5749 ///
5750 /// # Additional Parameters
5751 ///
5752 /// * *$.xgafv* (query-string) - V1 error format.
5753 /// * *access_token* (query-string) - OAuth access token.
5754 /// * *alt* (query-string) - Data format for response.
5755 /// * *callback* (query-string) - JSONP
5756 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5757 /// * *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.
5758 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5759 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5760 /// * *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.
5761 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5762 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5763 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNoteGetCall<'a, C>
5764 where
5765 T: AsRef<str>,
5766 {
5767 self._additional_params
5768 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5769 self
5770 }
5771
5772 /// Identifies the authorization scope for the method you are building.
5773 ///
5774 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5775 /// [`Scope::CloudPlatform`].
5776 ///
5777 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5778 /// tokens for more than one scope.
5779 ///
5780 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5781 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5782 /// sufficient, a read-write scope will do as well.
5783 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNoteGetCall<'a, C>
5784 where
5785 St: AsRef<str>,
5786 {
5787 self._scopes.insert(String::from(scope.as_ref()));
5788 self
5789 }
5790 /// Identifies the authorization scope(s) for the method you are building.
5791 ///
5792 /// See [`Self::add_scope()`] for details.
5793 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNoteGetCall<'a, C>
5794 where
5795 I: IntoIterator<Item = St>,
5796 St: AsRef<str>,
5797 {
5798 self._scopes
5799 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5800 self
5801 }
5802
5803 /// Removes all scopes, and no default scope will be used either.
5804 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5805 /// for details).
5806 pub fn clear_scopes(mut self) -> ProjectLocationNoteGetCall<'a, C> {
5807 self._scopes.clear();
5808 self
5809 }
5810}
5811
5812/// 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.
5813///
5814/// A builder for the *locations.notes.getIamPolicy* method supported by a *project* resource.
5815/// It is not used directly, but through a [`ProjectMethods`] instance.
5816///
5817/// # Example
5818///
5819/// Instantiate a resource method builder
5820///
5821/// ```test_harness,no_run
5822/// # extern crate hyper;
5823/// # extern crate hyper_rustls;
5824/// # extern crate google_containeranalysis1 as containeranalysis1;
5825/// use containeranalysis1::api::GetIamPolicyRequest;
5826/// # async fn dox() {
5827/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5828///
5829/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5830/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5831/// # .with_native_roots()
5832/// # .unwrap()
5833/// # .https_only()
5834/// # .enable_http2()
5835/// # .build();
5836///
5837/// # let executor = hyper_util::rt::TokioExecutor::new();
5838/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5839/// # secret,
5840/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5841/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5842/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5843/// # ),
5844/// # ).build().await.unwrap();
5845///
5846/// # let client = hyper_util::client::legacy::Client::builder(
5847/// # hyper_util::rt::TokioExecutor::new()
5848/// # )
5849/// # .build(
5850/// # hyper_rustls::HttpsConnectorBuilder::new()
5851/// # .with_native_roots()
5852/// # .unwrap()
5853/// # .https_or_http()
5854/// # .enable_http2()
5855/// # .build()
5856/// # );
5857/// # let mut hub = ContainerAnalysis::new(client, auth);
5858/// // As the method needs a request, you would usually fill it with the desired information
5859/// // into the respective structure. Some of the parts shown here might not be applicable !
5860/// // Values shown here are possibly random and not representative !
5861/// let mut req = GetIamPolicyRequest::default();
5862///
5863/// // You can configure optional parameters by calling the respective setters at will, and
5864/// // execute the final call using `doit()`.
5865/// // Values shown here are possibly random and not representative !
5866/// let result = hub.projects().locations_notes_get_iam_policy(req, "resource")
5867/// .doit().await;
5868/// # }
5869/// ```
5870pub struct ProjectLocationNoteGetIamPolicyCall<'a, C>
5871where
5872 C: 'a,
5873{
5874 hub: &'a ContainerAnalysis<C>,
5875 _request: GetIamPolicyRequest,
5876 _resource: String,
5877 _delegate: Option<&'a mut dyn common::Delegate>,
5878 _additional_params: HashMap<String, String>,
5879 _scopes: BTreeSet<String>,
5880}
5881
5882impl<'a, C> common::CallBuilder for ProjectLocationNoteGetIamPolicyCall<'a, C> {}
5883
5884impl<'a, C> ProjectLocationNoteGetIamPolicyCall<'a, C>
5885where
5886 C: common::Connector,
5887{
5888 /// Perform the operation you have build so far.
5889 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
5890 use std::borrow::Cow;
5891 use std::io::{Read, Seek};
5892
5893 use common::{url::Params, ToParts};
5894 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5895
5896 let mut dd = common::DefaultDelegate;
5897 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5898 dlg.begin(common::MethodInfo {
5899 id: "containeranalysis.projects.locations.notes.getIamPolicy",
5900 http_method: hyper::Method::POST,
5901 });
5902
5903 for &field in ["alt", "resource"].iter() {
5904 if self._additional_params.contains_key(field) {
5905 dlg.finished(false);
5906 return Err(common::Error::FieldClash(field));
5907 }
5908 }
5909
5910 let mut params = Params::with_capacity(4 + self._additional_params.len());
5911 params.push("resource", self._resource);
5912
5913 params.extend(self._additional_params.iter());
5914
5915 params.push("alt", "json");
5916 let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
5917 if self._scopes.is_empty() {
5918 self._scopes
5919 .insert(Scope::CloudPlatform.as_ref().to_string());
5920 }
5921
5922 #[allow(clippy::single_element_loop)]
5923 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
5924 url = params.uri_replacement(url, param_name, find_this, true);
5925 }
5926 {
5927 let to_remove = ["resource"];
5928 params.remove_params(&to_remove);
5929 }
5930
5931 let url = params.parse_with_url(&url);
5932
5933 let mut json_mime_type = mime::APPLICATION_JSON;
5934 let mut request_value_reader = {
5935 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5936 common::remove_json_null_values(&mut value);
5937 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5938 serde_json::to_writer(&mut dst, &value).unwrap();
5939 dst
5940 };
5941 let request_size = request_value_reader
5942 .seek(std::io::SeekFrom::End(0))
5943 .unwrap();
5944 request_value_reader
5945 .seek(std::io::SeekFrom::Start(0))
5946 .unwrap();
5947
5948 loop {
5949 let token = match self
5950 .hub
5951 .auth
5952 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5953 .await
5954 {
5955 Ok(token) => token,
5956 Err(e) => match dlg.token(e) {
5957 Ok(token) => token,
5958 Err(e) => {
5959 dlg.finished(false);
5960 return Err(common::Error::MissingToken(e));
5961 }
5962 },
5963 };
5964 request_value_reader
5965 .seek(std::io::SeekFrom::Start(0))
5966 .unwrap();
5967 let mut req_result = {
5968 let client = &self.hub.client;
5969 dlg.pre_request();
5970 let mut req_builder = hyper::Request::builder()
5971 .method(hyper::Method::POST)
5972 .uri(url.as_str())
5973 .header(USER_AGENT, self.hub._user_agent.clone());
5974
5975 if let Some(token) = token.as_ref() {
5976 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5977 }
5978
5979 let request = req_builder
5980 .header(CONTENT_TYPE, json_mime_type.to_string())
5981 .header(CONTENT_LENGTH, request_size as u64)
5982 .body(common::to_body(
5983 request_value_reader.get_ref().clone().into(),
5984 ));
5985
5986 client.request(request.unwrap()).await
5987 };
5988
5989 match req_result {
5990 Err(err) => {
5991 if let common::Retry::After(d) = dlg.http_error(&err) {
5992 sleep(d).await;
5993 continue;
5994 }
5995 dlg.finished(false);
5996 return Err(common::Error::HttpError(err));
5997 }
5998 Ok(res) => {
5999 let (mut parts, body) = res.into_parts();
6000 let mut body = common::Body::new(body);
6001 if !parts.status.is_success() {
6002 let bytes = common::to_bytes(body).await.unwrap_or_default();
6003 let error = serde_json::from_str(&common::to_string(&bytes));
6004 let response = common::to_response(parts, bytes.into());
6005
6006 if let common::Retry::After(d) =
6007 dlg.http_failure(&response, error.as_ref().ok())
6008 {
6009 sleep(d).await;
6010 continue;
6011 }
6012
6013 dlg.finished(false);
6014
6015 return Err(match error {
6016 Ok(value) => common::Error::BadRequest(value),
6017 _ => common::Error::Failure(response),
6018 });
6019 }
6020 let response = {
6021 let bytes = common::to_bytes(body).await.unwrap_or_default();
6022 let encoded = common::to_string(&bytes);
6023 match serde_json::from_str(&encoded) {
6024 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6025 Err(error) => {
6026 dlg.response_json_decode_error(&encoded, &error);
6027 return Err(common::Error::JsonDecodeError(
6028 encoded.to_string(),
6029 error,
6030 ));
6031 }
6032 }
6033 };
6034
6035 dlg.finished(true);
6036 return Ok(response);
6037 }
6038 }
6039 }
6040 }
6041
6042 ///
6043 /// Sets the *request* property to the given value.
6044 ///
6045 /// Even though the property as already been set when instantiating this call,
6046 /// we provide this method for API completeness.
6047 pub fn request(
6048 mut self,
6049 new_value: GetIamPolicyRequest,
6050 ) -> ProjectLocationNoteGetIamPolicyCall<'a, C> {
6051 self._request = new_value;
6052 self
6053 }
6054 /// 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.
6055 ///
6056 /// Sets the *resource* path property to the given value.
6057 ///
6058 /// Even though the property as already been set when instantiating this call,
6059 /// we provide this method for API completeness.
6060 pub fn resource(mut self, new_value: &str) -> ProjectLocationNoteGetIamPolicyCall<'a, C> {
6061 self._resource = new_value.to_string();
6062 self
6063 }
6064 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6065 /// while executing the actual API request.
6066 ///
6067 /// ````text
6068 /// It should be used to handle progress information, and to implement a certain level of resilience.
6069 /// ````
6070 ///
6071 /// Sets the *delegate* property to the given value.
6072 pub fn delegate(
6073 mut self,
6074 new_value: &'a mut dyn common::Delegate,
6075 ) -> ProjectLocationNoteGetIamPolicyCall<'a, C> {
6076 self._delegate = Some(new_value);
6077 self
6078 }
6079
6080 /// Set any additional parameter of the query string used in the request.
6081 /// It should be used to set parameters which are not yet available through their own
6082 /// setters.
6083 ///
6084 /// Please note that this method must not be used to set any of the known parameters
6085 /// which have their own setter method. If done anyway, the request will fail.
6086 ///
6087 /// # Additional Parameters
6088 ///
6089 /// * *$.xgafv* (query-string) - V1 error format.
6090 /// * *access_token* (query-string) - OAuth access token.
6091 /// * *alt* (query-string) - Data format for response.
6092 /// * *callback* (query-string) - JSONP
6093 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6094 /// * *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.
6095 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6096 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6097 /// * *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.
6098 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6099 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6100 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNoteGetIamPolicyCall<'a, C>
6101 where
6102 T: AsRef<str>,
6103 {
6104 self._additional_params
6105 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6106 self
6107 }
6108
6109 /// Identifies the authorization scope for the method you are building.
6110 ///
6111 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6112 /// [`Scope::CloudPlatform`].
6113 ///
6114 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6115 /// tokens for more than one scope.
6116 ///
6117 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6118 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6119 /// sufficient, a read-write scope will do as well.
6120 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNoteGetIamPolicyCall<'a, C>
6121 where
6122 St: AsRef<str>,
6123 {
6124 self._scopes.insert(String::from(scope.as_ref()));
6125 self
6126 }
6127 /// Identifies the authorization scope(s) for the method you are building.
6128 ///
6129 /// See [`Self::add_scope()`] for details.
6130 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNoteGetIamPolicyCall<'a, C>
6131 where
6132 I: IntoIterator<Item = St>,
6133 St: AsRef<str>,
6134 {
6135 self._scopes
6136 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6137 self
6138 }
6139
6140 /// Removes all scopes, and no default scope will be used either.
6141 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6142 /// for details).
6143 pub fn clear_scopes(mut self) -> ProjectLocationNoteGetIamPolicyCall<'a, C> {
6144 self._scopes.clear();
6145 self
6146 }
6147}
6148
6149/// Lists notes for the specified project.
6150///
6151/// A builder for the *locations.notes.list* method supported by a *project* resource.
6152/// It is not used directly, but through a [`ProjectMethods`] instance.
6153///
6154/// # Example
6155///
6156/// Instantiate a resource method builder
6157///
6158/// ```test_harness,no_run
6159/// # extern crate hyper;
6160/// # extern crate hyper_rustls;
6161/// # extern crate google_containeranalysis1 as containeranalysis1;
6162/// # async fn dox() {
6163/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6164///
6165/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6166/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6167/// # .with_native_roots()
6168/// # .unwrap()
6169/// # .https_only()
6170/// # .enable_http2()
6171/// # .build();
6172///
6173/// # let executor = hyper_util::rt::TokioExecutor::new();
6174/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6175/// # secret,
6176/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6177/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6178/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6179/// # ),
6180/// # ).build().await.unwrap();
6181///
6182/// # let client = hyper_util::client::legacy::Client::builder(
6183/// # hyper_util::rt::TokioExecutor::new()
6184/// # )
6185/// # .build(
6186/// # hyper_rustls::HttpsConnectorBuilder::new()
6187/// # .with_native_roots()
6188/// # .unwrap()
6189/// # .https_or_http()
6190/// # .enable_http2()
6191/// # .build()
6192/// # );
6193/// # let mut hub = ContainerAnalysis::new(client, auth);
6194/// // You can configure optional parameters by calling the respective setters at will, and
6195/// // execute the final call using `doit()`.
6196/// // Values shown here are possibly random and not representative !
6197/// let result = hub.projects().locations_notes_list("parent")
6198/// .return_partial_success(true)
6199/// .page_token("invidunt")
6200/// .page_size(-47)
6201/// .filter("duo")
6202/// .doit().await;
6203/// # }
6204/// ```
6205pub struct ProjectLocationNoteListCall<'a, C>
6206where
6207 C: 'a,
6208{
6209 hub: &'a ContainerAnalysis<C>,
6210 _parent: String,
6211 _return_partial_success: Option<bool>,
6212 _page_token: Option<String>,
6213 _page_size: Option<i32>,
6214 _filter: Option<String>,
6215 _delegate: Option<&'a mut dyn common::Delegate>,
6216 _additional_params: HashMap<String, String>,
6217 _scopes: BTreeSet<String>,
6218}
6219
6220impl<'a, C> common::CallBuilder for ProjectLocationNoteListCall<'a, C> {}
6221
6222impl<'a, C> ProjectLocationNoteListCall<'a, C>
6223where
6224 C: common::Connector,
6225{
6226 /// Perform the operation you have build so far.
6227 pub async fn doit(mut self) -> common::Result<(common::Response, ListNotesResponse)> {
6228 use std::borrow::Cow;
6229 use std::io::{Read, Seek};
6230
6231 use common::{url::Params, ToParts};
6232 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6233
6234 let mut dd = common::DefaultDelegate;
6235 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6236 dlg.begin(common::MethodInfo {
6237 id: "containeranalysis.projects.locations.notes.list",
6238 http_method: hyper::Method::GET,
6239 });
6240
6241 for &field in [
6242 "alt",
6243 "parent",
6244 "returnPartialSuccess",
6245 "pageToken",
6246 "pageSize",
6247 "filter",
6248 ]
6249 .iter()
6250 {
6251 if self._additional_params.contains_key(field) {
6252 dlg.finished(false);
6253 return Err(common::Error::FieldClash(field));
6254 }
6255 }
6256
6257 let mut params = Params::with_capacity(7 + self._additional_params.len());
6258 params.push("parent", self._parent);
6259 if let Some(value) = self._return_partial_success.as_ref() {
6260 params.push("returnPartialSuccess", value.to_string());
6261 }
6262 if let Some(value) = self._page_token.as_ref() {
6263 params.push("pageToken", value);
6264 }
6265 if let Some(value) = self._page_size.as_ref() {
6266 params.push("pageSize", value.to_string());
6267 }
6268 if let Some(value) = self._filter.as_ref() {
6269 params.push("filter", value);
6270 }
6271
6272 params.extend(self._additional_params.iter());
6273
6274 params.push("alt", "json");
6275 let mut url = self.hub._base_url.clone() + "v1/{+parent}/notes";
6276 if self._scopes.is_empty() {
6277 self._scopes
6278 .insert(Scope::CloudPlatform.as_ref().to_string());
6279 }
6280
6281 #[allow(clippy::single_element_loop)]
6282 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6283 url = params.uri_replacement(url, param_name, find_this, true);
6284 }
6285 {
6286 let to_remove = ["parent"];
6287 params.remove_params(&to_remove);
6288 }
6289
6290 let url = params.parse_with_url(&url);
6291
6292 loop {
6293 let token = match self
6294 .hub
6295 .auth
6296 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6297 .await
6298 {
6299 Ok(token) => token,
6300 Err(e) => match dlg.token(e) {
6301 Ok(token) => token,
6302 Err(e) => {
6303 dlg.finished(false);
6304 return Err(common::Error::MissingToken(e));
6305 }
6306 },
6307 };
6308 let mut req_result = {
6309 let client = &self.hub.client;
6310 dlg.pre_request();
6311 let mut req_builder = hyper::Request::builder()
6312 .method(hyper::Method::GET)
6313 .uri(url.as_str())
6314 .header(USER_AGENT, self.hub._user_agent.clone());
6315
6316 if let Some(token) = token.as_ref() {
6317 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6318 }
6319
6320 let request = req_builder
6321 .header(CONTENT_LENGTH, 0_u64)
6322 .body(common::to_body::<String>(None));
6323
6324 client.request(request.unwrap()).await
6325 };
6326
6327 match req_result {
6328 Err(err) => {
6329 if let common::Retry::After(d) = dlg.http_error(&err) {
6330 sleep(d).await;
6331 continue;
6332 }
6333 dlg.finished(false);
6334 return Err(common::Error::HttpError(err));
6335 }
6336 Ok(res) => {
6337 let (mut parts, body) = res.into_parts();
6338 let mut body = common::Body::new(body);
6339 if !parts.status.is_success() {
6340 let bytes = common::to_bytes(body).await.unwrap_or_default();
6341 let error = serde_json::from_str(&common::to_string(&bytes));
6342 let response = common::to_response(parts, bytes.into());
6343
6344 if let common::Retry::After(d) =
6345 dlg.http_failure(&response, error.as_ref().ok())
6346 {
6347 sleep(d).await;
6348 continue;
6349 }
6350
6351 dlg.finished(false);
6352
6353 return Err(match error {
6354 Ok(value) => common::Error::BadRequest(value),
6355 _ => common::Error::Failure(response),
6356 });
6357 }
6358 let response = {
6359 let bytes = common::to_bytes(body).await.unwrap_or_default();
6360 let encoded = common::to_string(&bytes);
6361 match serde_json::from_str(&encoded) {
6362 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6363 Err(error) => {
6364 dlg.response_json_decode_error(&encoded, &error);
6365 return Err(common::Error::JsonDecodeError(
6366 encoded.to_string(),
6367 error,
6368 ));
6369 }
6370 }
6371 };
6372
6373 dlg.finished(true);
6374 return Ok(response);
6375 }
6376 }
6377 }
6378 }
6379
6380 /// Required. The name of the project to list notes for in the form of `projects/[PROJECT_ID]`.
6381 ///
6382 /// Sets the *parent* path property to the given value.
6383 ///
6384 /// Even though the property as already been set when instantiating this call,
6385 /// we provide this method for API completeness.
6386 pub fn parent(mut self, new_value: &str) -> ProjectLocationNoteListCall<'a, C> {
6387 self._parent = new_value.to_string();
6388 self
6389 }
6390 /// If set, the request will return all reachable Notes and report all unreachable regions in the `unreachable` field in the response. Only applicable for requests in the global region.
6391 ///
6392 /// Sets the *return partial success* query property to the given value.
6393 pub fn return_partial_success(mut self, new_value: bool) -> ProjectLocationNoteListCall<'a, C> {
6394 self._return_partial_success = Some(new_value);
6395 self
6396 }
6397 /// Token to provide to skip to a particular spot in the list.
6398 ///
6399 /// Sets the *page token* query property to the given value.
6400 pub fn page_token(mut self, new_value: &str) -> ProjectLocationNoteListCall<'a, C> {
6401 self._page_token = Some(new_value.to_string());
6402 self
6403 }
6404 /// 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.
6405 ///
6406 /// Sets the *page size* query property to the given value.
6407 pub fn page_size(mut self, new_value: i32) -> ProjectLocationNoteListCall<'a, C> {
6408 self._page_size = Some(new_value);
6409 self
6410 }
6411 /// The filter expression.
6412 ///
6413 /// Sets the *filter* query property to the given value.
6414 pub fn filter(mut self, new_value: &str) -> ProjectLocationNoteListCall<'a, C> {
6415 self._filter = Some(new_value.to_string());
6416 self
6417 }
6418 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6419 /// while executing the actual API request.
6420 ///
6421 /// ````text
6422 /// It should be used to handle progress information, and to implement a certain level of resilience.
6423 /// ````
6424 ///
6425 /// Sets the *delegate* property to the given value.
6426 pub fn delegate(
6427 mut self,
6428 new_value: &'a mut dyn common::Delegate,
6429 ) -> ProjectLocationNoteListCall<'a, C> {
6430 self._delegate = Some(new_value);
6431 self
6432 }
6433
6434 /// Set any additional parameter of the query string used in the request.
6435 /// It should be used to set parameters which are not yet available through their own
6436 /// setters.
6437 ///
6438 /// Please note that this method must not be used to set any of the known parameters
6439 /// which have their own setter method. If done anyway, the request will fail.
6440 ///
6441 /// # Additional Parameters
6442 ///
6443 /// * *$.xgafv* (query-string) - V1 error format.
6444 /// * *access_token* (query-string) - OAuth access token.
6445 /// * *alt* (query-string) - Data format for response.
6446 /// * *callback* (query-string) - JSONP
6447 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6448 /// * *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.
6449 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6450 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6451 /// * *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.
6452 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6453 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6454 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNoteListCall<'a, C>
6455 where
6456 T: AsRef<str>,
6457 {
6458 self._additional_params
6459 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6460 self
6461 }
6462
6463 /// Identifies the authorization scope for the method you are building.
6464 ///
6465 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6466 /// [`Scope::CloudPlatform`].
6467 ///
6468 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6469 /// tokens for more than one scope.
6470 ///
6471 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6472 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6473 /// sufficient, a read-write scope will do as well.
6474 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNoteListCall<'a, C>
6475 where
6476 St: AsRef<str>,
6477 {
6478 self._scopes.insert(String::from(scope.as_ref()));
6479 self
6480 }
6481 /// Identifies the authorization scope(s) for the method you are building.
6482 ///
6483 /// See [`Self::add_scope()`] for details.
6484 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNoteListCall<'a, C>
6485 where
6486 I: IntoIterator<Item = St>,
6487 St: AsRef<str>,
6488 {
6489 self._scopes
6490 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6491 self
6492 }
6493
6494 /// Removes all scopes, and no default scope will be used either.
6495 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6496 /// for details).
6497 pub fn clear_scopes(mut self) -> ProjectLocationNoteListCall<'a, C> {
6498 self._scopes.clear();
6499 self
6500 }
6501}
6502
6503/// Updates the specified note.
6504///
6505/// A builder for the *locations.notes.patch* method supported by a *project* resource.
6506/// It is not used directly, but through a [`ProjectMethods`] instance.
6507///
6508/// # Example
6509///
6510/// Instantiate a resource method builder
6511///
6512/// ```test_harness,no_run
6513/// # extern crate hyper;
6514/// # extern crate hyper_rustls;
6515/// # extern crate google_containeranalysis1 as containeranalysis1;
6516/// use containeranalysis1::api::Note;
6517/// # async fn dox() {
6518/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6519///
6520/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6521/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6522/// # .with_native_roots()
6523/// # .unwrap()
6524/// # .https_only()
6525/// # .enable_http2()
6526/// # .build();
6527///
6528/// # let executor = hyper_util::rt::TokioExecutor::new();
6529/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6530/// # secret,
6531/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6532/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6533/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6534/// # ),
6535/// # ).build().await.unwrap();
6536///
6537/// # let client = hyper_util::client::legacy::Client::builder(
6538/// # hyper_util::rt::TokioExecutor::new()
6539/// # )
6540/// # .build(
6541/// # hyper_rustls::HttpsConnectorBuilder::new()
6542/// # .with_native_roots()
6543/// # .unwrap()
6544/// # .https_or_http()
6545/// # .enable_http2()
6546/// # .build()
6547/// # );
6548/// # let mut hub = ContainerAnalysis::new(client, auth);
6549/// // As the method needs a request, you would usually fill it with the desired information
6550/// // into the respective structure. Some of the parts shown here might not be applicable !
6551/// // Values shown here are possibly random and not representative !
6552/// let mut req = Note::default();
6553///
6554/// // You can configure optional parameters by calling the respective setters at will, and
6555/// // execute the final call using `doit()`.
6556/// // Values shown here are possibly random and not representative !
6557/// let result = hub.projects().locations_notes_patch(req, "name")
6558/// .update_mask(FieldMask::new::<&str>(&[]))
6559/// .doit().await;
6560/// # }
6561/// ```
6562pub struct ProjectLocationNotePatchCall<'a, C>
6563where
6564 C: 'a,
6565{
6566 hub: &'a ContainerAnalysis<C>,
6567 _request: Note,
6568 _name: String,
6569 _update_mask: Option<common::FieldMask>,
6570 _delegate: Option<&'a mut dyn common::Delegate>,
6571 _additional_params: HashMap<String, String>,
6572 _scopes: BTreeSet<String>,
6573}
6574
6575impl<'a, C> common::CallBuilder for ProjectLocationNotePatchCall<'a, C> {}
6576
6577impl<'a, C> ProjectLocationNotePatchCall<'a, C>
6578where
6579 C: common::Connector,
6580{
6581 /// Perform the operation you have build so far.
6582 pub async fn doit(mut self) -> common::Result<(common::Response, Note)> {
6583 use std::borrow::Cow;
6584 use std::io::{Read, Seek};
6585
6586 use common::{url::Params, ToParts};
6587 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6588
6589 let mut dd = common::DefaultDelegate;
6590 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6591 dlg.begin(common::MethodInfo {
6592 id: "containeranalysis.projects.locations.notes.patch",
6593 http_method: hyper::Method::PATCH,
6594 });
6595
6596 for &field in ["alt", "name", "updateMask"].iter() {
6597 if self._additional_params.contains_key(field) {
6598 dlg.finished(false);
6599 return Err(common::Error::FieldClash(field));
6600 }
6601 }
6602
6603 let mut params = Params::with_capacity(5 + self._additional_params.len());
6604 params.push("name", self._name);
6605 if let Some(value) = self._update_mask.as_ref() {
6606 params.push("updateMask", value.to_string());
6607 }
6608
6609 params.extend(self._additional_params.iter());
6610
6611 params.push("alt", "json");
6612 let mut url = self.hub._base_url.clone() + "v1/{+name}";
6613 if self._scopes.is_empty() {
6614 self._scopes
6615 .insert(Scope::CloudPlatform.as_ref().to_string());
6616 }
6617
6618 #[allow(clippy::single_element_loop)]
6619 for &(find_this, param_name) in [("{+name}", "name")].iter() {
6620 url = params.uri_replacement(url, param_name, find_this, true);
6621 }
6622 {
6623 let to_remove = ["name"];
6624 params.remove_params(&to_remove);
6625 }
6626
6627 let url = params.parse_with_url(&url);
6628
6629 let mut json_mime_type = mime::APPLICATION_JSON;
6630 let mut request_value_reader = {
6631 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6632 common::remove_json_null_values(&mut value);
6633 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6634 serde_json::to_writer(&mut dst, &value).unwrap();
6635 dst
6636 };
6637 let request_size = request_value_reader
6638 .seek(std::io::SeekFrom::End(0))
6639 .unwrap();
6640 request_value_reader
6641 .seek(std::io::SeekFrom::Start(0))
6642 .unwrap();
6643
6644 loop {
6645 let token = match self
6646 .hub
6647 .auth
6648 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6649 .await
6650 {
6651 Ok(token) => token,
6652 Err(e) => match dlg.token(e) {
6653 Ok(token) => token,
6654 Err(e) => {
6655 dlg.finished(false);
6656 return Err(common::Error::MissingToken(e));
6657 }
6658 },
6659 };
6660 request_value_reader
6661 .seek(std::io::SeekFrom::Start(0))
6662 .unwrap();
6663 let mut req_result = {
6664 let client = &self.hub.client;
6665 dlg.pre_request();
6666 let mut req_builder = hyper::Request::builder()
6667 .method(hyper::Method::PATCH)
6668 .uri(url.as_str())
6669 .header(USER_AGENT, self.hub._user_agent.clone());
6670
6671 if let Some(token) = token.as_ref() {
6672 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6673 }
6674
6675 let request = req_builder
6676 .header(CONTENT_TYPE, json_mime_type.to_string())
6677 .header(CONTENT_LENGTH, request_size as u64)
6678 .body(common::to_body(
6679 request_value_reader.get_ref().clone().into(),
6680 ));
6681
6682 client.request(request.unwrap()).await
6683 };
6684
6685 match req_result {
6686 Err(err) => {
6687 if let common::Retry::After(d) = dlg.http_error(&err) {
6688 sleep(d).await;
6689 continue;
6690 }
6691 dlg.finished(false);
6692 return Err(common::Error::HttpError(err));
6693 }
6694 Ok(res) => {
6695 let (mut parts, body) = res.into_parts();
6696 let mut body = common::Body::new(body);
6697 if !parts.status.is_success() {
6698 let bytes = common::to_bytes(body).await.unwrap_or_default();
6699 let error = serde_json::from_str(&common::to_string(&bytes));
6700 let response = common::to_response(parts, bytes.into());
6701
6702 if let common::Retry::After(d) =
6703 dlg.http_failure(&response, error.as_ref().ok())
6704 {
6705 sleep(d).await;
6706 continue;
6707 }
6708
6709 dlg.finished(false);
6710
6711 return Err(match error {
6712 Ok(value) => common::Error::BadRequest(value),
6713 _ => common::Error::Failure(response),
6714 });
6715 }
6716 let response = {
6717 let bytes = common::to_bytes(body).await.unwrap_or_default();
6718 let encoded = common::to_string(&bytes);
6719 match serde_json::from_str(&encoded) {
6720 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6721 Err(error) => {
6722 dlg.response_json_decode_error(&encoded, &error);
6723 return Err(common::Error::JsonDecodeError(
6724 encoded.to_string(),
6725 error,
6726 ));
6727 }
6728 }
6729 };
6730
6731 dlg.finished(true);
6732 return Ok(response);
6733 }
6734 }
6735 }
6736 }
6737
6738 ///
6739 /// Sets the *request* property to the given value.
6740 ///
6741 /// Even though the property as already been set when instantiating this call,
6742 /// we provide this method for API completeness.
6743 pub fn request(mut self, new_value: Note) -> ProjectLocationNotePatchCall<'a, C> {
6744 self._request = new_value;
6745 self
6746 }
6747 /// Required. The name of the note in the form of `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.
6748 ///
6749 /// Sets the *name* path property to the given value.
6750 ///
6751 /// Even though the property as already been set when instantiating this call,
6752 /// we provide this method for API completeness.
6753 pub fn name(mut self, new_value: &str) -> ProjectLocationNotePatchCall<'a, C> {
6754 self._name = new_value.to_string();
6755 self
6756 }
6757 /// The fields to update.
6758 ///
6759 /// Sets the *update mask* query property to the given value.
6760 pub fn update_mask(
6761 mut self,
6762 new_value: common::FieldMask,
6763 ) -> ProjectLocationNotePatchCall<'a, C> {
6764 self._update_mask = Some(new_value);
6765 self
6766 }
6767 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6768 /// while executing the actual API request.
6769 ///
6770 /// ````text
6771 /// It should be used to handle progress information, and to implement a certain level of resilience.
6772 /// ````
6773 ///
6774 /// Sets the *delegate* property to the given value.
6775 pub fn delegate(
6776 mut self,
6777 new_value: &'a mut dyn common::Delegate,
6778 ) -> ProjectLocationNotePatchCall<'a, C> {
6779 self._delegate = Some(new_value);
6780 self
6781 }
6782
6783 /// Set any additional parameter of the query string used in the request.
6784 /// It should be used to set parameters which are not yet available through their own
6785 /// setters.
6786 ///
6787 /// Please note that this method must not be used to set any of the known parameters
6788 /// which have their own setter method. If done anyway, the request will fail.
6789 ///
6790 /// # Additional Parameters
6791 ///
6792 /// * *$.xgafv* (query-string) - V1 error format.
6793 /// * *access_token* (query-string) - OAuth access token.
6794 /// * *alt* (query-string) - Data format for response.
6795 /// * *callback* (query-string) - JSONP
6796 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6797 /// * *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.
6798 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6799 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6800 /// * *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.
6801 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6802 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6803 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNotePatchCall<'a, C>
6804 where
6805 T: AsRef<str>,
6806 {
6807 self._additional_params
6808 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6809 self
6810 }
6811
6812 /// Identifies the authorization scope for the method you are building.
6813 ///
6814 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6815 /// [`Scope::CloudPlatform`].
6816 ///
6817 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6818 /// tokens for more than one scope.
6819 ///
6820 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6821 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6822 /// sufficient, a read-write scope will do as well.
6823 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNotePatchCall<'a, C>
6824 where
6825 St: AsRef<str>,
6826 {
6827 self._scopes.insert(String::from(scope.as_ref()));
6828 self
6829 }
6830 /// Identifies the authorization scope(s) for the method you are building.
6831 ///
6832 /// See [`Self::add_scope()`] for details.
6833 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNotePatchCall<'a, C>
6834 where
6835 I: IntoIterator<Item = St>,
6836 St: AsRef<str>,
6837 {
6838 self._scopes
6839 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6840 self
6841 }
6842
6843 /// Removes all scopes, and no default scope will be used either.
6844 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6845 /// for details).
6846 pub fn clear_scopes(mut self) -> ProjectLocationNotePatchCall<'a, C> {
6847 self._scopes.clear();
6848 self
6849 }
6850}
6851
6852/// 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.
6853///
6854/// A builder for the *locations.notes.setIamPolicy* method supported by a *project* resource.
6855/// It is not used directly, but through a [`ProjectMethods`] instance.
6856///
6857/// # Example
6858///
6859/// Instantiate a resource method builder
6860///
6861/// ```test_harness,no_run
6862/// # extern crate hyper;
6863/// # extern crate hyper_rustls;
6864/// # extern crate google_containeranalysis1 as containeranalysis1;
6865/// use containeranalysis1::api::SetIamPolicyRequest;
6866/// # async fn dox() {
6867/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6868///
6869/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6870/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6871/// # .with_native_roots()
6872/// # .unwrap()
6873/// # .https_only()
6874/// # .enable_http2()
6875/// # .build();
6876///
6877/// # let executor = hyper_util::rt::TokioExecutor::new();
6878/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6879/// # secret,
6880/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6881/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6882/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6883/// # ),
6884/// # ).build().await.unwrap();
6885///
6886/// # let client = hyper_util::client::legacy::Client::builder(
6887/// # hyper_util::rt::TokioExecutor::new()
6888/// # )
6889/// # .build(
6890/// # hyper_rustls::HttpsConnectorBuilder::new()
6891/// # .with_native_roots()
6892/// # .unwrap()
6893/// # .https_or_http()
6894/// # .enable_http2()
6895/// # .build()
6896/// # );
6897/// # let mut hub = ContainerAnalysis::new(client, auth);
6898/// // As the method needs a request, you would usually fill it with the desired information
6899/// // into the respective structure. Some of the parts shown here might not be applicable !
6900/// // Values shown here are possibly random and not representative !
6901/// let mut req = SetIamPolicyRequest::default();
6902///
6903/// // You can configure optional parameters by calling the respective setters at will, and
6904/// // execute the final call using `doit()`.
6905/// // Values shown here are possibly random and not representative !
6906/// let result = hub.projects().locations_notes_set_iam_policy(req, "resource")
6907/// .doit().await;
6908/// # }
6909/// ```
6910pub struct ProjectLocationNoteSetIamPolicyCall<'a, C>
6911where
6912 C: 'a,
6913{
6914 hub: &'a ContainerAnalysis<C>,
6915 _request: SetIamPolicyRequest,
6916 _resource: String,
6917 _delegate: Option<&'a mut dyn common::Delegate>,
6918 _additional_params: HashMap<String, String>,
6919 _scopes: BTreeSet<String>,
6920}
6921
6922impl<'a, C> common::CallBuilder for ProjectLocationNoteSetIamPolicyCall<'a, C> {}
6923
6924impl<'a, C> ProjectLocationNoteSetIamPolicyCall<'a, C>
6925where
6926 C: common::Connector,
6927{
6928 /// Perform the operation you have build so far.
6929 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
6930 use std::borrow::Cow;
6931 use std::io::{Read, Seek};
6932
6933 use common::{url::Params, ToParts};
6934 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6935
6936 let mut dd = common::DefaultDelegate;
6937 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6938 dlg.begin(common::MethodInfo {
6939 id: "containeranalysis.projects.locations.notes.setIamPolicy",
6940 http_method: hyper::Method::POST,
6941 });
6942
6943 for &field in ["alt", "resource"].iter() {
6944 if self._additional_params.contains_key(field) {
6945 dlg.finished(false);
6946 return Err(common::Error::FieldClash(field));
6947 }
6948 }
6949
6950 let mut params = Params::with_capacity(4 + self._additional_params.len());
6951 params.push("resource", self._resource);
6952
6953 params.extend(self._additional_params.iter());
6954
6955 params.push("alt", "json");
6956 let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
6957 if self._scopes.is_empty() {
6958 self._scopes
6959 .insert(Scope::CloudPlatform.as_ref().to_string());
6960 }
6961
6962 #[allow(clippy::single_element_loop)]
6963 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
6964 url = params.uri_replacement(url, param_name, find_this, true);
6965 }
6966 {
6967 let to_remove = ["resource"];
6968 params.remove_params(&to_remove);
6969 }
6970
6971 let url = params.parse_with_url(&url);
6972
6973 let mut json_mime_type = mime::APPLICATION_JSON;
6974 let mut request_value_reader = {
6975 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6976 common::remove_json_null_values(&mut value);
6977 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6978 serde_json::to_writer(&mut dst, &value).unwrap();
6979 dst
6980 };
6981 let request_size = request_value_reader
6982 .seek(std::io::SeekFrom::End(0))
6983 .unwrap();
6984 request_value_reader
6985 .seek(std::io::SeekFrom::Start(0))
6986 .unwrap();
6987
6988 loop {
6989 let token = match self
6990 .hub
6991 .auth
6992 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6993 .await
6994 {
6995 Ok(token) => token,
6996 Err(e) => match dlg.token(e) {
6997 Ok(token) => token,
6998 Err(e) => {
6999 dlg.finished(false);
7000 return Err(common::Error::MissingToken(e));
7001 }
7002 },
7003 };
7004 request_value_reader
7005 .seek(std::io::SeekFrom::Start(0))
7006 .unwrap();
7007 let mut req_result = {
7008 let client = &self.hub.client;
7009 dlg.pre_request();
7010 let mut req_builder = hyper::Request::builder()
7011 .method(hyper::Method::POST)
7012 .uri(url.as_str())
7013 .header(USER_AGENT, self.hub._user_agent.clone());
7014
7015 if let Some(token) = token.as_ref() {
7016 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7017 }
7018
7019 let request = req_builder
7020 .header(CONTENT_TYPE, json_mime_type.to_string())
7021 .header(CONTENT_LENGTH, request_size as u64)
7022 .body(common::to_body(
7023 request_value_reader.get_ref().clone().into(),
7024 ));
7025
7026 client.request(request.unwrap()).await
7027 };
7028
7029 match req_result {
7030 Err(err) => {
7031 if let common::Retry::After(d) = dlg.http_error(&err) {
7032 sleep(d).await;
7033 continue;
7034 }
7035 dlg.finished(false);
7036 return Err(common::Error::HttpError(err));
7037 }
7038 Ok(res) => {
7039 let (mut parts, body) = res.into_parts();
7040 let mut body = common::Body::new(body);
7041 if !parts.status.is_success() {
7042 let bytes = common::to_bytes(body).await.unwrap_or_default();
7043 let error = serde_json::from_str(&common::to_string(&bytes));
7044 let response = common::to_response(parts, bytes.into());
7045
7046 if let common::Retry::After(d) =
7047 dlg.http_failure(&response, error.as_ref().ok())
7048 {
7049 sleep(d).await;
7050 continue;
7051 }
7052
7053 dlg.finished(false);
7054
7055 return Err(match error {
7056 Ok(value) => common::Error::BadRequest(value),
7057 _ => common::Error::Failure(response),
7058 });
7059 }
7060 let response = {
7061 let bytes = common::to_bytes(body).await.unwrap_or_default();
7062 let encoded = common::to_string(&bytes);
7063 match serde_json::from_str(&encoded) {
7064 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7065 Err(error) => {
7066 dlg.response_json_decode_error(&encoded, &error);
7067 return Err(common::Error::JsonDecodeError(
7068 encoded.to_string(),
7069 error,
7070 ));
7071 }
7072 }
7073 };
7074
7075 dlg.finished(true);
7076 return Ok(response);
7077 }
7078 }
7079 }
7080 }
7081
7082 ///
7083 /// Sets the *request* property to the given value.
7084 ///
7085 /// Even though the property as already been set when instantiating this call,
7086 /// we provide this method for API completeness.
7087 pub fn request(
7088 mut self,
7089 new_value: SetIamPolicyRequest,
7090 ) -> ProjectLocationNoteSetIamPolicyCall<'a, C> {
7091 self._request = new_value;
7092 self
7093 }
7094 /// 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.
7095 ///
7096 /// Sets the *resource* path property to the given value.
7097 ///
7098 /// Even though the property as already been set when instantiating this call,
7099 /// we provide this method for API completeness.
7100 pub fn resource(mut self, new_value: &str) -> ProjectLocationNoteSetIamPolicyCall<'a, C> {
7101 self._resource = new_value.to_string();
7102 self
7103 }
7104 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7105 /// while executing the actual API request.
7106 ///
7107 /// ````text
7108 /// It should be used to handle progress information, and to implement a certain level of resilience.
7109 /// ````
7110 ///
7111 /// Sets the *delegate* property to the given value.
7112 pub fn delegate(
7113 mut self,
7114 new_value: &'a mut dyn common::Delegate,
7115 ) -> ProjectLocationNoteSetIamPolicyCall<'a, C> {
7116 self._delegate = Some(new_value);
7117 self
7118 }
7119
7120 /// Set any additional parameter of the query string used in the request.
7121 /// It should be used to set parameters which are not yet available through their own
7122 /// setters.
7123 ///
7124 /// Please note that this method must not be used to set any of the known parameters
7125 /// which have their own setter method. If done anyway, the request will fail.
7126 ///
7127 /// # Additional Parameters
7128 ///
7129 /// * *$.xgafv* (query-string) - V1 error format.
7130 /// * *access_token* (query-string) - OAuth access token.
7131 /// * *alt* (query-string) - Data format for response.
7132 /// * *callback* (query-string) - JSONP
7133 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7134 /// * *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.
7135 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7136 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7137 /// * *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.
7138 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7139 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7140 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNoteSetIamPolicyCall<'a, C>
7141 where
7142 T: AsRef<str>,
7143 {
7144 self._additional_params
7145 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7146 self
7147 }
7148
7149 /// Identifies the authorization scope for the method you are building.
7150 ///
7151 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7152 /// [`Scope::CloudPlatform`].
7153 ///
7154 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7155 /// tokens for more than one scope.
7156 ///
7157 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7158 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7159 /// sufficient, a read-write scope will do as well.
7160 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNoteSetIamPolicyCall<'a, C>
7161 where
7162 St: AsRef<str>,
7163 {
7164 self._scopes.insert(String::from(scope.as_ref()));
7165 self
7166 }
7167 /// Identifies the authorization scope(s) for the method you are building.
7168 ///
7169 /// See [`Self::add_scope()`] for details.
7170 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNoteSetIamPolicyCall<'a, C>
7171 where
7172 I: IntoIterator<Item = St>,
7173 St: AsRef<str>,
7174 {
7175 self._scopes
7176 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7177 self
7178 }
7179
7180 /// Removes all scopes, and no default scope will be used either.
7181 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7182 /// for details).
7183 pub fn clear_scopes(mut self) -> ProjectLocationNoteSetIamPolicyCall<'a, C> {
7184 self._scopes.clear();
7185 self
7186 }
7187}
7188
7189/// 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.
7190///
7191/// A builder for the *locations.notes.testIamPermissions* method supported by a *project* resource.
7192/// It is not used directly, but through a [`ProjectMethods`] instance.
7193///
7194/// # Example
7195///
7196/// Instantiate a resource method builder
7197///
7198/// ```test_harness,no_run
7199/// # extern crate hyper;
7200/// # extern crate hyper_rustls;
7201/// # extern crate google_containeranalysis1 as containeranalysis1;
7202/// use containeranalysis1::api::TestIamPermissionsRequest;
7203/// # async fn dox() {
7204/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7205///
7206/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7207/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7208/// # .with_native_roots()
7209/// # .unwrap()
7210/// # .https_only()
7211/// # .enable_http2()
7212/// # .build();
7213///
7214/// # let executor = hyper_util::rt::TokioExecutor::new();
7215/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7216/// # secret,
7217/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7218/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7219/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7220/// # ),
7221/// # ).build().await.unwrap();
7222///
7223/// # let client = hyper_util::client::legacy::Client::builder(
7224/// # hyper_util::rt::TokioExecutor::new()
7225/// # )
7226/// # .build(
7227/// # hyper_rustls::HttpsConnectorBuilder::new()
7228/// # .with_native_roots()
7229/// # .unwrap()
7230/// # .https_or_http()
7231/// # .enable_http2()
7232/// # .build()
7233/// # );
7234/// # let mut hub = ContainerAnalysis::new(client, auth);
7235/// // As the method needs a request, you would usually fill it with the desired information
7236/// // into the respective structure. Some of the parts shown here might not be applicable !
7237/// // Values shown here are possibly random and not representative !
7238/// let mut req = TestIamPermissionsRequest::default();
7239///
7240/// // You can configure optional parameters by calling the respective setters at will, and
7241/// // execute the final call using `doit()`.
7242/// // Values shown here are possibly random and not representative !
7243/// let result = hub.projects().locations_notes_test_iam_permissions(req, "resource")
7244/// .doit().await;
7245/// # }
7246/// ```
7247pub struct ProjectLocationNoteTestIamPermissionCall<'a, C>
7248where
7249 C: 'a,
7250{
7251 hub: &'a ContainerAnalysis<C>,
7252 _request: TestIamPermissionsRequest,
7253 _resource: String,
7254 _delegate: Option<&'a mut dyn common::Delegate>,
7255 _additional_params: HashMap<String, String>,
7256 _scopes: BTreeSet<String>,
7257}
7258
7259impl<'a, C> common::CallBuilder for ProjectLocationNoteTestIamPermissionCall<'a, C> {}
7260
7261impl<'a, C> ProjectLocationNoteTestIamPermissionCall<'a, C>
7262where
7263 C: common::Connector,
7264{
7265 /// Perform the operation you have build so far.
7266 pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
7267 use std::borrow::Cow;
7268 use std::io::{Read, Seek};
7269
7270 use common::{url::Params, ToParts};
7271 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7272
7273 let mut dd = common::DefaultDelegate;
7274 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7275 dlg.begin(common::MethodInfo {
7276 id: "containeranalysis.projects.locations.notes.testIamPermissions",
7277 http_method: hyper::Method::POST,
7278 });
7279
7280 for &field in ["alt", "resource"].iter() {
7281 if self._additional_params.contains_key(field) {
7282 dlg.finished(false);
7283 return Err(common::Error::FieldClash(field));
7284 }
7285 }
7286
7287 let mut params = Params::with_capacity(4 + self._additional_params.len());
7288 params.push("resource", self._resource);
7289
7290 params.extend(self._additional_params.iter());
7291
7292 params.push("alt", "json");
7293 let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
7294 if self._scopes.is_empty() {
7295 self._scopes
7296 .insert(Scope::CloudPlatform.as_ref().to_string());
7297 }
7298
7299 #[allow(clippy::single_element_loop)]
7300 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
7301 url = params.uri_replacement(url, param_name, find_this, true);
7302 }
7303 {
7304 let to_remove = ["resource"];
7305 params.remove_params(&to_remove);
7306 }
7307
7308 let url = params.parse_with_url(&url);
7309
7310 let mut json_mime_type = mime::APPLICATION_JSON;
7311 let mut request_value_reader = {
7312 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7313 common::remove_json_null_values(&mut value);
7314 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7315 serde_json::to_writer(&mut dst, &value).unwrap();
7316 dst
7317 };
7318 let request_size = request_value_reader
7319 .seek(std::io::SeekFrom::End(0))
7320 .unwrap();
7321 request_value_reader
7322 .seek(std::io::SeekFrom::Start(0))
7323 .unwrap();
7324
7325 loop {
7326 let token = match self
7327 .hub
7328 .auth
7329 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7330 .await
7331 {
7332 Ok(token) => token,
7333 Err(e) => match dlg.token(e) {
7334 Ok(token) => token,
7335 Err(e) => {
7336 dlg.finished(false);
7337 return Err(common::Error::MissingToken(e));
7338 }
7339 },
7340 };
7341 request_value_reader
7342 .seek(std::io::SeekFrom::Start(0))
7343 .unwrap();
7344 let mut req_result = {
7345 let client = &self.hub.client;
7346 dlg.pre_request();
7347 let mut req_builder = hyper::Request::builder()
7348 .method(hyper::Method::POST)
7349 .uri(url.as_str())
7350 .header(USER_AGENT, self.hub._user_agent.clone());
7351
7352 if let Some(token) = token.as_ref() {
7353 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7354 }
7355
7356 let request = req_builder
7357 .header(CONTENT_TYPE, json_mime_type.to_string())
7358 .header(CONTENT_LENGTH, request_size as u64)
7359 .body(common::to_body(
7360 request_value_reader.get_ref().clone().into(),
7361 ));
7362
7363 client.request(request.unwrap()).await
7364 };
7365
7366 match req_result {
7367 Err(err) => {
7368 if let common::Retry::After(d) = dlg.http_error(&err) {
7369 sleep(d).await;
7370 continue;
7371 }
7372 dlg.finished(false);
7373 return Err(common::Error::HttpError(err));
7374 }
7375 Ok(res) => {
7376 let (mut parts, body) = res.into_parts();
7377 let mut body = common::Body::new(body);
7378 if !parts.status.is_success() {
7379 let bytes = common::to_bytes(body).await.unwrap_or_default();
7380 let error = serde_json::from_str(&common::to_string(&bytes));
7381 let response = common::to_response(parts, bytes.into());
7382
7383 if let common::Retry::After(d) =
7384 dlg.http_failure(&response, error.as_ref().ok())
7385 {
7386 sleep(d).await;
7387 continue;
7388 }
7389
7390 dlg.finished(false);
7391
7392 return Err(match error {
7393 Ok(value) => common::Error::BadRequest(value),
7394 _ => common::Error::Failure(response),
7395 });
7396 }
7397 let response = {
7398 let bytes = common::to_bytes(body).await.unwrap_or_default();
7399 let encoded = common::to_string(&bytes);
7400 match serde_json::from_str(&encoded) {
7401 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7402 Err(error) => {
7403 dlg.response_json_decode_error(&encoded, &error);
7404 return Err(common::Error::JsonDecodeError(
7405 encoded.to_string(),
7406 error,
7407 ));
7408 }
7409 }
7410 };
7411
7412 dlg.finished(true);
7413 return Ok(response);
7414 }
7415 }
7416 }
7417 }
7418
7419 ///
7420 /// Sets the *request* property to the given value.
7421 ///
7422 /// Even though the property as already been set when instantiating this call,
7423 /// we provide this method for API completeness.
7424 pub fn request(
7425 mut self,
7426 new_value: TestIamPermissionsRequest,
7427 ) -> ProjectLocationNoteTestIamPermissionCall<'a, C> {
7428 self._request = new_value;
7429 self
7430 }
7431 /// 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.
7432 ///
7433 /// Sets the *resource* path property to the given value.
7434 ///
7435 /// Even though the property as already been set when instantiating this call,
7436 /// we provide this method for API completeness.
7437 pub fn resource(mut self, new_value: &str) -> ProjectLocationNoteTestIamPermissionCall<'a, C> {
7438 self._resource = new_value.to_string();
7439 self
7440 }
7441 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7442 /// while executing the actual API request.
7443 ///
7444 /// ````text
7445 /// It should be used to handle progress information, and to implement a certain level of resilience.
7446 /// ````
7447 ///
7448 /// Sets the *delegate* property to the given value.
7449 pub fn delegate(
7450 mut self,
7451 new_value: &'a mut dyn common::Delegate,
7452 ) -> ProjectLocationNoteTestIamPermissionCall<'a, C> {
7453 self._delegate = Some(new_value);
7454 self
7455 }
7456
7457 /// Set any additional parameter of the query string used in the request.
7458 /// It should be used to set parameters which are not yet available through their own
7459 /// setters.
7460 ///
7461 /// Please note that this method must not be used to set any of the known parameters
7462 /// which have their own setter method. If done anyway, the request will fail.
7463 ///
7464 /// # Additional Parameters
7465 ///
7466 /// * *$.xgafv* (query-string) - V1 error format.
7467 /// * *access_token* (query-string) - OAuth access token.
7468 /// * *alt* (query-string) - Data format for response.
7469 /// * *callback* (query-string) - JSONP
7470 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7471 /// * *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.
7472 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7473 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7474 /// * *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.
7475 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7476 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7477 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationNoteTestIamPermissionCall<'a, C>
7478 where
7479 T: AsRef<str>,
7480 {
7481 self._additional_params
7482 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7483 self
7484 }
7485
7486 /// Identifies the authorization scope for the method you are building.
7487 ///
7488 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7489 /// [`Scope::CloudPlatform`].
7490 ///
7491 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7492 /// tokens for more than one scope.
7493 ///
7494 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7495 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7496 /// sufficient, a read-write scope will do as well.
7497 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationNoteTestIamPermissionCall<'a, C>
7498 where
7499 St: AsRef<str>,
7500 {
7501 self._scopes.insert(String::from(scope.as_ref()));
7502 self
7503 }
7504 /// Identifies the authorization scope(s) for the method you are building.
7505 ///
7506 /// See [`Self::add_scope()`] for details.
7507 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationNoteTestIamPermissionCall<'a, C>
7508 where
7509 I: IntoIterator<Item = St>,
7510 St: AsRef<str>,
7511 {
7512 self._scopes
7513 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7514 self
7515 }
7516
7517 /// Removes all scopes, and no default scope will be used either.
7518 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7519 /// for details).
7520 pub fn clear_scopes(mut self) -> ProjectLocationNoteTestIamPermissionCall<'a, C> {
7521 self._scopes.clear();
7522 self
7523 }
7524}
7525
7526/// Creates new occurrences in batch.
7527///
7528/// A builder for the *locations.occurrences.batchCreate* method supported by a *project* resource.
7529/// It is not used directly, but through a [`ProjectMethods`] instance.
7530///
7531/// # Example
7532///
7533/// Instantiate a resource method builder
7534///
7535/// ```test_harness,no_run
7536/// # extern crate hyper;
7537/// # extern crate hyper_rustls;
7538/// # extern crate google_containeranalysis1 as containeranalysis1;
7539/// use containeranalysis1::api::BatchCreateOccurrencesRequest;
7540/// # async fn dox() {
7541/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7542///
7543/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7544/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7545/// # .with_native_roots()
7546/// # .unwrap()
7547/// # .https_only()
7548/// # .enable_http2()
7549/// # .build();
7550///
7551/// # let executor = hyper_util::rt::TokioExecutor::new();
7552/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7553/// # secret,
7554/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7555/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7556/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7557/// # ),
7558/// # ).build().await.unwrap();
7559///
7560/// # let client = hyper_util::client::legacy::Client::builder(
7561/// # hyper_util::rt::TokioExecutor::new()
7562/// # )
7563/// # .build(
7564/// # hyper_rustls::HttpsConnectorBuilder::new()
7565/// # .with_native_roots()
7566/// # .unwrap()
7567/// # .https_or_http()
7568/// # .enable_http2()
7569/// # .build()
7570/// # );
7571/// # let mut hub = ContainerAnalysis::new(client, auth);
7572/// // As the method needs a request, you would usually fill it with the desired information
7573/// // into the respective structure. Some of the parts shown here might not be applicable !
7574/// // Values shown here are possibly random and not representative !
7575/// let mut req = BatchCreateOccurrencesRequest::default();
7576///
7577/// // You can configure optional parameters by calling the respective setters at will, and
7578/// // execute the final call using `doit()`.
7579/// // Values shown here are possibly random and not representative !
7580/// let result = hub.projects().locations_occurrences_batch_create(req, "parent")
7581/// .doit().await;
7582/// # }
7583/// ```
7584pub struct ProjectLocationOccurrenceBatchCreateCall<'a, C>
7585where
7586 C: 'a,
7587{
7588 hub: &'a ContainerAnalysis<C>,
7589 _request: BatchCreateOccurrencesRequest,
7590 _parent: String,
7591 _delegate: Option<&'a mut dyn common::Delegate>,
7592 _additional_params: HashMap<String, String>,
7593 _scopes: BTreeSet<String>,
7594}
7595
7596impl<'a, C> common::CallBuilder for ProjectLocationOccurrenceBatchCreateCall<'a, C> {}
7597
7598impl<'a, C> ProjectLocationOccurrenceBatchCreateCall<'a, C>
7599where
7600 C: common::Connector,
7601{
7602 /// Perform the operation you have build so far.
7603 pub async fn doit(
7604 mut self,
7605 ) -> common::Result<(common::Response, BatchCreateOccurrencesResponse)> {
7606 use std::borrow::Cow;
7607 use std::io::{Read, Seek};
7608
7609 use common::{url::Params, ToParts};
7610 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7611
7612 let mut dd = common::DefaultDelegate;
7613 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7614 dlg.begin(common::MethodInfo {
7615 id: "containeranalysis.projects.locations.occurrences.batchCreate",
7616 http_method: hyper::Method::POST,
7617 });
7618
7619 for &field in ["alt", "parent"].iter() {
7620 if self._additional_params.contains_key(field) {
7621 dlg.finished(false);
7622 return Err(common::Error::FieldClash(field));
7623 }
7624 }
7625
7626 let mut params = Params::with_capacity(4 + self._additional_params.len());
7627 params.push("parent", self._parent);
7628
7629 params.extend(self._additional_params.iter());
7630
7631 params.push("alt", "json");
7632 let mut url = self.hub._base_url.clone() + "v1/{+parent}/occurrences:batchCreate";
7633 if self._scopes.is_empty() {
7634 self._scopes
7635 .insert(Scope::CloudPlatform.as_ref().to_string());
7636 }
7637
7638 #[allow(clippy::single_element_loop)]
7639 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
7640 url = params.uri_replacement(url, param_name, find_this, true);
7641 }
7642 {
7643 let to_remove = ["parent"];
7644 params.remove_params(&to_remove);
7645 }
7646
7647 let url = params.parse_with_url(&url);
7648
7649 let mut json_mime_type = mime::APPLICATION_JSON;
7650 let mut request_value_reader = {
7651 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7652 common::remove_json_null_values(&mut value);
7653 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7654 serde_json::to_writer(&mut dst, &value).unwrap();
7655 dst
7656 };
7657 let request_size = request_value_reader
7658 .seek(std::io::SeekFrom::End(0))
7659 .unwrap();
7660 request_value_reader
7661 .seek(std::io::SeekFrom::Start(0))
7662 .unwrap();
7663
7664 loop {
7665 let token = match self
7666 .hub
7667 .auth
7668 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7669 .await
7670 {
7671 Ok(token) => token,
7672 Err(e) => match dlg.token(e) {
7673 Ok(token) => token,
7674 Err(e) => {
7675 dlg.finished(false);
7676 return Err(common::Error::MissingToken(e));
7677 }
7678 },
7679 };
7680 request_value_reader
7681 .seek(std::io::SeekFrom::Start(0))
7682 .unwrap();
7683 let mut req_result = {
7684 let client = &self.hub.client;
7685 dlg.pre_request();
7686 let mut req_builder = hyper::Request::builder()
7687 .method(hyper::Method::POST)
7688 .uri(url.as_str())
7689 .header(USER_AGENT, self.hub._user_agent.clone());
7690
7691 if let Some(token) = token.as_ref() {
7692 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7693 }
7694
7695 let request = req_builder
7696 .header(CONTENT_TYPE, json_mime_type.to_string())
7697 .header(CONTENT_LENGTH, request_size as u64)
7698 .body(common::to_body(
7699 request_value_reader.get_ref().clone().into(),
7700 ));
7701
7702 client.request(request.unwrap()).await
7703 };
7704
7705 match req_result {
7706 Err(err) => {
7707 if let common::Retry::After(d) = dlg.http_error(&err) {
7708 sleep(d).await;
7709 continue;
7710 }
7711 dlg.finished(false);
7712 return Err(common::Error::HttpError(err));
7713 }
7714 Ok(res) => {
7715 let (mut parts, body) = res.into_parts();
7716 let mut body = common::Body::new(body);
7717 if !parts.status.is_success() {
7718 let bytes = common::to_bytes(body).await.unwrap_or_default();
7719 let error = serde_json::from_str(&common::to_string(&bytes));
7720 let response = common::to_response(parts, bytes.into());
7721
7722 if let common::Retry::After(d) =
7723 dlg.http_failure(&response, error.as_ref().ok())
7724 {
7725 sleep(d).await;
7726 continue;
7727 }
7728
7729 dlg.finished(false);
7730
7731 return Err(match error {
7732 Ok(value) => common::Error::BadRequest(value),
7733 _ => common::Error::Failure(response),
7734 });
7735 }
7736 let response = {
7737 let bytes = common::to_bytes(body).await.unwrap_or_default();
7738 let encoded = common::to_string(&bytes);
7739 match serde_json::from_str(&encoded) {
7740 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7741 Err(error) => {
7742 dlg.response_json_decode_error(&encoded, &error);
7743 return Err(common::Error::JsonDecodeError(
7744 encoded.to_string(),
7745 error,
7746 ));
7747 }
7748 }
7749 };
7750
7751 dlg.finished(true);
7752 return Ok(response);
7753 }
7754 }
7755 }
7756 }
7757
7758 ///
7759 /// Sets the *request* property to the given value.
7760 ///
7761 /// Even though the property as already been set when instantiating this call,
7762 /// we provide this method for API completeness.
7763 pub fn request(
7764 mut self,
7765 new_value: BatchCreateOccurrencesRequest,
7766 ) -> ProjectLocationOccurrenceBatchCreateCall<'a, C> {
7767 self._request = new_value;
7768 self
7769 }
7770 /// Required. The name of the project in the form of `projects/[PROJECT_ID]`, under which the occurrences are to be created.
7771 ///
7772 /// Sets the *parent* path property to the given value.
7773 ///
7774 /// Even though the property as already been set when instantiating this call,
7775 /// we provide this method for API completeness.
7776 pub fn parent(mut self, new_value: &str) -> ProjectLocationOccurrenceBatchCreateCall<'a, C> {
7777 self._parent = new_value.to_string();
7778 self
7779 }
7780 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7781 /// while executing the actual API request.
7782 ///
7783 /// ````text
7784 /// It should be used to handle progress information, and to implement a certain level of resilience.
7785 /// ````
7786 ///
7787 /// Sets the *delegate* property to the given value.
7788 pub fn delegate(
7789 mut self,
7790 new_value: &'a mut dyn common::Delegate,
7791 ) -> ProjectLocationOccurrenceBatchCreateCall<'a, C> {
7792 self._delegate = Some(new_value);
7793 self
7794 }
7795
7796 /// Set any additional parameter of the query string used in the request.
7797 /// It should be used to set parameters which are not yet available through their own
7798 /// setters.
7799 ///
7800 /// Please note that this method must not be used to set any of the known parameters
7801 /// which have their own setter method. If done anyway, the request will fail.
7802 ///
7803 /// # Additional Parameters
7804 ///
7805 /// * *$.xgafv* (query-string) - V1 error format.
7806 /// * *access_token* (query-string) - OAuth access token.
7807 /// * *alt* (query-string) - Data format for response.
7808 /// * *callback* (query-string) - JSONP
7809 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7810 /// * *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.
7811 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7812 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7813 /// * *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.
7814 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7815 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7816 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOccurrenceBatchCreateCall<'a, C>
7817 where
7818 T: AsRef<str>,
7819 {
7820 self._additional_params
7821 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7822 self
7823 }
7824
7825 /// Identifies the authorization scope for the method you are building.
7826 ///
7827 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7828 /// [`Scope::CloudPlatform`].
7829 ///
7830 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7831 /// tokens for more than one scope.
7832 ///
7833 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7834 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7835 /// sufficient, a read-write scope will do as well.
7836 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOccurrenceBatchCreateCall<'a, C>
7837 where
7838 St: AsRef<str>,
7839 {
7840 self._scopes.insert(String::from(scope.as_ref()));
7841 self
7842 }
7843 /// Identifies the authorization scope(s) for the method you are building.
7844 ///
7845 /// See [`Self::add_scope()`] for details.
7846 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOccurrenceBatchCreateCall<'a, C>
7847 where
7848 I: IntoIterator<Item = St>,
7849 St: AsRef<str>,
7850 {
7851 self._scopes
7852 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7853 self
7854 }
7855
7856 /// Removes all scopes, and no default scope will be used either.
7857 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7858 /// for details).
7859 pub fn clear_scopes(mut self) -> ProjectLocationOccurrenceBatchCreateCall<'a, C> {
7860 self._scopes.clear();
7861 self
7862 }
7863}
7864
7865/// Creates a new occurrence.
7866///
7867/// A builder for the *locations.occurrences.create* method supported by a *project* resource.
7868/// It is not used directly, but through a [`ProjectMethods`] instance.
7869///
7870/// # Example
7871///
7872/// Instantiate a resource method builder
7873///
7874/// ```test_harness,no_run
7875/// # extern crate hyper;
7876/// # extern crate hyper_rustls;
7877/// # extern crate google_containeranalysis1 as containeranalysis1;
7878/// use containeranalysis1::api::Occurrence;
7879/// # async fn dox() {
7880/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7881///
7882/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7883/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7884/// # .with_native_roots()
7885/// # .unwrap()
7886/// # .https_only()
7887/// # .enable_http2()
7888/// # .build();
7889///
7890/// # let executor = hyper_util::rt::TokioExecutor::new();
7891/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7892/// # secret,
7893/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7894/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7895/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7896/// # ),
7897/// # ).build().await.unwrap();
7898///
7899/// # let client = hyper_util::client::legacy::Client::builder(
7900/// # hyper_util::rt::TokioExecutor::new()
7901/// # )
7902/// # .build(
7903/// # hyper_rustls::HttpsConnectorBuilder::new()
7904/// # .with_native_roots()
7905/// # .unwrap()
7906/// # .https_or_http()
7907/// # .enable_http2()
7908/// # .build()
7909/// # );
7910/// # let mut hub = ContainerAnalysis::new(client, auth);
7911/// // As the method needs a request, you would usually fill it with the desired information
7912/// // into the respective structure. Some of the parts shown here might not be applicable !
7913/// // Values shown here are possibly random and not representative !
7914/// let mut req = Occurrence::default();
7915///
7916/// // You can configure optional parameters by calling the respective setters at will, and
7917/// // execute the final call using `doit()`.
7918/// // Values shown here are possibly random and not representative !
7919/// let result = hub.projects().locations_occurrences_create(req, "parent")
7920/// .doit().await;
7921/// # }
7922/// ```
7923pub struct ProjectLocationOccurrenceCreateCall<'a, C>
7924where
7925 C: 'a,
7926{
7927 hub: &'a ContainerAnalysis<C>,
7928 _request: Occurrence,
7929 _parent: String,
7930 _delegate: Option<&'a mut dyn common::Delegate>,
7931 _additional_params: HashMap<String, String>,
7932 _scopes: BTreeSet<String>,
7933}
7934
7935impl<'a, C> common::CallBuilder for ProjectLocationOccurrenceCreateCall<'a, C> {}
7936
7937impl<'a, C> ProjectLocationOccurrenceCreateCall<'a, C>
7938where
7939 C: common::Connector,
7940{
7941 /// Perform the operation you have build so far.
7942 pub async fn doit(mut self) -> common::Result<(common::Response, Occurrence)> {
7943 use std::borrow::Cow;
7944 use std::io::{Read, Seek};
7945
7946 use common::{url::Params, ToParts};
7947 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7948
7949 let mut dd = common::DefaultDelegate;
7950 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7951 dlg.begin(common::MethodInfo {
7952 id: "containeranalysis.projects.locations.occurrences.create",
7953 http_method: hyper::Method::POST,
7954 });
7955
7956 for &field in ["alt", "parent"].iter() {
7957 if self._additional_params.contains_key(field) {
7958 dlg.finished(false);
7959 return Err(common::Error::FieldClash(field));
7960 }
7961 }
7962
7963 let mut params = Params::with_capacity(4 + self._additional_params.len());
7964 params.push("parent", self._parent);
7965
7966 params.extend(self._additional_params.iter());
7967
7968 params.push("alt", "json");
7969 let mut url = self.hub._base_url.clone() + "v1/{+parent}/occurrences";
7970 if self._scopes.is_empty() {
7971 self._scopes
7972 .insert(Scope::CloudPlatform.as_ref().to_string());
7973 }
7974
7975 #[allow(clippy::single_element_loop)]
7976 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
7977 url = params.uri_replacement(url, param_name, find_this, true);
7978 }
7979 {
7980 let to_remove = ["parent"];
7981 params.remove_params(&to_remove);
7982 }
7983
7984 let url = params.parse_with_url(&url);
7985
7986 let mut json_mime_type = mime::APPLICATION_JSON;
7987 let mut request_value_reader = {
7988 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7989 common::remove_json_null_values(&mut value);
7990 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7991 serde_json::to_writer(&mut dst, &value).unwrap();
7992 dst
7993 };
7994 let request_size = request_value_reader
7995 .seek(std::io::SeekFrom::End(0))
7996 .unwrap();
7997 request_value_reader
7998 .seek(std::io::SeekFrom::Start(0))
7999 .unwrap();
8000
8001 loop {
8002 let token = match self
8003 .hub
8004 .auth
8005 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8006 .await
8007 {
8008 Ok(token) => token,
8009 Err(e) => match dlg.token(e) {
8010 Ok(token) => token,
8011 Err(e) => {
8012 dlg.finished(false);
8013 return Err(common::Error::MissingToken(e));
8014 }
8015 },
8016 };
8017 request_value_reader
8018 .seek(std::io::SeekFrom::Start(0))
8019 .unwrap();
8020 let mut req_result = {
8021 let client = &self.hub.client;
8022 dlg.pre_request();
8023 let mut req_builder = hyper::Request::builder()
8024 .method(hyper::Method::POST)
8025 .uri(url.as_str())
8026 .header(USER_AGENT, self.hub._user_agent.clone());
8027
8028 if let Some(token) = token.as_ref() {
8029 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8030 }
8031
8032 let request = req_builder
8033 .header(CONTENT_TYPE, json_mime_type.to_string())
8034 .header(CONTENT_LENGTH, request_size as u64)
8035 .body(common::to_body(
8036 request_value_reader.get_ref().clone().into(),
8037 ));
8038
8039 client.request(request.unwrap()).await
8040 };
8041
8042 match req_result {
8043 Err(err) => {
8044 if let common::Retry::After(d) = dlg.http_error(&err) {
8045 sleep(d).await;
8046 continue;
8047 }
8048 dlg.finished(false);
8049 return Err(common::Error::HttpError(err));
8050 }
8051 Ok(res) => {
8052 let (mut parts, body) = res.into_parts();
8053 let mut body = common::Body::new(body);
8054 if !parts.status.is_success() {
8055 let bytes = common::to_bytes(body).await.unwrap_or_default();
8056 let error = serde_json::from_str(&common::to_string(&bytes));
8057 let response = common::to_response(parts, bytes.into());
8058
8059 if let common::Retry::After(d) =
8060 dlg.http_failure(&response, error.as_ref().ok())
8061 {
8062 sleep(d).await;
8063 continue;
8064 }
8065
8066 dlg.finished(false);
8067
8068 return Err(match error {
8069 Ok(value) => common::Error::BadRequest(value),
8070 _ => common::Error::Failure(response),
8071 });
8072 }
8073 let response = {
8074 let bytes = common::to_bytes(body).await.unwrap_or_default();
8075 let encoded = common::to_string(&bytes);
8076 match serde_json::from_str(&encoded) {
8077 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8078 Err(error) => {
8079 dlg.response_json_decode_error(&encoded, &error);
8080 return Err(common::Error::JsonDecodeError(
8081 encoded.to_string(),
8082 error,
8083 ));
8084 }
8085 }
8086 };
8087
8088 dlg.finished(true);
8089 return Ok(response);
8090 }
8091 }
8092 }
8093 }
8094
8095 ///
8096 /// Sets the *request* property to the given value.
8097 ///
8098 /// Even though the property as already been set when instantiating this call,
8099 /// we provide this method for API completeness.
8100 pub fn request(mut self, new_value: Occurrence) -> ProjectLocationOccurrenceCreateCall<'a, C> {
8101 self._request = new_value;
8102 self
8103 }
8104 /// Required. The name of the project in the form of `projects/[PROJECT_ID]`, under which the occurrence is to be created.
8105 ///
8106 /// Sets the *parent* path property to the given value.
8107 ///
8108 /// Even though the property as already been set when instantiating this call,
8109 /// we provide this method for API completeness.
8110 pub fn parent(mut self, new_value: &str) -> ProjectLocationOccurrenceCreateCall<'a, C> {
8111 self._parent = new_value.to_string();
8112 self
8113 }
8114 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8115 /// while executing the actual API request.
8116 ///
8117 /// ````text
8118 /// It should be used to handle progress information, and to implement a certain level of resilience.
8119 /// ````
8120 ///
8121 /// Sets the *delegate* property to the given value.
8122 pub fn delegate(
8123 mut self,
8124 new_value: &'a mut dyn common::Delegate,
8125 ) -> ProjectLocationOccurrenceCreateCall<'a, C> {
8126 self._delegate = Some(new_value);
8127 self
8128 }
8129
8130 /// Set any additional parameter of the query string used in the request.
8131 /// It should be used to set parameters which are not yet available through their own
8132 /// setters.
8133 ///
8134 /// Please note that this method must not be used to set any of the known parameters
8135 /// which have their own setter method. If done anyway, the request will fail.
8136 ///
8137 /// # Additional Parameters
8138 ///
8139 /// * *$.xgafv* (query-string) - V1 error format.
8140 /// * *access_token* (query-string) - OAuth access token.
8141 /// * *alt* (query-string) - Data format for response.
8142 /// * *callback* (query-string) - JSONP
8143 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8144 /// * *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.
8145 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8146 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8147 /// * *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.
8148 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8149 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8150 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOccurrenceCreateCall<'a, C>
8151 where
8152 T: AsRef<str>,
8153 {
8154 self._additional_params
8155 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8156 self
8157 }
8158
8159 /// Identifies the authorization scope for the method you are building.
8160 ///
8161 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8162 /// [`Scope::CloudPlatform`].
8163 ///
8164 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8165 /// tokens for more than one scope.
8166 ///
8167 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8168 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8169 /// sufficient, a read-write scope will do as well.
8170 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOccurrenceCreateCall<'a, C>
8171 where
8172 St: AsRef<str>,
8173 {
8174 self._scopes.insert(String::from(scope.as_ref()));
8175 self
8176 }
8177 /// Identifies the authorization scope(s) for the method you are building.
8178 ///
8179 /// See [`Self::add_scope()`] for details.
8180 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOccurrenceCreateCall<'a, C>
8181 where
8182 I: IntoIterator<Item = St>,
8183 St: AsRef<str>,
8184 {
8185 self._scopes
8186 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8187 self
8188 }
8189
8190 /// Removes all scopes, and no default scope will be used either.
8191 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8192 /// for details).
8193 pub fn clear_scopes(mut self) -> ProjectLocationOccurrenceCreateCall<'a, C> {
8194 self._scopes.clear();
8195 self
8196 }
8197}
8198
8199/// Deletes the specified occurrence. For example, use this method to delete an occurrence when the occurrence is no longer applicable for the given resource.
8200///
8201/// A builder for the *locations.occurrences.delete* method supported by a *project* resource.
8202/// It is not used directly, but through a [`ProjectMethods`] instance.
8203///
8204/// # Example
8205///
8206/// Instantiate a resource method builder
8207///
8208/// ```test_harness,no_run
8209/// # extern crate hyper;
8210/// # extern crate hyper_rustls;
8211/// # extern crate google_containeranalysis1 as containeranalysis1;
8212/// # async fn dox() {
8213/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8214///
8215/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8216/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8217/// # .with_native_roots()
8218/// # .unwrap()
8219/// # .https_only()
8220/// # .enable_http2()
8221/// # .build();
8222///
8223/// # let executor = hyper_util::rt::TokioExecutor::new();
8224/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8225/// # secret,
8226/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8227/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8228/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8229/// # ),
8230/// # ).build().await.unwrap();
8231///
8232/// # let client = hyper_util::client::legacy::Client::builder(
8233/// # hyper_util::rt::TokioExecutor::new()
8234/// # )
8235/// # .build(
8236/// # hyper_rustls::HttpsConnectorBuilder::new()
8237/// # .with_native_roots()
8238/// # .unwrap()
8239/// # .https_or_http()
8240/// # .enable_http2()
8241/// # .build()
8242/// # );
8243/// # let mut hub = ContainerAnalysis::new(client, auth);
8244/// // You can configure optional parameters by calling the respective setters at will, and
8245/// // execute the final call using `doit()`.
8246/// // Values shown here are possibly random and not representative !
8247/// let result = hub.projects().locations_occurrences_delete("name")
8248/// .doit().await;
8249/// # }
8250/// ```
8251pub struct ProjectLocationOccurrenceDeleteCall<'a, C>
8252where
8253 C: 'a,
8254{
8255 hub: &'a ContainerAnalysis<C>,
8256 _name: String,
8257 _delegate: Option<&'a mut dyn common::Delegate>,
8258 _additional_params: HashMap<String, String>,
8259 _scopes: BTreeSet<String>,
8260}
8261
8262impl<'a, C> common::CallBuilder for ProjectLocationOccurrenceDeleteCall<'a, C> {}
8263
8264impl<'a, C> ProjectLocationOccurrenceDeleteCall<'a, C>
8265where
8266 C: common::Connector,
8267{
8268 /// Perform the operation you have build so far.
8269 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
8270 use std::borrow::Cow;
8271 use std::io::{Read, Seek};
8272
8273 use common::{url::Params, ToParts};
8274 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8275
8276 let mut dd = common::DefaultDelegate;
8277 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8278 dlg.begin(common::MethodInfo {
8279 id: "containeranalysis.projects.locations.occurrences.delete",
8280 http_method: hyper::Method::DELETE,
8281 });
8282
8283 for &field in ["alt", "name"].iter() {
8284 if self._additional_params.contains_key(field) {
8285 dlg.finished(false);
8286 return Err(common::Error::FieldClash(field));
8287 }
8288 }
8289
8290 let mut params = Params::with_capacity(3 + self._additional_params.len());
8291 params.push("name", self._name);
8292
8293 params.extend(self._additional_params.iter());
8294
8295 params.push("alt", "json");
8296 let mut url = self.hub._base_url.clone() + "v1/{+name}";
8297 if self._scopes.is_empty() {
8298 self._scopes
8299 .insert(Scope::CloudPlatform.as_ref().to_string());
8300 }
8301
8302 #[allow(clippy::single_element_loop)]
8303 for &(find_this, param_name) in [("{+name}", "name")].iter() {
8304 url = params.uri_replacement(url, param_name, find_this, true);
8305 }
8306 {
8307 let to_remove = ["name"];
8308 params.remove_params(&to_remove);
8309 }
8310
8311 let url = params.parse_with_url(&url);
8312
8313 loop {
8314 let token = match self
8315 .hub
8316 .auth
8317 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8318 .await
8319 {
8320 Ok(token) => token,
8321 Err(e) => match dlg.token(e) {
8322 Ok(token) => token,
8323 Err(e) => {
8324 dlg.finished(false);
8325 return Err(common::Error::MissingToken(e));
8326 }
8327 },
8328 };
8329 let mut req_result = {
8330 let client = &self.hub.client;
8331 dlg.pre_request();
8332 let mut req_builder = hyper::Request::builder()
8333 .method(hyper::Method::DELETE)
8334 .uri(url.as_str())
8335 .header(USER_AGENT, self.hub._user_agent.clone());
8336
8337 if let Some(token) = token.as_ref() {
8338 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8339 }
8340
8341 let request = req_builder
8342 .header(CONTENT_LENGTH, 0_u64)
8343 .body(common::to_body::<String>(None));
8344
8345 client.request(request.unwrap()).await
8346 };
8347
8348 match req_result {
8349 Err(err) => {
8350 if let common::Retry::After(d) = dlg.http_error(&err) {
8351 sleep(d).await;
8352 continue;
8353 }
8354 dlg.finished(false);
8355 return Err(common::Error::HttpError(err));
8356 }
8357 Ok(res) => {
8358 let (mut parts, body) = res.into_parts();
8359 let mut body = common::Body::new(body);
8360 if !parts.status.is_success() {
8361 let bytes = common::to_bytes(body).await.unwrap_or_default();
8362 let error = serde_json::from_str(&common::to_string(&bytes));
8363 let response = common::to_response(parts, bytes.into());
8364
8365 if let common::Retry::After(d) =
8366 dlg.http_failure(&response, error.as_ref().ok())
8367 {
8368 sleep(d).await;
8369 continue;
8370 }
8371
8372 dlg.finished(false);
8373
8374 return Err(match error {
8375 Ok(value) => common::Error::BadRequest(value),
8376 _ => common::Error::Failure(response),
8377 });
8378 }
8379 let response = {
8380 let bytes = common::to_bytes(body).await.unwrap_or_default();
8381 let encoded = common::to_string(&bytes);
8382 match serde_json::from_str(&encoded) {
8383 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8384 Err(error) => {
8385 dlg.response_json_decode_error(&encoded, &error);
8386 return Err(common::Error::JsonDecodeError(
8387 encoded.to_string(),
8388 error,
8389 ));
8390 }
8391 }
8392 };
8393
8394 dlg.finished(true);
8395 return Ok(response);
8396 }
8397 }
8398 }
8399 }
8400
8401 /// Required. The name of the occurrence in the form of `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.
8402 ///
8403 /// Sets the *name* path property to the given value.
8404 ///
8405 /// Even though the property as already been set when instantiating this call,
8406 /// we provide this method for API completeness.
8407 pub fn name(mut self, new_value: &str) -> ProjectLocationOccurrenceDeleteCall<'a, C> {
8408 self._name = new_value.to_string();
8409 self
8410 }
8411 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8412 /// while executing the actual API request.
8413 ///
8414 /// ````text
8415 /// It should be used to handle progress information, and to implement a certain level of resilience.
8416 /// ````
8417 ///
8418 /// Sets the *delegate* property to the given value.
8419 pub fn delegate(
8420 mut self,
8421 new_value: &'a mut dyn common::Delegate,
8422 ) -> ProjectLocationOccurrenceDeleteCall<'a, C> {
8423 self._delegate = Some(new_value);
8424 self
8425 }
8426
8427 /// Set any additional parameter of the query string used in the request.
8428 /// It should be used to set parameters which are not yet available through their own
8429 /// setters.
8430 ///
8431 /// Please note that this method must not be used to set any of the known parameters
8432 /// which have their own setter method. If done anyway, the request will fail.
8433 ///
8434 /// # Additional Parameters
8435 ///
8436 /// * *$.xgafv* (query-string) - V1 error format.
8437 /// * *access_token* (query-string) - OAuth access token.
8438 /// * *alt* (query-string) - Data format for response.
8439 /// * *callback* (query-string) - JSONP
8440 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8441 /// * *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.
8442 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8443 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8444 /// * *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.
8445 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8446 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8447 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOccurrenceDeleteCall<'a, C>
8448 where
8449 T: AsRef<str>,
8450 {
8451 self._additional_params
8452 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8453 self
8454 }
8455
8456 /// Identifies the authorization scope for the method you are building.
8457 ///
8458 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8459 /// [`Scope::CloudPlatform`].
8460 ///
8461 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8462 /// tokens for more than one scope.
8463 ///
8464 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8465 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8466 /// sufficient, a read-write scope will do as well.
8467 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOccurrenceDeleteCall<'a, C>
8468 where
8469 St: AsRef<str>,
8470 {
8471 self._scopes.insert(String::from(scope.as_ref()));
8472 self
8473 }
8474 /// Identifies the authorization scope(s) for the method you are building.
8475 ///
8476 /// See [`Self::add_scope()`] for details.
8477 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOccurrenceDeleteCall<'a, C>
8478 where
8479 I: IntoIterator<Item = St>,
8480 St: AsRef<str>,
8481 {
8482 self._scopes
8483 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8484 self
8485 }
8486
8487 /// Removes all scopes, and no default scope will be used either.
8488 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8489 /// for details).
8490 pub fn clear_scopes(mut self) -> ProjectLocationOccurrenceDeleteCall<'a, C> {
8491 self._scopes.clear();
8492 self
8493 }
8494}
8495
8496/// Gets the specified occurrence.
8497///
8498/// A builder for the *locations.occurrences.get* method supported by a *project* resource.
8499/// It is not used directly, but through a [`ProjectMethods`] instance.
8500///
8501/// # Example
8502///
8503/// Instantiate a resource method builder
8504///
8505/// ```test_harness,no_run
8506/// # extern crate hyper;
8507/// # extern crate hyper_rustls;
8508/// # extern crate google_containeranalysis1 as containeranalysis1;
8509/// # async fn dox() {
8510/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8511///
8512/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8513/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8514/// # .with_native_roots()
8515/// # .unwrap()
8516/// # .https_only()
8517/// # .enable_http2()
8518/// # .build();
8519///
8520/// # let executor = hyper_util::rt::TokioExecutor::new();
8521/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8522/// # secret,
8523/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8524/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8525/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8526/// # ),
8527/// # ).build().await.unwrap();
8528///
8529/// # let client = hyper_util::client::legacy::Client::builder(
8530/// # hyper_util::rt::TokioExecutor::new()
8531/// # )
8532/// # .build(
8533/// # hyper_rustls::HttpsConnectorBuilder::new()
8534/// # .with_native_roots()
8535/// # .unwrap()
8536/// # .https_or_http()
8537/// # .enable_http2()
8538/// # .build()
8539/// # );
8540/// # let mut hub = ContainerAnalysis::new(client, auth);
8541/// // You can configure optional parameters by calling the respective setters at will, and
8542/// // execute the final call using `doit()`.
8543/// // Values shown here are possibly random and not representative !
8544/// let result = hub.projects().locations_occurrences_get("name")
8545/// .doit().await;
8546/// # }
8547/// ```
8548pub struct ProjectLocationOccurrenceGetCall<'a, C>
8549where
8550 C: 'a,
8551{
8552 hub: &'a ContainerAnalysis<C>,
8553 _name: String,
8554 _delegate: Option<&'a mut dyn common::Delegate>,
8555 _additional_params: HashMap<String, String>,
8556 _scopes: BTreeSet<String>,
8557}
8558
8559impl<'a, C> common::CallBuilder for ProjectLocationOccurrenceGetCall<'a, C> {}
8560
8561impl<'a, C> ProjectLocationOccurrenceGetCall<'a, C>
8562where
8563 C: common::Connector,
8564{
8565 /// Perform the operation you have build so far.
8566 pub async fn doit(mut self) -> common::Result<(common::Response, Occurrence)> {
8567 use std::borrow::Cow;
8568 use std::io::{Read, Seek};
8569
8570 use common::{url::Params, ToParts};
8571 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8572
8573 let mut dd = common::DefaultDelegate;
8574 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8575 dlg.begin(common::MethodInfo {
8576 id: "containeranalysis.projects.locations.occurrences.get",
8577 http_method: hyper::Method::GET,
8578 });
8579
8580 for &field in ["alt", "name"].iter() {
8581 if self._additional_params.contains_key(field) {
8582 dlg.finished(false);
8583 return Err(common::Error::FieldClash(field));
8584 }
8585 }
8586
8587 let mut params = Params::with_capacity(3 + self._additional_params.len());
8588 params.push("name", self._name);
8589
8590 params.extend(self._additional_params.iter());
8591
8592 params.push("alt", "json");
8593 let mut url = self.hub._base_url.clone() + "v1/{+name}";
8594 if self._scopes.is_empty() {
8595 self._scopes
8596 .insert(Scope::CloudPlatform.as_ref().to_string());
8597 }
8598
8599 #[allow(clippy::single_element_loop)]
8600 for &(find_this, param_name) in [("{+name}", "name")].iter() {
8601 url = params.uri_replacement(url, param_name, find_this, true);
8602 }
8603 {
8604 let to_remove = ["name"];
8605 params.remove_params(&to_remove);
8606 }
8607
8608 let url = params.parse_with_url(&url);
8609
8610 loop {
8611 let token = match self
8612 .hub
8613 .auth
8614 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8615 .await
8616 {
8617 Ok(token) => token,
8618 Err(e) => match dlg.token(e) {
8619 Ok(token) => token,
8620 Err(e) => {
8621 dlg.finished(false);
8622 return Err(common::Error::MissingToken(e));
8623 }
8624 },
8625 };
8626 let mut req_result = {
8627 let client = &self.hub.client;
8628 dlg.pre_request();
8629 let mut req_builder = hyper::Request::builder()
8630 .method(hyper::Method::GET)
8631 .uri(url.as_str())
8632 .header(USER_AGENT, self.hub._user_agent.clone());
8633
8634 if let Some(token) = token.as_ref() {
8635 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8636 }
8637
8638 let request = req_builder
8639 .header(CONTENT_LENGTH, 0_u64)
8640 .body(common::to_body::<String>(None));
8641
8642 client.request(request.unwrap()).await
8643 };
8644
8645 match req_result {
8646 Err(err) => {
8647 if let common::Retry::After(d) = dlg.http_error(&err) {
8648 sleep(d).await;
8649 continue;
8650 }
8651 dlg.finished(false);
8652 return Err(common::Error::HttpError(err));
8653 }
8654 Ok(res) => {
8655 let (mut parts, body) = res.into_parts();
8656 let mut body = common::Body::new(body);
8657 if !parts.status.is_success() {
8658 let bytes = common::to_bytes(body).await.unwrap_or_default();
8659 let error = serde_json::from_str(&common::to_string(&bytes));
8660 let response = common::to_response(parts, bytes.into());
8661
8662 if let common::Retry::After(d) =
8663 dlg.http_failure(&response, error.as_ref().ok())
8664 {
8665 sleep(d).await;
8666 continue;
8667 }
8668
8669 dlg.finished(false);
8670
8671 return Err(match error {
8672 Ok(value) => common::Error::BadRequest(value),
8673 _ => common::Error::Failure(response),
8674 });
8675 }
8676 let response = {
8677 let bytes = common::to_bytes(body).await.unwrap_or_default();
8678 let encoded = common::to_string(&bytes);
8679 match serde_json::from_str(&encoded) {
8680 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8681 Err(error) => {
8682 dlg.response_json_decode_error(&encoded, &error);
8683 return Err(common::Error::JsonDecodeError(
8684 encoded.to_string(),
8685 error,
8686 ));
8687 }
8688 }
8689 };
8690
8691 dlg.finished(true);
8692 return Ok(response);
8693 }
8694 }
8695 }
8696 }
8697
8698 /// Required. The name of the occurrence in the form of `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.
8699 ///
8700 /// Sets the *name* path property to the given value.
8701 ///
8702 /// Even though the property as already been set when instantiating this call,
8703 /// we provide this method for API completeness.
8704 pub fn name(mut self, new_value: &str) -> ProjectLocationOccurrenceGetCall<'a, C> {
8705 self._name = new_value.to_string();
8706 self
8707 }
8708 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8709 /// while executing the actual API request.
8710 ///
8711 /// ````text
8712 /// It should be used to handle progress information, and to implement a certain level of resilience.
8713 /// ````
8714 ///
8715 /// Sets the *delegate* property to the given value.
8716 pub fn delegate(
8717 mut self,
8718 new_value: &'a mut dyn common::Delegate,
8719 ) -> ProjectLocationOccurrenceGetCall<'a, C> {
8720 self._delegate = Some(new_value);
8721 self
8722 }
8723
8724 /// Set any additional parameter of the query string used in the request.
8725 /// It should be used to set parameters which are not yet available through their own
8726 /// setters.
8727 ///
8728 /// Please note that this method must not be used to set any of the known parameters
8729 /// which have their own setter method. If done anyway, the request will fail.
8730 ///
8731 /// # Additional Parameters
8732 ///
8733 /// * *$.xgafv* (query-string) - V1 error format.
8734 /// * *access_token* (query-string) - OAuth access token.
8735 /// * *alt* (query-string) - Data format for response.
8736 /// * *callback* (query-string) - JSONP
8737 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8738 /// * *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.
8739 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8740 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8741 /// * *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.
8742 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8743 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8744 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOccurrenceGetCall<'a, C>
8745 where
8746 T: AsRef<str>,
8747 {
8748 self._additional_params
8749 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8750 self
8751 }
8752
8753 /// Identifies the authorization scope for the method you are building.
8754 ///
8755 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8756 /// [`Scope::CloudPlatform`].
8757 ///
8758 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8759 /// tokens for more than one scope.
8760 ///
8761 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8762 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8763 /// sufficient, a read-write scope will do as well.
8764 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOccurrenceGetCall<'a, C>
8765 where
8766 St: AsRef<str>,
8767 {
8768 self._scopes.insert(String::from(scope.as_ref()));
8769 self
8770 }
8771 /// Identifies the authorization scope(s) for the method you are building.
8772 ///
8773 /// See [`Self::add_scope()`] for details.
8774 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOccurrenceGetCall<'a, C>
8775 where
8776 I: IntoIterator<Item = St>,
8777 St: AsRef<str>,
8778 {
8779 self._scopes
8780 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8781 self
8782 }
8783
8784 /// Removes all scopes, and no default scope will be used either.
8785 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8786 /// for details).
8787 pub fn clear_scopes(mut self) -> ProjectLocationOccurrenceGetCall<'a, C> {
8788 self._scopes.clear();
8789 self
8790 }
8791}
8792
8793/// 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.
8794///
8795/// A builder for the *locations.occurrences.getIamPolicy* method supported by a *project* resource.
8796/// It is not used directly, but through a [`ProjectMethods`] instance.
8797///
8798/// # Example
8799///
8800/// Instantiate a resource method builder
8801///
8802/// ```test_harness,no_run
8803/// # extern crate hyper;
8804/// # extern crate hyper_rustls;
8805/// # extern crate google_containeranalysis1 as containeranalysis1;
8806/// use containeranalysis1::api::GetIamPolicyRequest;
8807/// # async fn dox() {
8808/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8809///
8810/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8811/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8812/// # .with_native_roots()
8813/// # .unwrap()
8814/// # .https_only()
8815/// # .enable_http2()
8816/// # .build();
8817///
8818/// # let executor = hyper_util::rt::TokioExecutor::new();
8819/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8820/// # secret,
8821/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8822/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8823/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8824/// # ),
8825/// # ).build().await.unwrap();
8826///
8827/// # let client = hyper_util::client::legacy::Client::builder(
8828/// # hyper_util::rt::TokioExecutor::new()
8829/// # )
8830/// # .build(
8831/// # hyper_rustls::HttpsConnectorBuilder::new()
8832/// # .with_native_roots()
8833/// # .unwrap()
8834/// # .https_or_http()
8835/// # .enable_http2()
8836/// # .build()
8837/// # );
8838/// # let mut hub = ContainerAnalysis::new(client, auth);
8839/// // As the method needs a request, you would usually fill it with the desired information
8840/// // into the respective structure. Some of the parts shown here might not be applicable !
8841/// // Values shown here are possibly random and not representative !
8842/// let mut req = GetIamPolicyRequest::default();
8843///
8844/// // You can configure optional parameters by calling the respective setters at will, and
8845/// // execute the final call using `doit()`.
8846/// // Values shown here are possibly random and not representative !
8847/// let result = hub.projects().locations_occurrences_get_iam_policy(req, "resource")
8848/// .doit().await;
8849/// # }
8850/// ```
8851pub struct ProjectLocationOccurrenceGetIamPolicyCall<'a, C>
8852where
8853 C: 'a,
8854{
8855 hub: &'a ContainerAnalysis<C>,
8856 _request: GetIamPolicyRequest,
8857 _resource: String,
8858 _delegate: Option<&'a mut dyn common::Delegate>,
8859 _additional_params: HashMap<String, String>,
8860 _scopes: BTreeSet<String>,
8861}
8862
8863impl<'a, C> common::CallBuilder for ProjectLocationOccurrenceGetIamPolicyCall<'a, C> {}
8864
8865impl<'a, C> ProjectLocationOccurrenceGetIamPolicyCall<'a, C>
8866where
8867 C: common::Connector,
8868{
8869 /// Perform the operation you have build so far.
8870 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
8871 use std::borrow::Cow;
8872 use std::io::{Read, Seek};
8873
8874 use common::{url::Params, ToParts};
8875 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8876
8877 let mut dd = common::DefaultDelegate;
8878 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8879 dlg.begin(common::MethodInfo {
8880 id: "containeranalysis.projects.locations.occurrences.getIamPolicy",
8881 http_method: hyper::Method::POST,
8882 });
8883
8884 for &field in ["alt", "resource"].iter() {
8885 if self._additional_params.contains_key(field) {
8886 dlg.finished(false);
8887 return Err(common::Error::FieldClash(field));
8888 }
8889 }
8890
8891 let mut params = Params::with_capacity(4 + self._additional_params.len());
8892 params.push("resource", self._resource);
8893
8894 params.extend(self._additional_params.iter());
8895
8896 params.push("alt", "json");
8897 let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
8898 if self._scopes.is_empty() {
8899 self._scopes
8900 .insert(Scope::CloudPlatform.as_ref().to_string());
8901 }
8902
8903 #[allow(clippy::single_element_loop)]
8904 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
8905 url = params.uri_replacement(url, param_name, find_this, true);
8906 }
8907 {
8908 let to_remove = ["resource"];
8909 params.remove_params(&to_remove);
8910 }
8911
8912 let url = params.parse_with_url(&url);
8913
8914 let mut json_mime_type = mime::APPLICATION_JSON;
8915 let mut request_value_reader = {
8916 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8917 common::remove_json_null_values(&mut value);
8918 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8919 serde_json::to_writer(&mut dst, &value).unwrap();
8920 dst
8921 };
8922 let request_size = request_value_reader
8923 .seek(std::io::SeekFrom::End(0))
8924 .unwrap();
8925 request_value_reader
8926 .seek(std::io::SeekFrom::Start(0))
8927 .unwrap();
8928
8929 loop {
8930 let token = match self
8931 .hub
8932 .auth
8933 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8934 .await
8935 {
8936 Ok(token) => token,
8937 Err(e) => match dlg.token(e) {
8938 Ok(token) => token,
8939 Err(e) => {
8940 dlg.finished(false);
8941 return Err(common::Error::MissingToken(e));
8942 }
8943 },
8944 };
8945 request_value_reader
8946 .seek(std::io::SeekFrom::Start(0))
8947 .unwrap();
8948 let mut req_result = {
8949 let client = &self.hub.client;
8950 dlg.pre_request();
8951 let mut req_builder = hyper::Request::builder()
8952 .method(hyper::Method::POST)
8953 .uri(url.as_str())
8954 .header(USER_AGENT, self.hub._user_agent.clone());
8955
8956 if let Some(token) = token.as_ref() {
8957 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8958 }
8959
8960 let request = req_builder
8961 .header(CONTENT_TYPE, json_mime_type.to_string())
8962 .header(CONTENT_LENGTH, request_size as u64)
8963 .body(common::to_body(
8964 request_value_reader.get_ref().clone().into(),
8965 ));
8966
8967 client.request(request.unwrap()).await
8968 };
8969
8970 match req_result {
8971 Err(err) => {
8972 if let common::Retry::After(d) = dlg.http_error(&err) {
8973 sleep(d).await;
8974 continue;
8975 }
8976 dlg.finished(false);
8977 return Err(common::Error::HttpError(err));
8978 }
8979 Ok(res) => {
8980 let (mut parts, body) = res.into_parts();
8981 let mut body = common::Body::new(body);
8982 if !parts.status.is_success() {
8983 let bytes = common::to_bytes(body).await.unwrap_or_default();
8984 let error = serde_json::from_str(&common::to_string(&bytes));
8985 let response = common::to_response(parts, bytes.into());
8986
8987 if let common::Retry::After(d) =
8988 dlg.http_failure(&response, error.as_ref().ok())
8989 {
8990 sleep(d).await;
8991 continue;
8992 }
8993
8994 dlg.finished(false);
8995
8996 return Err(match error {
8997 Ok(value) => common::Error::BadRequest(value),
8998 _ => common::Error::Failure(response),
8999 });
9000 }
9001 let response = {
9002 let bytes = common::to_bytes(body).await.unwrap_or_default();
9003 let encoded = common::to_string(&bytes);
9004 match serde_json::from_str(&encoded) {
9005 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9006 Err(error) => {
9007 dlg.response_json_decode_error(&encoded, &error);
9008 return Err(common::Error::JsonDecodeError(
9009 encoded.to_string(),
9010 error,
9011 ));
9012 }
9013 }
9014 };
9015
9016 dlg.finished(true);
9017 return Ok(response);
9018 }
9019 }
9020 }
9021 }
9022
9023 ///
9024 /// Sets the *request* property to the given value.
9025 ///
9026 /// Even though the property as already been set when instantiating this call,
9027 /// we provide this method for API completeness.
9028 pub fn request(
9029 mut self,
9030 new_value: GetIamPolicyRequest,
9031 ) -> ProjectLocationOccurrenceGetIamPolicyCall<'a, C> {
9032 self._request = new_value;
9033 self
9034 }
9035 /// 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.
9036 ///
9037 /// Sets the *resource* path property to the given value.
9038 ///
9039 /// Even though the property as already been set when instantiating this call,
9040 /// we provide this method for API completeness.
9041 pub fn resource(mut self, new_value: &str) -> ProjectLocationOccurrenceGetIamPolicyCall<'a, C> {
9042 self._resource = new_value.to_string();
9043 self
9044 }
9045 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9046 /// while executing the actual API request.
9047 ///
9048 /// ````text
9049 /// It should be used to handle progress information, and to implement a certain level of resilience.
9050 /// ````
9051 ///
9052 /// Sets the *delegate* property to the given value.
9053 pub fn delegate(
9054 mut self,
9055 new_value: &'a mut dyn common::Delegate,
9056 ) -> ProjectLocationOccurrenceGetIamPolicyCall<'a, C> {
9057 self._delegate = Some(new_value);
9058 self
9059 }
9060
9061 /// Set any additional parameter of the query string used in the request.
9062 /// It should be used to set parameters which are not yet available through their own
9063 /// setters.
9064 ///
9065 /// Please note that this method must not be used to set any of the known parameters
9066 /// which have their own setter method. If done anyway, the request will fail.
9067 ///
9068 /// # Additional Parameters
9069 ///
9070 /// * *$.xgafv* (query-string) - V1 error format.
9071 /// * *access_token* (query-string) - OAuth access token.
9072 /// * *alt* (query-string) - Data format for response.
9073 /// * *callback* (query-string) - JSONP
9074 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9075 /// * *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.
9076 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9077 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9078 /// * *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.
9079 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9080 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9081 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOccurrenceGetIamPolicyCall<'a, C>
9082 where
9083 T: AsRef<str>,
9084 {
9085 self._additional_params
9086 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9087 self
9088 }
9089
9090 /// Identifies the authorization scope for the method you are building.
9091 ///
9092 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9093 /// [`Scope::CloudPlatform`].
9094 ///
9095 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9096 /// tokens for more than one scope.
9097 ///
9098 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9099 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9100 /// sufficient, a read-write scope will do as well.
9101 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOccurrenceGetIamPolicyCall<'a, C>
9102 where
9103 St: AsRef<str>,
9104 {
9105 self._scopes.insert(String::from(scope.as_ref()));
9106 self
9107 }
9108 /// Identifies the authorization scope(s) for the method you are building.
9109 ///
9110 /// See [`Self::add_scope()`] for details.
9111 pub fn add_scopes<I, St>(
9112 mut self,
9113 scopes: I,
9114 ) -> ProjectLocationOccurrenceGetIamPolicyCall<'a, C>
9115 where
9116 I: IntoIterator<Item = St>,
9117 St: AsRef<str>,
9118 {
9119 self._scopes
9120 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9121 self
9122 }
9123
9124 /// Removes all scopes, and no default scope will be used either.
9125 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9126 /// for details).
9127 pub fn clear_scopes(mut self) -> ProjectLocationOccurrenceGetIamPolicyCall<'a, C> {
9128 self._scopes.clear();
9129 self
9130 }
9131}
9132
9133/// Gets the note attached to the specified occurrence. Consumer projects can use this method to get a note that belongs to a provider project.
9134///
9135/// A builder for the *locations.occurrences.getNotes* method supported by a *project* resource.
9136/// It is not used directly, but through a [`ProjectMethods`] instance.
9137///
9138/// # Example
9139///
9140/// Instantiate a resource method builder
9141///
9142/// ```test_harness,no_run
9143/// # extern crate hyper;
9144/// # extern crate hyper_rustls;
9145/// # extern crate google_containeranalysis1 as containeranalysis1;
9146/// # async fn dox() {
9147/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9148///
9149/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9150/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9151/// # .with_native_roots()
9152/// # .unwrap()
9153/// # .https_only()
9154/// # .enable_http2()
9155/// # .build();
9156///
9157/// # let executor = hyper_util::rt::TokioExecutor::new();
9158/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9159/// # secret,
9160/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9161/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9162/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9163/// # ),
9164/// # ).build().await.unwrap();
9165///
9166/// # let client = hyper_util::client::legacy::Client::builder(
9167/// # hyper_util::rt::TokioExecutor::new()
9168/// # )
9169/// # .build(
9170/// # hyper_rustls::HttpsConnectorBuilder::new()
9171/// # .with_native_roots()
9172/// # .unwrap()
9173/// # .https_or_http()
9174/// # .enable_http2()
9175/// # .build()
9176/// # );
9177/// # let mut hub = ContainerAnalysis::new(client, auth);
9178/// // You can configure optional parameters by calling the respective setters at will, and
9179/// // execute the final call using `doit()`.
9180/// // Values shown here are possibly random and not representative !
9181/// let result = hub.projects().locations_occurrences_get_notes("name")
9182/// .doit().await;
9183/// # }
9184/// ```
9185pub struct ProjectLocationOccurrenceGetNoteCall<'a, C>
9186where
9187 C: 'a,
9188{
9189 hub: &'a ContainerAnalysis<C>,
9190 _name: String,
9191 _delegate: Option<&'a mut dyn common::Delegate>,
9192 _additional_params: HashMap<String, String>,
9193 _scopes: BTreeSet<String>,
9194}
9195
9196impl<'a, C> common::CallBuilder for ProjectLocationOccurrenceGetNoteCall<'a, C> {}
9197
9198impl<'a, C> ProjectLocationOccurrenceGetNoteCall<'a, C>
9199where
9200 C: common::Connector,
9201{
9202 /// Perform the operation you have build so far.
9203 pub async fn doit(mut self) -> common::Result<(common::Response, Note)> {
9204 use std::borrow::Cow;
9205 use std::io::{Read, Seek};
9206
9207 use common::{url::Params, ToParts};
9208 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9209
9210 let mut dd = common::DefaultDelegate;
9211 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9212 dlg.begin(common::MethodInfo {
9213 id: "containeranalysis.projects.locations.occurrences.getNotes",
9214 http_method: hyper::Method::GET,
9215 });
9216
9217 for &field in ["alt", "name"].iter() {
9218 if self._additional_params.contains_key(field) {
9219 dlg.finished(false);
9220 return Err(common::Error::FieldClash(field));
9221 }
9222 }
9223
9224 let mut params = Params::with_capacity(3 + self._additional_params.len());
9225 params.push("name", self._name);
9226
9227 params.extend(self._additional_params.iter());
9228
9229 params.push("alt", "json");
9230 let mut url = self.hub._base_url.clone() + "v1/{+name}/notes";
9231 if self._scopes.is_empty() {
9232 self._scopes
9233 .insert(Scope::CloudPlatform.as_ref().to_string());
9234 }
9235
9236 #[allow(clippy::single_element_loop)]
9237 for &(find_this, param_name) in [("{+name}", "name")].iter() {
9238 url = params.uri_replacement(url, param_name, find_this, true);
9239 }
9240 {
9241 let to_remove = ["name"];
9242 params.remove_params(&to_remove);
9243 }
9244
9245 let url = params.parse_with_url(&url);
9246
9247 loop {
9248 let token = match self
9249 .hub
9250 .auth
9251 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9252 .await
9253 {
9254 Ok(token) => token,
9255 Err(e) => match dlg.token(e) {
9256 Ok(token) => token,
9257 Err(e) => {
9258 dlg.finished(false);
9259 return Err(common::Error::MissingToken(e));
9260 }
9261 },
9262 };
9263 let mut req_result = {
9264 let client = &self.hub.client;
9265 dlg.pre_request();
9266 let mut req_builder = hyper::Request::builder()
9267 .method(hyper::Method::GET)
9268 .uri(url.as_str())
9269 .header(USER_AGENT, self.hub._user_agent.clone());
9270
9271 if let Some(token) = token.as_ref() {
9272 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9273 }
9274
9275 let request = req_builder
9276 .header(CONTENT_LENGTH, 0_u64)
9277 .body(common::to_body::<String>(None));
9278
9279 client.request(request.unwrap()).await
9280 };
9281
9282 match req_result {
9283 Err(err) => {
9284 if let common::Retry::After(d) = dlg.http_error(&err) {
9285 sleep(d).await;
9286 continue;
9287 }
9288 dlg.finished(false);
9289 return Err(common::Error::HttpError(err));
9290 }
9291 Ok(res) => {
9292 let (mut parts, body) = res.into_parts();
9293 let mut body = common::Body::new(body);
9294 if !parts.status.is_success() {
9295 let bytes = common::to_bytes(body).await.unwrap_or_default();
9296 let error = serde_json::from_str(&common::to_string(&bytes));
9297 let response = common::to_response(parts, bytes.into());
9298
9299 if let common::Retry::After(d) =
9300 dlg.http_failure(&response, error.as_ref().ok())
9301 {
9302 sleep(d).await;
9303 continue;
9304 }
9305
9306 dlg.finished(false);
9307
9308 return Err(match error {
9309 Ok(value) => common::Error::BadRequest(value),
9310 _ => common::Error::Failure(response),
9311 });
9312 }
9313 let response = {
9314 let bytes = common::to_bytes(body).await.unwrap_or_default();
9315 let encoded = common::to_string(&bytes);
9316 match serde_json::from_str(&encoded) {
9317 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9318 Err(error) => {
9319 dlg.response_json_decode_error(&encoded, &error);
9320 return Err(common::Error::JsonDecodeError(
9321 encoded.to_string(),
9322 error,
9323 ));
9324 }
9325 }
9326 };
9327
9328 dlg.finished(true);
9329 return Ok(response);
9330 }
9331 }
9332 }
9333 }
9334
9335 /// Required. The name of the occurrence in the form of `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.
9336 ///
9337 /// Sets the *name* path property to the given value.
9338 ///
9339 /// Even though the property as already been set when instantiating this call,
9340 /// we provide this method for API completeness.
9341 pub fn name(mut self, new_value: &str) -> ProjectLocationOccurrenceGetNoteCall<'a, C> {
9342 self._name = new_value.to_string();
9343 self
9344 }
9345 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9346 /// while executing the actual API request.
9347 ///
9348 /// ````text
9349 /// It should be used to handle progress information, and to implement a certain level of resilience.
9350 /// ````
9351 ///
9352 /// Sets the *delegate* property to the given value.
9353 pub fn delegate(
9354 mut self,
9355 new_value: &'a mut dyn common::Delegate,
9356 ) -> ProjectLocationOccurrenceGetNoteCall<'a, C> {
9357 self._delegate = Some(new_value);
9358 self
9359 }
9360
9361 /// Set any additional parameter of the query string used in the request.
9362 /// It should be used to set parameters which are not yet available through their own
9363 /// setters.
9364 ///
9365 /// Please note that this method must not be used to set any of the known parameters
9366 /// which have their own setter method. If done anyway, the request will fail.
9367 ///
9368 /// # Additional Parameters
9369 ///
9370 /// * *$.xgafv* (query-string) - V1 error format.
9371 /// * *access_token* (query-string) - OAuth access token.
9372 /// * *alt* (query-string) - Data format for response.
9373 /// * *callback* (query-string) - JSONP
9374 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9375 /// * *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.
9376 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9377 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9378 /// * *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.
9379 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9380 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9381 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOccurrenceGetNoteCall<'a, C>
9382 where
9383 T: AsRef<str>,
9384 {
9385 self._additional_params
9386 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9387 self
9388 }
9389
9390 /// Identifies the authorization scope for the method you are building.
9391 ///
9392 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9393 /// [`Scope::CloudPlatform`].
9394 ///
9395 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9396 /// tokens for more than one scope.
9397 ///
9398 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9399 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9400 /// sufficient, a read-write scope will do as well.
9401 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOccurrenceGetNoteCall<'a, C>
9402 where
9403 St: AsRef<str>,
9404 {
9405 self._scopes.insert(String::from(scope.as_ref()));
9406 self
9407 }
9408 /// Identifies the authorization scope(s) for the method you are building.
9409 ///
9410 /// See [`Self::add_scope()`] for details.
9411 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOccurrenceGetNoteCall<'a, C>
9412 where
9413 I: IntoIterator<Item = St>,
9414 St: AsRef<str>,
9415 {
9416 self._scopes
9417 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9418 self
9419 }
9420
9421 /// Removes all scopes, and no default scope will be used either.
9422 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9423 /// for details).
9424 pub fn clear_scopes(mut self) -> ProjectLocationOccurrenceGetNoteCall<'a, C> {
9425 self._scopes.clear();
9426 self
9427 }
9428}
9429
9430/// Gets a summary of the number and severity of occurrences.
9431///
9432/// A builder for the *locations.occurrences.getVulnerabilitySummary* method supported by a *project* resource.
9433/// It is not used directly, but through a [`ProjectMethods`] instance.
9434///
9435/// # Example
9436///
9437/// Instantiate a resource method builder
9438///
9439/// ```test_harness,no_run
9440/// # extern crate hyper;
9441/// # extern crate hyper_rustls;
9442/// # extern crate google_containeranalysis1 as containeranalysis1;
9443/// # async fn dox() {
9444/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9445///
9446/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9447/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9448/// # .with_native_roots()
9449/// # .unwrap()
9450/// # .https_only()
9451/// # .enable_http2()
9452/// # .build();
9453///
9454/// # let executor = hyper_util::rt::TokioExecutor::new();
9455/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9456/// # secret,
9457/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9458/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9459/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9460/// # ),
9461/// # ).build().await.unwrap();
9462///
9463/// # let client = hyper_util::client::legacy::Client::builder(
9464/// # hyper_util::rt::TokioExecutor::new()
9465/// # )
9466/// # .build(
9467/// # hyper_rustls::HttpsConnectorBuilder::new()
9468/// # .with_native_roots()
9469/// # .unwrap()
9470/// # .https_or_http()
9471/// # .enable_http2()
9472/// # .build()
9473/// # );
9474/// # let mut hub = ContainerAnalysis::new(client, auth);
9475/// // You can configure optional parameters by calling the respective setters at will, and
9476/// // execute the final call using `doit()`.
9477/// // Values shown here are possibly random and not representative !
9478/// let result = hub.projects().locations_occurrences_get_vulnerability_summary("parent")
9479/// .return_partial_success(false)
9480/// .filter("Lorem")
9481/// .doit().await;
9482/// # }
9483/// ```
9484pub struct ProjectLocationOccurrenceGetVulnerabilitySummaryCall<'a, C>
9485where
9486 C: 'a,
9487{
9488 hub: &'a ContainerAnalysis<C>,
9489 _parent: String,
9490 _return_partial_success: Option<bool>,
9491 _filter: Option<String>,
9492 _delegate: Option<&'a mut dyn common::Delegate>,
9493 _additional_params: HashMap<String, String>,
9494 _scopes: BTreeSet<String>,
9495}
9496
9497impl<'a, C> common::CallBuilder for ProjectLocationOccurrenceGetVulnerabilitySummaryCall<'a, C> {}
9498
9499impl<'a, C> ProjectLocationOccurrenceGetVulnerabilitySummaryCall<'a, C>
9500where
9501 C: common::Connector,
9502{
9503 /// Perform the operation you have build so far.
9504 pub async fn doit(
9505 mut self,
9506 ) -> common::Result<(common::Response, VulnerabilityOccurrencesSummary)> {
9507 use std::borrow::Cow;
9508 use std::io::{Read, Seek};
9509
9510 use common::{url::Params, ToParts};
9511 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9512
9513 let mut dd = common::DefaultDelegate;
9514 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9515 dlg.begin(common::MethodInfo {
9516 id: "containeranalysis.projects.locations.occurrences.getVulnerabilitySummary",
9517 http_method: hyper::Method::GET,
9518 });
9519
9520 for &field in ["alt", "parent", "returnPartialSuccess", "filter"].iter() {
9521 if self._additional_params.contains_key(field) {
9522 dlg.finished(false);
9523 return Err(common::Error::FieldClash(field));
9524 }
9525 }
9526
9527 let mut params = Params::with_capacity(5 + self._additional_params.len());
9528 params.push("parent", self._parent);
9529 if let Some(value) = self._return_partial_success.as_ref() {
9530 params.push("returnPartialSuccess", value.to_string());
9531 }
9532 if let Some(value) = self._filter.as_ref() {
9533 params.push("filter", value);
9534 }
9535
9536 params.extend(self._additional_params.iter());
9537
9538 params.push("alt", "json");
9539 let mut url = self.hub._base_url.clone() + "v1/{+parent}/occurrences:vulnerabilitySummary";
9540 if self._scopes.is_empty() {
9541 self._scopes
9542 .insert(Scope::CloudPlatform.as_ref().to_string());
9543 }
9544
9545 #[allow(clippy::single_element_loop)]
9546 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
9547 url = params.uri_replacement(url, param_name, find_this, true);
9548 }
9549 {
9550 let to_remove = ["parent"];
9551 params.remove_params(&to_remove);
9552 }
9553
9554 let url = params.parse_with_url(&url);
9555
9556 loop {
9557 let token = match self
9558 .hub
9559 .auth
9560 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9561 .await
9562 {
9563 Ok(token) => token,
9564 Err(e) => match dlg.token(e) {
9565 Ok(token) => token,
9566 Err(e) => {
9567 dlg.finished(false);
9568 return Err(common::Error::MissingToken(e));
9569 }
9570 },
9571 };
9572 let mut req_result = {
9573 let client = &self.hub.client;
9574 dlg.pre_request();
9575 let mut req_builder = hyper::Request::builder()
9576 .method(hyper::Method::GET)
9577 .uri(url.as_str())
9578 .header(USER_AGENT, self.hub._user_agent.clone());
9579
9580 if let Some(token) = token.as_ref() {
9581 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9582 }
9583
9584 let request = req_builder
9585 .header(CONTENT_LENGTH, 0_u64)
9586 .body(common::to_body::<String>(None));
9587
9588 client.request(request.unwrap()).await
9589 };
9590
9591 match req_result {
9592 Err(err) => {
9593 if let common::Retry::After(d) = dlg.http_error(&err) {
9594 sleep(d).await;
9595 continue;
9596 }
9597 dlg.finished(false);
9598 return Err(common::Error::HttpError(err));
9599 }
9600 Ok(res) => {
9601 let (mut parts, body) = res.into_parts();
9602 let mut body = common::Body::new(body);
9603 if !parts.status.is_success() {
9604 let bytes = common::to_bytes(body).await.unwrap_or_default();
9605 let error = serde_json::from_str(&common::to_string(&bytes));
9606 let response = common::to_response(parts, bytes.into());
9607
9608 if let common::Retry::After(d) =
9609 dlg.http_failure(&response, error.as_ref().ok())
9610 {
9611 sleep(d).await;
9612 continue;
9613 }
9614
9615 dlg.finished(false);
9616
9617 return Err(match error {
9618 Ok(value) => common::Error::BadRequest(value),
9619 _ => common::Error::Failure(response),
9620 });
9621 }
9622 let response = {
9623 let bytes = common::to_bytes(body).await.unwrap_or_default();
9624 let encoded = common::to_string(&bytes);
9625 match serde_json::from_str(&encoded) {
9626 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9627 Err(error) => {
9628 dlg.response_json_decode_error(&encoded, &error);
9629 return Err(common::Error::JsonDecodeError(
9630 encoded.to_string(),
9631 error,
9632 ));
9633 }
9634 }
9635 };
9636
9637 dlg.finished(true);
9638 return Ok(response);
9639 }
9640 }
9641 }
9642 }
9643
9644 /// Required. The name of the project to get a vulnerability summary for in the form of `projects/[PROJECT_ID]`.
9645 ///
9646 /// Sets the *parent* path property to the given value.
9647 ///
9648 /// Even though the property as already been set when instantiating this call,
9649 /// we provide this method for API completeness.
9650 pub fn parent(
9651 mut self,
9652 new_value: &str,
9653 ) -> ProjectLocationOccurrenceGetVulnerabilitySummaryCall<'a, C> {
9654 self._parent = new_value.to_string();
9655 self
9656 }
9657 /// If set, the request will return all reachable occurrence summaries and report all unreachable regions in the `unreachable` field in the response. Only applicable for requests in the global region.
9658 ///
9659 /// Sets the *return partial success* query property to the given value.
9660 pub fn return_partial_success(
9661 mut self,
9662 new_value: bool,
9663 ) -> ProjectLocationOccurrenceGetVulnerabilitySummaryCall<'a, C> {
9664 self._return_partial_success = Some(new_value);
9665 self
9666 }
9667 /// The filter expression.
9668 ///
9669 /// Sets the *filter* query property to the given value.
9670 pub fn filter(
9671 mut self,
9672 new_value: &str,
9673 ) -> ProjectLocationOccurrenceGetVulnerabilitySummaryCall<'a, C> {
9674 self._filter = Some(new_value.to_string());
9675 self
9676 }
9677 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9678 /// while executing the actual API request.
9679 ///
9680 /// ````text
9681 /// It should be used to handle progress information, and to implement a certain level of resilience.
9682 /// ````
9683 ///
9684 /// Sets the *delegate* property to the given value.
9685 pub fn delegate(
9686 mut self,
9687 new_value: &'a mut dyn common::Delegate,
9688 ) -> ProjectLocationOccurrenceGetVulnerabilitySummaryCall<'a, C> {
9689 self._delegate = Some(new_value);
9690 self
9691 }
9692
9693 /// Set any additional parameter of the query string used in the request.
9694 /// It should be used to set parameters which are not yet available through their own
9695 /// setters.
9696 ///
9697 /// Please note that this method must not be used to set any of the known parameters
9698 /// which have their own setter method. If done anyway, the request will fail.
9699 ///
9700 /// # Additional Parameters
9701 ///
9702 /// * *$.xgafv* (query-string) - V1 error format.
9703 /// * *access_token* (query-string) - OAuth access token.
9704 /// * *alt* (query-string) - Data format for response.
9705 /// * *callback* (query-string) - JSONP
9706 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9707 /// * *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.
9708 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9709 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9710 /// * *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.
9711 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9712 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9713 pub fn param<T>(
9714 mut self,
9715 name: T,
9716 value: T,
9717 ) -> ProjectLocationOccurrenceGetVulnerabilitySummaryCall<'a, C>
9718 where
9719 T: AsRef<str>,
9720 {
9721 self._additional_params
9722 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9723 self
9724 }
9725
9726 /// Identifies the authorization scope for the method you are building.
9727 ///
9728 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9729 /// [`Scope::CloudPlatform`].
9730 ///
9731 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9732 /// tokens for more than one scope.
9733 ///
9734 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9735 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9736 /// sufficient, a read-write scope will do as well.
9737 pub fn add_scope<St>(
9738 mut self,
9739 scope: St,
9740 ) -> ProjectLocationOccurrenceGetVulnerabilitySummaryCall<'a, C>
9741 where
9742 St: AsRef<str>,
9743 {
9744 self._scopes.insert(String::from(scope.as_ref()));
9745 self
9746 }
9747 /// Identifies the authorization scope(s) for the method you are building.
9748 ///
9749 /// See [`Self::add_scope()`] for details.
9750 pub fn add_scopes<I, St>(
9751 mut self,
9752 scopes: I,
9753 ) -> ProjectLocationOccurrenceGetVulnerabilitySummaryCall<'a, C>
9754 where
9755 I: IntoIterator<Item = St>,
9756 St: AsRef<str>,
9757 {
9758 self._scopes
9759 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9760 self
9761 }
9762
9763 /// Removes all scopes, and no default scope will be used either.
9764 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9765 /// for details).
9766 pub fn clear_scopes(mut self) -> ProjectLocationOccurrenceGetVulnerabilitySummaryCall<'a, C> {
9767 self._scopes.clear();
9768 self
9769 }
9770}
9771
9772/// Lists occurrences for the specified project.
9773///
9774/// A builder for the *locations.occurrences.list* method supported by a *project* resource.
9775/// It is not used directly, but through a [`ProjectMethods`] instance.
9776///
9777/// # Example
9778///
9779/// Instantiate a resource method builder
9780///
9781/// ```test_harness,no_run
9782/// # extern crate hyper;
9783/// # extern crate hyper_rustls;
9784/// # extern crate google_containeranalysis1 as containeranalysis1;
9785/// # async fn dox() {
9786/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9787///
9788/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9789/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9790/// # .with_native_roots()
9791/// # .unwrap()
9792/// # .https_only()
9793/// # .enable_http2()
9794/// # .build();
9795///
9796/// # let executor = hyper_util::rt::TokioExecutor::new();
9797/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9798/// # secret,
9799/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9800/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9801/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9802/// # ),
9803/// # ).build().await.unwrap();
9804///
9805/// # let client = hyper_util::client::legacy::Client::builder(
9806/// # hyper_util::rt::TokioExecutor::new()
9807/// # )
9808/// # .build(
9809/// # hyper_rustls::HttpsConnectorBuilder::new()
9810/// # .with_native_roots()
9811/// # .unwrap()
9812/// # .https_or_http()
9813/// # .enable_http2()
9814/// # .build()
9815/// # );
9816/// # let mut hub = ContainerAnalysis::new(client, auth);
9817/// // You can configure optional parameters by calling the respective setters at will, and
9818/// // execute the final call using `doit()`.
9819/// // Values shown here are possibly random and not representative !
9820/// let result = hub.projects().locations_occurrences_list("parent")
9821/// .return_partial_success(false)
9822/// .page_token("sed")
9823/// .page_size(-70)
9824/// .filter("sed")
9825/// .doit().await;
9826/// # }
9827/// ```
9828pub struct ProjectLocationOccurrenceListCall<'a, C>
9829where
9830 C: 'a,
9831{
9832 hub: &'a ContainerAnalysis<C>,
9833 _parent: String,
9834 _return_partial_success: Option<bool>,
9835 _page_token: Option<String>,
9836 _page_size: Option<i32>,
9837 _filter: Option<String>,
9838 _delegate: Option<&'a mut dyn common::Delegate>,
9839 _additional_params: HashMap<String, String>,
9840 _scopes: BTreeSet<String>,
9841}
9842
9843impl<'a, C> common::CallBuilder for ProjectLocationOccurrenceListCall<'a, C> {}
9844
9845impl<'a, C> ProjectLocationOccurrenceListCall<'a, C>
9846where
9847 C: common::Connector,
9848{
9849 /// Perform the operation you have build so far.
9850 pub async fn doit(mut self) -> common::Result<(common::Response, ListOccurrencesResponse)> {
9851 use std::borrow::Cow;
9852 use std::io::{Read, Seek};
9853
9854 use common::{url::Params, ToParts};
9855 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9856
9857 let mut dd = common::DefaultDelegate;
9858 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9859 dlg.begin(common::MethodInfo {
9860 id: "containeranalysis.projects.locations.occurrences.list",
9861 http_method: hyper::Method::GET,
9862 });
9863
9864 for &field in [
9865 "alt",
9866 "parent",
9867 "returnPartialSuccess",
9868 "pageToken",
9869 "pageSize",
9870 "filter",
9871 ]
9872 .iter()
9873 {
9874 if self._additional_params.contains_key(field) {
9875 dlg.finished(false);
9876 return Err(common::Error::FieldClash(field));
9877 }
9878 }
9879
9880 let mut params = Params::with_capacity(7 + self._additional_params.len());
9881 params.push("parent", self._parent);
9882 if let Some(value) = self._return_partial_success.as_ref() {
9883 params.push("returnPartialSuccess", value.to_string());
9884 }
9885 if let Some(value) = self._page_token.as_ref() {
9886 params.push("pageToken", value);
9887 }
9888 if let Some(value) = self._page_size.as_ref() {
9889 params.push("pageSize", value.to_string());
9890 }
9891 if let Some(value) = self._filter.as_ref() {
9892 params.push("filter", value);
9893 }
9894
9895 params.extend(self._additional_params.iter());
9896
9897 params.push("alt", "json");
9898 let mut url = self.hub._base_url.clone() + "v1/{+parent}/occurrences";
9899 if self._scopes.is_empty() {
9900 self._scopes
9901 .insert(Scope::CloudPlatform.as_ref().to_string());
9902 }
9903
9904 #[allow(clippy::single_element_loop)]
9905 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
9906 url = params.uri_replacement(url, param_name, find_this, true);
9907 }
9908 {
9909 let to_remove = ["parent"];
9910 params.remove_params(&to_remove);
9911 }
9912
9913 let url = params.parse_with_url(&url);
9914
9915 loop {
9916 let token = match self
9917 .hub
9918 .auth
9919 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9920 .await
9921 {
9922 Ok(token) => token,
9923 Err(e) => match dlg.token(e) {
9924 Ok(token) => token,
9925 Err(e) => {
9926 dlg.finished(false);
9927 return Err(common::Error::MissingToken(e));
9928 }
9929 },
9930 };
9931 let mut req_result = {
9932 let client = &self.hub.client;
9933 dlg.pre_request();
9934 let mut req_builder = hyper::Request::builder()
9935 .method(hyper::Method::GET)
9936 .uri(url.as_str())
9937 .header(USER_AGENT, self.hub._user_agent.clone());
9938
9939 if let Some(token) = token.as_ref() {
9940 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9941 }
9942
9943 let request = req_builder
9944 .header(CONTENT_LENGTH, 0_u64)
9945 .body(common::to_body::<String>(None));
9946
9947 client.request(request.unwrap()).await
9948 };
9949
9950 match req_result {
9951 Err(err) => {
9952 if let common::Retry::After(d) = dlg.http_error(&err) {
9953 sleep(d).await;
9954 continue;
9955 }
9956 dlg.finished(false);
9957 return Err(common::Error::HttpError(err));
9958 }
9959 Ok(res) => {
9960 let (mut parts, body) = res.into_parts();
9961 let mut body = common::Body::new(body);
9962 if !parts.status.is_success() {
9963 let bytes = common::to_bytes(body).await.unwrap_or_default();
9964 let error = serde_json::from_str(&common::to_string(&bytes));
9965 let response = common::to_response(parts, bytes.into());
9966
9967 if let common::Retry::After(d) =
9968 dlg.http_failure(&response, error.as_ref().ok())
9969 {
9970 sleep(d).await;
9971 continue;
9972 }
9973
9974 dlg.finished(false);
9975
9976 return Err(match error {
9977 Ok(value) => common::Error::BadRequest(value),
9978 _ => common::Error::Failure(response),
9979 });
9980 }
9981 let response = {
9982 let bytes = common::to_bytes(body).await.unwrap_or_default();
9983 let encoded = common::to_string(&bytes);
9984 match serde_json::from_str(&encoded) {
9985 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9986 Err(error) => {
9987 dlg.response_json_decode_error(&encoded, &error);
9988 return Err(common::Error::JsonDecodeError(
9989 encoded.to_string(),
9990 error,
9991 ));
9992 }
9993 }
9994 };
9995
9996 dlg.finished(true);
9997 return Ok(response);
9998 }
9999 }
10000 }
10001 }
10002
10003 /// Required. The name of the project to list occurrences for in the form of `projects/[PROJECT_ID]`.
10004 ///
10005 /// Sets the *parent* path property to the given value.
10006 ///
10007 /// Even though the property as already been set when instantiating this call,
10008 /// we provide this method for API completeness.
10009 pub fn parent(mut self, new_value: &str) -> ProjectLocationOccurrenceListCall<'a, C> {
10010 self._parent = new_value.to_string();
10011 self
10012 }
10013 /// If set, the request will return all reachable Occurrences and report all unreachable regions in the `unreachable` field in the response. Only applicable for requests in the global region.
10014 ///
10015 /// Sets the *return partial success* query property to the given value.
10016 pub fn return_partial_success(
10017 mut self,
10018 new_value: bool,
10019 ) -> ProjectLocationOccurrenceListCall<'a, C> {
10020 self._return_partial_success = Some(new_value);
10021 self
10022 }
10023 /// Token to provide to skip to a particular spot in the list.
10024 ///
10025 /// Sets the *page token* query property to the given value.
10026 pub fn page_token(mut self, new_value: &str) -> ProjectLocationOccurrenceListCall<'a, C> {
10027 self._page_token = Some(new_value.to_string());
10028 self
10029 }
10030 /// 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.
10031 ///
10032 /// Sets the *page size* query property to the given value.
10033 pub fn page_size(mut self, new_value: i32) -> ProjectLocationOccurrenceListCall<'a, C> {
10034 self._page_size = Some(new_value);
10035 self
10036 }
10037 /// The filter expression.
10038 ///
10039 /// Sets the *filter* query property to the given value.
10040 pub fn filter(mut self, new_value: &str) -> ProjectLocationOccurrenceListCall<'a, C> {
10041 self._filter = Some(new_value.to_string());
10042 self
10043 }
10044 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10045 /// while executing the actual API request.
10046 ///
10047 /// ````text
10048 /// It should be used to handle progress information, and to implement a certain level of resilience.
10049 /// ````
10050 ///
10051 /// Sets the *delegate* property to the given value.
10052 pub fn delegate(
10053 mut self,
10054 new_value: &'a mut dyn common::Delegate,
10055 ) -> ProjectLocationOccurrenceListCall<'a, C> {
10056 self._delegate = Some(new_value);
10057 self
10058 }
10059
10060 /// Set any additional parameter of the query string used in the request.
10061 /// It should be used to set parameters which are not yet available through their own
10062 /// setters.
10063 ///
10064 /// Please note that this method must not be used to set any of the known parameters
10065 /// which have their own setter method. If done anyway, the request will fail.
10066 ///
10067 /// # Additional Parameters
10068 ///
10069 /// * *$.xgafv* (query-string) - V1 error format.
10070 /// * *access_token* (query-string) - OAuth access token.
10071 /// * *alt* (query-string) - Data format for response.
10072 /// * *callback* (query-string) - JSONP
10073 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10074 /// * *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.
10075 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10076 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10077 /// * *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.
10078 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10079 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10080 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOccurrenceListCall<'a, C>
10081 where
10082 T: AsRef<str>,
10083 {
10084 self._additional_params
10085 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10086 self
10087 }
10088
10089 /// Identifies the authorization scope for the method you are building.
10090 ///
10091 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10092 /// [`Scope::CloudPlatform`].
10093 ///
10094 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10095 /// tokens for more than one scope.
10096 ///
10097 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10098 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10099 /// sufficient, a read-write scope will do as well.
10100 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOccurrenceListCall<'a, C>
10101 where
10102 St: AsRef<str>,
10103 {
10104 self._scopes.insert(String::from(scope.as_ref()));
10105 self
10106 }
10107 /// Identifies the authorization scope(s) for the method you are building.
10108 ///
10109 /// See [`Self::add_scope()`] for details.
10110 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOccurrenceListCall<'a, C>
10111 where
10112 I: IntoIterator<Item = St>,
10113 St: AsRef<str>,
10114 {
10115 self._scopes
10116 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10117 self
10118 }
10119
10120 /// Removes all scopes, and no default scope will be used either.
10121 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10122 /// for details).
10123 pub fn clear_scopes(mut self) -> ProjectLocationOccurrenceListCall<'a, C> {
10124 self._scopes.clear();
10125 self
10126 }
10127}
10128
10129/// Updates the specified occurrence.
10130///
10131/// A builder for the *locations.occurrences.patch* method supported by a *project* resource.
10132/// It is not used directly, but through a [`ProjectMethods`] instance.
10133///
10134/// # Example
10135///
10136/// Instantiate a resource method builder
10137///
10138/// ```test_harness,no_run
10139/// # extern crate hyper;
10140/// # extern crate hyper_rustls;
10141/// # extern crate google_containeranalysis1 as containeranalysis1;
10142/// use containeranalysis1::api::Occurrence;
10143/// # async fn dox() {
10144/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10145///
10146/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10147/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10148/// # .with_native_roots()
10149/// # .unwrap()
10150/// # .https_only()
10151/// # .enable_http2()
10152/// # .build();
10153///
10154/// # let executor = hyper_util::rt::TokioExecutor::new();
10155/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10156/// # secret,
10157/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10158/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10159/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10160/// # ),
10161/// # ).build().await.unwrap();
10162///
10163/// # let client = hyper_util::client::legacy::Client::builder(
10164/// # hyper_util::rt::TokioExecutor::new()
10165/// # )
10166/// # .build(
10167/// # hyper_rustls::HttpsConnectorBuilder::new()
10168/// # .with_native_roots()
10169/// # .unwrap()
10170/// # .https_or_http()
10171/// # .enable_http2()
10172/// # .build()
10173/// # );
10174/// # let mut hub = ContainerAnalysis::new(client, auth);
10175/// // As the method needs a request, you would usually fill it with the desired information
10176/// // into the respective structure. Some of the parts shown here might not be applicable !
10177/// // Values shown here are possibly random and not representative !
10178/// let mut req = Occurrence::default();
10179///
10180/// // You can configure optional parameters by calling the respective setters at will, and
10181/// // execute the final call using `doit()`.
10182/// // Values shown here are possibly random and not representative !
10183/// let result = hub.projects().locations_occurrences_patch(req, "name")
10184/// .update_mask(FieldMask::new::<&str>(&[]))
10185/// .doit().await;
10186/// # }
10187/// ```
10188pub struct ProjectLocationOccurrencePatchCall<'a, C>
10189where
10190 C: 'a,
10191{
10192 hub: &'a ContainerAnalysis<C>,
10193 _request: Occurrence,
10194 _name: String,
10195 _update_mask: Option<common::FieldMask>,
10196 _delegate: Option<&'a mut dyn common::Delegate>,
10197 _additional_params: HashMap<String, String>,
10198 _scopes: BTreeSet<String>,
10199}
10200
10201impl<'a, C> common::CallBuilder for ProjectLocationOccurrencePatchCall<'a, C> {}
10202
10203impl<'a, C> ProjectLocationOccurrencePatchCall<'a, C>
10204where
10205 C: common::Connector,
10206{
10207 /// Perform the operation you have build so far.
10208 pub async fn doit(mut self) -> common::Result<(common::Response, Occurrence)> {
10209 use std::borrow::Cow;
10210 use std::io::{Read, Seek};
10211
10212 use common::{url::Params, ToParts};
10213 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10214
10215 let mut dd = common::DefaultDelegate;
10216 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10217 dlg.begin(common::MethodInfo {
10218 id: "containeranalysis.projects.locations.occurrences.patch",
10219 http_method: hyper::Method::PATCH,
10220 });
10221
10222 for &field in ["alt", "name", "updateMask"].iter() {
10223 if self._additional_params.contains_key(field) {
10224 dlg.finished(false);
10225 return Err(common::Error::FieldClash(field));
10226 }
10227 }
10228
10229 let mut params = Params::with_capacity(5 + self._additional_params.len());
10230 params.push("name", self._name);
10231 if let Some(value) = self._update_mask.as_ref() {
10232 params.push("updateMask", value.to_string());
10233 }
10234
10235 params.extend(self._additional_params.iter());
10236
10237 params.push("alt", "json");
10238 let mut url = self.hub._base_url.clone() + "v1/{+name}";
10239 if self._scopes.is_empty() {
10240 self._scopes
10241 .insert(Scope::CloudPlatform.as_ref().to_string());
10242 }
10243
10244 #[allow(clippy::single_element_loop)]
10245 for &(find_this, param_name) in [("{+name}", "name")].iter() {
10246 url = params.uri_replacement(url, param_name, find_this, true);
10247 }
10248 {
10249 let to_remove = ["name"];
10250 params.remove_params(&to_remove);
10251 }
10252
10253 let url = params.parse_with_url(&url);
10254
10255 let mut json_mime_type = mime::APPLICATION_JSON;
10256 let mut request_value_reader = {
10257 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10258 common::remove_json_null_values(&mut value);
10259 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10260 serde_json::to_writer(&mut dst, &value).unwrap();
10261 dst
10262 };
10263 let request_size = request_value_reader
10264 .seek(std::io::SeekFrom::End(0))
10265 .unwrap();
10266 request_value_reader
10267 .seek(std::io::SeekFrom::Start(0))
10268 .unwrap();
10269
10270 loop {
10271 let token = match self
10272 .hub
10273 .auth
10274 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10275 .await
10276 {
10277 Ok(token) => token,
10278 Err(e) => match dlg.token(e) {
10279 Ok(token) => token,
10280 Err(e) => {
10281 dlg.finished(false);
10282 return Err(common::Error::MissingToken(e));
10283 }
10284 },
10285 };
10286 request_value_reader
10287 .seek(std::io::SeekFrom::Start(0))
10288 .unwrap();
10289 let mut req_result = {
10290 let client = &self.hub.client;
10291 dlg.pre_request();
10292 let mut req_builder = hyper::Request::builder()
10293 .method(hyper::Method::PATCH)
10294 .uri(url.as_str())
10295 .header(USER_AGENT, self.hub._user_agent.clone());
10296
10297 if let Some(token) = token.as_ref() {
10298 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10299 }
10300
10301 let request = req_builder
10302 .header(CONTENT_TYPE, json_mime_type.to_string())
10303 .header(CONTENT_LENGTH, request_size as u64)
10304 .body(common::to_body(
10305 request_value_reader.get_ref().clone().into(),
10306 ));
10307
10308 client.request(request.unwrap()).await
10309 };
10310
10311 match req_result {
10312 Err(err) => {
10313 if let common::Retry::After(d) = dlg.http_error(&err) {
10314 sleep(d).await;
10315 continue;
10316 }
10317 dlg.finished(false);
10318 return Err(common::Error::HttpError(err));
10319 }
10320 Ok(res) => {
10321 let (mut parts, body) = res.into_parts();
10322 let mut body = common::Body::new(body);
10323 if !parts.status.is_success() {
10324 let bytes = common::to_bytes(body).await.unwrap_or_default();
10325 let error = serde_json::from_str(&common::to_string(&bytes));
10326 let response = common::to_response(parts, bytes.into());
10327
10328 if let common::Retry::After(d) =
10329 dlg.http_failure(&response, error.as_ref().ok())
10330 {
10331 sleep(d).await;
10332 continue;
10333 }
10334
10335 dlg.finished(false);
10336
10337 return Err(match error {
10338 Ok(value) => common::Error::BadRequest(value),
10339 _ => common::Error::Failure(response),
10340 });
10341 }
10342 let response = {
10343 let bytes = common::to_bytes(body).await.unwrap_or_default();
10344 let encoded = common::to_string(&bytes);
10345 match serde_json::from_str(&encoded) {
10346 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10347 Err(error) => {
10348 dlg.response_json_decode_error(&encoded, &error);
10349 return Err(common::Error::JsonDecodeError(
10350 encoded.to_string(),
10351 error,
10352 ));
10353 }
10354 }
10355 };
10356
10357 dlg.finished(true);
10358 return Ok(response);
10359 }
10360 }
10361 }
10362 }
10363
10364 ///
10365 /// Sets the *request* property to the given value.
10366 ///
10367 /// Even though the property as already been set when instantiating this call,
10368 /// we provide this method for API completeness.
10369 pub fn request(mut self, new_value: Occurrence) -> ProjectLocationOccurrencePatchCall<'a, C> {
10370 self._request = new_value;
10371 self
10372 }
10373 /// Required. The name of the occurrence in the form of `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.
10374 ///
10375 /// Sets the *name* path property to the given value.
10376 ///
10377 /// Even though the property as already been set when instantiating this call,
10378 /// we provide this method for API completeness.
10379 pub fn name(mut self, new_value: &str) -> ProjectLocationOccurrencePatchCall<'a, C> {
10380 self._name = new_value.to_string();
10381 self
10382 }
10383 /// The fields to update.
10384 ///
10385 /// Sets the *update mask* query property to the given value.
10386 pub fn update_mask(
10387 mut self,
10388 new_value: common::FieldMask,
10389 ) -> ProjectLocationOccurrencePatchCall<'a, C> {
10390 self._update_mask = Some(new_value);
10391 self
10392 }
10393 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10394 /// while executing the actual API request.
10395 ///
10396 /// ````text
10397 /// It should be used to handle progress information, and to implement a certain level of resilience.
10398 /// ````
10399 ///
10400 /// Sets the *delegate* property to the given value.
10401 pub fn delegate(
10402 mut self,
10403 new_value: &'a mut dyn common::Delegate,
10404 ) -> ProjectLocationOccurrencePatchCall<'a, C> {
10405 self._delegate = Some(new_value);
10406 self
10407 }
10408
10409 /// Set any additional parameter of the query string used in the request.
10410 /// It should be used to set parameters which are not yet available through their own
10411 /// setters.
10412 ///
10413 /// Please note that this method must not be used to set any of the known parameters
10414 /// which have their own setter method. If done anyway, the request will fail.
10415 ///
10416 /// # Additional Parameters
10417 ///
10418 /// * *$.xgafv* (query-string) - V1 error format.
10419 /// * *access_token* (query-string) - OAuth access token.
10420 /// * *alt* (query-string) - Data format for response.
10421 /// * *callback* (query-string) - JSONP
10422 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10423 /// * *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.
10424 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10425 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10426 /// * *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.
10427 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10428 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10429 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOccurrencePatchCall<'a, C>
10430 where
10431 T: AsRef<str>,
10432 {
10433 self._additional_params
10434 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10435 self
10436 }
10437
10438 /// Identifies the authorization scope for the method you are building.
10439 ///
10440 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10441 /// [`Scope::CloudPlatform`].
10442 ///
10443 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10444 /// tokens for more than one scope.
10445 ///
10446 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10447 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10448 /// sufficient, a read-write scope will do as well.
10449 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOccurrencePatchCall<'a, C>
10450 where
10451 St: AsRef<str>,
10452 {
10453 self._scopes.insert(String::from(scope.as_ref()));
10454 self
10455 }
10456 /// Identifies the authorization scope(s) for the method you are building.
10457 ///
10458 /// See [`Self::add_scope()`] for details.
10459 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationOccurrencePatchCall<'a, C>
10460 where
10461 I: IntoIterator<Item = St>,
10462 St: AsRef<str>,
10463 {
10464 self._scopes
10465 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10466 self
10467 }
10468
10469 /// Removes all scopes, and no default scope will be used either.
10470 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10471 /// for details).
10472 pub fn clear_scopes(mut self) -> ProjectLocationOccurrencePatchCall<'a, C> {
10473 self._scopes.clear();
10474 self
10475 }
10476}
10477
10478/// 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.
10479///
10480/// A builder for the *locations.occurrences.setIamPolicy* method supported by a *project* resource.
10481/// It is not used directly, but through a [`ProjectMethods`] instance.
10482///
10483/// # Example
10484///
10485/// Instantiate a resource method builder
10486///
10487/// ```test_harness,no_run
10488/// # extern crate hyper;
10489/// # extern crate hyper_rustls;
10490/// # extern crate google_containeranalysis1 as containeranalysis1;
10491/// use containeranalysis1::api::SetIamPolicyRequest;
10492/// # async fn dox() {
10493/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10494///
10495/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10496/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10497/// # .with_native_roots()
10498/// # .unwrap()
10499/// # .https_only()
10500/// # .enable_http2()
10501/// # .build();
10502///
10503/// # let executor = hyper_util::rt::TokioExecutor::new();
10504/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10505/// # secret,
10506/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10507/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10508/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10509/// # ),
10510/// # ).build().await.unwrap();
10511///
10512/// # let client = hyper_util::client::legacy::Client::builder(
10513/// # hyper_util::rt::TokioExecutor::new()
10514/// # )
10515/// # .build(
10516/// # hyper_rustls::HttpsConnectorBuilder::new()
10517/// # .with_native_roots()
10518/// # .unwrap()
10519/// # .https_or_http()
10520/// # .enable_http2()
10521/// # .build()
10522/// # );
10523/// # let mut hub = ContainerAnalysis::new(client, auth);
10524/// // As the method needs a request, you would usually fill it with the desired information
10525/// // into the respective structure. Some of the parts shown here might not be applicable !
10526/// // Values shown here are possibly random and not representative !
10527/// let mut req = SetIamPolicyRequest::default();
10528///
10529/// // You can configure optional parameters by calling the respective setters at will, and
10530/// // execute the final call using `doit()`.
10531/// // Values shown here are possibly random and not representative !
10532/// let result = hub.projects().locations_occurrences_set_iam_policy(req, "resource")
10533/// .doit().await;
10534/// # }
10535/// ```
10536pub struct ProjectLocationOccurrenceSetIamPolicyCall<'a, C>
10537where
10538 C: 'a,
10539{
10540 hub: &'a ContainerAnalysis<C>,
10541 _request: SetIamPolicyRequest,
10542 _resource: String,
10543 _delegate: Option<&'a mut dyn common::Delegate>,
10544 _additional_params: HashMap<String, String>,
10545 _scopes: BTreeSet<String>,
10546}
10547
10548impl<'a, C> common::CallBuilder for ProjectLocationOccurrenceSetIamPolicyCall<'a, C> {}
10549
10550impl<'a, C> ProjectLocationOccurrenceSetIamPolicyCall<'a, C>
10551where
10552 C: common::Connector,
10553{
10554 /// Perform the operation you have build so far.
10555 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
10556 use std::borrow::Cow;
10557 use std::io::{Read, Seek};
10558
10559 use common::{url::Params, ToParts};
10560 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10561
10562 let mut dd = common::DefaultDelegate;
10563 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10564 dlg.begin(common::MethodInfo {
10565 id: "containeranalysis.projects.locations.occurrences.setIamPolicy",
10566 http_method: hyper::Method::POST,
10567 });
10568
10569 for &field in ["alt", "resource"].iter() {
10570 if self._additional_params.contains_key(field) {
10571 dlg.finished(false);
10572 return Err(common::Error::FieldClash(field));
10573 }
10574 }
10575
10576 let mut params = Params::with_capacity(4 + self._additional_params.len());
10577 params.push("resource", self._resource);
10578
10579 params.extend(self._additional_params.iter());
10580
10581 params.push("alt", "json");
10582 let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
10583 if self._scopes.is_empty() {
10584 self._scopes
10585 .insert(Scope::CloudPlatform.as_ref().to_string());
10586 }
10587
10588 #[allow(clippy::single_element_loop)]
10589 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
10590 url = params.uri_replacement(url, param_name, find_this, true);
10591 }
10592 {
10593 let to_remove = ["resource"];
10594 params.remove_params(&to_remove);
10595 }
10596
10597 let url = params.parse_with_url(&url);
10598
10599 let mut json_mime_type = mime::APPLICATION_JSON;
10600 let mut request_value_reader = {
10601 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10602 common::remove_json_null_values(&mut value);
10603 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10604 serde_json::to_writer(&mut dst, &value).unwrap();
10605 dst
10606 };
10607 let request_size = request_value_reader
10608 .seek(std::io::SeekFrom::End(0))
10609 .unwrap();
10610 request_value_reader
10611 .seek(std::io::SeekFrom::Start(0))
10612 .unwrap();
10613
10614 loop {
10615 let token = match self
10616 .hub
10617 .auth
10618 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10619 .await
10620 {
10621 Ok(token) => token,
10622 Err(e) => match dlg.token(e) {
10623 Ok(token) => token,
10624 Err(e) => {
10625 dlg.finished(false);
10626 return Err(common::Error::MissingToken(e));
10627 }
10628 },
10629 };
10630 request_value_reader
10631 .seek(std::io::SeekFrom::Start(0))
10632 .unwrap();
10633 let mut req_result = {
10634 let client = &self.hub.client;
10635 dlg.pre_request();
10636 let mut req_builder = hyper::Request::builder()
10637 .method(hyper::Method::POST)
10638 .uri(url.as_str())
10639 .header(USER_AGENT, self.hub._user_agent.clone());
10640
10641 if let Some(token) = token.as_ref() {
10642 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10643 }
10644
10645 let request = req_builder
10646 .header(CONTENT_TYPE, json_mime_type.to_string())
10647 .header(CONTENT_LENGTH, request_size as u64)
10648 .body(common::to_body(
10649 request_value_reader.get_ref().clone().into(),
10650 ));
10651
10652 client.request(request.unwrap()).await
10653 };
10654
10655 match req_result {
10656 Err(err) => {
10657 if let common::Retry::After(d) = dlg.http_error(&err) {
10658 sleep(d).await;
10659 continue;
10660 }
10661 dlg.finished(false);
10662 return Err(common::Error::HttpError(err));
10663 }
10664 Ok(res) => {
10665 let (mut parts, body) = res.into_parts();
10666 let mut body = common::Body::new(body);
10667 if !parts.status.is_success() {
10668 let bytes = common::to_bytes(body).await.unwrap_or_default();
10669 let error = serde_json::from_str(&common::to_string(&bytes));
10670 let response = common::to_response(parts, bytes.into());
10671
10672 if let common::Retry::After(d) =
10673 dlg.http_failure(&response, error.as_ref().ok())
10674 {
10675 sleep(d).await;
10676 continue;
10677 }
10678
10679 dlg.finished(false);
10680
10681 return Err(match error {
10682 Ok(value) => common::Error::BadRequest(value),
10683 _ => common::Error::Failure(response),
10684 });
10685 }
10686 let response = {
10687 let bytes = common::to_bytes(body).await.unwrap_or_default();
10688 let encoded = common::to_string(&bytes);
10689 match serde_json::from_str(&encoded) {
10690 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10691 Err(error) => {
10692 dlg.response_json_decode_error(&encoded, &error);
10693 return Err(common::Error::JsonDecodeError(
10694 encoded.to_string(),
10695 error,
10696 ));
10697 }
10698 }
10699 };
10700
10701 dlg.finished(true);
10702 return Ok(response);
10703 }
10704 }
10705 }
10706 }
10707
10708 ///
10709 /// Sets the *request* property to the given value.
10710 ///
10711 /// Even though the property as already been set when instantiating this call,
10712 /// we provide this method for API completeness.
10713 pub fn request(
10714 mut self,
10715 new_value: SetIamPolicyRequest,
10716 ) -> ProjectLocationOccurrenceSetIamPolicyCall<'a, C> {
10717 self._request = new_value;
10718 self
10719 }
10720 /// 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.
10721 ///
10722 /// Sets the *resource* path property to the given value.
10723 ///
10724 /// Even though the property as already been set when instantiating this call,
10725 /// we provide this method for API completeness.
10726 pub fn resource(mut self, new_value: &str) -> ProjectLocationOccurrenceSetIamPolicyCall<'a, C> {
10727 self._resource = new_value.to_string();
10728 self
10729 }
10730 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10731 /// while executing the actual API request.
10732 ///
10733 /// ````text
10734 /// It should be used to handle progress information, and to implement a certain level of resilience.
10735 /// ````
10736 ///
10737 /// Sets the *delegate* property to the given value.
10738 pub fn delegate(
10739 mut self,
10740 new_value: &'a mut dyn common::Delegate,
10741 ) -> ProjectLocationOccurrenceSetIamPolicyCall<'a, C> {
10742 self._delegate = Some(new_value);
10743 self
10744 }
10745
10746 /// Set any additional parameter of the query string used in the request.
10747 /// It should be used to set parameters which are not yet available through their own
10748 /// setters.
10749 ///
10750 /// Please note that this method must not be used to set any of the known parameters
10751 /// which have their own setter method. If done anyway, the request will fail.
10752 ///
10753 /// # Additional Parameters
10754 ///
10755 /// * *$.xgafv* (query-string) - V1 error format.
10756 /// * *access_token* (query-string) - OAuth access token.
10757 /// * *alt* (query-string) - Data format for response.
10758 /// * *callback* (query-string) - JSONP
10759 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10760 /// * *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.
10761 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10762 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10763 /// * *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.
10764 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10765 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10766 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationOccurrenceSetIamPolicyCall<'a, C>
10767 where
10768 T: AsRef<str>,
10769 {
10770 self._additional_params
10771 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10772 self
10773 }
10774
10775 /// Identifies the authorization scope for the method you are building.
10776 ///
10777 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10778 /// [`Scope::CloudPlatform`].
10779 ///
10780 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10781 /// tokens for more than one scope.
10782 ///
10783 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10784 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10785 /// sufficient, a read-write scope will do as well.
10786 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationOccurrenceSetIamPolicyCall<'a, C>
10787 where
10788 St: AsRef<str>,
10789 {
10790 self._scopes.insert(String::from(scope.as_ref()));
10791 self
10792 }
10793 /// Identifies the authorization scope(s) for the method you are building.
10794 ///
10795 /// See [`Self::add_scope()`] for details.
10796 pub fn add_scopes<I, St>(
10797 mut self,
10798 scopes: I,
10799 ) -> ProjectLocationOccurrenceSetIamPolicyCall<'a, C>
10800 where
10801 I: IntoIterator<Item = St>,
10802 St: AsRef<str>,
10803 {
10804 self._scopes
10805 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10806 self
10807 }
10808
10809 /// Removes all scopes, and no default scope will be used either.
10810 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10811 /// for details).
10812 pub fn clear_scopes(mut self) -> ProjectLocationOccurrenceSetIamPolicyCall<'a, C> {
10813 self._scopes.clear();
10814 self
10815 }
10816}
10817
10818/// 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.
10819///
10820/// A builder for the *locations.occurrences.testIamPermissions* method supported by a *project* resource.
10821/// It is not used directly, but through a [`ProjectMethods`] instance.
10822///
10823/// # Example
10824///
10825/// Instantiate a resource method builder
10826///
10827/// ```test_harness,no_run
10828/// # extern crate hyper;
10829/// # extern crate hyper_rustls;
10830/// # extern crate google_containeranalysis1 as containeranalysis1;
10831/// use containeranalysis1::api::TestIamPermissionsRequest;
10832/// # async fn dox() {
10833/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10834///
10835/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10836/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10837/// # .with_native_roots()
10838/// # .unwrap()
10839/// # .https_only()
10840/// # .enable_http2()
10841/// # .build();
10842///
10843/// # let executor = hyper_util::rt::TokioExecutor::new();
10844/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10845/// # secret,
10846/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10847/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10848/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10849/// # ),
10850/// # ).build().await.unwrap();
10851///
10852/// # let client = hyper_util::client::legacy::Client::builder(
10853/// # hyper_util::rt::TokioExecutor::new()
10854/// # )
10855/// # .build(
10856/// # hyper_rustls::HttpsConnectorBuilder::new()
10857/// # .with_native_roots()
10858/// # .unwrap()
10859/// # .https_or_http()
10860/// # .enable_http2()
10861/// # .build()
10862/// # );
10863/// # let mut hub = ContainerAnalysis::new(client, auth);
10864/// // As the method needs a request, you would usually fill it with the desired information
10865/// // into the respective structure. Some of the parts shown here might not be applicable !
10866/// // Values shown here are possibly random and not representative !
10867/// let mut req = TestIamPermissionsRequest::default();
10868///
10869/// // You can configure optional parameters by calling the respective setters at will, and
10870/// // execute the final call using `doit()`.
10871/// // Values shown here are possibly random and not representative !
10872/// let result = hub.projects().locations_occurrences_test_iam_permissions(req, "resource")
10873/// .doit().await;
10874/// # }
10875/// ```
10876pub struct ProjectLocationOccurrenceTestIamPermissionCall<'a, C>
10877where
10878 C: 'a,
10879{
10880 hub: &'a ContainerAnalysis<C>,
10881 _request: TestIamPermissionsRequest,
10882 _resource: String,
10883 _delegate: Option<&'a mut dyn common::Delegate>,
10884 _additional_params: HashMap<String, String>,
10885 _scopes: BTreeSet<String>,
10886}
10887
10888impl<'a, C> common::CallBuilder for ProjectLocationOccurrenceTestIamPermissionCall<'a, C> {}
10889
10890impl<'a, C> ProjectLocationOccurrenceTestIamPermissionCall<'a, C>
10891where
10892 C: common::Connector,
10893{
10894 /// Perform the operation you have build so far.
10895 pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
10896 use std::borrow::Cow;
10897 use std::io::{Read, Seek};
10898
10899 use common::{url::Params, ToParts};
10900 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10901
10902 let mut dd = common::DefaultDelegate;
10903 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10904 dlg.begin(common::MethodInfo {
10905 id: "containeranalysis.projects.locations.occurrences.testIamPermissions",
10906 http_method: hyper::Method::POST,
10907 });
10908
10909 for &field in ["alt", "resource"].iter() {
10910 if self._additional_params.contains_key(field) {
10911 dlg.finished(false);
10912 return Err(common::Error::FieldClash(field));
10913 }
10914 }
10915
10916 let mut params = Params::with_capacity(4 + self._additional_params.len());
10917 params.push("resource", self._resource);
10918
10919 params.extend(self._additional_params.iter());
10920
10921 params.push("alt", "json");
10922 let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
10923 if self._scopes.is_empty() {
10924 self._scopes
10925 .insert(Scope::CloudPlatform.as_ref().to_string());
10926 }
10927
10928 #[allow(clippy::single_element_loop)]
10929 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
10930 url = params.uri_replacement(url, param_name, find_this, true);
10931 }
10932 {
10933 let to_remove = ["resource"];
10934 params.remove_params(&to_remove);
10935 }
10936
10937 let url = params.parse_with_url(&url);
10938
10939 let mut json_mime_type = mime::APPLICATION_JSON;
10940 let mut request_value_reader = {
10941 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10942 common::remove_json_null_values(&mut value);
10943 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10944 serde_json::to_writer(&mut dst, &value).unwrap();
10945 dst
10946 };
10947 let request_size = request_value_reader
10948 .seek(std::io::SeekFrom::End(0))
10949 .unwrap();
10950 request_value_reader
10951 .seek(std::io::SeekFrom::Start(0))
10952 .unwrap();
10953
10954 loop {
10955 let token = match self
10956 .hub
10957 .auth
10958 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10959 .await
10960 {
10961 Ok(token) => token,
10962 Err(e) => match dlg.token(e) {
10963 Ok(token) => token,
10964 Err(e) => {
10965 dlg.finished(false);
10966 return Err(common::Error::MissingToken(e));
10967 }
10968 },
10969 };
10970 request_value_reader
10971 .seek(std::io::SeekFrom::Start(0))
10972 .unwrap();
10973 let mut req_result = {
10974 let client = &self.hub.client;
10975 dlg.pre_request();
10976 let mut req_builder = hyper::Request::builder()
10977 .method(hyper::Method::POST)
10978 .uri(url.as_str())
10979 .header(USER_AGENT, self.hub._user_agent.clone());
10980
10981 if let Some(token) = token.as_ref() {
10982 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10983 }
10984
10985 let request = req_builder
10986 .header(CONTENT_TYPE, json_mime_type.to_string())
10987 .header(CONTENT_LENGTH, request_size as u64)
10988 .body(common::to_body(
10989 request_value_reader.get_ref().clone().into(),
10990 ));
10991
10992 client.request(request.unwrap()).await
10993 };
10994
10995 match req_result {
10996 Err(err) => {
10997 if let common::Retry::After(d) = dlg.http_error(&err) {
10998 sleep(d).await;
10999 continue;
11000 }
11001 dlg.finished(false);
11002 return Err(common::Error::HttpError(err));
11003 }
11004 Ok(res) => {
11005 let (mut parts, body) = res.into_parts();
11006 let mut body = common::Body::new(body);
11007 if !parts.status.is_success() {
11008 let bytes = common::to_bytes(body).await.unwrap_or_default();
11009 let error = serde_json::from_str(&common::to_string(&bytes));
11010 let response = common::to_response(parts, bytes.into());
11011
11012 if let common::Retry::After(d) =
11013 dlg.http_failure(&response, error.as_ref().ok())
11014 {
11015 sleep(d).await;
11016 continue;
11017 }
11018
11019 dlg.finished(false);
11020
11021 return Err(match error {
11022 Ok(value) => common::Error::BadRequest(value),
11023 _ => common::Error::Failure(response),
11024 });
11025 }
11026 let response = {
11027 let bytes = common::to_bytes(body).await.unwrap_or_default();
11028 let encoded = common::to_string(&bytes);
11029 match serde_json::from_str(&encoded) {
11030 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11031 Err(error) => {
11032 dlg.response_json_decode_error(&encoded, &error);
11033 return Err(common::Error::JsonDecodeError(
11034 encoded.to_string(),
11035 error,
11036 ));
11037 }
11038 }
11039 };
11040
11041 dlg.finished(true);
11042 return Ok(response);
11043 }
11044 }
11045 }
11046 }
11047
11048 ///
11049 /// Sets the *request* property to the given value.
11050 ///
11051 /// Even though the property as already been set when instantiating this call,
11052 /// we provide this method for API completeness.
11053 pub fn request(
11054 mut self,
11055 new_value: TestIamPermissionsRequest,
11056 ) -> ProjectLocationOccurrenceTestIamPermissionCall<'a, C> {
11057 self._request = new_value;
11058 self
11059 }
11060 /// 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.
11061 ///
11062 /// Sets the *resource* path property to the given value.
11063 ///
11064 /// Even though the property as already been set when instantiating this call,
11065 /// we provide this method for API completeness.
11066 pub fn resource(
11067 mut self,
11068 new_value: &str,
11069 ) -> ProjectLocationOccurrenceTestIamPermissionCall<'a, C> {
11070 self._resource = new_value.to_string();
11071 self
11072 }
11073 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11074 /// while executing the actual API request.
11075 ///
11076 /// ````text
11077 /// It should be used to handle progress information, and to implement a certain level of resilience.
11078 /// ````
11079 ///
11080 /// Sets the *delegate* property to the given value.
11081 pub fn delegate(
11082 mut self,
11083 new_value: &'a mut dyn common::Delegate,
11084 ) -> ProjectLocationOccurrenceTestIamPermissionCall<'a, C> {
11085 self._delegate = Some(new_value);
11086 self
11087 }
11088
11089 /// Set any additional parameter of the query string used in the request.
11090 /// It should be used to set parameters which are not yet available through their own
11091 /// setters.
11092 ///
11093 /// Please note that this method must not be used to set any of the known parameters
11094 /// which have their own setter method. If done anyway, the request will fail.
11095 ///
11096 /// # Additional Parameters
11097 ///
11098 /// * *$.xgafv* (query-string) - V1 error format.
11099 /// * *access_token* (query-string) - OAuth access token.
11100 /// * *alt* (query-string) - Data format for response.
11101 /// * *callback* (query-string) - JSONP
11102 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11103 /// * *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.
11104 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11105 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11106 /// * *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.
11107 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11108 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11109 pub fn param<T>(
11110 mut self,
11111 name: T,
11112 value: T,
11113 ) -> ProjectLocationOccurrenceTestIamPermissionCall<'a, C>
11114 where
11115 T: AsRef<str>,
11116 {
11117 self._additional_params
11118 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11119 self
11120 }
11121
11122 /// Identifies the authorization scope for the method you are building.
11123 ///
11124 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11125 /// [`Scope::CloudPlatform`].
11126 ///
11127 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11128 /// tokens for more than one scope.
11129 ///
11130 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11131 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11132 /// sufficient, a read-write scope will do as well.
11133 pub fn add_scope<St>(
11134 mut self,
11135 scope: St,
11136 ) -> ProjectLocationOccurrenceTestIamPermissionCall<'a, C>
11137 where
11138 St: AsRef<str>,
11139 {
11140 self._scopes.insert(String::from(scope.as_ref()));
11141 self
11142 }
11143 /// Identifies the authorization scope(s) for the method you are building.
11144 ///
11145 /// See [`Self::add_scope()`] for details.
11146 pub fn add_scopes<I, St>(
11147 mut self,
11148 scopes: I,
11149 ) -> ProjectLocationOccurrenceTestIamPermissionCall<'a, C>
11150 where
11151 I: IntoIterator<Item = St>,
11152 St: AsRef<str>,
11153 {
11154 self._scopes
11155 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11156 self
11157 }
11158
11159 /// Removes all scopes, and no default scope will be used either.
11160 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11161 /// for details).
11162 pub fn clear_scopes(mut self) -> ProjectLocationOccurrenceTestIamPermissionCall<'a, C> {
11163 self._scopes.clear();
11164 self
11165 }
11166}
11167
11168/// Generates an SBOM for the given resource.
11169///
11170/// A builder for the *locations.resources.exportSBOM* method supported by a *project* resource.
11171/// It is not used directly, but through a [`ProjectMethods`] instance.
11172///
11173/// # Example
11174///
11175/// Instantiate a resource method builder
11176///
11177/// ```test_harness,no_run
11178/// # extern crate hyper;
11179/// # extern crate hyper_rustls;
11180/// # extern crate google_containeranalysis1 as containeranalysis1;
11181/// use containeranalysis1::api::ExportSBOMRequest;
11182/// # async fn dox() {
11183/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11184///
11185/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11186/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11187/// # .with_native_roots()
11188/// # .unwrap()
11189/// # .https_only()
11190/// # .enable_http2()
11191/// # .build();
11192///
11193/// # let executor = hyper_util::rt::TokioExecutor::new();
11194/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11195/// # secret,
11196/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11197/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11198/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11199/// # ),
11200/// # ).build().await.unwrap();
11201///
11202/// # let client = hyper_util::client::legacy::Client::builder(
11203/// # hyper_util::rt::TokioExecutor::new()
11204/// # )
11205/// # .build(
11206/// # hyper_rustls::HttpsConnectorBuilder::new()
11207/// # .with_native_roots()
11208/// # .unwrap()
11209/// # .https_or_http()
11210/// # .enable_http2()
11211/// # .build()
11212/// # );
11213/// # let mut hub = ContainerAnalysis::new(client, auth);
11214/// // As the method needs a request, you would usually fill it with the desired information
11215/// // into the respective structure. Some of the parts shown here might not be applicable !
11216/// // Values shown here are possibly random and not representative !
11217/// let mut req = ExportSBOMRequest::default();
11218///
11219/// // You can configure optional parameters by calling the respective setters at will, and
11220/// // execute the final call using `doit()`.
11221/// // Values shown here are possibly random and not representative !
11222/// let result = hub.projects().locations_resources_export_sbom(req, "name")
11223/// .doit().await;
11224/// # }
11225/// ```
11226pub struct ProjectLocationResourceExportSBOMCall<'a, C>
11227where
11228 C: 'a,
11229{
11230 hub: &'a ContainerAnalysis<C>,
11231 _request: ExportSBOMRequest,
11232 _name: String,
11233 _delegate: Option<&'a mut dyn common::Delegate>,
11234 _additional_params: HashMap<String, String>,
11235 _scopes: BTreeSet<String>,
11236}
11237
11238impl<'a, C> common::CallBuilder for ProjectLocationResourceExportSBOMCall<'a, C> {}
11239
11240impl<'a, C> ProjectLocationResourceExportSBOMCall<'a, C>
11241where
11242 C: common::Connector,
11243{
11244 /// Perform the operation you have build so far.
11245 pub async fn doit(mut self) -> common::Result<(common::Response, ExportSBOMResponse)> {
11246 use std::borrow::Cow;
11247 use std::io::{Read, Seek};
11248
11249 use common::{url::Params, ToParts};
11250 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11251
11252 let mut dd = common::DefaultDelegate;
11253 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11254 dlg.begin(common::MethodInfo {
11255 id: "containeranalysis.projects.locations.resources.exportSBOM",
11256 http_method: hyper::Method::POST,
11257 });
11258
11259 for &field in ["alt", "name"].iter() {
11260 if self._additional_params.contains_key(field) {
11261 dlg.finished(false);
11262 return Err(common::Error::FieldClash(field));
11263 }
11264 }
11265
11266 let mut params = Params::with_capacity(4 + self._additional_params.len());
11267 params.push("name", self._name);
11268
11269 params.extend(self._additional_params.iter());
11270
11271 params.push("alt", "json");
11272 let mut url = self.hub._base_url.clone() + "v1/{+name}:exportSBOM";
11273 if self._scopes.is_empty() {
11274 self._scopes
11275 .insert(Scope::CloudPlatform.as_ref().to_string());
11276 }
11277
11278 #[allow(clippy::single_element_loop)]
11279 for &(find_this, param_name) in [("{+name}", "name")].iter() {
11280 url = params.uri_replacement(url, param_name, find_this, true);
11281 }
11282 {
11283 let to_remove = ["name"];
11284 params.remove_params(&to_remove);
11285 }
11286
11287 let url = params.parse_with_url(&url);
11288
11289 let mut json_mime_type = mime::APPLICATION_JSON;
11290 let mut request_value_reader = {
11291 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11292 common::remove_json_null_values(&mut value);
11293 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11294 serde_json::to_writer(&mut dst, &value).unwrap();
11295 dst
11296 };
11297 let request_size = request_value_reader
11298 .seek(std::io::SeekFrom::End(0))
11299 .unwrap();
11300 request_value_reader
11301 .seek(std::io::SeekFrom::Start(0))
11302 .unwrap();
11303
11304 loop {
11305 let token = match self
11306 .hub
11307 .auth
11308 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11309 .await
11310 {
11311 Ok(token) => token,
11312 Err(e) => match dlg.token(e) {
11313 Ok(token) => token,
11314 Err(e) => {
11315 dlg.finished(false);
11316 return Err(common::Error::MissingToken(e));
11317 }
11318 },
11319 };
11320 request_value_reader
11321 .seek(std::io::SeekFrom::Start(0))
11322 .unwrap();
11323 let mut req_result = {
11324 let client = &self.hub.client;
11325 dlg.pre_request();
11326 let mut req_builder = hyper::Request::builder()
11327 .method(hyper::Method::POST)
11328 .uri(url.as_str())
11329 .header(USER_AGENT, self.hub._user_agent.clone());
11330
11331 if let Some(token) = token.as_ref() {
11332 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11333 }
11334
11335 let request = req_builder
11336 .header(CONTENT_TYPE, json_mime_type.to_string())
11337 .header(CONTENT_LENGTH, request_size as u64)
11338 .body(common::to_body(
11339 request_value_reader.get_ref().clone().into(),
11340 ));
11341
11342 client.request(request.unwrap()).await
11343 };
11344
11345 match req_result {
11346 Err(err) => {
11347 if let common::Retry::After(d) = dlg.http_error(&err) {
11348 sleep(d).await;
11349 continue;
11350 }
11351 dlg.finished(false);
11352 return Err(common::Error::HttpError(err));
11353 }
11354 Ok(res) => {
11355 let (mut parts, body) = res.into_parts();
11356 let mut body = common::Body::new(body);
11357 if !parts.status.is_success() {
11358 let bytes = common::to_bytes(body).await.unwrap_or_default();
11359 let error = serde_json::from_str(&common::to_string(&bytes));
11360 let response = common::to_response(parts, bytes.into());
11361
11362 if let common::Retry::After(d) =
11363 dlg.http_failure(&response, error.as_ref().ok())
11364 {
11365 sleep(d).await;
11366 continue;
11367 }
11368
11369 dlg.finished(false);
11370
11371 return Err(match error {
11372 Ok(value) => common::Error::BadRequest(value),
11373 _ => common::Error::Failure(response),
11374 });
11375 }
11376 let response = {
11377 let bytes = common::to_bytes(body).await.unwrap_or_default();
11378 let encoded = common::to_string(&bytes);
11379 match serde_json::from_str(&encoded) {
11380 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11381 Err(error) => {
11382 dlg.response_json_decode_error(&encoded, &error);
11383 return Err(common::Error::JsonDecodeError(
11384 encoded.to_string(),
11385 error,
11386 ));
11387 }
11388 }
11389 };
11390
11391 dlg.finished(true);
11392 return Ok(response);
11393 }
11394 }
11395 }
11396 }
11397
11398 ///
11399 /// Sets the *request* property to the given value.
11400 ///
11401 /// Even though the property as already been set when instantiating this call,
11402 /// we provide this method for API completeness.
11403 pub fn request(
11404 mut self,
11405 new_value: ExportSBOMRequest,
11406 ) -> ProjectLocationResourceExportSBOMCall<'a, C> {
11407 self._request = new_value;
11408 self
11409 }
11410 /// Required. The name of the resource in the form of `projects/[PROJECT_ID]/resources/[RESOURCE_URL]`.
11411 ///
11412 /// Sets the *name* path property to the given value.
11413 ///
11414 /// Even though the property as already been set when instantiating this call,
11415 /// we provide this method for API completeness.
11416 pub fn name(mut self, new_value: &str) -> ProjectLocationResourceExportSBOMCall<'a, C> {
11417 self._name = new_value.to_string();
11418 self
11419 }
11420 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11421 /// while executing the actual API request.
11422 ///
11423 /// ````text
11424 /// It should be used to handle progress information, and to implement a certain level of resilience.
11425 /// ````
11426 ///
11427 /// Sets the *delegate* property to the given value.
11428 pub fn delegate(
11429 mut self,
11430 new_value: &'a mut dyn common::Delegate,
11431 ) -> ProjectLocationResourceExportSBOMCall<'a, C> {
11432 self._delegate = Some(new_value);
11433 self
11434 }
11435
11436 /// Set any additional parameter of the query string used in the request.
11437 /// It should be used to set parameters which are not yet available through their own
11438 /// setters.
11439 ///
11440 /// Please note that this method must not be used to set any of the known parameters
11441 /// which have their own setter method. If done anyway, the request will fail.
11442 ///
11443 /// # Additional Parameters
11444 ///
11445 /// * *$.xgafv* (query-string) - V1 error format.
11446 /// * *access_token* (query-string) - OAuth access token.
11447 /// * *alt* (query-string) - Data format for response.
11448 /// * *callback* (query-string) - JSONP
11449 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11450 /// * *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.
11451 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11452 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11453 /// * *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.
11454 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11455 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11456 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationResourceExportSBOMCall<'a, C>
11457 where
11458 T: AsRef<str>,
11459 {
11460 self._additional_params
11461 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11462 self
11463 }
11464
11465 /// Identifies the authorization scope for the method you are building.
11466 ///
11467 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11468 /// [`Scope::CloudPlatform`].
11469 ///
11470 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11471 /// tokens for more than one scope.
11472 ///
11473 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11474 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11475 /// sufficient, a read-write scope will do as well.
11476 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationResourceExportSBOMCall<'a, C>
11477 where
11478 St: AsRef<str>,
11479 {
11480 self._scopes.insert(String::from(scope.as_ref()));
11481 self
11482 }
11483 /// Identifies the authorization scope(s) for the method you are building.
11484 ///
11485 /// See [`Self::add_scope()`] for details.
11486 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationResourceExportSBOMCall<'a, C>
11487 where
11488 I: IntoIterator<Item = St>,
11489 St: AsRef<str>,
11490 {
11491 self._scopes
11492 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11493 self
11494 }
11495
11496 /// Removes all scopes, and no default scope will be used either.
11497 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11498 /// for details).
11499 pub fn clear_scopes(mut self) -> ProjectLocationResourceExportSBOMCall<'a, C> {
11500 self._scopes.clear();
11501 self
11502 }
11503}
11504
11505/// Lists occurrences referencing the specified note. Provider projects can use this method to get all occurrences across consumer projects referencing the specified note.
11506///
11507/// A builder for the *notes.occurrences.list* method supported by a *project* resource.
11508/// It is not used directly, but through a [`ProjectMethods`] instance.
11509///
11510/// # Example
11511///
11512/// Instantiate a resource method builder
11513///
11514/// ```test_harness,no_run
11515/// # extern crate hyper;
11516/// # extern crate hyper_rustls;
11517/// # extern crate google_containeranalysis1 as containeranalysis1;
11518/// # async fn dox() {
11519/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11520///
11521/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11522/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11523/// # .with_native_roots()
11524/// # .unwrap()
11525/// # .https_only()
11526/// # .enable_http2()
11527/// # .build();
11528///
11529/// # let executor = hyper_util::rt::TokioExecutor::new();
11530/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11531/// # secret,
11532/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11533/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11534/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11535/// # ),
11536/// # ).build().await.unwrap();
11537///
11538/// # let client = hyper_util::client::legacy::Client::builder(
11539/// # hyper_util::rt::TokioExecutor::new()
11540/// # )
11541/// # .build(
11542/// # hyper_rustls::HttpsConnectorBuilder::new()
11543/// # .with_native_roots()
11544/// # .unwrap()
11545/// # .https_or_http()
11546/// # .enable_http2()
11547/// # .build()
11548/// # );
11549/// # let mut hub = ContainerAnalysis::new(client, auth);
11550/// // You can configure optional parameters by calling the respective setters at will, and
11551/// // execute the final call using `doit()`.
11552/// // Values shown here are possibly random and not representative !
11553/// let result = hub.projects().notes_occurrences_list("name")
11554/// .page_token("et")
11555/// .page_size(-68)
11556/// .filter("vero")
11557/// .doit().await;
11558/// # }
11559/// ```
11560pub struct ProjectNoteOccurrenceListCall<'a, C>
11561where
11562 C: 'a,
11563{
11564 hub: &'a ContainerAnalysis<C>,
11565 _name: String,
11566 _page_token: Option<String>,
11567 _page_size: Option<i32>,
11568 _filter: Option<String>,
11569 _delegate: Option<&'a mut dyn common::Delegate>,
11570 _additional_params: HashMap<String, String>,
11571 _scopes: BTreeSet<String>,
11572}
11573
11574impl<'a, C> common::CallBuilder for ProjectNoteOccurrenceListCall<'a, C> {}
11575
11576impl<'a, C> ProjectNoteOccurrenceListCall<'a, C>
11577where
11578 C: common::Connector,
11579{
11580 /// Perform the operation you have build so far.
11581 pub async fn doit(mut self) -> common::Result<(common::Response, ListNoteOccurrencesResponse)> {
11582 use std::borrow::Cow;
11583 use std::io::{Read, Seek};
11584
11585 use common::{url::Params, ToParts};
11586 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11587
11588 let mut dd = common::DefaultDelegate;
11589 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11590 dlg.begin(common::MethodInfo {
11591 id: "containeranalysis.projects.notes.occurrences.list",
11592 http_method: hyper::Method::GET,
11593 });
11594
11595 for &field in ["alt", "name", "pageToken", "pageSize", "filter"].iter() {
11596 if self._additional_params.contains_key(field) {
11597 dlg.finished(false);
11598 return Err(common::Error::FieldClash(field));
11599 }
11600 }
11601
11602 let mut params = Params::with_capacity(6 + self._additional_params.len());
11603 params.push("name", self._name);
11604 if let Some(value) = self._page_token.as_ref() {
11605 params.push("pageToken", value);
11606 }
11607 if let Some(value) = self._page_size.as_ref() {
11608 params.push("pageSize", value.to_string());
11609 }
11610 if let Some(value) = self._filter.as_ref() {
11611 params.push("filter", value);
11612 }
11613
11614 params.extend(self._additional_params.iter());
11615
11616 params.push("alt", "json");
11617 let mut url = self.hub._base_url.clone() + "v1/{+name}/occurrences";
11618 if self._scopes.is_empty() {
11619 self._scopes
11620 .insert(Scope::CloudPlatform.as_ref().to_string());
11621 }
11622
11623 #[allow(clippy::single_element_loop)]
11624 for &(find_this, param_name) in [("{+name}", "name")].iter() {
11625 url = params.uri_replacement(url, param_name, find_this, true);
11626 }
11627 {
11628 let to_remove = ["name"];
11629 params.remove_params(&to_remove);
11630 }
11631
11632 let url = params.parse_with_url(&url);
11633
11634 loop {
11635 let token = match self
11636 .hub
11637 .auth
11638 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11639 .await
11640 {
11641 Ok(token) => token,
11642 Err(e) => match dlg.token(e) {
11643 Ok(token) => token,
11644 Err(e) => {
11645 dlg.finished(false);
11646 return Err(common::Error::MissingToken(e));
11647 }
11648 },
11649 };
11650 let mut req_result = {
11651 let client = &self.hub.client;
11652 dlg.pre_request();
11653 let mut req_builder = hyper::Request::builder()
11654 .method(hyper::Method::GET)
11655 .uri(url.as_str())
11656 .header(USER_AGENT, self.hub._user_agent.clone());
11657
11658 if let Some(token) = token.as_ref() {
11659 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11660 }
11661
11662 let request = req_builder
11663 .header(CONTENT_LENGTH, 0_u64)
11664 .body(common::to_body::<String>(None));
11665
11666 client.request(request.unwrap()).await
11667 };
11668
11669 match req_result {
11670 Err(err) => {
11671 if let common::Retry::After(d) = dlg.http_error(&err) {
11672 sleep(d).await;
11673 continue;
11674 }
11675 dlg.finished(false);
11676 return Err(common::Error::HttpError(err));
11677 }
11678 Ok(res) => {
11679 let (mut parts, body) = res.into_parts();
11680 let mut body = common::Body::new(body);
11681 if !parts.status.is_success() {
11682 let bytes = common::to_bytes(body).await.unwrap_or_default();
11683 let error = serde_json::from_str(&common::to_string(&bytes));
11684 let response = common::to_response(parts, bytes.into());
11685
11686 if let common::Retry::After(d) =
11687 dlg.http_failure(&response, error.as_ref().ok())
11688 {
11689 sleep(d).await;
11690 continue;
11691 }
11692
11693 dlg.finished(false);
11694
11695 return Err(match error {
11696 Ok(value) => common::Error::BadRequest(value),
11697 _ => common::Error::Failure(response),
11698 });
11699 }
11700 let response = {
11701 let bytes = common::to_bytes(body).await.unwrap_or_default();
11702 let encoded = common::to_string(&bytes);
11703 match serde_json::from_str(&encoded) {
11704 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11705 Err(error) => {
11706 dlg.response_json_decode_error(&encoded, &error);
11707 return Err(common::Error::JsonDecodeError(
11708 encoded.to_string(),
11709 error,
11710 ));
11711 }
11712 }
11713 };
11714
11715 dlg.finished(true);
11716 return Ok(response);
11717 }
11718 }
11719 }
11720 }
11721
11722 /// Required. The name of the note to list occurrences for in the form of `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.
11723 ///
11724 /// Sets the *name* path property to the given value.
11725 ///
11726 /// Even though the property as already been set when instantiating this call,
11727 /// we provide this method for API completeness.
11728 pub fn name(mut self, new_value: &str) -> ProjectNoteOccurrenceListCall<'a, C> {
11729 self._name = new_value.to_string();
11730 self
11731 }
11732 /// Token to provide to skip to a particular spot in the list.
11733 ///
11734 /// Sets the *page token* query property to the given value.
11735 pub fn page_token(mut self, new_value: &str) -> ProjectNoteOccurrenceListCall<'a, C> {
11736 self._page_token = Some(new_value.to_string());
11737 self
11738 }
11739 /// Number of occurrences to return in the list.
11740 ///
11741 /// Sets the *page size* query property to the given value.
11742 pub fn page_size(mut self, new_value: i32) -> ProjectNoteOccurrenceListCall<'a, C> {
11743 self._page_size = Some(new_value);
11744 self
11745 }
11746 /// The filter expression.
11747 ///
11748 /// Sets the *filter* query property to the given value.
11749 pub fn filter(mut self, new_value: &str) -> ProjectNoteOccurrenceListCall<'a, C> {
11750 self._filter = Some(new_value.to_string());
11751 self
11752 }
11753 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11754 /// while executing the actual API request.
11755 ///
11756 /// ````text
11757 /// It should be used to handle progress information, and to implement a certain level of resilience.
11758 /// ````
11759 ///
11760 /// Sets the *delegate* property to the given value.
11761 pub fn delegate(
11762 mut self,
11763 new_value: &'a mut dyn common::Delegate,
11764 ) -> ProjectNoteOccurrenceListCall<'a, C> {
11765 self._delegate = Some(new_value);
11766 self
11767 }
11768
11769 /// Set any additional parameter of the query string used in the request.
11770 /// It should be used to set parameters which are not yet available through their own
11771 /// setters.
11772 ///
11773 /// Please note that this method must not be used to set any of the known parameters
11774 /// which have their own setter method. If done anyway, the request will fail.
11775 ///
11776 /// # Additional Parameters
11777 ///
11778 /// * *$.xgafv* (query-string) - V1 error format.
11779 /// * *access_token* (query-string) - OAuth access token.
11780 /// * *alt* (query-string) - Data format for response.
11781 /// * *callback* (query-string) - JSONP
11782 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11783 /// * *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.
11784 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11785 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11786 /// * *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.
11787 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11788 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11789 pub fn param<T>(mut self, name: T, value: T) -> ProjectNoteOccurrenceListCall<'a, C>
11790 where
11791 T: AsRef<str>,
11792 {
11793 self._additional_params
11794 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11795 self
11796 }
11797
11798 /// Identifies the authorization scope for the method you are building.
11799 ///
11800 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11801 /// [`Scope::CloudPlatform`].
11802 ///
11803 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11804 /// tokens for more than one scope.
11805 ///
11806 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11807 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11808 /// sufficient, a read-write scope will do as well.
11809 pub fn add_scope<St>(mut self, scope: St) -> ProjectNoteOccurrenceListCall<'a, C>
11810 where
11811 St: AsRef<str>,
11812 {
11813 self._scopes.insert(String::from(scope.as_ref()));
11814 self
11815 }
11816 /// Identifies the authorization scope(s) for the method you are building.
11817 ///
11818 /// See [`Self::add_scope()`] for details.
11819 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectNoteOccurrenceListCall<'a, C>
11820 where
11821 I: IntoIterator<Item = St>,
11822 St: AsRef<str>,
11823 {
11824 self._scopes
11825 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11826 self
11827 }
11828
11829 /// Removes all scopes, and no default scope will be used either.
11830 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11831 /// for details).
11832 pub fn clear_scopes(mut self) -> ProjectNoteOccurrenceListCall<'a, C> {
11833 self._scopes.clear();
11834 self
11835 }
11836}
11837
11838/// Creates new notes in batch.
11839///
11840/// A builder for the *notes.batchCreate* method supported by a *project* resource.
11841/// It is not used directly, but through a [`ProjectMethods`] instance.
11842///
11843/// # Example
11844///
11845/// Instantiate a resource method builder
11846///
11847/// ```test_harness,no_run
11848/// # extern crate hyper;
11849/// # extern crate hyper_rustls;
11850/// # extern crate google_containeranalysis1 as containeranalysis1;
11851/// use containeranalysis1::api::BatchCreateNotesRequest;
11852/// # async fn dox() {
11853/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11854///
11855/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11856/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11857/// # .with_native_roots()
11858/// # .unwrap()
11859/// # .https_only()
11860/// # .enable_http2()
11861/// # .build();
11862///
11863/// # let executor = hyper_util::rt::TokioExecutor::new();
11864/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11865/// # secret,
11866/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11867/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11868/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11869/// # ),
11870/// # ).build().await.unwrap();
11871///
11872/// # let client = hyper_util::client::legacy::Client::builder(
11873/// # hyper_util::rt::TokioExecutor::new()
11874/// # )
11875/// # .build(
11876/// # hyper_rustls::HttpsConnectorBuilder::new()
11877/// # .with_native_roots()
11878/// # .unwrap()
11879/// # .https_or_http()
11880/// # .enable_http2()
11881/// # .build()
11882/// # );
11883/// # let mut hub = ContainerAnalysis::new(client, auth);
11884/// // As the method needs a request, you would usually fill it with the desired information
11885/// // into the respective structure. Some of the parts shown here might not be applicable !
11886/// // Values shown here are possibly random and not representative !
11887/// let mut req = BatchCreateNotesRequest::default();
11888///
11889/// // You can configure optional parameters by calling the respective setters at will, and
11890/// // execute the final call using `doit()`.
11891/// // Values shown here are possibly random and not representative !
11892/// let result = hub.projects().notes_batch_create(req, "parent")
11893/// .doit().await;
11894/// # }
11895/// ```
11896pub struct ProjectNoteBatchCreateCall<'a, C>
11897where
11898 C: 'a,
11899{
11900 hub: &'a ContainerAnalysis<C>,
11901 _request: BatchCreateNotesRequest,
11902 _parent: String,
11903 _delegate: Option<&'a mut dyn common::Delegate>,
11904 _additional_params: HashMap<String, String>,
11905 _scopes: BTreeSet<String>,
11906}
11907
11908impl<'a, C> common::CallBuilder for ProjectNoteBatchCreateCall<'a, C> {}
11909
11910impl<'a, C> ProjectNoteBatchCreateCall<'a, C>
11911where
11912 C: common::Connector,
11913{
11914 /// Perform the operation you have build so far.
11915 pub async fn doit(mut self) -> common::Result<(common::Response, BatchCreateNotesResponse)> {
11916 use std::borrow::Cow;
11917 use std::io::{Read, Seek};
11918
11919 use common::{url::Params, ToParts};
11920 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11921
11922 let mut dd = common::DefaultDelegate;
11923 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11924 dlg.begin(common::MethodInfo {
11925 id: "containeranalysis.projects.notes.batchCreate",
11926 http_method: hyper::Method::POST,
11927 });
11928
11929 for &field in ["alt", "parent"].iter() {
11930 if self._additional_params.contains_key(field) {
11931 dlg.finished(false);
11932 return Err(common::Error::FieldClash(field));
11933 }
11934 }
11935
11936 let mut params = Params::with_capacity(4 + self._additional_params.len());
11937 params.push("parent", self._parent);
11938
11939 params.extend(self._additional_params.iter());
11940
11941 params.push("alt", "json");
11942 let mut url = self.hub._base_url.clone() + "v1/{+parent}/notes:batchCreate";
11943 if self._scopes.is_empty() {
11944 self._scopes
11945 .insert(Scope::CloudPlatform.as_ref().to_string());
11946 }
11947
11948 #[allow(clippy::single_element_loop)]
11949 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
11950 url = params.uri_replacement(url, param_name, find_this, true);
11951 }
11952 {
11953 let to_remove = ["parent"];
11954 params.remove_params(&to_remove);
11955 }
11956
11957 let url = params.parse_with_url(&url);
11958
11959 let mut json_mime_type = mime::APPLICATION_JSON;
11960 let mut request_value_reader = {
11961 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
11962 common::remove_json_null_values(&mut value);
11963 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
11964 serde_json::to_writer(&mut dst, &value).unwrap();
11965 dst
11966 };
11967 let request_size = request_value_reader
11968 .seek(std::io::SeekFrom::End(0))
11969 .unwrap();
11970 request_value_reader
11971 .seek(std::io::SeekFrom::Start(0))
11972 .unwrap();
11973
11974 loop {
11975 let token = match self
11976 .hub
11977 .auth
11978 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11979 .await
11980 {
11981 Ok(token) => token,
11982 Err(e) => match dlg.token(e) {
11983 Ok(token) => token,
11984 Err(e) => {
11985 dlg.finished(false);
11986 return Err(common::Error::MissingToken(e));
11987 }
11988 },
11989 };
11990 request_value_reader
11991 .seek(std::io::SeekFrom::Start(0))
11992 .unwrap();
11993 let mut req_result = {
11994 let client = &self.hub.client;
11995 dlg.pre_request();
11996 let mut req_builder = hyper::Request::builder()
11997 .method(hyper::Method::POST)
11998 .uri(url.as_str())
11999 .header(USER_AGENT, self.hub._user_agent.clone());
12000
12001 if let Some(token) = token.as_ref() {
12002 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12003 }
12004
12005 let request = req_builder
12006 .header(CONTENT_TYPE, json_mime_type.to_string())
12007 .header(CONTENT_LENGTH, request_size as u64)
12008 .body(common::to_body(
12009 request_value_reader.get_ref().clone().into(),
12010 ));
12011
12012 client.request(request.unwrap()).await
12013 };
12014
12015 match req_result {
12016 Err(err) => {
12017 if let common::Retry::After(d) = dlg.http_error(&err) {
12018 sleep(d).await;
12019 continue;
12020 }
12021 dlg.finished(false);
12022 return Err(common::Error::HttpError(err));
12023 }
12024 Ok(res) => {
12025 let (mut parts, body) = res.into_parts();
12026 let mut body = common::Body::new(body);
12027 if !parts.status.is_success() {
12028 let bytes = common::to_bytes(body).await.unwrap_or_default();
12029 let error = serde_json::from_str(&common::to_string(&bytes));
12030 let response = common::to_response(parts, bytes.into());
12031
12032 if let common::Retry::After(d) =
12033 dlg.http_failure(&response, error.as_ref().ok())
12034 {
12035 sleep(d).await;
12036 continue;
12037 }
12038
12039 dlg.finished(false);
12040
12041 return Err(match error {
12042 Ok(value) => common::Error::BadRequest(value),
12043 _ => common::Error::Failure(response),
12044 });
12045 }
12046 let response = {
12047 let bytes = common::to_bytes(body).await.unwrap_or_default();
12048 let encoded = common::to_string(&bytes);
12049 match serde_json::from_str(&encoded) {
12050 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12051 Err(error) => {
12052 dlg.response_json_decode_error(&encoded, &error);
12053 return Err(common::Error::JsonDecodeError(
12054 encoded.to_string(),
12055 error,
12056 ));
12057 }
12058 }
12059 };
12060
12061 dlg.finished(true);
12062 return Ok(response);
12063 }
12064 }
12065 }
12066 }
12067
12068 ///
12069 /// Sets the *request* property to the given value.
12070 ///
12071 /// Even though the property as already been set when instantiating this call,
12072 /// we provide this method for API completeness.
12073 pub fn request(
12074 mut self,
12075 new_value: BatchCreateNotesRequest,
12076 ) -> ProjectNoteBatchCreateCall<'a, C> {
12077 self._request = new_value;
12078 self
12079 }
12080 /// Required. The name of the project in the form of `projects/[PROJECT_ID]`, under which the notes are to be created.
12081 ///
12082 /// Sets the *parent* path property to the given value.
12083 ///
12084 /// Even though the property as already been set when instantiating this call,
12085 /// we provide this method for API completeness.
12086 pub fn parent(mut self, new_value: &str) -> ProjectNoteBatchCreateCall<'a, C> {
12087 self._parent = new_value.to_string();
12088 self
12089 }
12090 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12091 /// while executing the actual API request.
12092 ///
12093 /// ````text
12094 /// It should be used to handle progress information, and to implement a certain level of resilience.
12095 /// ````
12096 ///
12097 /// Sets the *delegate* property to the given value.
12098 pub fn delegate(
12099 mut self,
12100 new_value: &'a mut dyn common::Delegate,
12101 ) -> ProjectNoteBatchCreateCall<'a, C> {
12102 self._delegate = Some(new_value);
12103 self
12104 }
12105
12106 /// Set any additional parameter of the query string used in the request.
12107 /// It should be used to set parameters which are not yet available through their own
12108 /// setters.
12109 ///
12110 /// Please note that this method must not be used to set any of the known parameters
12111 /// which have their own setter method. If done anyway, the request will fail.
12112 ///
12113 /// # Additional Parameters
12114 ///
12115 /// * *$.xgafv* (query-string) - V1 error format.
12116 /// * *access_token* (query-string) - OAuth access token.
12117 /// * *alt* (query-string) - Data format for response.
12118 /// * *callback* (query-string) - JSONP
12119 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12120 /// * *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.
12121 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12122 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12123 /// * *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.
12124 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12125 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12126 pub fn param<T>(mut self, name: T, value: T) -> ProjectNoteBatchCreateCall<'a, C>
12127 where
12128 T: AsRef<str>,
12129 {
12130 self._additional_params
12131 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12132 self
12133 }
12134
12135 /// Identifies the authorization scope for the method you are building.
12136 ///
12137 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12138 /// [`Scope::CloudPlatform`].
12139 ///
12140 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12141 /// tokens for more than one scope.
12142 ///
12143 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12144 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12145 /// sufficient, a read-write scope will do as well.
12146 pub fn add_scope<St>(mut self, scope: St) -> ProjectNoteBatchCreateCall<'a, C>
12147 where
12148 St: AsRef<str>,
12149 {
12150 self._scopes.insert(String::from(scope.as_ref()));
12151 self
12152 }
12153 /// Identifies the authorization scope(s) for the method you are building.
12154 ///
12155 /// See [`Self::add_scope()`] for details.
12156 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectNoteBatchCreateCall<'a, C>
12157 where
12158 I: IntoIterator<Item = St>,
12159 St: AsRef<str>,
12160 {
12161 self._scopes
12162 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12163 self
12164 }
12165
12166 /// Removes all scopes, and no default scope will be used either.
12167 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12168 /// for details).
12169 pub fn clear_scopes(mut self) -> ProjectNoteBatchCreateCall<'a, C> {
12170 self._scopes.clear();
12171 self
12172 }
12173}
12174
12175/// Creates a new note.
12176///
12177/// A builder for the *notes.create* method supported by a *project* resource.
12178/// It is not used directly, but through a [`ProjectMethods`] instance.
12179///
12180/// # Example
12181///
12182/// Instantiate a resource method builder
12183///
12184/// ```test_harness,no_run
12185/// # extern crate hyper;
12186/// # extern crate hyper_rustls;
12187/// # extern crate google_containeranalysis1 as containeranalysis1;
12188/// use containeranalysis1::api::Note;
12189/// # async fn dox() {
12190/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12191///
12192/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12193/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12194/// # .with_native_roots()
12195/// # .unwrap()
12196/// # .https_only()
12197/// # .enable_http2()
12198/// # .build();
12199///
12200/// # let executor = hyper_util::rt::TokioExecutor::new();
12201/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12202/// # secret,
12203/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12204/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12205/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12206/// # ),
12207/// # ).build().await.unwrap();
12208///
12209/// # let client = hyper_util::client::legacy::Client::builder(
12210/// # hyper_util::rt::TokioExecutor::new()
12211/// # )
12212/// # .build(
12213/// # hyper_rustls::HttpsConnectorBuilder::new()
12214/// # .with_native_roots()
12215/// # .unwrap()
12216/// # .https_or_http()
12217/// # .enable_http2()
12218/// # .build()
12219/// # );
12220/// # let mut hub = ContainerAnalysis::new(client, auth);
12221/// // As the method needs a request, you would usually fill it with the desired information
12222/// // into the respective structure. Some of the parts shown here might not be applicable !
12223/// // Values shown here are possibly random and not representative !
12224/// let mut req = Note::default();
12225///
12226/// // You can configure optional parameters by calling the respective setters at will, and
12227/// // execute the final call using `doit()`.
12228/// // Values shown here are possibly random and not representative !
12229/// let result = hub.projects().notes_create(req, "parent")
12230/// .note_id("duo")
12231/// .doit().await;
12232/// # }
12233/// ```
12234pub struct ProjectNoteCreateCall<'a, C>
12235where
12236 C: 'a,
12237{
12238 hub: &'a ContainerAnalysis<C>,
12239 _request: Note,
12240 _parent: String,
12241 _note_id: Option<String>,
12242 _delegate: Option<&'a mut dyn common::Delegate>,
12243 _additional_params: HashMap<String, String>,
12244 _scopes: BTreeSet<String>,
12245}
12246
12247impl<'a, C> common::CallBuilder for ProjectNoteCreateCall<'a, C> {}
12248
12249impl<'a, C> ProjectNoteCreateCall<'a, C>
12250where
12251 C: common::Connector,
12252{
12253 /// Perform the operation you have build so far.
12254 pub async fn doit(mut self) -> common::Result<(common::Response, Note)> {
12255 use std::borrow::Cow;
12256 use std::io::{Read, Seek};
12257
12258 use common::{url::Params, ToParts};
12259 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12260
12261 let mut dd = common::DefaultDelegate;
12262 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12263 dlg.begin(common::MethodInfo {
12264 id: "containeranalysis.projects.notes.create",
12265 http_method: hyper::Method::POST,
12266 });
12267
12268 for &field in ["alt", "parent", "noteId"].iter() {
12269 if self._additional_params.contains_key(field) {
12270 dlg.finished(false);
12271 return Err(common::Error::FieldClash(field));
12272 }
12273 }
12274
12275 let mut params = Params::with_capacity(5 + self._additional_params.len());
12276 params.push("parent", self._parent);
12277 if let Some(value) = self._note_id.as_ref() {
12278 params.push("noteId", value);
12279 }
12280
12281 params.extend(self._additional_params.iter());
12282
12283 params.push("alt", "json");
12284 let mut url = self.hub._base_url.clone() + "v1/{+parent}/notes";
12285 if self._scopes.is_empty() {
12286 self._scopes
12287 .insert(Scope::CloudPlatform.as_ref().to_string());
12288 }
12289
12290 #[allow(clippy::single_element_loop)]
12291 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
12292 url = params.uri_replacement(url, param_name, find_this, true);
12293 }
12294 {
12295 let to_remove = ["parent"];
12296 params.remove_params(&to_remove);
12297 }
12298
12299 let url = params.parse_with_url(&url);
12300
12301 let mut json_mime_type = mime::APPLICATION_JSON;
12302 let mut request_value_reader = {
12303 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12304 common::remove_json_null_values(&mut value);
12305 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12306 serde_json::to_writer(&mut dst, &value).unwrap();
12307 dst
12308 };
12309 let request_size = request_value_reader
12310 .seek(std::io::SeekFrom::End(0))
12311 .unwrap();
12312 request_value_reader
12313 .seek(std::io::SeekFrom::Start(0))
12314 .unwrap();
12315
12316 loop {
12317 let token = match self
12318 .hub
12319 .auth
12320 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12321 .await
12322 {
12323 Ok(token) => token,
12324 Err(e) => match dlg.token(e) {
12325 Ok(token) => token,
12326 Err(e) => {
12327 dlg.finished(false);
12328 return Err(common::Error::MissingToken(e));
12329 }
12330 },
12331 };
12332 request_value_reader
12333 .seek(std::io::SeekFrom::Start(0))
12334 .unwrap();
12335 let mut req_result = {
12336 let client = &self.hub.client;
12337 dlg.pre_request();
12338 let mut req_builder = hyper::Request::builder()
12339 .method(hyper::Method::POST)
12340 .uri(url.as_str())
12341 .header(USER_AGENT, self.hub._user_agent.clone());
12342
12343 if let Some(token) = token.as_ref() {
12344 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12345 }
12346
12347 let request = req_builder
12348 .header(CONTENT_TYPE, json_mime_type.to_string())
12349 .header(CONTENT_LENGTH, request_size as u64)
12350 .body(common::to_body(
12351 request_value_reader.get_ref().clone().into(),
12352 ));
12353
12354 client.request(request.unwrap()).await
12355 };
12356
12357 match req_result {
12358 Err(err) => {
12359 if let common::Retry::After(d) = dlg.http_error(&err) {
12360 sleep(d).await;
12361 continue;
12362 }
12363 dlg.finished(false);
12364 return Err(common::Error::HttpError(err));
12365 }
12366 Ok(res) => {
12367 let (mut parts, body) = res.into_parts();
12368 let mut body = common::Body::new(body);
12369 if !parts.status.is_success() {
12370 let bytes = common::to_bytes(body).await.unwrap_or_default();
12371 let error = serde_json::from_str(&common::to_string(&bytes));
12372 let response = common::to_response(parts, bytes.into());
12373
12374 if let common::Retry::After(d) =
12375 dlg.http_failure(&response, error.as_ref().ok())
12376 {
12377 sleep(d).await;
12378 continue;
12379 }
12380
12381 dlg.finished(false);
12382
12383 return Err(match error {
12384 Ok(value) => common::Error::BadRequest(value),
12385 _ => common::Error::Failure(response),
12386 });
12387 }
12388 let response = {
12389 let bytes = common::to_bytes(body).await.unwrap_or_default();
12390 let encoded = common::to_string(&bytes);
12391 match serde_json::from_str(&encoded) {
12392 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12393 Err(error) => {
12394 dlg.response_json_decode_error(&encoded, &error);
12395 return Err(common::Error::JsonDecodeError(
12396 encoded.to_string(),
12397 error,
12398 ));
12399 }
12400 }
12401 };
12402
12403 dlg.finished(true);
12404 return Ok(response);
12405 }
12406 }
12407 }
12408 }
12409
12410 ///
12411 /// Sets the *request* property to the given value.
12412 ///
12413 /// Even though the property as already been set when instantiating this call,
12414 /// we provide this method for API completeness.
12415 pub fn request(mut self, new_value: Note) -> ProjectNoteCreateCall<'a, C> {
12416 self._request = new_value;
12417 self
12418 }
12419 /// Required. The name of the project in the form of `projects/[PROJECT_ID]`, under which the note is to be created.
12420 ///
12421 /// Sets the *parent* path property to the given value.
12422 ///
12423 /// Even though the property as already been set when instantiating this call,
12424 /// we provide this method for API completeness.
12425 pub fn parent(mut self, new_value: &str) -> ProjectNoteCreateCall<'a, C> {
12426 self._parent = new_value.to_string();
12427 self
12428 }
12429 /// Required. The ID to use for this note.
12430 ///
12431 /// Sets the *note id* query property to the given value.
12432 pub fn note_id(mut self, new_value: &str) -> ProjectNoteCreateCall<'a, C> {
12433 self._note_id = Some(new_value.to_string());
12434 self
12435 }
12436 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12437 /// while executing the actual API request.
12438 ///
12439 /// ````text
12440 /// It should be used to handle progress information, and to implement a certain level of resilience.
12441 /// ````
12442 ///
12443 /// Sets the *delegate* property to the given value.
12444 pub fn delegate(
12445 mut self,
12446 new_value: &'a mut dyn common::Delegate,
12447 ) -> ProjectNoteCreateCall<'a, C> {
12448 self._delegate = Some(new_value);
12449 self
12450 }
12451
12452 /// Set any additional parameter of the query string used in the request.
12453 /// It should be used to set parameters which are not yet available through their own
12454 /// setters.
12455 ///
12456 /// Please note that this method must not be used to set any of the known parameters
12457 /// which have their own setter method. If done anyway, the request will fail.
12458 ///
12459 /// # Additional Parameters
12460 ///
12461 /// * *$.xgafv* (query-string) - V1 error format.
12462 /// * *access_token* (query-string) - OAuth access token.
12463 /// * *alt* (query-string) - Data format for response.
12464 /// * *callback* (query-string) - JSONP
12465 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12466 /// * *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.
12467 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12468 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12469 /// * *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.
12470 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12471 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12472 pub fn param<T>(mut self, name: T, value: T) -> ProjectNoteCreateCall<'a, C>
12473 where
12474 T: AsRef<str>,
12475 {
12476 self._additional_params
12477 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12478 self
12479 }
12480
12481 /// Identifies the authorization scope for the method you are building.
12482 ///
12483 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12484 /// [`Scope::CloudPlatform`].
12485 ///
12486 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12487 /// tokens for more than one scope.
12488 ///
12489 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12490 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12491 /// sufficient, a read-write scope will do as well.
12492 pub fn add_scope<St>(mut self, scope: St) -> ProjectNoteCreateCall<'a, C>
12493 where
12494 St: AsRef<str>,
12495 {
12496 self._scopes.insert(String::from(scope.as_ref()));
12497 self
12498 }
12499 /// Identifies the authorization scope(s) for the method you are building.
12500 ///
12501 /// See [`Self::add_scope()`] for details.
12502 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectNoteCreateCall<'a, C>
12503 where
12504 I: IntoIterator<Item = St>,
12505 St: AsRef<str>,
12506 {
12507 self._scopes
12508 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12509 self
12510 }
12511
12512 /// Removes all scopes, and no default scope will be used either.
12513 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12514 /// for details).
12515 pub fn clear_scopes(mut self) -> ProjectNoteCreateCall<'a, C> {
12516 self._scopes.clear();
12517 self
12518 }
12519}
12520
12521/// Deletes the specified note.
12522///
12523/// A builder for the *notes.delete* method supported by a *project* resource.
12524/// It is not used directly, but through a [`ProjectMethods`] instance.
12525///
12526/// # Example
12527///
12528/// Instantiate a resource method builder
12529///
12530/// ```test_harness,no_run
12531/// # extern crate hyper;
12532/// # extern crate hyper_rustls;
12533/// # extern crate google_containeranalysis1 as containeranalysis1;
12534/// # async fn dox() {
12535/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12536///
12537/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12538/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12539/// # .with_native_roots()
12540/// # .unwrap()
12541/// # .https_only()
12542/// # .enable_http2()
12543/// # .build();
12544///
12545/// # let executor = hyper_util::rt::TokioExecutor::new();
12546/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12547/// # secret,
12548/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12549/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12550/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12551/// # ),
12552/// # ).build().await.unwrap();
12553///
12554/// # let client = hyper_util::client::legacy::Client::builder(
12555/// # hyper_util::rt::TokioExecutor::new()
12556/// # )
12557/// # .build(
12558/// # hyper_rustls::HttpsConnectorBuilder::new()
12559/// # .with_native_roots()
12560/// # .unwrap()
12561/// # .https_or_http()
12562/// # .enable_http2()
12563/// # .build()
12564/// # );
12565/// # let mut hub = ContainerAnalysis::new(client, auth);
12566/// // You can configure optional parameters by calling the respective setters at will, and
12567/// // execute the final call using `doit()`.
12568/// // Values shown here are possibly random and not representative !
12569/// let result = hub.projects().notes_delete("name")
12570/// .doit().await;
12571/// # }
12572/// ```
12573pub struct ProjectNoteDeleteCall<'a, C>
12574where
12575 C: 'a,
12576{
12577 hub: &'a ContainerAnalysis<C>,
12578 _name: String,
12579 _delegate: Option<&'a mut dyn common::Delegate>,
12580 _additional_params: HashMap<String, String>,
12581 _scopes: BTreeSet<String>,
12582}
12583
12584impl<'a, C> common::CallBuilder for ProjectNoteDeleteCall<'a, C> {}
12585
12586impl<'a, C> ProjectNoteDeleteCall<'a, C>
12587where
12588 C: common::Connector,
12589{
12590 /// Perform the operation you have build so far.
12591 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
12592 use std::borrow::Cow;
12593 use std::io::{Read, Seek};
12594
12595 use common::{url::Params, ToParts};
12596 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12597
12598 let mut dd = common::DefaultDelegate;
12599 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12600 dlg.begin(common::MethodInfo {
12601 id: "containeranalysis.projects.notes.delete",
12602 http_method: hyper::Method::DELETE,
12603 });
12604
12605 for &field in ["alt", "name"].iter() {
12606 if self._additional_params.contains_key(field) {
12607 dlg.finished(false);
12608 return Err(common::Error::FieldClash(field));
12609 }
12610 }
12611
12612 let mut params = Params::with_capacity(3 + self._additional_params.len());
12613 params.push("name", self._name);
12614
12615 params.extend(self._additional_params.iter());
12616
12617 params.push("alt", "json");
12618 let mut url = self.hub._base_url.clone() + "v1/{+name}";
12619 if self._scopes.is_empty() {
12620 self._scopes
12621 .insert(Scope::CloudPlatform.as_ref().to_string());
12622 }
12623
12624 #[allow(clippy::single_element_loop)]
12625 for &(find_this, param_name) in [("{+name}", "name")].iter() {
12626 url = params.uri_replacement(url, param_name, find_this, true);
12627 }
12628 {
12629 let to_remove = ["name"];
12630 params.remove_params(&to_remove);
12631 }
12632
12633 let url = params.parse_with_url(&url);
12634
12635 loop {
12636 let token = match self
12637 .hub
12638 .auth
12639 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12640 .await
12641 {
12642 Ok(token) => token,
12643 Err(e) => match dlg.token(e) {
12644 Ok(token) => token,
12645 Err(e) => {
12646 dlg.finished(false);
12647 return Err(common::Error::MissingToken(e));
12648 }
12649 },
12650 };
12651 let mut req_result = {
12652 let client = &self.hub.client;
12653 dlg.pre_request();
12654 let mut req_builder = hyper::Request::builder()
12655 .method(hyper::Method::DELETE)
12656 .uri(url.as_str())
12657 .header(USER_AGENT, self.hub._user_agent.clone());
12658
12659 if let Some(token) = token.as_ref() {
12660 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12661 }
12662
12663 let request = req_builder
12664 .header(CONTENT_LENGTH, 0_u64)
12665 .body(common::to_body::<String>(None));
12666
12667 client.request(request.unwrap()).await
12668 };
12669
12670 match req_result {
12671 Err(err) => {
12672 if let common::Retry::After(d) = dlg.http_error(&err) {
12673 sleep(d).await;
12674 continue;
12675 }
12676 dlg.finished(false);
12677 return Err(common::Error::HttpError(err));
12678 }
12679 Ok(res) => {
12680 let (mut parts, body) = res.into_parts();
12681 let mut body = common::Body::new(body);
12682 if !parts.status.is_success() {
12683 let bytes = common::to_bytes(body).await.unwrap_or_default();
12684 let error = serde_json::from_str(&common::to_string(&bytes));
12685 let response = common::to_response(parts, bytes.into());
12686
12687 if let common::Retry::After(d) =
12688 dlg.http_failure(&response, error.as_ref().ok())
12689 {
12690 sleep(d).await;
12691 continue;
12692 }
12693
12694 dlg.finished(false);
12695
12696 return Err(match error {
12697 Ok(value) => common::Error::BadRequest(value),
12698 _ => common::Error::Failure(response),
12699 });
12700 }
12701 let response = {
12702 let bytes = common::to_bytes(body).await.unwrap_or_default();
12703 let encoded = common::to_string(&bytes);
12704 match serde_json::from_str(&encoded) {
12705 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12706 Err(error) => {
12707 dlg.response_json_decode_error(&encoded, &error);
12708 return Err(common::Error::JsonDecodeError(
12709 encoded.to_string(),
12710 error,
12711 ));
12712 }
12713 }
12714 };
12715
12716 dlg.finished(true);
12717 return Ok(response);
12718 }
12719 }
12720 }
12721 }
12722
12723 /// Required. The name of the note in the form of `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.
12724 ///
12725 /// Sets the *name* path property to the given value.
12726 ///
12727 /// Even though the property as already been set when instantiating this call,
12728 /// we provide this method for API completeness.
12729 pub fn name(mut self, new_value: &str) -> ProjectNoteDeleteCall<'a, C> {
12730 self._name = new_value.to_string();
12731 self
12732 }
12733 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12734 /// while executing the actual API request.
12735 ///
12736 /// ````text
12737 /// It should be used to handle progress information, and to implement a certain level of resilience.
12738 /// ````
12739 ///
12740 /// Sets the *delegate* property to the given value.
12741 pub fn delegate(
12742 mut self,
12743 new_value: &'a mut dyn common::Delegate,
12744 ) -> ProjectNoteDeleteCall<'a, C> {
12745 self._delegate = Some(new_value);
12746 self
12747 }
12748
12749 /// Set any additional parameter of the query string used in the request.
12750 /// It should be used to set parameters which are not yet available through their own
12751 /// setters.
12752 ///
12753 /// Please note that this method must not be used to set any of the known parameters
12754 /// which have their own setter method. If done anyway, the request will fail.
12755 ///
12756 /// # Additional Parameters
12757 ///
12758 /// * *$.xgafv* (query-string) - V1 error format.
12759 /// * *access_token* (query-string) - OAuth access token.
12760 /// * *alt* (query-string) - Data format for response.
12761 /// * *callback* (query-string) - JSONP
12762 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12763 /// * *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.
12764 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12765 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12766 /// * *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.
12767 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12768 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12769 pub fn param<T>(mut self, name: T, value: T) -> ProjectNoteDeleteCall<'a, C>
12770 where
12771 T: AsRef<str>,
12772 {
12773 self._additional_params
12774 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12775 self
12776 }
12777
12778 /// Identifies the authorization scope for the method you are building.
12779 ///
12780 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12781 /// [`Scope::CloudPlatform`].
12782 ///
12783 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12784 /// tokens for more than one scope.
12785 ///
12786 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12787 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12788 /// sufficient, a read-write scope will do as well.
12789 pub fn add_scope<St>(mut self, scope: St) -> ProjectNoteDeleteCall<'a, C>
12790 where
12791 St: AsRef<str>,
12792 {
12793 self._scopes.insert(String::from(scope.as_ref()));
12794 self
12795 }
12796 /// Identifies the authorization scope(s) for the method you are building.
12797 ///
12798 /// See [`Self::add_scope()`] for details.
12799 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectNoteDeleteCall<'a, C>
12800 where
12801 I: IntoIterator<Item = St>,
12802 St: AsRef<str>,
12803 {
12804 self._scopes
12805 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12806 self
12807 }
12808
12809 /// Removes all scopes, and no default scope will be used either.
12810 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12811 /// for details).
12812 pub fn clear_scopes(mut self) -> ProjectNoteDeleteCall<'a, C> {
12813 self._scopes.clear();
12814 self
12815 }
12816}
12817
12818/// Gets the specified note.
12819///
12820/// A builder for the *notes.get* method supported by a *project* resource.
12821/// It is not used directly, but through a [`ProjectMethods`] instance.
12822///
12823/// # Example
12824///
12825/// Instantiate a resource method builder
12826///
12827/// ```test_harness,no_run
12828/// # extern crate hyper;
12829/// # extern crate hyper_rustls;
12830/// # extern crate google_containeranalysis1 as containeranalysis1;
12831/// # async fn dox() {
12832/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12833///
12834/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12835/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12836/// # .with_native_roots()
12837/// # .unwrap()
12838/// # .https_only()
12839/// # .enable_http2()
12840/// # .build();
12841///
12842/// # let executor = hyper_util::rt::TokioExecutor::new();
12843/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12844/// # secret,
12845/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12846/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12847/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12848/// # ),
12849/// # ).build().await.unwrap();
12850///
12851/// # let client = hyper_util::client::legacy::Client::builder(
12852/// # hyper_util::rt::TokioExecutor::new()
12853/// # )
12854/// # .build(
12855/// # hyper_rustls::HttpsConnectorBuilder::new()
12856/// # .with_native_roots()
12857/// # .unwrap()
12858/// # .https_or_http()
12859/// # .enable_http2()
12860/// # .build()
12861/// # );
12862/// # let mut hub = ContainerAnalysis::new(client, auth);
12863/// // You can configure optional parameters by calling the respective setters at will, and
12864/// // execute the final call using `doit()`.
12865/// // Values shown here are possibly random and not representative !
12866/// let result = hub.projects().notes_get("name")
12867/// .doit().await;
12868/// # }
12869/// ```
12870pub struct ProjectNoteGetCall<'a, C>
12871where
12872 C: 'a,
12873{
12874 hub: &'a ContainerAnalysis<C>,
12875 _name: String,
12876 _delegate: Option<&'a mut dyn common::Delegate>,
12877 _additional_params: HashMap<String, String>,
12878 _scopes: BTreeSet<String>,
12879}
12880
12881impl<'a, C> common::CallBuilder for ProjectNoteGetCall<'a, C> {}
12882
12883impl<'a, C> ProjectNoteGetCall<'a, C>
12884where
12885 C: common::Connector,
12886{
12887 /// Perform the operation you have build so far.
12888 pub async fn doit(mut self) -> common::Result<(common::Response, Note)> {
12889 use std::borrow::Cow;
12890 use std::io::{Read, Seek};
12891
12892 use common::{url::Params, ToParts};
12893 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12894
12895 let mut dd = common::DefaultDelegate;
12896 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12897 dlg.begin(common::MethodInfo {
12898 id: "containeranalysis.projects.notes.get",
12899 http_method: hyper::Method::GET,
12900 });
12901
12902 for &field in ["alt", "name"].iter() {
12903 if self._additional_params.contains_key(field) {
12904 dlg.finished(false);
12905 return Err(common::Error::FieldClash(field));
12906 }
12907 }
12908
12909 let mut params = Params::with_capacity(3 + self._additional_params.len());
12910 params.push("name", self._name);
12911
12912 params.extend(self._additional_params.iter());
12913
12914 params.push("alt", "json");
12915 let mut url = self.hub._base_url.clone() + "v1/{+name}";
12916 if self._scopes.is_empty() {
12917 self._scopes
12918 .insert(Scope::CloudPlatform.as_ref().to_string());
12919 }
12920
12921 #[allow(clippy::single_element_loop)]
12922 for &(find_this, param_name) in [("{+name}", "name")].iter() {
12923 url = params.uri_replacement(url, param_name, find_this, true);
12924 }
12925 {
12926 let to_remove = ["name"];
12927 params.remove_params(&to_remove);
12928 }
12929
12930 let url = params.parse_with_url(&url);
12931
12932 loop {
12933 let token = match self
12934 .hub
12935 .auth
12936 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12937 .await
12938 {
12939 Ok(token) => token,
12940 Err(e) => match dlg.token(e) {
12941 Ok(token) => token,
12942 Err(e) => {
12943 dlg.finished(false);
12944 return Err(common::Error::MissingToken(e));
12945 }
12946 },
12947 };
12948 let mut req_result = {
12949 let client = &self.hub.client;
12950 dlg.pre_request();
12951 let mut req_builder = hyper::Request::builder()
12952 .method(hyper::Method::GET)
12953 .uri(url.as_str())
12954 .header(USER_AGENT, self.hub._user_agent.clone());
12955
12956 if let Some(token) = token.as_ref() {
12957 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12958 }
12959
12960 let request = req_builder
12961 .header(CONTENT_LENGTH, 0_u64)
12962 .body(common::to_body::<String>(None));
12963
12964 client.request(request.unwrap()).await
12965 };
12966
12967 match req_result {
12968 Err(err) => {
12969 if let common::Retry::After(d) = dlg.http_error(&err) {
12970 sleep(d).await;
12971 continue;
12972 }
12973 dlg.finished(false);
12974 return Err(common::Error::HttpError(err));
12975 }
12976 Ok(res) => {
12977 let (mut parts, body) = res.into_parts();
12978 let mut body = common::Body::new(body);
12979 if !parts.status.is_success() {
12980 let bytes = common::to_bytes(body).await.unwrap_or_default();
12981 let error = serde_json::from_str(&common::to_string(&bytes));
12982 let response = common::to_response(parts, bytes.into());
12983
12984 if let common::Retry::After(d) =
12985 dlg.http_failure(&response, error.as_ref().ok())
12986 {
12987 sleep(d).await;
12988 continue;
12989 }
12990
12991 dlg.finished(false);
12992
12993 return Err(match error {
12994 Ok(value) => common::Error::BadRequest(value),
12995 _ => common::Error::Failure(response),
12996 });
12997 }
12998 let response = {
12999 let bytes = common::to_bytes(body).await.unwrap_or_default();
13000 let encoded = common::to_string(&bytes);
13001 match serde_json::from_str(&encoded) {
13002 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13003 Err(error) => {
13004 dlg.response_json_decode_error(&encoded, &error);
13005 return Err(common::Error::JsonDecodeError(
13006 encoded.to_string(),
13007 error,
13008 ));
13009 }
13010 }
13011 };
13012
13013 dlg.finished(true);
13014 return Ok(response);
13015 }
13016 }
13017 }
13018 }
13019
13020 /// Required. The name of the note in the form of `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.
13021 ///
13022 /// Sets the *name* path property to the given value.
13023 ///
13024 /// Even though the property as already been set when instantiating this call,
13025 /// we provide this method for API completeness.
13026 pub fn name(mut self, new_value: &str) -> ProjectNoteGetCall<'a, C> {
13027 self._name = new_value.to_string();
13028 self
13029 }
13030 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13031 /// while executing the actual API request.
13032 ///
13033 /// ````text
13034 /// It should be used to handle progress information, and to implement a certain level of resilience.
13035 /// ````
13036 ///
13037 /// Sets the *delegate* property to the given value.
13038 pub fn delegate(
13039 mut self,
13040 new_value: &'a mut dyn common::Delegate,
13041 ) -> ProjectNoteGetCall<'a, C> {
13042 self._delegate = Some(new_value);
13043 self
13044 }
13045
13046 /// Set any additional parameter of the query string used in the request.
13047 /// It should be used to set parameters which are not yet available through their own
13048 /// setters.
13049 ///
13050 /// Please note that this method must not be used to set any of the known parameters
13051 /// which have their own setter method. If done anyway, the request will fail.
13052 ///
13053 /// # Additional Parameters
13054 ///
13055 /// * *$.xgafv* (query-string) - V1 error format.
13056 /// * *access_token* (query-string) - OAuth access token.
13057 /// * *alt* (query-string) - Data format for response.
13058 /// * *callback* (query-string) - JSONP
13059 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13060 /// * *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.
13061 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13062 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13063 /// * *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.
13064 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13065 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13066 pub fn param<T>(mut self, name: T, value: T) -> ProjectNoteGetCall<'a, C>
13067 where
13068 T: AsRef<str>,
13069 {
13070 self._additional_params
13071 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13072 self
13073 }
13074
13075 /// Identifies the authorization scope for the method you are building.
13076 ///
13077 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13078 /// [`Scope::CloudPlatform`].
13079 ///
13080 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13081 /// tokens for more than one scope.
13082 ///
13083 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13084 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13085 /// sufficient, a read-write scope will do as well.
13086 pub fn add_scope<St>(mut self, scope: St) -> ProjectNoteGetCall<'a, C>
13087 where
13088 St: AsRef<str>,
13089 {
13090 self._scopes.insert(String::from(scope.as_ref()));
13091 self
13092 }
13093 /// Identifies the authorization scope(s) for the method you are building.
13094 ///
13095 /// See [`Self::add_scope()`] for details.
13096 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectNoteGetCall<'a, C>
13097 where
13098 I: IntoIterator<Item = St>,
13099 St: AsRef<str>,
13100 {
13101 self._scopes
13102 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13103 self
13104 }
13105
13106 /// Removes all scopes, and no default scope will be used either.
13107 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13108 /// for details).
13109 pub fn clear_scopes(mut self) -> ProjectNoteGetCall<'a, C> {
13110 self._scopes.clear();
13111 self
13112 }
13113}
13114
13115/// 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.
13116///
13117/// A builder for the *notes.getIamPolicy* method supported by a *project* resource.
13118/// It is not used directly, but through a [`ProjectMethods`] instance.
13119///
13120/// # Example
13121///
13122/// Instantiate a resource method builder
13123///
13124/// ```test_harness,no_run
13125/// # extern crate hyper;
13126/// # extern crate hyper_rustls;
13127/// # extern crate google_containeranalysis1 as containeranalysis1;
13128/// use containeranalysis1::api::GetIamPolicyRequest;
13129/// # async fn dox() {
13130/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13131///
13132/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13133/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13134/// # .with_native_roots()
13135/// # .unwrap()
13136/// # .https_only()
13137/// # .enable_http2()
13138/// # .build();
13139///
13140/// # let executor = hyper_util::rt::TokioExecutor::new();
13141/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13142/// # secret,
13143/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13144/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13145/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13146/// # ),
13147/// # ).build().await.unwrap();
13148///
13149/// # let client = hyper_util::client::legacy::Client::builder(
13150/// # hyper_util::rt::TokioExecutor::new()
13151/// # )
13152/// # .build(
13153/// # hyper_rustls::HttpsConnectorBuilder::new()
13154/// # .with_native_roots()
13155/// # .unwrap()
13156/// # .https_or_http()
13157/// # .enable_http2()
13158/// # .build()
13159/// # );
13160/// # let mut hub = ContainerAnalysis::new(client, auth);
13161/// // As the method needs a request, you would usually fill it with the desired information
13162/// // into the respective structure. Some of the parts shown here might not be applicable !
13163/// // Values shown here are possibly random and not representative !
13164/// let mut req = GetIamPolicyRequest::default();
13165///
13166/// // You can configure optional parameters by calling the respective setters at will, and
13167/// // execute the final call using `doit()`.
13168/// // Values shown here are possibly random and not representative !
13169/// let result = hub.projects().notes_get_iam_policy(req, "resource")
13170/// .doit().await;
13171/// # }
13172/// ```
13173pub struct ProjectNoteGetIamPolicyCall<'a, C>
13174where
13175 C: 'a,
13176{
13177 hub: &'a ContainerAnalysis<C>,
13178 _request: GetIamPolicyRequest,
13179 _resource: String,
13180 _delegate: Option<&'a mut dyn common::Delegate>,
13181 _additional_params: HashMap<String, String>,
13182 _scopes: BTreeSet<String>,
13183}
13184
13185impl<'a, C> common::CallBuilder for ProjectNoteGetIamPolicyCall<'a, C> {}
13186
13187impl<'a, C> ProjectNoteGetIamPolicyCall<'a, C>
13188where
13189 C: common::Connector,
13190{
13191 /// Perform the operation you have build so far.
13192 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
13193 use std::borrow::Cow;
13194 use std::io::{Read, Seek};
13195
13196 use common::{url::Params, ToParts};
13197 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13198
13199 let mut dd = common::DefaultDelegate;
13200 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13201 dlg.begin(common::MethodInfo {
13202 id: "containeranalysis.projects.notes.getIamPolicy",
13203 http_method: hyper::Method::POST,
13204 });
13205
13206 for &field in ["alt", "resource"].iter() {
13207 if self._additional_params.contains_key(field) {
13208 dlg.finished(false);
13209 return Err(common::Error::FieldClash(field));
13210 }
13211 }
13212
13213 let mut params = Params::with_capacity(4 + self._additional_params.len());
13214 params.push("resource", self._resource);
13215
13216 params.extend(self._additional_params.iter());
13217
13218 params.push("alt", "json");
13219 let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
13220 if self._scopes.is_empty() {
13221 self._scopes
13222 .insert(Scope::CloudPlatform.as_ref().to_string());
13223 }
13224
13225 #[allow(clippy::single_element_loop)]
13226 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
13227 url = params.uri_replacement(url, param_name, find_this, true);
13228 }
13229 {
13230 let to_remove = ["resource"];
13231 params.remove_params(&to_remove);
13232 }
13233
13234 let url = params.parse_with_url(&url);
13235
13236 let mut json_mime_type = mime::APPLICATION_JSON;
13237 let mut request_value_reader = {
13238 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13239 common::remove_json_null_values(&mut value);
13240 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13241 serde_json::to_writer(&mut dst, &value).unwrap();
13242 dst
13243 };
13244 let request_size = request_value_reader
13245 .seek(std::io::SeekFrom::End(0))
13246 .unwrap();
13247 request_value_reader
13248 .seek(std::io::SeekFrom::Start(0))
13249 .unwrap();
13250
13251 loop {
13252 let token = match self
13253 .hub
13254 .auth
13255 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13256 .await
13257 {
13258 Ok(token) => token,
13259 Err(e) => match dlg.token(e) {
13260 Ok(token) => token,
13261 Err(e) => {
13262 dlg.finished(false);
13263 return Err(common::Error::MissingToken(e));
13264 }
13265 },
13266 };
13267 request_value_reader
13268 .seek(std::io::SeekFrom::Start(0))
13269 .unwrap();
13270 let mut req_result = {
13271 let client = &self.hub.client;
13272 dlg.pre_request();
13273 let mut req_builder = hyper::Request::builder()
13274 .method(hyper::Method::POST)
13275 .uri(url.as_str())
13276 .header(USER_AGENT, self.hub._user_agent.clone());
13277
13278 if let Some(token) = token.as_ref() {
13279 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13280 }
13281
13282 let request = req_builder
13283 .header(CONTENT_TYPE, json_mime_type.to_string())
13284 .header(CONTENT_LENGTH, request_size as u64)
13285 .body(common::to_body(
13286 request_value_reader.get_ref().clone().into(),
13287 ));
13288
13289 client.request(request.unwrap()).await
13290 };
13291
13292 match req_result {
13293 Err(err) => {
13294 if let common::Retry::After(d) = dlg.http_error(&err) {
13295 sleep(d).await;
13296 continue;
13297 }
13298 dlg.finished(false);
13299 return Err(common::Error::HttpError(err));
13300 }
13301 Ok(res) => {
13302 let (mut parts, body) = res.into_parts();
13303 let mut body = common::Body::new(body);
13304 if !parts.status.is_success() {
13305 let bytes = common::to_bytes(body).await.unwrap_or_default();
13306 let error = serde_json::from_str(&common::to_string(&bytes));
13307 let response = common::to_response(parts, bytes.into());
13308
13309 if let common::Retry::After(d) =
13310 dlg.http_failure(&response, error.as_ref().ok())
13311 {
13312 sleep(d).await;
13313 continue;
13314 }
13315
13316 dlg.finished(false);
13317
13318 return Err(match error {
13319 Ok(value) => common::Error::BadRequest(value),
13320 _ => common::Error::Failure(response),
13321 });
13322 }
13323 let response = {
13324 let bytes = common::to_bytes(body).await.unwrap_or_default();
13325 let encoded = common::to_string(&bytes);
13326 match serde_json::from_str(&encoded) {
13327 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13328 Err(error) => {
13329 dlg.response_json_decode_error(&encoded, &error);
13330 return Err(common::Error::JsonDecodeError(
13331 encoded.to_string(),
13332 error,
13333 ));
13334 }
13335 }
13336 };
13337
13338 dlg.finished(true);
13339 return Ok(response);
13340 }
13341 }
13342 }
13343 }
13344
13345 ///
13346 /// Sets the *request* property to the given value.
13347 ///
13348 /// Even though the property as already been set when instantiating this call,
13349 /// we provide this method for API completeness.
13350 pub fn request(mut self, new_value: GetIamPolicyRequest) -> ProjectNoteGetIamPolicyCall<'a, C> {
13351 self._request = new_value;
13352 self
13353 }
13354 /// 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.
13355 ///
13356 /// Sets the *resource* path property to the given value.
13357 ///
13358 /// Even though the property as already been set when instantiating this call,
13359 /// we provide this method for API completeness.
13360 pub fn resource(mut self, new_value: &str) -> ProjectNoteGetIamPolicyCall<'a, C> {
13361 self._resource = new_value.to_string();
13362 self
13363 }
13364 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13365 /// while executing the actual API request.
13366 ///
13367 /// ````text
13368 /// It should be used to handle progress information, and to implement a certain level of resilience.
13369 /// ````
13370 ///
13371 /// Sets the *delegate* property to the given value.
13372 pub fn delegate(
13373 mut self,
13374 new_value: &'a mut dyn common::Delegate,
13375 ) -> ProjectNoteGetIamPolicyCall<'a, C> {
13376 self._delegate = Some(new_value);
13377 self
13378 }
13379
13380 /// Set any additional parameter of the query string used in the request.
13381 /// It should be used to set parameters which are not yet available through their own
13382 /// setters.
13383 ///
13384 /// Please note that this method must not be used to set any of the known parameters
13385 /// which have their own setter method. If done anyway, the request will fail.
13386 ///
13387 /// # Additional Parameters
13388 ///
13389 /// * *$.xgafv* (query-string) - V1 error format.
13390 /// * *access_token* (query-string) - OAuth access token.
13391 /// * *alt* (query-string) - Data format for response.
13392 /// * *callback* (query-string) - JSONP
13393 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13394 /// * *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.
13395 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13396 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13397 /// * *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.
13398 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13399 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13400 pub fn param<T>(mut self, name: T, value: T) -> ProjectNoteGetIamPolicyCall<'a, C>
13401 where
13402 T: AsRef<str>,
13403 {
13404 self._additional_params
13405 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13406 self
13407 }
13408
13409 /// Identifies the authorization scope for the method you are building.
13410 ///
13411 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13412 /// [`Scope::CloudPlatform`].
13413 ///
13414 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13415 /// tokens for more than one scope.
13416 ///
13417 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13418 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13419 /// sufficient, a read-write scope will do as well.
13420 pub fn add_scope<St>(mut self, scope: St) -> ProjectNoteGetIamPolicyCall<'a, C>
13421 where
13422 St: AsRef<str>,
13423 {
13424 self._scopes.insert(String::from(scope.as_ref()));
13425 self
13426 }
13427 /// Identifies the authorization scope(s) for the method you are building.
13428 ///
13429 /// See [`Self::add_scope()`] for details.
13430 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectNoteGetIamPolicyCall<'a, C>
13431 where
13432 I: IntoIterator<Item = St>,
13433 St: AsRef<str>,
13434 {
13435 self._scopes
13436 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13437 self
13438 }
13439
13440 /// Removes all scopes, and no default scope will be used either.
13441 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13442 /// for details).
13443 pub fn clear_scopes(mut self) -> ProjectNoteGetIamPolicyCall<'a, C> {
13444 self._scopes.clear();
13445 self
13446 }
13447}
13448
13449/// Lists notes for the specified project.
13450///
13451/// A builder for the *notes.list* method supported by a *project* resource.
13452/// It is not used directly, but through a [`ProjectMethods`] instance.
13453///
13454/// # Example
13455///
13456/// Instantiate a resource method builder
13457///
13458/// ```test_harness,no_run
13459/// # extern crate hyper;
13460/// # extern crate hyper_rustls;
13461/// # extern crate google_containeranalysis1 as containeranalysis1;
13462/// # async fn dox() {
13463/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13464///
13465/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13466/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13467/// # .with_native_roots()
13468/// # .unwrap()
13469/// # .https_only()
13470/// # .enable_http2()
13471/// # .build();
13472///
13473/// # let executor = hyper_util::rt::TokioExecutor::new();
13474/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13475/// # secret,
13476/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13477/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13478/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13479/// # ),
13480/// # ).build().await.unwrap();
13481///
13482/// # let client = hyper_util::client::legacy::Client::builder(
13483/// # hyper_util::rt::TokioExecutor::new()
13484/// # )
13485/// # .build(
13486/// # hyper_rustls::HttpsConnectorBuilder::new()
13487/// # .with_native_roots()
13488/// # .unwrap()
13489/// # .https_or_http()
13490/// # .enable_http2()
13491/// # .build()
13492/// # );
13493/// # let mut hub = ContainerAnalysis::new(client, auth);
13494/// // You can configure optional parameters by calling the respective setters at will, and
13495/// // execute the final call using `doit()`.
13496/// // Values shown here are possibly random and not representative !
13497/// let result = hub.projects().notes_list("parent")
13498/// .return_partial_success(false)
13499/// .page_token("diam")
13500/// .page_size(-49)
13501/// .filter("et")
13502/// .doit().await;
13503/// # }
13504/// ```
13505pub struct ProjectNoteListCall<'a, C>
13506where
13507 C: 'a,
13508{
13509 hub: &'a ContainerAnalysis<C>,
13510 _parent: String,
13511 _return_partial_success: Option<bool>,
13512 _page_token: Option<String>,
13513 _page_size: Option<i32>,
13514 _filter: Option<String>,
13515 _delegate: Option<&'a mut dyn common::Delegate>,
13516 _additional_params: HashMap<String, String>,
13517 _scopes: BTreeSet<String>,
13518}
13519
13520impl<'a, C> common::CallBuilder for ProjectNoteListCall<'a, C> {}
13521
13522impl<'a, C> ProjectNoteListCall<'a, C>
13523where
13524 C: common::Connector,
13525{
13526 /// Perform the operation you have build so far.
13527 pub async fn doit(mut self) -> common::Result<(common::Response, ListNotesResponse)> {
13528 use std::borrow::Cow;
13529 use std::io::{Read, Seek};
13530
13531 use common::{url::Params, ToParts};
13532 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13533
13534 let mut dd = common::DefaultDelegate;
13535 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13536 dlg.begin(common::MethodInfo {
13537 id: "containeranalysis.projects.notes.list",
13538 http_method: hyper::Method::GET,
13539 });
13540
13541 for &field in [
13542 "alt",
13543 "parent",
13544 "returnPartialSuccess",
13545 "pageToken",
13546 "pageSize",
13547 "filter",
13548 ]
13549 .iter()
13550 {
13551 if self._additional_params.contains_key(field) {
13552 dlg.finished(false);
13553 return Err(common::Error::FieldClash(field));
13554 }
13555 }
13556
13557 let mut params = Params::with_capacity(7 + self._additional_params.len());
13558 params.push("parent", self._parent);
13559 if let Some(value) = self._return_partial_success.as_ref() {
13560 params.push("returnPartialSuccess", value.to_string());
13561 }
13562 if let Some(value) = self._page_token.as_ref() {
13563 params.push("pageToken", value);
13564 }
13565 if let Some(value) = self._page_size.as_ref() {
13566 params.push("pageSize", value.to_string());
13567 }
13568 if let Some(value) = self._filter.as_ref() {
13569 params.push("filter", value);
13570 }
13571
13572 params.extend(self._additional_params.iter());
13573
13574 params.push("alt", "json");
13575 let mut url = self.hub._base_url.clone() + "v1/{+parent}/notes";
13576 if self._scopes.is_empty() {
13577 self._scopes
13578 .insert(Scope::CloudPlatform.as_ref().to_string());
13579 }
13580
13581 #[allow(clippy::single_element_loop)]
13582 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
13583 url = params.uri_replacement(url, param_name, find_this, true);
13584 }
13585 {
13586 let to_remove = ["parent"];
13587 params.remove_params(&to_remove);
13588 }
13589
13590 let url = params.parse_with_url(&url);
13591
13592 loop {
13593 let token = match self
13594 .hub
13595 .auth
13596 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13597 .await
13598 {
13599 Ok(token) => token,
13600 Err(e) => match dlg.token(e) {
13601 Ok(token) => token,
13602 Err(e) => {
13603 dlg.finished(false);
13604 return Err(common::Error::MissingToken(e));
13605 }
13606 },
13607 };
13608 let mut req_result = {
13609 let client = &self.hub.client;
13610 dlg.pre_request();
13611 let mut req_builder = hyper::Request::builder()
13612 .method(hyper::Method::GET)
13613 .uri(url.as_str())
13614 .header(USER_AGENT, self.hub._user_agent.clone());
13615
13616 if let Some(token) = token.as_ref() {
13617 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13618 }
13619
13620 let request = req_builder
13621 .header(CONTENT_LENGTH, 0_u64)
13622 .body(common::to_body::<String>(None));
13623
13624 client.request(request.unwrap()).await
13625 };
13626
13627 match req_result {
13628 Err(err) => {
13629 if let common::Retry::After(d) = dlg.http_error(&err) {
13630 sleep(d).await;
13631 continue;
13632 }
13633 dlg.finished(false);
13634 return Err(common::Error::HttpError(err));
13635 }
13636 Ok(res) => {
13637 let (mut parts, body) = res.into_parts();
13638 let mut body = common::Body::new(body);
13639 if !parts.status.is_success() {
13640 let bytes = common::to_bytes(body).await.unwrap_or_default();
13641 let error = serde_json::from_str(&common::to_string(&bytes));
13642 let response = common::to_response(parts, bytes.into());
13643
13644 if let common::Retry::After(d) =
13645 dlg.http_failure(&response, error.as_ref().ok())
13646 {
13647 sleep(d).await;
13648 continue;
13649 }
13650
13651 dlg.finished(false);
13652
13653 return Err(match error {
13654 Ok(value) => common::Error::BadRequest(value),
13655 _ => common::Error::Failure(response),
13656 });
13657 }
13658 let response = {
13659 let bytes = common::to_bytes(body).await.unwrap_or_default();
13660 let encoded = common::to_string(&bytes);
13661 match serde_json::from_str(&encoded) {
13662 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
13663 Err(error) => {
13664 dlg.response_json_decode_error(&encoded, &error);
13665 return Err(common::Error::JsonDecodeError(
13666 encoded.to_string(),
13667 error,
13668 ));
13669 }
13670 }
13671 };
13672
13673 dlg.finished(true);
13674 return Ok(response);
13675 }
13676 }
13677 }
13678 }
13679
13680 /// Required. The name of the project to list notes for in the form of `projects/[PROJECT_ID]`.
13681 ///
13682 /// Sets the *parent* path property to the given value.
13683 ///
13684 /// Even though the property as already been set when instantiating this call,
13685 /// we provide this method for API completeness.
13686 pub fn parent(mut self, new_value: &str) -> ProjectNoteListCall<'a, C> {
13687 self._parent = new_value.to_string();
13688 self
13689 }
13690 /// If set, the request will return all reachable Notes and report all unreachable regions in the `unreachable` field in the response. Only applicable for requests in the global region.
13691 ///
13692 /// Sets the *return partial success* query property to the given value.
13693 pub fn return_partial_success(mut self, new_value: bool) -> ProjectNoteListCall<'a, C> {
13694 self._return_partial_success = Some(new_value);
13695 self
13696 }
13697 /// Token to provide to skip to a particular spot in the list.
13698 ///
13699 /// Sets the *page token* query property to the given value.
13700 pub fn page_token(mut self, new_value: &str) -> ProjectNoteListCall<'a, C> {
13701 self._page_token = Some(new_value.to_string());
13702 self
13703 }
13704 /// 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.
13705 ///
13706 /// Sets the *page size* query property to the given value.
13707 pub fn page_size(mut self, new_value: i32) -> ProjectNoteListCall<'a, C> {
13708 self._page_size = Some(new_value);
13709 self
13710 }
13711 /// The filter expression.
13712 ///
13713 /// Sets the *filter* query property to the given value.
13714 pub fn filter(mut self, new_value: &str) -> ProjectNoteListCall<'a, C> {
13715 self._filter = Some(new_value.to_string());
13716 self
13717 }
13718 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
13719 /// while executing the actual API request.
13720 ///
13721 /// ````text
13722 /// It should be used to handle progress information, and to implement a certain level of resilience.
13723 /// ````
13724 ///
13725 /// Sets the *delegate* property to the given value.
13726 pub fn delegate(
13727 mut self,
13728 new_value: &'a mut dyn common::Delegate,
13729 ) -> ProjectNoteListCall<'a, C> {
13730 self._delegate = Some(new_value);
13731 self
13732 }
13733
13734 /// Set any additional parameter of the query string used in the request.
13735 /// It should be used to set parameters which are not yet available through their own
13736 /// setters.
13737 ///
13738 /// Please note that this method must not be used to set any of the known parameters
13739 /// which have their own setter method. If done anyway, the request will fail.
13740 ///
13741 /// # Additional Parameters
13742 ///
13743 /// * *$.xgafv* (query-string) - V1 error format.
13744 /// * *access_token* (query-string) - OAuth access token.
13745 /// * *alt* (query-string) - Data format for response.
13746 /// * *callback* (query-string) - JSONP
13747 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
13748 /// * *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.
13749 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
13750 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
13751 /// * *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.
13752 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
13753 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
13754 pub fn param<T>(mut self, name: T, value: T) -> ProjectNoteListCall<'a, C>
13755 where
13756 T: AsRef<str>,
13757 {
13758 self._additional_params
13759 .insert(name.as_ref().to_string(), value.as_ref().to_string());
13760 self
13761 }
13762
13763 /// Identifies the authorization scope for the method you are building.
13764 ///
13765 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
13766 /// [`Scope::CloudPlatform`].
13767 ///
13768 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
13769 /// tokens for more than one scope.
13770 ///
13771 /// Usually there is more than one suitable scope to authorize an operation, some of which may
13772 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
13773 /// sufficient, a read-write scope will do as well.
13774 pub fn add_scope<St>(mut self, scope: St) -> ProjectNoteListCall<'a, C>
13775 where
13776 St: AsRef<str>,
13777 {
13778 self._scopes.insert(String::from(scope.as_ref()));
13779 self
13780 }
13781 /// Identifies the authorization scope(s) for the method you are building.
13782 ///
13783 /// See [`Self::add_scope()`] for details.
13784 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectNoteListCall<'a, C>
13785 where
13786 I: IntoIterator<Item = St>,
13787 St: AsRef<str>,
13788 {
13789 self._scopes
13790 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
13791 self
13792 }
13793
13794 /// Removes all scopes, and no default scope will be used either.
13795 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
13796 /// for details).
13797 pub fn clear_scopes(mut self) -> ProjectNoteListCall<'a, C> {
13798 self._scopes.clear();
13799 self
13800 }
13801}
13802
13803/// Updates the specified note.
13804///
13805/// A builder for the *notes.patch* method supported by a *project* resource.
13806/// It is not used directly, but through a [`ProjectMethods`] instance.
13807///
13808/// # Example
13809///
13810/// Instantiate a resource method builder
13811///
13812/// ```test_harness,no_run
13813/// # extern crate hyper;
13814/// # extern crate hyper_rustls;
13815/// # extern crate google_containeranalysis1 as containeranalysis1;
13816/// use containeranalysis1::api::Note;
13817/// # async fn dox() {
13818/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
13819///
13820/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
13821/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
13822/// # .with_native_roots()
13823/// # .unwrap()
13824/// # .https_only()
13825/// # .enable_http2()
13826/// # .build();
13827///
13828/// # let executor = hyper_util::rt::TokioExecutor::new();
13829/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
13830/// # secret,
13831/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
13832/// # yup_oauth2::client::CustomHyperClientBuilder::from(
13833/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
13834/// # ),
13835/// # ).build().await.unwrap();
13836///
13837/// # let client = hyper_util::client::legacy::Client::builder(
13838/// # hyper_util::rt::TokioExecutor::new()
13839/// # )
13840/// # .build(
13841/// # hyper_rustls::HttpsConnectorBuilder::new()
13842/// # .with_native_roots()
13843/// # .unwrap()
13844/// # .https_or_http()
13845/// # .enable_http2()
13846/// # .build()
13847/// # );
13848/// # let mut hub = ContainerAnalysis::new(client, auth);
13849/// // As the method needs a request, you would usually fill it with the desired information
13850/// // into the respective structure. Some of the parts shown here might not be applicable !
13851/// // Values shown here are possibly random and not representative !
13852/// let mut req = Note::default();
13853///
13854/// // You can configure optional parameters by calling the respective setters at will, and
13855/// // execute the final call using `doit()`.
13856/// // Values shown here are possibly random and not representative !
13857/// let result = hub.projects().notes_patch(req, "name")
13858/// .update_mask(FieldMask::new::<&str>(&[]))
13859/// .doit().await;
13860/// # }
13861/// ```
13862pub struct ProjectNotePatchCall<'a, C>
13863where
13864 C: 'a,
13865{
13866 hub: &'a ContainerAnalysis<C>,
13867 _request: Note,
13868 _name: String,
13869 _update_mask: Option<common::FieldMask>,
13870 _delegate: Option<&'a mut dyn common::Delegate>,
13871 _additional_params: HashMap<String, String>,
13872 _scopes: BTreeSet<String>,
13873}
13874
13875impl<'a, C> common::CallBuilder for ProjectNotePatchCall<'a, C> {}
13876
13877impl<'a, C> ProjectNotePatchCall<'a, C>
13878where
13879 C: common::Connector,
13880{
13881 /// Perform the operation you have build so far.
13882 pub async fn doit(mut self) -> common::Result<(common::Response, Note)> {
13883 use std::borrow::Cow;
13884 use std::io::{Read, Seek};
13885
13886 use common::{url::Params, ToParts};
13887 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
13888
13889 let mut dd = common::DefaultDelegate;
13890 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
13891 dlg.begin(common::MethodInfo {
13892 id: "containeranalysis.projects.notes.patch",
13893 http_method: hyper::Method::PATCH,
13894 });
13895
13896 for &field in ["alt", "name", "updateMask"].iter() {
13897 if self._additional_params.contains_key(field) {
13898 dlg.finished(false);
13899 return Err(common::Error::FieldClash(field));
13900 }
13901 }
13902
13903 let mut params = Params::with_capacity(5 + self._additional_params.len());
13904 params.push("name", self._name);
13905 if let Some(value) = self._update_mask.as_ref() {
13906 params.push("updateMask", value.to_string());
13907 }
13908
13909 params.extend(self._additional_params.iter());
13910
13911 params.push("alt", "json");
13912 let mut url = self.hub._base_url.clone() + "v1/{+name}";
13913 if self._scopes.is_empty() {
13914 self._scopes
13915 .insert(Scope::CloudPlatform.as_ref().to_string());
13916 }
13917
13918 #[allow(clippy::single_element_loop)]
13919 for &(find_this, param_name) in [("{+name}", "name")].iter() {
13920 url = params.uri_replacement(url, param_name, find_this, true);
13921 }
13922 {
13923 let to_remove = ["name"];
13924 params.remove_params(&to_remove);
13925 }
13926
13927 let url = params.parse_with_url(&url);
13928
13929 let mut json_mime_type = mime::APPLICATION_JSON;
13930 let mut request_value_reader = {
13931 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
13932 common::remove_json_null_values(&mut value);
13933 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
13934 serde_json::to_writer(&mut dst, &value).unwrap();
13935 dst
13936 };
13937 let request_size = request_value_reader
13938 .seek(std::io::SeekFrom::End(0))
13939 .unwrap();
13940 request_value_reader
13941 .seek(std::io::SeekFrom::Start(0))
13942 .unwrap();
13943
13944 loop {
13945 let token = match self
13946 .hub
13947 .auth
13948 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
13949 .await
13950 {
13951 Ok(token) => token,
13952 Err(e) => match dlg.token(e) {
13953 Ok(token) => token,
13954 Err(e) => {
13955 dlg.finished(false);
13956 return Err(common::Error::MissingToken(e));
13957 }
13958 },
13959 };
13960 request_value_reader
13961 .seek(std::io::SeekFrom::Start(0))
13962 .unwrap();
13963 let mut req_result = {
13964 let client = &self.hub.client;
13965 dlg.pre_request();
13966 let mut req_builder = hyper::Request::builder()
13967 .method(hyper::Method::PATCH)
13968 .uri(url.as_str())
13969 .header(USER_AGENT, self.hub._user_agent.clone());
13970
13971 if let Some(token) = token.as_ref() {
13972 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
13973 }
13974
13975 let request = req_builder
13976 .header(CONTENT_TYPE, json_mime_type.to_string())
13977 .header(CONTENT_LENGTH, request_size as u64)
13978 .body(common::to_body(
13979 request_value_reader.get_ref().clone().into(),
13980 ));
13981
13982 client.request(request.unwrap()).await
13983 };
13984
13985 match req_result {
13986 Err(err) => {
13987 if let common::Retry::After(d) = dlg.http_error(&err) {
13988 sleep(d).await;
13989 continue;
13990 }
13991 dlg.finished(false);
13992 return Err(common::Error::HttpError(err));
13993 }
13994 Ok(res) => {
13995 let (mut parts, body) = res.into_parts();
13996 let mut body = common::Body::new(body);
13997 if !parts.status.is_success() {
13998 let bytes = common::to_bytes(body).await.unwrap_or_default();
13999 let error = serde_json::from_str(&common::to_string(&bytes));
14000 let response = common::to_response(parts, bytes.into());
14001
14002 if let common::Retry::After(d) =
14003 dlg.http_failure(&response, error.as_ref().ok())
14004 {
14005 sleep(d).await;
14006 continue;
14007 }
14008
14009 dlg.finished(false);
14010
14011 return Err(match error {
14012 Ok(value) => common::Error::BadRequest(value),
14013 _ => common::Error::Failure(response),
14014 });
14015 }
14016 let response = {
14017 let bytes = common::to_bytes(body).await.unwrap_or_default();
14018 let encoded = common::to_string(&bytes);
14019 match serde_json::from_str(&encoded) {
14020 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14021 Err(error) => {
14022 dlg.response_json_decode_error(&encoded, &error);
14023 return Err(common::Error::JsonDecodeError(
14024 encoded.to_string(),
14025 error,
14026 ));
14027 }
14028 }
14029 };
14030
14031 dlg.finished(true);
14032 return Ok(response);
14033 }
14034 }
14035 }
14036 }
14037
14038 ///
14039 /// Sets the *request* property to the given value.
14040 ///
14041 /// Even though the property as already been set when instantiating this call,
14042 /// we provide this method for API completeness.
14043 pub fn request(mut self, new_value: Note) -> ProjectNotePatchCall<'a, C> {
14044 self._request = new_value;
14045 self
14046 }
14047 /// Required. The name of the note in the form of `projects/[PROVIDER_ID]/notes/[NOTE_ID]`.
14048 ///
14049 /// Sets the *name* path property to the given value.
14050 ///
14051 /// Even though the property as already been set when instantiating this call,
14052 /// we provide this method for API completeness.
14053 pub fn name(mut self, new_value: &str) -> ProjectNotePatchCall<'a, C> {
14054 self._name = new_value.to_string();
14055 self
14056 }
14057 /// The fields to update.
14058 ///
14059 /// Sets the *update mask* query property to the given value.
14060 pub fn update_mask(mut self, new_value: common::FieldMask) -> ProjectNotePatchCall<'a, C> {
14061 self._update_mask = Some(new_value);
14062 self
14063 }
14064 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14065 /// while executing the actual API request.
14066 ///
14067 /// ````text
14068 /// It should be used to handle progress information, and to implement a certain level of resilience.
14069 /// ````
14070 ///
14071 /// Sets the *delegate* property to the given value.
14072 pub fn delegate(
14073 mut self,
14074 new_value: &'a mut dyn common::Delegate,
14075 ) -> ProjectNotePatchCall<'a, C> {
14076 self._delegate = Some(new_value);
14077 self
14078 }
14079
14080 /// Set any additional parameter of the query string used in the request.
14081 /// It should be used to set parameters which are not yet available through their own
14082 /// setters.
14083 ///
14084 /// Please note that this method must not be used to set any of the known parameters
14085 /// which have their own setter method. If done anyway, the request will fail.
14086 ///
14087 /// # Additional Parameters
14088 ///
14089 /// * *$.xgafv* (query-string) - V1 error format.
14090 /// * *access_token* (query-string) - OAuth access token.
14091 /// * *alt* (query-string) - Data format for response.
14092 /// * *callback* (query-string) - JSONP
14093 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14094 /// * *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.
14095 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14096 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14097 /// * *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.
14098 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14099 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14100 pub fn param<T>(mut self, name: T, value: T) -> ProjectNotePatchCall<'a, C>
14101 where
14102 T: AsRef<str>,
14103 {
14104 self._additional_params
14105 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14106 self
14107 }
14108
14109 /// Identifies the authorization scope for the method you are building.
14110 ///
14111 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14112 /// [`Scope::CloudPlatform`].
14113 ///
14114 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14115 /// tokens for more than one scope.
14116 ///
14117 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14118 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14119 /// sufficient, a read-write scope will do as well.
14120 pub fn add_scope<St>(mut self, scope: St) -> ProjectNotePatchCall<'a, C>
14121 where
14122 St: AsRef<str>,
14123 {
14124 self._scopes.insert(String::from(scope.as_ref()));
14125 self
14126 }
14127 /// Identifies the authorization scope(s) for the method you are building.
14128 ///
14129 /// See [`Self::add_scope()`] for details.
14130 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectNotePatchCall<'a, C>
14131 where
14132 I: IntoIterator<Item = St>,
14133 St: AsRef<str>,
14134 {
14135 self._scopes
14136 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14137 self
14138 }
14139
14140 /// Removes all scopes, and no default scope will be used either.
14141 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14142 /// for details).
14143 pub fn clear_scopes(mut self) -> ProjectNotePatchCall<'a, C> {
14144 self._scopes.clear();
14145 self
14146 }
14147}
14148
14149/// 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.
14150///
14151/// A builder for the *notes.setIamPolicy* method supported by a *project* resource.
14152/// It is not used directly, but through a [`ProjectMethods`] instance.
14153///
14154/// # Example
14155///
14156/// Instantiate a resource method builder
14157///
14158/// ```test_harness,no_run
14159/// # extern crate hyper;
14160/// # extern crate hyper_rustls;
14161/// # extern crate google_containeranalysis1 as containeranalysis1;
14162/// use containeranalysis1::api::SetIamPolicyRequest;
14163/// # async fn dox() {
14164/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14165///
14166/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14167/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14168/// # .with_native_roots()
14169/// # .unwrap()
14170/// # .https_only()
14171/// # .enable_http2()
14172/// # .build();
14173///
14174/// # let executor = hyper_util::rt::TokioExecutor::new();
14175/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14176/// # secret,
14177/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14178/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14179/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14180/// # ),
14181/// # ).build().await.unwrap();
14182///
14183/// # let client = hyper_util::client::legacy::Client::builder(
14184/// # hyper_util::rt::TokioExecutor::new()
14185/// # )
14186/// # .build(
14187/// # hyper_rustls::HttpsConnectorBuilder::new()
14188/// # .with_native_roots()
14189/// # .unwrap()
14190/// # .https_or_http()
14191/// # .enable_http2()
14192/// # .build()
14193/// # );
14194/// # let mut hub = ContainerAnalysis::new(client, auth);
14195/// // As the method needs a request, you would usually fill it with the desired information
14196/// // into the respective structure. Some of the parts shown here might not be applicable !
14197/// // Values shown here are possibly random and not representative !
14198/// let mut req = SetIamPolicyRequest::default();
14199///
14200/// // You can configure optional parameters by calling the respective setters at will, and
14201/// // execute the final call using `doit()`.
14202/// // Values shown here are possibly random and not representative !
14203/// let result = hub.projects().notes_set_iam_policy(req, "resource")
14204/// .doit().await;
14205/// # }
14206/// ```
14207pub struct ProjectNoteSetIamPolicyCall<'a, C>
14208where
14209 C: 'a,
14210{
14211 hub: &'a ContainerAnalysis<C>,
14212 _request: SetIamPolicyRequest,
14213 _resource: String,
14214 _delegate: Option<&'a mut dyn common::Delegate>,
14215 _additional_params: HashMap<String, String>,
14216 _scopes: BTreeSet<String>,
14217}
14218
14219impl<'a, C> common::CallBuilder for ProjectNoteSetIamPolicyCall<'a, C> {}
14220
14221impl<'a, C> ProjectNoteSetIamPolicyCall<'a, C>
14222where
14223 C: common::Connector,
14224{
14225 /// Perform the operation you have build so far.
14226 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
14227 use std::borrow::Cow;
14228 use std::io::{Read, Seek};
14229
14230 use common::{url::Params, ToParts};
14231 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14232
14233 let mut dd = common::DefaultDelegate;
14234 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14235 dlg.begin(common::MethodInfo {
14236 id: "containeranalysis.projects.notes.setIamPolicy",
14237 http_method: hyper::Method::POST,
14238 });
14239
14240 for &field in ["alt", "resource"].iter() {
14241 if self._additional_params.contains_key(field) {
14242 dlg.finished(false);
14243 return Err(common::Error::FieldClash(field));
14244 }
14245 }
14246
14247 let mut params = Params::with_capacity(4 + self._additional_params.len());
14248 params.push("resource", self._resource);
14249
14250 params.extend(self._additional_params.iter());
14251
14252 params.push("alt", "json");
14253 let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
14254 if self._scopes.is_empty() {
14255 self._scopes
14256 .insert(Scope::CloudPlatform.as_ref().to_string());
14257 }
14258
14259 #[allow(clippy::single_element_loop)]
14260 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
14261 url = params.uri_replacement(url, param_name, find_this, true);
14262 }
14263 {
14264 let to_remove = ["resource"];
14265 params.remove_params(&to_remove);
14266 }
14267
14268 let url = params.parse_with_url(&url);
14269
14270 let mut json_mime_type = mime::APPLICATION_JSON;
14271 let mut request_value_reader = {
14272 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14273 common::remove_json_null_values(&mut value);
14274 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14275 serde_json::to_writer(&mut dst, &value).unwrap();
14276 dst
14277 };
14278 let request_size = request_value_reader
14279 .seek(std::io::SeekFrom::End(0))
14280 .unwrap();
14281 request_value_reader
14282 .seek(std::io::SeekFrom::Start(0))
14283 .unwrap();
14284
14285 loop {
14286 let token = match self
14287 .hub
14288 .auth
14289 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14290 .await
14291 {
14292 Ok(token) => token,
14293 Err(e) => match dlg.token(e) {
14294 Ok(token) => token,
14295 Err(e) => {
14296 dlg.finished(false);
14297 return Err(common::Error::MissingToken(e));
14298 }
14299 },
14300 };
14301 request_value_reader
14302 .seek(std::io::SeekFrom::Start(0))
14303 .unwrap();
14304 let mut req_result = {
14305 let client = &self.hub.client;
14306 dlg.pre_request();
14307 let mut req_builder = hyper::Request::builder()
14308 .method(hyper::Method::POST)
14309 .uri(url.as_str())
14310 .header(USER_AGENT, self.hub._user_agent.clone());
14311
14312 if let Some(token) = token.as_ref() {
14313 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14314 }
14315
14316 let request = req_builder
14317 .header(CONTENT_TYPE, json_mime_type.to_string())
14318 .header(CONTENT_LENGTH, request_size as u64)
14319 .body(common::to_body(
14320 request_value_reader.get_ref().clone().into(),
14321 ));
14322
14323 client.request(request.unwrap()).await
14324 };
14325
14326 match req_result {
14327 Err(err) => {
14328 if let common::Retry::After(d) = dlg.http_error(&err) {
14329 sleep(d).await;
14330 continue;
14331 }
14332 dlg.finished(false);
14333 return Err(common::Error::HttpError(err));
14334 }
14335 Ok(res) => {
14336 let (mut parts, body) = res.into_parts();
14337 let mut body = common::Body::new(body);
14338 if !parts.status.is_success() {
14339 let bytes = common::to_bytes(body).await.unwrap_or_default();
14340 let error = serde_json::from_str(&common::to_string(&bytes));
14341 let response = common::to_response(parts, bytes.into());
14342
14343 if let common::Retry::After(d) =
14344 dlg.http_failure(&response, error.as_ref().ok())
14345 {
14346 sleep(d).await;
14347 continue;
14348 }
14349
14350 dlg.finished(false);
14351
14352 return Err(match error {
14353 Ok(value) => common::Error::BadRequest(value),
14354 _ => common::Error::Failure(response),
14355 });
14356 }
14357 let response = {
14358 let bytes = common::to_bytes(body).await.unwrap_or_default();
14359 let encoded = common::to_string(&bytes);
14360 match serde_json::from_str(&encoded) {
14361 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14362 Err(error) => {
14363 dlg.response_json_decode_error(&encoded, &error);
14364 return Err(common::Error::JsonDecodeError(
14365 encoded.to_string(),
14366 error,
14367 ));
14368 }
14369 }
14370 };
14371
14372 dlg.finished(true);
14373 return Ok(response);
14374 }
14375 }
14376 }
14377 }
14378
14379 ///
14380 /// Sets the *request* property to the given value.
14381 ///
14382 /// Even though the property as already been set when instantiating this call,
14383 /// we provide this method for API completeness.
14384 pub fn request(mut self, new_value: SetIamPolicyRequest) -> ProjectNoteSetIamPolicyCall<'a, C> {
14385 self._request = new_value;
14386 self
14387 }
14388 /// 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.
14389 ///
14390 /// Sets the *resource* path property to the given value.
14391 ///
14392 /// Even though the property as already been set when instantiating this call,
14393 /// we provide this method for API completeness.
14394 pub fn resource(mut self, new_value: &str) -> ProjectNoteSetIamPolicyCall<'a, C> {
14395 self._resource = new_value.to_string();
14396 self
14397 }
14398 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14399 /// while executing the actual API request.
14400 ///
14401 /// ````text
14402 /// It should be used to handle progress information, and to implement a certain level of resilience.
14403 /// ````
14404 ///
14405 /// Sets the *delegate* property to the given value.
14406 pub fn delegate(
14407 mut self,
14408 new_value: &'a mut dyn common::Delegate,
14409 ) -> ProjectNoteSetIamPolicyCall<'a, C> {
14410 self._delegate = Some(new_value);
14411 self
14412 }
14413
14414 /// Set any additional parameter of the query string used in the request.
14415 /// It should be used to set parameters which are not yet available through their own
14416 /// setters.
14417 ///
14418 /// Please note that this method must not be used to set any of the known parameters
14419 /// which have their own setter method. If done anyway, the request will fail.
14420 ///
14421 /// # Additional Parameters
14422 ///
14423 /// * *$.xgafv* (query-string) - V1 error format.
14424 /// * *access_token* (query-string) - OAuth access token.
14425 /// * *alt* (query-string) - Data format for response.
14426 /// * *callback* (query-string) - JSONP
14427 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14428 /// * *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.
14429 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14430 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14431 /// * *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.
14432 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14433 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14434 pub fn param<T>(mut self, name: T, value: T) -> ProjectNoteSetIamPolicyCall<'a, C>
14435 where
14436 T: AsRef<str>,
14437 {
14438 self._additional_params
14439 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14440 self
14441 }
14442
14443 /// Identifies the authorization scope for the method you are building.
14444 ///
14445 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14446 /// [`Scope::CloudPlatform`].
14447 ///
14448 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14449 /// tokens for more than one scope.
14450 ///
14451 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14452 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14453 /// sufficient, a read-write scope will do as well.
14454 pub fn add_scope<St>(mut self, scope: St) -> ProjectNoteSetIamPolicyCall<'a, C>
14455 where
14456 St: AsRef<str>,
14457 {
14458 self._scopes.insert(String::from(scope.as_ref()));
14459 self
14460 }
14461 /// Identifies the authorization scope(s) for the method you are building.
14462 ///
14463 /// See [`Self::add_scope()`] for details.
14464 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectNoteSetIamPolicyCall<'a, C>
14465 where
14466 I: IntoIterator<Item = St>,
14467 St: AsRef<str>,
14468 {
14469 self._scopes
14470 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14471 self
14472 }
14473
14474 /// Removes all scopes, and no default scope will be used either.
14475 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14476 /// for details).
14477 pub fn clear_scopes(mut self) -> ProjectNoteSetIamPolicyCall<'a, C> {
14478 self._scopes.clear();
14479 self
14480 }
14481}
14482
14483/// 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.
14484///
14485/// A builder for the *notes.testIamPermissions* method supported by a *project* resource.
14486/// It is not used directly, but through a [`ProjectMethods`] instance.
14487///
14488/// # Example
14489///
14490/// Instantiate a resource method builder
14491///
14492/// ```test_harness,no_run
14493/// # extern crate hyper;
14494/// # extern crate hyper_rustls;
14495/// # extern crate google_containeranalysis1 as containeranalysis1;
14496/// use containeranalysis1::api::TestIamPermissionsRequest;
14497/// # async fn dox() {
14498/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14499///
14500/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14501/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14502/// # .with_native_roots()
14503/// # .unwrap()
14504/// # .https_only()
14505/// # .enable_http2()
14506/// # .build();
14507///
14508/// # let executor = hyper_util::rt::TokioExecutor::new();
14509/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14510/// # secret,
14511/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14512/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14513/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14514/// # ),
14515/// # ).build().await.unwrap();
14516///
14517/// # let client = hyper_util::client::legacy::Client::builder(
14518/// # hyper_util::rt::TokioExecutor::new()
14519/// # )
14520/// # .build(
14521/// # hyper_rustls::HttpsConnectorBuilder::new()
14522/// # .with_native_roots()
14523/// # .unwrap()
14524/// # .https_or_http()
14525/// # .enable_http2()
14526/// # .build()
14527/// # );
14528/// # let mut hub = ContainerAnalysis::new(client, auth);
14529/// // As the method needs a request, you would usually fill it with the desired information
14530/// // into the respective structure. Some of the parts shown here might not be applicable !
14531/// // Values shown here are possibly random and not representative !
14532/// let mut req = TestIamPermissionsRequest::default();
14533///
14534/// // You can configure optional parameters by calling the respective setters at will, and
14535/// // execute the final call using `doit()`.
14536/// // Values shown here are possibly random and not representative !
14537/// let result = hub.projects().notes_test_iam_permissions(req, "resource")
14538/// .doit().await;
14539/// # }
14540/// ```
14541pub struct ProjectNoteTestIamPermissionCall<'a, C>
14542where
14543 C: 'a,
14544{
14545 hub: &'a ContainerAnalysis<C>,
14546 _request: TestIamPermissionsRequest,
14547 _resource: String,
14548 _delegate: Option<&'a mut dyn common::Delegate>,
14549 _additional_params: HashMap<String, String>,
14550 _scopes: BTreeSet<String>,
14551}
14552
14553impl<'a, C> common::CallBuilder for ProjectNoteTestIamPermissionCall<'a, C> {}
14554
14555impl<'a, C> ProjectNoteTestIamPermissionCall<'a, C>
14556where
14557 C: common::Connector,
14558{
14559 /// Perform the operation you have build so far.
14560 pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
14561 use std::borrow::Cow;
14562 use std::io::{Read, Seek};
14563
14564 use common::{url::Params, ToParts};
14565 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14566
14567 let mut dd = common::DefaultDelegate;
14568 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14569 dlg.begin(common::MethodInfo {
14570 id: "containeranalysis.projects.notes.testIamPermissions",
14571 http_method: hyper::Method::POST,
14572 });
14573
14574 for &field in ["alt", "resource"].iter() {
14575 if self._additional_params.contains_key(field) {
14576 dlg.finished(false);
14577 return Err(common::Error::FieldClash(field));
14578 }
14579 }
14580
14581 let mut params = Params::with_capacity(4 + self._additional_params.len());
14582 params.push("resource", self._resource);
14583
14584 params.extend(self._additional_params.iter());
14585
14586 params.push("alt", "json");
14587 let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
14588 if self._scopes.is_empty() {
14589 self._scopes
14590 .insert(Scope::CloudPlatform.as_ref().to_string());
14591 }
14592
14593 #[allow(clippy::single_element_loop)]
14594 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
14595 url = params.uri_replacement(url, param_name, find_this, true);
14596 }
14597 {
14598 let to_remove = ["resource"];
14599 params.remove_params(&to_remove);
14600 }
14601
14602 let url = params.parse_with_url(&url);
14603
14604 let mut json_mime_type = mime::APPLICATION_JSON;
14605 let mut request_value_reader = {
14606 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14607 common::remove_json_null_values(&mut value);
14608 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14609 serde_json::to_writer(&mut dst, &value).unwrap();
14610 dst
14611 };
14612 let request_size = request_value_reader
14613 .seek(std::io::SeekFrom::End(0))
14614 .unwrap();
14615 request_value_reader
14616 .seek(std::io::SeekFrom::Start(0))
14617 .unwrap();
14618
14619 loop {
14620 let token = match self
14621 .hub
14622 .auth
14623 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14624 .await
14625 {
14626 Ok(token) => token,
14627 Err(e) => match dlg.token(e) {
14628 Ok(token) => token,
14629 Err(e) => {
14630 dlg.finished(false);
14631 return Err(common::Error::MissingToken(e));
14632 }
14633 },
14634 };
14635 request_value_reader
14636 .seek(std::io::SeekFrom::Start(0))
14637 .unwrap();
14638 let mut req_result = {
14639 let client = &self.hub.client;
14640 dlg.pre_request();
14641 let mut req_builder = hyper::Request::builder()
14642 .method(hyper::Method::POST)
14643 .uri(url.as_str())
14644 .header(USER_AGENT, self.hub._user_agent.clone());
14645
14646 if let Some(token) = token.as_ref() {
14647 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14648 }
14649
14650 let request = req_builder
14651 .header(CONTENT_TYPE, json_mime_type.to_string())
14652 .header(CONTENT_LENGTH, request_size as u64)
14653 .body(common::to_body(
14654 request_value_reader.get_ref().clone().into(),
14655 ));
14656
14657 client.request(request.unwrap()).await
14658 };
14659
14660 match req_result {
14661 Err(err) => {
14662 if let common::Retry::After(d) = dlg.http_error(&err) {
14663 sleep(d).await;
14664 continue;
14665 }
14666 dlg.finished(false);
14667 return Err(common::Error::HttpError(err));
14668 }
14669 Ok(res) => {
14670 let (mut parts, body) = res.into_parts();
14671 let mut body = common::Body::new(body);
14672 if !parts.status.is_success() {
14673 let bytes = common::to_bytes(body).await.unwrap_or_default();
14674 let error = serde_json::from_str(&common::to_string(&bytes));
14675 let response = common::to_response(parts, bytes.into());
14676
14677 if let common::Retry::After(d) =
14678 dlg.http_failure(&response, error.as_ref().ok())
14679 {
14680 sleep(d).await;
14681 continue;
14682 }
14683
14684 dlg.finished(false);
14685
14686 return Err(match error {
14687 Ok(value) => common::Error::BadRequest(value),
14688 _ => common::Error::Failure(response),
14689 });
14690 }
14691 let response = {
14692 let bytes = common::to_bytes(body).await.unwrap_or_default();
14693 let encoded = common::to_string(&bytes);
14694 match serde_json::from_str(&encoded) {
14695 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
14696 Err(error) => {
14697 dlg.response_json_decode_error(&encoded, &error);
14698 return Err(common::Error::JsonDecodeError(
14699 encoded.to_string(),
14700 error,
14701 ));
14702 }
14703 }
14704 };
14705
14706 dlg.finished(true);
14707 return Ok(response);
14708 }
14709 }
14710 }
14711 }
14712
14713 ///
14714 /// Sets the *request* property to the given value.
14715 ///
14716 /// Even though the property as already been set when instantiating this call,
14717 /// we provide this method for API completeness.
14718 pub fn request(
14719 mut self,
14720 new_value: TestIamPermissionsRequest,
14721 ) -> ProjectNoteTestIamPermissionCall<'a, C> {
14722 self._request = new_value;
14723 self
14724 }
14725 /// 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.
14726 ///
14727 /// Sets the *resource* path property to the given value.
14728 ///
14729 /// Even though the property as already been set when instantiating this call,
14730 /// we provide this method for API completeness.
14731 pub fn resource(mut self, new_value: &str) -> ProjectNoteTestIamPermissionCall<'a, C> {
14732 self._resource = new_value.to_string();
14733 self
14734 }
14735 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
14736 /// while executing the actual API request.
14737 ///
14738 /// ````text
14739 /// It should be used to handle progress information, and to implement a certain level of resilience.
14740 /// ````
14741 ///
14742 /// Sets the *delegate* property to the given value.
14743 pub fn delegate(
14744 mut self,
14745 new_value: &'a mut dyn common::Delegate,
14746 ) -> ProjectNoteTestIamPermissionCall<'a, C> {
14747 self._delegate = Some(new_value);
14748 self
14749 }
14750
14751 /// Set any additional parameter of the query string used in the request.
14752 /// It should be used to set parameters which are not yet available through their own
14753 /// setters.
14754 ///
14755 /// Please note that this method must not be used to set any of the known parameters
14756 /// which have their own setter method. If done anyway, the request will fail.
14757 ///
14758 /// # Additional Parameters
14759 ///
14760 /// * *$.xgafv* (query-string) - V1 error format.
14761 /// * *access_token* (query-string) - OAuth access token.
14762 /// * *alt* (query-string) - Data format for response.
14763 /// * *callback* (query-string) - JSONP
14764 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
14765 /// * *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.
14766 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
14767 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
14768 /// * *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.
14769 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
14770 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
14771 pub fn param<T>(mut self, name: T, value: T) -> ProjectNoteTestIamPermissionCall<'a, C>
14772 where
14773 T: AsRef<str>,
14774 {
14775 self._additional_params
14776 .insert(name.as_ref().to_string(), value.as_ref().to_string());
14777 self
14778 }
14779
14780 /// Identifies the authorization scope for the method you are building.
14781 ///
14782 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
14783 /// [`Scope::CloudPlatform`].
14784 ///
14785 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
14786 /// tokens for more than one scope.
14787 ///
14788 /// Usually there is more than one suitable scope to authorize an operation, some of which may
14789 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
14790 /// sufficient, a read-write scope will do as well.
14791 pub fn add_scope<St>(mut self, scope: St) -> ProjectNoteTestIamPermissionCall<'a, C>
14792 where
14793 St: AsRef<str>,
14794 {
14795 self._scopes.insert(String::from(scope.as_ref()));
14796 self
14797 }
14798 /// Identifies the authorization scope(s) for the method you are building.
14799 ///
14800 /// See [`Self::add_scope()`] for details.
14801 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectNoteTestIamPermissionCall<'a, C>
14802 where
14803 I: IntoIterator<Item = St>,
14804 St: AsRef<str>,
14805 {
14806 self._scopes
14807 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
14808 self
14809 }
14810
14811 /// Removes all scopes, and no default scope will be used either.
14812 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
14813 /// for details).
14814 pub fn clear_scopes(mut self) -> ProjectNoteTestIamPermissionCall<'a, C> {
14815 self._scopes.clear();
14816 self
14817 }
14818}
14819
14820/// Creates new occurrences in batch.
14821///
14822/// A builder for the *occurrences.batchCreate* method supported by a *project* resource.
14823/// It is not used directly, but through a [`ProjectMethods`] instance.
14824///
14825/// # Example
14826///
14827/// Instantiate a resource method builder
14828///
14829/// ```test_harness,no_run
14830/// # extern crate hyper;
14831/// # extern crate hyper_rustls;
14832/// # extern crate google_containeranalysis1 as containeranalysis1;
14833/// use containeranalysis1::api::BatchCreateOccurrencesRequest;
14834/// # async fn dox() {
14835/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
14836///
14837/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
14838/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
14839/// # .with_native_roots()
14840/// # .unwrap()
14841/// # .https_only()
14842/// # .enable_http2()
14843/// # .build();
14844///
14845/// # let executor = hyper_util::rt::TokioExecutor::new();
14846/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
14847/// # secret,
14848/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
14849/// # yup_oauth2::client::CustomHyperClientBuilder::from(
14850/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
14851/// # ),
14852/// # ).build().await.unwrap();
14853///
14854/// # let client = hyper_util::client::legacy::Client::builder(
14855/// # hyper_util::rt::TokioExecutor::new()
14856/// # )
14857/// # .build(
14858/// # hyper_rustls::HttpsConnectorBuilder::new()
14859/// # .with_native_roots()
14860/// # .unwrap()
14861/// # .https_or_http()
14862/// # .enable_http2()
14863/// # .build()
14864/// # );
14865/// # let mut hub = ContainerAnalysis::new(client, auth);
14866/// // As the method needs a request, you would usually fill it with the desired information
14867/// // into the respective structure. Some of the parts shown here might not be applicable !
14868/// // Values shown here are possibly random and not representative !
14869/// let mut req = BatchCreateOccurrencesRequest::default();
14870///
14871/// // You can configure optional parameters by calling the respective setters at will, and
14872/// // execute the final call using `doit()`.
14873/// // Values shown here are possibly random and not representative !
14874/// let result = hub.projects().occurrences_batch_create(req, "parent")
14875/// .doit().await;
14876/// # }
14877/// ```
14878pub struct ProjectOccurrenceBatchCreateCall<'a, C>
14879where
14880 C: 'a,
14881{
14882 hub: &'a ContainerAnalysis<C>,
14883 _request: BatchCreateOccurrencesRequest,
14884 _parent: String,
14885 _delegate: Option<&'a mut dyn common::Delegate>,
14886 _additional_params: HashMap<String, String>,
14887 _scopes: BTreeSet<String>,
14888}
14889
14890impl<'a, C> common::CallBuilder for ProjectOccurrenceBatchCreateCall<'a, C> {}
14891
14892impl<'a, C> ProjectOccurrenceBatchCreateCall<'a, C>
14893where
14894 C: common::Connector,
14895{
14896 /// Perform the operation you have build so far.
14897 pub async fn doit(
14898 mut self,
14899 ) -> common::Result<(common::Response, BatchCreateOccurrencesResponse)> {
14900 use std::borrow::Cow;
14901 use std::io::{Read, Seek};
14902
14903 use common::{url::Params, ToParts};
14904 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
14905
14906 let mut dd = common::DefaultDelegate;
14907 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
14908 dlg.begin(common::MethodInfo {
14909 id: "containeranalysis.projects.occurrences.batchCreate",
14910 http_method: hyper::Method::POST,
14911 });
14912
14913 for &field in ["alt", "parent"].iter() {
14914 if self._additional_params.contains_key(field) {
14915 dlg.finished(false);
14916 return Err(common::Error::FieldClash(field));
14917 }
14918 }
14919
14920 let mut params = Params::with_capacity(4 + self._additional_params.len());
14921 params.push("parent", self._parent);
14922
14923 params.extend(self._additional_params.iter());
14924
14925 params.push("alt", "json");
14926 let mut url = self.hub._base_url.clone() + "v1/{+parent}/occurrences:batchCreate";
14927 if self._scopes.is_empty() {
14928 self._scopes
14929 .insert(Scope::CloudPlatform.as_ref().to_string());
14930 }
14931
14932 #[allow(clippy::single_element_loop)]
14933 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
14934 url = params.uri_replacement(url, param_name, find_this, true);
14935 }
14936 {
14937 let to_remove = ["parent"];
14938 params.remove_params(&to_remove);
14939 }
14940
14941 let url = params.parse_with_url(&url);
14942
14943 let mut json_mime_type = mime::APPLICATION_JSON;
14944 let mut request_value_reader = {
14945 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
14946 common::remove_json_null_values(&mut value);
14947 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
14948 serde_json::to_writer(&mut dst, &value).unwrap();
14949 dst
14950 };
14951 let request_size = request_value_reader
14952 .seek(std::io::SeekFrom::End(0))
14953 .unwrap();
14954 request_value_reader
14955 .seek(std::io::SeekFrom::Start(0))
14956 .unwrap();
14957
14958 loop {
14959 let token = match self
14960 .hub
14961 .auth
14962 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
14963 .await
14964 {
14965 Ok(token) => token,
14966 Err(e) => match dlg.token(e) {
14967 Ok(token) => token,
14968 Err(e) => {
14969 dlg.finished(false);
14970 return Err(common::Error::MissingToken(e));
14971 }
14972 },
14973 };
14974 request_value_reader
14975 .seek(std::io::SeekFrom::Start(0))
14976 .unwrap();
14977 let mut req_result = {
14978 let client = &self.hub.client;
14979 dlg.pre_request();
14980 let mut req_builder = hyper::Request::builder()
14981 .method(hyper::Method::POST)
14982 .uri(url.as_str())
14983 .header(USER_AGENT, self.hub._user_agent.clone());
14984
14985 if let Some(token) = token.as_ref() {
14986 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
14987 }
14988
14989 let request = req_builder
14990 .header(CONTENT_TYPE, json_mime_type.to_string())
14991 .header(CONTENT_LENGTH, request_size as u64)
14992 .body(common::to_body(
14993 request_value_reader.get_ref().clone().into(),
14994 ));
14995
14996 client.request(request.unwrap()).await
14997 };
14998
14999 match req_result {
15000 Err(err) => {
15001 if let common::Retry::After(d) = dlg.http_error(&err) {
15002 sleep(d).await;
15003 continue;
15004 }
15005 dlg.finished(false);
15006 return Err(common::Error::HttpError(err));
15007 }
15008 Ok(res) => {
15009 let (mut parts, body) = res.into_parts();
15010 let mut body = common::Body::new(body);
15011 if !parts.status.is_success() {
15012 let bytes = common::to_bytes(body).await.unwrap_or_default();
15013 let error = serde_json::from_str(&common::to_string(&bytes));
15014 let response = common::to_response(parts, bytes.into());
15015
15016 if let common::Retry::After(d) =
15017 dlg.http_failure(&response, error.as_ref().ok())
15018 {
15019 sleep(d).await;
15020 continue;
15021 }
15022
15023 dlg.finished(false);
15024
15025 return Err(match error {
15026 Ok(value) => common::Error::BadRequest(value),
15027 _ => common::Error::Failure(response),
15028 });
15029 }
15030 let response = {
15031 let bytes = common::to_bytes(body).await.unwrap_or_default();
15032 let encoded = common::to_string(&bytes);
15033 match serde_json::from_str(&encoded) {
15034 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15035 Err(error) => {
15036 dlg.response_json_decode_error(&encoded, &error);
15037 return Err(common::Error::JsonDecodeError(
15038 encoded.to_string(),
15039 error,
15040 ));
15041 }
15042 }
15043 };
15044
15045 dlg.finished(true);
15046 return Ok(response);
15047 }
15048 }
15049 }
15050 }
15051
15052 ///
15053 /// Sets the *request* property to the given value.
15054 ///
15055 /// Even though the property as already been set when instantiating this call,
15056 /// we provide this method for API completeness.
15057 pub fn request(
15058 mut self,
15059 new_value: BatchCreateOccurrencesRequest,
15060 ) -> ProjectOccurrenceBatchCreateCall<'a, C> {
15061 self._request = new_value;
15062 self
15063 }
15064 /// Required. The name of the project in the form of `projects/[PROJECT_ID]`, under which the occurrences are to be created.
15065 ///
15066 /// Sets the *parent* path property to the given value.
15067 ///
15068 /// Even though the property as already been set when instantiating this call,
15069 /// we provide this method for API completeness.
15070 pub fn parent(mut self, new_value: &str) -> ProjectOccurrenceBatchCreateCall<'a, C> {
15071 self._parent = new_value.to_string();
15072 self
15073 }
15074 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15075 /// while executing the actual API request.
15076 ///
15077 /// ````text
15078 /// It should be used to handle progress information, and to implement a certain level of resilience.
15079 /// ````
15080 ///
15081 /// Sets the *delegate* property to the given value.
15082 pub fn delegate(
15083 mut self,
15084 new_value: &'a mut dyn common::Delegate,
15085 ) -> ProjectOccurrenceBatchCreateCall<'a, C> {
15086 self._delegate = Some(new_value);
15087 self
15088 }
15089
15090 /// Set any additional parameter of the query string used in the request.
15091 /// It should be used to set parameters which are not yet available through their own
15092 /// setters.
15093 ///
15094 /// Please note that this method must not be used to set any of the known parameters
15095 /// which have their own setter method. If done anyway, the request will fail.
15096 ///
15097 /// # Additional Parameters
15098 ///
15099 /// * *$.xgafv* (query-string) - V1 error format.
15100 /// * *access_token* (query-string) - OAuth access token.
15101 /// * *alt* (query-string) - Data format for response.
15102 /// * *callback* (query-string) - JSONP
15103 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15104 /// * *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.
15105 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15106 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15107 /// * *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.
15108 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15109 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15110 pub fn param<T>(mut self, name: T, value: T) -> ProjectOccurrenceBatchCreateCall<'a, C>
15111 where
15112 T: AsRef<str>,
15113 {
15114 self._additional_params
15115 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15116 self
15117 }
15118
15119 /// Identifies the authorization scope for the method you are building.
15120 ///
15121 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15122 /// [`Scope::CloudPlatform`].
15123 ///
15124 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15125 /// tokens for more than one scope.
15126 ///
15127 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15128 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15129 /// sufficient, a read-write scope will do as well.
15130 pub fn add_scope<St>(mut self, scope: St) -> ProjectOccurrenceBatchCreateCall<'a, C>
15131 where
15132 St: AsRef<str>,
15133 {
15134 self._scopes.insert(String::from(scope.as_ref()));
15135 self
15136 }
15137 /// Identifies the authorization scope(s) for the method you are building.
15138 ///
15139 /// See [`Self::add_scope()`] for details.
15140 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectOccurrenceBatchCreateCall<'a, C>
15141 where
15142 I: IntoIterator<Item = St>,
15143 St: AsRef<str>,
15144 {
15145 self._scopes
15146 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15147 self
15148 }
15149
15150 /// Removes all scopes, and no default scope will be used either.
15151 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15152 /// for details).
15153 pub fn clear_scopes(mut self) -> ProjectOccurrenceBatchCreateCall<'a, C> {
15154 self._scopes.clear();
15155 self
15156 }
15157}
15158
15159/// Creates a new occurrence.
15160///
15161/// A builder for the *occurrences.create* method supported by a *project* resource.
15162/// It is not used directly, but through a [`ProjectMethods`] instance.
15163///
15164/// # Example
15165///
15166/// Instantiate a resource method builder
15167///
15168/// ```test_harness,no_run
15169/// # extern crate hyper;
15170/// # extern crate hyper_rustls;
15171/// # extern crate google_containeranalysis1 as containeranalysis1;
15172/// use containeranalysis1::api::Occurrence;
15173/// # async fn dox() {
15174/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15175///
15176/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15177/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15178/// # .with_native_roots()
15179/// # .unwrap()
15180/// # .https_only()
15181/// # .enable_http2()
15182/// # .build();
15183///
15184/// # let executor = hyper_util::rt::TokioExecutor::new();
15185/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15186/// # secret,
15187/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15188/// # yup_oauth2::client::CustomHyperClientBuilder::from(
15189/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
15190/// # ),
15191/// # ).build().await.unwrap();
15192///
15193/// # let client = hyper_util::client::legacy::Client::builder(
15194/// # hyper_util::rt::TokioExecutor::new()
15195/// # )
15196/// # .build(
15197/// # hyper_rustls::HttpsConnectorBuilder::new()
15198/// # .with_native_roots()
15199/// # .unwrap()
15200/// # .https_or_http()
15201/// # .enable_http2()
15202/// # .build()
15203/// # );
15204/// # let mut hub = ContainerAnalysis::new(client, auth);
15205/// // As the method needs a request, you would usually fill it with the desired information
15206/// // into the respective structure. Some of the parts shown here might not be applicable !
15207/// // Values shown here are possibly random and not representative !
15208/// let mut req = Occurrence::default();
15209///
15210/// // You can configure optional parameters by calling the respective setters at will, and
15211/// // execute the final call using `doit()`.
15212/// // Values shown here are possibly random and not representative !
15213/// let result = hub.projects().occurrences_create(req, "parent")
15214/// .doit().await;
15215/// # }
15216/// ```
15217pub struct ProjectOccurrenceCreateCall<'a, C>
15218where
15219 C: 'a,
15220{
15221 hub: &'a ContainerAnalysis<C>,
15222 _request: Occurrence,
15223 _parent: String,
15224 _delegate: Option<&'a mut dyn common::Delegate>,
15225 _additional_params: HashMap<String, String>,
15226 _scopes: BTreeSet<String>,
15227}
15228
15229impl<'a, C> common::CallBuilder for ProjectOccurrenceCreateCall<'a, C> {}
15230
15231impl<'a, C> ProjectOccurrenceCreateCall<'a, C>
15232where
15233 C: common::Connector,
15234{
15235 /// Perform the operation you have build so far.
15236 pub async fn doit(mut self) -> common::Result<(common::Response, Occurrence)> {
15237 use std::borrow::Cow;
15238 use std::io::{Read, Seek};
15239
15240 use common::{url::Params, ToParts};
15241 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15242
15243 let mut dd = common::DefaultDelegate;
15244 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15245 dlg.begin(common::MethodInfo {
15246 id: "containeranalysis.projects.occurrences.create",
15247 http_method: hyper::Method::POST,
15248 });
15249
15250 for &field in ["alt", "parent"].iter() {
15251 if self._additional_params.contains_key(field) {
15252 dlg.finished(false);
15253 return Err(common::Error::FieldClash(field));
15254 }
15255 }
15256
15257 let mut params = Params::with_capacity(4 + self._additional_params.len());
15258 params.push("parent", self._parent);
15259
15260 params.extend(self._additional_params.iter());
15261
15262 params.push("alt", "json");
15263 let mut url = self.hub._base_url.clone() + "v1/{+parent}/occurrences";
15264 if self._scopes.is_empty() {
15265 self._scopes
15266 .insert(Scope::CloudPlatform.as_ref().to_string());
15267 }
15268
15269 #[allow(clippy::single_element_loop)]
15270 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
15271 url = params.uri_replacement(url, param_name, find_this, true);
15272 }
15273 {
15274 let to_remove = ["parent"];
15275 params.remove_params(&to_remove);
15276 }
15277
15278 let url = params.parse_with_url(&url);
15279
15280 let mut json_mime_type = mime::APPLICATION_JSON;
15281 let mut request_value_reader = {
15282 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
15283 common::remove_json_null_values(&mut value);
15284 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
15285 serde_json::to_writer(&mut dst, &value).unwrap();
15286 dst
15287 };
15288 let request_size = request_value_reader
15289 .seek(std::io::SeekFrom::End(0))
15290 .unwrap();
15291 request_value_reader
15292 .seek(std::io::SeekFrom::Start(0))
15293 .unwrap();
15294
15295 loop {
15296 let token = match self
15297 .hub
15298 .auth
15299 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15300 .await
15301 {
15302 Ok(token) => token,
15303 Err(e) => match dlg.token(e) {
15304 Ok(token) => token,
15305 Err(e) => {
15306 dlg.finished(false);
15307 return Err(common::Error::MissingToken(e));
15308 }
15309 },
15310 };
15311 request_value_reader
15312 .seek(std::io::SeekFrom::Start(0))
15313 .unwrap();
15314 let mut req_result = {
15315 let client = &self.hub.client;
15316 dlg.pre_request();
15317 let mut req_builder = hyper::Request::builder()
15318 .method(hyper::Method::POST)
15319 .uri(url.as_str())
15320 .header(USER_AGENT, self.hub._user_agent.clone());
15321
15322 if let Some(token) = token.as_ref() {
15323 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15324 }
15325
15326 let request = req_builder
15327 .header(CONTENT_TYPE, json_mime_type.to_string())
15328 .header(CONTENT_LENGTH, request_size as u64)
15329 .body(common::to_body(
15330 request_value_reader.get_ref().clone().into(),
15331 ));
15332
15333 client.request(request.unwrap()).await
15334 };
15335
15336 match req_result {
15337 Err(err) => {
15338 if let common::Retry::After(d) = dlg.http_error(&err) {
15339 sleep(d).await;
15340 continue;
15341 }
15342 dlg.finished(false);
15343 return Err(common::Error::HttpError(err));
15344 }
15345 Ok(res) => {
15346 let (mut parts, body) = res.into_parts();
15347 let mut body = common::Body::new(body);
15348 if !parts.status.is_success() {
15349 let bytes = common::to_bytes(body).await.unwrap_or_default();
15350 let error = serde_json::from_str(&common::to_string(&bytes));
15351 let response = common::to_response(parts, bytes.into());
15352
15353 if let common::Retry::After(d) =
15354 dlg.http_failure(&response, error.as_ref().ok())
15355 {
15356 sleep(d).await;
15357 continue;
15358 }
15359
15360 dlg.finished(false);
15361
15362 return Err(match error {
15363 Ok(value) => common::Error::BadRequest(value),
15364 _ => common::Error::Failure(response),
15365 });
15366 }
15367 let response = {
15368 let bytes = common::to_bytes(body).await.unwrap_or_default();
15369 let encoded = common::to_string(&bytes);
15370 match serde_json::from_str(&encoded) {
15371 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15372 Err(error) => {
15373 dlg.response_json_decode_error(&encoded, &error);
15374 return Err(common::Error::JsonDecodeError(
15375 encoded.to_string(),
15376 error,
15377 ));
15378 }
15379 }
15380 };
15381
15382 dlg.finished(true);
15383 return Ok(response);
15384 }
15385 }
15386 }
15387 }
15388
15389 ///
15390 /// Sets the *request* property to the given value.
15391 ///
15392 /// Even though the property as already been set when instantiating this call,
15393 /// we provide this method for API completeness.
15394 pub fn request(mut self, new_value: Occurrence) -> ProjectOccurrenceCreateCall<'a, C> {
15395 self._request = new_value;
15396 self
15397 }
15398 /// Required. The name of the project in the form of `projects/[PROJECT_ID]`, under which the occurrence is to be created.
15399 ///
15400 /// Sets the *parent* path property to the given value.
15401 ///
15402 /// Even though the property as already been set when instantiating this call,
15403 /// we provide this method for API completeness.
15404 pub fn parent(mut self, new_value: &str) -> ProjectOccurrenceCreateCall<'a, C> {
15405 self._parent = new_value.to_string();
15406 self
15407 }
15408 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15409 /// while executing the actual API request.
15410 ///
15411 /// ````text
15412 /// It should be used to handle progress information, and to implement a certain level of resilience.
15413 /// ````
15414 ///
15415 /// Sets the *delegate* property to the given value.
15416 pub fn delegate(
15417 mut self,
15418 new_value: &'a mut dyn common::Delegate,
15419 ) -> ProjectOccurrenceCreateCall<'a, C> {
15420 self._delegate = Some(new_value);
15421 self
15422 }
15423
15424 /// Set any additional parameter of the query string used in the request.
15425 /// It should be used to set parameters which are not yet available through their own
15426 /// setters.
15427 ///
15428 /// Please note that this method must not be used to set any of the known parameters
15429 /// which have their own setter method. If done anyway, the request will fail.
15430 ///
15431 /// # Additional Parameters
15432 ///
15433 /// * *$.xgafv* (query-string) - V1 error format.
15434 /// * *access_token* (query-string) - OAuth access token.
15435 /// * *alt* (query-string) - Data format for response.
15436 /// * *callback* (query-string) - JSONP
15437 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15438 /// * *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.
15439 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15440 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15441 /// * *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.
15442 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15443 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15444 pub fn param<T>(mut self, name: T, value: T) -> ProjectOccurrenceCreateCall<'a, C>
15445 where
15446 T: AsRef<str>,
15447 {
15448 self._additional_params
15449 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15450 self
15451 }
15452
15453 /// Identifies the authorization scope for the method you are building.
15454 ///
15455 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15456 /// [`Scope::CloudPlatform`].
15457 ///
15458 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15459 /// tokens for more than one scope.
15460 ///
15461 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15462 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15463 /// sufficient, a read-write scope will do as well.
15464 pub fn add_scope<St>(mut self, scope: St) -> ProjectOccurrenceCreateCall<'a, C>
15465 where
15466 St: AsRef<str>,
15467 {
15468 self._scopes.insert(String::from(scope.as_ref()));
15469 self
15470 }
15471 /// Identifies the authorization scope(s) for the method you are building.
15472 ///
15473 /// See [`Self::add_scope()`] for details.
15474 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectOccurrenceCreateCall<'a, C>
15475 where
15476 I: IntoIterator<Item = St>,
15477 St: AsRef<str>,
15478 {
15479 self._scopes
15480 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15481 self
15482 }
15483
15484 /// Removes all scopes, and no default scope will be used either.
15485 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15486 /// for details).
15487 pub fn clear_scopes(mut self) -> ProjectOccurrenceCreateCall<'a, C> {
15488 self._scopes.clear();
15489 self
15490 }
15491}
15492
15493/// Deletes the specified occurrence. For example, use this method to delete an occurrence when the occurrence is no longer applicable for the given resource.
15494///
15495/// A builder for the *occurrences.delete* method supported by a *project* resource.
15496/// It is not used directly, but through a [`ProjectMethods`] instance.
15497///
15498/// # Example
15499///
15500/// Instantiate a resource method builder
15501///
15502/// ```test_harness,no_run
15503/// # extern crate hyper;
15504/// # extern crate hyper_rustls;
15505/// # extern crate google_containeranalysis1 as containeranalysis1;
15506/// # async fn dox() {
15507/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15508///
15509/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15510/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15511/// # .with_native_roots()
15512/// # .unwrap()
15513/// # .https_only()
15514/// # .enable_http2()
15515/// # .build();
15516///
15517/// # let executor = hyper_util::rt::TokioExecutor::new();
15518/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15519/// # secret,
15520/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15521/// # yup_oauth2::client::CustomHyperClientBuilder::from(
15522/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
15523/// # ),
15524/// # ).build().await.unwrap();
15525///
15526/// # let client = hyper_util::client::legacy::Client::builder(
15527/// # hyper_util::rt::TokioExecutor::new()
15528/// # )
15529/// # .build(
15530/// # hyper_rustls::HttpsConnectorBuilder::new()
15531/// # .with_native_roots()
15532/// # .unwrap()
15533/// # .https_or_http()
15534/// # .enable_http2()
15535/// # .build()
15536/// # );
15537/// # let mut hub = ContainerAnalysis::new(client, auth);
15538/// // You can configure optional parameters by calling the respective setters at will, and
15539/// // execute the final call using `doit()`.
15540/// // Values shown here are possibly random and not representative !
15541/// let result = hub.projects().occurrences_delete("name")
15542/// .doit().await;
15543/// # }
15544/// ```
15545pub struct ProjectOccurrenceDeleteCall<'a, C>
15546where
15547 C: 'a,
15548{
15549 hub: &'a ContainerAnalysis<C>,
15550 _name: String,
15551 _delegate: Option<&'a mut dyn common::Delegate>,
15552 _additional_params: HashMap<String, String>,
15553 _scopes: BTreeSet<String>,
15554}
15555
15556impl<'a, C> common::CallBuilder for ProjectOccurrenceDeleteCall<'a, C> {}
15557
15558impl<'a, C> ProjectOccurrenceDeleteCall<'a, C>
15559where
15560 C: common::Connector,
15561{
15562 /// Perform the operation you have build so far.
15563 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
15564 use std::borrow::Cow;
15565 use std::io::{Read, Seek};
15566
15567 use common::{url::Params, ToParts};
15568 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15569
15570 let mut dd = common::DefaultDelegate;
15571 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15572 dlg.begin(common::MethodInfo {
15573 id: "containeranalysis.projects.occurrences.delete",
15574 http_method: hyper::Method::DELETE,
15575 });
15576
15577 for &field in ["alt", "name"].iter() {
15578 if self._additional_params.contains_key(field) {
15579 dlg.finished(false);
15580 return Err(common::Error::FieldClash(field));
15581 }
15582 }
15583
15584 let mut params = Params::with_capacity(3 + self._additional_params.len());
15585 params.push("name", self._name);
15586
15587 params.extend(self._additional_params.iter());
15588
15589 params.push("alt", "json");
15590 let mut url = self.hub._base_url.clone() + "v1/{+name}";
15591 if self._scopes.is_empty() {
15592 self._scopes
15593 .insert(Scope::CloudPlatform.as_ref().to_string());
15594 }
15595
15596 #[allow(clippy::single_element_loop)]
15597 for &(find_this, param_name) in [("{+name}", "name")].iter() {
15598 url = params.uri_replacement(url, param_name, find_this, true);
15599 }
15600 {
15601 let to_remove = ["name"];
15602 params.remove_params(&to_remove);
15603 }
15604
15605 let url = params.parse_with_url(&url);
15606
15607 loop {
15608 let token = match self
15609 .hub
15610 .auth
15611 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15612 .await
15613 {
15614 Ok(token) => token,
15615 Err(e) => match dlg.token(e) {
15616 Ok(token) => token,
15617 Err(e) => {
15618 dlg.finished(false);
15619 return Err(common::Error::MissingToken(e));
15620 }
15621 },
15622 };
15623 let mut req_result = {
15624 let client = &self.hub.client;
15625 dlg.pre_request();
15626 let mut req_builder = hyper::Request::builder()
15627 .method(hyper::Method::DELETE)
15628 .uri(url.as_str())
15629 .header(USER_AGENT, self.hub._user_agent.clone());
15630
15631 if let Some(token) = token.as_ref() {
15632 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15633 }
15634
15635 let request = req_builder
15636 .header(CONTENT_LENGTH, 0_u64)
15637 .body(common::to_body::<String>(None));
15638
15639 client.request(request.unwrap()).await
15640 };
15641
15642 match req_result {
15643 Err(err) => {
15644 if let common::Retry::After(d) = dlg.http_error(&err) {
15645 sleep(d).await;
15646 continue;
15647 }
15648 dlg.finished(false);
15649 return Err(common::Error::HttpError(err));
15650 }
15651 Ok(res) => {
15652 let (mut parts, body) = res.into_parts();
15653 let mut body = common::Body::new(body);
15654 if !parts.status.is_success() {
15655 let bytes = common::to_bytes(body).await.unwrap_or_default();
15656 let error = serde_json::from_str(&common::to_string(&bytes));
15657 let response = common::to_response(parts, bytes.into());
15658
15659 if let common::Retry::After(d) =
15660 dlg.http_failure(&response, error.as_ref().ok())
15661 {
15662 sleep(d).await;
15663 continue;
15664 }
15665
15666 dlg.finished(false);
15667
15668 return Err(match error {
15669 Ok(value) => common::Error::BadRequest(value),
15670 _ => common::Error::Failure(response),
15671 });
15672 }
15673 let response = {
15674 let bytes = common::to_bytes(body).await.unwrap_or_default();
15675 let encoded = common::to_string(&bytes);
15676 match serde_json::from_str(&encoded) {
15677 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15678 Err(error) => {
15679 dlg.response_json_decode_error(&encoded, &error);
15680 return Err(common::Error::JsonDecodeError(
15681 encoded.to_string(),
15682 error,
15683 ));
15684 }
15685 }
15686 };
15687
15688 dlg.finished(true);
15689 return Ok(response);
15690 }
15691 }
15692 }
15693 }
15694
15695 /// Required. The name of the occurrence in the form of `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.
15696 ///
15697 /// Sets the *name* path property to the given value.
15698 ///
15699 /// Even though the property as already been set when instantiating this call,
15700 /// we provide this method for API completeness.
15701 pub fn name(mut self, new_value: &str) -> ProjectOccurrenceDeleteCall<'a, C> {
15702 self._name = new_value.to_string();
15703 self
15704 }
15705 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
15706 /// while executing the actual API request.
15707 ///
15708 /// ````text
15709 /// It should be used to handle progress information, and to implement a certain level of resilience.
15710 /// ````
15711 ///
15712 /// Sets the *delegate* property to the given value.
15713 pub fn delegate(
15714 mut self,
15715 new_value: &'a mut dyn common::Delegate,
15716 ) -> ProjectOccurrenceDeleteCall<'a, C> {
15717 self._delegate = Some(new_value);
15718 self
15719 }
15720
15721 /// Set any additional parameter of the query string used in the request.
15722 /// It should be used to set parameters which are not yet available through their own
15723 /// setters.
15724 ///
15725 /// Please note that this method must not be used to set any of the known parameters
15726 /// which have their own setter method. If done anyway, the request will fail.
15727 ///
15728 /// # Additional Parameters
15729 ///
15730 /// * *$.xgafv* (query-string) - V1 error format.
15731 /// * *access_token* (query-string) - OAuth access token.
15732 /// * *alt* (query-string) - Data format for response.
15733 /// * *callback* (query-string) - JSONP
15734 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
15735 /// * *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.
15736 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
15737 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
15738 /// * *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.
15739 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
15740 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
15741 pub fn param<T>(mut self, name: T, value: T) -> ProjectOccurrenceDeleteCall<'a, C>
15742 where
15743 T: AsRef<str>,
15744 {
15745 self._additional_params
15746 .insert(name.as_ref().to_string(), value.as_ref().to_string());
15747 self
15748 }
15749
15750 /// Identifies the authorization scope for the method you are building.
15751 ///
15752 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
15753 /// [`Scope::CloudPlatform`].
15754 ///
15755 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
15756 /// tokens for more than one scope.
15757 ///
15758 /// Usually there is more than one suitable scope to authorize an operation, some of which may
15759 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
15760 /// sufficient, a read-write scope will do as well.
15761 pub fn add_scope<St>(mut self, scope: St) -> ProjectOccurrenceDeleteCall<'a, C>
15762 where
15763 St: AsRef<str>,
15764 {
15765 self._scopes.insert(String::from(scope.as_ref()));
15766 self
15767 }
15768 /// Identifies the authorization scope(s) for the method you are building.
15769 ///
15770 /// See [`Self::add_scope()`] for details.
15771 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectOccurrenceDeleteCall<'a, C>
15772 where
15773 I: IntoIterator<Item = St>,
15774 St: AsRef<str>,
15775 {
15776 self._scopes
15777 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
15778 self
15779 }
15780
15781 /// Removes all scopes, and no default scope will be used either.
15782 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
15783 /// for details).
15784 pub fn clear_scopes(mut self) -> ProjectOccurrenceDeleteCall<'a, C> {
15785 self._scopes.clear();
15786 self
15787 }
15788}
15789
15790/// Gets the specified occurrence.
15791///
15792/// A builder for the *occurrences.get* method supported by a *project* resource.
15793/// It is not used directly, but through a [`ProjectMethods`] instance.
15794///
15795/// # Example
15796///
15797/// Instantiate a resource method builder
15798///
15799/// ```test_harness,no_run
15800/// # extern crate hyper;
15801/// # extern crate hyper_rustls;
15802/// # extern crate google_containeranalysis1 as containeranalysis1;
15803/// # async fn dox() {
15804/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
15805///
15806/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
15807/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
15808/// # .with_native_roots()
15809/// # .unwrap()
15810/// # .https_only()
15811/// # .enable_http2()
15812/// # .build();
15813///
15814/// # let executor = hyper_util::rt::TokioExecutor::new();
15815/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
15816/// # secret,
15817/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
15818/// # yup_oauth2::client::CustomHyperClientBuilder::from(
15819/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
15820/// # ),
15821/// # ).build().await.unwrap();
15822///
15823/// # let client = hyper_util::client::legacy::Client::builder(
15824/// # hyper_util::rt::TokioExecutor::new()
15825/// # )
15826/// # .build(
15827/// # hyper_rustls::HttpsConnectorBuilder::new()
15828/// # .with_native_roots()
15829/// # .unwrap()
15830/// # .https_or_http()
15831/// # .enable_http2()
15832/// # .build()
15833/// # );
15834/// # let mut hub = ContainerAnalysis::new(client, auth);
15835/// // You can configure optional parameters by calling the respective setters at will, and
15836/// // execute the final call using `doit()`.
15837/// // Values shown here are possibly random and not representative !
15838/// let result = hub.projects().occurrences_get("name")
15839/// .doit().await;
15840/// # }
15841/// ```
15842pub struct ProjectOccurrenceGetCall<'a, C>
15843where
15844 C: 'a,
15845{
15846 hub: &'a ContainerAnalysis<C>,
15847 _name: String,
15848 _delegate: Option<&'a mut dyn common::Delegate>,
15849 _additional_params: HashMap<String, String>,
15850 _scopes: BTreeSet<String>,
15851}
15852
15853impl<'a, C> common::CallBuilder for ProjectOccurrenceGetCall<'a, C> {}
15854
15855impl<'a, C> ProjectOccurrenceGetCall<'a, C>
15856where
15857 C: common::Connector,
15858{
15859 /// Perform the operation you have build so far.
15860 pub async fn doit(mut self) -> common::Result<(common::Response, Occurrence)> {
15861 use std::borrow::Cow;
15862 use std::io::{Read, Seek};
15863
15864 use common::{url::Params, ToParts};
15865 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
15866
15867 let mut dd = common::DefaultDelegate;
15868 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
15869 dlg.begin(common::MethodInfo {
15870 id: "containeranalysis.projects.occurrences.get",
15871 http_method: hyper::Method::GET,
15872 });
15873
15874 for &field in ["alt", "name"].iter() {
15875 if self._additional_params.contains_key(field) {
15876 dlg.finished(false);
15877 return Err(common::Error::FieldClash(field));
15878 }
15879 }
15880
15881 let mut params = Params::with_capacity(3 + self._additional_params.len());
15882 params.push("name", self._name);
15883
15884 params.extend(self._additional_params.iter());
15885
15886 params.push("alt", "json");
15887 let mut url = self.hub._base_url.clone() + "v1/{+name}";
15888 if self._scopes.is_empty() {
15889 self._scopes
15890 .insert(Scope::CloudPlatform.as_ref().to_string());
15891 }
15892
15893 #[allow(clippy::single_element_loop)]
15894 for &(find_this, param_name) in [("{+name}", "name")].iter() {
15895 url = params.uri_replacement(url, param_name, find_this, true);
15896 }
15897 {
15898 let to_remove = ["name"];
15899 params.remove_params(&to_remove);
15900 }
15901
15902 let url = params.parse_with_url(&url);
15903
15904 loop {
15905 let token = match self
15906 .hub
15907 .auth
15908 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
15909 .await
15910 {
15911 Ok(token) => token,
15912 Err(e) => match dlg.token(e) {
15913 Ok(token) => token,
15914 Err(e) => {
15915 dlg.finished(false);
15916 return Err(common::Error::MissingToken(e));
15917 }
15918 },
15919 };
15920 let mut req_result = {
15921 let client = &self.hub.client;
15922 dlg.pre_request();
15923 let mut req_builder = hyper::Request::builder()
15924 .method(hyper::Method::GET)
15925 .uri(url.as_str())
15926 .header(USER_AGENT, self.hub._user_agent.clone());
15927
15928 if let Some(token) = token.as_ref() {
15929 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
15930 }
15931
15932 let request = req_builder
15933 .header(CONTENT_LENGTH, 0_u64)
15934 .body(common::to_body::<String>(None));
15935
15936 client.request(request.unwrap()).await
15937 };
15938
15939 match req_result {
15940 Err(err) => {
15941 if let common::Retry::After(d) = dlg.http_error(&err) {
15942 sleep(d).await;
15943 continue;
15944 }
15945 dlg.finished(false);
15946 return Err(common::Error::HttpError(err));
15947 }
15948 Ok(res) => {
15949 let (mut parts, body) = res.into_parts();
15950 let mut body = common::Body::new(body);
15951 if !parts.status.is_success() {
15952 let bytes = common::to_bytes(body).await.unwrap_or_default();
15953 let error = serde_json::from_str(&common::to_string(&bytes));
15954 let response = common::to_response(parts, bytes.into());
15955
15956 if let common::Retry::After(d) =
15957 dlg.http_failure(&response, error.as_ref().ok())
15958 {
15959 sleep(d).await;
15960 continue;
15961 }
15962
15963 dlg.finished(false);
15964
15965 return Err(match error {
15966 Ok(value) => common::Error::BadRequest(value),
15967 _ => common::Error::Failure(response),
15968 });
15969 }
15970 let response = {
15971 let bytes = common::to_bytes(body).await.unwrap_or_default();
15972 let encoded = common::to_string(&bytes);
15973 match serde_json::from_str(&encoded) {
15974 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
15975 Err(error) => {
15976 dlg.response_json_decode_error(&encoded, &error);
15977 return Err(common::Error::JsonDecodeError(
15978 encoded.to_string(),
15979 error,
15980 ));
15981 }
15982 }
15983 };
15984
15985 dlg.finished(true);
15986 return Ok(response);
15987 }
15988 }
15989 }
15990 }
15991
15992 /// Required. The name of the occurrence in the form of `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.
15993 ///
15994 /// Sets the *name* path property to the given value.
15995 ///
15996 /// Even though the property as already been set when instantiating this call,
15997 /// we provide this method for API completeness.
15998 pub fn name(mut self, new_value: &str) -> ProjectOccurrenceGetCall<'a, C> {
15999 self._name = new_value.to_string();
16000 self
16001 }
16002 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16003 /// while executing the actual API request.
16004 ///
16005 /// ````text
16006 /// It should be used to handle progress information, and to implement a certain level of resilience.
16007 /// ````
16008 ///
16009 /// Sets the *delegate* property to the given value.
16010 pub fn delegate(
16011 mut self,
16012 new_value: &'a mut dyn common::Delegate,
16013 ) -> ProjectOccurrenceGetCall<'a, C> {
16014 self._delegate = Some(new_value);
16015 self
16016 }
16017
16018 /// Set any additional parameter of the query string used in the request.
16019 /// It should be used to set parameters which are not yet available through their own
16020 /// setters.
16021 ///
16022 /// Please note that this method must not be used to set any of the known parameters
16023 /// which have their own setter method. If done anyway, the request will fail.
16024 ///
16025 /// # Additional Parameters
16026 ///
16027 /// * *$.xgafv* (query-string) - V1 error format.
16028 /// * *access_token* (query-string) - OAuth access token.
16029 /// * *alt* (query-string) - Data format for response.
16030 /// * *callback* (query-string) - JSONP
16031 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16032 /// * *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.
16033 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16034 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16035 /// * *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.
16036 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16037 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16038 pub fn param<T>(mut self, name: T, value: T) -> ProjectOccurrenceGetCall<'a, C>
16039 where
16040 T: AsRef<str>,
16041 {
16042 self._additional_params
16043 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16044 self
16045 }
16046
16047 /// Identifies the authorization scope for the method you are building.
16048 ///
16049 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16050 /// [`Scope::CloudPlatform`].
16051 ///
16052 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16053 /// tokens for more than one scope.
16054 ///
16055 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16056 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16057 /// sufficient, a read-write scope will do as well.
16058 pub fn add_scope<St>(mut self, scope: St) -> ProjectOccurrenceGetCall<'a, C>
16059 where
16060 St: AsRef<str>,
16061 {
16062 self._scopes.insert(String::from(scope.as_ref()));
16063 self
16064 }
16065 /// Identifies the authorization scope(s) for the method you are building.
16066 ///
16067 /// See [`Self::add_scope()`] for details.
16068 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectOccurrenceGetCall<'a, C>
16069 where
16070 I: IntoIterator<Item = St>,
16071 St: AsRef<str>,
16072 {
16073 self._scopes
16074 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16075 self
16076 }
16077
16078 /// Removes all scopes, and no default scope will be used either.
16079 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16080 /// for details).
16081 pub fn clear_scopes(mut self) -> ProjectOccurrenceGetCall<'a, C> {
16082 self._scopes.clear();
16083 self
16084 }
16085}
16086
16087/// 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.
16088///
16089/// A builder for the *occurrences.getIamPolicy* method supported by a *project* resource.
16090/// It is not used directly, but through a [`ProjectMethods`] instance.
16091///
16092/// # Example
16093///
16094/// Instantiate a resource method builder
16095///
16096/// ```test_harness,no_run
16097/// # extern crate hyper;
16098/// # extern crate hyper_rustls;
16099/// # extern crate google_containeranalysis1 as containeranalysis1;
16100/// use containeranalysis1::api::GetIamPolicyRequest;
16101/// # async fn dox() {
16102/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16103///
16104/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16105/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16106/// # .with_native_roots()
16107/// # .unwrap()
16108/// # .https_only()
16109/// # .enable_http2()
16110/// # .build();
16111///
16112/// # let executor = hyper_util::rt::TokioExecutor::new();
16113/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16114/// # secret,
16115/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16116/// # yup_oauth2::client::CustomHyperClientBuilder::from(
16117/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
16118/// # ),
16119/// # ).build().await.unwrap();
16120///
16121/// # let client = hyper_util::client::legacy::Client::builder(
16122/// # hyper_util::rt::TokioExecutor::new()
16123/// # )
16124/// # .build(
16125/// # hyper_rustls::HttpsConnectorBuilder::new()
16126/// # .with_native_roots()
16127/// # .unwrap()
16128/// # .https_or_http()
16129/// # .enable_http2()
16130/// # .build()
16131/// # );
16132/// # let mut hub = ContainerAnalysis::new(client, auth);
16133/// // As the method needs a request, you would usually fill it with the desired information
16134/// // into the respective structure. Some of the parts shown here might not be applicable !
16135/// // Values shown here are possibly random and not representative !
16136/// let mut req = GetIamPolicyRequest::default();
16137///
16138/// // You can configure optional parameters by calling the respective setters at will, and
16139/// // execute the final call using `doit()`.
16140/// // Values shown here are possibly random and not representative !
16141/// let result = hub.projects().occurrences_get_iam_policy(req, "resource")
16142/// .doit().await;
16143/// # }
16144/// ```
16145pub struct ProjectOccurrenceGetIamPolicyCall<'a, C>
16146where
16147 C: 'a,
16148{
16149 hub: &'a ContainerAnalysis<C>,
16150 _request: GetIamPolicyRequest,
16151 _resource: String,
16152 _delegate: Option<&'a mut dyn common::Delegate>,
16153 _additional_params: HashMap<String, String>,
16154 _scopes: BTreeSet<String>,
16155}
16156
16157impl<'a, C> common::CallBuilder for ProjectOccurrenceGetIamPolicyCall<'a, C> {}
16158
16159impl<'a, C> ProjectOccurrenceGetIamPolicyCall<'a, C>
16160where
16161 C: common::Connector,
16162{
16163 /// Perform the operation you have build so far.
16164 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
16165 use std::borrow::Cow;
16166 use std::io::{Read, Seek};
16167
16168 use common::{url::Params, ToParts};
16169 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16170
16171 let mut dd = common::DefaultDelegate;
16172 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16173 dlg.begin(common::MethodInfo {
16174 id: "containeranalysis.projects.occurrences.getIamPolicy",
16175 http_method: hyper::Method::POST,
16176 });
16177
16178 for &field in ["alt", "resource"].iter() {
16179 if self._additional_params.contains_key(field) {
16180 dlg.finished(false);
16181 return Err(common::Error::FieldClash(field));
16182 }
16183 }
16184
16185 let mut params = Params::with_capacity(4 + self._additional_params.len());
16186 params.push("resource", self._resource);
16187
16188 params.extend(self._additional_params.iter());
16189
16190 params.push("alt", "json");
16191 let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
16192 if self._scopes.is_empty() {
16193 self._scopes
16194 .insert(Scope::CloudPlatform.as_ref().to_string());
16195 }
16196
16197 #[allow(clippy::single_element_loop)]
16198 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
16199 url = params.uri_replacement(url, param_name, find_this, true);
16200 }
16201 {
16202 let to_remove = ["resource"];
16203 params.remove_params(&to_remove);
16204 }
16205
16206 let url = params.parse_with_url(&url);
16207
16208 let mut json_mime_type = mime::APPLICATION_JSON;
16209 let mut request_value_reader = {
16210 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
16211 common::remove_json_null_values(&mut value);
16212 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
16213 serde_json::to_writer(&mut dst, &value).unwrap();
16214 dst
16215 };
16216 let request_size = request_value_reader
16217 .seek(std::io::SeekFrom::End(0))
16218 .unwrap();
16219 request_value_reader
16220 .seek(std::io::SeekFrom::Start(0))
16221 .unwrap();
16222
16223 loop {
16224 let token = match self
16225 .hub
16226 .auth
16227 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16228 .await
16229 {
16230 Ok(token) => token,
16231 Err(e) => match dlg.token(e) {
16232 Ok(token) => token,
16233 Err(e) => {
16234 dlg.finished(false);
16235 return Err(common::Error::MissingToken(e));
16236 }
16237 },
16238 };
16239 request_value_reader
16240 .seek(std::io::SeekFrom::Start(0))
16241 .unwrap();
16242 let mut req_result = {
16243 let client = &self.hub.client;
16244 dlg.pre_request();
16245 let mut req_builder = hyper::Request::builder()
16246 .method(hyper::Method::POST)
16247 .uri(url.as_str())
16248 .header(USER_AGENT, self.hub._user_agent.clone());
16249
16250 if let Some(token) = token.as_ref() {
16251 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16252 }
16253
16254 let request = req_builder
16255 .header(CONTENT_TYPE, json_mime_type.to_string())
16256 .header(CONTENT_LENGTH, request_size as u64)
16257 .body(common::to_body(
16258 request_value_reader.get_ref().clone().into(),
16259 ));
16260
16261 client.request(request.unwrap()).await
16262 };
16263
16264 match req_result {
16265 Err(err) => {
16266 if let common::Retry::After(d) = dlg.http_error(&err) {
16267 sleep(d).await;
16268 continue;
16269 }
16270 dlg.finished(false);
16271 return Err(common::Error::HttpError(err));
16272 }
16273 Ok(res) => {
16274 let (mut parts, body) = res.into_parts();
16275 let mut body = common::Body::new(body);
16276 if !parts.status.is_success() {
16277 let bytes = common::to_bytes(body).await.unwrap_or_default();
16278 let error = serde_json::from_str(&common::to_string(&bytes));
16279 let response = common::to_response(parts, bytes.into());
16280
16281 if let common::Retry::After(d) =
16282 dlg.http_failure(&response, error.as_ref().ok())
16283 {
16284 sleep(d).await;
16285 continue;
16286 }
16287
16288 dlg.finished(false);
16289
16290 return Err(match error {
16291 Ok(value) => common::Error::BadRequest(value),
16292 _ => common::Error::Failure(response),
16293 });
16294 }
16295 let response = {
16296 let bytes = common::to_bytes(body).await.unwrap_or_default();
16297 let encoded = common::to_string(&bytes);
16298 match serde_json::from_str(&encoded) {
16299 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16300 Err(error) => {
16301 dlg.response_json_decode_error(&encoded, &error);
16302 return Err(common::Error::JsonDecodeError(
16303 encoded.to_string(),
16304 error,
16305 ));
16306 }
16307 }
16308 };
16309
16310 dlg.finished(true);
16311 return Ok(response);
16312 }
16313 }
16314 }
16315 }
16316
16317 ///
16318 /// Sets the *request* property to the given value.
16319 ///
16320 /// Even though the property as already been set when instantiating this call,
16321 /// we provide this method for API completeness.
16322 pub fn request(
16323 mut self,
16324 new_value: GetIamPolicyRequest,
16325 ) -> ProjectOccurrenceGetIamPolicyCall<'a, C> {
16326 self._request = new_value;
16327 self
16328 }
16329 /// 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.
16330 ///
16331 /// Sets the *resource* path property to the given value.
16332 ///
16333 /// Even though the property as already been set when instantiating this call,
16334 /// we provide this method for API completeness.
16335 pub fn resource(mut self, new_value: &str) -> ProjectOccurrenceGetIamPolicyCall<'a, C> {
16336 self._resource = new_value.to_string();
16337 self
16338 }
16339 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16340 /// while executing the actual API request.
16341 ///
16342 /// ````text
16343 /// It should be used to handle progress information, and to implement a certain level of resilience.
16344 /// ````
16345 ///
16346 /// Sets the *delegate* property to the given value.
16347 pub fn delegate(
16348 mut self,
16349 new_value: &'a mut dyn common::Delegate,
16350 ) -> ProjectOccurrenceGetIamPolicyCall<'a, C> {
16351 self._delegate = Some(new_value);
16352 self
16353 }
16354
16355 /// Set any additional parameter of the query string used in the request.
16356 /// It should be used to set parameters which are not yet available through their own
16357 /// setters.
16358 ///
16359 /// Please note that this method must not be used to set any of the known parameters
16360 /// which have their own setter method. If done anyway, the request will fail.
16361 ///
16362 /// # Additional Parameters
16363 ///
16364 /// * *$.xgafv* (query-string) - V1 error format.
16365 /// * *access_token* (query-string) - OAuth access token.
16366 /// * *alt* (query-string) - Data format for response.
16367 /// * *callback* (query-string) - JSONP
16368 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16369 /// * *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.
16370 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16371 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16372 /// * *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.
16373 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16374 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16375 pub fn param<T>(mut self, name: T, value: T) -> ProjectOccurrenceGetIamPolicyCall<'a, C>
16376 where
16377 T: AsRef<str>,
16378 {
16379 self._additional_params
16380 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16381 self
16382 }
16383
16384 /// Identifies the authorization scope for the method you are building.
16385 ///
16386 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16387 /// [`Scope::CloudPlatform`].
16388 ///
16389 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16390 /// tokens for more than one scope.
16391 ///
16392 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16393 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16394 /// sufficient, a read-write scope will do as well.
16395 pub fn add_scope<St>(mut self, scope: St) -> ProjectOccurrenceGetIamPolicyCall<'a, C>
16396 where
16397 St: AsRef<str>,
16398 {
16399 self._scopes.insert(String::from(scope.as_ref()));
16400 self
16401 }
16402 /// Identifies the authorization scope(s) for the method you are building.
16403 ///
16404 /// See [`Self::add_scope()`] for details.
16405 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectOccurrenceGetIamPolicyCall<'a, C>
16406 where
16407 I: IntoIterator<Item = St>,
16408 St: AsRef<str>,
16409 {
16410 self._scopes
16411 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16412 self
16413 }
16414
16415 /// Removes all scopes, and no default scope will be used either.
16416 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16417 /// for details).
16418 pub fn clear_scopes(mut self) -> ProjectOccurrenceGetIamPolicyCall<'a, C> {
16419 self._scopes.clear();
16420 self
16421 }
16422}
16423
16424/// Gets the note attached to the specified occurrence. Consumer projects can use this method to get a note that belongs to a provider project.
16425///
16426/// A builder for the *occurrences.getNotes* method supported by a *project* resource.
16427/// It is not used directly, but through a [`ProjectMethods`] instance.
16428///
16429/// # Example
16430///
16431/// Instantiate a resource method builder
16432///
16433/// ```test_harness,no_run
16434/// # extern crate hyper;
16435/// # extern crate hyper_rustls;
16436/// # extern crate google_containeranalysis1 as containeranalysis1;
16437/// # async fn dox() {
16438/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16439///
16440/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16441/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16442/// # .with_native_roots()
16443/// # .unwrap()
16444/// # .https_only()
16445/// # .enable_http2()
16446/// # .build();
16447///
16448/// # let executor = hyper_util::rt::TokioExecutor::new();
16449/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16450/// # secret,
16451/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16452/// # yup_oauth2::client::CustomHyperClientBuilder::from(
16453/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
16454/// # ),
16455/// # ).build().await.unwrap();
16456///
16457/// # let client = hyper_util::client::legacy::Client::builder(
16458/// # hyper_util::rt::TokioExecutor::new()
16459/// # )
16460/// # .build(
16461/// # hyper_rustls::HttpsConnectorBuilder::new()
16462/// # .with_native_roots()
16463/// # .unwrap()
16464/// # .https_or_http()
16465/// # .enable_http2()
16466/// # .build()
16467/// # );
16468/// # let mut hub = ContainerAnalysis::new(client, auth);
16469/// // You can configure optional parameters by calling the respective setters at will, and
16470/// // execute the final call using `doit()`.
16471/// // Values shown here are possibly random and not representative !
16472/// let result = hub.projects().occurrences_get_notes("name")
16473/// .doit().await;
16474/// # }
16475/// ```
16476pub struct ProjectOccurrenceGetNoteCall<'a, C>
16477where
16478 C: 'a,
16479{
16480 hub: &'a ContainerAnalysis<C>,
16481 _name: String,
16482 _delegate: Option<&'a mut dyn common::Delegate>,
16483 _additional_params: HashMap<String, String>,
16484 _scopes: BTreeSet<String>,
16485}
16486
16487impl<'a, C> common::CallBuilder for ProjectOccurrenceGetNoteCall<'a, C> {}
16488
16489impl<'a, C> ProjectOccurrenceGetNoteCall<'a, C>
16490where
16491 C: common::Connector,
16492{
16493 /// Perform the operation you have build so far.
16494 pub async fn doit(mut self) -> common::Result<(common::Response, Note)> {
16495 use std::borrow::Cow;
16496 use std::io::{Read, Seek};
16497
16498 use common::{url::Params, ToParts};
16499 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16500
16501 let mut dd = common::DefaultDelegate;
16502 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16503 dlg.begin(common::MethodInfo {
16504 id: "containeranalysis.projects.occurrences.getNotes",
16505 http_method: hyper::Method::GET,
16506 });
16507
16508 for &field in ["alt", "name"].iter() {
16509 if self._additional_params.contains_key(field) {
16510 dlg.finished(false);
16511 return Err(common::Error::FieldClash(field));
16512 }
16513 }
16514
16515 let mut params = Params::with_capacity(3 + self._additional_params.len());
16516 params.push("name", self._name);
16517
16518 params.extend(self._additional_params.iter());
16519
16520 params.push("alt", "json");
16521 let mut url = self.hub._base_url.clone() + "v1/{+name}/notes";
16522 if self._scopes.is_empty() {
16523 self._scopes
16524 .insert(Scope::CloudPlatform.as_ref().to_string());
16525 }
16526
16527 #[allow(clippy::single_element_loop)]
16528 for &(find_this, param_name) in [("{+name}", "name")].iter() {
16529 url = params.uri_replacement(url, param_name, find_this, true);
16530 }
16531 {
16532 let to_remove = ["name"];
16533 params.remove_params(&to_remove);
16534 }
16535
16536 let url = params.parse_with_url(&url);
16537
16538 loop {
16539 let token = match self
16540 .hub
16541 .auth
16542 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16543 .await
16544 {
16545 Ok(token) => token,
16546 Err(e) => match dlg.token(e) {
16547 Ok(token) => token,
16548 Err(e) => {
16549 dlg.finished(false);
16550 return Err(common::Error::MissingToken(e));
16551 }
16552 },
16553 };
16554 let mut req_result = {
16555 let client = &self.hub.client;
16556 dlg.pre_request();
16557 let mut req_builder = hyper::Request::builder()
16558 .method(hyper::Method::GET)
16559 .uri(url.as_str())
16560 .header(USER_AGENT, self.hub._user_agent.clone());
16561
16562 if let Some(token) = token.as_ref() {
16563 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16564 }
16565
16566 let request = req_builder
16567 .header(CONTENT_LENGTH, 0_u64)
16568 .body(common::to_body::<String>(None));
16569
16570 client.request(request.unwrap()).await
16571 };
16572
16573 match req_result {
16574 Err(err) => {
16575 if let common::Retry::After(d) = dlg.http_error(&err) {
16576 sleep(d).await;
16577 continue;
16578 }
16579 dlg.finished(false);
16580 return Err(common::Error::HttpError(err));
16581 }
16582 Ok(res) => {
16583 let (mut parts, body) = res.into_parts();
16584 let mut body = common::Body::new(body);
16585 if !parts.status.is_success() {
16586 let bytes = common::to_bytes(body).await.unwrap_or_default();
16587 let error = serde_json::from_str(&common::to_string(&bytes));
16588 let response = common::to_response(parts, bytes.into());
16589
16590 if let common::Retry::After(d) =
16591 dlg.http_failure(&response, error.as_ref().ok())
16592 {
16593 sleep(d).await;
16594 continue;
16595 }
16596
16597 dlg.finished(false);
16598
16599 return Err(match error {
16600 Ok(value) => common::Error::BadRequest(value),
16601 _ => common::Error::Failure(response),
16602 });
16603 }
16604 let response = {
16605 let bytes = common::to_bytes(body).await.unwrap_or_default();
16606 let encoded = common::to_string(&bytes);
16607 match serde_json::from_str(&encoded) {
16608 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16609 Err(error) => {
16610 dlg.response_json_decode_error(&encoded, &error);
16611 return Err(common::Error::JsonDecodeError(
16612 encoded.to_string(),
16613 error,
16614 ));
16615 }
16616 }
16617 };
16618
16619 dlg.finished(true);
16620 return Ok(response);
16621 }
16622 }
16623 }
16624 }
16625
16626 /// Required. The name of the occurrence in the form of `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.
16627 ///
16628 /// Sets the *name* path property to the given value.
16629 ///
16630 /// Even though the property as already been set when instantiating this call,
16631 /// we provide this method for API completeness.
16632 pub fn name(mut self, new_value: &str) -> ProjectOccurrenceGetNoteCall<'a, C> {
16633 self._name = new_value.to_string();
16634 self
16635 }
16636 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16637 /// while executing the actual API request.
16638 ///
16639 /// ````text
16640 /// It should be used to handle progress information, and to implement a certain level of resilience.
16641 /// ````
16642 ///
16643 /// Sets the *delegate* property to the given value.
16644 pub fn delegate(
16645 mut self,
16646 new_value: &'a mut dyn common::Delegate,
16647 ) -> ProjectOccurrenceGetNoteCall<'a, C> {
16648 self._delegate = Some(new_value);
16649 self
16650 }
16651
16652 /// Set any additional parameter of the query string used in the request.
16653 /// It should be used to set parameters which are not yet available through their own
16654 /// setters.
16655 ///
16656 /// Please note that this method must not be used to set any of the known parameters
16657 /// which have their own setter method. If done anyway, the request will fail.
16658 ///
16659 /// # Additional Parameters
16660 ///
16661 /// * *$.xgafv* (query-string) - V1 error format.
16662 /// * *access_token* (query-string) - OAuth access token.
16663 /// * *alt* (query-string) - Data format for response.
16664 /// * *callback* (query-string) - JSONP
16665 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16666 /// * *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.
16667 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
16668 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
16669 /// * *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.
16670 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
16671 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
16672 pub fn param<T>(mut self, name: T, value: T) -> ProjectOccurrenceGetNoteCall<'a, C>
16673 where
16674 T: AsRef<str>,
16675 {
16676 self._additional_params
16677 .insert(name.as_ref().to_string(), value.as_ref().to_string());
16678 self
16679 }
16680
16681 /// Identifies the authorization scope for the method you are building.
16682 ///
16683 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
16684 /// [`Scope::CloudPlatform`].
16685 ///
16686 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
16687 /// tokens for more than one scope.
16688 ///
16689 /// Usually there is more than one suitable scope to authorize an operation, some of which may
16690 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
16691 /// sufficient, a read-write scope will do as well.
16692 pub fn add_scope<St>(mut self, scope: St) -> ProjectOccurrenceGetNoteCall<'a, C>
16693 where
16694 St: AsRef<str>,
16695 {
16696 self._scopes.insert(String::from(scope.as_ref()));
16697 self
16698 }
16699 /// Identifies the authorization scope(s) for the method you are building.
16700 ///
16701 /// See [`Self::add_scope()`] for details.
16702 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectOccurrenceGetNoteCall<'a, C>
16703 where
16704 I: IntoIterator<Item = St>,
16705 St: AsRef<str>,
16706 {
16707 self._scopes
16708 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
16709 self
16710 }
16711
16712 /// Removes all scopes, and no default scope will be used either.
16713 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
16714 /// for details).
16715 pub fn clear_scopes(mut self) -> ProjectOccurrenceGetNoteCall<'a, C> {
16716 self._scopes.clear();
16717 self
16718 }
16719}
16720
16721/// Gets a summary of the number and severity of occurrences.
16722///
16723/// A builder for the *occurrences.getVulnerabilitySummary* method supported by a *project* resource.
16724/// It is not used directly, but through a [`ProjectMethods`] instance.
16725///
16726/// # Example
16727///
16728/// Instantiate a resource method builder
16729///
16730/// ```test_harness,no_run
16731/// # extern crate hyper;
16732/// # extern crate hyper_rustls;
16733/// # extern crate google_containeranalysis1 as containeranalysis1;
16734/// # async fn dox() {
16735/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
16736///
16737/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
16738/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
16739/// # .with_native_roots()
16740/// # .unwrap()
16741/// # .https_only()
16742/// # .enable_http2()
16743/// # .build();
16744///
16745/// # let executor = hyper_util::rt::TokioExecutor::new();
16746/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
16747/// # secret,
16748/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
16749/// # yup_oauth2::client::CustomHyperClientBuilder::from(
16750/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
16751/// # ),
16752/// # ).build().await.unwrap();
16753///
16754/// # let client = hyper_util::client::legacy::Client::builder(
16755/// # hyper_util::rt::TokioExecutor::new()
16756/// # )
16757/// # .build(
16758/// # hyper_rustls::HttpsConnectorBuilder::new()
16759/// # .with_native_roots()
16760/// # .unwrap()
16761/// # .https_or_http()
16762/// # .enable_http2()
16763/// # .build()
16764/// # );
16765/// # let mut hub = ContainerAnalysis::new(client, auth);
16766/// // You can configure optional parameters by calling the respective setters at will, and
16767/// // execute the final call using `doit()`.
16768/// // Values shown here are possibly random and not representative !
16769/// let result = hub.projects().occurrences_get_vulnerability_summary("parent")
16770/// .return_partial_success(true)
16771/// .filter("Lorem")
16772/// .doit().await;
16773/// # }
16774/// ```
16775pub struct ProjectOccurrenceGetVulnerabilitySummaryCall<'a, C>
16776where
16777 C: 'a,
16778{
16779 hub: &'a ContainerAnalysis<C>,
16780 _parent: String,
16781 _return_partial_success: Option<bool>,
16782 _filter: Option<String>,
16783 _delegate: Option<&'a mut dyn common::Delegate>,
16784 _additional_params: HashMap<String, String>,
16785 _scopes: BTreeSet<String>,
16786}
16787
16788impl<'a, C> common::CallBuilder for ProjectOccurrenceGetVulnerabilitySummaryCall<'a, C> {}
16789
16790impl<'a, C> ProjectOccurrenceGetVulnerabilitySummaryCall<'a, C>
16791where
16792 C: common::Connector,
16793{
16794 /// Perform the operation you have build so far.
16795 pub async fn doit(
16796 mut self,
16797 ) -> common::Result<(common::Response, VulnerabilityOccurrencesSummary)> {
16798 use std::borrow::Cow;
16799 use std::io::{Read, Seek};
16800
16801 use common::{url::Params, ToParts};
16802 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
16803
16804 let mut dd = common::DefaultDelegate;
16805 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
16806 dlg.begin(common::MethodInfo {
16807 id: "containeranalysis.projects.occurrences.getVulnerabilitySummary",
16808 http_method: hyper::Method::GET,
16809 });
16810
16811 for &field in ["alt", "parent", "returnPartialSuccess", "filter"].iter() {
16812 if self._additional_params.contains_key(field) {
16813 dlg.finished(false);
16814 return Err(common::Error::FieldClash(field));
16815 }
16816 }
16817
16818 let mut params = Params::with_capacity(5 + self._additional_params.len());
16819 params.push("parent", self._parent);
16820 if let Some(value) = self._return_partial_success.as_ref() {
16821 params.push("returnPartialSuccess", value.to_string());
16822 }
16823 if let Some(value) = self._filter.as_ref() {
16824 params.push("filter", value);
16825 }
16826
16827 params.extend(self._additional_params.iter());
16828
16829 params.push("alt", "json");
16830 let mut url = self.hub._base_url.clone() + "v1/{+parent}/occurrences:vulnerabilitySummary";
16831 if self._scopes.is_empty() {
16832 self._scopes
16833 .insert(Scope::CloudPlatform.as_ref().to_string());
16834 }
16835
16836 #[allow(clippy::single_element_loop)]
16837 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
16838 url = params.uri_replacement(url, param_name, find_this, true);
16839 }
16840 {
16841 let to_remove = ["parent"];
16842 params.remove_params(&to_remove);
16843 }
16844
16845 let url = params.parse_with_url(&url);
16846
16847 loop {
16848 let token = match self
16849 .hub
16850 .auth
16851 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
16852 .await
16853 {
16854 Ok(token) => token,
16855 Err(e) => match dlg.token(e) {
16856 Ok(token) => token,
16857 Err(e) => {
16858 dlg.finished(false);
16859 return Err(common::Error::MissingToken(e));
16860 }
16861 },
16862 };
16863 let mut req_result = {
16864 let client = &self.hub.client;
16865 dlg.pre_request();
16866 let mut req_builder = hyper::Request::builder()
16867 .method(hyper::Method::GET)
16868 .uri(url.as_str())
16869 .header(USER_AGENT, self.hub._user_agent.clone());
16870
16871 if let Some(token) = token.as_ref() {
16872 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
16873 }
16874
16875 let request = req_builder
16876 .header(CONTENT_LENGTH, 0_u64)
16877 .body(common::to_body::<String>(None));
16878
16879 client.request(request.unwrap()).await
16880 };
16881
16882 match req_result {
16883 Err(err) => {
16884 if let common::Retry::After(d) = dlg.http_error(&err) {
16885 sleep(d).await;
16886 continue;
16887 }
16888 dlg.finished(false);
16889 return Err(common::Error::HttpError(err));
16890 }
16891 Ok(res) => {
16892 let (mut parts, body) = res.into_parts();
16893 let mut body = common::Body::new(body);
16894 if !parts.status.is_success() {
16895 let bytes = common::to_bytes(body).await.unwrap_or_default();
16896 let error = serde_json::from_str(&common::to_string(&bytes));
16897 let response = common::to_response(parts, bytes.into());
16898
16899 if let common::Retry::After(d) =
16900 dlg.http_failure(&response, error.as_ref().ok())
16901 {
16902 sleep(d).await;
16903 continue;
16904 }
16905
16906 dlg.finished(false);
16907
16908 return Err(match error {
16909 Ok(value) => common::Error::BadRequest(value),
16910 _ => common::Error::Failure(response),
16911 });
16912 }
16913 let response = {
16914 let bytes = common::to_bytes(body).await.unwrap_or_default();
16915 let encoded = common::to_string(&bytes);
16916 match serde_json::from_str(&encoded) {
16917 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
16918 Err(error) => {
16919 dlg.response_json_decode_error(&encoded, &error);
16920 return Err(common::Error::JsonDecodeError(
16921 encoded.to_string(),
16922 error,
16923 ));
16924 }
16925 }
16926 };
16927
16928 dlg.finished(true);
16929 return Ok(response);
16930 }
16931 }
16932 }
16933 }
16934
16935 /// Required. The name of the project to get a vulnerability summary for in the form of `projects/[PROJECT_ID]`.
16936 ///
16937 /// Sets the *parent* path property to the given value.
16938 ///
16939 /// Even though the property as already been set when instantiating this call,
16940 /// we provide this method for API completeness.
16941 pub fn parent(
16942 mut self,
16943 new_value: &str,
16944 ) -> ProjectOccurrenceGetVulnerabilitySummaryCall<'a, C> {
16945 self._parent = new_value.to_string();
16946 self
16947 }
16948 /// If set, the request will return all reachable occurrence summaries and report all unreachable regions in the `unreachable` field in the response. Only applicable for requests in the global region.
16949 ///
16950 /// Sets the *return partial success* query property to the given value.
16951 pub fn return_partial_success(
16952 mut self,
16953 new_value: bool,
16954 ) -> ProjectOccurrenceGetVulnerabilitySummaryCall<'a, C> {
16955 self._return_partial_success = Some(new_value);
16956 self
16957 }
16958 /// The filter expression.
16959 ///
16960 /// Sets the *filter* query property to the given value.
16961 pub fn filter(
16962 mut self,
16963 new_value: &str,
16964 ) -> ProjectOccurrenceGetVulnerabilitySummaryCall<'a, C> {
16965 self._filter = Some(new_value.to_string());
16966 self
16967 }
16968 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
16969 /// while executing the actual API request.
16970 ///
16971 /// ````text
16972 /// It should be used to handle progress information, and to implement a certain level of resilience.
16973 /// ````
16974 ///
16975 /// Sets the *delegate* property to the given value.
16976 pub fn delegate(
16977 mut self,
16978 new_value: &'a mut dyn common::Delegate,
16979 ) -> ProjectOccurrenceGetVulnerabilitySummaryCall<'a, C> {
16980 self._delegate = Some(new_value);
16981 self
16982 }
16983
16984 /// Set any additional parameter of the query string used in the request.
16985 /// It should be used to set parameters which are not yet available through their own
16986 /// setters.
16987 ///
16988 /// Please note that this method must not be used to set any of the known parameters
16989 /// which have their own setter method. If done anyway, the request will fail.
16990 ///
16991 /// # Additional Parameters
16992 ///
16993 /// * *$.xgafv* (query-string) - V1 error format.
16994 /// * *access_token* (query-string) - OAuth access token.
16995 /// * *alt* (query-string) - Data format for response.
16996 /// * *callback* (query-string) - JSONP
16997 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
16998 /// * *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.
16999 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17000 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17001 /// * *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.
17002 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17003 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17004 pub fn param<T>(
17005 mut self,
17006 name: T,
17007 value: T,
17008 ) -> ProjectOccurrenceGetVulnerabilitySummaryCall<'a, C>
17009 where
17010 T: AsRef<str>,
17011 {
17012 self._additional_params
17013 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17014 self
17015 }
17016
17017 /// Identifies the authorization scope for the method you are building.
17018 ///
17019 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17020 /// [`Scope::CloudPlatform`].
17021 ///
17022 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17023 /// tokens for more than one scope.
17024 ///
17025 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17026 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17027 /// sufficient, a read-write scope will do as well.
17028 pub fn add_scope<St>(mut self, scope: St) -> ProjectOccurrenceGetVulnerabilitySummaryCall<'a, C>
17029 where
17030 St: AsRef<str>,
17031 {
17032 self._scopes.insert(String::from(scope.as_ref()));
17033 self
17034 }
17035 /// Identifies the authorization scope(s) for the method you are building.
17036 ///
17037 /// See [`Self::add_scope()`] for details.
17038 pub fn add_scopes<I, St>(
17039 mut self,
17040 scopes: I,
17041 ) -> ProjectOccurrenceGetVulnerabilitySummaryCall<'a, C>
17042 where
17043 I: IntoIterator<Item = St>,
17044 St: AsRef<str>,
17045 {
17046 self._scopes
17047 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17048 self
17049 }
17050
17051 /// Removes all scopes, and no default scope will be used either.
17052 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17053 /// for details).
17054 pub fn clear_scopes(mut self) -> ProjectOccurrenceGetVulnerabilitySummaryCall<'a, C> {
17055 self._scopes.clear();
17056 self
17057 }
17058}
17059
17060/// Lists occurrences for the specified project.
17061///
17062/// A builder for the *occurrences.list* method supported by a *project* resource.
17063/// It is not used directly, but through a [`ProjectMethods`] instance.
17064///
17065/// # Example
17066///
17067/// Instantiate a resource method builder
17068///
17069/// ```test_harness,no_run
17070/// # extern crate hyper;
17071/// # extern crate hyper_rustls;
17072/// # extern crate google_containeranalysis1 as containeranalysis1;
17073/// # async fn dox() {
17074/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17075///
17076/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17077/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17078/// # .with_native_roots()
17079/// # .unwrap()
17080/// # .https_only()
17081/// # .enable_http2()
17082/// # .build();
17083///
17084/// # let executor = hyper_util::rt::TokioExecutor::new();
17085/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17086/// # secret,
17087/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17088/// # yup_oauth2::client::CustomHyperClientBuilder::from(
17089/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
17090/// # ),
17091/// # ).build().await.unwrap();
17092///
17093/// # let client = hyper_util::client::legacy::Client::builder(
17094/// # hyper_util::rt::TokioExecutor::new()
17095/// # )
17096/// # .build(
17097/// # hyper_rustls::HttpsConnectorBuilder::new()
17098/// # .with_native_roots()
17099/// # .unwrap()
17100/// # .https_or_http()
17101/// # .enable_http2()
17102/// # .build()
17103/// # );
17104/// # let mut hub = ContainerAnalysis::new(client, auth);
17105/// // You can configure optional parameters by calling the respective setters at will, and
17106/// // execute the final call using `doit()`.
17107/// // Values shown here are possibly random and not representative !
17108/// let result = hub.projects().occurrences_list("parent")
17109/// .return_partial_success(true)
17110/// .page_token("ipsum")
17111/// .page_size(-23)
17112/// .filter("takimata")
17113/// .doit().await;
17114/// # }
17115/// ```
17116pub struct ProjectOccurrenceListCall<'a, C>
17117where
17118 C: 'a,
17119{
17120 hub: &'a ContainerAnalysis<C>,
17121 _parent: String,
17122 _return_partial_success: Option<bool>,
17123 _page_token: Option<String>,
17124 _page_size: Option<i32>,
17125 _filter: Option<String>,
17126 _delegate: Option<&'a mut dyn common::Delegate>,
17127 _additional_params: HashMap<String, String>,
17128 _scopes: BTreeSet<String>,
17129}
17130
17131impl<'a, C> common::CallBuilder for ProjectOccurrenceListCall<'a, C> {}
17132
17133impl<'a, C> ProjectOccurrenceListCall<'a, C>
17134where
17135 C: common::Connector,
17136{
17137 /// Perform the operation you have build so far.
17138 pub async fn doit(mut self) -> common::Result<(common::Response, ListOccurrencesResponse)> {
17139 use std::borrow::Cow;
17140 use std::io::{Read, Seek};
17141
17142 use common::{url::Params, ToParts};
17143 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17144
17145 let mut dd = common::DefaultDelegate;
17146 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17147 dlg.begin(common::MethodInfo {
17148 id: "containeranalysis.projects.occurrences.list",
17149 http_method: hyper::Method::GET,
17150 });
17151
17152 for &field in [
17153 "alt",
17154 "parent",
17155 "returnPartialSuccess",
17156 "pageToken",
17157 "pageSize",
17158 "filter",
17159 ]
17160 .iter()
17161 {
17162 if self._additional_params.contains_key(field) {
17163 dlg.finished(false);
17164 return Err(common::Error::FieldClash(field));
17165 }
17166 }
17167
17168 let mut params = Params::with_capacity(7 + self._additional_params.len());
17169 params.push("parent", self._parent);
17170 if let Some(value) = self._return_partial_success.as_ref() {
17171 params.push("returnPartialSuccess", value.to_string());
17172 }
17173 if let Some(value) = self._page_token.as_ref() {
17174 params.push("pageToken", value);
17175 }
17176 if let Some(value) = self._page_size.as_ref() {
17177 params.push("pageSize", value.to_string());
17178 }
17179 if let Some(value) = self._filter.as_ref() {
17180 params.push("filter", value);
17181 }
17182
17183 params.extend(self._additional_params.iter());
17184
17185 params.push("alt", "json");
17186 let mut url = self.hub._base_url.clone() + "v1/{+parent}/occurrences";
17187 if self._scopes.is_empty() {
17188 self._scopes
17189 .insert(Scope::CloudPlatform.as_ref().to_string());
17190 }
17191
17192 #[allow(clippy::single_element_loop)]
17193 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
17194 url = params.uri_replacement(url, param_name, find_this, true);
17195 }
17196 {
17197 let to_remove = ["parent"];
17198 params.remove_params(&to_remove);
17199 }
17200
17201 let url = params.parse_with_url(&url);
17202
17203 loop {
17204 let token = match self
17205 .hub
17206 .auth
17207 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17208 .await
17209 {
17210 Ok(token) => token,
17211 Err(e) => match dlg.token(e) {
17212 Ok(token) => token,
17213 Err(e) => {
17214 dlg.finished(false);
17215 return Err(common::Error::MissingToken(e));
17216 }
17217 },
17218 };
17219 let mut req_result = {
17220 let client = &self.hub.client;
17221 dlg.pre_request();
17222 let mut req_builder = hyper::Request::builder()
17223 .method(hyper::Method::GET)
17224 .uri(url.as_str())
17225 .header(USER_AGENT, self.hub._user_agent.clone());
17226
17227 if let Some(token) = token.as_ref() {
17228 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17229 }
17230
17231 let request = req_builder
17232 .header(CONTENT_LENGTH, 0_u64)
17233 .body(common::to_body::<String>(None));
17234
17235 client.request(request.unwrap()).await
17236 };
17237
17238 match req_result {
17239 Err(err) => {
17240 if let common::Retry::After(d) = dlg.http_error(&err) {
17241 sleep(d).await;
17242 continue;
17243 }
17244 dlg.finished(false);
17245 return Err(common::Error::HttpError(err));
17246 }
17247 Ok(res) => {
17248 let (mut parts, body) = res.into_parts();
17249 let mut body = common::Body::new(body);
17250 if !parts.status.is_success() {
17251 let bytes = common::to_bytes(body).await.unwrap_or_default();
17252 let error = serde_json::from_str(&common::to_string(&bytes));
17253 let response = common::to_response(parts, bytes.into());
17254
17255 if let common::Retry::After(d) =
17256 dlg.http_failure(&response, error.as_ref().ok())
17257 {
17258 sleep(d).await;
17259 continue;
17260 }
17261
17262 dlg.finished(false);
17263
17264 return Err(match error {
17265 Ok(value) => common::Error::BadRequest(value),
17266 _ => common::Error::Failure(response),
17267 });
17268 }
17269 let response = {
17270 let bytes = common::to_bytes(body).await.unwrap_or_default();
17271 let encoded = common::to_string(&bytes);
17272 match serde_json::from_str(&encoded) {
17273 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17274 Err(error) => {
17275 dlg.response_json_decode_error(&encoded, &error);
17276 return Err(common::Error::JsonDecodeError(
17277 encoded.to_string(),
17278 error,
17279 ));
17280 }
17281 }
17282 };
17283
17284 dlg.finished(true);
17285 return Ok(response);
17286 }
17287 }
17288 }
17289 }
17290
17291 /// Required. The name of the project to list occurrences for in the form of `projects/[PROJECT_ID]`.
17292 ///
17293 /// Sets the *parent* path property to the given value.
17294 ///
17295 /// Even though the property as already been set when instantiating this call,
17296 /// we provide this method for API completeness.
17297 pub fn parent(mut self, new_value: &str) -> ProjectOccurrenceListCall<'a, C> {
17298 self._parent = new_value.to_string();
17299 self
17300 }
17301 /// If set, the request will return all reachable Occurrences and report all unreachable regions in the `unreachable` field in the response. Only applicable for requests in the global region.
17302 ///
17303 /// Sets the *return partial success* query property to the given value.
17304 pub fn return_partial_success(mut self, new_value: bool) -> ProjectOccurrenceListCall<'a, C> {
17305 self._return_partial_success = Some(new_value);
17306 self
17307 }
17308 /// Token to provide to skip to a particular spot in the list.
17309 ///
17310 /// Sets the *page token* query property to the given value.
17311 pub fn page_token(mut self, new_value: &str) -> ProjectOccurrenceListCall<'a, C> {
17312 self._page_token = Some(new_value.to_string());
17313 self
17314 }
17315 /// 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.
17316 ///
17317 /// Sets the *page size* query property to the given value.
17318 pub fn page_size(mut self, new_value: i32) -> ProjectOccurrenceListCall<'a, C> {
17319 self._page_size = Some(new_value);
17320 self
17321 }
17322 /// The filter expression.
17323 ///
17324 /// Sets the *filter* query property to the given value.
17325 pub fn filter(mut self, new_value: &str) -> ProjectOccurrenceListCall<'a, C> {
17326 self._filter = Some(new_value.to_string());
17327 self
17328 }
17329 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17330 /// while executing the actual API request.
17331 ///
17332 /// ````text
17333 /// It should be used to handle progress information, and to implement a certain level of resilience.
17334 /// ````
17335 ///
17336 /// Sets the *delegate* property to the given value.
17337 pub fn delegate(
17338 mut self,
17339 new_value: &'a mut dyn common::Delegate,
17340 ) -> ProjectOccurrenceListCall<'a, C> {
17341 self._delegate = Some(new_value);
17342 self
17343 }
17344
17345 /// Set any additional parameter of the query string used in the request.
17346 /// It should be used to set parameters which are not yet available through their own
17347 /// setters.
17348 ///
17349 /// Please note that this method must not be used to set any of the known parameters
17350 /// which have their own setter method. If done anyway, the request will fail.
17351 ///
17352 /// # Additional Parameters
17353 ///
17354 /// * *$.xgafv* (query-string) - V1 error format.
17355 /// * *access_token* (query-string) - OAuth access token.
17356 /// * *alt* (query-string) - Data format for response.
17357 /// * *callback* (query-string) - JSONP
17358 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17359 /// * *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.
17360 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17361 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17362 /// * *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.
17363 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17364 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17365 pub fn param<T>(mut self, name: T, value: T) -> ProjectOccurrenceListCall<'a, C>
17366 where
17367 T: AsRef<str>,
17368 {
17369 self._additional_params
17370 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17371 self
17372 }
17373
17374 /// Identifies the authorization scope for the method you are building.
17375 ///
17376 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17377 /// [`Scope::CloudPlatform`].
17378 ///
17379 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17380 /// tokens for more than one scope.
17381 ///
17382 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17383 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17384 /// sufficient, a read-write scope will do as well.
17385 pub fn add_scope<St>(mut self, scope: St) -> ProjectOccurrenceListCall<'a, C>
17386 where
17387 St: AsRef<str>,
17388 {
17389 self._scopes.insert(String::from(scope.as_ref()));
17390 self
17391 }
17392 /// Identifies the authorization scope(s) for the method you are building.
17393 ///
17394 /// See [`Self::add_scope()`] for details.
17395 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectOccurrenceListCall<'a, C>
17396 where
17397 I: IntoIterator<Item = St>,
17398 St: AsRef<str>,
17399 {
17400 self._scopes
17401 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17402 self
17403 }
17404
17405 /// Removes all scopes, and no default scope will be used either.
17406 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17407 /// for details).
17408 pub fn clear_scopes(mut self) -> ProjectOccurrenceListCall<'a, C> {
17409 self._scopes.clear();
17410 self
17411 }
17412}
17413
17414/// Updates the specified occurrence.
17415///
17416/// A builder for the *occurrences.patch* method supported by a *project* resource.
17417/// It is not used directly, but through a [`ProjectMethods`] instance.
17418///
17419/// # Example
17420///
17421/// Instantiate a resource method builder
17422///
17423/// ```test_harness,no_run
17424/// # extern crate hyper;
17425/// # extern crate hyper_rustls;
17426/// # extern crate google_containeranalysis1 as containeranalysis1;
17427/// use containeranalysis1::api::Occurrence;
17428/// # async fn dox() {
17429/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17430///
17431/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17432/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17433/// # .with_native_roots()
17434/// # .unwrap()
17435/// # .https_only()
17436/// # .enable_http2()
17437/// # .build();
17438///
17439/// # let executor = hyper_util::rt::TokioExecutor::new();
17440/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17441/// # secret,
17442/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17443/// # yup_oauth2::client::CustomHyperClientBuilder::from(
17444/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
17445/// # ),
17446/// # ).build().await.unwrap();
17447///
17448/// # let client = hyper_util::client::legacy::Client::builder(
17449/// # hyper_util::rt::TokioExecutor::new()
17450/// # )
17451/// # .build(
17452/// # hyper_rustls::HttpsConnectorBuilder::new()
17453/// # .with_native_roots()
17454/// # .unwrap()
17455/// # .https_or_http()
17456/// # .enable_http2()
17457/// # .build()
17458/// # );
17459/// # let mut hub = ContainerAnalysis::new(client, auth);
17460/// // As the method needs a request, you would usually fill it with the desired information
17461/// // into the respective structure. Some of the parts shown here might not be applicable !
17462/// // Values shown here are possibly random and not representative !
17463/// let mut req = Occurrence::default();
17464///
17465/// // You can configure optional parameters by calling the respective setters at will, and
17466/// // execute the final call using `doit()`.
17467/// // Values shown here are possibly random and not representative !
17468/// let result = hub.projects().occurrences_patch(req, "name")
17469/// .update_mask(FieldMask::new::<&str>(&[]))
17470/// .doit().await;
17471/// # }
17472/// ```
17473pub struct ProjectOccurrencePatchCall<'a, C>
17474where
17475 C: 'a,
17476{
17477 hub: &'a ContainerAnalysis<C>,
17478 _request: Occurrence,
17479 _name: String,
17480 _update_mask: Option<common::FieldMask>,
17481 _delegate: Option<&'a mut dyn common::Delegate>,
17482 _additional_params: HashMap<String, String>,
17483 _scopes: BTreeSet<String>,
17484}
17485
17486impl<'a, C> common::CallBuilder for ProjectOccurrencePatchCall<'a, C> {}
17487
17488impl<'a, C> ProjectOccurrencePatchCall<'a, C>
17489where
17490 C: common::Connector,
17491{
17492 /// Perform the operation you have build so far.
17493 pub async fn doit(mut self) -> common::Result<(common::Response, Occurrence)> {
17494 use std::borrow::Cow;
17495 use std::io::{Read, Seek};
17496
17497 use common::{url::Params, ToParts};
17498 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17499
17500 let mut dd = common::DefaultDelegate;
17501 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17502 dlg.begin(common::MethodInfo {
17503 id: "containeranalysis.projects.occurrences.patch",
17504 http_method: hyper::Method::PATCH,
17505 });
17506
17507 for &field in ["alt", "name", "updateMask"].iter() {
17508 if self._additional_params.contains_key(field) {
17509 dlg.finished(false);
17510 return Err(common::Error::FieldClash(field));
17511 }
17512 }
17513
17514 let mut params = Params::with_capacity(5 + self._additional_params.len());
17515 params.push("name", self._name);
17516 if let Some(value) = self._update_mask.as_ref() {
17517 params.push("updateMask", value.to_string());
17518 }
17519
17520 params.extend(self._additional_params.iter());
17521
17522 params.push("alt", "json");
17523 let mut url = self.hub._base_url.clone() + "v1/{+name}";
17524 if self._scopes.is_empty() {
17525 self._scopes
17526 .insert(Scope::CloudPlatform.as_ref().to_string());
17527 }
17528
17529 #[allow(clippy::single_element_loop)]
17530 for &(find_this, param_name) in [("{+name}", "name")].iter() {
17531 url = params.uri_replacement(url, param_name, find_this, true);
17532 }
17533 {
17534 let to_remove = ["name"];
17535 params.remove_params(&to_remove);
17536 }
17537
17538 let url = params.parse_with_url(&url);
17539
17540 let mut json_mime_type = mime::APPLICATION_JSON;
17541 let mut request_value_reader = {
17542 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17543 common::remove_json_null_values(&mut value);
17544 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17545 serde_json::to_writer(&mut dst, &value).unwrap();
17546 dst
17547 };
17548 let request_size = request_value_reader
17549 .seek(std::io::SeekFrom::End(0))
17550 .unwrap();
17551 request_value_reader
17552 .seek(std::io::SeekFrom::Start(0))
17553 .unwrap();
17554
17555 loop {
17556 let token = match self
17557 .hub
17558 .auth
17559 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17560 .await
17561 {
17562 Ok(token) => token,
17563 Err(e) => match dlg.token(e) {
17564 Ok(token) => token,
17565 Err(e) => {
17566 dlg.finished(false);
17567 return Err(common::Error::MissingToken(e));
17568 }
17569 },
17570 };
17571 request_value_reader
17572 .seek(std::io::SeekFrom::Start(0))
17573 .unwrap();
17574 let mut req_result = {
17575 let client = &self.hub.client;
17576 dlg.pre_request();
17577 let mut req_builder = hyper::Request::builder()
17578 .method(hyper::Method::PATCH)
17579 .uri(url.as_str())
17580 .header(USER_AGENT, self.hub._user_agent.clone());
17581
17582 if let Some(token) = token.as_ref() {
17583 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17584 }
17585
17586 let request = req_builder
17587 .header(CONTENT_TYPE, json_mime_type.to_string())
17588 .header(CONTENT_LENGTH, request_size as u64)
17589 .body(common::to_body(
17590 request_value_reader.get_ref().clone().into(),
17591 ));
17592
17593 client.request(request.unwrap()).await
17594 };
17595
17596 match req_result {
17597 Err(err) => {
17598 if let common::Retry::After(d) = dlg.http_error(&err) {
17599 sleep(d).await;
17600 continue;
17601 }
17602 dlg.finished(false);
17603 return Err(common::Error::HttpError(err));
17604 }
17605 Ok(res) => {
17606 let (mut parts, body) = res.into_parts();
17607 let mut body = common::Body::new(body);
17608 if !parts.status.is_success() {
17609 let bytes = common::to_bytes(body).await.unwrap_or_default();
17610 let error = serde_json::from_str(&common::to_string(&bytes));
17611 let response = common::to_response(parts, bytes.into());
17612
17613 if let common::Retry::After(d) =
17614 dlg.http_failure(&response, error.as_ref().ok())
17615 {
17616 sleep(d).await;
17617 continue;
17618 }
17619
17620 dlg.finished(false);
17621
17622 return Err(match error {
17623 Ok(value) => common::Error::BadRequest(value),
17624 _ => common::Error::Failure(response),
17625 });
17626 }
17627 let response = {
17628 let bytes = common::to_bytes(body).await.unwrap_or_default();
17629 let encoded = common::to_string(&bytes);
17630 match serde_json::from_str(&encoded) {
17631 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17632 Err(error) => {
17633 dlg.response_json_decode_error(&encoded, &error);
17634 return Err(common::Error::JsonDecodeError(
17635 encoded.to_string(),
17636 error,
17637 ));
17638 }
17639 }
17640 };
17641
17642 dlg.finished(true);
17643 return Ok(response);
17644 }
17645 }
17646 }
17647 }
17648
17649 ///
17650 /// Sets the *request* property to the given value.
17651 ///
17652 /// Even though the property as already been set when instantiating this call,
17653 /// we provide this method for API completeness.
17654 pub fn request(mut self, new_value: Occurrence) -> ProjectOccurrencePatchCall<'a, C> {
17655 self._request = new_value;
17656 self
17657 }
17658 /// Required. The name of the occurrence in the form of `projects/[PROJECT_ID]/occurrences/[OCCURRENCE_ID]`.
17659 ///
17660 /// Sets the *name* path property to the given value.
17661 ///
17662 /// Even though the property as already been set when instantiating this call,
17663 /// we provide this method for API completeness.
17664 pub fn name(mut self, new_value: &str) -> ProjectOccurrencePatchCall<'a, C> {
17665 self._name = new_value.to_string();
17666 self
17667 }
17668 /// The fields to update.
17669 ///
17670 /// Sets the *update mask* query property to the given value.
17671 pub fn update_mask(
17672 mut self,
17673 new_value: common::FieldMask,
17674 ) -> ProjectOccurrencePatchCall<'a, C> {
17675 self._update_mask = Some(new_value);
17676 self
17677 }
17678 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
17679 /// while executing the actual API request.
17680 ///
17681 /// ````text
17682 /// It should be used to handle progress information, and to implement a certain level of resilience.
17683 /// ````
17684 ///
17685 /// Sets the *delegate* property to the given value.
17686 pub fn delegate(
17687 mut self,
17688 new_value: &'a mut dyn common::Delegate,
17689 ) -> ProjectOccurrencePatchCall<'a, C> {
17690 self._delegate = Some(new_value);
17691 self
17692 }
17693
17694 /// Set any additional parameter of the query string used in the request.
17695 /// It should be used to set parameters which are not yet available through their own
17696 /// setters.
17697 ///
17698 /// Please note that this method must not be used to set any of the known parameters
17699 /// which have their own setter method. If done anyway, the request will fail.
17700 ///
17701 /// # Additional Parameters
17702 ///
17703 /// * *$.xgafv* (query-string) - V1 error format.
17704 /// * *access_token* (query-string) - OAuth access token.
17705 /// * *alt* (query-string) - Data format for response.
17706 /// * *callback* (query-string) - JSONP
17707 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
17708 /// * *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.
17709 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
17710 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
17711 /// * *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.
17712 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
17713 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
17714 pub fn param<T>(mut self, name: T, value: T) -> ProjectOccurrencePatchCall<'a, C>
17715 where
17716 T: AsRef<str>,
17717 {
17718 self._additional_params
17719 .insert(name.as_ref().to_string(), value.as_ref().to_string());
17720 self
17721 }
17722
17723 /// Identifies the authorization scope for the method you are building.
17724 ///
17725 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
17726 /// [`Scope::CloudPlatform`].
17727 ///
17728 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
17729 /// tokens for more than one scope.
17730 ///
17731 /// Usually there is more than one suitable scope to authorize an operation, some of which may
17732 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
17733 /// sufficient, a read-write scope will do as well.
17734 pub fn add_scope<St>(mut self, scope: St) -> ProjectOccurrencePatchCall<'a, C>
17735 where
17736 St: AsRef<str>,
17737 {
17738 self._scopes.insert(String::from(scope.as_ref()));
17739 self
17740 }
17741 /// Identifies the authorization scope(s) for the method you are building.
17742 ///
17743 /// See [`Self::add_scope()`] for details.
17744 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectOccurrencePatchCall<'a, C>
17745 where
17746 I: IntoIterator<Item = St>,
17747 St: AsRef<str>,
17748 {
17749 self._scopes
17750 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
17751 self
17752 }
17753
17754 /// Removes all scopes, and no default scope will be used either.
17755 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
17756 /// for details).
17757 pub fn clear_scopes(mut self) -> ProjectOccurrencePatchCall<'a, C> {
17758 self._scopes.clear();
17759 self
17760 }
17761}
17762
17763/// 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.
17764///
17765/// A builder for the *occurrences.setIamPolicy* method supported by a *project* resource.
17766/// It is not used directly, but through a [`ProjectMethods`] instance.
17767///
17768/// # Example
17769///
17770/// Instantiate a resource method builder
17771///
17772/// ```test_harness,no_run
17773/// # extern crate hyper;
17774/// # extern crate hyper_rustls;
17775/// # extern crate google_containeranalysis1 as containeranalysis1;
17776/// use containeranalysis1::api::SetIamPolicyRequest;
17777/// # async fn dox() {
17778/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
17779///
17780/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
17781/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
17782/// # .with_native_roots()
17783/// # .unwrap()
17784/// # .https_only()
17785/// # .enable_http2()
17786/// # .build();
17787///
17788/// # let executor = hyper_util::rt::TokioExecutor::new();
17789/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
17790/// # secret,
17791/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
17792/// # yup_oauth2::client::CustomHyperClientBuilder::from(
17793/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
17794/// # ),
17795/// # ).build().await.unwrap();
17796///
17797/// # let client = hyper_util::client::legacy::Client::builder(
17798/// # hyper_util::rt::TokioExecutor::new()
17799/// # )
17800/// # .build(
17801/// # hyper_rustls::HttpsConnectorBuilder::new()
17802/// # .with_native_roots()
17803/// # .unwrap()
17804/// # .https_or_http()
17805/// # .enable_http2()
17806/// # .build()
17807/// # );
17808/// # let mut hub = ContainerAnalysis::new(client, auth);
17809/// // As the method needs a request, you would usually fill it with the desired information
17810/// // into the respective structure. Some of the parts shown here might not be applicable !
17811/// // Values shown here are possibly random and not representative !
17812/// let mut req = SetIamPolicyRequest::default();
17813///
17814/// // You can configure optional parameters by calling the respective setters at will, and
17815/// // execute the final call using `doit()`.
17816/// // Values shown here are possibly random and not representative !
17817/// let result = hub.projects().occurrences_set_iam_policy(req, "resource")
17818/// .doit().await;
17819/// # }
17820/// ```
17821pub struct ProjectOccurrenceSetIamPolicyCall<'a, C>
17822where
17823 C: 'a,
17824{
17825 hub: &'a ContainerAnalysis<C>,
17826 _request: SetIamPolicyRequest,
17827 _resource: String,
17828 _delegate: Option<&'a mut dyn common::Delegate>,
17829 _additional_params: HashMap<String, String>,
17830 _scopes: BTreeSet<String>,
17831}
17832
17833impl<'a, C> common::CallBuilder for ProjectOccurrenceSetIamPolicyCall<'a, C> {}
17834
17835impl<'a, C> ProjectOccurrenceSetIamPolicyCall<'a, C>
17836where
17837 C: common::Connector,
17838{
17839 /// Perform the operation you have build so far.
17840 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
17841 use std::borrow::Cow;
17842 use std::io::{Read, Seek};
17843
17844 use common::{url::Params, ToParts};
17845 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
17846
17847 let mut dd = common::DefaultDelegate;
17848 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
17849 dlg.begin(common::MethodInfo {
17850 id: "containeranalysis.projects.occurrences.setIamPolicy",
17851 http_method: hyper::Method::POST,
17852 });
17853
17854 for &field in ["alt", "resource"].iter() {
17855 if self._additional_params.contains_key(field) {
17856 dlg.finished(false);
17857 return Err(common::Error::FieldClash(field));
17858 }
17859 }
17860
17861 let mut params = Params::with_capacity(4 + self._additional_params.len());
17862 params.push("resource", self._resource);
17863
17864 params.extend(self._additional_params.iter());
17865
17866 params.push("alt", "json");
17867 let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
17868 if self._scopes.is_empty() {
17869 self._scopes
17870 .insert(Scope::CloudPlatform.as_ref().to_string());
17871 }
17872
17873 #[allow(clippy::single_element_loop)]
17874 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
17875 url = params.uri_replacement(url, param_name, find_this, true);
17876 }
17877 {
17878 let to_remove = ["resource"];
17879 params.remove_params(&to_remove);
17880 }
17881
17882 let url = params.parse_with_url(&url);
17883
17884 let mut json_mime_type = mime::APPLICATION_JSON;
17885 let mut request_value_reader = {
17886 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
17887 common::remove_json_null_values(&mut value);
17888 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
17889 serde_json::to_writer(&mut dst, &value).unwrap();
17890 dst
17891 };
17892 let request_size = request_value_reader
17893 .seek(std::io::SeekFrom::End(0))
17894 .unwrap();
17895 request_value_reader
17896 .seek(std::io::SeekFrom::Start(0))
17897 .unwrap();
17898
17899 loop {
17900 let token = match self
17901 .hub
17902 .auth
17903 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
17904 .await
17905 {
17906 Ok(token) => token,
17907 Err(e) => match dlg.token(e) {
17908 Ok(token) => token,
17909 Err(e) => {
17910 dlg.finished(false);
17911 return Err(common::Error::MissingToken(e));
17912 }
17913 },
17914 };
17915 request_value_reader
17916 .seek(std::io::SeekFrom::Start(0))
17917 .unwrap();
17918 let mut req_result = {
17919 let client = &self.hub.client;
17920 dlg.pre_request();
17921 let mut req_builder = hyper::Request::builder()
17922 .method(hyper::Method::POST)
17923 .uri(url.as_str())
17924 .header(USER_AGENT, self.hub._user_agent.clone());
17925
17926 if let Some(token) = token.as_ref() {
17927 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
17928 }
17929
17930 let request = req_builder
17931 .header(CONTENT_TYPE, json_mime_type.to_string())
17932 .header(CONTENT_LENGTH, request_size as u64)
17933 .body(common::to_body(
17934 request_value_reader.get_ref().clone().into(),
17935 ));
17936
17937 client.request(request.unwrap()).await
17938 };
17939
17940 match req_result {
17941 Err(err) => {
17942 if let common::Retry::After(d) = dlg.http_error(&err) {
17943 sleep(d).await;
17944 continue;
17945 }
17946 dlg.finished(false);
17947 return Err(common::Error::HttpError(err));
17948 }
17949 Ok(res) => {
17950 let (mut parts, body) = res.into_parts();
17951 let mut body = common::Body::new(body);
17952 if !parts.status.is_success() {
17953 let bytes = common::to_bytes(body).await.unwrap_or_default();
17954 let error = serde_json::from_str(&common::to_string(&bytes));
17955 let response = common::to_response(parts, bytes.into());
17956
17957 if let common::Retry::After(d) =
17958 dlg.http_failure(&response, error.as_ref().ok())
17959 {
17960 sleep(d).await;
17961 continue;
17962 }
17963
17964 dlg.finished(false);
17965
17966 return Err(match error {
17967 Ok(value) => common::Error::BadRequest(value),
17968 _ => common::Error::Failure(response),
17969 });
17970 }
17971 let response = {
17972 let bytes = common::to_bytes(body).await.unwrap_or_default();
17973 let encoded = common::to_string(&bytes);
17974 match serde_json::from_str(&encoded) {
17975 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
17976 Err(error) => {
17977 dlg.response_json_decode_error(&encoded, &error);
17978 return Err(common::Error::JsonDecodeError(
17979 encoded.to_string(),
17980 error,
17981 ));
17982 }
17983 }
17984 };
17985
17986 dlg.finished(true);
17987 return Ok(response);
17988 }
17989 }
17990 }
17991 }
17992
17993 ///
17994 /// Sets the *request* property to the given value.
17995 ///
17996 /// Even though the property as already been set when instantiating this call,
17997 /// we provide this method for API completeness.
17998 pub fn request(
17999 mut self,
18000 new_value: SetIamPolicyRequest,
18001 ) -> ProjectOccurrenceSetIamPolicyCall<'a, C> {
18002 self._request = new_value;
18003 self
18004 }
18005 /// 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.
18006 ///
18007 /// Sets the *resource* path property to the given value.
18008 ///
18009 /// Even though the property as already been set when instantiating this call,
18010 /// we provide this method for API completeness.
18011 pub fn resource(mut self, new_value: &str) -> ProjectOccurrenceSetIamPolicyCall<'a, C> {
18012 self._resource = new_value.to_string();
18013 self
18014 }
18015 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18016 /// while executing the actual API request.
18017 ///
18018 /// ````text
18019 /// It should be used to handle progress information, and to implement a certain level of resilience.
18020 /// ````
18021 ///
18022 /// Sets the *delegate* property to the given value.
18023 pub fn delegate(
18024 mut self,
18025 new_value: &'a mut dyn common::Delegate,
18026 ) -> ProjectOccurrenceSetIamPolicyCall<'a, C> {
18027 self._delegate = Some(new_value);
18028 self
18029 }
18030
18031 /// Set any additional parameter of the query string used in the request.
18032 /// It should be used to set parameters which are not yet available through their own
18033 /// setters.
18034 ///
18035 /// Please note that this method must not be used to set any of the known parameters
18036 /// which have their own setter method. If done anyway, the request will fail.
18037 ///
18038 /// # Additional Parameters
18039 ///
18040 /// * *$.xgafv* (query-string) - V1 error format.
18041 /// * *access_token* (query-string) - OAuth access token.
18042 /// * *alt* (query-string) - Data format for response.
18043 /// * *callback* (query-string) - JSONP
18044 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18045 /// * *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.
18046 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18047 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18048 /// * *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.
18049 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18050 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18051 pub fn param<T>(mut self, name: T, value: T) -> ProjectOccurrenceSetIamPolicyCall<'a, C>
18052 where
18053 T: AsRef<str>,
18054 {
18055 self._additional_params
18056 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18057 self
18058 }
18059
18060 /// Identifies the authorization scope for the method you are building.
18061 ///
18062 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18063 /// [`Scope::CloudPlatform`].
18064 ///
18065 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18066 /// tokens for more than one scope.
18067 ///
18068 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18069 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18070 /// sufficient, a read-write scope will do as well.
18071 pub fn add_scope<St>(mut self, scope: St) -> ProjectOccurrenceSetIamPolicyCall<'a, C>
18072 where
18073 St: AsRef<str>,
18074 {
18075 self._scopes.insert(String::from(scope.as_ref()));
18076 self
18077 }
18078 /// Identifies the authorization scope(s) for the method you are building.
18079 ///
18080 /// See [`Self::add_scope()`] for details.
18081 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectOccurrenceSetIamPolicyCall<'a, C>
18082 where
18083 I: IntoIterator<Item = St>,
18084 St: AsRef<str>,
18085 {
18086 self._scopes
18087 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18088 self
18089 }
18090
18091 /// Removes all scopes, and no default scope will be used either.
18092 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18093 /// for details).
18094 pub fn clear_scopes(mut self) -> ProjectOccurrenceSetIamPolicyCall<'a, C> {
18095 self._scopes.clear();
18096 self
18097 }
18098}
18099
18100/// 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.
18101///
18102/// A builder for the *occurrences.testIamPermissions* method supported by a *project* resource.
18103/// It is not used directly, but through a [`ProjectMethods`] instance.
18104///
18105/// # Example
18106///
18107/// Instantiate a resource method builder
18108///
18109/// ```test_harness,no_run
18110/// # extern crate hyper;
18111/// # extern crate hyper_rustls;
18112/// # extern crate google_containeranalysis1 as containeranalysis1;
18113/// use containeranalysis1::api::TestIamPermissionsRequest;
18114/// # async fn dox() {
18115/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18116///
18117/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18118/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18119/// # .with_native_roots()
18120/// # .unwrap()
18121/// # .https_only()
18122/// # .enable_http2()
18123/// # .build();
18124///
18125/// # let executor = hyper_util::rt::TokioExecutor::new();
18126/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18127/// # secret,
18128/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18129/// # yup_oauth2::client::CustomHyperClientBuilder::from(
18130/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
18131/// # ),
18132/// # ).build().await.unwrap();
18133///
18134/// # let client = hyper_util::client::legacy::Client::builder(
18135/// # hyper_util::rt::TokioExecutor::new()
18136/// # )
18137/// # .build(
18138/// # hyper_rustls::HttpsConnectorBuilder::new()
18139/// # .with_native_roots()
18140/// # .unwrap()
18141/// # .https_or_http()
18142/// # .enable_http2()
18143/// # .build()
18144/// # );
18145/// # let mut hub = ContainerAnalysis::new(client, auth);
18146/// // As the method needs a request, you would usually fill it with the desired information
18147/// // into the respective structure. Some of the parts shown here might not be applicable !
18148/// // Values shown here are possibly random and not representative !
18149/// let mut req = TestIamPermissionsRequest::default();
18150///
18151/// // You can configure optional parameters by calling the respective setters at will, and
18152/// // execute the final call using `doit()`.
18153/// // Values shown here are possibly random and not representative !
18154/// let result = hub.projects().occurrences_test_iam_permissions(req, "resource")
18155/// .doit().await;
18156/// # }
18157/// ```
18158pub struct ProjectOccurrenceTestIamPermissionCall<'a, C>
18159where
18160 C: 'a,
18161{
18162 hub: &'a ContainerAnalysis<C>,
18163 _request: TestIamPermissionsRequest,
18164 _resource: String,
18165 _delegate: Option<&'a mut dyn common::Delegate>,
18166 _additional_params: HashMap<String, String>,
18167 _scopes: BTreeSet<String>,
18168}
18169
18170impl<'a, C> common::CallBuilder for ProjectOccurrenceTestIamPermissionCall<'a, C> {}
18171
18172impl<'a, C> ProjectOccurrenceTestIamPermissionCall<'a, C>
18173where
18174 C: common::Connector,
18175{
18176 /// Perform the operation you have build so far.
18177 pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
18178 use std::borrow::Cow;
18179 use std::io::{Read, Seek};
18180
18181 use common::{url::Params, ToParts};
18182 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18183
18184 let mut dd = common::DefaultDelegate;
18185 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18186 dlg.begin(common::MethodInfo {
18187 id: "containeranalysis.projects.occurrences.testIamPermissions",
18188 http_method: hyper::Method::POST,
18189 });
18190
18191 for &field in ["alt", "resource"].iter() {
18192 if self._additional_params.contains_key(field) {
18193 dlg.finished(false);
18194 return Err(common::Error::FieldClash(field));
18195 }
18196 }
18197
18198 let mut params = Params::with_capacity(4 + self._additional_params.len());
18199 params.push("resource", self._resource);
18200
18201 params.extend(self._additional_params.iter());
18202
18203 params.push("alt", "json");
18204 let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
18205 if self._scopes.is_empty() {
18206 self._scopes
18207 .insert(Scope::CloudPlatform.as_ref().to_string());
18208 }
18209
18210 #[allow(clippy::single_element_loop)]
18211 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
18212 url = params.uri_replacement(url, param_name, find_this, true);
18213 }
18214 {
18215 let to_remove = ["resource"];
18216 params.remove_params(&to_remove);
18217 }
18218
18219 let url = params.parse_with_url(&url);
18220
18221 let mut json_mime_type = mime::APPLICATION_JSON;
18222 let mut request_value_reader = {
18223 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18224 common::remove_json_null_values(&mut value);
18225 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18226 serde_json::to_writer(&mut dst, &value).unwrap();
18227 dst
18228 };
18229 let request_size = request_value_reader
18230 .seek(std::io::SeekFrom::End(0))
18231 .unwrap();
18232 request_value_reader
18233 .seek(std::io::SeekFrom::Start(0))
18234 .unwrap();
18235
18236 loop {
18237 let token = match self
18238 .hub
18239 .auth
18240 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18241 .await
18242 {
18243 Ok(token) => token,
18244 Err(e) => match dlg.token(e) {
18245 Ok(token) => token,
18246 Err(e) => {
18247 dlg.finished(false);
18248 return Err(common::Error::MissingToken(e));
18249 }
18250 },
18251 };
18252 request_value_reader
18253 .seek(std::io::SeekFrom::Start(0))
18254 .unwrap();
18255 let mut req_result = {
18256 let client = &self.hub.client;
18257 dlg.pre_request();
18258 let mut req_builder = hyper::Request::builder()
18259 .method(hyper::Method::POST)
18260 .uri(url.as_str())
18261 .header(USER_AGENT, self.hub._user_agent.clone());
18262
18263 if let Some(token) = token.as_ref() {
18264 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18265 }
18266
18267 let request = req_builder
18268 .header(CONTENT_TYPE, json_mime_type.to_string())
18269 .header(CONTENT_LENGTH, request_size as u64)
18270 .body(common::to_body(
18271 request_value_reader.get_ref().clone().into(),
18272 ));
18273
18274 client.request(request.unwrap()).await
18275 };
18276
18277 match req_result {
18278 Err(err) => {
18279 if let common::Retry::After(d) = dlg.http_error(&err) {
18280 sleep(d).await;
18281 continue;
18282 }
18283 dlg.finished(false);
18284 return Err(common::Error::HttpError(err));
18285 }
18286 Ok(res) => {
18287 let (mut parts, body) = res.into_parts();
18288 let mut body = common::Body::new(body);
18289 if !parts.status.is_success() {
18290 let bytes = common::to_bytes(body).await.unwrap_or_default();
18291 let error = serde_json::from_str(&common::to_string(&bytes));
18292 let response = common::to_response(parts, bytes.into());
18293
18294 if let common::Retry::After(d) =
18295 dlg.http_failure(&response, error.as_ref().ok())
18296 {
18297 sleep(d).await;
18298 continue;
18299 }
18300
18301 dlg.finished(false);
18302
18303 return Err(match error {
18304 Ok(value) => common::Error::BadRequest(value),
18305 _ => common::Error::Failure(response),
18306 });
18307 }
18308 let response = {
18309 let bytes = common::to_bytes(body).await.unwrap_or_default();
18310 let encoded = common::to_string(&bytes);
18311 match serde_json::from_str(&encoded) {
18312 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18313 Err(error) => {
18314 dlg.response_json_decode_error(&encoded, &error);
18315 return Err(common::Error::JsonDecodeError(
18316 encoded.to_string(),
18317 error,
18318 ));
18319 }
18320 }
18321 };
18322
18323 dlg.finished(true);
18324 return Ok(response);
18325 }
18326 }
18327 }
18328 }
18329
18330 ///
18331 /// Sets the *request* property to the given value.
18332 ///
18333 /// Even though the property as already been set when instantiating this call,
18334 /// we provide this method for API completeness.
18335 pub fn request(
18336 mut self,
18337 new_value: TestIamPermissionsRequest,
18338 ) -> ProjectOccurrenceTestIamPermissionCall<'a, C> {
18339 self._request = new_value;
18340 self
18341 }
18342 /// 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.
18343 ///
18344 /// Sets the *resource* path property to the given value.
18345 ///
18346 /// Even though the property as already been set when instantiating this call,
18347 /// we provide this method for API completeness.
18348 pub fn resource(mut self, new_value: &str) -> ProjectOccurrenceTestIamPermissionCall<'a, C> {
18349 self._resource = new_value.to_string();
18350 self
18351 }
18352 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18353 /// while executing the actual API request.
18354 ///
18355 /// ````text
18356 /// It should be used to handle progress information, and to implement a certain level of resilience.
18357 /// ````
18358 ///
18359 /// Sets the *delegate* property to the given value.
18360 pub fn delegate(
18361 mut self,
18362 new_value: &'a mut dyn common::Delegate,
18363 ) -> ProjectOccurrenceTestIamPermissionCall<'a, C> {
18364 self._delegate = Some(new_value);
18365 self
18366 }
18367
18368 /// Set any additional parameter of the query string used in the request.
18369 /// It should be used to set parameters which are not yet available through their own
18370 /// setters.
18371 ///
18372 /// Please note that this method must not be used to set any of the known parameters
18373 /// which have their own setter method. If done anyway, the request will fail.
18374 ///
18375 /// # Additional Parameters
18376 ///
18377 /// * *$.xgafv* (query-string) - V1 error format.
18378 /// * *access_token* (query-string) - OAuth access token.
18379 /// * *alt* (query-string) - Data format for response.
18380 /// * *callback* (query-string) - JSONP
18381 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18382 /// * *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.
18383 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18384 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18385 /// * *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.
18386 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18387 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18388 pub fn param<T>(mut self, name: T, value: T) -> ProjectOccurrenceTestIamPermissionCall<'a, C>
18389 where
18390 T: AsRef<str>,
18391 {
18392 self._additional_params
18393 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18394 self
18395 }
18396
18397 /// Identifies the authorization scope for the method you are building.
18398 ///
18399 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18400 /// [`Scope::CloudPlatform`].
18401 ///
18402 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18403 /// tokens for more than one scope.
18404 ///
18405 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18406 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18407 /// sufficient, a read-write scope will do as well.
18408 pub fn add_scope<St>(mut self, scope: St) -> ProjectOccurrenceTestIamPermissionCall<'a, C>
18409 where
18410 St: AsRef<str>,
18411 {
18412 self._scopes.insert(String::from(scope.as_ref()));
18413 self
18414 }
18415 /// Identifies the authorization scope(s) for the method you are building.
18416 ///
18417 /// See [`Self::add_scope()`] for details.
18418 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectOccurrenceTestIamPermissionCall<'a, C>
18419 where
18420 I: IntoIterator<Item = St>,
18421 St: AsRef<str>,
18422 {
18423 self._scopes
18424 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18425 self
18426 }
18427
18428 /// Removes all scopes, and no default scope will be used either.
18429 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18430 /// for details).
18431 pub fn clear_scopes(mut self) -> ProjectOccurrenceTestIamPermissionCall<'a, C> {
18432 self._scopes.clear();
18433 self
18434 }
18435}
18436
18437/// Generates an SBOM for the given resource.
18438///
18439/// A builder for the *resources.exportSBOM* method supported by a *project* resource.
18440/// It is not used directly, but through a [`ProjectMethods`] instance.
18441///
18442/// # Example
18443///
18444/// Instantiate a resource method builder
18445///
18446/// ```test_harness,no_run
18447/// # extern crate hyper;
18448/// # extern crate hyper_rustls;
18449/// # extern crate google_containeranalysis1 as containeranalysis1;
18450/// use containeranalysis1::api::ExportSBOMRequest;
18451/// # async fn dox() {
18452/// # use containeranalysis1::{ContainerAnalysis, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
18453///
18454/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
18455/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
18456/// # .with_native_roots()
18457/// # .unwrap()
18458/// # .https_only()
18459/// # .enable_http2()
18460/// # .build();
18461///
18462/// # let executor = hyper_util::rt::TokioExecutor::new();
18463/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
18464/// # secret,
18465/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
18466/// # yup_oauth2::client::CustomHyperClientBuilder::from(
18467/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
18468/// # ),
18469/// # ).build().await.unwrap();
18470///
18471/// # let client = hyper_util::client::legacy::Client::builder(
18472/// # hyper_util::rt::TokioExecutor::new()
18473/// # )
18474/// # .build(
18475/// # hyper_rustls::HttpsConnectorBuilder::new()
18476/// # .with_native_roots()
18477/// # .unwrap()
18478/// # .https_or_http()
18479/// # .enable_http2()
18480/// # .build()
18481/// # );
18482/// # let mut hub = ContainerAnalysis::new(client, auth);
18483/// // As the method needs a request, you would usually fill it with the desired information
18484/// // into the respective structure. Some of the parts shown here might not be applicable !
18485/// // Values shown here are possibly random and not representative !
18486/// let mut req = ExportSBOMRequest::default();
18487///
18488/// // You can configure optional parameters by calling the respective setters at will, and
18489/// // execute the final call using `doit()`.
18490/// // Values shown here are possibly random and not representative !
18491/// let result = hub.projects().resources_export_sbom(req, "name")
18492/// .doit().await;
18493/// # }
18494/// ```
18495pub struct ProjectResourceExportSBOMCall<'a, C>
18496where
18497 C: 'a,
18498{
18499 hub: &'a ContainerAnalysis<C>,
18500 _request: ExportSBOMRequest,
18501 _name: String,
18502 _delegate: Option<&'a mut dyn common::Delegate>,
18503 _additional_params: HashMap<String, String>,
18504 _scopes: BTreeSet<String>,
18505}
18506
18507impl<'a, C> common::CallBuilder for ProjectResourceExportSBOMCall<'a, C> {}
18508
18509impl<'a, C> ProjectResourceExportSBOMCall<'a, C>
18510where
18511 C: common::Connector,
18512{
18513 /// Perform the operation you have build so far.
18514 pub async fn doit(mut self) -> common::Result<(common::Response, ExportSBOMResponse)> {
18515 use std::borrow::Cow;
18516 use std::io::{Read, Seek};
18517
18518 use common::{url::Params, ToParts};
18519 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
18520
18521 let mut dd = common::DefaultDelegate;
18522 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
18523 dlg.begin(common::MethodInfo {
18524 id: "containeranalysis.projects.resources.exportSBOM",
18525 http_method: hyper::Method::POST,
18526 });
18527
18528 for &field in ["alt", "name"].iter() {
18529 if self._additional_params.contains_key(field) {
18530 dlg.finished(false);
18531 return Err(common::Error::FieldClash(field));
18532 }
18533 }
18534
18535 let mut params = Params::with_capacity(4 + self._additional_params.len());
18536 params.push("name", self._name);
18537
18538 params.extend(self._additional_params.iter());
18539
18540 params.push("alt", "json");
18541 let mut url = self.hub._base_url.clone() + "v1/{+name}:exportSBOM";
18542 if self._scopes.is_empty() {
18543 self._scopes
18544 .insert(Scope::CloudPlatform.as_ref().to_string());
18545 }
18546
18547 #[allow(clippy::single_element_loop)]
18548 for &(find_this, param_name) in [("{+name}", "name")].iter() {
18549 url = params.uri_replacement(url, param_name, find_this, true);
18550 }
18551 {
18552 let to_remove = ["name"];
18553 params.remove_params(&to_remove);
18554 }
18555
18556 let url = params.parse_with_url(&url);
18557
18558 let mut json_mime_type = mime::APPLICATION_JSON;
18559 let mut request_value_reader = {
18560 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
18561 common::remove_json_null_values(&mut value);
18562 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
18563 serde_json::to_writer(&mut dst, &value).unwrap();
18564 dst
18565 };
18566 let request_size = request_value_reader
18567 .seek(std::io::SeekFrom::End(0))
18568 .unwrap();
18569 request_value_reader
18570 .seek(std::io::SeekFrom::Start(0))
18571 .unwrap();
18572
18573 loop {
18574 let token = match self
18575 .hub
18576 .auth
18577 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
18578 .await
18579 {
18580 Ok(token) => token,
18581 Err(e) => match dlg.token(e) {
18582 Ok(token) => token,
18583 Err(e) => {
18584 dlg.finished(false);
18585 return Err(common::Error::MissingToken(e));
18586 }
18587 },
18588 };
18589 request_value_reader
18590 .seek(std::io::SeekFrom::Start(0))
18591 .unwrap();
18592 let mut req_result = {
18593 let client = &self.hub.client;
18594 dlg.pre_request();
18595 let mut req_builder = hyper::Request::builder()
18596 .method(hyper::Method::POST)
18597 .uri(url.as_str())
18598 .header(USER_AGENT, self.hub._user_agent.clone());
18599
18600 if let Some(token) = token.as_ref() {
18601 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
18602 }
18603
18604 let request = req_builder
18605 .header(CONTENT_TYPE, json_mime_type.to_string())
18606 .header(CONTENT_LENGTH, request_size as u64)
18607 .body(common::to_body(
18608 request_value_reader.get_ref().clone().into(),
18609 ));
18610
18611 client.request(request.unwrap()).await
18612 };
18613
18614 match req_result {
18615 Err(err) => {
18616 if let common::Retry::After(d) = dlg.http_error(&err) {
18617 sleep(d).await;
18618 continue;
18619 }
18620 dlg.finished(false);
18621 return Err(common::Error::HttpError(err));
18622 }
18623 Ok(res) => {
18624 let (mut parts, body) = res.into_parts();
18625 let mut body = common::Body::new(body);
18626 if !parts.status.is_success() {
18627 let bytes = common::to_bytes(body).await.unwrap_or_default();
18628 let error = serde_json::from_str(&common::to_string(&bytes));
18629 let response = common::to_response(parts, bytes.into());
18630
18631 if let common::Retry::After(d) =
18632 dlg.http_failure(&response, error.as_ref().ok())
18633 {
18634 sleep(d).await;
18635 continue;
18636 }
18637
18638 dlg.finished(false);
18639
18640 return Err(match error {
18641 Ok(value) => common::Error::BadRequest(value),
18642 _ => common::Error::Failure(response),
18643 });
18644 }
18645 let response = {
18646 let bytes = common::to_bytes(body).await.unwrap_or_default();
18647 let encoded = common::to_string(&bytes);
18648 match serde_json::from_str(&encoded) {
18649 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
18650 Err(error) => {
18651 dlg.response_json_decode_error(&encoded, &error);
18652 return Err(common::Error::JsonDecodeError(
18653 encoded.to_string(),
18654 error,
18655 ));
18656 }
18657 }
18658 };
18659
18660 dlg.finished(true);
18661 return Ok(response);
18662 }
18663 }
18664 }
18665 }
18666
18667 ///
18668 /// Sets the *request* property to the given value.
18669 ///
18670 /// Even though the property as already been set when instantiating this call,
18671 /// we provide this method for API completeness.
18672 pub fn request(mut self, new_value: ExportSBOMRequest) -> ProjectResourceExportSBOMCall<'a, C> {
18673 self._request = new_value;
18674 self
18675 }
18676 /// Required. The name of the resource in the form of `projects/[PROJECT_ID]/resources/[RESOURCE_URL]`.
18677 ///
18678 /// Sets the *name* path property to the given value.
18679 ///
18680 /// Even though the property as already been set when instantiating this call,
18681 /// we provide this method for API completeness.
18682 pub fn name(mut self, new_value: &str) -> ProjectResourceExportSBOMCall<'a, C> {
18683 self._name = new_value.to_string();
18684 self
18685 }
18686 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
18687 /// while executing the actual API request.
18688 ///
18689 /// ````text
18690 /// It should be used to handle progress information, and to implement a certain level of resilience.
18691 /// ````
18692 ///
18693 /// Sets the *delegate* property to the given value.
18694 pub fn delegate(
18695 mut self,
18696 new_value: &'a mut dyn common::Delegate,
18697 ) -> ProjectResourceExportSBOMCall<'a, C> {
18698 self._delegate = Some(new_value);
18699 self
18700 }
18701
18702 /// Set any additional parameter of the query string used in the request.
18703 /// It should be used to set parameters which are not yet available through their own
18704 /// setters.
18705 ///
18706 /// Please note that this method must not be used to set any of the known parameters
18707 /// which have their own setter method. If done anyway, the request will fail.
18708 ///
18709 /// # Additional Parameters
18710 ///
18711 /// * *$.xgafv* (query-string) - V1 error format.
18712 /// * *access_token* (query-string) - OAuth access token.
18713 /// * *alt* (query-string) - Data format for response.
18714 /// * *callback* (query-string) - JSONP
18715 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
18716 /// * *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.
18717 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
18718 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
18719 /// * *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.
18720 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
18721 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
18722 pub fn param<T>(mut self, name: T, value: T) -> ProjectResourceExportSBOMCall<'a, C>
18723 where
18724 T: AsRef<str>,
18725 {
18726 self._additional_params
18727 .insert(name.as_ref().to_string(), value.as_ref().to_string());
18728 self
18729 }
18730
18731 /// Identifies the authorization scope for the method you are building.
18732 ///
18733 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
18734 /// [`Scope::CloudPlatform`].
18735 ///
18736 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
18737 /// tokens for more than one scope.
18738 ///
18739 /// Usually there is more than one suitable scope to authorize an operation, some of which may
18740 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
18741 /// sufficient, a read-write scope will do as well.
18742 pub fn add_scope<St>(mut self, scope: St) -> ProjectResourceExportSBOMCall<'a, C>
18743 where
18744 St: AsRef<str>,
18745 {
18746 self._scopes.insert(String::from(scope.as_ref()));
18747 self
18748 }
18749 /// Identifies the authorization scope(s) for the method you are building.
18750 ///
18751 /// See [`Self::add_scope()`] for details.
18752 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectResourceExportSBOMCall<'a, C>
18753 where
18754 I: IntoIterator<Item = St>,
18755 St: AsRef<str>,
18756 {
18757 self._scopes
18758 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
18759 self
18760 }
18761
18762 /// Removes all scopes, and no default scope will be used either.
18763 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
18764 /// for details).
18765 pub fn clear_scopes(mut self) -> ProjectResourceExportSBOMCall<'a, C> {
18766 self._scopes.clear();
18767 self
18768 }
18769}