google_binaryauthorization1/api.rs
1use std::collections::HashMap;
2use std::cell::RefCell;
3use std::default::Default;
4use std::collections::BTreeSet;
5use std::error::Error as StdError;
6use serde_json as json;
7use std::io;
8use std::fs;
9use std::mem;
10
11use hyper::client::connect;
12use tokio::io::{AsyncRead, AsyncWrite};
13use tokio::time::sleep;
14use tower_service;
15use serde::{Serialize, Deserialize};
16
17use crate::{client, client::GetToken, client::serde_with};
18
19// ##############
20// UTILITIES ###
21// ############
22
23/// Identifies the an OAuth2 authorization scope.
24/// A scope is needed when requesting an
25/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
26#[derive(PartialEq, Eq, Hash)]
27pub enum Scope {
28 /// See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
29 CloudPlatform,
30}
31
32impl AsRef<str> for Scope {
33 fn as_ref(&self) -> &str {
34 match *self {
35 Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
36 }
37 }
38}
39
40impl Default for Scope {
41 fn default() -> Scope {
42 Scope::CloudPlatform
43 }
44}
45
46
47
48// ########
49// HUB ###
50// ######
51
52/// Central instance to access all BinaryAuthorization related resource activities
53///
54/// # Examples
55///
56/// Instantiate a new hub
57///
58/// ```test_harness,no_run
59/// extern crate hyper;
60/// extern crate hyper_rustls;
61/// extern crate google_binaryauthorization1 as binaryauthorization1;
62/// use binaryauthorization1::{Result, Error};
63/// # async fn dox() {
64/// use std::default::Default;
65/// use binaryauthorization1::{BinaryAuthorization, oauth2, hyper, hyper_rustls, chrono, FieldMask};
66///
67/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
68/// // `client_secret`, among other things.
69/// let secret: oauth2::ApplicationSecret = Default::default();
70/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
71/// // unless you replace `None` with the desired Flow.
72/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
73/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
74/// // retrieve them from storage.
75/// let auth = oauth2::InstalledFlowAuthenticator::builder(
76/// secret,
77/// oauth2::InstalledFlowReturnMethod::HTTPRedirect,
78/// ).build().await.unwrap();
79/// let mut hub = BinaryAuthorization::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth);
80/// // You can configure optional parameters by calling the respective setters at will, and
81/// // execute the final call using `doit()`.
82/// // Values shown here are possibly random and not representative !
83/// let result = hub.projects().attestors_get_iam_policy("resource")
84/// .options_requested_policy_version(-27)
85/// .doit().await;
86///
87/// match result {
88/// Err(e) => match e {
89/// // The Error enum provides details about what exactly happened.
90/// // You can also just use its `Debug`, `Display` or `Error` traits
91/// Error::HttpError(_)
92/// |Error::Io(_)
93/// |Error::MissingAPIKey
94/// |Error::MissingToken(_)
95/// |Error::Cancelled
96/// |Error::UploadSizeLimitExceeded(_, _)
97/// |Error::Failure(_)
98/// |Error::BadRequest(_)
99/// |Error::FieldClash(_)
100/// |Error::JsonDecodeError(_, _) => println!("{}", e),
101/// },
102/// Ok(res) => println!("Success: {:?}", res),
103/// }
104/// # }
105/// ```
106#[derive(Clone)]
107pub struct BinaryAuthorization<S> {
108 pub client: hyper::Client<S, hyper::body::Body>,
109 pub auth: Box<dyn client::GetToken>,
110 _user_agent: String,
111 _base_url: String,
112 _root_url: String,
113}
114
115impl<'a, S> client::Hub for BinaryAuthorization<S> {}
116
117impl<'a, S> BinaryAuthorization<S> {
118
119 pub fn new<A: 'static + client::GetToken>(client: hyper::Client<S, hyper::body::Body>, auth: A) -> BinaryAuthorization<S> {
120 BinaryAuthorization {
121 client,
122 auth: Box::new(auth),
123 _user_agent: "google-api-rust-client/5.0.3".to_string(),
124 _base_url: "https://binaryauthorization.googleapis.com/".to_string(),
125 _root_url: "https://binaryauthorization.googleapis.com/".to_string(),
126 }
127 }
128
129 pub fn projects(&'a self) -> ProjectMethods<'a, S> {
130 ProjectMethods { hub: &self }
131 }
132 pub fn systempolicy(&'a self) -> SystempolicyMethods<'a, S> {
133 SystempolicyMethods { hub: &self }
134 }
135
136 /// Set the user-agent header field to use in all requests to the server.
137 /// It defaults to `google-api-rust-client/5.0.3`.
138 ///
139 /// Returns the previously set user-agent.
140 pub fn user_agent(&mut self, agent_name: String) -> String {
141 mem::replace(&mut self._user_agent, agent_name)
142 }
143
144 /// Set the base url to use in all requests to the server.
145 /// It defaults to `https://binaryauthorization.googleapis.com/`.
146 ///
147 /// Returns the previously set base url.
148 pub fn base_url(&mut self, new_base_url: String) -> String {
149 mem::replace(&mut self._base_url, new_base_url)
150 }
151
152 /// Set the root url to use in all requests to the server.
153 /// It defaults to `https://binaryauthorization.googleapis.com/`.
154 ///
155 /// Returns the previously set root url.
156 pub fn root_url(&mut self, new_root_url: String) -> String {
157 mem::replace(&mut self._root_url, new_root_url)
158 }
159}
160
161
162// ############
163// SCHEMAS ###
164// ##########
165/// An admission rule specifies either that all container images used in a pod creation request must be attested to by one or more attestors, that all pod creations will be allowed, or that all pod creations will be denied. Images matching an admission allowlist pattern are exempted from admission rules and will never block a pod creation.
166///
167/// This type is not used in any activity, and only used as *part* of another schema.
168///
169#[serde_with::serde_as(crate = "::client::serde_with")]
170#[derive(Default, Clone, Debug, Serialize, Deserialize)]
171pub struct AdmissionRule {
172 /// Required. The action when a pod creation is denied by the admission rule.
173 #[serde(rename="enforcementMode")]
174
175 pub enforcement_mode: Option<String>,
176 /// Required. How this admission rule will be evaluated.
177 #[serde(rename="evaluationMode")]
178
179 pub evaluation_mode: Option<String>,
180 /// Optional. The resource names of the attestors that must attest to a container image, in the format `projects/*/attestors/*`. Each attestor must exist before a policy can reference it. To add an attestor to a policy the principal issuing the policy change request must be able to read the attestor resource. Note: this field must be non-empty when the evaluation_mode field specifies REQUIRE_ATTESTATION, otherwise it must be empty.
181 #[serde(rename="requireAttestationsBy")]
182
183 pub require_attestations_by: Option<Vec<String>>,
184}
185
186impl client::Part for AdmissionRule {}
187
188
189/// An admission allowlist pattern exempts images from checks by admission rules.
190///
191/// This type is not used in any activity, and only used as *part* of another schema.
192///
193#[serde_with::serde_as(crate = "::client::serde_with")]
194#[derive(Default, Clone, Debug, Serialize, Deserialize)]
195pub struct AdmissionWhitelistPattern {
196 /// An image name pattern to allowlist, in the form `registry/path/to/image`. This supports a trailing `*` wildcard, but this is allowed only in text after the `registry/` part. This also supports a trailing `**` wildcard which matches subdirectories of a given entry.
197 #[serde(rename="namePattern")]
198
199 pub name_pattern: Option<String>,
200}
201
202impl client::Part for AdmissionWhitelistPattern {}
203
204
205/// 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.
206///
207/// This type is not used in any activity, and only used as *part* of another schema.
208///
209#[serde_with::serde_as(crate = "::client::serde_with")]
210#[derive(Default, Clone, Debug, Serialize, Deserialize)]
211pub struct AttestationOccurrence {
212 /// 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.
213
214 pub jwts: Option<Vec<Jwt>>,
215 /// Required. The serialized payload that is verified by one or more `signatures`.
216 #[serde(rename="serializedPayload")]
217
218 #[serde_as(as = "Option<::client::serde::urlsafe_base64::Wrapper>")]
219 pub serialized_payload: Option<Vec<u8>>,
220 /// 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.
221
222 pub signatures: Option<Vec<Signature>>,
223}
224
225impl client::Part for AttestationOccurrence {}
226
227
228/// An attestor that attests to container image artifacts. An existing attestor cannot be modified except where indicated.
229///
230/// # Activities
231///
232/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
233/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
234///
235/// * [attestors create projects](ProjectAttestorCreateCall) (request|response)
236/// * [attestors get projects](ProjectAttestorGetCall) (response)
237/// * [attestors update projects](ProjectAttestorUpdateCall) (request|response)
238#[serde_with::serde_as(crate = "::client::serde_with")]
239#[derive(Default, Clone, Debug, Serialize, Deserialize)]
240pub struct Attestor {
241 /// Optional. A descriptive comment. This field may be updated. The field may be displayed in chooser dialogs.
242
243 pub description: Option<String>,
244 /// Optional. A checksum, returned by the server, that can be sent on update requests to ensure the attestor has an up-to-date value before attempting to update it. See https://google.aip.dev/154.
245
246 pub etag: Option<String>,
247 /// Required. The resource name, in the format: `projects/*/attestors/*`. This field may not be updated.
248
249 pub name: Option<String>,
250 /// Output only. Time when the attestor was last updated.
251 #[serde(rename="updateTime")]
252
253 pub update_time: Option<client::chrono::DateTime<client::chrono::offset::Utc>>,
254 /// This specifies how an attestation will be read, and how it will be used during policy enforcement.
255 #[serde(rename="userOwnedGrafeasNote")]
256
257 pub user_owned_grafeas_note: Option<UserOwnedGrafeasNote>,
258}
259
260impl client::RequestValue for Attestor {}
261impl client::ResponseResult for Attestor {}
262
263
264/// An attestor public key that will be used to verify attestations signed by this attestor.
265///
266/// This type is not used in any activity, and only used as *part* of another schema.
267///
268#[serde_with::serde_as(crate = "::client::serde_with")]
269#[derive(Default, Clone, Debug, Serialize, Deserialize)]
270pub struct AttestorPublicKey {
271 /// ASCII-armored representation of a PGP public key, as the entire output by the command `gpg --export --armor foo@example.com` (either LF or CRLF line endings). When using this field, `id` should be left blank. The BinAuthz API handlers will calculate the ID and fill it in automatically. BinAuthz computes this ID as the OpenPGP RFC4880 V4 fingerprint, represented as upper-case hex. If `id` is provided by the caller, it will be overwritten by the API-calculated ID.
272 #[serde(rename="asciiArmoredPgpPublicKey")]
273
274 pub ascii_armored_pgp_public_key: Option<String>,
275 /// Optional. A descriptive comment. This field may be updated.
276
277 pub comment: Option<String>,
278 /// The ID of this public key. Signatures verified by BinAuthz must include the ID of the public key that can be used to verify them, and that ID must match the contents of this field exactly. Additional restrictions on this field can be imposed based on which public key type is encapsulated. See the documentation on `public_key` cases below for details.
279
280 pub id: Option<String>,
281 /// A raw PKIX SubjectPublicKeyInfo format public key. NOTE: `id` may be explicitly provided by the caller when using this type of public key, but it MUST be a valid RFC3986 URI. If `id` is left blank, a default one will be computed based on the digest of the DER encoding of the public key.
282 #[serde(rename="pkixPublicKey")]
283
284 pub pkix_public_key: Option<PkixPublicKey>,
285}
286
287impl client::Part for AttestorPublicKey {}
288
289
290/// Associates `members`, or principals, with a `role`.
291///
292/// This type is not used in any activity, and only used as *part* of another schema.
293///
294#[serde_with::serde_as(crate = "::client::serde_with")]
295#[derive(Default, Clone, Debug, Serialize, Deserialize)]
296pub struct Binding {
297 /// 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).
298
299 pub condition: Option<Expr>,
300 /// 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`. * `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. * `domain:{domain}`: The G Suite domain (primary) that represents all the users of that domain. For example, `google.com` or `example.com`.
301
302 pub members: Option<Vec<String>>,
303 /// Role that is assigned to the list of `members`, or principals. For example, `roles/viewer`, `roles/editor`, or `roles/owner`.
304
305 pub role: Option<String>,
306}
307
308impl client::Part for Binding {}
309
310
311/// 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); }
312///
313/// # Activities
314///
315/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
316/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
317///
318/// * [attestors delete projects](ProjectAttestorDeleteCall) (response)
319#[serde_with::serde_as(crate = "::client::serde_with")]
320#[derive(Default, Clone, Debug, Serialize, Deserialize)]
321pub struct Empty { _never_set: Option<bool> }
322
323impl client::ResponseResult for Empty {}
324
325
326/// 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.
327///
328/// This type is not used in any activity, and only used as *part* of another schema.
329///
330#[serde_with::serde_as(crate = "::client::serde_with")]
331#[derive(Default, Clone, Debug, Serialize, Deserialize)]
332pub struct Expr {
333 /// Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.
334
335 pub description: Option<String>,
336 /// Textual representation of an expression in Common Expression Language syntax.
337
338 pub expression: Option<String>,
339 /// Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.
340
341 pub location: Option<String>,
342 /// 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.
343
344 pub title: Option<String>,
345}
346
347impl client::Part for Expr {}
348
349
350/// 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/).
351///
352/// # Activities
353///
354/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
355/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
356///
357/// * [attestors get iam policy projects](ProjectAttestorGetIamPolicyCall) (response)
358/// * [attestors set iam policy projects](ProjectAttestorSetIamPolicyCall) (response)
359/// * [policy get iam policy projects](ProjectPolicyGetIamPolicyCall) (response)
360/// * [policy set iam policy projects](ProjectPolicySetIamPolicyCall) (response)
361#[serde_with::serde_as(crate = "::client::serde_with")]
362#[derive(Default, Clone, Debug, Serialize, Deserialize)]
363pub struct IamPolicy {
364 /// 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`.
365
366 pub bindings: Option<Vec<Binding>>,
367 /// `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.
368
369 #[serde_as(as = "Option<::client::serde::urlsafe_base64::Wrapper>")]
370 pub etag: Option<Vec<u8>>,
371 /// 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).
372
373 pub version: Option<i32>,
374}
375
376impl client::ResponseResult for IamPolicy {}
377
378
379/// There is no detailed description.
380///
381/// This type is not used in any activity, and only used as *part* of another schema.
382///
383#[serde_with::serde_as(crate = "::client::serde_with")]
384#[derive(Default, Clone, Debug, Serialize, Deserialize)]
385pub struct Jwt {
386 /// 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
387 #[serde(rename="compactJwt")]
388
389 pub compact_jwt: Option<String>,
390}
391
392impl client::Part for Jwt {}
393
394
395/// Response message for BinauthzManagementService.ListAttestors.
396///
397/// # Activities
398///
399/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
400/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
401///
402/// * [attestors list projects](ProjectAttestorListCall) (response)
403#[serde_with::serde_as(crate = "::client::serde_with")]
404#[derive(Default, Clone, Debug, Serialize, Deserialize)]
405pub struct ListAttestorsResponse {
406 /// The list of attestors.
407
408 pub attestors: Option<Vec<Attestor>>,
409 /// A token to retrieve the next page of results. Pass this value in the ListAttestorsRequest.page_token field in the subsequent call to the `ListAttestors` method to retrieve the next page of results.
410 #[serde(rename="nextPageToken")]
411
412 pub next_page_token: Option<String>,
413}
414
415impl client::ResponseResult for ListAttestorsResponse {}
416
417
418/// A public key in the PkixPublicKey format (see https://tools.ietf.org/html/rfc5280#section-4.1.2.7 for details). Public keys of this type are typically textually encoded using the PEM format.
419///
420/// This type is not used in any activity, and only used as *part* of another schema.
421///
422#[serde_with::serde_as(crate = "::client::serde_with")]
423#[derive(Default, Clone, Debug, Serialize, Deserialize)]
424pub struct PkixPublicKey {
425 /// A PEM-encoded public key, as described in https://tools.ietf.org/html/rfc7468#section-13
426 #[serde(rename="publicKeyPem")]
427
428 pub public_key_pem: Option<String>,
429 /// The signature algorithm used to verify a message against a signature using this key. These signature algorithm must match the structure and any object identifiers encoded in `public_key_pem` (i.e. this algorithm must match that of the public key).
430 #[serde(rename="signatureAlgorithm")]
431
432 pub signature_algorithm: Option<String>,
433}
434
435impl client::Part for PkixPublicKey {}
436
437
438/// A policy for container image binary authorization.
439///
440/// # Activities
441///
442/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
443/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
444///
445/// * [get policy projects](ProjectGetPolicyCall) (response)
446/// * [update policy projects](ProjectUpdatePolicyCall) (request|response)
447/// * [get policy systempolicy](SystempolicyGetPolicyCall) (response)
448#[serde_with::serde_as(crate = "::client::serde_with")]
449#[derive(Default, Clone, Debug, Serialize, Deserialize)]
450pub struct Policy {
451 /// Optional. Admission policy allowlisting. A matching admission request will always be permitted. This feature is typically used to exclude Google or third-party infrastructure images from Binary Authorization policies.
452 #[serde(rename="admissionWhitelistPatterns")]
453
454 pub admission_whitelist_patterns: Option<Vec<AdmissionWhitelistPattern>>,
455 /// Optional. Per-cluster admission rules. Cluster spec format: `location.clusterId`. There can be at most one admission rule per cluster spec. A `location` is either a compute zone (e.g. us-central1-a) or a region (e.g. us-central1). For `clusterId` syntax restrictions see https://cloud.google.com/container-engine/reference/rest/v1/projects.zones.clusters.
456 #[serde(rename="clusterAdmissionRules")]
457
458 pub cluster_admission_rules: Option<HashMap<String, AdmissionRule>>,
459 /// Required. Default admission rule for a cluster without a per-cluster, per- kubernetes-service-account, or per-istio-service-identity admission rule.
460 #[serde(rename="defaultAdmissionRule")]
461
462 pub default_admission_rule: Option<AdmissionRule>,
463 /// Optional. A descriptive comment.
464
465 pub description: Option<String>,
466 /// Optional. A checksum, returned by the server, that can be sent on update requests to ensure the policy has an up-to-date value before attempting to update it. See https://google.aip.dev/154.
467
468 pub etag: Option<String>,
469 /// Optional. Controls the evaluation of a Google-maintained global admission policy for common system-level images. Images not covered by the global policy will be subject to the project admission policy. This setting has no effect when specified inside a global admission policy.
470 #[serde(rename="globalPolicyEvaluationMode")]
471
472 pub global_policy_evaluation_mode: Option<String>,
473 /// Optional. Per-istio-service-identity admission rules. Istio service identity spec format: `spiffe:///ns//sa/` or `/ns//sa/` e.g. `spiffe://example.com/ns/test-ns/sa/default`
474 #[serde(rename="istioServiceIdentityAdmissionRules")]
475
476 pub istio_service_identity_admission_rules: Option<HashMap<String, AdmissionRule>>,
477 /// Optional. Per-kubernetes-namespace admission rules. K8s namespace spec format: `[a-z.-]+`, e.g. `some-namespace`
478 #[serde(rename="kubernetesNamespaceAdmissionRules")]
479
480 pub kubernetes_namespace_admission_rules: Option<HashMap<String, AdmissionRule>>,
481 /// Optional. Per-kubernetes-service-account admission rules. Service account spec format: `namespace:serviceaccount`. e.g. `test-ns:default`
482 #[serde(rename="kubernetesServiceAccountAdmissionRules")]
483
484 pub kubernetes_service_account_admission_rules: Option<HashMap<String, AdmissionRule>>,
485 /// Output only. The resource name, in the format `projects/*/policy`. There is at most one policy per project.
486
487 pub name: Option<String>,
488 /// Output only. Time when the policy was last updated.
489 #[serde(rename="updateTime")]
490
491 pub update_time: Option<client::chrono::DateTime<client::chrono::offset::Utc>>,
492}
493
494impl client::RequestValue for Policy {}
495impl client::ResponseResult for Policy {}
496
497
498/// Request message for `SetIamPolicy` method.
499///
500/// # Activities
501///
502/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
503/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
504///
505/// * [attestors set iam policy projects](ProjectAttestorSetIamPolicyCall) (request)
506/// * [policy set iam policy projects](ProjectPolicySetIamPolicyCall) (request)
507#[serde_with::serde_as(crate = "::client::serde_with")]
508#[derive(Default, Clone, Debug, Serialize, Deserialize)]
509pub struct SetIamPolicyRequest {
510 /// 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.
511
512 pub policy: Option<IamPolicy>,
513}
514
515impl client::RequestValue for SetIamPolicyRequest {}
516
517
518/// 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).
519///
520/// This type is not used in any activity, and only used as *part* of another schema.
521///
522#[serde_with::serde_as(crate = "::client::serde_with")]
523#[derive(Default, Clone, Debug, Serialize, Deserialize)]
524pub struct Signature {
525 /// 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"
526 #[serde(rename="publicKeyId")]
527
528 pub public_key_id: Option<String>,
529 /// 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.
530
531 #[serde_as(as = "Option<::client::serde::urlsafe_base64::Wrapper>")]
532 pub signature: Option<Vec<u8>>,
533}
534
535impl client::Part for Signature {}
536
537
538/// Request message for `TestIamPermissions` method.
539///
540/// # Activities
541///
542/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
543/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
544///
545/// * [attestors test iam permissions projects](ProjectAttestorTestIamPermissionCall) (request)
546/// * [policy test iam permissions projects](ProjectPolicyTestIamPermissionCall) (request)
547#[serde_with::serde_as(crate = "::client::serde_with")]
548#[derive(Default, Clone, Debug, Serialize, Deserialize)]
549pub struct TestIamPermissionsRequest {
550 /// 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).
551
552 pub permissions: Option<Vec<String>>,
553}
554
555impl client::RequestValue for TestIamPermissionsRequest {}
556
557
558/// Response message for `TestIamPermissions` method.
559///
560/// # Activities
561///
562/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
563/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
564///
565/// * [attestors test iam permissions projects](ProjectAttestorTestIamPermissionCall) (response)
566/// * [policy test iam permissions projects](ProjectPolicyTestIamPermissionCall) (response)
567#[serde_with::serde_as(crate = "::client::serde_with")]
568#[derive(Default, Clone, Debug, Serialize, Deserialize)]
569pub struct TestIamPermissionsResponse {
570 /// A subset of `TestPermissionsRequest.permissions` that the caller is allowed.
571
572 pub permissions: Option<Vec<String>>,
573}
574
575impl client::ResponseResult for TestIamPermissionsResponse {}
576
577
578/// An user owned Grafeas note references a Grafeas Attestation.Authority Note created by the user.
579///
580/// This type is not used in any activity, and only used as *part* of another schema.
581///
582#[serde_with::serde_as(crate = "::client::serde_with")]
583#[derive(Default, Clone, Debug, Serialize, Deserialize)]
584pub struct UserOwnedGrafeasNote {
585 /// Output only. This field will contain the service account email address that this Attestor will use as the principal when querying Container Analysis. Attestor administrators must grant this service account the IAM role needed to read attestations from the note_reference in Container Analysis (`containeranalysis.notes.occurrences.viewer`). This email address is fixed for the lifetime of the Attestor, but callers should not make any other assumptions about the service account email; future versions may use an email based on a different naming pattern.
586 #[serde(rename="delegationServiceAccountEmail")]
587
588 pub delegation_service_account_email: Option<String>,
589 /// Required. The Grafeas resource name of a Attestation.Authority Note, created by the user, in the format: `projects/*/notes/*`. This field may not be updated. An attestation by this attestor is stored as a Grafeas Attestation.Authority Occurrence that names a container image and that links to this Note. Grafeas is an external dependency.
590 #[serde(rename="noteReference")]
591
592 pub note_reference: Option<String>,
593 /// Optional. Public keys that verify attestations signed by this attestor. This field may be updated. If this field is non-empty, one of the specified public keys must verify that an attestation was signed by this attestor for the image specified in the admission request. If this field is empty, this attestor always returns that no valid attestations exist.
594 #[serde(rename="publicKeys")]
595
596 pub public_keys: Option<Vec<AttestorPublicKey>>,
597}
598
599impl client::Part for UserOwnedGrafeasNote {}
600
601
602/// Request message for ValidationHelperV1.ValidateAttestationOccurrence.
603///
604/// # Activities
605///
606/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
607/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
608///
609/// * [attestors validate attestation occurrence projects](ProjectAttestorValidateAttestationOccurrenceCall) (request)
610#[serde_with::serde_as(crate = "::client::serde_with")]
611#[derive(Default, Clone, Debug, Serialize, Deserialize)]
612pub struct ValidateAttestationOccurrenceRequest {
613 /// Required. An AttestationOccurrence to be checked that it can be verified by the Attestor. It does not have to be an existing entity in Container Analysis. It must otherwise be a valid AttestationOccurrence.
614
615 pub attestation: Option<AttestationOccurrence>,
616 /// Required. The resource name of the Note to which the containing Occurrence is associated.
617 #[serde(rename="occurrenceNote")]
618
619 pub occurrence_note: Option<String>,
620 /// Required. The URI of the artifact (e.g. container image) that is the subject of the containing Occurrence.
621 #[serde(rename="occurrenceResourceUri")]
622
623 pub occurrence_resource_uri: Option<String>,
624}
625
626impl client::RequestValue for ValidateAttestationOccurrenceRequest {}
627
628
629/// Response message for ValidationHelperV1.ValidateAttestationOccurrence.
630///
631/// # Activities
632///
633/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
634/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
635///
636/// * [attestors validate attestation occurrence projects](ProjectAttestorValidateAttestationOccurrenceCall) (response)
637#[serde_with::serde_as(crate = "::client::serde_with")]
638#[derive(Default, Clone, Debug, Serialize, Deserialize)]
639pub struct ValidateAttestationOccurrenceResponse {
640 /// The reason for denial if the Attestation couldn't be validated.
641 #[serde(rename="denialReason")]
642
643 pub denial_reason: Option<String>,
644 /// The result of the Attestation validation.
645
646 pub result: Option<String>,
647}
648
649impl client::ResponseResult for ValidateAttestationOccurrenceResponse {}
650
651
652
653// ###################
654// MethodBuilders ###
655// #################
656
657/// A builder providing access to all methods supported on *project* resources.
658/// It is not used directly, but through the [`BinaryAuthorization`] hub.
659///
660/// # Example
661///
662/// Instantiate a resource builder
663///
664/// ```test_harness,no_run
665/// extern crate hyper;
666/// extern crate hyper_rustls;
667/// extern crate google_binaryauthorization1 as binaryauthorization1;
668///
669/// # async fn dox() {
670/// use std::default::Default;
671/// use binaryauthorization1::{BinaryAuthorization, oauth2, hyper, hyper_rustls, chrono, FieldMask};
672///
673/// let secret: oauth2::ApplicationSecret = Default::default();
674/// let auth = oauth2::InstalledFlowAuthenticator::builder(
675/// secret,
676/// oauth2::InstalledFlowReturnMethod::HTTPRedirect,
677/// ).build().await.unwrap();
678/// let mut hub = BinaryAuthorization::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth);
679/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
680/// // like `attestors_create(...)`, `attestors_delete(...)`, `attestors_get(...)`, `attestors_get_iam_policy(...)`, `attestors_list(...)`, `attestors_set_iam_policy(...)`, `attestors_test_iam_permissions(...)`, `attestors_update(...)`, `attestors_validate_attestation_occurrence(...)`, `get_policy(...)`, `policy_get_iam_policy(...)`, `policy_set_iam_policy(...)`, `policy_test_iam_permissions(...)` and `update_policy(...)`
681/// // to build up your call.
682/// let rb = hub.projects();
683/// # }
684/// ```
685pub struct ProjectMethods<'a, S>
686 where S: 'a {
687
688 hub: &'a BinaryAuthorization<S>,
689}
690
691impl<'a, S> client::MethodsBuilder for ProjectMethods<'a, S> {}
692
693impl<'a, S> ProjectMethods<'a, S> {
694
695 /// Create a builder to help you perform the following task:
696 ///
697 /// Creates an attestor, and returns a copy of the new attestor. Returns NOT_FOUND if the project does not exist, INVALID_ARGUMENT if the request is malformed, ALREADY_EXISTS if the attestor already exists.
698 ///
699 /// # Arguments
700 ///
701 /// * `request` - No description provided.
702 /// * `parent` - Required. The parent of this attestor.
703 pub fn attestors_create(&self, request: Attestor, parent: &str) -> ProjectAttestorCreateCall<'a, S> {
704 ProjectAttestorCreateCall {
705 hub: self.hub,
706 _request: request,
707 _parent: parent.to_string(),
708 _attestor_id: Default::default(),
709 _delegate: Default::default(),
710 _additional_params: Default::default(),
711 _scopes: Default::default(),
712 }
713 }
714
715 /// Create a builder to help you perform the following task:
716 ///
717 /// Deletes an attestor. Returns NOT_FOUND if the attestor does not exist.
718 ///
719 /// # Arguments
720 ///
721 /// * `name` - Required. The name of the attestors to delete, in the format `projects/*/attestors/*`.
722 pub fn attestors_delete(&self, name: &str) -> ProjectAttestorDeleteCall<'a, S> {
723 ProjectAttestorDeleteCall {
724 hub: self.hub,
725 _name: name.to_string(),
726 _delegate: Default::default(),
727 _additional_params: Default::default(),
728 _scopes: Default::default(),
729 }
730 }
731
732 /// Create a builder to help you perform the following task:
733 ///
734 /// Gets an attestor. Returns NOT_FOUND if the attestor does not exist.
735 ///
736 /// # Arguments
737 ///
738 /// * `name` - Required. The name of the attestor to retrieve, in the format `projects/*/attestors/*`.
739 pub fn attestors_get(&self, name: &str) -> ProjectAttestorGetCall<'a, S> {
740 ProjectAttestorGetCall {
741 hub: self.hub,
742 _name: name.to_string(),
743 _delegate: Default::default(),
744 _additional_params: Default::default(),
745 _scopes: Default::default(),
746 }
747 }
748
749 /// Create a builder to help you perform the following task:
750 ///
751 /// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
752 ///
753 /// # Arguments
754 ///
755 /// * `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.
756 pub fn attestors_get_iam_policy(&self, resource: &str) -> ProjectAttestorGetIamPolicyCall<'a, S> {
757 ProjectAttestorGetIamPolicyCall {
758 hub: self.hub,
759 _resource: resource.to_string(),
760 _options_requested_policy_version: Default::default(),
761 _delegate: Default::default(),
762 _additional_params: Default::default(),
763 _scopes: Default::default(),
764 }
765 }
766
767 /// Create a builder to help you perform the following task:
768 ///
769 /// Lists attestors. Returns INVALID_ARGUMENT if the project does not exist.
770 ///
771 /// # Arguments
772 ///
773 /// * `parent` - Required. The resource name of the project associated with the attestors, in the format `projects/*`.
774 pub fn attestors_list(&self, parent: &str) -> ProjectAttestorListCall<'a, S> {
775 ProjectAttestorListCall {
776 hub: self.hub,
777 _parent: parent.to_string(),
778 _page_token: Default::default(),
779 _page_size: Default::default(),
780 _delegate: Default::default(),
781 _additional_params: Default::default(),
782 _scopes: Default::default(),
783 }
784 }
785
786 /// Create a builder to help you perform the following task:
787 ///
788 /// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
789 ///
790 /// # Arguments
791 ///
792 /// * `request` - No description provided.
793 /// * `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.
794 pub fn attestors_set_iam_policy(&self, request: SetIamPolicyRequest, resource: &str) -> ProjectAttestorSetIamPolicyCall<'a, S> {
795 ProjectAttestorSetIamPolicyCall {
796 hub: self.hub,
797 _request: request,
798 _resource: resource.to_string(),
799 _delegate: Default::default(),
800 _additional_params: Default::default(),
801 _scopes: Default::default(),
802 }
803 }
804
805 /// Create a builder to help you perform the following task:
806 ///
807 /// Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
808 ///
809 /// # Arguments
810 ///
811 /// * `request` - No description provided.
812 /// * `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.
813 pub fn attestors_test_iam_permissions(&self, request: TestIamPermissionsRequest, resource: &str) -> ProjectAttestorTestIamPermissionCall<'a, S> {
814 ProjectAttestorTestIamPermissionCall {
815 hub: self.hub,
816 _request: request,
817 _resource: resource.to_string(),
818 _delegate: Default::default(),
819 _additional_params: Default::default(),
820 _scopes: Default::default(),
821 }
822 }
823
824 /// Create a builder to help you perform the following task:
825 ///
826 /// Updates an attestor. Returns NOT_FOUND if the attestor does not exist.
827 ///
828 /// # Arguments
829 ///
830 /// * `request` - No description provided.
831 /// * `name` - Required. The resource name, in the format: `projects/*/attestors/*`. This field may not be updated.
832 pub fn attestors_update(&self, request: Attestor, name: &str) -> ProjectAttestorUpdateCall<'a, S> {
833 ProjectAttestorUpdateCall {
834 hub: self.hub,
835 _request: request,
836 _name: name.to_string(),
837 _delegate: Default::default(),
838 _additional_params: Default::default(),
839 _scopes: Default::default(),
840 }
841 }
842
843 /// Create a builder to help you perform the following task:
844 ///
845 /// Returns whether the given Attestation for the given image URI was signed by the given Attestor
846 ///
847 /// # Arguments
848 ///
849 /// * `request` - No description provided.
850 /// * `attestor` - Required. The resource name of the Attestor of the occurrence, in the format `projects/*/attestors/*`.
851 pub fn attestors_validate_attestation_occurrence(&self, request: ValidateAttestationOccurrenceRequest, attestor: &str) -> ProjectAttestorValidateAttestationOccurrenceCall<'a, S> {
852 ProjectAttestorValidateAttestationOccurrenceCall {
853 hub: self.hub,
854 _request: request,
855 _attestor: attestor.to_string(),
856 _delegate: Default::default(),
857 _additional_params: Default::default(),
858 _scopes: Default::default(),
859 }
860 }
861
862 /// Create a builder to help you perform the following task:
863 ///
864 /// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
865 ///
866 /// # Arguments
867 ///
868 /// * `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.
869 pub fn policy_get_iam_policy(&self, resource: &str) -> ProjectPolicyGetIamPolicyCall<'a, S> {
870 ProjectPolicyGetIamPolicyCall {
871 hub: self.hub,
872 _resource: resource.to_string(),
873 _options_requested_policy_version: Default::default(),
874 _delegate: Default::default(),
875 _additional_params: Default::default(),
876 _scopes: Default::default(),
877 }
878 }
879
880 /// Create a builder to help you perform the following task:
881 ///
882 /// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
883 ///
884 /// # Arguments
885 ///
886 /// * `request` - No description provided.
887 /// * `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.
888 pub fn policy_set_iam_policy(&self, request: SetIamPolicyRequest, resource: &str) -> ProjectPolicySetIamPolicyCall<'a, S> {
889 ProjectPolicySetIamPolicyCall {
890 hub: self.hub,
891 _request: request,
892 _resource: resource.to_string(),
893 _delegate: Default::default(),
894 _additional_params: Default::default(),
895 _scopes: Default::default(),
896 }
897 }
898
899 /// Create a builder to help you perform the following task:
900 ///
901 /// Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
902 ///
903 /// # Arguments
904 ///
905 /// * `request` - No description provided.
906 /// * `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.
907 pub fn policy_test_iam_permissions(&self, request: TestIamPermissionsRequest, resource: &str) -> ProjectPolicyTestIamPermissionCall<'a, S> {
908 ProjectPolicyTestIamPermissionCall {
909 hub: self.hub,
910 _request: request,
911 _resource: resource.to_string(),
912 _delegate: Default::default(),
913 _additional_params: Default::default(),
914 _scopes: Default::default(),
915 }
916 }
917
918 /// Create a builder to help you perform the following task:
919 ///
920 /// A policy specifies the attestors that must attest to a container image, before the project is allowed to deploy that image. There is at most one policy per project. All image admission requests are permitted if a project has no policy. Gets the policy for this project. Returns a default policy if the project does not have one.
921 ///
922 /// # Arguments
923 ///
924 /// * `name` - Required. The resource name of the policy to retrieve, in the format `projects/*/policy`.
925 pub fn get_policy(&self, name: &str) -> ProjectGetPolicyCall<'a, S> {
926 ProjectGetPolicyCall {
927 hub: self.hub,
928 _name: name.to_string(),
929 _delegate: Default::default(),
930 _additional_params: Default::default(),
931 _scopes: Default::default(),
932 }
933 }
934
935 /// Create a builder to help you perform the following task:
936 ///
937 /// Creates or updates a project's policy, and returns a copy of the new policy. A policy is always updated as a whole, to avoid race conditions with concurrent policy enforcement (or management!) requests. Returns NOT_FOUND if the project does not exist, INVALID_ARGUMENT if the request is malformed.
938 ///
939 /// # Arguments
940 ///
941 /// * `request` - No description provided.
942 /// * `name` - Output only. The resource name, in the format `projects/*/policy`. There is at most one policy per project.
943 pub fn update_policy(&self, request: Policy, name: &str) -> ProjectUpdatePolicyCall<'a, S> {
944 ProjectUpdatePolicyCall {
945 hub: self.hub,
946 _request: request,
947 _name: name.to_string(),
948 _delegate: Default::default(),
949 _additional_params: Default::default(),
950 _scopes: Default::default(),
951 }
952 }
953}
954
955
956
957/// A builder providing access to all methods supported on *systempolicy* resources.
958/// It is not used directly, but through the [`BinaryAuthorization`] hub.
959///
960/// # Example
961///
962/// Instantiate a resource builder
963///
964/// ```test_harness,no_run
965/// extern crate hyper;
966/// extern crate hyper_rustls;
967/// extern crate google_binaryauthorization1 as binaryauthorization1;
968///
969/// # async fn dox() {
970/// use std::default::Default;
971/// use binaryauthorization1::{BinaryAuthorization, oauth2, hyper, hyper_rustls, chrono, FieldMask};
972///
973/// let secret: oauth2::ApplicationSecret = Default::default();
974/// let auth = oauth2::InstalledFlowAuthenticator::builder(
975/// secret,
976/// oauth2::InstalledFlowReturnMethod::HTTPRedirect,
977/// ).build().await.unwrap();
978/// let mut hub = BinaryAuthorization::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth);
979/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
980/// // like `get_policy(...)`
981/// // to build up your call.
982/// let rb = hub.systempolicy();
983/// # }
984/// ```
985pub struct SystempolicyMethods<'a, S>
986 where S: 'a {
987
988 hub: &'a BinaryAuthorization<S>,
989}
990
991impl<'a, S> client::MethodsBuilder for SystempolicyMethods<'a, S> {}
992
993impl<'a, S> SystempolicyMethods<'a, S> {
994
995 /// Create a builder to help you perform the following task:
996 ///
997 /// Gets the current system policy in the specified location.
998 ///
999 /// # Arguments
1000 ///
1001 /// * `name` - Required. The resource name, in the format `locations/*/policy`. Note that the system policy is not associated with a project.
1002 pub fn get_policy(&self, name: &str) -> SystempolicyGetPolicyCall<'a, S> {
1003 SystempolicyGetPolicyCall {
1004 hub: self.hub,
1005 _name: name.to_string(),
1006 _delegate: Default::default(),
1007 _additional_params: Default::default(),
1008 _scopes: Default::default(),
1009 }
1010 }
1011}
1012
1013
1014
1015
1016
1017// ###################
1018// CallBuilders ###
1019// #################
1020
1021/// Creates an attestor, and returns a copy of the new attestor. Returns NOT_FOUND if the project does not exist, INVALID_ARGUMENT if the request is malformed, ALREADY_EXISTS if the attestor already exists.
1022///
1023/// A builder for the *attestors.create* method supported by a *project* resource.
1024/// It is not used directly, but through a [`ProjectMethods`] instance.
1025///
1026/// # Example
1027///
1028/// Instantiate a resource method builder
1029///
1030/// ```test_harness,no_run
1031/// # extern crate hyper;
1032/// # extern crate hyper_rustls;
1033/// # extern crate google_binaryauthorization1 as binaryauthorization1;
1034/// use binaryauthorization1::api::Attestor;
1035/// # async fn dox() {
1036/// # use std::default::Default;
1037/// # use binaryauthorization1::{BinaryAuthorization, oauth2, hyper, hyper_rustls, chrono, FieldMask};
1038///
1039/// # let secret: oauth2::ApplicationSecret = Default::default();
1040/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
1041/// # secret,
1042/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1043/// # ).build().await.unwrap();
1044/// # let mut hub = BinaryAuthorization::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth);
1045/// // As the method needs a request, you would usually fill it with the desired information
1046/// // into the respective structure. Some of the parts shown here might not be applicable !
1047/// // Values shown here are possibly random and not representative !
1048/// let mut req = Attestor::default();
1049///
1050/// // You can configure optional parameters by calling the respective setters at will, and
1051/// // execute the final call using `doit()`.
1052/// // Values shown here are possibly random and not representative !
1053/// let result = hub.projects().attestors_create(req, "parent")
1054/// .attestor_id("sed")
1055/// .doit().await;
1056/// # }
1057/// ```
1058pub struct ProjectAttestorCreateCall<'a, S>
1059 where S: 'a {
1060
1061 hub: &'a BinaryAuthorization<S>,
1062 _request: Attestor,
1063 _parent: String,
1064 _attestor_id: Option<String>,
1065 _delegate: Option<&'a mut dyn client::Delegate>,
1066 _additional_params: HashMap<String, String>,
1067 _scopes: BTreeSet<String>
1068}
1069
1070impl<'a, S> client::CallBuilder for ProjectAttestorCreateCall<'a, S> {}
1071
1072impl<'a, S> ProjectAttestorCreateCall<'a, S>
1073where
1074 S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
1075 S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
1076 S::Future: Send + Unpin + 'static,
1077 S::Error: Into<Box<dyn StdError + Send + Sync>>,
1078{
1079
1080
1081 /// Perform the operation you have build so far.
1082 pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Attestor)> {
1083 use std::io::{Read, Seek};
1084 use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
1085 use client::{ToParts, url::Params};
1086 use std::borrow::Cow;
1087
1088 let mut dd = client::DefaultDelegate;
1089 let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
1090 dlg.begin(client::MethodInfo { id: "binaryauthorization.projects.attestors.create",
1091 http_method: hyper::Method::POST });
1092
1093 for &field in ["alt", "parent", "attestorId"].iter() {
1094 if self._additional_params.contains_key(field) {
1095 dlg.finished(false);
1096 return Err(client::Error::FieldClash(field));
1097 }
1098 }
1099
1100 let mut params = Params::with_capacity(5 + self._additional_params.len());
1101 params.push("parent", self._parent);
1102 if let Some(value) = self._attestor_id.as_ref() {
1103 params.push("attestorId", value);
1104 }
1105
1106 params.extend(self._additional_params.iter());
1107
1108 params.push("alt", "json");
1109 let mut url = self.hub._base_url.clone() + "v1/{+parent}/attestors";
1110 if self._scopes.is_empty() {
1111 self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
1112 }
1113
1114 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
1115 url = params.uri_replacement(url, param_name, find_this, true);
1116 }
1117 {
1118 let to_remove = ["parent"];
1119 params.remove_params(&to_remove);
1120 }
1121
1122 let url = params.parse_with_url(&url);
1123
1124 let mut json_mime_type = mime::APPLICATION_JSON;
1125 let mut request_value_reader =
1126 {
1127 let mut value = json::value::to_value(&self._request).expect("serde to work");
1128 client::remove_json_null_values(&mut value);
1129 let mut dst = io::Cursor::new(Vec::with_capacity(128));
1130 json::to_writer(&mut dst, &value).unwrap();
1131 dst
1132 };
1133 let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
1134 request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
1135
1136
1137 loop {
1138 let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
1139 Ok(token) => token,
1140 Err(e) => {
1141 match dlg.token(e) {
1142 Ok(token) => token,
1143 Err(e) => {
1144 dlg.finished(false);
1145 return Err(client::Error::MissingToken(e));
1146 }
1147 }
1148 }
1149 };
1150 request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
1151 let mut req_result = {
1152 let client = &self.hub.client;
1153 dlg.pre_request();
1154 let mut req_builder = hyper::Request::builder()
1155 .method(hyper::Method::POST)
1156 .uri(url.as_str())
1157 .header(USER_AGENT, self.hub._user_agent.clone());
1158
1159 if let Some(token) = token.as_ref() {
1160 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1161 }
1162
1163
1164 let request = req_builder
1165 .header(CONTENT_TYPE, json_mime_type.to_string())
1166 .header(CONTENT_LENGTH, request_size as u64)
1167 .body(hyper::body::Body::from(request_value_reader.get_ref().clone()));
1168
1169 client.request(request.unwrap()).await
1170
1171 };
1172
1173 match req_result {
1174 Err(err) => {
1175 if let client::Retry::After(d) = dlg.http_error(&err) {
1176 sleep(d).await;
1177 continue;
1178 }
1179 dlg.finished(false);
1180 return Err(client::Error::HttpError(err))
1181 }
1182 Ok(mut res) => {
1183 if !res.status().is_success() {
1184 let res_body_string = client::get_body_as_string(res.body_mut()).await;
1185 let (parts, _) = res.into_parts();
1186 let body = hyper::Body::from(res_body_string.clone());
1187 let restored_response = hyper::Response::from_parts(parts, body);
1188
1189 let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
1190
1191 if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
1192 sleep(d).await;
1193 continue;
1194 }
1195
1196 dlg.finished(false);
1197
1198 return match server_response {
1199 Some(error_value) => Err(client::Error::BadRequest(error_value)),
1200 None => Err(client::Error::Failure(restored_response)),
1201 }
1202 }
1203 let result_value = {
1204 let res_body_string = client::get_body_as_string(res.body_mut()).await;
1205
1206 match json::from_str(&res_body_string) {
1207 Ok(decoded) => (res, decoded),
1208 Err(err) => {
1209 dlg.response_json_decode_error(&res_body_string, &err);
1210 return Err(client::Error::JsonDecodeError(res_body_string, err));
1211 }
1212 }
1213 };
1214
1215 dlg.finished(true);
1216 return Ok(result_value)
1217 }
1218 }
1219 }
1220 }
1221
1222
1223 ///
1224 /// Sets the *request* property to the given value.
1225 ///
1226 /// Even though the property as already been set when instantiating this call,
1227 /// we provide this method for API completeness.
1228 pub fn request(mut self, new_value: Attestor) -> ProjectAttestorCreateCall<'a, S> {
1229 self._request = new_value;
1230 self
1231 }
1232 /// Required. The parent of this attestor.
1233 ///
1234 /// Sets the *parent* path property to the given value.
1235 ///
1236 /// Even though the property as already been set when instantiating this call,
1237 /// we provide this method for API completeness.
1238 pub fn parent(mut self, new_value: &str) -> ProjectAttestorCreateCall<'a, S> {
1239 self._parent = new_value.to_string();
1240 self
1241 }
1242 /// Required. The attestors ID.
1243 ///
1244 /// Sets the *attestor id* query property to the given value.
1245 pub fn attestor_id(mut self, new_value: &str) -> ProjectAttestorCreateCall<'a, S> {
1246 self._attestor_id = Some(new_value.to_string());
1247 self
1248 }
1249 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1250 /// while executing the actual API request.
1251 ///
1252 /// ````text
1253 /// It should be used to handle progress information, and to implement a certain level of resilience.
1254 /// ````
1255 ///
1256 /// Sets the *delegate* property to the given value.
1257 pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ProjectAttestorCreateCall<'a, S> {
1258 self._delegate = Some(new_value);
1259 self
1260 }
1261
1262 /// Set any additional parameter of the query string used in the request.
1263 /// It should be used to set parameters which are not yet available through their own
1264 /// setters.
1265 ///
1266 /// Please note that this method must not be used to set any of the known parameters
1267 /// which have their own setter method. If done anyway, the request will fail.
1268 ///
1269 /// # Additional Parameters
1270 ///
1271 /// * *$.xgafv* (query-string) - V1 error format.
1272 /// * *access_token* (query-string) - OAuth access token.
1273 /// * *alt* (query-string) - Data format for response.
1274 /// * *callback* (query-string) - JSONP
1275 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1276 /// * *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.
1277 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1278 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1279 /// * *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.
1280 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1281 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1282 pub fn param<T>(mut self, name: T, value: T) -> ProjectAttestorCreateCall<'a, S>
1283 where T: AsRef<str> {
1284 self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
1285 self
1286 }
1287
1288 /// Identifies the authorization scope for the method you are building.
1289 ///
1290 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1291 /// [`Scope::CloudPlatform`].
1292 ///
1293 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1294 /// tokens for more than one scope.
1295 ///
1296 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1297 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1298 /// sufficient, a read-write scope will do as well.
1299 pub fn add_scope<St>(mut self, scope: St) -> ProjectAttestorCreateCall<'a, S>
1300 where St: AsRef<str> {
1301 self._scopes.insert(String::from(scope.as_ref()));
1302 self
1303 }
1304 /// Identifies the authorization scope(s) for the method you are building.
1305 ///
1306 /// See [`Self::add_scope()`] for details.
1307 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectAttestorCreateCall<'a, S>
1308 where I: IntoIterator<Item = St>,
1309 St: AsRef<str> {
1310 self._scopes
1311 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1312 self
1313 }
1314
1315 /// Removes all scopes, and no default scope will be used either.
1316 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1317 /// for details).
1318 pub fn clear_scopes(mut self) -> ProjectAttestorCreateCall<'a, S> {
1319 self._scopes.clear();
1320 self
1321 }
1322}
1323
1324
1325/// Deletes an attestor. Returns NOT_FOUND if the attestor does not exist.
1326///
1327/// A builder for the *attestors.delete* method supported by a *project* resource.
1328/// It is not used directly, but through a [`ProjectMethods`] instance.
1329///
1330/// # Example
1331///
1332/// Instantiate a resource method builder
1333///
1334/// ```test_harness,no_run
1335/// # extern crate hyper;
1336/// # extern crate hyper_rustls;
1337/// # extern crate google_binaryauthorization1 as binaryauthorization1;
1338/// # async fn dox() {
1339/// # use std::default::Default;
1340/// # use binaryauthorization1::{BinaryAuthorization, oauth2, hyper, hyper_rustls, chrono, FieldMask};
1341///
1342/// # let secret: oauth2::ApplicationSecret = Default::default();
1343/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
1344/// # secret,
1345/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1346/// # ).build().await.unwrap();
1347/// # let mut hub = BinaryAuthorization::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth);
1348/// // You can configure optional parameters by calling the respective setters at will, and
1349/// // execute the final call using `doit()`.
1350/// // Values shown here are possibly random and not representative !
1351/// let result = hub.projects().attestors_delete("name")
1352/// .doit().await;
1353/// # }
1354/// ```
1355pub struct ProjectAttestorDeleteCall<'a, S>
1356 where S: 'a {
1357
1358 hub: &'a BinaryAuthorization<S>,
1359 _name: String,
1360 _delegate: Option<&'a mut dyn client::Delegate>,
1361 _additional_params: HashMap<String, String>,
1362 _scopes: BTreeSet<String>
1363}
1364
1365impl<'a, S> client::CallBuilder for ProjectAttestorDeleteCall<'a, S> {}
1366
1367impl<'a, S> ProjectAttestorDeleteCall<'a, S>
1368where
1369 S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
1370 S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
1371 S::Future: Send + Unpin + 'static,
1372 S::Error: Into<Box<dyn StdError + Send + Sync>>,
1373{
1374
1375
1376 /// Perform the operation you have build so far.
1377 pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Empty)> {
1378 use std::io::{Read, Seek};
1379 use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
1380 use client::{ToParts, url::Params};
1381 use std::borrow::Cow;
1382
1383 let mut dd = client::DefaultDelegate;
1384 let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
1385 dlg.begin(client::MethodInfo { id: "binaryauthorization.projects.attestors.delete",
1386 http_method: hyper::Method::DELETE });
1387
1388 for &field in ["alt", "name"].iter() {
1389 if self._additional_params.contains_key(field) {
1390 dlg.finished(false);
1391 return Err(client::Error::FieldClash(field));
1392 }
1393 }
1394
1395 let mut params = Params::with_capacity(3 + self._additional_params.len());
1396 params.push("name", self._name);
1397
1398 params.extend(self._additional_params.iter());
1399
1400 params.push("alt", "json");
1401 let mut url = self.hub._base_url.clone() + "v1/{+name}";
1402 if self._scopes.is_empty() {
1403 self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
1404 }
1405
1406 for &(find_this, param_name) in [("{+name}", "name")].iter() {
1407 url = params.uri_replacement(url, param_name, find_this, true);
1408 }
1409 {
1410 let to_remove = ["name"];
1411 params.remove_params(&to_remove);
1412 }
1413
1414 let url = params.parse_with_url(&url);
1415
1416
1417
1418 loop {
1419 let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
1420 Ok(token) => token,
1421 Err(e) => {
1422 match dlg.token(e) {
1423 Ok(token) => token,
1424 Err(e) => {
1425 dlg.finished(false);
1426 return Err(client::Error::MissingToken(e));
1427 }
1428 }
1429 }
1430 };
1431 let mut req_result = {
1432 let client = &self.hub.client;
1433 dlg.pre_request();
1434 let mut req_builder = hyper::Request::builder()
1435 .method(hyper::Method::DELETE)
1436 .uri(url.as_str())
1437 .header(USER_AGENT, self.hub._user_agent.clone());
1438
1439 if let Some(token) = token.as_ref() {
1440 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1441 }
1442
1443
1444 let request = req_builder
1445 .body(hyper::body::Body::empty());
1446
1447 client.request(request.unwrap()).await
1448
1449 };
1450
1451 match req_result {
1452 Err(err) => {
1453 if let client::Retry::After(d) = dlg.http_error(&err) {
1454 sleep(d).await;
1455 continue;
1456 }
1457 dlg.finished(false);
1458 return Err(client::Error::HttpError(err))
1459 }
1460 Ok(mut res) => {
1461 if !res.status().is_success() {
1462 let res_body_string = client::get_body_as_string(res.body_mut()).await;
1463 let (parts, _) = res.into_parts();
1464 let body = hyper::Body::from(res_body_string.clone());
1465 let restored_response = hyper::Response::from_parts(parts, body);
1466
1467 let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
1468
1469 if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
1470 sleep(d).await;
1471 continue;
1472 }
1473
1474 dlg.finished(false);
1475
1476 return match server_response {
1477 Some(error_value) => Err(client::Error::BadRequest(error_value)),
1478 None => Err(client::Error::Failure(restored_response)),
1479 }
1480 }
1481 let result_value = {
1482 let res_body_string = client::get_body_as_string(res.body_mut()).await;
1483
1484 match json::from_str(&res_body_string) {
1485 Ok(decoded) => (res, decoded),
1486 Err(err) => {
1487 dlg.response_json_decode_error(&res_body_string, &err);
1488 return Err(client::Error::JsonDecodeError(res_body_string, err));
1489 }
1490 }
1491 };
1492
1493 dlg.finished(true);
1494 return Ok(result_value)
1495 }
1496 }
1497 }
1498 }
1499
1500
1501 /// Required. The name of the attestors to delete, in the format `projects/*/attestors/*`.
1502 ///
1503 /// Sets the *name* path property to the given value.
1504 ///
1505 /// Even though the property as already been set when instantiating this call,
1506 /// we provide this method for API completeness.
1507 pub fn name(mut self, new_value: &str) -> ProjectAttestorDeleteCall<'a, S> {
1508 self._name = new_value.to_string();
1509 self
1510 }
1511 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1512 /// while executing the actual API request.
1513 ///
1514 /// ````text
1515 /// It should be used to handle progress information, and to implement a certain level of resilience.
1516 /// ````
1517 ///
1518 /// Sets the *delegate* property to the given value.
1519 pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ProjectAttestorDeleteCall<'a, S> {
1520 self._delegate = Some(new_value);
1521 self
1522 }
1523
1524 /// Set any additional parameter of the query string used in the request.
1525 /// It should be used to set parameters which are not yet available through their own
1526 /// setters.
1527 ///
1528 /// Please note that this method must not be used to set any of the known parameters
1529 /// which have their own setter method. If done anyway, the request will fail.
1530 ///
1531 /// # Additional Parameters
1532 ///
1533 /// * *$.xgafv* (query-string) - V1 error format.
1534 /// * *access_token* (query-string) - OAuth access token.
1535 /// * *alt* (query-string) - Data format for response.
1536 /// * *callback* (query-string) - JSONP
1537 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1538 /// * *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.
1539 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1540 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1541 /// * *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.
1542 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1543 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1544 pub fn param<T>(mut self, name: T, value: T) -> ProjectAttestorDeleteCall<'a, S>
1545 where T: AsRef<str> {
1546 self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
1547 self
1548 }
1549
1550 /// Identifies the authorization scope for the method you are building.
1551 ///
1552 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1553 /// [`Scope::CloudPlatform`].
1554 ///
1555 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1556 /// tokens for more than one scope.
1557 ///
1558 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1559 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1560 /// sufficient, a read-write scope will do as well.
1561 pub fn add_scope<St>(mut self, scope: St) -> ProjectAttestorDeleteCall<'a, S>
1562 where St: AsRef<str> {
1563 self._scopes.insert(String::from(scope.as_ref()));
1564 self
1565 }
1566 /// Identifies the authorization scope(s) for the method you are building.
1567 ///
1568 /// See [`Self::add_scope()`] for details.
1569 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectAttestorDeleteCall<'a, S>
1570 where I: IntoIterator<Item = St>,
1571 St: AsRef<str> {
1572 self._scopes
1573 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1574 self
1575 }
1576
1577 /// Removes all scopes, and no default scope will be used either.
1578 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1579 /// for details).
1580 pub fn clear_scopes(mut self) -> ProjectAttestorDeleteCall<'a, S> {
1581 self._scopes.clear();
1582 self
1583 }
1584}
1585
1586
1587/// Gets an attestor. Returns NOT_FOUND if the attestor does not exist.
1588///
1589/// A builder for the *attestors.get* method supported by a *project* resource.
1590/// It is not used directly, but through a [`ProjectMethods`] instance.
1591///
1592/// # Example
1593///
1594/// Instantiate a resource method builder
1595///
1596/// ```test_harness,no_run
1597/// # extern crate hyper;
1598/// # extern crate hyper_rustls;
1599/// # extern crate google_binaryauthorization1 as binaryauthorization1;
1600/// # async fn dox() {
1601/// # use std::default::Default;
1602/// # use binaryauthorization1::{BinaryAuthorization, oauth2, hyper, hyper_rustls, chrono, FieldMask};
1603///
1604/// # let secret: oauth2::ApplicationSecret = Default::default();
1605/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
1606/// # secret,
1607/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1608/// # ).build().await.unwrap();
1609/// # let mut hub = BinaryAuthorization::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth);
1610/// // You can configure optional parameters by calling the respective setters at will, and
1611/// // execute the final call using `doit()`.
1612/// // Values shown here are possibly random and not representative !
1613/// let result = hub.projects().attestors_get("name")
1614/// .doit().await;
1615/// # }
1616/// ```
1617pub struct ProjectAttestorGetCall<'a, S>
1618 where S: 'a {
1619
1620 hub: &'a BinaryAuthorization<S>,
1621 _name: String,
1622 _delegate: Option<&'a mut dyn client::Delegate>,
1623 _additional_params: HashMap<String, String>,
1624 _scopes: BTreeSet<String>
1625}
1626
1627impl<'a, S> client::CallBuilder for ProjectAttestorGetCall<'a, S> {}
1628
1629impl<'a, S> ProjectAttestorGetCall<'a, S>
1630where
1631 S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
1632 S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
1633 S::Future: Send + Unpin + 'static,
1634 S::Error: Into<Box<dyn StdError + Send + Sync>>,
1635{
1636
1637
1638 /// Perform the operation you have build so far.
1639 pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Attestor)> {
1640 use std::io::{Read, Seek};
1641 use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
1642 use client::{ToParts, url::Params};
1643 use std::borrow::Cow;
1644
1645 let mut dd = client::DefaultDelegate;
1646 let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
1647 dlg.begin(client::MethodInfo { id: "binaryauthorization.projects.attestors.get",
1648 http_method: hyper::Method::GET });
1649
1650 for &field in ["alt", "name"].iter() {
1651 if self._additional_params.contains_key(field) {
1652 dlg.finished(false);
1653 return Err(client::Error::FieldClash(field));
1654 }
1655 }
1656
1657 let mut params = Params::with_capacity(3 + self._additional_params.len());
1658 params.push("name", self._name);
1659
1660 params.extend(self._additional_params.iter());
1661
1662 params.push("alt", "json");
1663 let mut url = self.hub._base_url.clone() + "v1/{+name}";
1664 if self._scopes.is_empty() {
1665 self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
1666 }
1667
1668 for &(find_this, param_name) in [("{+name}", "name")].iter() {
1669 url = params.uri_replacement(url, param_name, find_this, true);
1670 }
1671 {
1672 let to_remove = ["name"];
1673 params.remove_params(&to_remove);
1674 }
1675
1676 let url = params.parse_with_url(&url);
1677
1678
1679
1680 loop {
1681 let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
1682 Ok(token) => token,
1683 Err(e) => {
1684 match dlg.token(e) {
1685 Ok(token) => token,
1686 Err(e) => {
1687 dlg.finished(false);
1688 return Err(client::Error::MissingToken(e));
1689 }
1690 }
1691 }
1692 };
1693 let mut req_result = {
1694 let client = &self.hub.client;
1695 dlg.pre_request();
1696 let mut req_builder = hyper::Request::builder()
1697 .method(hyper::Method::GET)
1698 .uri(url.as_str())
1699 .header(USER_AGENT, self.hub._user_agent.clone());
1700
1701 if let Some(token) = token.as_ref() {
1702 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1703 }
1704
1705
1706 let request = req_builder
1707 .body(hyper::body::Body::empty());
1708
1709 client.request(request.unwrap()).await
1710
1711 };
1712
1713 match req_result {
1714 Err(err) => {
1715 if let client::Retry::After(d) = dlg.http_error(&err) {
1716 sleep(d).await;
1717 continue;
1718 }
1719 dlg.finished(false);
1720 return Err(client::Error::HttpError(err))
1721 }
1722 Ok(mut res) => {
1723 if !res.status().is_success() {
1724 let res_body_string = client::get_body_as_string(res.body_mut()).await;
1725 let (parts, _) = res.into_parts();
1726 let body = hyper::Body::from(res_body_string.clone());
1727 let restored_response = hyper::Response::from_parts(parts, body);
1728
1729 let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
1730
1731 if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
1732 sleep(d).await;
1733 continue;
1734 }
1735
1736 dlg.finished(false);
1737
1738 return match server_response {
1739 Some(error_value) => Err(client::Error::BadRequest(error_value)),
1740 None => Err(client::Error::Failure(restored_response)),
1741 }
1742 }
1743 let result_value = {
1744 let res_body_string = client::get_body_as_string(res.body_mut()).await;
1745
1746 match json::from_str(&res_body_string) {
1747 Ok(decoded) => (res, decoded),
1748 Err(err) => {
1749 dlg.response_json_decode_error(&res_body_string, &err);
1750 return Err(client::Error::JsonDecodeError(res_body_string, err));
1751 }
1752 }
1753 };
1754
1755 dlg.finished(true);
1756 return Ok(result_value)
1757 }
1758 }
1759 }
1760 }
1761
1762
1763 /// Required. The name of the attestor to retrieve, in the format `projects/*/attestors/*`.
1764 ///
1765 /// Sets the *name* path property to the given value.
1766 ///
1767 /// Even though the property as already been set when instantiating this call,
1768 /// we provide this method for API completeness.
1769 pub fn name(mut self, new_value: &str) -> ProjectAttestorGetCall<'a, S> {
1770 self._name = new_value.to_string();
1771 self
1772 }
1773 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1774 /// while executing the actual API request.
1775 ///
1776 /// ````text
1777 /// It should be used to handle progress information, and to implement a certain level of resilience.
1778 /// ````
1779 ///
1780 /// Sets the *delegate* property to the given value.
1781 pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ProjectAttestorGetCall<'a, S> {
1782 self._delegate = Some(new_value);
1783 self
1784 }
1785
1786 /// Set any additional parameter of the query string used in the request.
1787 /// It should be used to set parameters which are not yet available through their own
1788 /// setters.
1789 ///
1790 /// Please note that this method must not be used to set any of the known parameters
1791 /// which have their own setter method. If done anyway, the request will fail.
1792 ///
1793 /// # Additional Parameters
1794 ///
1795 /// * *$.xgafv* (query-string) - V1 error format.
1796 /// * *access_token* (query-string) - OAuth access token.
1797 /// * *alt* (query-string) - Data format for response.
1798 /// * *callback* (query-string) - JSONP
1799 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
1800 /// * *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.
1801 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
1802 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
1803 /// * *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.
1804 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
1805 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
1806 pub fn param<T>(mut self, name: T, value: T) -> ProjectAttestorGetCall<'a, S>
1807 where T: AsRef<str> {
1808 self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
1809 self
1810 }
1811
1812 /// Identifies the authorization scope for the method you are building.
1813 ///
1814 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
1815 /// [`Scope::CloudPlatform`].
1816 ///
1817 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
1818 /// tokens for more than one scope.
1819 ///
1820 /// Usually there is more than one suitable scope to authorize an operation, some of which may
1821 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
1822 /// sufficient, a read-write scope will do as well.
1823 pub fn add_scope<St>(mut self, scope: St) -> ProjectAttestorGetCall<'a, S>
1824 where St: AsRef<str> {
1825 self._scopes.insert(String::from(scope.as_ref()));
1826 self
1827 }
1828 /// Identifies the authorization scope(s) for the method you are building.
1829 ///
1830 /// See [`Self::add_scope()`] for details.
1831 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectAttestorGetCall<'a, S>
1832 where I: IntoIterator<Item = St>,
1833 St: AsRef<str> {
1834 self._scopes
1835 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
1836 self
1837 }
1838
1839 /// Removes all scopes, and no default scope will be used either.
1840 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
1841 /// for details).
1842 pub fn clear_scopes(mut self) -> ProjectAttestorGetCall<'a, S> {
1843 self._scopes.clear();
1844 self
1845 }
1846}
1847
1848
1849/// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
1850///
1851/// A builder for the *attestors.getIamPolicy* method supported by a *project* resource.
1852/// It is not used directly, but through a [`ProjectMethods`] instance.
1853///
1854/// # Example
1855///
1856/// Instantiate a resource method builder
1857///
1858/// ```test_harness,no_run
1859/// # extern crate hyper;
1860/// # extern crate hyper_rustls;
1861/// # extern crate google_binaryauthorization1 as binaryauthorization1;
1862/// # async fn dox() {
1863/// # use std::default::Default;
1864/// # use binaryauthorization1::{BinaryAuthorization, oauth2, hyper, hyper_rustls, chrono, FieldMask};
1865///
1866/// # let secret: oauth2::ApplicationSecret = Default::default();
1867/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
1868/// # secret,
1869/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1870/// # ).build().await.unwrap();
1871/// # let mut hub = BinaryAuthorization::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth);
1872/// // You can configure optional parameters by calling the respective setters at will, and
1873/// // execute the final call using `doit()`.
1874/// // Values shown here are possibly random and not representative !
1875/// let result = hub.projects().attestors_get_iam_policy("resource")
1876/// .options_requested_policy_version(-20)
1877/// .doit().await;
1878/// # }
1879/// ```
1880pub struct ProjectAttestorGetIamPolicyCall<'a, S>
1881 where S: 'a {
1882
1883 hub: &'a BinaryAuthorization<S>,
1884 _resource: String,
1885 _options_requested_policy_version: Option<i32>,
1886 _delegate: Option<&'a mut dyn client::Delegate>,
1887 _additional_params: HashMap<String, String>,
1888 _scopes: BTreeSet<String>
1889}
1890
1891impl<'a, S> client::CallBuilder for ProjectAttestorGetIamPolicyCall<'a, S> {}
1892
1893impl<'a, S> ProjectAttestorGetIamPolicyCall<'a, S>
1894where
1895 S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
1896 S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
1897 S::Future: Send + Unpin + 'static,
1898 S::Error: Into<Box<dyn StdError + Send + Sync>>,
1899{
1900
1901
1902 /// Perform the operation you have build so far.
1903 pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, IamPolicy)> {
1904 use std::io::{Read, Seek};
1905 use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
1906 use client::{ToParts, url::Params};
1907 use std::borrow::Cow;
1908
1909 let mut dd = client::DefaultDelegate;
1910 let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
1911 dlg.begin(client::MethodInfo { id: "binaryauthorization.projects.attestors.getIamPolicy",
1912 http_method: hyper::Method::GET });
1913
1914 for &field in ["alt", "resource", "options.requestedPolicyVersion"].iter() {
1915 if self._additional_params.contains_key(field) {
1916 dlg.finished(false);
1917 return Err(client::Error::FieldClash(field));
1918 }
1919 }
1920
1921 let mut params = Params::with_capacity(4 + self._additional_params.len());
1922 params.push("resource", self._resource);
1923 if let Some(value) = self._options_requested_policy_version.as_ref() {
1924 params.push("options.requestedPolicyVersion", value.to_string());
1925 }
1926
1927 params.extend(self._additional_params.iter());
1928
1929 params.push("alt", "json");
1930 let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
1931 if self._scopes.is_empty() {
1932 self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
1933 }
1934
1935 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
1936 url = params.uri_replacement(url, param_name, find_this, true);
1937 }
1938 {
1939 let to_remove = ["resource"];
1940 params.remove_params(&to_remove);
1941 }
1942
1943 let url = params.parse_with_url(&url);
1944
1945
1946
1947 loop {
1948 let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
1949 Ok(token) => token,
1950 Err(e) => {
1951 match dlg.token(e) {
1952 Ok(token) => token,
1953 Err(e) => {
1954 dlg.finished(false);
1955 return Err(client::Error::MissingToken(e));
1956 }
1957 }
1958 }
1959 };
1960 let mut req_result = {
1961 let client = &self.hub.client;
1962 dlg.pre_request();
1963 let mut req_builder = hyper::Request::builder()
1964 .method(hyper::Method::GET)
1965 .uri(url.as_str())
1966 .header(USER_AGENT, self.hub._user_agent.clone());
1967
1968 if let Some(token) = token.as_ref() {
1969 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1970 }
1971
1972
1973 let request = req_builder
1974 .body(hyper::body::Body::empty());
1975
1976 client.request(request.unwrap()).await
1977
1978 };
1979
1980 match req_result {
1981 Err(err) => {
1982 if let client::Retry::After(d) = dlg.http_error(&err) {
1983 sleep(d).await;
1984 continue;
1985 }
1986 dlg.finished(false);
1987 return Err(client::Error::HttpError(err))
1988 }
1989 Ok(mut res) => {
1990 if !res.status().is_success() {
1991 let res_body_string = client::get_body_as_string(res.body_mut()).await;
1992 let (parts, _) = res.into_parts();
1993 let body = hyper::Body::from(res_body_string.clone());
1994 let restored_response = hyper::Response::from_parts(parts, body);
1995
1996 let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
1997
1998 if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
1999 sleep(d).await;
2000 continue;
2001 }
2002
2003 dlg.finished(false);
2004
2005 return match server_response {
2006 Some(error_value) => Err(client::Error::BadRequest(error_value)),
2007 None => Err(client::Error::Failure(restored_response)),
2008 }
2009 }
2010 let result_value = {
2011 let res_body_string = client::get_body_as_string(res.body_mut()).await;
2012
2013 match json::from_str(&res_body_string) {
2014 Ok(decoded) => (res, decoded),
2015 Err(err) => {
2016 dlg.response_json_decode_error(&res_body_string, &err);
2017 return Err(client::Error::JsonDecodeError(res_body_string, err));
2018 }
2019 }
2020 };
2021
2022 dlg.finished(true);
2023 return Ok(result_value)
2024 }
2025 }
2026 }
2027 }
2028
2029
2030 /// 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.
2031 ///
2032 /// Sets the *resource* path property to the given value.
2033 ///
2034 /// Even though the property as already been set when instantiating this call,
2035 /// we provide this method for API completeness.
2036 pub fn resource(mut self, new_value: &str) -> ProjectAttestorGetIamPolicyCall<'a, S> {
2037 self._resource = new_value.to_string();
2038 self
2039 }
2040 /// 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).
2041 ///
2042 /// Sets the *options.requested policy version* query property to the given value.
2043 pub fn options_requested_policy_version(mut self, new_value: i32) -> ProjectAttestorGetIamPolicyCall<'a, S> {
2044 self._options_requested_policy_version = Some(new_value);
2045 self
2046 }
2047 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2048 /// while executing the actual API request.
2049 ///
2050 /// ````text
2051 /// It should be used to handle progress information, and to implement a certain level of resilience.
2052 /// ````
2053 ///
2054 /// Sets the *delegate* property to the given value.
2055 pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ProjectAttestorGetIamPolicyCall<'a, S> {
2056 self._delegate = Some(new_value);
2057 self
2058 }
2059
2060 /// Set any additional parameter of the query string used in the request.
2061 /// It should be used to set parameters which are not yet available through their own
2062 /// setters.
2063 ///
2064 /// Please note that this method must not be used to set any of the known parameters
2065 /// which have their own setter method. If done anyway, the request will fail.
2066 ///
2067 /// # Additional Parameters
2068 ///
2069 /// * *$.xgafv* (query-string) - V1 error format.
2070 /// * *access_token* (query-string) - OAuth access token.
2071 /// * *alt* (query-string) - Data format for response.
2072 /// * *callback* (query-string) - JSONP
2073 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2074 /// * *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.
2075 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2076 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2077 /// * *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.
2078 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2079 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2080 pub fn param<T>(mut self, name: T, value: T) -> ProjectAttestorGetIamPolicyCall<'a, S>
2081 where T: AsRef<str> {
2082 self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
2083 self
2084 }
2085
2086 /// Identifies the authorization scope for the method you are building.
2087 ///
2088 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2089 /// [`Scope::CloudPlatform`].
2090 ///
2091 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2092 /// tokens for more than one scope.
2093 ///
2094 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2095 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2096 /// sufficient, a read-write scope will do as well.
2097 pub fn add_scope<St>(mut self, scope: St) -> ProjectAttestorGetIamPolicyCall<'a, S>
2098 where St: AsRef<str> {
2099 self._scopes.insert(String::from(scope.as_ref()));
2100 self
2101 }
2102 /// Identifies the authorization scope(s) for the method you are building.
2103 ///
2104 /// See [`Self::add_scope()`] for details.
2105 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectAttestorGetIamPolicyCall<'a, S>
2106 where I: IntoIterator<Item = St>,
2107 St: AsRef<str> {
2108 self._scopes
2109 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2110 self
2111 }
2112
2113 /// Removes all scopes, and no default scope will be used either.
2114 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2115 /// for details).
2116 pub fn clear_scopes(mut self) -> ProjectAttestorGetIamPolicyCall<'a, S> {
2117 self._scopes.clear();
2118 self
2119 }
2120}
2121
2122
2123/// Lists attestors. Returns INVALID_ARGUMENT if the project does not exist.
2124///
2125/// A builder for the *attestors.list* method supported by a *project* resource.
2126/// It is not used directly, but through a [`ProjectMethods`] instance.
2127///
2128/// # Example
2129///
2130/// Instantiate a resource method builder
2131///
2132/// ```test_harness,no_run
2133/// # extern crate hyper;
2134/// # extern crate hyper_rustls;
2135/// # extern crate google_binaryauthorization1 as binaryauthorization1;
2136/// # async fn dox() {
2137/// # use std::default::Default;
2138/// # use binaryauthorization1::{BinaryAuthorization, oauth2, hyper, hyper_rustls, chrono, FieldMask};
2139///
2140/// # let secret: oauth2::ApplicationSecret = Default::default();
2141/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
2142/// # secret,
2143/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2144/// # ).build().await.unwrap();
2145/// # let mut hub = BinaryAuthorization::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth);
2146/// // You can configure optional parameters by calling the respective setters at will, and
2147/// // execute the final call using `doit()`.
2148/// // Values shown here are possibly random and not representative !
2149/// let result = hub.projects().attestors_list("parent")
2150/// .page_token("gubergren")
2151/// .page_size(-51)
2152/// .doit().await;
2153/// # }
2154/// ```
2155pub struct ProjectAttestorListCall<'a, S>
2156 where S: 'a {
2157
2158 hub: &'a BinaryAuthorization<S>,
2159 _parent: String,
2160 _page_token: Option<String>,
2161 _page_size: Option<i32>,
2162 _delegate: Option<&'a mut dyn client::Delegate>,
2163 _additional_params: HashMap<String, String>,
2164 _scopes: BTreeSet<String>
2165}
2166
2167impl<'a, S> client::CallBuilder for ProjectAttestorListCall<'a, S> {}
2168
2169impl<'a, S> ProjectAttestorListCall<'a, S>
2170where
2171 S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
2172 S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
2173 S::Future: Send + Unpin + 'static,
2174 S::Error: Into<Box<dyn StdError + Send + Sync>>,
2175{
2176
2177
2178 /// Perform the operation you have build so far.
2179 pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, ListAttestorsResponse)> {
2180 use std::io::{Read, Seek};
2181 use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
2182 use client::{ToParts, url::Params};
2183 use std::borrow::Cow;
2184
2185 let mut dd = client::DefaultDelegate;
2186 let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
2187 dlg.begin(client::MethodInfo { id: "binaryauthorization.projects.attestors.list",
2188 http_method: hyper::Method::GET });
2189
2190 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
2191 if self._additional_params.contains_key(field) {
2192 dlg.finished(false);
2193 return Err(client::Error::FieldClash(field));
2194 }
2195 }
2196
2197 let mut params = Params::with_capacity(5 + self._additional_params.len());
2198 params.push("parent", self._parent);
2199 if let Some(value) = self._page_token.as_ref() {
2200 params.push("pageToken", value);
2201 }
2202 if let Some(value) = self._page_size.as_ref() {
2203 params.push("pageSize", value.to_string());
2204 }
2205
2206 params.extend(self._additional_params.iter());
2207
2208 params.push("alt", "json");
2209 let mut url = self.hub._base_url.clone() + "v1/{+parent}/attestors";
2210 if self._scopes.is_empty() {
2211 self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
2212 }
2213
2214 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
2215 url = params.uri_replacement(url, param_name, find_this, true);
2216 }
2217 {
2218 let to_remove = ["parent"];
2219 params.remove_params(&to_remove);
2220 }
2221
2222 let url = params.parse_with_url(&url);
2223
2224
2225
2226 loop {
2227 let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
2228 Ok(token) => token,
2229 Err(e) => {
2230 match dlg.token(e) {
2231 Ok(token) => token,
2232 Err(e) => {
2233 dlg.finished(false);
2234 return Err(client::Error::MissingToken(e));
2235 }
2236 }
2237 }
2238 };
2239 let mut req_result = {
2240 let client = &self.hub.client;
2241 dlg.pre_request();
2242 let mut req_builder = hyper::Request::builder()
2243 .method(hyper::Method::GET)
2244 .uri(url.as_str())
2245 .header(USER_AGENT, self.hub._user_agent.clone());
2246
2247 if let Some(token) = token.as_ref() {
2248 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2249 }
2250
2251
2252 let request = req_builder
2253 .body(hyper::body::Body::empty());
2254
2255 client.request(request.unwrap()).await
2256
2257 };
2258
2259 match req_result {
2260 Err(err) => {
2261 if let client::Retry::After(d) = dlg.http_error(&err) {
2262 sleep(d).await;
2263 continue;
2264 }
2265 dlg.finished(false);
2266 return Err(client::Error::HttpError(err))
2267 }
2268 Ok(mut res) => {
2269 if !res.status().is_success() {
2270 let res_body_string = client::get_body_as_string(res.body_mut()).await;
2271 let (parts, _) = res.into_parts();
2272 let body = hyper::Body::from(res_body_string.clone());
2273 let restored_response = hyper::Response::from_parts(parts, body);
2274
2275 let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
2276
2277 if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
2278 sleep(d).await;
2279 continue;
2280 }
2281
2282 dlg.finished(false);
2283
2284 return match server_response {
2285 Some(error_value) => Err(client::Error::BadRequest(error_value)),
2286 None => Err(client::Error::Failure(restored_response)),
2287 }
2288 }
2289 let result_value = {
2290 let res_body_string = client::get_body_as_string(res.body_mut()).await;
2291
2292 match json::from_str(&res_body_string) {
2293 Ok(decoded) => (res, decoded),
2294 Err(err) => {
2295 dlg.response_json_decode_error(&res_body_string, &err);
2296 return Err(client::Error::JsonDecodeError(res_body_string, err));
2297 }
2298 }
2299 };
2300
2301 dlg.finished(true);
2302 return Ok(result_value)
2303 }
2304 }
2305 }
2306 }
2307
2308
2309 /// Required. The resource name of the project associated with the attestors, in the format `projects/*`.
2310 ///
2311 /// Sets the *parent* path property to the given value.
2312 ///
2313 /// Even though the property as already been set when instantiating this call,
2314 /// we provide this method for API completeness.
2315 pub fn parent(mut self, new_value: &str) -> ProjectAttestorListCall<'a, S> {
2316 self._parent = new_value.to_string();
2317 self
2318 }
2319 /// A token identifying a page of results the server should return. Typically, this is the value of ListAttestorsResponse.next_page_token returned from the previous call to the `ListAttestors` method.
2320 ///
2321 /// Sets the *page token* query property to the given value.
2322 pub fn page_token(mut self, new_value: &str) -> ProjectAttestorListCall<'a, S> {
2323 self._page_token = Some(new_value.to_string());
2324 self
2325 }
2326 /// Requested page size. The server may return fewer results than requested. If unspecified, the server will pick an appropriate default.
2327 ///
2328 /// Sets the *page size* query property to the given value.
2329 pub fn page_size(mut self, new_value: i32) -> ProjectAttestorListCall<'a, S> {
2330 self._page_size = Some(new_value);
2331 self
2332 }
2333 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2334 /// while executing the actual API request.
2335 ///
2336 /// ````text
2337 /// It should be used to handle progress information, and to implement a certain level of resilience.
2338 /// ````
2339 ///
2340 /// Sets the *delegate* property to the given value.
2341 pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ProjectAttestorListCall<'a, S> {
2342 self._delegate = Some(new_value);
2343 self
2344 }
2345
2346 /// Set any additional parameter of the query string used in the request.
2347 /// It should be used to set parameters which are not yet available through their own
2348 /// setters.
2349 ///
2350 /// Please note that this method must not be used to set any of the known parameters
2351 /// which have their own setter method. If done anyway, the request will fail.
2352 ///
2353 /// # Additional Parameters
2354 ///
2355 /// * *$.xgafv* (query-string) - V1 error format.
2356 /// * *access_token* (query-string) - OAuth access token.
2357 /// * *alt* (query-string) - Data format for response.
2358 /// * *callback* (query-string) - JSONP
2359 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2360 /// * *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.
2361 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2362 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2363 /// * *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.
2364 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2365 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2366 pub fn param<T>(mut self, name: T, value: T) -> ProjectAttestorListCall<'a, S>
2367 where T: AsRef<str> {
2368 self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
2369 self
2370 }
2371
2372 /// Identifies the authorization scope for the method you are building.
2373 ///
2374 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2375 /// [`Scope::CloudPlatform`].
2376 ///
2377 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2378 /// tokens for more than one scope.
2379 ///
2380 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2381 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2382 /// sufficient, a read-write scope will do as well.
2383 pub fn add_scope<St>(mut self, scope: St) -> ProjectAttestorListCall<'a, S>
2384 where St: AsRef<str> {
2385 self._scopes.insert(String::from(scope.as_ref()));
2386 self
2387 }
2388 /// Identifies the authorization scope(s) for the method you are building.
2389 ///
2390 /// See [`Self::add_scope()`] for details.
2391 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectAttestorListCall<'a, S>
2392 where I: IntoIterator<Item = St>,
2393 St: AsRef<str> {
2394 self._scopes
2395 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2396 self
2397 }
2398
2399 /// Removes all scopes, and no default scope will be used either.
2400 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2401 /// for details).
2402 pub fn clear_scopes(mut self) -> ProjectAttestorListCall<'a, S> {
2403 self._scopes.clear();
2404 self
2405 }
2406}
2407
2408
2409/// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
2410///
2411/// A builder for the *attestors.setIamPolicy* method supported by a *project* resource.
2412/// It is not used directly, but through a [`ProjectMethods`] instance.
2413///
2414/// # Example
2415///
2416/// Instantiate a resource method builder
2417///
2418/// ```test_harness,no_run
2419/// # extern crate hyper;
2420/// # extern crate hyper_rustls;
2421/// # extern crate google_binaryauthorization1 as binaryauthorization1;
2422/// use binaryauthorization1::api::SetIamPolicyRequest;
2423/// # async fn dox() {
2424/// # use std::default::Default;
2425/// # use binaryauthorization1::{BinaryAuthorization, oauth2, hyper, hyper_rustls, chrono, FieldMask};
2426///
2427/// # let secret: oauth2::ApplicationSecret = Default::default();
2428/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
2429/// # secret,
2430/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2431/// # ).build().await.unwrap();
2432/// # let mut hub = BinaryAuthorization::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth);
2433/// // As the method needs a request, you would usually fill it with the desired information
2434/// // into the respective structure. Some of the parts shown here might not be applicable !
2435/// // Values shown here are possibly random and not representative !
2436/// let mut req = SetIamPolicyRequest::default();
2437///
2438/// // You can configure optional parameters by calling the respective setters at will, and
2439/// // execute the final call using `doit()`.
2440/// // Values shown here are possibly random and not representative !
2441/// let result = hub.projects().attestors_set_iam_policy(req, "resource")
2442/// .doit().await;
2443/// # }
2444/// ```
2445pub struct ProjectAttestorSetIamPolicyCall<'a, S>
2446 where S: 'a {
2447
2448 hub: &'a BinaryAuthorization<S>,
2449 _request: SetIamPolicyRequest,
2450 _resource: String,
2451 _delegate: Option<&'a mut dyn client::Delegate>,
2452 _additional_params: HashMap<String, String>,
2453 _scopes: BTreeSet<String>
2454}
2455
2456impl<'a, S> client::CallBuilder for ProjectAttestorSetIamPolicyCall<'a, S> {}
2457
2458impl<'a, S> ProjectAttestorSetIamPolicyCall<'a, S>
2459where
2460 S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
2461 S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
2462 S::Future: Send + Unpin + 'static,
2463 S::Error: Into<Box<dyn StdError + Send + Sync>>,
2464{
2465
2466
2467 /// Perform the operation you have build so far.
2468 pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, IamPolicy)> {
2469 use std::io::{Read, Seek};
2470 use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
2471 use client::{ToParts, url::Params};
2472 use std::borrow::Cow;
2473
2474 let mut dd = client::DefaultDelegate;
2475 let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
2476 dlg.begin(client::MethodInfo { id: "binaryauthorization.projects.attestors.setIamPolicy",
2477 http_method: hyper::Method::POST });
2478
2479 for &field in ["alt", "resource"].iter() {
2480 if self._additional_params.contains_key(field) {
2481 dlg.finished(false);
2482 return Err(client::Error::FieldClash(field));
2483 }
2484 }
2485
2486 let mut params = Params::with_capacity(4 + self._additional_params.len());
2487 params.push("resource", self._resource);
2488
2489 params.extend(self._additional_params.iter());
2490
2491 params.push("alt", "json");
2492 let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
2493 if self._scopes.is_empty() {
2494 self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
2495 }
2496
2497 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
2498 url = params.uri_replacement(url, param_name, find_this, true);
2499 }
2500 {
2501 let to_remove = ["resource"];
2502 params.remove_params(&to_remove);
2503 }
2504
2505 let url = params.parse_with_url(&url);
2506
2507 let mut json_mime_type = mime::APPLICATION_JSON;
2508 let mut request_value_reader =
2509 {
2510 let mut value = json::value::to_value(&self._request).expect("serde to work");
2511 client::remove_json_null_values(&mut value);
2512 let mut dst = io::Cursor::new(Vec::with_capacity(128));
2513 json::to_writer(&mut dst, &value).unwrap();
2514 dst
2515 };
2516 let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
2517 request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
2518
2519
2520 loop {
2521 let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
2522 Ok(token) => token,
2523 Err(e) => {
2524 match dlg.token(e) {
2525 Ok(token) => token,
2526 Err(e) => {
2527 dlg.finished(false);
2528 return Err(client::Error::MissingToken(e));
2529 }
2530 }
2531 }
2532 };
2533 request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
2534 let mut req_result = {
2535 let client = &self.hub.client;
2536 dlg.pre_request();
2537 let mut req_builder = hyper::Request::builder()
2538 .method(hyper::Method::POST)
2539 .uri(url.as_str())
2540 .header(USER_AGENT, self.hub._user_agent.clone());
2541
2542 if let Some(token) = token.as_ref() {
2543 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2544 }
2545
2546
2547 let request = req_builder
2548 .header(CONTENT_TYPE, json_mime_type.to_string())
2549 .header(CONTENT_LENGTH, request_size as u64)
2550 .body(hyper::body::Body::from(request_value_reader.get_ref().clone()));
2551
2552 client.request(request.unwrap()).await
2553
2554 };
2555
2556 match req_result {
2557 Err(err) => {
2558 if let client::Retry::After(d) = dlg.http_error(&err) {
2559 sleep(d).await;
2560 continue;
2561 }
2562 dlg.finished(false);
2563 return Err(client::Error::HttpError(err))
2564 }
2565 Ok(mut res) => {
2566 if !res.status().is_success() {
2567 let res_body_string = client::get_body_as_string(res.body_mut()).await;
2568 let (parts, _) = res.into_parts();
2569 let body = hyper::Body::from(res_body_string.clone());
2570 let restored_response = hyper::Response::from_parts(parts, body);
2571
2572 let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
2573
2574 if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
2575 sleep(d).await;
2576 continue;
2577 }
2578
2579 dlg.finished(false);
2580
2581 return match server_response {
2582 Some(error_value) => Err(client::Error::BadRequest(error_value)),
2583 None => Err(client::Error::Failure(restored_response)),
2584 }
2585 }
2586 let result_value = {
2587 let res_body_string = client::get_body_as_string(res.body_mut()).await;
2588
2589 match json::from_str(&res_body_string) {
2590 Ok(decoded) => (res, decoded),
2591 Err(err) => {
2592 dlg.response_json_decode_error(&res_body_string, &err);
2593 return Err(client::Error::JsonDecodeError(res_body_string, err));
2594 }
2595 }
2596 };
2597
2598 dlg.finished(true);
2599 return Ok(result_value)
2600 }
2601 }
2602 }
2603 }
2604
2605
2606 ///
2607 /// Sets the *request* property to the given value.
2608 ///
2609 /// Even though the property as already been set when instantiating this call,
2610 /// we provide this method for API completeness.
2611 pub fn request(mut self, new_value: SetIamPolicyRequest) -> ProjectAttestorSetIamPolicyCall<'a, S> {
2612 self._request = new_value;
2613 self
2614 }
2615 /// 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.
2616 ///
2617 /// Sets the *resource* path property to the given value.
2618 ///
2619 /// Even though the property as already been set when instantiating this call,
2620 /// we provide this method for API completeness.
2621 pub fn resource(mut self, new_value: &str) -> ProjectAttestorSetIamPolicyCall<'a, S> {
2622 self._resource = new_value.to_string();
2623 self
2624 }
2625 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2626 /// while executing the actual API request.
2627 ///
2628 /// ````text
2629 /// It should be used to handle progress information, and to implement a certain level of resilience.
2630 /// ````
2631 ///
2632 /// Sets the *delegate* property to the given value.
2633 pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ProjectAttestorSetIamPolicyCall<'a, S> {
2634 self._delegate = Some(new_value);
2635 self
2636 }
2637
2638 /// Set any additional parameter of the query string used in the request.
2639 /// It should be used to set parameters which are not yet available through their own
2640 /// setters.
2641 ///
2642 /// Please note that this method must not be used to set any of the known parameters
2643 /// which have their own setter method. If done anyway, the request will fail.
2644 ///
2645 /// # Additional Parameters
2646 ///
2647 /// * *$.xgafv* (query-string) - V1 error format.
2648 /// * *access_token* (query-string) - OAuth access token.
2649 /// * *alt* (query-string) - Data format for response.
2650 /// * *callback* (query-string) - JSONP
2651 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2652 /// * *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.
2653 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2654 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2655 /// * *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.
2656 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2657 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2658 pub fn param<T>(mut self, name: T, value: T) -> ProjectAttestorSetIamPolicyCall<'a, S>
2659 where T: AsRef<str> {
2660 self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
2661 self
2662 }
2663
2664 /// Identifies the authorization scope for the method you are building.
2665 ///
2666 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2667 /// [`Scope::CloudPlatform`].
2668 ///
2669 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2670 /// tokens for more than one scope.
2671 ///
2672 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2673 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2674 /// sufficient, a read-write scope will do as well.
2675 pub fn add_scope<St>(mut self, scope: St) -> ProjectAttestorSetIamPolicyCall<'a, S>
2676 where St: AsRef<str> {
2677 self._scopes.insert(String::from(scope.as_ref()));
2678 self
2679 }
2680 /// Identifies the authorization scope(s) for the method you are building.
2681 ///
2682 /// See [`Self::add_scope()`] for details.
2683 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectAttestorSetIamPolicyCall<'a, S>
2684 where I: IntoIterator<Item = St>,
2685 St: AsRef<str> {
2686 self._scopes
2687 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2688 self
2689 }
2690
2691 /// Removes all scopes, and no default scope will be used either.
2692 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2693 /// for details).
2694 pub fn clear_scopes(mut self) -> ProjectAttestorSetIamPolicyCall<'a, S> {
2695 self._scopes.clear();
2696 self
2697 }
2698}
2699
2700
2701/// Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
2702///
2703/// A builder for the *attestors.testIamPermissions* method supported by a *project* resource.
2704/// It is not used directly, but through a [`ProjectMethods`] instance.
2705///
2706/// # Example
2707///
2708/// Instantiate a resource method builder
2709///
2710/// ```test_harness,no_run
2711/// # extern crate hyper;
2712/// # extern crate hyper_rustls;
2713/// # extern crate google_binaryauthorization1 as binaryauthorization1;
2714/// use binaryauthorization1::api::TestIamPermissionsRequest;
2715/// # async fn dox() {
2716/// # use std::default::Default;
2717/// # use binaryauthorization1::{BinaryAuthorization, oauth2, hyper, hyper_rustls, chrono, FieldMask};
2718///
2719/// # let secret: oauth2::ApplicationSecret = Default::default();
2720/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
2721/// # secret,
2722/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2723/// # ).build().await.unwrap();
2724/// # let mut hub = BinaryAuthorization::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth);
2725/// // As the method needs a request, you would usually fill it with the desired information
2726/// // into the respective structure. Some of the parts shown here might not be applicable !
2727/// // Values shown here are possibly random and not representative !
2728/// let mut req = TestIamPermissionsRequest::default();
2729///
2730/// // You can configure optional parameters by calling the respective setters at will, and
2731/// // execute the final call using `doit()`.
2732/// // Values shown here are possibly random and not representative !
2733/// let result = hub.projects().attestors_test_iam_permissions(req, "resource")
2734/// .doit().await;
2735/// # }
2736/// ```
2737pub struct ProjectAttestorTestIamPermissionCall<'a, S>
2738 where S: 'a {
2739
2740 hub: &'a BinaryAuthorization<S>,
2741 _request: TestIamPermissionsRequest,
2742 _resource: String,
2743 _delegate: Option<&'a mut dyn client::Delegate>,
2744 _additional_params: HashMap<String, String>,
2745 _scopes: BTreeSet<String>
2746}
2747
2748impl<'a, S> client::CallBuilder for ProjectAttestorTestIamPermissionCall<'a, S> {}
2749
2750impl<'a, S> ProjectAttestorTestIamPermissionCall<'a, S>
2751where
2752 S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
2753 S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
2754 S::Future: Send + Unpin + 'static,
2755 S::Error: Into<Box<dyn StdError + Send + Sync>>,
2756{
2757
2758
2759 /// Perform the operation you have build so far.
2760 pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, TestIamPermissionsResponse)> {
2761 use std::io::{Read, Seek};
2762 use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
2763 use client::{ToParts, url::Params};
2764 use std::borrow::Cow;
2765
2766 let mut dd = client::DefaultDelegate;
2767 let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
2768 dlg.begin(client::MethodInfo { id: "binaryauthorization.projects.attestors.testIamPermissions",
2769 http_method: hyper::Method::POST });
2770
2771 for &field in ["alt", "resource"].iter() {
2772 if self._additional_params.contains_key(field) {
2773 dlg.finished(false);
2774 return Err(client::Error::FieldClash(field));
2775 }
2776 }
2777
2778 let mut params = Params::with_capacity(4 + self._additional_params.len());
2779 params.push("resource", self._resource);
2780
2781 params.extend(self._additional_params.iter());
2782
2783 params.push("alt", "json");
2784 let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
2785 if self._scopes.is_empty() {
2786 self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
2787 }
2788
2789 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
2790 url = params.uri_replacement(url, param_name, find_this, true);
2791 }
2792 {
2793 let to_remove = ["resource"];
2794 params.remove_params(&to_remove);
2795 }
2796
2797 let url = params.parse_with_url(&url);
2798
2799 let mut json_mime_type = mime::APPLICATION_JSON;
2800 let mut request_value_reader =
2801 {
2802 let mut value = json::value::to_value(&self._request).expect("serde to work");
2803 client::remove_json_null_values(&mut value);
2804 let mut dst = io::Cursor::new(Vec::with_capacity(128));
2805 json::to_writer(&mut dst, &value).unwrap();
2806 dst
2807 };
2808 let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
2809 request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
2810
2811
2812 loop {
2813 let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
2814 Ok(token) => token,
2815 Err(e) => {
2816 match dlg.token(e) {
2817 Ok(token) => token,
2818 Err(e) => {
2819 dlg.finished(false);
2820 return Err(client::Error::MissingToken(e));
2821 }
2822 }
2823 }
2824 };
2825 request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
2826 let mut req_result = {
2827 let client = &self.hub.client;
2828 dlg.pre_request();
2829 let mut req_builder = hyper::Request::builder()
2830 .method(hyper::Method::POST)
2831 .uri(url.as_str())
2832 .header(USER_AGENT, self.hub._user_agent.clone());
2833
2834 if let Some(token) = token.as_ref() {
2835 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2836 }
2837
2838
2839 let request = req_builder
2840 .header(CONTENT_TYPE, json_mime_type.to_string())
2841 .header(CONTENT_LENGTH, request_size as u64)
2842 .body(hyper::body::Body::from(request_value_reader.get_ref().clone()));
2843
2844 client.request(request.unwrap()).await
2845
2846 };
2847
2848 match req_result {
2849 Err(err) => {
2850 if let client::Retry::After(d) = dlg.http_error(&err) {
2851 sleep(d).await;
2852 continue;
2853 }
2854 dlg.finished(false);
2855 return Err(client::Error::HttpError(err))
2856 }
2857 Ok(mut res) => {
2858 if !res.status().is_success() {
2859 let res_body_string = client::get_body_as_string(res.body_mut()).await;
2860 let (parts, _) = res.into_parts();
2861 let body = hyper::Body::from(res_body_string.clone());
2862 let restored_response = hyper::Response::from_parts(parts, body);
2863
2864 let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
2865
2866 if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
2867 sleep(d).await;
2868 continue;
2869 }
2870
2871 dlg.finished(false);
2872
2873 return match server_response {
2874 Some(error_value) => Err(client::Error::BadRequest(error_value)),
2875 None => Err(client::Error::Failure(restored_response)),
2876 }
2877 }
2878 let result_value = {
2879 let res_body_string = client::get_body_as_string(res.body_mut()).await;
2880
2881 match json::from_str(&res_body_string) {
2882 Ok(decoded) => (res, decoded),
2883 Err(err) => {
2884 dlg.response_json_decode_error(&res_body_string, &err);
2885 return Err(client::Error::JsonDecodeError(res_body_string, err));
2886 }
2887 }
2888 };
2889
2890 dlg.finished(true);
2891 return Ok(result_value)
2892 }
2893 }
2894 }
2895 }
2896
2897
2898 ///
2899 /// Sets the *request* property to the given value.
2900 ///
2901 /// Even though the property as already been set when instantiating this call,
2902 /// we provide this method for API completeness.
2903 pub fn request(mut self, new_value: TestIamPermissionsRequest) -> ProjectAttestorTestIamPermissionCall<'a, S> {
2904 self._request = new_value;
2905 self
2906 }
2907 /// 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.
2908 ///
2909 /// Sets the *resource* path property to the given value.
2910 ///
2911 /// Even though the property as already been set when instantiating this call,
2912 /// we provide this method for API completeness.
2913 pub fn resource(mut self, new_value: &str) -> ProjectAttestorTestIamPermissionCall<'a, S> {
2914 self._resource = new_value.to_string();
2915 self
2916 }
2917 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2918 /// while executing the actual API request.
2919 ///
2920 /// ````text
2921 /// It should be used to handle progress information, and to implement a certain level of resilience.
2922 /// ````
2923 ///
2924 /// Sets the *delegate* property to the given value.
2925 pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ProjectAttestorTestIamPermissionCall<'a, S> {
2926 self._delegate = Some(new_value);
2927 self
2928 }
2929
2930 /// Set any additional parameter of the query string used in the request.
2931 /// It should be used to set parameters which are not yet available through their own
2932 /// setters.
2933 ///
2934 /// Please note that this method must not be used to set any of the known parameters
2935 /// which have their own setter method. If done anyway, the request will fail.
2936 ///
2937 /// # Additional Parameters
2938 ///
2939 /// * *$.xgafv* (query-string) - V1 error format.
2940 /// * *access_token* (query-string) - OAuth access token.
2941 /// * *alt* (query-string) - Data format for response.
2942 /// * *callback* (query-string) - JSONP
2943 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2944 /// * *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.
2945 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2946 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2947 /// * *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.
2948 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2949 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2950 pub fn param<T>(mut self, name: T, value: T) -> ProjectAttestorTestIamPermissionCall<'a, S>
2951 where T: AsRef<str> {
2952 self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
2953 self
2954 }
2955
2956 /// Identifies the authorization scope for the method you are building.
2957 ///
2958 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2959 /// [`Scope::CloudPlatform`].
2960 ///
2961 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2962 /// tokens for more than one scope.
2963 ///
2964 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2965 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2966 /// sufficient, a read-write scope will do as well.
2967 pub fn add_scope<St>(mut self, scope: St) -> ProjectAttestorTestIamPermissionCall<'a, S>
2968 where St: AsRef<str> {
2969 self._scopes.insert(String::from(scope.as_ref()));
2970 self
2971 }
2972 /// Identifies the authorization scope(s) for the method you are building.
2973 ///
2974 /// See [`Self::add_scope()`] for details.
2975 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectAttestorTestIamPermissionCall<'a, S>
2976 where I: IntoIterator<Item = St>,
2977 St: AsRef<str> {
2978 self._scopes
2979 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2980 self
2981 }
2982
2983 /// Removes all scopes, and no default scope will be used either.
2984 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2985 /// for details).
2986 pub fn clear_scopes(mut self) -> ProjectAttestorTestIamPermissionCall<'a, S> {
2987 self._scopes.clear();
2988 self
2989 }
2990}
2991
2992
2993/// Updates an attestor. Returns NOT_FOUND if the attestor does not exist.
2994///
2995/// A builder for the *attestors.update* method supported by a *project* resource.
2996/// It is not used directly, but through a [`ProjectMethods`] instance.
2997///
2998/// # Example
2999///
3000/// Instantiate a resource method builder
3001///
3002/// ```test_harness,no_run
3003/// # extern crate hyper;
3004/// # extern crate hyper_rustls;
3005/// # extern crate google_binaryauthorization1 as binaryauthorization1;
3006/// use binaryauthorization1::api::Attestor;
3007/// # async fn dox() {
3008/// # use std::default::Default;
3009/// # use binaryauthorization1::{BinaryAuthorization, oauth2, hyper, hyper_rustls, chrono, FieldMask};
3010///
3011/// # let secret: oauth2::ApplicationSecret = Default::default();
3012/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
3013/// # secret,
3014/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3015/// # ).build().await.unwrap();
3016/// # let mut hub = BinaryAuthorization::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth);
3017/// // As the method needs a request, you would usually fill it with the desired information
3018/// // into the respective structure. Some of the parts shown here might not be applicable !
3019/// // Values shown here are possibly random and not representative !
3020/// let mut req = Attestor::default();
3021///
3022/// // You can configure optional parameters by calling the respective setters at will, and
3023/// // execute the final call using `doit()`.
3024/// // Values shown here are possibly random and not representative !
3025/// let result = hub.projects().attestors_update(req, "name")
3026/// .doit().await;
3027/// # }
3028/// ```
3029pub struct ProjectAttestorUpdateCall<'a, S>
3030 where S: 'a {
3031
3032 hub: &'a BinaryAuthorization<S>,
3033 _request: Attestor,
3034 _name: String,
3035 _delegate: Option<&'a mut dyn client::Delegate>,
3036 _additional_params: HashMap<String, String>,
3037 _scopes: BTreeSet<String>
3038}
3039
3040impl<'a, S> client::CallBuilder for ProjectAttestorUpdateCall<'a, S> {}
3041
3042impl<'a, S> ProjectAttestorUpdateCall<'a, S>
3043where
3044 S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
3045 S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
3046 S::Future: Send + Unpin + 'static,
3047 S::Error: Into<Box<dyn StdError + Send + Sync>>,
3048{
3049
3050
3051 /// Perform the operation you have build so far.
3052 pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Attestor)> {
3053 use std::io::{Read, Seek};
3054 use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
3055 use client::{ToParts, url::Params};
3056 use std::borrow::Cow;
3057
3058 let mut dd = client::DefaultDelegate;
3059 let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
3060 dlg.begin(client::MethodInfo { id: "binaryauthorization.projects.attestors.update",
3061 http_method: hyper::Method::PUT });
3062
3063 for &field in ["alt", "name"].iter() {
3064 if self._additional_params.contains_key(field) {
3065 dlg.finished(false);
3066 return Err(client::Error::FieldClash(field));
3067 }
3068 }
3069
3070 let mut params = Params::with_capacity(4 + self._additional_params.len());
3071 params.push("name", self._name);
3072
3073 params.extend(self._additional_params.iter());
3074
3075 params.push("alt", "json");
3076 let mut url = self.hub._base_url.clone() + "v1/{+name}";
3077 if self._scopes.is_empty() {
3078 self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
3079 }
3080
3081 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3082 url = params.uri_replacement(url, param_name, find_this, true);
3083 }
3084 {
3085 let to_remove = ["name"];
3086 params.remove_params(&to_remove);
3087 }
3088
3089 let url = params.parse_with_url(&url);
3090
3091 let mut json_mime_type = mime::APPLICATION_JSON;
3092 let mut request_value_reader =
3093 {
3094 let mut value = json::value::to_value(&self._request).expect("serde to work");
3095 client::remove_json_null_values(&mut value);
3096 let mut dst = io::Cursor::new(Vec::with_capacity(128));
3097 json::to_writer(&mut dst, &value).unwrap();
3098 dst
3099 };
3100 let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
3101 request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
3102
3103
3104 loop {
3105 let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
3106 Ok(token) => token,
3107 Err(e) => {
3108 match dlg.token(e) {
3109 Ok(token) => token,
3110 Err(e) => {
3111 dlg.finished(false);
3112 return Err(client::Error::MissingToken(e));
3113 }
3114 }
3115 }
3116 };
3117 request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
3118 let mut req_result = {
3119 let client = &self.hub.client;
3120 dlg.pre_request();
3121 let mut req_builder = hyper::Request::builder()
3122 .method(hyper::Method::PUT)
3123 .uri(url.as_str())
3124 .header(USER_AGENT, self.hub._user_agent.clone());
3125
3126 if let Some(token) = token.as_ref() {
3127 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3128 }
3129
3130
3131 let request = req_builder
3132 .header(CONTENT_TYPE, json_mime_type.to_string())
3133 .header(CONTENT_LENGTH, request_size as u64)
3134 .body(hyper::body::Body::from(request_value_reader.get_ref().clone()));
3135
3136 client.request(request.unwrap()).await
3137
3138 };
3139
3140 match req_result {
3141 Err(err) => {
3142 if let client::Retry::After(d) = dlg.http_error(&err) {
3143 sleep(d).await;
3144 continue;
3145 }
3146 dlg.finished(false);
3147 return Err(client::Error::HttpError(err))
3148 }
3149 Ok(mut res) => {
3150 if !res.status().is_success() {
3151 let res_body_string = client::get_body_as_string(res.body_mut()).await;
3152 let (parts, _) = res.into_parts();
3153 let body = hyper::Body::from(res_body_string.clone());
3154 let restored_response = hyper::Response::from_parts(parts, body);
3155
3156 let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
3157
3158 if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
3159 sleep(d).await;
3160 continue;
3161 }
3162
3163 dlg.finished(false);
3164
3165 return match server_response {
3166 Some(error_value) => Err(client::Error::BadRequest(error_value)),
3167 None => Err(client::Error::Failure(restored_response)),
3168 }
3169 }
3170 let result_value = {
3171 let res_body_string = client::get_body_as_string(res.body_mut()).await;
3172
3173 match json::from_str(&res_body_string) {
3174 Ok(decoded) => (res, decoded),
3175 Err(err) => {
3176 dlg.response_json_decode_error(&res_body_string, &err);
3177 return Err(client::Error::JsonDecodeError(res_body_string, err));
3178 }
3179 }
3180 };
3181
3182 dlg.finished(true);
3183 return Ok(result_value)
3184 }
3185 }
3186 }
3187 }
3188
3189
3190 ///
3191 /// Sets the *request* property to the given value.
3192 ///
3193 /// Even though the property as already been set when instantiating this call,
3194 /// we provide this method for API completeness.
3195 pub fn request(mut self, new_value: Attestor) -> ProjectAttestorUpdateCall<'a, S> {
3196 self._request = new_value;
3197 self
3198 }
3199 /// Required. The resource name, in the format: `projects/*/attestors/*`. This field may not be updated.
3200 ///
3201 /// Sets the *name* path property to the given value.
3202 ///
3203 /// Even though the property as already been set when instantiating this call,
3204 /// we provide this method for API completeness.
3205 pub fn name(mut self, new_value: &str) -> ProjectAttestorUpdateCall<'a, S> {
3206 self._name = new_value.to_string();
3207 self
3208 }
3209 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3210 /// while executing the actual API request.
3211 ///
3212 /// ````text
3213 /// It should be used to handle progress information, and to implement a certain level of resilience.
3214 /// ````
3215 ///
3216 /// Sets the *delegate* property to the given value.
3217 pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ProjectAttestorUpdateCall<'a, S> {
3218 self._delegate = Some(new_value);
3219 self
3220 }
3221
3222 /// Set any additional parameter of the query string used in the request.
3223 /// It should be used to set parameters which are not yet available through their own
3224 /// setters.
3225 ///
3226 /// Please note that this method must not be used to set any of the known parameters
3227 /// which have their own setter method. If done anyway, the request will fail.
3228 ///
3229 /// # Additional Parameters
3230 ///
3231 /// * *$.xgafv* (query-string) - V1 error format.
3232 /// * *access_token* (query-string) - OAuth access token.
3233 /// * *alt* (query-string) - Data format for response.
3234 /// * *callback* (query-string) - JSONP
3235 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3236 /// * *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.
3237 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3238 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3239 /// * *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.
3240 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3241 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3242 pub fn param<T>(mut self, name: T, value: T) -> ProjectAttestorUpdateCall<'a, S>
3243 where T: AsRef<str> {
3244 self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
3245 self
3246 }
3247
3248 /// Identifies the authorization scope for the method you are building.
3249 ///
3250 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3251 /// [`Scope::CloudPlatform`].
3252 ///
3253 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3254 /// tokens for more than one scope.
3255 ///
3256 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3257 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3258 /// sufficient, a read-write scope will do as well.
3259 pub fn add_scope<St>(mut self, scope: St) -> ProjectAttestorUpdateCall<'a, S>
3260 where St: AsRef<str> {
3261 self._scopes.insert(String::from(scope.as_ref()));
3262 self
3263 }
3264 /// Identifies the authorization scope(s) for the method you are building.
3265 ///
3266 /// See [`Self::add_scope()`] for details.
3267 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectAttestorUpdateCall<'a, S>
3268 where I: IntoIterator<Item = St>,
3269 St: AsRef<str> {
3270 self._scopes
3271 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3272 self
3273 }
3274
3275 /// Removes all scopes, and no default scope will be used either.
3276 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3277 /// for details).
3278 pub fn clear_scopes(mut self) -> ProjectAttestorUpdateCall<'a, S> {
3279 self._scopes.clear();
3280 self
3281 }
3282}
3283
3284
3285/// Returns whether the given Attestation for the given image URI was signed by the given Attestor
3286///
3287/// A builder for the *attestors.validateAttestationOccurrence* method supported by a *project* resource.
3288/// It is not used directly, but through a [`ProjectMethods`] instance.
3289///
3290/// # Example
3291///
3292/// Instantiate a resource method builder
3293///
3294/// ```test_harness,no_run
3295/// # extern crate hyper;
3296/// # extern crate hyper_rustls;
3297/// # extern crate google_binaryauthorization1 as binaryauthorization1;
3298/// use binaryauthorization1::api::ValidateAttestationOccurrenceRequest;
3299/// # async fn dox() {
3300/// # use std::default::Default;
3301/// # use binaryauthorization1::{BinaryAuthorization, oauth2, hyper, hyper_rustls, chrono, FieldMask};
3302///
3303/// # let secret: oauth2::ApplicationSecret = Default::default();
3304/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
3305/// # secret,
3306/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3307/// # ).build().await.unwrap();
3308/// # let mut hub = BinaryAuthorization::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth);
3309/// // As the method needs a request, you would usually fill it with the desired information
3310/// // into the respective structure. Some of the parts shown here might not be applicable !
3311/// // Values shown here are possibly random and not representative !
3312/// let mut req = ValidateAttestationOccurrenceRequest::default();
3313///
3314/// // You can configure optional parameters by calling the respective setters at will, and
3315/// // execute the final call using `doit()`.
3316/// // Values shown here are possibly random and not representative !
3317/// let result = hub.projects().attestors_validate_attestation_occurrence(req, "attestor")
3318/// .doit().await;
3319/// # }
3320/// ```
3321pub struct ProjectAttestorValidateAttestationOccurrenceCall<'a, S>
3322 where S: 'a {
3323
3324 hub: &'a BinaryAuthorization<S>,
3325 _request: ValidateAttestationOccurrenceRequest,
3326 _attestor: String,
3327 _delegate: Option<&'a mut dyn client::Delegate>,
3328 _additional_params: HashMap<String, String>,
3329 _scopes: BTreeSet<String>
3330}
3331
3332impl<'a, S> client::CallBuilder for ProjectAttestorValidateAttestationOccurrenceCall<'a, S> {}
3333
3334impl<'a, S> ProjectAttestorValidateAttestationOccurrenceCall<'a, S>
3335where
3336 S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
3337 S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
3338 S::Future: Send + Unpin + 'static,
3339 S::Error: Into<Box<dyn StdError + Send + Sync>>,
3340{
3341
3342
3343 /// Perform the operation you have build so far.
3344 pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, ValidateAttestationOccurrenceResponse)> {
3345 use std::io::{Read, Seek};
3346 use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
3347 use client::{ToParts, url::Params};
3348 use std::borrow::Cow;
3349
3350 let mut dd = client::DefaultDelegate;
3351 let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
3352 dlg.begin(client::MethodInfo { id: "binaryauthorization.projects.attestors.validateAttestationOccurrence",
3353 http_method: hyper::Method::POST });
3354
3355 for &field in ["alt", "attestor"].iter() {
3356 if self._additional_params.contains_key(field) {
3357 dlg.finished(false);
3358 return Err(client::Error::FieldClash(field));
3359 }
3360 }
3361
3362 let mut params = Params::with_capacity(4 + self._additional_params.len());
3363 params.push("attestor", self._attestor);
3364
3365 params.extend(self._additional_params.iter());
3366
3367 params.push("alt", "json");
3368 let mut url = self.hub._base_url.clone() + "v1/{+attestor}:validateAttestationOccurrence";
3369 if self._scopes.is_empty() {
3370 self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
3371 }
3372
3373 for &(find_this, param_name) in [("{+attestor}", "attestor")].iter() {
3374 url = params.uri_replacement(url, param_name, find_this, true);
3375 }
3376 {
3377 let to_remove = ["attestor"];
3378 params.remove_params(&to_remove);
3379 }
3380
3381 let url = params.parse_with_url(&url);
3382
3383 let mut json_mime_type = mime::APPLICATION_JSON;
3384 let mut request_value_reader =
3385 {
3386 let mut value = json::value::to_value(&self._request).expect("serde to work");
3387 client::remove_json_null_values(&mut value);
3388 let mut dst = io::Cursor::new(Vec::with_capacity(128));
3389 json::to_writer(&mut dst, &value).unwrap();
3390 dst
3391 };
3392 let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
3393 request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
3394
3395
3396 loop {
3397 let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
3398 Ok(token) => token,
3399 Err(e) => {
3400 match dlg.token(e) {
3401 Ok(token) => token,
3402 Err(e) => {
3403 dlg.finished(false);
3404 return Err(client::Error::MissingToken(e));
3405 }
3406 }
3407 }
3408 };
3409 request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
3410 let mut req_result = {
3411 let client = &self.hub.client;
3412 dlg.pre_request();
3413 let mut req_builder = hyper::Request::builder()
3414 .method(hyper::Method::POST)
3415 .uri(url.as_str())
3416 .header(USER_AGENT, self.hub._user_agent.clone());
3417
3418 if let Some(token) = token.as_ref() {
3419 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3420 }
3421
3422
3423 let request = req_builder
3424 .header(CONTENT_TYPE, json_mime_type.to_string())
3425 .header(CONTENT_LENGTH, request_size as u64)
3426 .body(hyper::body::Body::from(request_value_reader.get_ref().clone()));
3427
3428 client.request(request.unwrap()).await
3429
3430 };
3431
3432 match req_result {
3433 Err(err) => {
3434 if let client::Retry::After(d) = dlg.http_error(&err) {
3435 sleep(d).await;
3436 continue;
3437 }
3438 dlg.finished(false);
3439 return Err(client::Error::HttpError(err))
3440 }
3441 Ok(mut res) => {
3442 if !res.status().is_success() {
3443 let res_body_string = client::get_body_as_string(res.body_mut()).await;
3444 let (parts, _) = res.into_parts();
3445 let body = hyper::Body::from(res_body_string.clone());
3446 let restored_response = hyper::Response::from_parts(parts, body);
3447
3448 let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
3449
3450 if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
3451 sleep(d).await;
3452 continue;
3453 }
3454
3455 dlg.finished(false);
3456
3457 return match server_response {
3458 Some(error_value) => Err(client::Error::BadRequest(error_value)),
3459 None => Err(client::Error::Failure(restored_response)),
3460 }
3461 }
3462 let result_value = {
3463 let res_body_string = client::get_body_as_string(res.body_mut()).await;
3464
3465 match json::from_str(&res_body_string) {
3466 Ok(decoded) => (res, decoded),
3467 Err(err) => {
3468 dlg.response_json_decode_error(&res_body_string, &err);
3469 return Err(client::Error::JsonDecodeError(res_body_string, err));
3470 }
3471 }
3472 };
3473
3474 dlg.finished(true);
3475 return Ok(result_value)
3476 }
3477 }
3478 }
3479 }
3480
3481
3482 ///
3483 /// Sets the *request* property to the given value.
3484 ///
3485 /// Even though the property as already been set when instantiating this call,
3486 /// we provide this method for API completeness.
3487 pub fn request(mut self, new_value: ValidateAttestationOccurrenceRequest) -> ProjectAttestorValidateAttestationOccurrenceCall<'a, S> {
3488 self._request = new_value;
3489 self
3490 }
3491 /// Required. The resource name of the Attestor of the occurrence, in the format `projects/*/attestors/*`.
3492 ///
3493 /// Sets the *attestor* path property to the given value.
3494 ///
3495 /// Even though the property as already been set when instantiating this call,
3496 /// we provide this method for API completeness.
3497 pub fn attestor(mut self, new_value: &str) -> ProjectAttestorValidateAttestationOccurrenceCall<'a, S> {
3498 self._attestor = new_value.to_string();
3499 self
3500 }
3501 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3502 /// while executing the actual API request.
3503 ///
3504 /// ````text
3505 /// It should be used to handle progress information, and to implement a certain level of resilience.
3506 /// ````
3507 ///
3508 /// Sets the *delegate* property to the given value.
3509 pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ProjectAttestorValidateAttestationOccurrenceCall<'a, S> {
3510 self._delegate = Some(new_value);
3511 self
3512 }
3513
3514 /// Set any additional parameter of the query string used in the request.
3515 /// It should be used to set parameters which are not yet available through their own
3516 /// setters.
3517 ///
3518 /// Please note that this method must not be used to set any of the known parameters
3519 /// which have their own setter method. If done anyway, the request will fail.
3520 ///
3521 /// # Additional Parameters
3522 ///
3523 /// * *$.xgafv* (query-string) - V1 error format.
3524 /// * *access_token* (query-string) - OAuth access token.
3525 /// * *alt* (query-string) - Data format for response.
3526 /// * *callback* (query-string) - JSONP
3527 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3528 /// * *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.
3529 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3530 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3531 /// * *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.
3532 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3533 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3534 pub fn param<T>(mut self, name: T, value: T) -> ProjectAttestorValidateAttestationOccurrenceCall<'a, S>
3535 where T: AsRef<str> {
3536 self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
3537 self
3538 }
3539
3540 /// Identifies the authorization scope for the method you are building.
3541 ///
3542 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3543 /// [`Scope::CloudPlatform`].
3544 ///
3545 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3546 /// tokens for more than one scope.
3547 ///
3548 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3549 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3550 /// sufficient, a read-write scope will do as well.
3551 pub fn add_scope<St>(mut self, scope: St) -> ProjectAttestorValidateAttestationOccurrenceCall<'a, S>
3552 where St: AsRef<str> {
3553 self._scopes.insert(String::from(scope.as_ref()));
3554 self
3555 }
3556 /// Identifies the authorization scope(s) for the method you are building.
3557 ///
3558 /// See [`Self::add_scope()`] for details.
3559 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectAttestorValidateAttestationOccurrenceCall<'a, S>
3560 where I: IntoIterator<Item = St>,
3561 St: AsRef<str> {
3562 self._scopes
3563 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3564 self
3565 }
3566
3567 /// Removes all scopes, and no default scope will be used either.
3568 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3569 /// for details).
3570 pub fn clear_scopes(mut self) -> ProjectAttestorValidateAttestationOccurrenceCall<'a, S> {
3571 self._scopes.clear();
3572 self
3573 }
3574}
3575
3576
3577/// Gets the access control policy for a resource. Returns an empty policy if the resource exists and does not have a policy set.
3578///
3579/// A builder for the *policy.getIamPolicy* method supported by a *project* resource.
3580/// It is not used directly, but through a [`ProjectMethods`] instance.
3581///
3582/// # Example
3583///
3584/// Instantiate a resource method builder
3585///
3586/// ```test_harness,no_run
3587/// # extern crate hyper;
3588/// # extern crate hyper_rustls;
3589/// # extern crate google_binaryauthorization1 as binaryauthorization1;
3590/// # async fn dox() {
3591/// # use std::default::Default;
3592/// # use binaryauthorization1::{BinaryAuthorization, oauth2, hyper, hyper_rustls, chrono, FieldMask};
3593///
3594/// # let secret: oauth2::ApplicationSecret = Default::default();
3595/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
3596/// # secret,
3597/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3598/// # ).build().await.unwrap();
3599/// # let mut hub = BinaryAuthorization::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth);
3600/// // You can configure optional parameters by calling the respective setters at will, and
3601/// // execute the final call using `doit()`.
3602/// // Values shown here are possibly random and not representative !
3603/// let result = hub.projects().policy_get_iam_policy("resource")
3604/// .options_requested_policy_version(-88)
3605/// .doit().await;
3606/// # }
3607/// ```
3608pub struct ProjectPolicyGetIamPolicyCall<'a, S>
3609 where S: 'a {
3610
3611 hub: &'a BinaryAuthorization<S>,
3612 _resource: String,
3613 _options_requested_policy_version: Option<i32>,
3614 _delegate: Option<&'a mut dyn client::Delegate>,
3615 _additional_params: HashMap<String, String>,
3616 _scopes: BTreeSet<String>
3617}
3618
3619impl<'a, S> client::CallBuilder for ProjectPolicyGetIamPolicyCall<'a, S> {}
3620
3621impl<'a, S> ProjectPolicyGetIamPolicyCall<'a, S>
3622where
3623 S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
3624 S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
3625 S::Future: Send + Unpin + 'static,
3626 S::Error: Into<Box<dyn StdError + Send + Sync>>,
3627{
3628
3629
3630 /// Perform the operation you have build so far.
3631 pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, IamPolicy)> {
3632 use std::io::{Read, Seek};
3633 use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
3634 use client::{ToParts, url::Params};
3635 use std::borrow::Cow;
3636
3637 let mut dd = client::DefaultDelegate;
3638 let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
3639 dlg.begin(client::MethodInfo { id: "binaryauthorization.projects.policy.getIamPolicy",
3640 http_method: hyper::Method::GET });
3641
3642 for &field in ["alt", "resource", "options.requestedPolicyVersion"].iter() {
3643 if self._additional_params.contains_key(field) {
3644 dlg.finished(false);
3645 return Err(client::Error::FieldClash(field));
3646 }
3647 }
3648
3649 let mut params = Params::with_capacity(4 + self._additional_params.len());
3650 params.push("resource", self._resource);
3651 if let Some(value) = self._options_requested_policy_version.as_ref() {
3652 params.push("options.requestedPolicyVersion", value.to_string());
3653 }
3654
3655 params.extend(self._additional_params.iter());
3656
3657 params.push("alt", "json");
3658 let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
3659 if self._scopes.is_empty() {
3660 self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
3661 }
3662
3663 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
3664 url = params.uri_replacement(url, param_name, find_this, true);
3665 }
3666 {
3667 let to_remove = ["resource"];
3668 params.remove_params(&to_remove);
3669 }
3670
3671 let url = params.parse_with_url(&url);
3672
3673
3674
3675 loop {
3676 let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
3677 Ok(token) => token,
3678 Err(e) => {
3679 match dlg.token(e) {
3680 Ok(token) => token,
3681 Err(e) => {
3682 dlg.finished(false);
3683 return Err(client::Error::MissingToken(e));
3684 }
3685 }
3686 }
3687 };
3688 let mut req_result = {
3689 let client = &self.hub.client;
3690 dlg.pre_request();
3691 let mut req_builder = hyper::Request::builder()
3692 .method(hyper::Method::GET)
3693 .uri(url.as_str())
3694 .header(USER_AGENT, self.hub._user_agent.clone());
3695
3696 if let Some(token) = token.as_ref() {
3697 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3698 }
3699
3700
3701 let request = req_builder
3702 .body(hyper::body::Body::empty());
3703
3704 client.request(request.unwrap()).await
3705
3706 };
3707
3708 match req_result {
3709 Err(err) => {
3710 if let client::Retry::After(d) = dlg.http_error(&err) {
3711 sleep(d).await;
3712 continue;
3713 }
3714 dlg.finished(false);
3715 return Err(client::Error::HttpError(err))
3716 }
3717 Ok(mut res) => {
3718 if !res.status().is_success() {
3719 let res_body_string = client::get_body_as_string(res.body_mut()).await;
3720 let (parts, _) = res.into_parts();
3721 let body = hyper::Body::from(res_body_string.clone());
3722 let restored_response = hyper::Response::from_parts(parts, body);
3723
3724 let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
3725
3726 if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
3727 sleep(d).await;
3728 continue;
3729 }
3730
3731 dlg.finished(false);
3732
3733 return match server_response {
3734 Some(error_value) => Err(client::Error::BadRequest(error_value)),
3735 None => Err(client::Error::Failure(restored_response)),
3736 }
3737 }
3738 let result_value = {
3739 let res_body_string = client::get_body_as_string(res.body_mut()).await;
3740
3741 match json::from_str(&res_body_string) {
3742 Ok(decoded) => (res, decoded),
3743 Err(err) => {
3744 dlg.response_json_decode_error(&res_body_string, &err);
3745 return Err(client::Error::JsonDecodeError(res_body_string, err));
3746 }
3747 }
3748 };
3749
3750 dlg.finished(true);
3751 return Ok(result_value)
3752 }
3753 }
3754 }
3755 }
3756
3757
3758 /// 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.
3759 ///
3760 /// Sets the *resource* path property to the given value.
3761 ///
3762 /// Even though the property as already been set when instantiating this call,
3763 /// we provide this method for API completeness.
3764 pub fn resource(mut self, new_value: &str) -> ProjectPolicyGetIamPolicyCall<'a, S> {
3765 self._resource = new_value.to_string();
3766 self
3767 }
3768 /// 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).
3769 ///
3770 /// Sets the *options.requested policy version* query property to the given value.
3771 pub fn options_requested_policy_version(mut self, new_value: i32) -> ProjectPolicyGetIamPolicyCall<'a, S> {
3772 self._options_requested_policy_version = Some(new_value);
3773 self
3774 }
3775 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3776 /// while executing the actual API request.
3777 ///
3778 /// ````text
3779 /// It should be used to handle progress information, and to implement a certain level of resilience.
3780 /// ````
3781 ///
3782 /// Sets the *delegate* property to the given value.
3783 pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ProjectPolicyGetIamPolicyCall<'a, S> {
3784 self._delegate = Some(new_value);
3785 self
3786 }
3787
3788 /// Set any additional parameter of the query string used in the request.
3789 /// It should be used to set parameters which are not yet available through their own
3790 /// setters.
3791 ///
3792 /// Please note that this method must not be used to set any of the known parameters
3793 /// which have their own setter method. If done anyway, the request will fail.
3794 ///
3795 /// # Additional Parameters
3796 ///
3797 /// * *$.xgafv* (query-string) - V1 error format.
3798 /// * *access_token* (query-string) - OAuth access token.
3799 /// * *alt* (query-string) - Data format for response.
3800 /// * *callback* (query-string) - JSONP
3801 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3802 /// * *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.
3803 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3804 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3805 /// * *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.
3806 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3807 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3808 pub fn param<T>(mut self, name: T, value: T) -> ProjectPolicyGetIamPolicyCall<'a, S>
3809 where T: AsRef<str> {
3810 self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
3811 self
3812 }
3813
3814 /// Identifies the authorization scope for the method you are building.
3815 ///
3816 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3817 /// [`Scope::CloudPlatform`].
3818 ///
3819 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3820 /// tokens for more than one scope.
3821 ///
3822 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3823 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3824 /// sufficient, a read-write scope will do as well.
3825 pub fn add_scope<St>(mut self, scope: St) -> ProjectPolicyGetIamPolicyCall<'a, S>
3826 where St: AsRef<str> {
3827 self._scopes.insert(String::from(scope.as_ref()));
3828 self
3829 }
3830 /// Identifies the authorization scope(s) for the method you are building.
3831 ///
3832 /// See [`Self::add_scope()`] for details.
3833 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectPolicyGetIamPolicyCall<'a, S>
3834 where I: IntoIterator<Item = St>,
3835 St: AsRef<str> {
3836 self._scopes
3837 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3838 self
3839 }
3840
3841 /// Removes all scopes, and no default scope will be used either.
3842 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3843 /// for details).
3844 pub fn clear_scopes(mut self) -> ProjectPolicyGetIamPolicyCall<'a, S> {
3845 self._scopes.clear();
3846 self
3847 }
3848}
3849
3850
3851/// Sets the access control policy on the specified resource. Replaces any existing policy. Can return `NOT_FOUND`, `INVALID_ARGUMENT`, and `PERMISSION_DENIED` errors.
3852///
3853/// A builder for the *policy.setIamPolicy* method supported by a *project* resource.
3854/// It is not used directly, but through a [`ProjectMethods`] instance.
3855///
3856/// # Example
3857///
3858/// Instantiate a resource method builder
3859///
3860/// ```test_harness,no_run
3861/// # extern crate hyper;
3862/// # extern crate hyper_rustls;
3863/// # extern crate google_binaryauthorization1 as binaryauthorization1;
3864/// use binaryauthorization1::api::SetIamPolicyRequest;
3865/// # async fn dox() {
3866/// # use std::default::Default;
3867/// # use binaryauthorization1::{BinaryAuthorization, oauth2, hyper, hyper_rustls, chrono, FieldMask};
3868///
3869/// # let secret: oauth2::ApplicationSecret = Default::default();
3870/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
3871/// # secret,
3872/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3873/// # ).build().await.unwrap();
3874/// # let mut hub = BinaryAuthorization::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth);
3875/// // As the method needs a request, you would usually fill it with the desired information
3876/// // into the respective structure. Some of the parts shown here might not be applicable !
3877/// // Values shown here are possibly random and not representative !
3878/// let mut req = SetIamPolicyRequest::default();
3879///
3880/// // You can configure optional parameters by calling the respective setters at will, and
3881/// // execute the final call using `doit()`.
3882/// // Values shown here are possibly random and not representative !
3883/// let result = hub.projects().policy_set_iam_policy(req, "resource")
3884/// .doit().await;
3885/// # }
3886/// ```
3887pub struct ProjectPolicySetIamPolicyCall<'a, S>
3888 where S: 'a {
3889
3890 hub: &'a BinaryAuthorization<S>,
3891 _request: SetIamPolicyRequest,
3892 _resource: String,
3893 _delegate: Option<&'a mut dyn client::Delegate>,
3894 _additional_params: HashMap<String, String>,
3895 _scopes: BTreeSet<String>
3896}
3897
3898impl<'a, S> client::CallBuilder for ProjectPolicySetIamPolicyCall<'a, S> {}
3899
3900impl<'a, S> ProjectPolicySetIamPolicyCall<'a, S>
3901where
3902 S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
3903 S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
3904 S::Future: Send + Unpin + 'static,
3905 S::Error: Into<Box<dyn StdError + Send + Sync>>,
3906{
3907
3908
3909 /// Perform the operation you have build so far.
3910 pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, IamPolicy)> {
3911 use std::io::{Read, Seek};
3912 use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
3913 use client::{ToParts, url::Params};
3914 use std::borrow::Cow;
3915
3916 let mut dd = client::DefaultDelegate;
3917 let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
3918 dlg.begin(client::MethodInfo { id: "binaryauthorization.projects.policy.setIamPolicy",
3919 http_method: hyper::Method::POST });
3920
3921 for &field in ["alt", "resource"].iter() {
3922 if self._additional_params.contains_key(field) {
3923 dlg.finished(false);
3924 return Err(client::Error::FieldClash(field));
3925 }
3926 }
3927
3928 let mut params = Params::with_capacity(4 + self._additional_params.len());
3929 params.push("resource", self._resource);
3930
3931 params.extend(self._additional_params.iter());
3932
3933 params.push("alt", "json");
3934 let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
3935 if self._scopes.is_empty() {
3936 self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
3937 }
3938
3939 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
3940 url = params.uri_replacement(url, param_name, find_this, true);
3941 }
3942 {
3943 let to_remove = ["resource"];
3944 params.remove_params(&to_remove);
3945 }
3946
3947 let url = params.parse_with_url(&url);
3948
3949 let mut json_mime_type = mime::APPLICATION_JSON;
3950 let mut request_value_reader =
3951 {
3952 let mut value = json::value::to_value(&self._request).expect("serde to work");
3953 client::remove_json_null_values(&mut value);
3954 let mut dst = io::Cursor::new(Vec::with_capacity(128));
3955 json::to_writer(&mut dst, &value).unwrap();
3956 dst
3957 };
3958 let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
3959 request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
3960
3961
3962 loop {
3963 let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
3964 Ok(token) => token,
3965 Err(e) => {
3966 match dlg.token(e) {
3967 Ok(token) => token,
3968 Err(e) => {
3969 dlg.finished(false);
3970 return Err(client::Error::MissingToken(e));
3971 }
3972 }
3973 }
3974 };
3975 request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
3976 let mut req_result = {
3977 let client = &self.hub.client;
3978 dlg.pre_request();
3979 let mut req_builder = hyper::Request::builder()
3980 .method(hyper::Method::POST)
3981 .uri(url.as_str())
3982 .header(USER_AGENT, self.hub._user_agent.clone());
3983
3984 if let Some(token) = token.as_ref() {
3985 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3986 }
3987
3988
3989 let request = req_builder
3990 .header(CONTENT_TYPE, json_mime_type.to_string())
3991 .header(CONTENT_LENGTH, request_size as u64)
3992 .body(hyper::body::Body::from(request_value_reader.get_ref().clone()));
3993
3994 client.request(request.unwrap()).await
3995
3996 };
3997
3998 match req_result {
3999 Err(err) => {
4000 if let client::Retry::After(d) = dlg.http_error(&err) {
4001 sleep(d).await;
4002 continue;
4003 }
4004 dlg.finished(false);
4005 return Err(client::Error::HttpError(err))
4006 }
4007 Ok(mut res) => {
4008 if !res.status().is_success() {
4009 let res_body_string = client::get_body_as_string(res.body_mut()).await;
4010 let (parts, _) = res.into_parts();
4011 let body = hyper::Body::from(res_body_string.clone());
4012 let restored_response = hyper::Response::from_parts(parts, body);
4013
4014 let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
4015
4016 if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
4017 sleep(d).await;
4018 continue;
4019 }
4020
4021 dlg.finished(false);
4022
4023 return match server_response {
4024 Some(error_value) => Err(client::Error::BadRequest(error_value)),
4025 None => Err(client::Error::Failure(restored_response)),
4026 }
4027 }
4028 let result_value = {
4029 let res_body_string = client::get_body_as_string(res.body_mut()).await;
4030
4031 match json::from_str(&res_body_string) {
4032 Ok(decoded) => (res, decoded),
4033 Err(err) => {
4034 dlg.response_json_decode_error(&res_body_string, &err);
4035 return Err(client::Error::JsonDecodeError(res_body_string, err));
4036 }
4037 }
4038 };
4039
4040 dlg.finished(true);
4041 return Ok(result_value)
4042 }
4043 }
4044 }
4045 }
4046
4047
4048 ///
4049 /// Sets the *request* property to the given value.
4050 ///
4051 /// Even though the property as already been set when instantiating this call,
4052 /// we provide this method for API completeness.
4053 pub fn request(mut self, new_value: SetIamPolicyRequest) -> ProjectPolicySetIamPolicyCall<'a, S> {
4054 self._request = new_value;
4055 self
4056 }
4057 /// 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.
4058 ///
4059 /// Sets the *resource* path property to the given value.
4060 ///
4061 /// Even though the property as already been set when instantiating this call,
4062 /// we provide this method for API completeness.
4063 pub fn resource(mut self, new_value: &str) -> ProjectPolicySetIamPolicyCall<'a, S> {
4064 self._resource = new_value.to_string();
4065 self
4066 }
4067 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4068 /// while executing the actual API request.
4069 ///
4070 /// ````text
4071 /// It should be used to handle progress information, and to implement a certain level of resilience.
4072 /// ````
4073 ///
4074 /// Sets the *delegate* property to the given value.
4075 pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ProjectPolicySetIamPolicyCall<'a, S> {
4076 self._delegate = Some(new_value);
4077 self
4078 }
4079
4080 /// Set any additional parameter of the query string used in the request.
4081 /// It should be used to set parameters which are not yet available through their own
4082 /// setters.
4083 ///
4084 /// Please note that this method must not be used to set any of the known parameters
4085 /// which have their own setter method. If done anyway, the request will fail.
4086 ///
4087 /// # Additional Parameters
4088 ///
4089 /// * *$.xgafv* (query-string) - V1 error format.
4090 /// * *access_token* (query-string) - OAuth access token.
4091 /// * *alt* (query-string) - Data format for response.
4092 /// * *callback* (query-string) - JSONP
4093 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4094 /// * *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.
4095 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4096 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4097 /// * *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.
4098 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4099 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4100 pub fn param<T>(mut self, name: T, value: T) -> ProjectPolicySetIamPolicyCall<'a, S>
4101 where T: AsRef<str> {
4102 self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
4103 self
4104 }
4105
4106 /// Identifies the authorization scope for the method you are building.
4107 ///
4108 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4109 /// [`Scope::CloudPlatform`].
4110 ///
4111 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4112 /// tokens for more than one scope.
4113 ///
4114 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4115 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4116 /// sufficient, a read-write scope will do as well.
4117 pub fn add_scope<St>(mut self, scope: St) -> ProjectPolicySetIamPolicyCall<'a, S>
4118 where St: AsRef<str> {
4119 self._scopes.insert(String::from(scope.as_ref()));
4120 self
4121 }
4122 /// Identifies the authorization scope(s) for the method you are building.
4123 ///
4124 /// See [`Self::add_scope()`] for details.
4125 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectPolicySetIamPolicyCall<'a, S>
4126 where I: IntoIterator<Item = St>,
4127 St: AsRef<str> {
4128 self._scopes
4129 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4130 self
4131 }
4132
4133 /// Removes all scopes, and no default scope will be used either.
4134 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4135 /// for details).
4136 pub fn clear_scopes(mut self) -> ProjectPolicySetIamPolicyCall<'a, S> {
4137 self._scopes.clear();
4138 self
4139 }
4140}
4141
4142
4143/// Returns permissions that a caller has on the specified resource. If the resource does not exist, this will return an empty set of permissions, not a `NOT_FOUND` error. Note: This operation is designed to be used for building permission-aware UIs and command-line tools, not for authorization checking. This operation may "fail open" without warning.
4144///
4145/// A builder for the *policy.testIamPermissions* method supported by a *project* resource.
4146/// It is not used directly, but through a [`ProjectMethods`] instance.
4147///
4148/// # Example
4149///
4150/// Instantiate a resource method builder
4151///
4152/// ```test_harness,no_run
4153/// # extern crate hyper;
4154/// # extern crate hyper_rustls;
4155/// # extern crate google_binaryauthorization1 as binaryauthorization1;
4156/// use binaryauthorization1::api::TestIamPermissionsRequest;
4157/// # async fn dox() {
4158/// # use std::default::Default;
4159/// # use binaryauthorization1::{BinaryAuthorization, oauth2, hyper, hyper_rustls, chrono, FieldMask};
4160///
4161/// # let secret: oauth2::ApplicationSecret = Default::default();
4162/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
4163/// # secret,
4164/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4165/// # ).build().await.unwrap();
4166/// # let mut hub = BinaryAuthorization::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth);
4167/// // As the method needs a request, you would usually fill it with the desired information
4168/// // into the respective structure. Some of the parts shown here might not be applicable !
4169/// // Values shown here are possibly random and not representative !
4170/// let mut req = TestIamPermissionsRequest::default();
4171///
4172/// // You can configure optional parameters by calling the respective setters at will, and
4173/// // execute the final call using `doit()`.
4174/// // Values shown here are possibly random and not representative !
4175/// let result = hub.projects().policy_test_iam_permissions(req, "resource")
4176/// .doit().await;
4177/// # }
4178/// ```
4179pub struct ProjectPolicyTestIamPermissionCall<'a, S>
4180 where S: 'a {
4181
4182 hub: &'a BinaryAuthorization<S>,
4183 _request: TestIamPermissionsRequest,
4184 _resource: String,
4185 _delegate: Option<&'a mut dyn client::Delegate>,
4186 _additional_params: HashMap<String, String>,
4187 _scopes: BTreeSet<String>
4188}
4189
4190impl<'a, S> client::CallBuilder for ProjectPolicyTestIamPermissionCall<'a, S> {}
4191
4192impl<'a, S> ProjectPolicyTestIamPermissionCall<'a, S>
4193where
4194 S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
4195 S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
4196 S::Future: Send + Unpin + 'static,
4197 S::Error: Into<Box<dyn StdError + Send + Sync>>,
4198{
4199
4200
4201 /// Perform the operation you have build so far.
4202 pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, TestIamPermissionsResponse)> {
4203 use std::io::{Read, Seek};
4204 use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
4205 use client::{ToParts, url::Params};
4206 use std::borrow::Cow;
4207
4208 let mut dd = client::DefaultDelegate;
4209 let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
4210 dlg.begin(client::MethodInfo { id: "binaryauthorization.projects.policy.testIamPermissions",
4211 http_method: hyper::Method::POST });
4212
4213 for &field in ["alt", "resource"].iter() {
4214 if self._additional_params.contains_key(field) {
4215 dlg.finished(false);
4216 return Err(client::Error::FieldClash(field));
4217 }
4218 }
4219
4220 let mut params = Params::with_capacity(4 + self._additional_params.len());
4221 params.push("resource", self._resource);
4222
4223 params.extend(self._additional_params.iter());
4224
4225 params.push("alt", "json");
4226 let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
4227 if self._scopes.is_empty() {
4228 self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
4229 }
4230
4231 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
4232 url = params.uri_replacement(url, param_name, find_this, true);
4233 }
4234 {
4235 let to_remove = ["resource"];
4236 params.remove_params(&to_remove);
4237 }
4238
4239 let url = params.parse_with_url(&url);
4240
4241 let mut json_mime_type = mime::APPLICATION_JSON;
4242 let mut request_value_reader =
4243 {
4244 let mut value = json::value::to_value(&self._request).expect("serde to work");
4245 client::remove_json_null_values(&mut value);
4246 let mut dst = io::Cursor::new(Vec::with_capacity(128));
4247 json::to_writer(&mut dst, &value).unwrap();
4248 dst
4249 };
4250 let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
4251 request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
4252
4253
4254 loop {
4255 let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
4256 Ok(token) => token,
4257 Err(e) => {
4258 match dlg.token(e) {
4259 Ok(token) => token,
4260 Err(e) => {
4261 dlg.finished(false);
4262 return Err(client::Error::MissingToken(e));
4263 }
4264 }
4265 }
4266 };
4267 request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
4268 let mut req_result = {
4269 let client = &self.hub.client;
4270 dlg.pre_request();
4271 let mut req_builder = hyper::Request::builder()
4272 .method(hyper::Method::POST)
4273 .uri(url.as_str())
4274 .header(USER_AGENT, self.hub._user_agent.clone());
4275
4276 if let Some(token) = token.as_ref() {
4277 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4278 }
4279
4280
4281 let request = req_builder
4282 .header(CONTENT_TYPE, json_mime_type.to_string())
4283 .header(CONTENT_LENGTH, request_size as u64)
4284 .body(hyper::body::Body::from(request_value_reader.get_ref().clone()));
4285
4286 client.request(request.unwrap()).await
4287
4288 };
4289
4290 match req_result {
4291 Err(err) => {
4292 if let client::Retry::After(d) = dlg.http_error(&err) {
4293 sleep(d).await;
4294 continue;
4295 }
4296 dlg.finished(false);
4297 return Err(client::Error::HttpError(err))
4298 }
4299 Ok(mut res) => {
4300 if !res.status().is_success() {
4301 let res_body_string = client::get_body_as_string(res.body_mut()).await;
4302 let (parts, _) = res.into_parts();
4303 let body = hyper::Body::from(res_body_string.clone());
4304 let restored_response = hyper::Response::from_parts(parts, body);
4305
4306 let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
4307
4308 if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
4309 sleep(d).await;
4310 continue;
4311 }
4312
4313 dlg.finished(false);
4314
4315 return match server_response {
4316 Some(error_value) => Err(client::Error::BadRequest(error_value)),
4317 None => Err(client::Error::Failure(restored_response)),
4318 }
4319 }
4320 let result_value = {
4321 let res_body_string = client::get_body_as_string(res.body_mut()).await;
4322
4323 match json::from_str(&res_body_string) {
4324 Ok(decoded) => (res, decoded),
4325 Err(err) => {
4326 dlg.response_json_decode_error(&res_body_string, &err);
4327 return Err(client::Error::JsonDecodeError(res_body_string, err));
4328 }
4329 }
4330 };
4331
4332 dlg.finished(true);
4333 return Ok(result_value)
4334 }
4335 }
4336 }
4337 }
4338
4339
4340 ///
4341 /// Sets the *request* property to the given value.
4342 ///
4343 /// Even though the property as already been set when instantiating this call,
4344 /// we provide this method for API completeness.
4345 pub fn request(mut self, new_value: TestIamPermissionsRequest) -> ProjectPolicyTestIamPermissionCall<'a, S> {
4346 self._request = new_value;
4347 self
4348 }
4349 /// 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.
4350 ///
4351 /// Sets the *resource* path property to the given value.
4352 ///
4353 /// Even though the property as already been set when instantiating this call,
4354 /// we provide this method for API completeness.
4355 pub fn resource(mut self, new_value: &str) -> ProjectPolicyTestIamPermissionCall<'a, S> {
4356 self._resource = new_value.to_string();
4357 self
4358 }
4359 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4360 /// while executing the actual API request.
4361 ///
4362 /// ````text
4363 /// It should be used to handle progress information, and to implement a certain level of resilience.
4364 /// ````
4365 ///
4366 /// Sets the *delegate* property to the given value.
4367 pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ProjectPolicyTestIamPermissionCall<'a, S> {
4368 self._delegate = Some(new_value);
4369 self
4370 }
4371
4372 /// Set any additional parameter of the query string used in the request.
4373 /// It should be used to set parameters which are not yet available through their own
4374 /// setters.
4375 ///
4376 /// Please note that this method must not be used to set any of the known parameters
4377 /// which have their own setter method. If done anyway, the request will fail.
4378 ///
4379 /// # Additional Parameters
4380 ///
4381 /// * *$.xgafv* (query-string) - V1 error format.
4382 /// * *access_token* (query-string) - OAuth access token.
4383 /// * *alt* (query-string) - Data format for response.
4384 /// * *callback* (query-string) - JSONP
4385 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4386 /// * *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.
4387 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4388 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4389 /// * *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.
4390 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4391 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4392 pub fn param<T>(mut self, name: T, value: T) -> ProjectPolicyTestIamPermissionCall<'a, S>
4393 where T: AsRef<str> {
4394 self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
4395 self
4396 }
4397
4398 /// Identifies the authorization scope for the method you are building.
4399 ///
4400 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4401 /// [`Scope::CloudPlatform`].
4402 ///
4403 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4404 /// tokens for more than one scope.
4405 ///
4406 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4407 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4408 /// sufficient, a read-write scope will do as well.
4409 pub fn add_scope<St>(mut self, scope: St) -> ProjectPolicyTestIamPermissionCall<'a, S>
4410 where St: AsRef<str> {
4411 self._scopes.insert(String::from(scope.as_ref()));
4412 self
4413 }
4414 /// Identifies the authorization scope(s) for the method you are building.
4415 ///
4416 /// See [`Self::add_scope()`] for details.
4417 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectPolicyTestIamPermissionCall<'a, S>
4418 where I: IntoIterator<Item = St>,
4419 St: AsRef<str> {
4420 self._scopes
4421 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4422 self
4423 }
4424
4425 /// Removes all scopes, and no default scope will be used either.
4426 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4427 /// for details).
4428 pub fn clear_scopes(mut self) -> ProjectPolicyTestIamPermissionCall<'a, S> {
4429 self._scopes.clear();
4430 self
4431 }
4432}
4433
4434
4435/// A policy specifies the attestors that must attest to a container image, before the project is allowed to deploy that image. There is at most one policy per project. All image admission requests are permitted if a project has no policy. Gets the policy for this project. Returns a default policy if the project does not have one.
4436///
4437/// A builder for the *getPolicy* method supported by a *project* resource.
4438/// It is not used directly, but through a [`ProjectMethods`] instance.
4439///
4440/// # Example
4441///
4442/// Instantiate a resource method builder
4443///
4444/// ```test_harness,no_run
4445/// # extern crate hyper;
4446/// # extern crate hyper_rustls;
4447/// # extern crate google_binaryauthorization1 as binaryauthorization1;
4448/// # async fn dox() {
4449/// # use std::default::Default;
4450/// # use binaryauthorization1::{BinaryAuthorization, oauth2, hyper, hyper_rustls, chrono, FieldMask};
4451///
4452/// # let secret: oauth2::ApplicationSecret = Default::default();
4453/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
4454/// # secret,
4455/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4456/// # ).build().await.unwrap();
4457/// # let mut hub = BinaryAuthorization::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth);
4458/// // You can configure optional parameters by calling the respective setters at will, and
4459/// // execute the final call using `doit()`.
4460/// // Values shown here are possibly random and not representative !
4461/// let result = hub.projects().get_policy("name")
4462/// .doit().await;
4463/// # }
4464/// ```
4465pub struct ProjectGetPolicyCall<'a, S>
4466 where S: 'a {
4467
4468 hub: &'a BinaryAuthorization<S>,
4469 _name: String,
4470 _delegate: Option<&'a mut dyn client::Delegate>,
4471 _additional_params: HashMap<String, String>,
4472 _scopes: BTreeSet<String>
4473}
4474
4475impl<'a, S> client::CallBuilder for ProjectGetPolicyCall<'a, S> {}
4476
4477impl<'a, S> ProjectGetPolicyCall<'a, S>
4478where
4479 S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
4480 S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
4481 S::Future: Send + Unpin + 'static,
4482 S::Error: Into<Box<dyn StdError + Send + Sync>>,
4483{
4484
4485
4486 /// Perform the operation you have build so far.
4487 pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Policy)> {
4488 use std::io::{Read, Seek};
4489 use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
4490 use client::{ToParts, url::Params};
4491 use std::borrow::Cow;
4492
4493 let mut dd = client::DefaultDelegate;
4494 let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
4495 dlg.begin(client::MethodInfo { id: "binaryauthorization.projects.getPolicy",
4496 http_method: hyper::Method::GET });
4497
4498 for &field in ["alt", "name"].iter() {
4499 if self._additional_params.contains_key(field) {
4500 dlg.finished(false);
4501 return Err(client::Error::FieldClash(field));
4502 }
4503 }
4504
4505 let mut params = Params::with_capacity(3 + self._additional_params.len());
4506 params.push("name", self._name);
4507
4508 params.extend(self._additional_params.iter());
4509
4510 params.push("alt", "json");
4511 let mut url = self.hub._base_url.clone() + "v1/{+name}";
4512 if self._scopes.is_empty() {
4513 self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
4514 }
4515
4516 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4517 url = params.uri_replacement(url, param_name, find_this, true);
4518 }
4519 {
4520 let to_remove = ["name"];
4521 params.remove_params(&to_remove);
4522 }
4523
4524 let url = params.parse_with_url(&url);
4525
4526
4527
4528 loop {
4529 let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
4530 Ok(token) => token,
4531 Err(e) => {
4532 match dlg.token(e) {
4533 Ok(token) => token,
4534 Err(e) => {
4535 dlg.finished(false);
4536 return Err(client::Error::MissingToken(e));
4537 }
4538 }
4539 }
4540 };
4541 let mut req_result = {
4542 let client = &self.hub.client;
4543 dlg.pre_request();
4544 let mut req_builder = hyper::Request::builder()
4545 .method(hyper::Method::GET)
4546 .uri(url.as_str())
4547 .header(USER_AGENT, self.hub._user_agent.clone());
4548
4549 if let Some(token) = token.as_ref() {
4550 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4551 }
4552
4553
4554 let request = req_builder
4555 .body(hyper::body::Body::empty());
4556
4557 client.request(request.unwrap()).await
4558
4559 };
4560
4561 match req_result {
4562 Err(err) => {
4563 if let client::Retry::After(d) = dlg.http_error(&err) {
4564 sleep(d).await;
4565 continue;
4566 }
4567 dlg.finished(false);
4568 return Err(client::Error::HttpError(err))
4569 }
4570 Ok(mut res) => {
4571 if !res.status().is_success() {
4572 let res_body_string = client::get_body_as_string(res.body_mut()).await;
4573 let (parts, _) = res.into_parts();
4574 let body = hyper::Body::from(res_body_string.clone());
4575 let restored_response = hyper::Response::from_parts(parts, body);
4576
4577 let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
4578
4579 if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
4580 sleep(d).await;
4581 continue;
4582 }
4583
4584 dlg.finished(false);
4585
4586 return match server_response {
4587 Some(error_value) => Err(client::Error::BadRequest(error_value)),
4588 None => Err(client::Error::Failure(restored_response)),
4589 }
4590 }
4591 let result_value = {
4592 let res_body_string = client::get_body_as_string(res.body_mut()).await;
4593
4594 match json::from_str(&res_body_string) {
4595 Ok(decoded) => (res, decoded),
4596 Err(err) => {
4597 dlg.response_json_decode_error(&res_body_string, &err);
4598 return Err(client::Error::JsonDecodeError(res_body_string, err));
4599 }
4600 }
4601 };
4602
4603 dlg.finished(true);
4604 return Ok(result_value)
4605 }
4606 }
4607 }
4608 }
4609
4610
4611 /// Required. The resource name of the policy to retrieve, in the format `projects/*/policy`.
4612 ///
4613 /// Sets the *name* path property to the given value.
4614 ///
4615 /// Even though the property as already been set when instantiating this call,
4616 /// we provide this method for API completeness.
4617 pub fn name(mut self, new_value: &str) -> ProjectGetPolicyCall<'a, S> {
4618 self._name = new_value.to_string();
4619 self
4620 }
4621 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4622 /// while executing the actual API request.
4623 ///
4624 /// ````text
4625 /// It should be used to handle progress information, and to implement a certain level of resilience.
4626 /// ````
4627 ///
4628 /// Sets the *delegate* property to the given value.
4629 pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ProjectGetPolicyCall<'a, S> {
4630 self._delegate = Some(new_value);
4631 self
4632 }
4633
4634 /// Set any additional parameter of the query string used in the request.
4635 /// It should be used to set parameters which are not yet available through their own
4636 /// setters.
4637 ///
4638 /// Please note that this method must not be used to set any of the known parameters
4639 /// which have their own setter method. If done anyway, the request will fail.
4640 ///
4641 /// # Additional Parameters
4642 ///
4643 /// * *$.xgafv* (query-string) - V1 error format.
4644 /// * *access_token* (query-string) - OAuth access token.
4645 /// * *alt* (query-string) - Data format for response.
4646 /// * *callback* (query-string) - JSONP
4647 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4648 /// * *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.
4649 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4650 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4651 /// * *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.
4652 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4653 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4654 pub fn param<T>(mut self, name: T, value: T) -> ProjectGetPolicyCall<'a, S>
4655 where T: AsRef<str> {
4656 self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
4657 self
4658 }
4659
4660 /// Identifies the authorization scope for the method you are building.
4661 ///
4662 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4663 /// [`Scope::CloudPlatform`].
4664 ///
4665 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4666 /// tokens for more than one scope.
4667 ///
4668 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4669 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4670 /// sufficient, a read-write scope will do as well.
4671 pub fn add_scope<St>(mut self, scope: St) -> ProjectGetPolicyCall<'a, S>
4672 where St: AsRef<str> {
4673 self._scopes.insert(String::from(scope.as_ref()));
4674 self
4675 }
4676 /// Identifies the authorization scope(s) for the method you are building.
4677 ///
4678 /// See [`Self::add_scope()`] for details.
4679 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectGetPolicyCall<'a, S>
4680 where I: IntoIterator<Item = St>,
4681 St: AsRef<str> {
4682 self._scopes
4683 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4684 self
4685 }
4686
4687 /// Removes all scopes, and no default scope will be used either.
4688 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4689 /// for details).
4690 pub fn clear_scopes(mut self) -> ProjectGetPolicyCall<'a, S> {
4691 self._scopes.clear();
4692 self
4693 }
4694}
4695
4696
4697/// Creates or updates a project's policy, and returns a copy of the new policy. A policy is always updated as a whole, to avoid race conditions with concurrent policy enforcement (or management!) requests. Returns NOT_FOUND if the project does not exist, INVALID_ARGUMENT if the request is malformed.
4698///
4699/// A builder for the *updatePolicy* method supported by a *project* resource.
4700/// It is not used directly, but through a [`ProjectMethods`] instance.
4701///
4702/// # Example
4703///
4704/// Instantiate a resource method builder
4705///
4706/// ```test_harness,no_run
4707/// # extern crate hyper;
4708/// # extern crate hyper_rustls;
4709/// # extern crate google_binaryauthorization1 as binaryauthorization1;
4710/// use binaryauthorization1::api::Policy;
4711/// # async fn dox() {
4712/// # use std::default::Default;
4713/// # use binaryauthorization1::{BinaryAuthorization, oauth2, hyper, hyper_rustls, chrono, FieldMask};
4714///
4715/// # let secret: oauth2::ApplicationSecret = Default::default();
4716/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
4717/// # secret,
4718/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4719/// # ).build().await.unwrap();
4720/// # let mut hub = BinaryAuthorization::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth);
4721/// // As the method needs a request, you would usually fill it with the desired information
4722/// // into the respective structure. Some of the parts shown here might not be applicable !
4723/// // Values shown here are possibly random and not representative !
4724/// let mut req = Policy::default();
4725///
4726/// // You can configure optional parameters by calling the respective setters at will, and
4727/// // execute the final call using `doit()`.
4728/// // Values shown here are possibly random and not representative !
4729/// let result = hub.projects().update_policy(req, "name")
4730/// .doit().await;
4731/// # }
4732/// ```
4733pub struct ProjectUpdatePolicyCall<'a, S>
4734 where S: 'a {
4735
4736 hub: &'a BinaryAuthorization<S>,
4737 _request: Policy,
4738 _name: String,
4739 _delegate: Option<&'a mut dyn client::Delegate>,
4740 _additional_params: HashMap<String, String>,
4741 _scopes: BTreeSet<String>
4742}
4743
4744impl<'a, S> client::CallBuilder for ProjectUpdatePolicyCall<'a, S> {}
4745
4746impl<'a, S> ProjectUpdatePolicyCall<'a, S>
4747where
4748 S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
4749 S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
4750 S::Future: Send + Unpin + 'static,
4751 S::Error: Into<Box<dyn StdError + Send + Sync>>,
4752{
4753
4754
4755 /// Perform the operation you have build so far.
4756 pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Policy)> {
4757 use std::io::{Read, Seek};
4758 use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
4759 use client::{ToParts, url::Params};
4760 use std::borrow::Cow;
4761
4762 let mut dd = client::DefaultDelegate;
4763 let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
4764 dlg.begin(client::MethodInfo { id: "binaryauthorization.projects.updatePolicy",
4765 http_method: hyper::Method::PUT });
4766
4767 for &field in ["alt", "name"].iter() {
4768 if self._additional_params.contains_key(field) {
4769 dlg.finished(false);
4770 return Err(client::Error::FieldClash(field));
4771 }
4772 }
4773
4774 let mut params = Params::with_capacity(4 + self._additional_params.len());
4775 params.push("name", self._name);
4776
4777 params.extend(self._additional_params.iter());
4778
4779 params.push("alt", "json");
4780 let mut url = self.hub._base_url.clone() + "v1/{+name}";
4781 if self._scopes.is_empty() {
4782 self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
4783 }
4784
4785 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4786 url = params.uri_replacement(url, param_name, find_this, true);
4787 }
4788 {
4789 let to_remove = ["name"];
4790 params.remove_params(&to_remove);
4791 }
4792
4793 let url = params.parse_with_url(&url);
4794
4795 let mut json_mime_type = mime::APPLICATION_JSON;
4796 let mut request_value_reader =
4797 {
4798 let mut value = json::value::to_value(&self._request).expect("serde to work");
4799 client::remove_json_null_values(&mut value);
4800 let mut dst = io::Cursor::new(Vec::with_capacity(128));
4801 json::to_writer(&mut dst, &value).unwrap();
4802 dst
4803 };
4804 let request_size = request_value_reader.seek(io::SeekFrom::End(0)).unwrap();
4805 request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
4806
4807
4808 loop {
4809 let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
4810 Ok(token) => token,
4811 Err(e) => {
4812 match dlg.token(e) {
4813 Ok(token) => token,
4814 Err(e) => {
4815 dlg.finished(false);
4816 return Err(client::Error::MissingToken(e));
4817 }
4818 }
4819 }
4820 };
4821 request_value_reader.seek(io::SeekFrom::Start(0)).unwrap();
4822 let mut req_result = {
4823 let client = &self.hub.client;
4824 dlg.pre_request();
4825 let mut req_builder = hyper::Request::builder()
4826 .method(hyper::Method::PUT)
4827 .uri(url.as_str())
4828 .header(USER_AGENT, self.hub._user_agent.clone());
4829
4830 if let Some(token) = token.as_ref() {
4831 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4832 }
4833
4834
4835 let request = req_builder
4836 .header(CONTENT_TYPE, json_mime_type.to_string())
4837 .header(CONTENT_LENGTH, request_size as u64)
4838 .body(hyper::body::Body::from(request_value_reader.get_ref().clone()));
4839
4840 client.request(request.unwrap()).await
4841
4842 };
4843
4844 match req_result {
4845 Err(err) => {
4846 if let client::Retry::After(d) = dlg.http_error(&err) {
4847 sleep(d).await;
4848 continue;
4849 }
4850 dlg.finished(false);
4851 return Err(client::Error::HttpError(err))
4852 }
4853 Ok(mut res) => {
4854 if !res.status().is_success() {
4855 let res_body_string = client::get_body_as_string(res.body_mut()).await;
4856 let (parts, _) = res.into_parts();
4857 let body = hyper::Body::from(res_body_string.clone());
4858 let restored_response = hyper::Response::from_parts(parts, body);
4859
4860 let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
4861
4862 if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
4863 sleep(d).await;
4864 continue;
4865 }
4866
4867 dlg.finished(false);
4868
4869 return match server_response {
4870 Some(error_value) => Err(client::Error::BadRequest(error_value)),
4871 None => Err(client::Error::Failure(restored_response)),
4872 }
4873 }
4874 let result_value = {
4875 let res_body_string = client::get_body_as_string(res.body_mut()).await;
4876
4877 match json::from_str(&res_body_string) {
4878 Ok(decoded) => (res, decoded),
4879 Err(err) => {
4880 dlg.response_json_decode_error(&res_body_string, &err);
4881 return Err(client::Error::JsonDecodeError(res_body_string, err));
4882 }
4883 }
4884 };
4885
4886 dlg.finished(true);
4887 return Ok(result_value)
4888 }
4889 }
4890 }
4891 }
4892
4893
4894 ///
4895 /// Sets the *request* property to the given value.
4896 ///
4897 /// Even though the property as already been set when instantiating this call,
4898 /// we provide this method for API completeness.
4899 pub fn request(mut self, new_value: Policy) -> ProjectUpdatePolicyCall<'a, S> {
4900 self._request = new_value;
4901 self
4902 }
4903 /// Output only. The resource name, in the format `projects/*/policy`. There is at most one policy per project.
4904 ///
4905 /// Sets the *name* path property to the given value.
4906 ///
4907 /// Even though the property as already been set when instantiating this call,
4908 /// we provide this method for API completeness.
4909 pub fn name(mut self, new_value: &str) -> ProjectUpdatePolicyCall<'a, S> {
4910 self._name = new_value.to_string();
4911 self
4912 }
4913 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4914 /// while executing the actual API request.
4915 ///
4916 /// ````text
4917 /// It should be used to handle progress information, and to implement a certain level of resilience.
4918 /// ````
4919 ///
4920 /// Sets the *delegate* property to the given value.
4921 pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> ProjectUpdatePolicyCall<'a, S> {
4922 self._delegate = Some(new_value);
4923 self
4924 }
4925
4926 /// Set any additional parameter of the query string used in the request.
4927 /// It should be used to set parameters which are not yet available through their own
4928 /// setters.
4929 ///
4930 /// Please note that this method must not be used to set any of the known parameters
4931 /// which have their own setter method. If done anyway, the request will fail.
4932 ///
4933 /// # Additional Parameters
4934 ///
4935 /// * *$.xgafv* (query-string) - V1 error format.
4936 /// * *access_token* (query-string) - OAuth access token.
4937 /// * *alt* (query-string) - Data format for response.
4938 /// * *callback* (query-string) - JSONP
4939 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4940 /// * *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.
4941 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4942 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4943 /// * *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.
4944 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4945 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4946 pub fn param<T>(mut self, name: T, value: T) -> ProjectUpdatePolicyCall<'a, S>
4947 where T: AsRef<str> {
4948 self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
4949 self
4950 }
4951
4952 /// Identifies the authorization scope for the method you are building.
4953 ///
4954 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4955 /// [`Scope::CloudPlatform`].
4956 ///
4957 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4958 /// tokens for more than one scope.
4959 ///
4960 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4961 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4962 /// sufficient, a read-write scope will do as well.
4963 pub fn add_scope<St>(mut self, scope: St) -> ProjectUpdatePolicyCall<'a, S>
4964 where St: AsRef<str> {
4965 self._scopes.insert(String::from(scope.as_ref()));
4966 self
4967 }
4968 /// Identifies the authorization scope(s) for the method you are building.
4969 ///
4970 /// See [`Self::add_scope()`] for details.
4971 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectUpdatePolicyCall<'a, S>
4972 where I: IntoIterator<Item = St>,
4973 St: AsRef<str> {
4974 self._scopes
4975 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4976 self
4977 }
4978
4979 /// Removes all scopes, and no default scope will be used either.
4980 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4981 /// for details).
4982 pub fn clear_scopes(mut self) -> ProjectUpdatePolicyCall<'a, S> {
4983 self._scopes.clear();
4984 self
4985 }
4986}
4987
4988
4989/// Gets the current system policy in the specified location.
4990///
4991/// A builder for the *getPolicy* method supported by a *systempolicy* resource.
4992/// It is not used directly, but through a [`SystempolicyMethods`] instance.
4993///
4994/// # Example
4995///
4996/// Instantiate a resource method builder
4997///
4998/// ```test_harness,no_run
4999/// # extern crate hyper;
5000/// # extern crate hyper_rustls;
5001/// # extern crate google_binaryauthorization1 as binaryauthorization1;
5002/// # async fn dox() {
5003/// # use std::default::Default;
5004/// # use binaryauthorization1::{BinaryAuthorization, oauth2, hyper, hyper_rustls, chrono, FieldMask};
5005///
5006/// # let secret: oauth2::ApplicationSecret = Default::default();
5007/// # let auth = oauth2::InstalledFlowAuthenticator::builder(
5008/// # secret,
5009/// # oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5010/// # ).build().await.unwrap();
5011/// # let mut hub = BinaryAuthorization::new(hyper::Client::builder().build(hyper_rustls::HttpsConnectorBuilder::new().with_native_roots().https_or_http().enable_http1().build()), auth);
5012/// // You can configure optional parameters by calling the respective setters at will, and
5013/// // execute the final call using `doit()`.
5014/// // Values shown here are possibly random and not representative !
5015/// let result = hub.systempolicy().get_policy("name")
5016/// .doit().await;
5017/// # }
5018/// ```
5019pub struct SystempolicyGetPolicyCall<'a, S>
5020 where S: 'a {
5021
5022 hub: &'a BinaryAuthorization<S>,
5023 _name: String,
5024 _delegate: Option<&'a mut dyn client::Delegate>,
5025 _additional_params: HashMap<String, String>,
5026 _scopes: BTreeSet<String>
5027}
5028
5029impl<'a, S> client::CallBuilder for SystempolicyGetPolicyCall<'a, S> {}
5030
5031impl<'a, S> SystempolicyGetPolicyCall<'a, S>
5032where
5033 S: tower_service::Service<http::Uri> + Clone + Send + Sync + 'static,
5034 S::Response: hyper::client::connect::Connection + AsyncRead + AsyncWrite + Send + Unpin + 'static,
5035 S::Future: Send + Unpin + 'static,
5036 S::Error: Into<Box<dyn StdError + Send + Sync>>,
5037{
5038
5039
5040 /// Perform the operation you have build so far.
5041 pub async fn doit(mut self) -> client::Result<(hyper::Response<hyper::body::Body>, Policy)> {
5042 use std::io::{Read, Seek};
5043 use hyper::header::{CONTENT_TYPE, CONTENT_LENGTH, AUTHORIZATION, USER_AGENT, LOCATION};
5044 use client::{ToParts, url::Params};
5045 use std::borrow::Cow;
5046
5047 let mut dd = client::DefaultDelegate;
5048 let mut dlg: &mut dyn client::Delegate = self._delegate.unwrap_or(&mut dd);
5049 dlg.begin(client::MethodInfo { id: "binaryauthorization.systempolicy.getPolicy",
5050 http_method: hyper::Method::GET });
5051
5052 for &field in ["alt", "name"].iter() {
5053 if self._additional_params.contains_key(field) {
5054 dlg.finished(false);
5055 return Err(client::Error::FieldClash(field));
5056 }
5057 }
5058
5059 let mut params = Params::with_capacity(3 + self._additional_params.len());
5060 params.push("name", self._name);
5061
5062 params.extend(self._additional_params.iter());
5063
5064 params.push("alt", "json");
5065 let mut url = self.hub._base_url.clone() + "v1/{+name}";
5066 if self._scopes.is_empty() {
5067 self._scopes.insert(Scope::CloudPlatform.as_ref().to_string());
5068 }
5069
5070 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5071 url = params.uri_replacement(url, param_name, find_this, true);
5072 }
5073 {
5074 let to_remove = ["name"];
5075 params.remove_params(&to_remove);
5076 }
5077
5078 let url = params.parse_with_url(&url);
5079
5080
5081
5082 loop {
5083 let token = match self.hub.auth.get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..]).await {
5084 Ok(token) => token,
5085 Err(e) => {
5086 match dlg.token(e) {
5087 Ok(token) => token,
5088 Err(e) => {
5089 dlg.finished(false);
5090 return Err(client::Error::MissingToken(e));
5091 }
5092 }
5093 }
5094 };
5095 let mut req_result = {
5096 let client = &self.hub.client;
5097 dlg.pre_request();
5098 let mut req_builder = hyper::Request::builder()
5099 .method(hyper::Method::GET)
5100 .uri(url.as_str())
5101 .header(USER_AGENT, self.hub._user_agent.clone());
5102
5103 if let Some(token) = token.as_ref() {
5104 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5105 }
5106
5107
5108 let request = req_builder
5109 .body(hyper::body::Body::empty());
5110
5111 client.request(request.unwrap()).await
5112
5113 };
5114
5115 match req_result {
5116 Err(err) => {
5117 if let client::Retry::After(d) = dlg.http_error(&err) {
5118 sleep(d).await;
5119 continue;
5120 }
5121 dlg.finished(false);
5122 return Err(client::Error::HttpError(err))
5123 }
5124 Ok(mut res) => {
5125 if !res.status().is_success() {
5126 let res_body_string = client::get_body_as_string(res.body_mut()).await;
5127 let (parts, _) = res.into_parts();
5128 let body = hyper::Body::from(res_body_string.clone());
5129 let restored_response = hyper::Response::from_parts(parts, body);
5130
5131 let server_response = json::from_str::<serde_json::Value>(&res_body_string).ok();
5132
5133 if let client::Retry::After(d) = dlg.http_failure(&restored_response, server_response.clone()) {
5134 sleep(d).await;
5135 continue;
5136 }
5137
5138 dlg.finished(false);
5139
5140 return match server_response {
5141 Some(error_value) => Err(client::Error::BadRequest(error_value)),
5142 None => Err(client::Error::Failure(restored_response)),
5143 }
5144 }
5145 let result_value = {
5146 let res_body_string = client::get_body_as_string(res.body_mut()).await;
5147
5148 match json::from_str(&res_body_string) {
5149 Ok(decoded) => (res, decoded),
5150 Err(err) => {
5151 dlg.response_json_decode_error(&res_body_string, &err);
5152 return Err(client::Error::JsonDecodeError(res_body_string, err));
5153 }
5154 }
5155 };
5156
5157 dlg.finished(true);
5158 return Ok(result_value)
5159 }
5160 }
5161 }
5162 }
5163
5164
5165 /// Required. The resource name, in the format `locations/*/policy`. Note that the system policy is not associated with a project.
5166 ///
5167 /// Sets the *name* path property to the given value.
5168 ///
5169 /// Even though the property as already been set when instantiating this call,
5170 /// we provide this method for API completeness.
5171 pub fn name(mut self, new_value: &str) -> SystempolicyGetPolicyCall<'a, S> {
5172 self._name = new_value.to_string();
5173 self
5174 }
5175 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5176 /// while executing the actual API request.
5177 ///
5178 /// ````text
5179 /// It should be used to handle progress information, and to implement a certain level of resilience.
5180 /// ````
5181 ///
5182 /// Sets the *delegate* property to the given value.
5183 pub fn delegate(mut self, new_value: &'a mut dyn client::Delegate) -> SystempolicyGetPolicyCall<'a, S> {
5184 self._delegate = Some(new_value);
5185 self
5186 }
5187
5188 /// Set any additional parameter of the query string used in the request.
5189 /// It should be used to set parameters which are not yet available through their own
5190 /// setters.
5191 ///
5192 /// Please note that this method must not be used to set any of the known parameters
5193 /// which have their own setter method. If done anyway, the request will fail.
5194 ///
5195 /// # Additional Parameters
5196 ///
5197 /// * *$.xgafv* (query-string) - V1 error format.
5198 /// * *access_token* (query-string) - OAuth access token.
5199 /// * *alt* (query-string) - Data format for response.
5200 /// * *callback* (query-string) - JSONP
5201 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5202 /// * *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.
5203 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5204 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5205 /// * *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.
5206 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5207 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5208 pub fn param<T>(mut self, name: T, value: T) -> SystempolicyGetPolicyCall<'a, S>
5209 where T: AsRef<str> {
5210 self._additional_params.insert(name.as_ref().to_string(), value.as_ref().to_string());
5211 self
5212 }
5213
5214 /// Identifies the authorization scope for the method you are building.
5215 ///
5216 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5217 /// [`Scope::CloudPlatform`].
5218 ///
5219 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5220 /// tokens for more than one scope.
5221 ///
5222 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5223 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5224 /// sufficient, a read-write scope will do as well.
5225 pub fn add_scope<St>(mut self, scope: St) -> SystempolicyGetPolicyCall<'a, S>
5226 where St: AsRef<str> {
5227 self._scopes.insert(String::from(scope.as_ref()));
5228 self
5229 }
5230 /// Identifies the authorization scope(s) for the method you are building.
5231 ///
5232 /// See [`Self::add_scope()`] for details.
5233 pub fn add_scopes<I, St>(mut self, scopes: I) -> SystempolicyGetPolicyCall<'a, S>
5234 where I: IntoIterator<Item = St>,
5235 St: AsRef<str> {
5236 self._scopes
5237 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5238 self
5239 }
5240
5241 /// Removes all scopes, and no default scope will be used either.
5242 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5243 /// for details).
5244 pub fn clear_scopes(mut self) -> SystempolicyGetPolicyCall<'a, S> {
5245 self._scopes.clear();
5246 self
5247 }
5248}
5249
5250