google_bigqueryreservation1/api.rs
1#![allow(clippy::ptr_arg)]
2
3use std::collections::{BTreeSet, HashMap};
4
5use tokio::time::sleep;
6
7// ##############
8// UTILITIES ###
9// ############
10
11/// Identifies the an OAuth2 authorization scope.
12/// A scope is needed when requesting an
13/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
14#[derive(PartialEq, Eq, Ord, PartialOrd, Hash, Debug, Clone, Copy)]
15pub enum Scope {
16 /// View and manage your data in Google BigQuery and see the email address for your Google Account
17 Bigquery,
18
19 /// See, edit, configure, and delete your Google Cloud data and see the email address for your Google Account.
20 CloudPlatform,
21}
22
23impl AsRef<str> for Scope {
24 fn as_ref(&self) -> &str {
25 match *self {
26 Scope::Bigquery => "https://www.googleapis.com/auth/bigquery",
27 Scope::CloudPlatform => "https://www.googleapis.com/auth/cloud-platform",
28 }
29 }
30}
31
32#[allow(clippy::derivable_impls)]
33impl Default for Scope {
34 fn default() -> Scope {
35 Scope::Bigquery
36 }
37}
38
39// ########
40// HUB ###
41// ######
42
43/// Central instance to access all BigQueryReservation related resource activities
44///
45/// # Examples
46///
47/// Instantiate a new hub
48///
49/// ```test_harness,no_run
50/// extern crate hyper;
51/// extern crate hyper_rustls;
52/// extern crate google_bigqueryreservation1 as bigqueryreservation1;
53/// use bigqueryreservation1::api::Reservation;
54/// use bigqueryreservation1::{Result, Error};
55/// # async fn dox() {
56/// use bigqueryreservation1::{BigQueryReservation, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
57///
58/// // Get an ApplicationSecret instance by some means. It contains the `client_id` and
59/// // `client_secret`, among other things.
60/// let secret: yup_oauth2::ApplicationSecret = Default::default();
61/// // Instantiate the authenticator. It will choose a suitable authentication flow for you,
62/// // unless you replace `None` with the desired Flow.
63/// // Provide your own `AuthenticatorDelegate` to adjust the way it operates and get feedback about
64/// // what's going on. You probably want to bring in your own `TokenStorage` to persist tokens and
65/// // retrieve them from storage.
66/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
67/// .with_native_roots()
68/// .unwrap()
69/// .https_only()
70/// .enable_http2()
71/// .build();
72///
73/// let executor = hyper_util::rt::TokioExecutor::new();
74/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
75/// secret,
76/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
77/// yup_oauth2::client::CustomHyperClientBuilder::from(
78/// hyper_util::client::legacy::Client::builder(executor).build(connector),
79/// ),
80/// ).build().await.unwrap();
81///
82/// let client = hyper_util::client::legacy::Client::builder(
83/// hyper_util::rt::TokioExecutor::new()
84/// )
85/// .build(
86/// hyper_rustls::HttpsConnectorBuilder::new()
87/// .with_native_roots()
88/// .unwrap()
89/// .https_or_http()
90/// .enable_http2()
91/// .build()
92/// );
93/// let mut hub = BigQueryReservation::new(client, auth);
94/// // As the method needs a request, you would usually fill it with the desired information
95/// // into the respective structure. Some of the parts shown here might not be applicable !
96/// // Values shown here are possibly random and not representative !
97/// let mut req = Reservation::default();
98///
99/// // You can configure optional parameters by calling the respective setters at will, and
100/// // execute the final call using `doit()`.
101/// // Values shown here are possibly random and not representative !
102/// let result = hub.projects().locations_reservations_create(req, "parent")
103/// .reservation_id("At")
104/// .doit().await;
105///
106/// match result {
107/// Err(e) => match e {
108/// // The Error enum provides details about what exactly happened.
109/// // You can also just use its `Debug`, `Display` or `Error` traits
110/// Error::HttpError(_)
111/// |Error::Io(_)
112/// |Error::MissingAPIKey
113/// |Error::MissingToken(_)
114/// |Error::Cancelled
115/// |Error::UploadSizeLimitExceeded(_, _)
116/// |Error::Failure(_)
117/// |Error::BadRequest(_)
118/// |Error::FieldClash(_)
119/// |Error::JsonDecodeError(_, _) => println!("{}", e),
120/// },
121/// Ok(res) => println!("Success: {:?}", res),
122/// }
123/// # }
124/// ```
125#[derive(Clone)]
126pub struct BigQueryReservation<C> {
127 pub client: common::Client<C>,
128 pub auth: Box<dyn common::GetToken>,
129 _user_agent: String,
130 _base_url: String,
131 _root_url: String,
132}
133
134impl<C> common::Hub for BigQueryReservation<C> {}
135
136impl<'a, C> BigQueryReservation<C> {
137 pub fn new<A: 'static + common::GetToken>(
138 client: common::Client<C>,
139 auth: A,
140 ) -> BigQueryReservation<C> {
141 BigQueryReservation {
142 client,
143 auth: Box::new(auth),
144 _user_agent: "google-api-rust-client/7.0.0".to_string(),
145 _base_url: "https://bigqueryreservation.googleapis.com/".to_string(),
146 _root_url: "https://bigqueryreservation.googleapis.com/".to_string(),
147 }
148 }
149
150 pub fn projects(&'a self) -> ProjectMethods<'a, C> {
151 ProjectMethods { hub: self }
152 }
153
154 /// Set the user-agent header field to use in all requests to the server.
155 /// It defaults to `google-api-rust-client/7.0.0`.
156 ///
157 /// Returns the previously set user-agent.
158 pub fn user_agent(&mut self, agent_name: String) -> String {
159 std::mem::replace(&mut self._user_agent, agent_name)
160 }
161
162 /// Set the base url to use in all requests to the server.
163 /// It defaults to `https://bigqueryreservation.googleapis.com/`.
164 ///
165 /// Returns the previously set base url.
166 pub fn base_url(&mut self, new_base_url: String) -> String {
167 std::mem::replace(&mut self._base_url, new_base_url)
168 }
169
170 /// Set the root url to use in all requests to the server.
171 /// It defaults to `https://bigqueryreservation.googleapis.com/`.
172 ///
173 /// Returns the previously set root url.
174 pub fn root_url(&mut self, new_root_url: String) -> String {
175 std::mem::replace(&mut self._root_url, new_root_url)
176 }
177}
178
179// ############
180// SCHEMAS ###
181// ##########
182/// An assignment allows a project to submit jobs of a certain type using slots from the specified reservation.
183///
184/// # Activities
185///
186/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
187/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
188///
189/// * [locations reservations assignments create projects](ProjectLocationReservationAssignmentCreateCall) (request|response)
190/// * [locations reservations assignments move projects](ProjectLocationReservationAssignmentMoveCall) (response)
191/// * [locations reservations assignments patch projects](ProjectLocationReservationAssignmentPatchCall) (request|response)
192#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
193#[serde_with::serde_as]
194#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
195pub struct Assignment {
196 /// Optional. The resource which will use the reservation. E.g. `projects/myproject`, `folders/123`, or `organizations/456`.
197 pub assignee: Option<String>,
198 /// Optional. This field controls if "Gemini in BigQuery" (https://cloud.google.com/gemini/docs/bigquery/overview) features should be enabled for this reservation assignment, which is not on by default. "Gemini in BigQuery" has a distinct compliance posture from BigQuery. If this field is set to true, the assignment job type is QUERY, and the parent reservation edition is ENTERPRISE_PLUS, then the assignment will give the grantee project/organization access to "Gemini in BigQuery" features.
199 #[serde(rename = "enableGeminiInBigquery")]
200 pub enable_gemini_in_bigquery: Option<bool>,
201 /// Optional. Which type of jobs will use the reservation.
202 #[serde(rename = "jobType")]
203 pub job_type: Option<String>,
204 /// Output only. Name of the resource. E.g.: `projects/myproject/locations/US/reservations/team1-prod/assignments/123`. The assignment_id must only contain lower case alphanumeric characters or dashes and the max length is 64 characters.
205 pub name: Option<String>,
206 /// Optional. The scheduling policy to use for jobs and queries of this assignee when running under the associated reservation. The scheduling policy controls how the reservation's resources are distributed. This overrides the default scheduling policy specified on the reservation. This feature is not yet generally available.
207 #[serde(rename = "schedulingPolicy")]
208 pub scheduling_policy: Option<SchedulingPolicy>,
209 /// Output only. State of the assignment.
210 pub state: Option<String>,
211}
212
213impl common::RequestValue for Assignment {}
214impl common::ResponseResult for Assignment {}
215
216/// Specifies the audit configuration for a service. The configuration determines which permission types are logged, and what identities, if any, are exempted from logging. An AuditConfig must have one or more AuditLogConfigs. If there are AuditConfigs for both `allServices` and a specific service, the union of the two AuditConfigs is used for that service: the log_types specified in each AuditConfig are enabled, and the exempted_members in each AuditLogConfig are exempted. Example Policy with multiple AuditConfigs: { "audit_configs": [ { "service": "allServices", "audit_log_configs": [ { "log_type": "DATA_READ", "exempted_members": [ "user:jose@example.com" ] }, { "log_type": "DATA_WRITE" }, { "log_type": "ADMIN_READ" } ] }, { "service": "sampleservice.googleapis.com", "audit_log_configs": [ { "log_type": "DATA_READ" }, { "log_type": "DATA_WRITE", "exempted_members": [ "user:aliya@example.com" ] } ] } ] } For sampleservice, this policy enables DATA_READ, DATA_WRITE and ADMIN_READ logging. It also exempts `jose@example.com` from DATA_READ logging, and `aliya@example.com` from DATA_WRITE logging.
217///
218/// This type is not used in any activity, and only used as *part* of another schema.
219///
220#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
221#[serde_with::serde_as]
222#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
223pub struct AuditConfig {
224 /// The configuration for logging of each type of permission.
225 #[serde(rename = "auditLogConfigs")]
226 pub audit_log_configs: Option<Vec<AuditLogConfig>>,
227 /// Specifies a service that will be enabled for audit logging. For example, `storage.googleapis.com`, `cloudsql.googleapis.com`. `allServices` is a special value that covers all services.
228 pub service: Option<String>,
229}
230
231impl common::Part for AuditConfig {}
232
233/// Provides the configuration for logging a type of permissions. Example: { "audit_log_configs": [ { "log_type": "DATA_READ", "exempted_members": [ "user:jose@example.com" ] }, { "log_type": "DATA_WRITE" } ] } This enables 'DATA_READ' and 'DATA_WRITE' logging, while exempting jose@example.com from DATA_READ logging.
234///
235/// This type is not used in any activity, and only used as *part* of another schema.
236///
237#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
238#[serde_with::serde_as]
239#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
240pub struct AuditLogConfig {
241 /// Specifies the identities that do not cause logging for this type of permission. Follows the same format of Binding.members.
242 #[serde(rename = "exemptedMembers")]
243 pub exempted_members: Option<Vec<String>>,
244 /// The log type that this config enables.
245 #[serde(rename = "logType")]
246 pub log_type: Option<String>,
247}
248
249impl common::Part for AuditLogConfig {}
250
251/// Auto scaling settings.
252///
253/// This type is not used in any activity, and only used as *part* of another schema.
254///
255#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
256#[serde_with::serde_as]
257#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
258pub struct Autoscale {
259 /// Output only. The slot capacity added to this reservation when autoscale happens. Will be between [0, max_slots]. Note: after users reduce max_slots, it may take a while before it can be propagated, so current_slots may stay in the original value and could be larger than max_slots for that brief period (less than one minute)
260 #[serde(rename = "currentSlots")]
261 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
262 pub current_slots: Option<i64>,
263 /// Optional. Number of slots to be scaled when needed.
264 #[serde(rename = "maxSlots")]
265 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
266 pub max_slots: Option<i64>,
267}
268
269impl common::Part for Autoscale {}
270
271/// Represents a BI Reservation.
272///
273/// # Activities
274///
275/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
276/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
277///
278/// * [locations get bi reservation projects](ProjectLocationGetBiReservationCall) (response)
279/// * [locations update bi reservation projects](ProjectLocationUpdateBiReservationCall) (request|response)
280#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
281#[serde_with::serde_as]
282#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
283pub struct BiReservation {
284 /// Identifier. The resource name of the singleton BI reservation. Reservation names have the form `projects/{project_id}/locations/{location_id}/biReservation`.
285 pub name: Option<String>,
286 /// Optional. Preferred tables to use BI capacity for.
287 #[serde(rename = "preferredTables")]
288 pub preferred_tables: Option<Vec<TableReference>>,
289 /// Optional. Size of a reservation, in bytes.
290 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
291 pub size: Option<i64>,
292 /// Output only. The last update timestamp of a reservation.
293 #[serde(rename = "updateTime")]
294 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
295}
296
297impl common::RequestValue for BiReservation {}
298impl common::ResponseResult for BiReservation {}
299
300/// Associates `members`, or principals, with a `role`.
301///
302/// This type is not used in any activity, and only used as *part* of another schema.
303///
304#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
305#[serde_with::serde_as]
306#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
307pub struct Binding {
308 /// 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).
309 pub condition: Option<Expr>,
310 /// Specifies the principals requesting access for a Google Cloud resource. `members` can have the following values: * `allUsers`: A special identifier that represents anyone who is on the internet; with or without a Google account. * `allAuthenticatedUsers`: A special identifier that represents anyone who is authenticated with a Google account or a service account. Does not include identities that come from external identity providers (IdPs) through identity federation. * `user:{emailid}`: An email address that represents a specific Google account. For example, `alice@example.com` . * `serviceAccount:{emailid}`: An email address that represents a Google service account. For example, `my-other-app@appspot.gserviceaccount.com`. * `serviceAccount:{projectid}.svc.id.goog[{namespace}/{kubernetes-sa}]`: An identifier for a [Kubernetes service account](https://cloud.google.com/kubernetes-engine/docs/how-to/kubernetes-service-accounts). For example, `my-project.svc.id.goog[my-namespace/my-kubernetes-sa]`. * `group:{emailid}`: An email address that represents a Google group. For example, `admins@example.com`. * `domain:{domain}`: The G Suite domain (primary) that represents all the users of that domain. For example, `google.com` or `example.com`. * `principal://iam.googleapis.com/locations/global/workforcePools/{pool_id}/subject/{subject_attribute_value}`: A single identity in a workforce identity pool. * `principalSet://iam.googleapis.com/locations/global/workforcePools/{pool_id}/group/{group_id}`: All workforce identities in a group. * `principalSet://iam.googleapis.com/locations/global/workforcePools/{pool_id}/attribute.{attribute_name}/{attribute_value}`: All workforce identities with a specific attribute value. * `principalSet://iam.googleapis.com/locations/global/workforcePools/{pool_id}/*`: All identities in a workforce identity pool. * `principal://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/subject/{subject_attribute_value}`: A single identity in a workload identity pool. * `principalSet://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/group/{group_id}`: A workload identity pool group. * `principalSet://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/attribute.{attribute_name}/{attribute_value}`: All identities in a workload identity pool with a certain attribute. * `principalSet://iam.googleapis.com/projects/{project_number}/locations/global/workloadIdentityPools/{pool_id}/*`: All identities in a workload identity pool. * `deleted:user:{emailid}?uid={uniqueid}`: An email address (plus unique identifier) representing a user that has been recently deleted. For example, `alice@example.com?uid=123456789012345678901`. If the user is recovered, this value reverts to `user:{emailid}` and the recovered user retains the role in the binding. * `deleted:serviceAccount:{emailid}?uid={uniqueid}`: An email address (plus unique identifier) representing a service account that has been recently deleted. For example, `my-other-app@appspot.gserviceaccount.com?uid=123456789012345678901`. If the service account is undeleted, this value reverts to `serviceAccount:{emailid}` and the undeleted service account retains the role in the binding. * `deleted:group:{emailid}?uid={uniqueid}`: An email address (plus unique identifier) representing a Google group that has been recently deleted. For example, `admins@example.com?uid=123456789012345678901`. If the group is recovered, this value reverts to `group:{emailid}` and the recovered group retains the role in the binding. * `deleted:principal://iam.googleapis.com/locations/global/workforcePools/{pool_id}/subject/{subject_attribute_value}`: Deleted single identity in a workforce identity pool. For example, `deleted:principal://iam.googleapis.com/locations/global/workforcePools/my-pool-id/subject/my-subject-attribute-value`.
311 pub members: Option<Vec<String>>,
312 /// Role that is assigned to the list of `members`, or principals. For example, `roles/viewer`, `roles/editor`, or `roles/owner`. For an overview of the IAM roles and permissions, see the [IAM documentation](https://cloud.google.com/iam/docs/roles-overview). For a list of the available pre-defined roles, see [here](https://cloud.google.com/iam/docs/understanding-roles).
313 pub role: Option<String>,
314}
315
316impl common::Part for Binding {}
317
318/// Capacity commitment is a way to purchase compute capacity for BigQuery jobs (in the form of slots) with some committed period of usage. Annual commitments renew by default. Commitments can be removed after their commitment end time passes. In order to remove annual commitment, its plan needs to be changed to monthly or flex first. A capacity commitment resource exists as a child resource of the admin project.
319///
320/// # Activities
321///
322/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
323/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
324///
325/// * [locations capacity commitments create projects](ProjectLocationCapacityCommitmentCreateCall) (request|response)
326/// * [locations capacity commitments get projects](ProjectLocationCapacityCommitmentGetCall) (response)
327/// * [locations capacity commitments merge projects](ProjectLocationCapacityCommitmentMergeCall) (response)
328/// * [locations capacity commitments patch projects](ProjectLocationCapacityCommitmentPatchCall) (request|response)
329#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
330#[serde_with::serde_as]
331#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
332pub struct CapacityCommitment {
333 /// Output only. The end of the current commitment period. It is applicable only for ACTIVE capacity commitments. Note after renewal, commitment_end_time is the time the renewed commitment expires. So itwould be at a time after commitment_start_time + committed period, because we don't change commitment_start_time ,
334 #[serde(rename = "commitmentEndTime")]
335 pub commitment_end_time: Option<chrono::DateTime<chrono::offset::Utc>>,
336 /// Output only. The start of the current commitment period. It is applicable only for ACTIVE capacity commitments. Note after the commitment is renewed, commitment_start_time won't be changed. It refers to the start time of the original commitment.
337 #[serde(rename = "commitmentStartTime")]
338 pub commitment_start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
339 /// Optional. Edition of the capacity commitment.
340 pub edition: Option<String>,
341 /// Output only. For FAILED commitment plan, provides the reason of failure.
342 #[serde(rename = "failureStatus")]
343 pub failure_status: Option<Status>,
344 /// Output only. If true, the commitment is a flat-rate commitment, otherwise, it's an edition commitment.
345 #[serde(rename = "isFlatRate")]
346 pub is_flat_rate: Option<bool>,
347 /// Applicable only for commitments located within one of the BigQuery multi-regions (US or EU). If set to true, this commitment is placed in the organization's secondary region which is designated for disaster recovery purposes. If false, this commitment is placed in the organization's default region. NOTE: this is a preview feature. Project must be allow-listed in order to set this field.
348 #[serde(rename = "multiRegionAuxiliary")]
349 pub multi_region_auxiliary: Option<bool>,
350 /// Output only. The resource name of the capacity commitment, e.g., `projects/myproject/locations/US/capacityCommitments/123` The commitment_id must only contain lower case alphanumeric characters or dashes. It must start with a letter and must not end with a dash. Its maximum length is 64 characters.
351 pub name: Option<String>,
352 /// Optional. Capacity commitment commitment plan.
353 pub plan: Option<String>,
354 /// Optional. The plan this capacity commitment is converted to after commitment_end_time passes. Once the plan is changed, committed period is extended according to commitment plan. Only applicable for ANNUAL and TRIAL commitments.
355 #[serde(rename = "renewalPlan")]
356 pub renewal_plan: Option<String>,
357 /// Optional. Number of slots in this commitment.
358 #[serde(rename = "slotCount")]
359 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
360 pub slot_count: Option<i64>,
361 /// Output only. State of the commitment.
362 pub state: Option<String>,
363}
364
365impl common::RequestValue for CapacityCommitment {}
366impl common::ResponseResult for CapacityCommitment {}
367
368/// 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); }
369///
370/// # Activities
371///
372/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
373/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
374///
375/// * [locations capacity commitments delete projects](ProjectLocationCapacityCommitmentDeleteCall) (response)
376/// * [locations reservation groups delete projects](ProjectLocationReservationGroupDeleteCall) (response)
377/// * [locations reservations assignments delete projects](ProjectLocationReservationAssignmentDeleteCall) (response)
378/// * [locations reservations delete projects](ProjectLocationReservationDeleteCall) (response)
379#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
380#[serde_with::serde_as]
381#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
382pub struct Empty {
383 _never_set: Option<bool>,
384}
385
386impl common::ResponseResult for Empty {}
387
388/// 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.
389///
390/// This type is not used in any activity, and only used as *part* of another schema.
391///
392#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
393#[serde_with::serde_as]
394#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
395pub struct Expr {
396 /// Optional. Description of the expression. This is a longer text which describes the expression, e.g. when hovered over it in a UI.
397 pub description: Option<String>,
398 /// Textual representation of an expression in Common Expression Language syntax.
399 pub expression: Option<String>,
400 /// Optional. String indicating the location of the expression for error reporting, e.g. a file name and a position in the file.
401 pub location: Option<String>,
402 /// 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.
403 pub title: Option<String>,
404}
405
406impl common::Part for Expr {}
407
408/// The request for ReservationService.FailoverReservation.
409///
410/// # Activities
411///
412/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
413/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
414///
415/// * [locations reservations failover reservation projects](ProjectLocationReservationFailoverReservationCall) (request)
416#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
417#[serde_with::serde_as]
418#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
419pub struct FailoverReservationRequest {
420 /// Optional. A parameter that determines how writes that are pending replication are handled after a failover is initiated. If not specified, HARD failover mode is used by default.
421 #[serde(rename = "failoverMode")]
422 pub failover_mode: Option<String>,
423}
424
425impl common::RequestValue for FailoverReservationRequest {}
426
427/// The response for ReservationService.ListAssignments.
428///
429/// # Activities
430///
431/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
432/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
433///
434/// * [locations reservations assignments list projects](ProjectLocationReservationAssignmentListCall) (response)
435#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
436#[serde_with::serde_as]
437#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
438pub struct ListAssignmentsResponse {
439 /// List of assignments visible to the user.
440 pub assignments: Option<Vec<Assignment>>,
441 /// Token to retrieve the next page of results, or empty if there are no more results in the list.
442 #[serde(rename = "nextPageToken")]
443 pub next_page_token: Option<String>,
444}
445
446impl common::ResponseResult for ListAssignmentsResponse {}
447
448/// The response for ReservationService.ListCapacityCommitments.
449///
450/// # Activities
451///
452/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
453/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
454///
455/// * [locations capacity commitments list projects](ProjectLocationCapacityCommitmentListCall) (response)
456#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
457#[serde_with::serde_as]
458#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
459pub struct ListCapacityCommitmentsResponse {
460 /// List of capacity commitments visible to the user.
461 #[serde(rename = "capacityCommitments")]
462 pub capacity_commitments: Option<Vec<CapacityCommitment>>,
463 /// Token to retrieve the next page of results, or empty if there are no more results in the list.
464 #[serde(rename = "nextPageToken")]
465 pub next_page_token: Option<String>,
466}
467
468impl common::ResponseResult for ListCapacityCommitmentsResponse {}
469
470/// The response for ReservationService.ListReservationGroups.
471///
472/// # Activities
473///
474/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
475/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
476///
477/// * [locations reservation groups list projects](ProjectLocationReservationGroupListCall) (response)
478#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
479#[serde_with::serde_as]
480#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
481pub struct ListReservationGroupsResponse {
482 /// Token to retrieve the next page of results, or empty if there are no more results in the list.
483 #[serde(rename = "nextPageToken")]
484 pub next_page_token: Option<String>,
485 /// List of reservations visible to the user.
486 #[serde(rename = "reservationGroups")]
487 pub reservation_groups: Option<Vec<ReservationGroup>>,
488}
489
490impl common::ResponseResult for ListReservationGroupsResponse {}
491
492/// The response for ReservationService.ListReservations.
493///
494/// # Activities
495///
496/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
497/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
498///
499/// * [locations reservations list projects](ProjectLocationReservationListCall) (response)
500#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
501#[serde_with::serde_as]
502#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
503pub struct ListReservationsResponse {
504 /// Token to retrieve the next page of results, or empty if there are no more results in the list.
505 #[serde(rename = "nextPageToken")]
506 pub next_page_token: Option<String>,
507 /// List of reservations visible to the user.
508 pub reservations: Option<Vec<Reservation>>,
509}
510
511impl common::ResponseResult for ListReservationsResponse {}
512
513/// The request for ReservationService.MergeCapacityCommitments.
514///
515/// # Activities
516///
517/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
518/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
519///
520/// * [locations capacity commitments merge projects](ProjectLocationCapacityCommitmentMergeCall) (request)
521#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
522#[serde_with::serde_as]
523#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
524pub struct MergeCapacityCommitmentsRequest {
525 /// Optional. The optional resulting capacity commitment ID. Capacity commitment name will be generated automatically if this field is empty. This field must only contain lower case alphanumeric characters or dashes. The first and last character cannot be a dash. Max length is 64 characters.
526 #[serde(rename = "capacityCommitmentId")]
527 pub capacity_commitment_id: Option<String>,
528 /// Ids of capacity commitments to merge. These capacity commitments must exist under admin project and location specified in the parent. ID is the last portion of capacity commitment name e.g., 'abc' for projects/myproject/locations/US/capacityCommitments/abc
529 #[serde(rename = "capacityCommitmentIds")]
530 pub capacity_commitment_ids: Option<Vec<String>>,
531}
532
533impl common::RequestValue for MergeCapacityCommitmentsRequest {}
534
535/// The request for ReservationService.MoveAssignment. **Note**: “bigquery.reservationAssignments.create” permission is required on the destination_id. **Note**: “bigquery.reservationAssignments.create” and “bigquery.reservationAssignments.delete” permission are required on the related assignee.
536///
537/// # Activities
538///
539/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
540/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
541///
542/// * [locations reservations assignments move projects](ProjectLocationReservationAssignmentMoveCall) (request)
543#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
544#[serde_with::serde_as]
545#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
546pub struct MoveAssignmentRequest {
547 /// The optional assignment ID. A new assignment name is generated if this field is empty. This field can contain only lowercase alphanumeric characters or dashes. Max length is 64 characters.
548 #[serde(rename = "assignmentId")]
549 pub assignment_id: Option<String>,
550 /// The new reservation ID, e.g.: `projects/myotherproject/locations/US/reservations/team2-prod`
551 #[serde(rename = "destinationId")]
552 pub destination_id: Option<String>,
553}
554
555impl common::RequestValue for MoveAssignmentRequest {}
556
557/// 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/).
558///
559/// # Activities
560///
561/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
562/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
563///
564/// * [locations reservations assignments get iam policy projects](ProjectLocationReservationAssignmentGetIamPolicyCall) (response)
565/// * [locations reservations assignments set iam policy projects](ProjectLocationReservationAssignmentSetIamPolicyCall) (response)
566/// * [locations reservations get iam policy projects](ProjectLocationReservationGetIamPolicyCall) (response)
567/// * [locations reservations set iam policy projects](ProjectLocationReservationSetIamPolicyCall) (response)
568#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
569#[serde_with::serde_as]
570#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
571pub struct Policy {
572 /// Specifies cloud audit logging configuration for this policy.
573 #[serde(rename = "auditConfigs")]
574 pub audit_configs: Option<Vec<AuditConfig>>,
575 /// 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`.
576 pub bindings: Option<Vec<Binding>>,
577 /// `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.
578 #[serde_as(as = "Option<common::serde::standard_base64::Wrapper>")]
579 pub etag: Option<Vec<u8>>,
580 /// 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).
581 pub version: Option<i32>,
582}
583
584impl common::ResponseResult for Policy {}
585
586/// Disaster Recovery(DR) replication status of the reservation.
587///
588/// This type is not used in any activity, and only used as *part* of another schema.
589///
590#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
591#[serde_with::serde_as]
592#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
593pub struct ReplicationStatus {
594 /// Output only. The last error encountered while trying to replicate changes from the primary to the secondary. This field is only available if the replication has not succeeded since.
595 pub error: Option<Status>,
596 /// Output only. The time at which the last error was encountered while trying to replicate changes from the primary to the secondary. This field is only available if the replication has not succeeded since.
597 #[serde(rename = "lastErrorTime")]
598 pub last_error_time: Option<chrono::DateTime<chrono::offset::Utc>>,
599 /// Output only. A timestamp corresponding to the last change on the primary that was successfully replicated to the secondary.
600 #[serde(rename = "lastReplicationTime")]
601 pub last_replication_time: Option<chrono::DateTime<chrono::offset::Utc>>,
602 /// Output only. The time at which a soft failover for the reservation and its associated datasets was initiated. After this field is set, all subsequent changes to the reservation will be rejected unless a hard failover overrides this operation. This field will be cleared once the failover is complete.
603 #[serde(rename = "softFailoverStartTime")]
604 pub soft_failover_start_time: Option<chrono::DateTime<chrono::offset::Utc>>,
605}
606
607impl common::Part for ReplicationStatus {}
608
609/// A reservation is a mechanism used to guarantee slots to users.
610///
611/// # Activities
612///
613/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
614/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
615///
616/// * [locations reservations create projects](ProjectLocationReservationCreateCall) (request|response)
617/// * [locations reservations failover reservation projects](ProjectLocationReservationFailoverReservationCall) (response)
618/// * [locations reservations get projects](ProjectLocationReservationGetCall) (response)
619/// * [locations reservations patch projects](ProjectLocationReservationPatchCall) (request|response)
620#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
621#[serde_with::serde_as]
622#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
623pub struct Reservation {
624 /// Optional. The configuration parameters for the auto scaling feature.
625 pub autoscale: Option<Autoscale>,
626 /// Optional. Job concurrency target which sets a soft upper bound on the number of jobs that can run concurrently in this reservation. This is a soft target due to asynchronous nature of the system and various optimizations for small queries. Default value is 0 which means that concurrency target will be automatically computed by the system. NOTE: this field is exposed as target job concurrency in the Information Schema, DDL and BigQuery CLI.
627 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
628 pub concurrency: Option<i64>,
629 /// Output only. Creation time of the reservation.
630 #[serde(rename = "creationTime")]
631 pub creation_time: Option<chrono::DateTime<chrono::offset::Utc>>,
632 /// Optional. Edition of the reservation.
633 pub edition: Option<String>,
634 /// Optional. If false, any query or pipeline job using this reservation will use idle slots from other reservations within the same admin project. If true, a query or pipeline job using this reservation will execute with the slot capacity specified in the slot_capacity field at most.
635 #[serde(rename = "ignoreIdleSlots")]
636 pub ignore_idle_slots: Option<bool>,
637 /// Optional. The labels associated with this reservation. You can use these to organize and group your reservations. You can set this property when you create or update a reservation.
638 pub labels: Option<HashMap<String, String>>,
639 /// Optional. The overall max slots for the reservation, covering slot_capacity (baseline), idle slots (if ignore_idle_slots is false) and scaled slots. If present, the reservation won't use more than the specified number of slots, even if there is demand and supply (from idle slots). NOTE: capping a reservation's idle slot usage is best effort and its usage may exceed the max_slots value. However, in terms of autoscale.current_slots (which accounts for the additional added slots), it will never exceed the max_slots - baseline. This field must be set together with the scaling_mode enum value, otherwise the request will be rejected with error code `google.rpc.Code.INVALID_ARGUMENT`. If the max_slots and scaling_mode are set, the autoscale or autoscale.max_slots field must be unset. Otherwise the request will be rejected with error code `google.rpc.Code.INVALID_ARGUMENT`. However, the autoscale field may still be in the output. The autopscale.max_slots will always show as 0 and the autoscaler.current_slots will represent the current slots from autoscaler excluding idle slots. For example, if the max_slots is 1000 and scaling_mode is AUTOSCALE_ONLY, then in the output, the autoscaler.max_slots will be 0 and the autoscaler.current_slots may be any value between 0 and 1000. If the max_slots is 1000, scaling_mode is ALL_SLOTS, the baseline is 100 and idle slots usage is 200, then in the output, the autoscaler.max_slots will be 0 and the autoscaler.current_slots will not be higher than 700. If the max_slots is 1000, scaling_mode is IDLE_SLOTS_ONLY, then in the output, the autoscaler field will be null. If the max_slots and scaling_mode are set, then the ignore_idle_slots field must be aligned with the scaling_mode enum value.(See details in ScalingMode comments). Otherwise the request will be rejected with error code `google.rpc.Code.INVALID_ARGUMENT`. Please note, the max_slots is for user to manage the part of slots greater than the baseline. Therefore, we don't allow users to set max_slots smaller or equal to the baseline as it will not be meaningful. If the field is present and slot_capacity>=max_slots, requests will be rejected with error code `google.rpc.Code.INVALID_ARGUMENT`. Please note that if max_slots is set to 0, we will treat it as unset. Customers can set max_slots to 0 and set scaling_mode to SCALING_MODE_UNSPECIFIED to disable the max_slots feature.
640 #[serde(rename = "maxSlots")]
641 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
642 pub max_slots: Option<i64>,
643 /// Applicable only for reservations located within one of the BigQuery multi-regions (US or EU). If set to true, this reservation is placed in the organization's secondary region which is designated for disaster recovery purposes. If false, this reservation is placed in the organization's default region. NOTE: this is a preview feature. Project must be allow-listed in order to set this field.
644 #[serde(rename = "multiRegionAuxiliary")]
645 pub multi_region_auxiliary: Option<bool>,
646 /// Identifier. The resource name of the reservation, e.g., `projects/*/locations/*/reservations/team1-prod`. The reservation_id must only contain lower case alphanumeric characters or dashes. It must start with a letter and must not end with a dash. Its maximum length is 64 characters.
647 pub name: Option<String>,
648 /// Output only. The location where the reservation was originally created. This is set only during the failover reservation's creation. All billing charges for the failover reservation will be applied to this location.
649 #[serde(rename = "originalPrimaryLocation")]
650 pub original_primary_location: Option<String>,
651 /// Output only. The current location of the reservation's primary replica. This field is only set for reservations using the managed disaster recovery feature.
652 #[serde(rename = "primaryLocation")]
653 pub primary_location: Option<String>,
654 /// Output only. The Disaster Recovery(DR) replication status of the reservation. This is only available for the primary replicas of DR/failover reservations and provides information about the both the staleness of the secondary and the last error encountered while trying to replicate changes from the primary to the secondary. If this field is blank, it means that the reservation is either not a DR reservation or the reservation is a DR secondary or that any replication operations on the reservation have succeeded.
655 #[serde(rename = "replicationStatus")]
656 pub replication_status: Option<ReplicationStatus>,
657 /// Optional. The reservation group that this reservation belongs to. You can set this property when you create or update a reservation. Reservations do not need to belong to a reservation group. Format: projects/{project}/locations/{location}/reservationGroups/{reservation_group} or just {reservation_group}
658 #[serde(rename = "reservationGroup")]
659 pub reservation_group: Option<String>,
660 /// Optional. The scaling mode for the reservation. If the field is present but max_slots is not present, requests will be rejected with error code `google.rpc.Code.INVALID_ARGUMENT`.
661 #[serde(rename = "scalingMode")]
662 pub scaling_mode: Option<String>,
663 /// Optional. The scheduling policy to use for jobs and queries running under this reservation. The scheduling policy controls how the reservation's resources are distributed. This feature is not yet generally available.
664 #[serde(rename = "schedulingPolicy")]
665 pub scheduling_policy: Option<SchedulingPolicy>,
666 /// Optional. The current location of the reservation's secondary replica. This field is only set for reservations using the managed disaster recovery feature. Users can set this in create reservation calls to create a failover reservation or in update reservation calls to convert a non-failover reservation to a failover reservation(or vice versa).
667 #[serde(rename = "secondaryLocation")]
668 pub secondary_location: Option<String>,
669 /// Optional. Baseline slots available to this reservation. A slot is a unit of computational power in BigQuery, and serves as the unit of parallelism. Queries using this reservation might use more slots during runtime if ignore_idle_slots is set to false, or autoscaling is enabled. The total slot_capacity of the reservation and its siblings may exceed the total slot_count of capacity commitments. In that case, the exceeding slots will be charged with the autoscale SKU. You can increase the number of baseline slots in a reservation every few minutes. If you want to decrease your baseline slots, you are limited to once an hour if you have recently changed your baseline slot capacity and your baseline slots exceed your committed slots. Otherwise, you can decrease your baseline slots every few minutes.
670 #[serde(rename = "slotCapacity")]
671 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
672 pub slot_capacity: Option<i64>,
673 /// Output only. Last update time of the reservation.
674 #[serde(rename = "updateTime")]
675 pub update_time: Option<chrono::DateTime<chrono::offset::Utc>>,
676}
677
678impl common::RequestValue for Reservation {}
679impl common::ResponseResult for Reservation {}
680
681/// A reservation group is a container for reservations.
682///
683/// # Activities
684///
685/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
686/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
687///
688/// * [locations reservation groups create projects](ProjectLocationReservationGroupCreateCall) (request|response)
689/// * [locations reservation groups get projects](ProjectLocationReservationGroupGetCall) (response)
690#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
691#[serde_with::serde_as]
692#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
693pub struct ReservationGroup {
694 /// Identifier. The resource name of the reservation group, e.g., `projects/*/locations/*/reservationGroups/team1-prod`. The reservation_group_id must only contain lower case alphanumeric characters or dashes. It must start with a letter and must not end with a dash. Its maximum length is 64 characters.
695 pub name: Option<String>,
696}
697
698impl common::RequestValue for ReservationGroup {}
699impl common::ResponseResult for ReservationGroup {}
700
701/// The scheduling policy controls how a reservation's resources are distributed.
702///
703/// This type is not used in any activity, and only used as *part* of another schema.
704///
705#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
706#[serde_with::serde_as]
707#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
708pub struct SchedulingPolicy {
709 /// Optional. If present and > 0, the reservation will attempt to limit the concurrency of jobs running for any particular project within it to the given value. This feature is not yet generally available.
710 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
711 pub concurrency: Option<i64>,
712 /// Optional. If present and > 0, the reservation will attempt to limit the slot consumption of queries running for any particular project within it to the given value. This feature is not yet generally available.
713 #[serde(rename = "maxSlots")]
714 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
715 pub max_slots: Option<i64>,
716}
717
718impl common::Part for SchedulingPolicy {}
719
720/// The response for ReservationService.SearchAllAssignments.
721///
722/// # Activities
723///
724/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
725/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
726///
727/// * [locations search all assignments projects](ProjectLocationSearchAllAssignmentCall) (response)
728#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
729#[serde_with::serde_as]
730#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
731pub struct SearchAllAssignmentsResponse {
732 /// List of assignments visible to the user.
733 pub assignments: Option<Vec<Assignment>>,
734 /// Token to retrieve the next page of results, or empty if there are no more results in the list.
735 #[serde(rename = "nextPageToken")]
736 pub next_page_token: Option<String>,
737}
738
739impl common::ResponseResult for SearchAllAssignmentsResponse {}
740
741/// The response for ReservationService.SearchAssignments.
742///
743/// # Activities
744///
745/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
746/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
747///
748/// * [locations search assignments projects](ProjectLocationSearchAssignmentCall) (response)
749#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
750#[serde_with::serde_as]
751#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
752pub struct SearchAssignmentsResponse {
753 /// List of assignments visible to the user.
754 pub assignments: Option<Vec<Assignment>>,
755 /// Token to retrieve the next page of results, or empty if there are no more results in the list.
756 #[serde(rename = "nextPageToken")]
757 pub next_page_token: Option<String>,
758}
759
760impl common::ResponseResult for SearchAssignmentsResponse {}
761
762/// Request message for `SetIamPolicy` method.
763///
764/// # Activities
765///
766/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
767/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
768///
769/// * [locations reservations assignments set iam policy projects](ProjectLocationReservationAssignmentSetIamPolicyCall) (request)
770/// * [locations reservations set iam policy projects](ProjectLocationReservationSetIamPolicyCall) (request)
771#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
772#[serde_with::serde_as]
773#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
774pub struct SetIamPolicyRequest {
775 /// 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.
776 pub policy: Option<Policy>,
777 /// OPTIONAL: A FieldMask specifying which fields of the policy to modify. Only the fields in the mask will be modified. If no mask is provided, the following default mask is used: `paths: "bindings, etag"`
778 #[serde(rename = "updateMask")]
779 pub update_mask: Option<common::FieldMask>,
780}
781
782impl common::RequestValue for SetIamPolicyRequest {}
783
784/// The request for ReservationService.SplitCapacityCommitment.
785///
786/// # Activities
787///
788/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
789/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
790///
791/// * [locations capacity commitments split projects](ProjectLocationCapacityCommitmentSplitCall) (request)
792#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
793#[serde_with::serde_as]
794#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
795pub struct SplitCapacityCommitmentRequest {
796 /// Number of slots in the capacity commitment after the split.
797 #[serde(rename = "slotCount")]
798 #[serde_as(as = "Option<serde_with::DisplayFromStr>")]
799 pub slot_count: Option<i64>,
800}
801
802impl common::RequestValue for SplitCapacityCommitmentRequest {}
803
804/// The response for ReservationService.SplitCapacityCommitment.
805///
806/// # Activities
807///
808/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
809/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
810///
811/// * [locations capacity commitments split projects](ProjectLocationCapacityCommitmentSplitCall) (response)
812#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
813#[serde_with::serde_as]
814#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
815pub struct SplitCapacityCommitmentResponse {
816 /// First capacity commitment, result of a split.
817 pub first: Option<CapacityCommitment>,
818 /// Second capacity commitment, result of a split.
819 pub second: Option<CapacityCommitment>,
820}
821
822impl common::ResponseResult for SplitCapacityCommitmentResponse {}
823
824/// The `Status` type defines a logical error model that is suitable for different programming environments, including REST APIs and RPC APIs. It is used by [gRPC](https://github.com/grpc). Each `Status` message contains three pieces of data: error code, error message, and error details. You can find out more about this error model and how to work with it in the [API Design Guide](https://cloud.google.com/apis/design/errors).
825///
826/// This type is not used in any activity, and only used as *part* of another schema.
827///
828#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
829#[serde_with::serde_as]
830#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
831pub struct Status {
832 /// The status code, which should be an enum value of google.rpc.Code.
833 pub code: Option<i32>,
834 /// A list of messages that carry the error details. There is a common set of message types for APIs to use.
835 pub details: Option<Vec<HashMap<String, serde_json::Value>>>,
836 /// A developer-facing error message, which should be in English. Any user-facing error message should be localized and sent in the google.rpc.Status.details field, or localized by the client.
837 pub message: Option<String>,
838}
839
840impl common::Part for Status {}
841
842/// Fully qualified reference to BigQuery table. Internally stored as google.cloud.bi.v1.BqTableReference.
843///
844/// This type is not used in any activity, and only used as *part* of another schema.
845///
846#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
847#[serde_with::serde_as]
848#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
849pub struct TableReference {
850 /// Optional. The ID of the dataset in the above project.
851 #[serde(rename = "datasetId")]
852 pub dataset_id: Option<String>,
853 /// Optional. The assigned project ID of the project.
854 #[serde(rename = "projectId")]
855 pub project_id: Option<String>,
856 /// Optional. The ID of the table in the above dataset.
857 #[serde(rename = "tableId")]
858 pub table_id: Option<String>,
859}
860
861impl common::Part for TableReference {}
862
863/// Request message for `TestIamPermissions` method.
864///
865/// # Activities
866///
867/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
868/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
869///
870/// * [locations reservations assignments test iam permissions projects](ProjectLocationReservationAssignmentTestIamPermissionCall) (request)
871/// * [locations reservations test iam permissions projects](ProjectLocationReservationTestIamPermissionCall) (request)
872#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
873#[serde_with::serde_as]
874#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
875pub struct TestIamPermissionsRequest {
876 /// 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).
877 pub permissions: Option<Vec<String>>,
878}
879
880impl common::RequestValue for TestIamPermissionsRequest {}
881
882/// Response message for `TestIamPermissions` method.
883///
884/// # Activities
885///
886/// This type is used in activities, which are methods you may call on this type or where this type is involved in.
887/// The list links the activity name, along with information about where it is used (one of *request* and *response*).
888///
889/// * [locations reservations assignments test iam permissions projects](ProjectLocationReservationAssignmentTestIamPermissionCall) (response)
890/// * [locations reservations test iam permissions projects](ProjectLocationReservationTestIamPermissionCall) (response)
891#[cfg_attr(feature = "utoipa", derive(utoipa::ToSchema))]
892#[serde_with::serde_as]
893#[derive(Default, Clone, Debug, serde::Serialize, serde::Deserialize)]
894pub struct TestIamPermissionsResponse {
895 /// A subset of `TestPermissionsRequest.permissions` that the caller is allowed.
896 pub permissions: Option<Vec<String>>,
897}
898
899impl common::ResponseResult for TestIamPermissionsResponse {}
900
901// ###################
902// MethodBuilders ###
903// #################
904
905/// A builder providing access to all methods supported on *project* resources.
906/// It is not used directly, but through the [`BigQueryReservation`] hub.
907///
908/// # Example
909///
910/// Instantiate a resource builder
911///
912/// ```test_harness,no_run
913/// extern crate hyper;
914/// extern crate hyper_rustls;
915/// extern crate google_bigqueryreservation1 as bigqueryreservation1;
916///
917/// # async fn dox() {
918/// use bigqueryreservation1::{BigQueryReservation, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
919///
920/// let secret: yup_oauth2::ApplicationSecret = Default::default();
921/// let connector = hyper_rustls::HttpsConnectorBuilder::new()
922/// .with_native_roots()
923/// .unwrap()
924/// .https_only()
925/// .enable_http2()
926/// .build();
927///
928/// let executor = hyper_util::rt::TokioExecutor::new();
929/// let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
930/// secret,
931/// yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
932/// yup_oauth2::client::CustomHyperClientBuilder::from(
933/// hyper_util::client::legacy::Client::builder(executor).build(connector),
934/// ),
935/// ).build().await.unwrap();
936///
937/// let client = hyper_util::client::legacy::Client::builder(
938/// hyper_util::rt::TokioExecutor::new()
939/// )
940/// .build(
941/// hyper_rustls::HttpsConnectorBuilder::new()
942/// .with_native_roots()
943/// .unwrap()
944/// .https_or_http()
945/// .enable_http2()
946/// .build()
947/// );
948/// let mut hub = BigQueryReservation::new(client, auth);
949/// // Usually you wouldn't bind this to a variable, but keep calling *CallBuilders*
950/// // like `locations_capacity_commitments_create(...)`, `locations_capacity_commitments_delete(...)`, `locations_capacity_commitments_get(...)`, `locations_capacity_commitments_list(...)`, `locations_capacity_commitments_merge(...)`, `locations_capacity_commitments_patch(...)`, `locations_capacity_commitments_split(...)`, `locations_get_bi_reservation(...)`, `locations_reservation_groups_create(...)`, `locations_reservation_groups_delete(...)`, `locations_reservation_groups_get(...)`, `locations_reservation_groups_list(...)`, `locations_reservations_assignments_create(...)`, `locations_reservations_assignments_delete(...)`, `locations_reservations_assignments_get_iam_policy(...)`, `locations_reservations_assignments_list(...)`, `locations_reservations_assignments_move(...)`, `locations_reservations_assignments_patch(...)`, `locations_reservations_assignments_set_iam_policy(...)`, `locations_reservations_assignments_test_iam_permissions(...)`, `locations_reservations_create(...)`, `locations_reservations_delete(...)`, `locations_reservations_failover_reservation(...)`, `locations_reservations_get(...)`, `locations_reservations_get_iam_policy(...)`, `locations_reservations_list(...)`, `locations_reservations_patch(...)`, `locations_reservations_set_iam_policy(...)`, `locations_reservations_test_iam_permissions(...)`, `locations_search_all_assignments(...)`, `locations_search_assignments(...)` and `locations_update_bi_reservation(...)`
951/// // to build up your call.
952/// let rb = hub.projects();
953/// # }
954/// ```
955pub struct ProjectMethods<'a, C>
956where
957 C: 'a,
958{
959 hub: &'a BigQueryReservation<C>,
960}
961
962impl<'a, C> common::MethodsBuilder for ProjectMethods<'a, C> {}
963
964impl<'a, C> ProjectMethods<'a, C> {
965 /// Create a builder to help you perform the following task:
966 ///
967 /// Creates a new capacity commitment resource.
968 ///
969 /// # Arguments
970 ///
971 /// * `request` - No description provided.
972 /// * `parent` - Required. Resource name of the parent reservation. E.g., `projects/myproject/locations/US`
973 pub fn locations_capacity_commitments_create(
974 &self,
975 request: CapacityCommitment,
976 parent: &str,
977 ) -> ProjectLocationCapacityCommitmentCreateCall<'a, C> {
978 ProjectLocationCapacityCommitmentCreateCall {
979 hub: self.hub,
980 _request: request,
981 _parent: parent.to_string(),
982 _enforce_single_admin_project_per_org: Default::default(),
983 _capacity_commitment_id: Default::default(),
984 _delegate: Default::default(),
985 _additional_params: Default::default(),
986 _scopes: Default::default(),
987 }
988 }
989
990 /// Create a builder to help you perform the following task:
991 ///
992 /// Deletes a capacity commitment. Attempting to delete capacity commitment before its commitment_end_time will fail with the error code `google.rpc.Code.FAILED_PRECONDITION`.
993 ///
994 /// # Arguments
995 ///
996 /// * `name` - Required. Resource name of the capacity commitment to delete. E.g., `projects/myproject/locations/US/capacityCommitments/123`
997 pub fn locations_capacity_commitments_delete(
998 &self,
999 name: &str,
1000 ) -> ProjectLocationCapacityCommitmentDeleteCall<'a, C> {
1001 ProjectLocationCapacityCommitmentDeleteCall {
1002 hub: self.hub,
1003 _name: name.to_string(),
1004 _force: Default::default(),
1005 _delegate: Default::default(),
1006 _additional_params: Default::default(),
1007 _scopes: Default::default(),
1008 }
1009 }
1010
1011 /// Create a builder to help you perform the following task:
1012 ///
1013 /// Returns information about the capacity commitment.
1014 ///
1015 /// # Arguments
1016 ///
1017 /// * `name` - Required. Resource name of the capacity commitment to retrieve. E.g., `projects/myproject/locations/US/capacityCommitments/123`
1018 pub fn locations_capacity_commitments_get(
1019 &self,
1020 name: &str,
1021 ) -> ProjectLocationCapacityCommitmentGetCall<'a, C> {
1022 ProjectLocationCapacityCommitmentGetCall {
1023 hub: self.hub,
1024 _name: name.to_string(),
1025 _delegate: Default::default(),
1026 _additional_params: Default::default(),
1027 _scopes: Default::default(),
1028 }
1029 }
1030
1031 /// Create a builder to help you perform the following task:
1032 ///
1033 /// Lists all the capacity commitments for the admin project.
1034 ///
1035 /// # Arguments
1036 ///
1037 /// * `parent` - Required. Resource name of the parent reservation. E.g., `projects/myproject/locations/US`
1038 pub fn locations_capacity_commitments_list(
1039 &self,
1040 parent: &str,
1041 ) -> ProjectLocationCapacityCommitmentListCall<'a, C> {
1042 ProjectLocationCapacityCommitmentListCall {
1043 hub: self.hub,
1044 _parent: parent.to_string(),
1045 _page_token: Default::default(),
1046 _page_size: Default::default(),
1047 _delegate: Default::default(),
1048 _additional_params: Default::default(),
1049 _scopes: Default::default(),
1050 }
1051 }
1052
1053 /// Create a builder to help you perform the following task:
1054 ///
1055 /// Merges capacity commitments of the same plan into a single commitment. The resulting capacity commitment has the greater commitment_end_time out of the to-be-merged capacity commitments. Attempting to merge capacity commitments of different plan will fail with the error code `google.rpc.Code.FAILED_PRECONDITION`.
1056 ///
1057 /// # Arguments
1058 ///
1059 /// * `request` - No description provided.
1060 /// * `parent` - Parent resource that identifies admin project and location e.g., `projects/myproject/locations/us`
1061 pub fn locations_capacity_commitments_merge(
1062 &self,
1063 request: MergeCapacityCommitmentsRequest,
1064 parent: &str,
1065 ) -> ProjectLocationCapacityCommitmentMergeCall<'a, C> {
1066 ProjectLocationCapacityCommitmentMergeCall {
1067 hub: self.hub,
1068 _request: request,
1069 _parent: parent.to_string(),
1070 _delegate: Default::default(),
1071 _additional_params: Default::default(),
1072 _scopes: Default::default(),
1073 }
1074 }
1075
1076 /// Create a builder to help you perform the following task:
1077 ///
1078 /// Updates an existing capacity commitment. Only `plan` and `renewal_plan` fields can be updated. Plan can only be changed to a plan of a longer commitment period. Attempting to change to a plan with shorter commitment period will fail with the error code `google.rpc.Code.FAILED_PRECONDITION`.
1079 ///
1080 /// # Arguments
1081 ///
1082 /// * `request` - No description provided.
1083 /// * `name` - Output only. The resource name of the capacity commitment, e.g., `projects/myproject/locations/US/capacityCommitments/123` The commitment_id must only contain lower case alphanumeric characters or dashes. It must start with a letter and must not end with a dash. Its maximum length is 64 characters.
1084 pub fn locations_capacity_commitments_patch(
1085 &self,
1086 request: CapacityCommitment,
1087 name: &str,
1088 ) -> ProjectLocationCapacityCommitmentPatchCall<'a, C> {
1089 ProjectLocationCapacityCommitmentPatchCall {
1090 hub: self.hub,
1091 _request: request,
1092 _name: name.to_string(),
1093 _update_mask: Default::default(),
1094 _delegate: Default::default(),
1095 _additional_params: Default::default(),
1096 _scopes: Default::default(),
1097 }
1098 }
1099
1100 /// Create a builder to help you perform the following task:
1101 ///
1102 /// Splits capacity commitment to two commitments of the same plan and `commitment_end_time`. A common use case is to enable downgrading commitments. For example, in order to downgrade from 10000 slots to 8000, you might split a 10000 capacity commitment into commitments of 2000 and 8000. Then, you delete the first one after the commitment end time passes.
1103 ///
1104 /// # Arguments
1105 ///
1106 /// * `request` - No description provided.
1107 /// * `name` - Required. The resource name e.g.,: `projects/myproject/locations/US/capacityCommitments/123`
1108 pub fn locations_capacity_commitments_split(
1109 &self,
1110 request: SplitCapacityCommitmentRequest,
1111 name: &str,
1112 ) -> ProjectLocationCapacityCommitmentSplitCall<'a, C> {
1113 ProjectLocationCapacityCommitmentSplitCall {
1114 hub: self.hub,
1115 _request: request,
1116 _name: name.to_string(),
1117 _delegate: Default::default(),
1118 _additional_params: Default::default(),
1119 _scopes: Default::default(),
1120 }
1121 }
1122
1123 /// Create a builder to help you perform the following task:
1124 ///
1125 /// Creates a new reservation group.
1126 ///
1127 /// # Arguments
1128 ///
1129 /// * `request` - No description provided.
1130 /// * `parent` - Required. Project, location. E.g., `projects/myproject/locations/US`
1131 pub fn locations_reservation_groups_create(
1132 &self,
1133 request: ReservationGroup,
1134 parent: &str,
1135 ) -> ProjectLocationReservationGroupCreateCall<'a, C> {
1136 ProjectLocationReservationGroupCreateCall {
1137 hub: self.hub,
1138 _request: request,
1139 _parent: parent.to_string(),
1140 _reservation_group_id: Default::default(),
1141 _delegate: Default::default(),
1142 _additional_params: Default::default(),
1143 _scopes: Default::default(),
1144 }
1145 }
1146
1147 /// Create a builder to help you perform the following task:
1148 ///
1149 /// Deletes a reservation. Returns `google.rpc.Code.FAILED_PRECONDITION` when reservation has assignments.
1150 ///
1151 /// # Arguments
1152 ///
1153 /// * `name` - Required. Resource name of the reservation group to retrieve. E.g., `projects/myproject/locations/US/reservationGroups/team1-prod`
1154 pub fn locations_reservation_groups_delete(
1155 &self,
1156 name: &str,
1157 ) -> ProjectLocationReservationGroupDeleteCall<'a, C> {
1158 ProjectLocationReservationGroupDeleteCall {
1159 hub: self.hub,
1160 _name: name.to_string(),
1161 _delegate: Default::default(),
1162 _additional_params: Default::default(),
1163 _scopes: Default::default(),
1164 }
1165 }
1166
1167 /// Create a builder to help you perform the following task:
1168 ///
1169 /// Returns information about the reservation group.
1170 ///
1171 /// # Arguments
1172 ///
1173 /// * `name` - Required. Resource name of the reservation group to retrieve. E.g., `projects/myproject/locations/US/reservationGroups/team1-prod`
1174 pub fn locations_reservation_groups_get(
1175 &self,
1176 name: &str,
1177 ) -> ProjectLocationReservationGroupGetCall<'a, C> {
1178 ProjectLocationReservationGroupGetCall {
1179 hub: self.hub,
1180 _name: name.to_string(),
1181 _delegate: Default::default(),
1182 _additional_params: Default::default(),
1183 _scopes: Default::default(),
1184 }
1185 }
1186
1187 /// Create a builder to help you perform the following task:
1188 ///
1189 /// Lists all the reservation groups for the project in the specified location.
1190 ///
1191 /// # Arguments
1192 ///
1193 /// * `parent` - Required. The parent resource name containing project and location, e.g.: `projects/myproject/locations/US`
1194 pub fn locations_reservation_groups_list(
1195 &self,
1196 parent: &str,
1197 ) -> ProjectLocationReservationGroupListCall<'a, C> {
1198 ProjectLocationReservationGroupListCall {
1199 hub: self.hub,
1200 _parent: parent.to_string(),
1201 _page_token: Default::default(),
1202 _page_size: Default::default(),
1203 _delegate: Default::default(),
1204 _additional_params: Default::default(),
1205 _scopes: Default::default(),
1206 }
1207 }
1208
1209 /// Create a builder to help you perform the following task:
1210 ///
1211 /// Creates an assignment object which allows the given project to submit jobs of a certain type using slots from the specified reservation. Currently a resource (project, folder, organization) can only have one assignment per each (job_type, location) combination, and that reservation will be used for all jobs of the matching type. Different assignments can be created on different levels of the projects, folders or organization hierarchy. During query execution, the assignment is looked up at the project, folder and organization levels in that order. The first assignment found is applied to the query. When creating assignments, it does not matter if other assignments exist at higher levels. Example: * The organization `organizationA` contains two projects, `project1` and `project2`. * Assignments for all three entities (`organizationA`, `project1`, and `project2`) could all be created and mapped to the same or different reservations. "None" assignments represent an absence of the assignment. Projects assigned to None use on-demand pricing. To create a "None" assignment, use "none" as a reservation_id in the parent. Example parent: `projects/myproject/locations/US/reservations/none`. Returns `google.rpc.Code.PERMISSION_DENIED` if user does not have 'bigquery.admin' permissions on the project using the reservation and the project that owns this reservation. Returns `google.rpc.Code.INVALID_ARGUMENT` when location of the assignment does not match location of the reservation.
1212 ///
1213 /// # Arguments
1214 ///
1215 /// * `request` - No description provided.
1216 /// * `parent` - Required. The parent resource name of the assignment E.g. `projects/myproject/locations/US/reservations/team1-prod`
1217 pub fn locations_reservations_assignments_create(
1218 &self,
1219 request: Assignment,
1220 parent: &str,
1221 ) -> ProjectLocationReservationAssignmentCreateCall<'a, C> {
1222 ProjectLocationReservationAssignmentCreateCall {
1223 hub: self.hub,
1224 _request: request,
1225 _parent: parent.to_string(),
1226 _assignment_id: Default::default(),
1227 _delegate: Default::default(),
1228 _additional_params: Default::default(),
1229 _scopes: Default::default(),
1230 }
1231 }
1232
1233 /// Create a builder to help you perform the following task:
1234 ///
1235 /// Deletes a assignment. No expansion will happen. Example: * Organization `organizationA` contains two projects, `project1` and `project2`. * Reservation `res1` exists and was created previously. * CreateAssignment was used previously to define the following associations between entities and reservations: `` and `` In this example, deletion of the `` assignment won't affect the other assignment ``. After said deletion, queries from `project1` will still use `res1` while queries from `project2` will switch to use on-demand mode.
1236 ///
1237 /// # Arguments
1238 ///
1239 /// * `name` - Required. Name of the resource, e.g. `projects/myproject/locations/US/reservations/team1-prod/assignments/123`
1240 pub fn locations_reservations_assignments_delete(
1241 &self,
1242 name: &str,
1243 ) -> ProjectLocationReservationAssignmentDeleteCall<'a, C> {
1244 ProjectLocationReservationAssignmentDeleteCall {
1245 hub: self.hub,
1246 _name: name.to_string(),
1247 _delegate: Default::default(),
1248 _additional_params: Default::default(),
1249 _scopes: Default::default(),
1250 }
1251 }
1252
1253 /// Create a builder to help you perform the following task:
1254 ///
1255 /// Gets the access control policy for a resource. May return: * A`NOT_FOUND` error if the resource doesn't exist or you don't have the permission to view it. * An empty policy if the resource exists but doesn't have a set policy. Supported resources are: - Reservations - ReservationAssignments To call this method, you must have the following Google IAM permissions: - `bigqueryreservation.reservations.getIamPolicy` to get policies on reservations.
1256 ///
1257 /// # Arguments
1258 ///
1259 /// * `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.
1260 pub fn locations_reservations_assignments_get_iam_policy(
1261 &self,
1262 resource: &str,
1263 ) -> ProjectLocationReservationAssignmentGetIamPolicyCall<'a, C> {
1264 ProjectLocationReservationAssignmentGetIamPolicyCall {
1265 hub: self.hub,
1266 _resource: resource.to_string(),
1267 _options_requested_policy_version: Default::default(),
1268 _delegate: Default::default(),
1269 _additional_params: Default::default(),
1270 _scopes: Default::default(),
1271 }
1272 }
1273
1274 /// Create a builder to help you perform the following task:
1275 ///
1276 /// Lists assignments. Only explicitly created assignments will be returned. Example: * Organization `organizationA` contains two projects, `project1` and `project2`. * Reservation `res1` exists and was created previously. * CreateAssignment was used previously to define the following associations between entities and reservations: `` and `` In this example, ListAssignments will just return the above two assignments for reservation `res1`, and no expansion/merge will happen. The wildcard "-" can be used for reservations in the request. In that case all assignments belongs to the specified project and location will be listed. **Note** "-" cannot be used for projects nor locations.
1277 ///
1278 /// # Arguments
1279 ///
1280 /// * `parent` - Required. The parent resource name e.g.: `projects/myproject/locations/US/reservations/team1-prod` Or: `projects/myproject/locations/US/reservations/-`
1281 pub fn locations_reservations_assignments_list(
1282 &self,
1283 parent: &str,
1284 ) -> ProjectLocationReservationAssignmentListCall<'a, C> {
1285 ProjectLocationReservationAssignmentListCall {
1286 hub: self.hub,
1287 _parent: parent.to_string(),
1288 _page_token: Default::default(),
1289 _page_size: Default::default(),
1290 _delegate: Default::default(),
1291 _additional_params: Default::default(),
1292 _scopes: Default::default(),
1293 }
1294 }
1295
1296 /// Create a builder to help you perform the following task:
1297 ///
1298 /// Moves an assignment under a new reservation. This differs from removing an existing assignment and recreating a new one by providing a transactional change that ensures an assignee always has an associated reservation.
1299 ///
1300 /// # Arguments
1301 ///
1302 /// * `request` - No description provided.
1303 /// * `name` - Required. The resource name of the assignment, e.g. `projects/myproject/locations/US/reservations/team1-prod/assignments/123`
1304 pub fn locations_reservations_assignments_move(
1305 &self,
1306 request: MoveAssignmentRequest,
1307 name: &str,
1308 ) -> ProjectLocationReservationAssignmentMoveCall<'a, C> {
1309 ProjectLocationReservationAssignmentMoveCall {
1310 hub: self.hub,
1311 _request: request,
1312 _name: name.to_string(),
1313 _delegate: Default::default(),
1314 _additional_params: Default::default(),
1315 _scopes: Default::default(),
1316 }
1317 }
1318
1319 /// Create a builder to help you perform the following task:
1320 ///
1321 /// Updates an existing assignment. Only the `priority` field can be updated.
1322 ///
1323 /// # Arguments
1324 ///
1325 /// * `request` - No description provided.
1326 /// * `name` - Output only. Name of the resource. E.g.: `projects/myproject/locations/US/reservations/team1-prod/assignments/123`. The assignment_id must only contain lower case alphanumeric characters or dashes and the max length is 64 characters.
1327 pub fn locations_reservations_assignments_patch(
1328 &self,
1329 request: Assignment,
1330 name: &str,
1331 ) -> ProjectLocationReservationAssignmentPatchCall<'a, C> {
1332 ProjectLocationReservationAssignmentPatchCall {
1333 hub: self.hub,
1334 _request: request,
1335 _name: name.to_string(),
1336 _update_mask: Default::default(),
1337 _delegate: Default::default(),
1338 _additional_params: Default::default(),
1339 _scopes: Default::default(),
1340 }
1341 }
1342
1343 /// Create a builder to help you perform the following task:
1344 ///
1345 /// Sets an access control policy for a resource. Replaces any existing policy. Supported resources are: - Reservations To call this method, you must have the following Google IAM permissions: - `bigqueryreservation.reservations.setIamPolicy` to set policies on reservations.
1346 ///
1347 /// # Arguments
1348 ///
1349 /// * `request` - No description provided.
1350 /// * `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.
1351 pub fn locations_reservations_assignments_set_iam_policy(
1352 &self,
1353 request: SetIamPolicyRequest,
1354 resource: &str,
1355 ) -> ProjectLocationReservationAssignmentSetIamPolicyCall<'a, C> {
1356 ProjectLocationReservationAssignmentSetIamPolicyCall {
1357 hub: self.hub,
1358 _request: request,
1359 _resource: resource.to_string(),
1360 _delegate: Default::default(),
1361 _additional_params: Default::default(),
1362 _scopes: Default::default(),
1363 }
1364 }
1365
1366 /// Create a builder to help you perform the following task:
1367 ///
1368 /// Gets your permissions on a resource. Returns an empty set of permissions if the resource doesn't exist. Supported resources are: - Reservations No Google IAM permissions are required to call this method.
1369 ///
1370 /// # Arguments
1371 ///
1372 /// * `request` - No description provided.
1373 /// * `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.
1374 pub fn locations_reservations_assignments_test_iam_permissions(
1375 &self,
1376 request: TestIamPermissionsRequest,
1377 resource: &str,
1378 ) -> ProjectLocationReservationAssignmentTestIamPermissionCall<'a, C> {
1379 ProjectLocationReservationAssignmentTestIamPermissionCall {
1380 hub: self.hub,
1381 _request: request,
1382 _resource: resource.to_string(),
1383 _delegate: Default::default(),
1384 _additional_params: Default::default(),
1385 _scopes: Default::default(),
1386 }
1387 }
1388
1389 /// Create a builder to help you perform the following task:
1390 ///
1391 /// Creates a new reservation resource.
1392 ///
1393 /// # Arguments
1394 ///
1395 /// * `request` - No description provided.
1396 /// * `parent` - Required. Project, location. E.g., `projects/myproject/locations/US`
1397 pub fn locations_reservations_create(
1398 &self,
1399 request: Reservation,
1400 parent: &str,
1401 ) -> ProjectLocationReservationCreateCall<'a, C> {
1402 ProjectLocationReservationCreateCall {
1403 hub: self.hub,
1404 _request: request,
1405 _parent: parent.to_string(),
1406 _reservation_id: Default::default(),
1407 _delegate: Default::default(),
1408 _additional_params: Default::default(),
1409 _scopes: Default::default(),
1410 }
1411 }
1412
1413 /// Create a builder to help you perform the following task:
1414 ///
1415 /// Deletes a reservation. Returns `google.rpc.Code.FAILED_PRECONDITION` when reservation has assignments.
1416 ///
1417 /// # Arguments
1418 ///
1419 /// * `name` - Required. Resource name of the reservation to retrieve. E.g., `projects/myproject/locations/US/reservations/team1-prod`
1420 pub fn locations_reservations_delete(
1421 &self,
1422 name: &str,
1423 ) -> ProjectLocationReservationDeleteCall<'a, C> {
1424 ProjectLocationReservationDeleteCall {
1425 hub: self.hub,
1426 _name: name.to_string(),
1427 _delegate: Default::default(),
1428 _additional_params: Default::default(),
1429 _scopes: Default::default(),
1430 }
1431 }
1432
1433 /// Create a builder to help you perform the following task:
1434 ///
1435 /// Fail over a reservation to the secondary location. The operation should be done in the current secondary location, which will be promoted to the new primary location for the reservation. Attempting to failover a reservation in the current primary location will fail with the error code `google.rpc.Code.FAILED_PRECONDITION`.
1436 ///
1437 /// # Arguments
1438 ///
1439 /// * `request` - No description provided.
1440 /// * `name` - Required. Resource name of the reservation to failover. E.g., `projects/myproject/locations/US/reservations/team1-prod`
1441 pub fn locations_reservations_failover_reservation(
1442 &self,
1443 request: FailoverReservationRequest,
1444 name: &str,
1445 ) -> ProjectLocationReservationFailoverReservationCall<'a, C> {
1446 ProjectLocationReservationFailoverReservationCall {
1447 hub: self.hub,
1448 _request: request,
1449 _name: name.to_string(),
1450 _delegate: Default::default(),
1451 _additional_params: Default::default(),
1452 _scopes: Default::default(),
1453 }
1454 }
1455
1456 /// Create a builder to help you perform the following task:
1457 ///
1458 /// Returns information about the reservation.
1459 ///
1460 /// # Arguments
1461 ///
1462 /// * `name` - Required. Resource name of the reservation to retrieve. E.g., `projects/myproject/locations/US/reservations/team1-prod`
1463 pub fn locations_reservations_get(
1464 &self,
1465 name: &str,
1466 ) -> ProjectLocationReservationGetCall<'a, C> {
1467 ProjectLocationReservationGetCall {
1468 hub: self.hub,
1469 _name: name.to_string(),
1470 _delegate: Default::default(),
1471 _additional_params: Default::default(),
1472 _scopes: Default::default(),
1473 }
1474 }
1475
1476 /// Create a builder to help you perform the following task:
1477 ///
1478 /// Gets the access control policy for a resource. May return: * A`NOT_FOUND` error if the resource doesn't exist or you don't have the permission to view it. * An empty policy if the resource exists but doesn't have a set policy. Supported resources are: - Reservations - ReservationAssignments To call this method, you must have the following Google IAM permissions: - `bigqueryreservation.reservations.getIamPolicy` to get policies on reservations.
1479 ///
1480 /// # Arguments
1481 ///
1482 /// * `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.
1483 pub fn locations_reservations_get_iam_policy(
1484 &self,
1485 resource: &str,
1486 ) -> ProjectLocationReservationGetIamPolicyCall<'a, C> {
1487 ProjectLocationReservationGetIamPolicyCall {
1488 hub: self.hub,
1489 _resource: resource.to_string(),
1490 _options_requested_policy_version: Default::default(),
1491 _delegate: Default::default(),
1492 _additional_params: Default::default(),
1493 _scopes: Default::default(),
1494 }
1495 }
1496
1497 /// Create a builder to help you perform the following task:
1498 ///
1499 /// Lists all the reservations for the project in the specified location.
1500 ///
1501 /// # Arguments
1502 ///
1503 /// * `parent` - Required. The parent resource name containing project and location, e.g.: `projects/myproject/locations/US`
1504 pub fn locations_reservations_list(
1505 &self,
1506 parent: &str,
1507 ) -> ProjectLocationReservationListCall<'a, C> {
1508 ProjectLocationReservationListCall {
1509 hub: self.hub,
1510 _parent: parent.to_string(),
1511 _page_token: Default::default(),
1512 _page_size: Default::default(),
1513 _delegate: Default::default(),
1514 _additional_params: Default::default(),
1515 _scopes: Default::default(),
1516 }
1517 }
1518
1519 /// Create a builder to help you perform the following task:
1520 ///
1521 /// Updates an existing reservation resource.
1522 ///
1523 /// # Arguments
1524 ///
1525 /// * `request` - No description provided.
1526 /// * `name` - Identifier. The resource name of the reservation, e.g., `projects/*/locations/*/reservations/team1-prod`. The reservation_id must only contain lower case alphanumeric characters or dashes. It must start with a letter and must not end with a dash. Its maximum length is 64 characters.
1527 pub fn locations_reservations_patch(
1528 &self,
1529 request: Reservation,
1530 name: &str,
1531 ) -> ProjectLocationReservationPatchCall<'a, C> {
1532 ProjectLocationReservationPatchCall {
1533 hub: self.hub,
1534 _request: request,
1535 _name: name.to_string(),
1536 _update_mask: Default::default(),
1537 _delegate: Default::default(),
1538 _additional_params: Default::default(),
1539 _scopes: Default::default(),
1540 }
1541 }
1542
1543 /// Create a builder to help you perform the following task:
1544 ///
1545 /// Sets an access control policy for a resource. Replaces any existing policy. Supported resources are: - Reservations To call this method, you must have the following Google IAM permissions: - `bigqueryreservation.reservations.setIamPolicy` to set policies on reservations.
1546 ///
1547 /// # Arguments
1548 ///
1549 /// * `request` - No description provided.
1550 /// * `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.
1551 pub fn locations_reservations_set_iam_policy(
1552 &self,
1553 request: SetIamPolicyRequest,
1554 resource: &str,
1555 ) -> ProjectLocationReservationSetIamPolicyCall<'a, C> {
1556 ProjectLocationReservationSetIamPolicyCall {
1557 hub: self.hub,
1558 _request: request,
1559 _resource: resource.to_string(),
1560 _delegate: Default::default(),
1561 _additional_params: Default::default(),
1562 _scopes: Default::default(),
1563 }
1564 }
1565
1566 /// Create a builder to help you perform the following task:
1567 ///
1568 /// Gets your permissions on a resource. Returns an empty set of permissions if the resource doesn't exist. Supported resources are: - Reservations No Google IAM permissions are required to call this method.
1569 ///
1570 /// # Arguments
1571 ///
1572 /// * `request` - No description provided.
1573 /// * `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.
1574 pub fn locations_reservations_test_iam_permissions(
1575 &self,
1576 request: TestIamPermissionsRequest,
1577 resource: &str,
1578 ) -> ProjectLocationReservationTestIamPermissionCall<'a, C> {
1579 ProjectLocationReservationTestIamPermissionCall {
1580 hub: self.hub,
1581 _request: request,
1582 _resource: resource.to_string(),
1583 _delegate: Default::default(),
1584 _additional_params: Default::default(),
1585 _scopes: Default::default(),
1586 }
1587 }
1588
1589 /// Create a builder to help you perform the following task:
1590 ///
1591 /// Retrieves a BI reservation.
1592 ///
1593 /// # Arguments
1594 ///
1595 /// * `name` - Required. Name of the requested reservation, for example: `projects/{project_id}/locations/{location_id}/biReservation`
1596 pub fn locations_get_bi_reservation(
1597 &self,
1598 name: &str,
1599 ) -> ProjectLocationGetBiReservationCall<'a, C> {
1600 ProjectLocationGetBiReservationCall {
1601 hub: self.hub,
1602 _name: name.to_string(),
1603 _delegate: Default::default(),
1604 _additional_params: Default::default(),
1605 _scopes: Default::default(),
1606 }
1607 }
1608
1609 /// Create a builder to help you perform the following task:
1610 ///
1611 /// Looks up assignments for a specified resource for a particular region. If the request is about a project: 1. Assignments created on the project will be returned if they exist. 2. Otherwise assignments created on the closest ancestor will be returned. 3. Assignments for different JobTypes will all be returned. The same logic applies if the request is about a folder. If the request is about an organization, then assignments created on the organization will be returned (organization doesn't have ancestors). Comparing to ListAssignments, there are some behavior differences: 1. permission on the assignee will be verified in this API. 2. Hierarchy lookup (project->folder->organization) happens in this API. 3. Parent here is `projects/*/locations/*`, instead of `projects/*/locations/*reservations/*`.
1612 ///
1613 /// # Arguments
1614 ///
1615 /// * `parent` - Required. The resource name with location (project name could be the wildcard '-'), e.g.: `projects/-/locations/US`.
1616 pub fn locations_search_all_assignments(
1617 &self,
1618 parent: &str,
1619 ) -> ProjectLocationSearchAllAssignmentCall<'a, C> {
1620 ProjectLocationSearchAllAssignmentCall {
1621 hub: self.hub,
1622 _parent: parent.to_string(),
1623 _query: Default::default(),
1624 _page_token: Default::default(),
1625 _page_size: Default::default(),
1626 _delegate: Default::default(),
1627 _additional_params: Default::default(),
1628 _scopes: Default::default(),
1629 }
1630 }
1631
1632 /// Create a builder to help you perform the following task:
1633 ///
1634 /// Deprecated: Looks up assignments for a specified resource for a particular region. If the request is about a project: 1. Assignments created on the project will be returned if they exist. 2. Otherwise assignments created on the closest ancestor will be returned. 3. Assignments for different JobTypes will all be returned. The same logic applies if the request is about a folder. If the request is about an organization, then assignments created on the organization will be returned (organization doesn't have ancestors). Comparing to ListAssignments, there are some behavior differences: 1. permission on the assignee will be verified in this API. 2. Hierarchy lookup (project->folder->organization) happens in this API. 3. Parent here is `projects/*/locations/*`, instead of `projects/*/locations/*reservations/*`. **Note** "-" cannot be used for projects nor locations.
1635 ///
1636 /// # Arguments
1637 ///
1638 /// * `parent` - Required. The resource name of the admin project(containing project and location), e.g.: `projects/myproject/locations/US`.
1639 pub fn locations_search_assignments(
1640 &self,
1641 parent: &str,
1642 ) -> ProjectLocationSearchAssignmentCall<'a, C> {
1643 ProjectLocationSearchAssignmentCall {
1644 hub: self.hub,
1645 _parent: parent.to_string(),
1646 _query: Default::default(),
1647 _page_token: Default::default(),
1648 _page_size: Default::default(),
1649 _delegate: Default::default(),
1650 _additional_params: Default::default(),
1651 _scopes: Default::default(),
1652 }
1653 }
1654
1655 /// Create a builder to help you perform the following task:
1656 ///
1657 /// Updates a BI reservation. Only fields specified in the `field_mask` are updated. A singleton BI reservation always exists with default size 0. In order to reserve BI capacity it needs to be updated to an amount greater than 0. In order to release BI capacity reservation size must be set to 0.
1658 ///
1659 /// # Arguments
1660 ///
1661 /// * `request` - No description provided.
1662 /// * `name` - Identifier. The resource name of the singleton BI reservation. Reservation names have the form `projects/{project_id}/locations/{location_id}/biReservation`.
1663 pub fn locations_update_bi_reservation(
1664 &self,
1665 request: BiReservation,
1666 name: &str,
1667 ) -> ProjectLocationUpdateBiReservationCall<'a, C> {
1668 ProjectLocationUpdateBiReservationCall {
1669 hub: self.hub,
1670 _request: request,
1671 _name: name.to_string(),
1672 _update_mask: Default::default(),
1673 _delegate: Default::default(),
1674 _additional_params: Default::default(),
1675 _scopes: Default::default(),
1676 }
1677 }
1678}
1679
1680// ###################
1681// CallBuilders ###
1682// #################
1683
1684/// Creates a new capacity commitment resource.
1685///
1686/// A builder for the *locations.capacityCommitments.create* method supported by a *project* resource.
1687/// It is not used directly, but through a [`ProjectMethods`] instance.
1688///
1689/// # Example
1690///
1691/// Instantiate a resource method builder
1692///
1693/// ```test_harness,no_run
1694/// # extern crate hyper;
1695/// # extern crate hyper_rustls;
1696/// # extern crate google_bigqueryreservation1 as bigqueryreservation1;
1697/// use bigqueryreservation1::api::CapacityCommitment;
1698/// # async fn dox() {
1699/// # use bigqueryreservation1::{BigQueryReservation, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
1700///
1701/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
1702/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
1703/// # .with_native_roots()
1704/// # .unwrap()
1705/// # .https_only()
1706/// # .enable_http2()
1707/// # .build();
1708///
1709/// # let executor = hyper_util::rt::TokioExecutor::new();
1710/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
1711/// # secret,
1712/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
1713/// # yup_oauth2::client::CustomHyperClientBuilder::from(
1714/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
1715/// # ),
1716/// # ).build().await.unwrap();
1717///
1718/// # let client = hyper_util::client::legacy::Client::builder(
1719/// # hyper_util::rt::TokioExecutor::new()
1720/// # )
1721/// # .build(
1722/// # hyper_rustls::HttpsConnectorBuilder::new()
1723/// # .with_native_roots()
1724/// # .unwrap()
1725/// # .https_or_http()
1726/// # .enable_http2()
1727/// # .build()
1728/// # );
1729/// # let mut hub = BigQueryReservation::new(client, auth);
1730/// // As the method needs a request, you would usually fill it with the desired information
1731/// // into the respective structure. Some of the parts shown here might not be applicable !
1732/// // Values shown here are possibly random and not representative !
1733/// let mut req = CapacityCommitment::default();
1734///
1735/// // You can configure optional parameters by calling the respective setters at will, and
1736/// // execute the final call using `doit()`.
1737/// // Values shown here are possibly random and not representative !
1738/// let result = hub.projects().locations_capacity_commitments_create(req, "parent")
1739/// .enforce_single_admin_project_per_org(false)
1740/// .capacity_commitment_id("amet.")
1741/// .doit().await;
1742/// # }
1743/// ```
1744pub struct ProjectLocationCapacityCommitmentCreateCall<'a, C>
1745where
1746 C: 'a,
1747{
1748 hub: &'a BigQueryReservation<C>,
1749 _request: CapacityCommitment,
1750 _parent: String,
1751 _enforce_single_admin_project_per_org: Option<bool>,
1752 _capacity_commitment_id: Option<String>,
1753 _delegate: Option<&'a mut dyn common::Delegate>,
1754 _additional_params: HashMap<String, String>,
1755 _scopes: BTreeSet<String>,
1756}
1757
1758impl<'a, C> common::CallBuilder for ProjectLocationCapacityCommitmentCreateCall<'a, C> {}
1759
1760impl<'a, C> ProjectLocationCapacityCommitmentCreateCall<'a, C>
1761where
1762 C: common::Connector,
1763{
1764 /// Perform the operation you have build so far.
1765 pub async fn doit(mut self) -> common::Result<(common::Response, CapacityCommitment)> {
1766 use std::borrow::Cow;
1767 use std::io::{Read, Seek};
1768
1769 use common::{url::Params, ToParts};
1770 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
1771
1772 let mut dd = common::DefaultDelegate;
1773 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
1774 dlg.begin(common::MethodInfo {
1775 id: "bigqueryreservation.projects.locations.capacityCommitments.create",
1776 http_method: hyper::Method::POST,
1777 });
1778
1779 for &field in [
1780 "alt",
1781 "parent",
1782 "enforceSingleAdminProjectPerOrg",
1783 "capacityCommitmentId",
1784 ]
1785 .iter()
1786 {
1787 if self._additional_params.contains_key(field) {
1788 dlg.finished(false);
1789 return Err(common::Error::FieldClash(field));
1790 }
1791 }
1792
1793 let mut params = Params::with_capacity(6 + self._additional_params.len());
1794 params.push("parent", self._parent);
1795 if let Some(value) = self._enforce_single_admin_project_per_org.as_ref() {
1796 params.push("enforceSingleAdminProjectPerOrg", value.to_string());
1797 }
1798 if let Some(value) = self._capacity_commitment_id.as_ref() {
1799 params.push("capacityCommitmentId", value);
1800 }
1801
1802 params.extend(self._additional_params.iter());
1803
1804 params.push("alt", "json");
1805 let mut url = self.hub._base_url.clone() + "v1/{+parent}/capacityCommitments";
1806 if self._scopes.is_empty() {
1807 self._scopes
1808 .insert(Scope::CloudPlatform.as_ref().to_string());
1809 }
1810
1811 #[allow(clippy::single_element_loop)]
1812 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
1813 url = params.uri_replacement(url, param_name, find_this, true);
1814 }
1815 {
1816 let to_remove = ["parent"];
1817 params.remove_params(&to_remove);
1818 }
1819
1820 let url = params.parse_with_url(&url);
1821
1822 let mut json_mime_type = mime::APPLICATION_JSON;
1823 let mut request_value_reader = {
1824 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
1825 common::remove_json_null_values(&mut value);
1826 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
1827 serde_json::to_writer(&mut dst, &value).unwrap();
1828 dst
1829 };
1830 let request_size = request_value_reader
1831 .seek(std::io::SeekFrom::End(0))
1832 .unwrap();
1833 request_value_reader
1834 .seek(std::io::SeekFrom::Start(0))
1835 .unwrap();
1836
1837 loop {
1838 let token = match self
1839 .hub
1840 .auth
1841 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
1842 .await
1843 {
1844 Ok(token) => token,
1845 Err(e) => match dlg.token(e) {
1846 Ok(token) => token,
1847 Err(e) => {
1848 dlg.finished(false);
1849 return Err(common::Error::MissingToken(e));
1850 }
1851 },
1852 };
1853 request_value_reader
1854 .seek(std::io::SeekFrom::Start(0))
1855 .unwrap();
1856 let mut req_result = {
1857 let client = &self.hub.client;
1858 dlg.pre_request();
1859 let mut req_builder = hyper::Request::builder()
1860 .method(hyper::Method::POST)
1861 .uri(url.as_str())
1862 .header(USER_AGENT, self.hub._user_agent.clone());
1863
1864 if let Some(token) = token.as_ref() {
1865 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
1866 }
1867
1868 let request = req_builder
1869 .header(CONTENT_TYPE, json_mime_type.to_string())
1870 .header(CONTENT_LENGTH, request_size as u64)
1871 .body(common::to_body(
1872 request_value_reader.get_ref().clone().into(),
1873 ));
1874
1875 client.request(request.unwrap()).await
1876 };
1877
1878 match req_result {
1879 Err(err) => {
1880 if let common::Retry::After(d) = dlg.http_error(&err) {
1881 sleep(d).await;
1882 continue;
1883 }
1884 dlg.finished(false);
1885 return Err(common::Error::HttpError(err));
1886 }
1887 Ok(res) => {
1888 let (mut parts, body) = res.into_parts();
1889 let mut body = common::Body::new(body);
1890 if !parts.status.is_success() {
1891 let bytes = common::to_bytes(body).await.unwrap_or_default();
1892 let error = serde_json::from_str(&common::to_string(&bytes));
1893 let response = common::to_response(parts, bytes.into());
1894
1895 if let common::Retry::After(d) =
1896 dlg.http_failure(&response, error.as_ref().ok())
1897 {
1898 sleep(d).await;
1899 continue;
1900 }
1901
1902 dlg.finished(false);
1903
1904 return Err(match error {
1905 Ok(value) => common::Error::BadRequest(value),
1906 _ => common::Error::Failure(response),
1907 });
1908 }
1909 let response = {
1910 let bytes = common::to_bytes(body).await.unwrap_or_default();
1911 let encoded = common::to_string(&bytes);
1912 match serde_json::from_str(&encoded) {
1913 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
1914 Err(error) => {
1915 dlg.response_json_decode_error(&encoded, &error);
1916 return Err(common::Error::JsonDecodeError(
1917 encoded.to_string(),
1918 error,
1919 ));
1920 }
1921 }
1922 };
1923
1924 dlg.finished(true);
1925 return Ok(response);
1926 }
1927 }
1928 }
1929 }
1930
1931 ///
1932 /// Sets the *request* property to the given value.
1933 ///
1934 /// Even though the property as already been set when instantiating this call,
1935 /// we provide this method for API completeness.
1936 pub fn request(
1937 mut self,
1938 new_value: CapacityCommitment,
1939 ) -> ProjectLocationCapacityCommitmentCreateCall<'a, C> {
1940 self._request = new_value;
1941 self
1942 }
1943 /// Required. Resource name of the parent reservation. E.g., `projects/myproject/locations/US`
1944 ///
1945 /// Sets the *parent* path property to the given value.
1946 ///
1947 /// Even though the property as already been set when instantiating this call,
1948 /// we provide this method for API completeness.
1949 pub fn parent(mut self, new_value: &str) -> ProjectLocationCapacityCommitmentCreateCall<'a, C> {
1950 self._parent = new_value.to_string();
1951 self
1952 }
1953 /// If true, fail the request if another project in the organization has a capacity commitment.
1954 ///
1955 /// Sets the *enforce single admin project per org* query property to the given value.
1956 pub fn enforce_single_admin_project_per_org(
1957 mut self,
1958 new_value: bool,
1959 ) -> ProjectLocationCapacityCommitmentCreateCall<'a, C> {
1960 self._enforce_single_admin_project_per_org = Some(new_value);
1961 self
1962 }
1963 /// The optional capacity commitment ID. Capacity commitment name will be generated automatically if this field is empty. This field must only contain lower case alphanumeric characters or dashes. The first and last character cannot be a dash. Max length is 64 characters. NOTE: this ID won't be kept if the capacity commitment is split or merged.
1964 ///
1965 /// Sets the *capacity commitment id* query property to the given value.
1966 pub fn capacity_commitment_id(
1967 mut self,
1968 new_value: &str,
1969 ) -> ProjectLocationCapacityCommitmentCreateCall<'a, C> {
1970 self._capacity_commitment_id = Some(new_value.to_string());
1971 self
1972 }
1973 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
1974 /// while executing the actual API request.
1975 ///
1976 /// ````text
1977 /// It should be used to handle progress information, and to implement a certain level of resilience.
1978 /// ````
1979 ///
1980 /// Sets the *delegate* property to the given value.
1981 pub fn delegate(
1982 mut self,
1983 new_value: &'a mut dyn common::Delegate,
1984 ) -> ProjectLocationCapacityCommitmentCreateCall<'a, C> {
1985 self._delegate = Some(new_value);
1986 self
1987 }
1988
1989 /// Set any additional parameter of the query string used in the request.
1990 /// It should be used to set parameters which are not yet available through their own
1991 /// setters.
1992 ///
1993 /// Please note that this method must not be used to set any of the known parameters
1994 /// which have their own setter method. If done anyway, the request will fail.
1995 ///
1996 /// # Additional Parameters
1997 ///
1998 /// * *$.xgafv* (query-string) - V1 error format.
1999 /// * *access_token* (query-string) - OAuth access token.
2000 /// * *alt* (query-string) - Data format for response.
2001 /// * *callback* (query-string) - JSONP
2002 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2003 /// * *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.
2004 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2005 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2006 /// * *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.
2007 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2008 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2009 pub fn param<T>(
2010 mut self,
2011 name: T,
2012 value: T,
2013 ) -> ProjectLocationCapacityCommitmentCreateCall<'a, C>
2014 where
2015 T: AsRef<str>,
2016 {
2017 self._additional_params
2018 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2019 self
2020 }
2021
2022 /// Identifies the authorization scope for the method you are building.
2023 ///
2024 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2025 /// [`Scope::CloudPlatform`].
2026 ///
2027 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2028 /// tokens for more than one scope.
2029 ///
2030 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2031 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2032 /// sufficient, a read-write scope will do as well.
2033 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCapacityCommitmentCreateCall<'a, C>
2034 where
2035 St: AsRef<str>,
2036 {
2037 self._scopes.insert(String::from(scope.as_ref()));
2038 self
2039 }
2040 /// Identifies the authorization scope(s) for the method you are building.
2041 ///
2042 /// See [`Self::add_scope()`] for details.
2043 pub fn add_scopes<I, St>(
2044 mut self,
2045 scopes: I,
2046 ) -> ProjectLocationCapacityCommitmentCreateCall<'a, C>
2047 where
2048 I: IntoIterator<Item = St>,
2049 St: AsRef<str>,
2050 {
2051 self._scopes
2052 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2053 self
2054 }
2055
2056 /// Removes all scopes, and no default scope will be used either.
2057 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2058 /// for details).
2059 pub fn clear_scopes(mut self) -> ProjectLocationCapacityCommitmentCreateCall<'a, C> {
2060 self._scopes.clear();
2061 self
2062 }
2063}
2064
2065/// Deletes a capacity commitment. Attempting to delete capacity commitment before its commitment_end_time will fail with the error code `google.rpc.Code.FAILED_PRECONDITION`.
2066///
2067/// A builder for the *locations.capacityCommitments.delete* method supported by a *project* resource.
2068/// It is not used directly, but through a [`ProjectMethods`] instance.
2069///
2070/// # Example
2071///
2072/// Instantiate a resource method builder
2073///
2074/// ```test_harness,no_run
2075/// # extern crate hyper;
2076/// # extern crate hyper_rustls;
2077/// # extern crate google_bigqueryreservation1 as bigqueryreservation1;
2078/// # async fn dox() {
2079/// # use bigqueryreservation1::{BigQueryReservation, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2080///
2081/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2082/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2083/// # .with_native_roots()
2084/// # .unwrap()
2085/// # .https_only()
2086/// # .enable_http2()
2087/// # .build();
2088///
2089/// # let executor = hyper_util::rt::TokioExecutor::new();
2090/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2091/// # secret,
2092/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2093/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2094/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2095/// # ),
2096/// # ).build().await.unwrap();
2097///
2098/// # let client = hyper_util::client::legacy::Client::builder(
2099/// # hyper_util::rt::TokioExecutor::new()
2100/// # )
2101/// # .build(
2102/// # hyper_rustls::HttpsConnectorBuilder::new()
2103/// # .with_native_roots()
2104/// # .unwrap()
2105/// # .https_or_http()
2106/// # .enable_http2()
2107/// # .build()
2108/// # );
2109/// # let mut hub = BigQueryReservation::new(client, auth);
2110/// // You can configure optional parameters by calling the respective setters at will, and
2111/// // execute the final call using `doit()`.
2112/// // Values shown here are possibly random and not representative !
2113/// let result = hub.projects().locations_capacity_commitments_delete("name")
2114/// .force(true)
2115/// .doit().await;
2116/// # }
2117/// ```
2118pub struct ProjectLocationCapacityCommitmentDeleteCall<'a, C>
2119where
2120 C: 'a,
2121{
2122 hub: &'a BigQueryReservation<C>,
2123 _name: String,
2124 _force: Option<bool>,
2125 _delegate: Option<&'a mut dyn common::Delegate>,
2126 _additional_params: HashMap<String, String>,
2127 _scopes: BTreeSet<String>,
2128}
2129
2130impl<'a, C> common::CallBuilder for ProjectLocationCapacityCommitmentDeleteCall<'a, C> {}
2131
2132impl<'a, C> ProjectLocationCapacityCommitmentDeleteCall<'a, C>
2133where
2134 C: common::Connector,
2135{
2136 /// Perform the operation you have build so far.
2137 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
2138 use std::borrow::Cow;
2139 use std::io::{Read, Seek};
2140
2141 use common::{url::Params, ToParts};
2142 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2143
2144 let mut dd = common::DefaultDelegate;
2145 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2146 dlg.begin(common::MethodInfo {
2147 id: "bigqueryreservation.projects.locations.capacityCommitments.delete",
2148 http_method: hyper::Method::DELETE,
2149 });
2150
2151 for &field in ["alt", "name", "force"].iter() {
2152 if self._additional_params.contains_key(field) {
2153 dlg.finished(false);
2154 return Err(common::Error::FieldClash(field));
2155 }
2156 }
2157
2158 let mut params = Params::with_capacity(4 + self._additional_params.len());
2159 params.push("name", self._name);
2160 if let Some(value) = self._force.as_ref() {
2161 params.push("force", value.to_string());
2162 }
2163
2164 params.extend(self._additional_params.iter());
2165
2166 params.push("alt", "json");
2167 let mut url = self.hub._base_url.clone() + "v1/{+name}";
2168 if self._scopes.is_empty() {
2169 self._scopes
2170 .insert(Scope::CloudPlatform.as_ref().to_string());
2171 }
2172
2173 #[allow(clippy::single_element_loop)]
2174 for &(find_this, param_name) in [("{+name}", "name")].iter() {
2175 url = params.uri_replacement(url, param_name, find_this, true);
2176 }
2177 {
2178 let to_remove = ["name"];
2179 params.remove_params(&to_remove);
2180 }
2181
2182 let url = params.parse_with_url(&url);
2183
2184 loop {
2185 let token = match self
2186 .hub
2187 .auth
2188 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2189 .await
2190 {
2191 Ok(token) => token,
2192 Err(e) => match dlg.token(e) {
2193 Ok(token) => token,
2194 Err(e) => {
2195 dlg.finished(false);
2196 return Err(common::Error::MissingToken(e));
2197 }
2198 },
2199 };
2200 let mut req_result = {
2201 let client = &self.hub.client;
2202 dlg.pre_request();
2203 let mut req_builder = hyper::Request::builder()
2204 .method(hyper::Method::DELETE)
2205 .uri(url.as_str())
2206 .header(USER_AGENT, self.hub._user_agent.clone());
2207
2208 if let Some(token) = token.as_ref() {
2209 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2210 }
2211
2212 let request = req_builder
2213 .header(CONTENT_LENGTH, 0_u64)
2214 .body(common::to_body::<String>(None));
2215
2216 client.request(request.unwrap()).await
2217 };
2218
2219 match req_result {
2220 Err(err) => {
2221 if let common::Retry::After(d) = dlg.http_error(&err) {
2222 sleep(d).await;
2223 continue;
2224 }
2225 dlg.finished(false);
2226 return Err(common::Error::HttpError(err));
2227 }
2228 Ok(res) => {
2229 let (mut parts, body) = res.into_parts();
2230 let mut body = common::Body::new(body);
2231 if !parts.status.is_success() {
2232 let bytes = common::to_bytes(body).await.unwrap_or_default();
2233 let error = serde_json::from_str(&common::to_string(&bytes));
2234 let response = common::to_response(parts, bytes.into());
2235
2236 if let common::Retry::After(d) =
2237 dlg.http_failure(&response, error.as_ref().ok())
2238 {
2239 sleep(d).await;
2240 continue;
2241 }
2242
2243 dlg.finished(false);
2244
2245 return Err(match error {
2246 Ok(value) => common::Error::BadRequest(value),
2247 _ => common::Error::Failure(response),
2248 });
2249 }
2250 let response = {
2251 let bytes = common::to_bytes(body).await.unwrap_or_default();
2252 let encoded = common::to_string(&bytes);
2253 match serde_json::from_str(&encoded) {
2254 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2255 Err(error) => {
2256 dlg.response_json_decode_error(&encoded, &error);
2257 return Err(common::Error::JsonDecodeError(
2258 encoded.to_string(),
2259 error,
2260 ));
2261 }
2262 }
2263 };
2264
2265 dlg.finished(true);
2266 return Ok(response);
2267 }
2268 }
2269 }
2270 }
2271
2272 /// Required. Resource name of the capacity commitment to delete. E.g., `projects/myproject/locations/US/capacityCommitments/123`
2273 ///
2274 /// Sets the *name* path property to the given value.
2275 ///
2276 /// Even though the property as already been set when instantiating this call,
2277 /// we provide this method for API completeness.
2278 pub fn name(mut self, new_value: &str) -> ProjectLocationCapacityCommitmentDeleteCall<'a, C> {
2279 self._name = new_value.to_string();
2280 self
2281 }
2282 /// Can be used to force delete commitments even if assignments exist. Deleting commitments with assignments may cause queries to fail if they no longer have access to slots.
2283 ///
2284 /// Sets the *force* query property to the given value.
2285 pub fn force(mut self, new_value: bool) -> ProjectLocationCapacityCommitmentDeleteCall<'a, C> {
2286 self._force = Some(new_value);
2287 self
2288 }
2289 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2290 /// while executing the actual API request.
2291 ///
2292 /// ````text
2293 /// It should be used to handle progress information, and to implement a certain level of resilience.
2294 /// ````
2295 ///
2296 /// Sets the *delegate* property to the given value.
2297 pub fn delegate(
2298 mut self,
2299 new_value: &'a mut dyn common::Delegate,
2300 ) -> ProjectLocationCapacityCommitmentDeleteCall<'a, C> {
2301 self._delegate = Some(new_value);
2302 self
2303 }
2304
2305 /// Set any additional parameter of the query string used in the request.
2306 /// It should be used to set parameters which are not yet available through their own
2307 /// setters.
2308 ///
2309 /// Please note that this method must not be used to set any of the known parameters
2310 /// which have their own setter method. If done anyway, the request will fail.
2311 ///
2312 /// # Additional Parameters
2313 ///
2314 /// * *$.xgafv* (query-string) - V1 error format.
2315 /// * *access_token* (query-string) - OAuth access token.
2316 /// * *alt* (query-string) - Data format for response.
2317 /// * *callback* (query-string) - JSONP
2318 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2319 /// * *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.
2320 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2321 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2322 /// * *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.
2323 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2324 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2325 pub fn param<T>(
2326 mut self,
2327 name: T,
2328 value: T,
2329 ) -> ProjectLocationCapacityCommitmentDeleteCall<'a, C>
2330 where
2331 T: AsRef<str>,
2332 {
2333 self._additional_params
2334 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2335 self
2336 }
2337
2338 /// Identifies the authorization scope for the method you are building.
2339 ///
2340 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2341 /// [`Scope::CloudPlatform`].
2342 ///
2343 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2344 /// tokens for more than one scope.
2345 ///
2346 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2347 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2348 /// sufficient, a read-write scope will do as well.
2349 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCapacityCommitmentDeleteCall<'a, C>
2350 where
2351 St: AsRef<str>,
2352 {
2353 self._scopes.insert(String::from(scope.as_ref()));
2354 self
2355 }
2356 /// Identifies the authorization scope(s) for the method you are building.
2357 ///
2358 /// See [`Self::add_scope()`] for details.
2359 pub fn add_scopes<I, St>(
2360 mut self,
2361 scopes: I,
2362 ) -> ProjectLocationCapacityCommitmentDeleteCall<'a, C>
2363 where
2364 I: IntoIterator<Item = St>,
2365 St: AsRef<str>,
2366 {
2367 self._scopes
2368 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2369 self
2370 }
2371
2372 /// Removes all scopes, and no default scope will be used either.
2373 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2374 /// for details).
2375 pub fn clear_scopes(mut self) -> ProjectLocationCapacityCommitmentDeleteCall<'a, C> {
2376 self._scopes.clear();
2377 self
2378 }
2379}
2380
2381/// Returns information about the capacity commitment.
2382///
2383/// A builder for the *locations.capacityCommitments.get* method supported by a *project* resource.
2384/// It is not used directly, but through a [`ProjectMethods`] instance.
2385///
2386/// # Example
2387///
2388/// Instantiate a resource method builder
2389///
2390/// ```test_harness,no_run
2391/// # extern crate hyper;
2392/// # extern crate hyper_rustls;
2393/// # extern crate google_bigqueryreservation1 as bigqueryreservation1;
2394/// # async fn dox() {
2395/// # use bigqueryreservation1::{BigQueryReservation, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2396///
2397/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2398/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2399/// # .with_native_roots()
2400/// # .unwrap()
2401/// # .https_only()
2402/// # .enable_http2()
2403/// # .build();
2404///
2405/// # let executor = hyper_util::rt::TokioExecutor::new();
2406/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2407/// # secret,
2408/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2409/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2410/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2411/// # ),
2412/// # ).build().await.unwrap();
2413///
2414/// # let client = hyper_util::client::legacy::Client::builder(
2415/// # hyper_util::rt::TokioExecutor::new()
2416/// # )
2417/// # .build(
2418/// # hyper_rustls::HttpsConnectorBuilder::new()
2419/// # .with_native_roots()
2420/// # .unwrap()
2421/// # .https_or_http()
2422/// # .enable_http2()
2423/// # .build()
2424/// # );
2425/// # let mut hub = BigQueryReservation::new(client, auth);
2426/// // You can configure optional parameters by calling the respective setters at will, and
2427/// // execute the final call using `doit()`.
2428/// // Values shown here are possibly random and not representative !
2429/// let result = hub.projects().locations_capacity_commitments_get("name")
2430/// .doit().await;
2431/// # }
2432/// ```
2433pub struct ProjectLocationCapacityCommitmentGetCall<'a, C>
2434where
2435 C: 'a,
2436{
2437 hub: &'a BigQueryReservation<C>,
2438 _name: String,
2439 _delegate: Option<&'a mut dyn common::Delegate>,
2440 _additional_params: HashMap<String, String>,
2441 _scopes: BTreeSet<String>,
2442}
2443
2444impl<'a, C> common::CallBuilder for ProjectLocationCapacityCommitmentGetCall<'a, C> {}
2445
2446impl<'a, C> ProjectLocationCapacityCommitmentGetCall<'a, C>
2447where
2448 C: common::Connector,
2449{
2450 /// Perform the operation you have build so far.
2451 pub async fn doit(mut self) -> common::Result<(common::Response, CapacityCommitment)> {
2452 use std::borrow::Cow;
2453 use std::io::{Read, Seek};
2454
2455 use common::{url::Params, ToParts};
2456 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2457
2458 let mut dd = common::DefaultDelegate;
2459 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2460 dlg.begin(common::MethodInfo {
2461 id: "bigqueryreservation.projects.locations.capacityCommitments.get",
2462 http_method: hyper::Method::GET,
2463 });
2464
2465 for &field in ["alt", "name"].iter() {
2466 if self._additional_params.contains_key(field) {
2467 dlg.finished(false);
2468 return Err(common::Error::FieldClash(field));
2469 }
2470 }
2471
2472 let mut params = Params::with_capacity(3 + self._additional_params.len());
2473 params.push("name", self._name);
2474
2475 params.extend(self._additional_params.iter());
2476
2477 params.push("alt", "json");
2478 let mut url = self.hub._base_url.clone() + "v1/{+name}";
2479 if self._scopes.is_empty() {
2480 self._scopes
2481 .insert(Scope::CloudPlatform.as_ref().to_string());
2482 }
2483
2484 #[allow(clippy::single_element_loop)]
2485 for &(find_this, param_name) in [("{+name}", "name")].iter() {
2486 url = params.uri_replacement(url, param_name, find_this, true);
2487 }
2488 {
2489 let to_remove = ["name"];
2490 params.remove_params(&to_remove);
2491 }
2492
2493 let url = params.parse_with_url(&url);
2494
2495 loop {
2496 let token = match self
2497 .hub
2498 .auth
2499 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2500 .await
2501 {
2502 Ok(token) => token,
2503 Err(e) => match dlg.token(e) {
2504 Ok(token) => token,
2505 Err(e) => {
2506 dlg.finished(false);
2507 return Err(common::Error::MissingToken(e));
2508 }
2509 },
2510 };
2511 let mut req_result = {
2512 let client = &self.hub.client;
2513 dlg.pre_request();
2514 let mut req_builder = hyper::Request::builder()
2515 .method(hyper::Method::GET)
2516 .uri(url.as_str())
2517 .header(USER_AGENT, self.hub._user_agent.clone());
2518
2519 if let Some(token) = token.as_ref() {
2520 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2521 }
2522
2523 let request = req_builder
2524 .header(CONTENT_LENGTH, 0_u64)
2525 .body(common::to_body::<String>(None));
2526
2527 client.request(request.unwrap()).await
2528 };
2529
2530 match req_result {
2531 Err(err) => {
2532 if let common::Retry::After(d) = dlg.http_error(&err) {
2533 sleep(d).await;
2534 continue;
2535 }
2536 dlg.finished(false);
2537 return Err(common::Error::HttpError(err));
2538 }
2539 Ok(res) => {
2540 let (mut parts, body) = res.into_parts();
2541 let mut body = common::Body::new(body);
2542 if !parts.status.is_success() {
2543 let bytes = common::to_bytes(body).await.unwrap_or_default();
2544 let error = serde_json::from_str(&common::to_string(&bytes));
2545 let response = common::to_response(parts, bytes.into());
2546
2547 if let common::Retry::After(d) =
2548 dlg.http_failure(&response, error.as_ref().ok())
2549 {
2550 sleep(d).await;
2551 continue;
2552 }
2553
2554 dlg.finished(false);
2555
2556 return Err(match error {
2557 Ok(value) => common::Error::BadRequest(value),
2558 _ => common::Error::Failure(response),
2559 });
2560 }
2561 let response = {
2562 let bytes = common::to_bytes(body).await.unwrap_or_default();
2563 let encoded = common::to_string(&bytes);
2564 match serde_json::from_str(&encoded) {
2565 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2566 Err(error) => {
2567 dlg.response_json_decode_error(&encoded, &error);
2568 return Err(common::Error::JsonDecodeError(
2569 encoded.to_string(),
2570 error,
2571 ));
2572 }
2573 }
2574 };
2575
2576 dlg.finished(true);
2577 return Ok(response);
2578 }
2579 }
2580 }
2581 }
2582
2583 /// Required. Resource name of the capacity commitment to retrieve. E.g., `projects/myproject/locations/US/capacityCommitments/123`
2584 ///
2585 /// Sets the *name* path property to the given value.
2586 ///
2587 /// Even though the property as already been set when instantiating this call,
2588 /// we provide this method for API completeness.
2589 pub fn name(mut self, new_value: &str) -> ProjectLocationCapacityCommitmentGetCall<'a, C> {
2590 self._name = new_value.to_string();
2591 self
2592 }
2593 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2594 /// while executing the actual API request.
2595 ///
2596 /// ````text
2597 /// It should be used to handle progress information, and to implement a certain level of resilience.
2598 /// ````
2599 ///
2600 /// Sets the *delegate* property to the given value.
2601 pub fn delegate(
2602 mut self,
2603 new_value: &'a mut dyn common::Delegate,
2604 ) -> ProjectLocationCapacityCommitmentGetCall<'a, C> {
2605 self._delegate = Some(new_value);
2606 self
2607 }
2608
2609 /// Set any additional parameter of the query string used in the request.
2610 /// It should be used to set parameters which are not yet available through their own
2611 /// setters.
2612 ///
2613 /// Please note that this method must not be used to set any of the known parameters
2614 /// which have their own setter method. If done anyway, the request will fail.
2615 ///
2616 /// # Additional Parameters
2617 ///
2618 /// * *$.xgafv* (query-string) - V1 error format.
2619 /// * *access_token* (query-string) - OAuth access token.
2620 /// * *alt* (query-string) - Data format for response.
2621 /// * *callback* (query-string) - JSONP
2622 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2623 /// * *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.
2624 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2625 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2626 /// * *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.
2627 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2628 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2629 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationCapacityCommitmentGetCall<'a, C>
2630 where
2631 T: AsRef<str>,
2632 {
2633 self._additional_params
2634 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2635 self
2636 }
2637
2638 /// Identifies the authorization scope for the method you are building.
2639 ///
2640 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2641 /// [`Scope::CloudPlatform`].
2642 ///
2643 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2644 /// tokens for more than one scope.
2645 ///
2646 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2647 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2648 /// sufficient, a read-write scope will do as well.
2649 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCapacityCommitmentGetCall<'a, C>
2650 where
2651 St: AsRef<str>,
2652 {
2653 self._scopes.insert(String::from(scope.as_ref()));
2654 self
2655 }
2656 /// Identifies the authorization scope(s) for the method you are building.
2657 ///
2658 /// See [`Self::add_scope()`] for details.
2659 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationCapacityCommitmentGetCall<'a, C>
2660 where
2661 I: IntoIterator<Item = St>,
2662 St: AsRef<str>,
2663 {
2664 self._scopes
2665 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2666 self
2667 }
2668
2669 /// Removes all scopes, and no default scope will be used either.
2670 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
2671 /// for details).
2672 pub fn clear_scopes(mut self) -> ProjectLocationCapacityCommitmentGetCall<'a, C> {
2673 self._scopes.clear();
2674 self
2675 }
2676}
2677
2678/// Lists all the capacity commitments for the admin project.
2679///
2680/// A builder for the *locations.capacityCommitments.list* method supported by a *project* resource.
2681/// It is not used directly, but through a [`ProjectMethods`] instance.
2682///
2683/// # Example
2684///
2685/// Instantiate a resource method builder
2686///
2687/// ```test_harness,no_run
2688/// # extern crate hyper;
2689/// # extern crate hyper_rustls;
2690/// # extern crate google_bigqueryreservation1 as bigqueryreservation1;
2691/// # async fn dox() {
2692/// # use bigqueryreservation1::{BigQueryReservation, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
2693///
2694/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
2695/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
2696/// # .with_native_roots()
2697/// # .unwrap()
2698/// # .https_only()
2699/// # .enable_http2()
2700/// # .build();
2701///
2702/// # let executor = hyper_util::rt::TokioExecutor::new();
2703/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
2704/// # secret,
2705/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
2706/// # yup_oauth2::client::CustomHyperClientBuilder::from(
2707/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
2708/// # ),
2709/// # ).build().await.unwrap();
2710///
2711/// # let client = hyper_util::client::legacy::Client::builder(
2712/// # hyper_util::rt::TokioExecutor::new()
2713/// # )
2714/// # .build(
2715/// # hyper_rustls::HttpsConnectorBuilder::new()
2716/// # .with_native_roots()
2717/// # .unwrap()
2718/// # .https_or_http()
2719/// # .enable_http2()
2720/// # .build()
2721/// # );
2722/// # let mut hub = BigQueryReservation::new(client, auth);
2723/// // You can configure optional parameters by calling the respective setters at will, and
2724/// // execute the final call using `doit()`.
2725/// // Values shown here are possibly random and not representative !
2726/// let result = hub.projects().locations_capacity_commitments_list("parent")
2727/// .page_token("gubergren")
2728/// .page_size(-51)
2729/// .doit().await;
2730/// # }
2731/// ```
2732pub struct ProjectLocationCapacityCommitmentListCall<'a, C>
2733where
2734 C: 'a,
2735{
2736 hub: &'a BigQueryReservation<C>,
2737 _parent: String,
2738 _page_token: Option<String>,
2739 _page_size: Option<i32>,
2740 _delegate: Option<&'a mut dyn common::Delegate>,
2741 _additional_params: HashMap<String, String>,
2742 _scopes: BTreeSet<String>,
2743}
2744
2745impl<'a, C> common::CallBuilder for ProjectLocationCapacityCommitmentListCall<'a, C> {}
2746
2747impl<'a, C> ProjectLocationCapacityCommitmentListCall<'a, C>
2748where
2749 C: common::Connector,
2750{
2751 /// Perform the operation you have build so far.
2752 pub async fn doit(
2753 mut self,
2754 ) -> common::Result<(common::Response, ListCapacityCommitmentsResponse)> {
2755 use std::borrow::Cow;
2756 use std::io::{Read, Seek};
2757
2758 use common::{url::Params, ToParts};
2759 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
2760
2761 let mut dd = common::DefaultDelegate;
2762 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
2763 dlg.begin(common::MethodInfo {
2764 id: "bigqueryreservation.projects.locations.capacityCommitments.list",
2765 http_method: hyper::Method::GET,
2766 });
2767
2768 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
2769 if self._additional_params.contains_key(field) {
2770 dlg.finished(false);
2771 return Err(common::Error::FieldClash(field));
2772 }
2773 }
2774
2775 let mut params = Params::with_capacity(5 + self._additional_params.len());
2776 params.push("parent", self._parent);
2777 if let Some(value) = self._page_token.as_ref() {
2778 params.push("pageToken", value);
2779 }
2780 if let Some(value) = self._page_size.as_ref() {
2781 params.push("pageSize", value.to_string());
2782 }
2783
2784 params.extend(self._additional_params.iter());
2785
2786 params.push("alt", "json");
2787 let mut url = self.hub._base_url.clone() + "v1/{+parent}/capacityCommitments";
2788 if self._scopes.is_empty() {
2789 self._scopes
2790 .insert(Scope::CloudPlatform.as_ref().to_string());
2791 }
2792
2793 #[allow(clippy::single_element_loop)]
2794 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
2795 url = params.uri_replacement(url, param_name, find_this, true);
2796 }
2797 {
2798 let to_remove = ["parent"];
2799 params.remove_params(&to_remove);
2800 }
2801
2802 let url = params.parse_with_url(&url);
2803
2804 loop {
2805 let token = match self
2806 .hub
2807 .auth
2808 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
2809 .await
2810 {
2811 Ok(token) => token,
2812 Err(e) => match dlg.token(e) {
2813 Ok(token) => token,
2814 Err(e) => {
2815 dlg.finished(false);
2816 return Err(common::Error::MissingToken(e));
2817 }
2818 },
2819 };
2820 let mut req_result = {
2821 let client = &self.hub.client;
2822 dlg.pre_request();
2823 let mut req_builder = hyper::Request::builder()
2824 .method(hyper::Method::GET)
2825 .uri(url.as_str())
2826 .header(USER_AGENT, self.hub._user_agent.clone());
2827
2828 if let Some(token) = token.as_ref() {
2829 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
2830 }
2831
2832 let request = req_builder
2833 .header(CONTENT_LENGTH, 0_u64)
2834 .body(common::to_body::<String>(None));
2835
2836 client.request(request.unwrap()).await
2837 };
2838
2839 match req_result {
2840 Err(err) => {
2841 if let common::Retry::After(d) = dlg.http_error(&err) {
2842 sleep(d).await;
2843 continue;
2844 }
2845 dlg.finished(false);
2846 return Err(common::Error::HttpError(err));
2847 }
2848 Ok(res) => {
2849 let (mut parts, body) = res.into_parts();
2850 let mut body = common::Body::new(body);
2851 if !parts.status.is_success() {
2852 let bytes = common::to_bytes(body).await.unwrap_or_default();
2853 let error = serde_json::from_str(&common::to_string(&bytes));
2854 let response = common::to_response(parts, bytes.into());
2855
2856 if let common::Retry::After(d) =
2857 dlg.http_failure(&response, error.as_ref().ok())
2858 {
2859 sleep(d).await;
2860 continue;
2861 }
2862
2863 dlg.finished(false);
2864
2865 return Err(match error {
2866 Ok(value) => common::Error::BadRequest(value),
2867 _ => common::Error::Failure(response),
2868 });
2869 }
2870 let response = {
2871 let bytes = common::to_bytes(body).await.unwrap_or_default();
2872 let encoded = common::to_string(&bytes);
2873 match serde_json::from_str(&encoded) {
2874 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
2875 Err(error) => {
2876 dlg.response_json_decode_error(&encoded, &error);
2877 return Err(common::Error::JsonDecodeError(
2878 encoded.to_string(),
2879 error,
2880 ));
2881 }
2882 }
2883 };
2884
2885 dlg.finished(true);
2886 return Ok(response);
2887 }
2888 }
2889 }
2890 }
2891
2892 /// Required. Resource name of the parent reservation. E.g., `projects/myproject/locations/US`
2893 ///
2894 /// Sets the *parent* path property to the given value.
2895 ///
2896 /// Even though the property as already been set when instantiating this call,
2897 /// we provide this method for API completeness.
2898 pub fn parent(mut self, new_value: &str) -> ProjectLocationCapacityCommitmentListCall<'a, C> {
2899 self._parent = new_value.to_string();
2900 self
2901 }
2902 /// The next_page_token value returned from a previous List request, if any.
2903 ///
2904 /// Sets the *page token* query property to the given value.
2905 pub fn page_token(
2906 mut self,
2907 new_value: &str,
2908 ) -> ProjectLocationCapacityCommitmentListCall<'a, C> {
2909 self._page_token = Some(new_value.to_string());
2910 self
2911 }
2912 /// The maximum number of items to return.
2913 ///
2914 /// Sets the *page size* query property to the given value.
2915 pub fn page_size(mut self, new_value: i32) -> ProjectLocationCapacityCommitmentListCall<'a, C> {
2916 self._page_size = Some(new_value);
2917 self
2918 }
2919 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
2920 /// while executing the actual API request.
2921 ///
2922 /// ````text
2923 /// It should be used to handle progress information, and to implement a certain level of resilience.
2924 /// ````
2925 ///
2926 /// Sets the *delegate* property to the given value.
2927 pub fn delegate(
2928 mut self,
2929 new_value: &'a mut dyn common::Delegate,
2930 ) -> ProjectLocationCapacityCommitmentListCall<'a, C> {
2931 self._delegate = Some(new_value);
2932 self
2933 }
2934
2935 /// Set any additional parameter of the query string used in the request.
2936 /// It should be used to set parameters which are not yet available through their own
2937 /// setters.
2938 ///
2939 /// Please note that this method must not be used to set any of the known parameters
2940 /// which have their own setter method. If done anyway, the request will fail.
2941 ///
2942 /// # Additional Parameters
2943 ///
2944 /// * *$.xgafv* (query-string) - V1 error format.
2945 /// * *access_token* (query-string) - OAuth access token.
2946 /// * *alt* (query-string) - Data format for response.
2947 /// * *callback* (query-string) - JSONP
2948 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
2949 /// * *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.
2950 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
2951 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
2952 /// * *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.
2953 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
2954 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
2955 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationCapacityCommitmentListCall<'a, C>
2956 where
2957 T: AsRef<str>,
2958 {
2959 self._additional_params
2960 .insert(name.as_ref().to_string(), value.as_ref().to_string());
2961 self
2962 }
2963
2964 /// Identifies the authorization scope for the method you are building.
2965 ///
2966 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
2967 /// [`Scope::CloudPlatform`].
2968 ///
2969 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
2970 /// tokens for more than one scope.
2971 ///
2972 /// Usually there is more than one suitable scope to authorize an operation, some of which may
2973 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
2974 /// sufficient, a read-write scope will do as well.
2975 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCapacityCommitmentListCall<'a, C>
2976 where
2977 St: AsRef<str>,
2978 {
2979 self._scopes.insert(String::from(scope.as_ref()));
2980 self
2981 }
2982 /// Identifies the authorization scope(s) for the method you are building.
2983 ///
2984 /// See [`Self::add_scope()`] for details.
2985 pub fn add_scopes<I, St>(
2986 mut self,
2987 scopes: I,
2988 ) -> ProjectLocationCapacityCommitmentListCall<'a, C>
2989 where
2990 I: IntoIterator<Item = St>,
2991 St: AsRef<str>,
2992 {
2993 self._scopes
2994 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
2995 self
2996 }
2997
2998 /// Removes all scopes, and no default scope will be used either.
2999 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3000 /// for details).
3001 pub fn clear_scopes(mut self) -> ProjectLocationCapacityCommitmentListCall<'a, C> {
3002 self._scopes.clear();
3003 self
3004 }
3005}
3006
3007/// Merges capacity commitments of the same plan into a single commitment. The resulting capacity commitment has the greater commitment_end_time out of the to-be-merged capacity commitments. Attempting to merge capacity commitments of different plan will fail with the error code `google.rpc.Code.FAILED_PRECONDITION`.
3008///
3009/// A builder for the *locations.capacityCommitments.merge* method supported by a *project* resource.
3010/// It is not used directly, but through a [`ProjectMethods`] instance.
3011///
3012/// # Example
3013///
3014/// Instantiate a resource method builder
3015///
3016/// ```test_harness,no_run
3017/// # extern crate hyper;
3018/// # extern crate hyper_rustls;
3019/// # extern crate google_bigqueryreservation1 as bigqueryreservation1;
3020/// use bigqueryreservation1::api::MergeCapacityCommitmentsRequest;
3021/// # async fn dox() {
3022/// # use bigqueryreservation1::{BigQueryReservation, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3023///
3024/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3025/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3026/// # .with_native_roots()
3027/// # .unwrap()
3028/// # .https_only()
3029/// # .enable_http2()
3030/// # .build();
3031///
3032/// # let executor = hyper_util::rt::TokioExecutor::new();
3033/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3034/// # secret,
3035/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3036/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3037/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3038/// # ),
3039/// # ).build().await.unwrap();
3040///
3041/// # let client = hyper_util::client::legacy::Client::builder(
3042/// # hyper_util::rt::TokioExecutor::new()
3043/// # )
3044/// # .build(
3045/// # hyper_rustls::HttpsConnectorBuilder::new()
3046/// # .with_native_roots()
3047/// # .unwrap()
3048/// # .https_or_http()
3049/// # .enable_http2()
3050/// # .build()
3051/// # );
3052/// # let mut hub = BigQueryReservation::new(client, auth);
3053/// // As the method needs a request, you would usually fill it with the desired information
3054/// // into the respective structure. Some of the parts shown here might not be applicable !
3055/// // Values shown here are possibly random and not representative !
3056/// let mut req = MergeCapacityCommitmentsRequest::default();
3057///
3058/// // You can configure optional parameters by calling the respective setters at will, and
3059/// // execute the final call using `doit()`.
3060/// // Values shown here are possibly random and not representative !
3061/// let result = hub.projects().locations_capacity_commitments_merge(req, "parent")
3062/// .doit().await;
3063/// # }
3064/// ```
3065pub struct ProjectLocationCapacityCommitmentMergeCall<'a, C>
3066where
3067 C: 'a,
3068{
3069 hub: &'a BigQueryReservation<C>,
3070 _request: MergeCapacityCommitmentsRequest,
3071 _parent: String,
3072 _delegate: Option<&'a mut dyn common::Delegate>,
3073 _additional_params: HashMap<String, String>,
3074 _scopes: BTreeSet<String>,
3075}
3076
3077impl<'a, C> common::CallBuilder for ProjectLocationCapacityCommitmentMergeCall<'a, C> {}
3078
3079impl<'a, C> ProjectLocationCapacityCommitmentMergeCall<'a, C>
3080where
3081 C: common::Connector,
3082{
3083 /// Perform the operation you have build so far.
3084 pub async fn doit(mut self) -> common::Result<(common::Response, CapacityCommitment)> {
3085 use std::borrow::Cow;
3086 use std::io::{Read, Seek};
3087
3088 use common::{url::Params, ToParts};
3089 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3090
3091 let mut dd = common::DefaultDelegate;
3092 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3093 dlg.begin(common::MethodInfo {
3094 id: "bigqueryreservation.projects.locations.capacityCommitments.merge",
3095 http_method: hyper::Method::POST,
3096 });
3097
3098 for &field in ["alt", "parent"].iter() {
3099 if self._additional_params.contains_key(field) {
3100 dlg.finished(false);
3101 return Err(common::Error::FieldClash(field));
3102 }
3103 }
3104
3105 let mut params = Params::with_capacity(4 + self._additional_params.len());
3106 params.push("parent", self._parent);
3107
3108 params.extend(self._additional_params.iter());
3109
3110 params.push("alt", "json");
3111 let mut url = self.hub._base_url.clone() + "v1/{+parent}/capacityCommitments:merge";
3112 if self._scopes.is_empty() {
3113 self._scopes
3114 .insert(Scope::CloudPlatform.as_ref().to_string());
3115 }
3116
3117 #[allow(clippy::single_element_loop)]
3118 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
3119 url = params.uri_replacement(url, param_name, find_this, true);
3120 }
3121 {
3122 let to_remove = ["parent"];
3123 params.remove_params(&to_remove);
3124 }
3125
3126 let url = params.parse_with_url(&url);
3127
3128 let mut json_mime_type = mime::APPLICATION_JSON;
3129 let mut request_value_reader = {
3130 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3131 common::remove_json_null_values(&mut value);
3132 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3133 serde_json::to_writer(&mut dst, &value).unwrap();
3134 dst
3135 };
3136 let request_size = request_value_reader
3137 .seek(std::io::SeekFrom::End(0))
3138 .unwrap();
3139 request_value_reader
3140 .seek(std::io::SeekFrom::Start(0))
3141 .unwrap();
3142
3143 loop {
3144 let token = match self
3145 .hub
3146 .auth
3147 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3148 .await
3149 {
3150 Ok(token) => token,
3151 Err(e) => match dlg.token(e) {
3152 Ok(token) => token,
3153 Err(e) => {
3154 dlg.finished(false);
3155 return Err(common::Error::MissingToken(e));
3156 }
3157 },
3158 };
3159 request_value_reader
3160 .seek(std::io::SeekFrom::Start(0))
3161 .unwrap();
3162 let mut req_result = {
3163 let client = &self.hub.client;
3164 dlg.pre_request();
3165 let mut req_builder = hyper::Request::builder()
3166 .method(hyper::Method::POST)
3167 .uri(url.as_str())
3168 .header(USER_AGENT, self.hub._user_agent.clone());
3169
3170 if let Some(token) = token.as_ref() {
3171 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3172 }
3173
3174 let request = req_builder
3175 .header(CONTENT_TYPE, json_mime_type.to_string())
3176 .header(CONTENT_LENGTH, request_size as u64)
3177 .body(common::to_body(
3178 request_value_reader.get_ref().clone().into(),
3179 ));
3180
3181 client.request(request.unwrap()).await
3182 };
3183
3184 match req_result {
3185 Err(err) => {
3186 if let common::Retry::After(d) = dlg.http_error(&err) {
3187 sleep(d).await;
3188 continue;
3189 }
3190 dlg.finished(false);
3191 return Err(common::Error::HttpError(err));
3192 }
3193 Ok(res) => {
3194 let (mut parts, body) = res.into_parts();
3195 let mut body = common::Body::new(body);
3196 if !parts.status.is_success() {
3197 let bytes = common::to_bytes(body).await.unwrap_or_default();
3198 let error = serde_json::from_str(&common::to_string(&bytes));
3199 let response = common::to_response(parts, bytes.into());
3200
3201 if let common::Retry::After(d) =
3202 dlg.http_failure(&response, error.as_ref().ok())
3203 {
3204 sleep(d).await;
3205 continue;
3206 }
3207
3208 dlg.finished(false);
3209
3210 return Err(match error {
3211 Ok(value) => common::Error::BadRequest(value),
3212 _ => common::Error::Failure(response),
3213 });
3214 }
3215 let response = {
3216 let bytes = common::to_bytes(body).await.unwrap_or_default();
3217 let encoded = common::to_string(&bytes);
3218 match serde_json::from_str(&encoded) {
3219 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3220 Err(error) => {
3221 dlg.response_json_decode_error(&encoded, &error);
3222 return Err(common::Error::JsonDecodeError(
3223 encoded.to_string(),
3224 error,
3225 ));
3226 }
3227 }
3228 };
3229
3230 dlg.finished(true);
3231 return Ok(response);
3232 }
3233 }
3234 }
3235 }
3236
3237 ///
3238 /// Sets the *request* property to the given value.
3239 ///
3240 /// Even though the property as already been set when instantiating this call,
3241 /// we provide this method for API completeness.
3242 pub fn request(
3243 mut self,
3244 new_value: MergeCapacityCommitmentsRequest,
3245 ) -> ProjectLocationCapacityCommitmentMergeCall<'a, C> {
3246 self._request = new_value;
3247 self
3248 }
3249 /// Parent resource that identifies admin project and location e.g., `projects/myproject/locations/us`
3250 ///
3251 /// Sets the *parent* path property to the given value.
3252 ///
3253 /// Even though the property as already been set when instantiating this call,
3254 /// we provide this method for API completeness.
3255 pub fn parent(mut self, new_value: &str) -> ProjectLocationCapacityCommitmentMergeCall<'a, C> {
3256 self._parent = new_value.to_string();
3257 self
3258 }
3259 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3260 /// while executing the actual API request.
3261 ///
3262 /// ````text
3263 /// It should be used to handle progress information, and to implement a certain level of resilience.
3264 /// ````
3265 ///
3266 /// Sets the *delegate* property to the given value.
3267 pub fn delegate(
3268 mut self,
3269 new_value: &'a mut dyn common::Delegate,
3270 ) -> ProjectLocationCapacityCommitmentMergeCall<'a, C> {
3271 self._delegate = Some(new_value);
3272 self
3273 }
3274
3275 /// Set any additional parameter of the query string used in the request.
3276 /// It should be used to set parameters which are not yet available through their own
3277 /// setters.
3278 ///
3279 /// Please note that this method must not be used to set any of the known parameters
3280 /// which have their own setter method. If done anyway, the request will fail.
3281 ///
3282 /// # Additional Parameters
3283 ///
3284 /// * *$.xgafv* (query-string) - V1 error format.
3285 /// * *access_token* (query-string) - OAuth access token.
3286 /// * *alt* (query-string) - Data format for response.
3287 /// * *callback* (query-string) - JSONP
3288 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3289 /// * *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.
3290 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3291 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3292 /// * *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.
3293 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3294 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3295 pub fn param<T>(
3296 mut self,
3297 name: T,
3298 value: T,
3299 ) -> ProjectLocationCapacityCommitmentMergeCall<'a, C>
3300 where
3301 T: AsRef<str>,
3302 {
3303 self._additional_params
3304 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3305 self
3306 }
3307
3308 /// Identifies the authorization scope for the method you are building.
3309 ///
3310 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3311 /// [`Scope::CloudPlatform`].
3312 ///
3313 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3314 /// tokens for more than one scope.
3315 ///
3316 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3317 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3318 /// sufficient, a read-write scope will do as well.
3319 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCapacityCommitmentMergeCall<'a, C>
3320 where
3321 St: AsRef<str>,
3322 {
3323 self._scopes.insert(String::from(scope.as_ref()));
3324 self
3325 }
3326 /// Identifies the authorization scope(s) for the method you are building.
3327 ///
3328 /// See [`Self::add_scope()`] for details.
3329 pub fn add_scopes<I, St>(
3330 mut self,
3331 scopes: I,
3332 ) -> ProjectLocationCapacityCommitmentMergeCall<'a, C>
3333 where
3334 I: IntoIterator<Item = St>,
3335 St: AsRef<str>,
3336 {
3337 self._scopes
3338 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3339 self
3340 }
3341
3342 /// Removes all scopes, and no default scope will be used either.
3343 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3344 /// for details).
3345 pub fn clear_scopes(mut self) -> ProjectLocationCapacityCommitmentMergeCall<'a, C> {
3346 self._scopes.clear();
3347 self
3348 }
3349}
3350
3351/// Updates an existing capacity commitment. Only `plan` and `renewal_plan` fields can be updated. Plan can only be changed to a plan of a longer commitment period. Attempting to change to a plan with shorter commitment period will fail with the error code `google.rpc.Code.FAILED_PRECONDITION`.
3352///
3353/// A builder for the *locations.capacityCommitments.patch* method supported by a *project* resource.
3354/// It is not used directly, but through a [`ProjectMethods`] instance.
3355///
3356/// # Example
3357///
3358/// Instantiate a resource method builder
3359///
3360/// ```test_harness,no_run
3361/// # extern crate hyper;
3362/// # extern crate hyper_rustls;
3363/// # extern crate google_bigqueryreservation1 as bigqueryreservation1;
3364/// use bigqueryreservation1::api::CapacityCommitment;
3365/// # async fn dox() {
3366/// # use bigqueryreservation1::{BigQueryReservation, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3367///
3368/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3369/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3370/// # .with_native_roots()
3371/// # .unwrap()
3372/// # .https_only()
3373/// # .enable_http2()
3374/// # .build();
3375///
3376/// # let executor = hyper_util::rt::TokioExecutor::new();
3377/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3378/// # secret,
3379/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3380/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3381/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3382/// # ),
3383/// # ).build().await.unwrap();
3384///
3385/// # let client = hyper_util::client::legacy::Client::builder(
3386/// # hyper_util::rt::TokioExecutor::new()
3387/// # )
3388/// # .build(
3389/// # hyper_rustls::HttpsConnectorBuilder::new()
3390/// # .with_native_roots()
3391/// # .unwrap()
3392/// # .https_or_http()
3393/// # .enable_http2()
3394/// # .build()
3395/// # );
3396/// # let mut hub = BigQueryReservation::new(client, auth);
3397/// // As the method needs a request, you would usually fill it with the desired information
3398/// // into the respective structure. Some of the parts shown here might not be applicable !
3399/// // Values shown here are possibly random and not representative !
3400/// let mut req = CapacityCommitment::default();
3401///
3402/// // You can configure optional parameters by calling the respective setters at will, and
3403/// // execute the final call using `doit()`.
3404/// // Values shown here are possibly random and not representative !
3405/// let result = hub.projects().locations_capacity_commitments_patch(req, "name")
3406/// .update_mask(FieldMask::new::<&str>(&[]))
3407/// .doit().await;
3408/// # }
3409/// ```
3410pub struct ProjectLocationCapacityCommitmentPatchCall<'a, C>
3411where
3412 C: 'a,
3413{
3414 hub: &'a BigQueryReservation<C>,
3415 _request: CapacityCommitment,
3416 _name: String,
3417 _update_mask: Option<common::FieldMask>,
3418 _delegate: Option<&'a mut dyn common::Delegate>,
3419 _additional_params: HashMap<String, String>,
3420 _scopes: BTreeSet<String>,
3421}
3422
3423impl<'a, C> common::CallBuilder for ProjectLocationCapacityCommitmentPatchCall<'a, C> {}
3424
3425impl<'a, C> ProjectLocationCapacityCommitmentPatchCall<'a, C>
3426where
3427 C: common::Connector,
3428{
3429 /// Perform the operation you have build so far.
3430 pub async fn doit(mut self) -> common::Result<(common::Response, CapacityCommitment)> {
3431 use std::borrow::Cow;
3432 use std::io::{Read, Seek};
3433
3434 use common::{url::Params, ToParts};
3435 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3436
3437 let mut dd = common::DefaultDelegate;
3438 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3439 dlg.begin(common::MethodInfo {
3440 id: "bigqueryreservation.projects.locations.capacityCommitments.patch",
3441 http_method: hyper::Method::PATCH,
3442 });
3443
3444 for &field in ["alt", "name", "updateMask"].iter() {
3445 if self._additional_params.contains_key(field) {
3446 dlg.finished(false);
3447 return Err(common::Error::FieldClash(field));
3448 }
3449 }
3450
3451 let mut params = Params::with_capacity(5 + self._additional_params.len());
3452 params.push("name", self._name);
3453 if let Some(value) = self._update_mask.as_ref() {
3454 params.push("updateMask", value.to_string());
3455 }
3456
3457 params.extend(self._additional_params.iter());
3458
3459 params.push("alt", "json");
3460 let mut url = self.hub._base_url.clone() + "v1/{+name}";
3461 if self._scopes.is_empty() {
3462 self._scopes
3463 .insert(Scope::CloudPlatform.as_ref().to_string());
3464 }
3465
3466 #[allow(clippy::single_element_loop)]
3467 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3468 url = params.uri_replacement(url, param_name, find_this, true);
3469 }
3470 {
3471 let to_remove = ["name"];
3472 params.remove_params(&to_remove);
3473 }
3474
3475 let url = params.parse_with_url(&url);
3476
3477 let mut json_mime_type = mime::APPLICATION_JSON;
3478 let mut request_value_reader = {
3479 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3480 common::remove_json_null_values(&mut value);
3481 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3482 serde_json::to_writer(&mut dst, &value).unwrap();
3483 dst
3484 };
3485 let request_size = request_value_reader
3486 .seek(std::io::SeekFrom::End(0))
3487 .unwrap();
3488 request_value_reader
3489 .seek(std::io::SeekFrom::Start(0))
3490 .unwrap();
3491
3492 loop {
3493 let token = match self
3494 .hub
3495 .auth
3496 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3497 .await
3498 {
3499 Ok(token) => token,
3500 Err(e) => match dlg.token(e) {
3501 Ok(token) => token,
3502 Err(e) => {
3503 dlg.finished(false);
3504 return Err(common::Error::MissingToken(e));
3505 }
3506 },
3507 };
3508 request_value_reader
3509 .seek(std::io::SeekFrom::Start(0))
3510 .unwrap();
3511 let mut req_result = {
3512 let client = &self.hub.client;
3513 dlg.pre_request();
3514 let mut req_builder = hyper::Request::builder()
3515 .method(hyper::Method::PATCH)
3516 .uri(url.as_str())
3517 .header(USER_AGENT, self.hub._user_agent.clone());
3518
3519 if let Some(token) = token.as_ref() {
3520 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3521 }
3522
3523 let request = req_builder
3524 .header(CONTENT_TYPE, json_mime_type.to_string())
3525 .header(CONTENT_LENGTH, request_size as u64)
3526 .body(common::to_body(
3527 request_value_reader.get_ref().clone().into(),
3528 ));
3529
3530 client.request(request.unwrap()).await
3531 };
3532
3533 match req_result {
3534 Err(err) => {
3535 if let common::Retry::After(d) = dlg.http_error(&err) {
3536 sleep(d).await;
3537 continue;
3538 }
3539 dlg.finished(false);
3540 return Err(common::Error::HttpError(err));
3541 }
3542 Ok(res) => {
3543 let (mut parts, body) = res.into_parts();
3544 let mut body = common::Body::new(body);
3545 if !parts.status.is_success() {
3546 let bytes = common::to_bytes(body).await.unwrap_or_default();
3547 let error = serde_json::from_str(&common::to_string(&bytes));
3548 let response = common::to_response(parts, bytes.into());
3549
3550 if let common::Retry::After(d) =
3551 dlg.http_failure(&response, error.as_ref().ok())
3552 {
3553 sleep(d).await;
3554 continue;
3555 }
3556
3557 dlg.finished(false);
3558
3559 return Err(match error {
3560 Ok(value) => common::Error::BadRequest(value),
3561 _ => common::Error::Failure(response),
3562 });
3563 }
3564 let response = {
3565 let bytes = common::to_bytes(body).await.unwrap_or_default();
3566 let encoded = common::to_string(&bytes);
3567 match serde_json::from_str(&encoded) {
3568 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3569 Err(error) => {
3570 dlg.response_json_decode_error(&encoded, &error);
3571 return Err(common::Error::JsonDecodeError(
3572 encoded.to_string(),
3573 error,
3574 ));
3575 }
3576 }
3577 };
3578
3579 dlg.finished(true);
3580 return Ok(response);
3581 }
3582 }
3583 }
3584 }
3585
3586 ///
3587 /// Sets the *request* property to the given value.
3588 ///
3589 /// Even though the property as already been set when instantiating this call,
3590 /// we provide this method for API completeness.
3591 pub fn request(
3592 mut self,
3593 new_value: CapacityCommitment,
3594 ) -> ProjectLocationCapacityCommitmentPatchCall<'a, C> {
3595 self._request = new_value;
3596 self
3597 }
3598 /// Output only. The resource name of the capacity commitment, e.g., `projects/myproject/locations/US/capacityCommitments/123` The commitment_id must only contain lower case alphanumeric characters or dashes. It must start with a letter and must not end with a dash. Its maximum length is 64 characters.
3599 ///
3600 /// Sets the *name* path property to the given value.
3601 ///
3602 /// Even though the property as already been set when instantiating this call,
3603 /// we provide this method for API completeness.
3604 pub fn name(mut self, new_value: &str) -> ProjectLocationCapacityCommitmentPatchCall<'a, C> {
3605 self._name = new_value.to_string();
3606 self
3607 }
3608 /// Standard field mask for the set of fields to be updated.
3609 ///
3610 /// Sets the *update mask* query property to the given value.
3611 pub fn update_mask(
3612 mut self,
3613 new_value: common::FieldMask,
3614 ) -> ProjectLocationCapacityCommitmentPatchCall<'a, C> {
3615 self._update_mask = Some(new_value);
3616 self
3617 }
3618 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3619 /// while executing the actual API request.
3620 ///
3621 /// ````text
3622 /// It should be used to handle progress information, and to implement a certain level of resilience.
3623 /// ````
3624 ///
3625 /// Sets the *delegate* property to the given value.
3626 pub fn delegate(
3627 mut self,
3628 new_value: &'a mut dyn common::Delegate,
3629 ) -> ProjectLocationCapacityCommitmentPatchCall<'a, C> {
3630 self._delegate = Some(new_value);
3631 self
3632 }
3633
3634 /// Set any additional parameter of the query string used in the request.
3635 /// It should be used to set parameters which are not yet available through their own
3636 /// setters.
3637 ///
3638 /// Please note that this method must not be used to set any of the known parameters
3639 /// which have their own setter method. If done anyway, the request will fail.
3640 ///
3641 /// # Additional Parameters
3642 ///
3643 /// * *$.xgafv* (query-string) - V1 error format.
3644 /// * *access_token* (query-string) - OAuth access token.
3645 /// * *alt* (query-string) - Data format for response.
3646 /// * *callback* (query-string) - JSONP
3647 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3648 /// * *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.
3649 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3650 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3651 /// * *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.
3652 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3653 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
3654 pub fn param<T>(
3655 mut self,
3656 name: T,
3657 value: T,
3658 ) -> ProjectLocationCapacityCommitmentPatchCall<'a, C>
3659 where
3660 T: AsRef<str>,
3661 {
3662 self._additional_params
3663 .insert(name.as_ref().to_string(), value.as_ref().to_string());
3664 self
3665 }
3666
3667 /// Identifies the authorization scope for the method you are building.
3668 ///
3669 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
3670 /// [`Scope::CloudPlatform`].
3671 ///
3672 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
3673 /// tokens for more than one scope.
3674 ///
3675 /// Usually there is more than one suitable scope to authorize an operation, some of which may
3676 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
3677 /// sufficient, a read-write scope will do as well.
3678 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCapacityCommitmentPatchCall<'a, C>
3679 where
3680 St: AsRef<str>,
3681 {
3682 self._scopes.insert(String::from(scope.as_ref()));
3683 self
3684 }
3685 /// Identifies the authorization scope(s) for the method you are building.
3686 ///
3687 /// See [`Self::add_scope()`] for details.
3688 pub fn add_scopes<I, St>(
3689 mut self,
3690 scopes: I,
3691 ) -> ProjectLocationCapacityCommitmentPatchCall<'a, C>
3692 where
3693 I: IntoIterator<Item = St>,
3694 St: AsRef<str>,
3695 {
3696 self._scopes
3697 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
3698 self
3699 }
3700
3701 /// Removes all scopes, and no default scope will be used either.
3702 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
3703 /// for details).
3704 pub fn clear_scopes(mut self) -> ProjectLocationCapacityCommitmentPatchCall<'a, C> {
3705 self._scopes.clear();
3706 self
3707 }
3708}
3709
3710/// Splits capacity commitment to two commitments of the same plan and `commitment_end_time`. A common use case is to enable downgrading commitments. For example, in order to downgrade from 10000 slots to 8000, you might split a 10000 capacity commitment into commitments of 2000 and 8000. Then, you delete the first one after the commitment end time passes.
3711///
3712/// A builder for the *locations.capacityCommitments.split* method supported by a *project* resource.
3713/// It is not used directly, but through a [`ProjectMethods`] instance.
3714///
3715/// # Example
3716///
3717/// Instantiate a resource method builder
3718///
3719/// ```test_harness,no_run
3720/// # extern crate hyper;
3721/// # extern crate hyper_rustls;
3722/// # extern crate google_bigqueryreservation1 as bigqueryreservation1;
3723/// use bigqueryreservation1::api::SplitCapacityCommitmentRequest;
3724/// # async fn dox() {
3725/// # use bigqueryreservation1::{BigQueryReservation, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
3726///
3727/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
3728/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
3729/// # .with_native_roots()
3730/// # .unwrap()
3731/// # .https_only()
3732/// # .enable_http2()
3733/// # .build();
3734///
3735/// # let executor = hyper_util::rt::TokioExecutor::new();
3736/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
3737/// # secret,
3738/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
3739/// # yup_oauth2::client::CustomHyperClientBuilder::from(
3740/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
3741/// # ),
3742/// # ).build().await.unwrap();
3743///
3744/// # let client = hyper_util::client::legacy::Client::builder(
3745/// # hyper_util::rt::TokioExecutor::new()
3746/// # )
3747/// # .build(
3748/// # hyper_rustls::HttpsConnectorBuilder::new()
3749/// # .with_native_roots()
3750/// # .unwrap()
3751/// # .https_or_http()
3752/// # .enable_http2()
3753/// # .build()
3754/// # );
3755/// # let mut hub = BigQueryReservation::new(client, auth);
3756/// // As the method needs a request, you would usually fill it with the desired information
3757/// // into the respective structure. Some of the parts shown here might not be applicable !
3758/// // Values shown here are possibly random and not representative !
3759/// let mut req = SplitCapacityCommitmentRequest::default();
3760///
3761/// // You can configure optional parameters by calling the respective setters at will, and
3762/// // execute the final call using `doit()`.
3763/// // Values shown here are possibly random and not representative !
3764/// let result = hub.projects().locations_capacity_commitments_split(req, "name")
3765/// .doit().await;
3766/// # }
3767/// ```
3768pub struct ProjectLocationCapacityCommitmentSplitCall<'a, C>
3769where
3770 C: 'a,
3771{
3772 hub: &'a BigQueryReservation<C>,
3773 _request: SplitCapacityCommitmentRequest,
3774 _name: String,
3775 _delegate: Option<&'a mut dyn common::Delegate>,
3776 _additional_params: HashMap<String, String>,
3777 _scopes: BTreeSet<String>,
3778}
3779
3780impl<'a, C> common::CallBuilder for ProjectLocationCapacityCommitmentSplitCall<'a, C> {}
3781
3782impl<'a, C> ProjectLocationCapacityCommitmentSplitCall<'a, C>
3783where
3784 C: common::Connector,
3785{
3786 /// Perform the operation you have build so far.
3787 pub async fn doit(
3788 mut self,
3789 ) -> common::Result<(common::Response, SplitCapacityCommitmentResponse)> {
3790 use std::borrow::Cow;
3791 use std::io::{Read, Seek};
3792
3793 use common::{url::Params, ToParts};
3794 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
3795
3796 let mut dd = common::DefaultDelegate;
3797 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
3798 dlg.begin(common::MethodInfo {
3799 id: "bigqueryreservation.projects.locations.capacityCommitments.split",
3800 http_method: hyper::Method::POST,
3801 });
3802
3803 for &field in ["alt", "name"].iter() {
3804 if self._additional_params.contains_key(field) {
3805 dlg.finished(false);
3806 return Err(common::Error::FieldClash(field));
3807 }
3808 }
3809
3810 let mut params = Params::with_capacity(4 + self._additional_params.len());
3811 params.push("name", self._name);
3812
3813 params.extend(self._additional_params.iter());
3814
3815 params.push("alt", "json");
3816 let mut url = self.hub._base_url.clone() + "v1/{+name}:split";
3817 if self._scopes.is_empty() {
3818 self._scopes
3819 .insert(Scope::CloudPlatform.as_ref().to_string());
3820 }
3821
3822 #[allow(clippy::single_element_loop)]
3823 for &(find_this, param_name) in [("{+name}", "name")].iter() {
3824 url = params.uri_replacement(url, param_name, find_this, true);
3825 }
3826 {
3827 let to_remove = ["name"];
3828 params.remove_params(&to_remove);
3829 }
3830
3831 let url = params.parse_with_url(&url);
3832
3833 let mut json_mime_type = mime::APPLICATION_JSON;
3834 let mut request_value_reader = {
3835 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
3836 common::remove_json_null_values(&mut value);
3837 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
3838 serde_json::to_writer(&mut dst, &value).unwrap();
3839 dst
3840 };
3841 let request_size = request_value_reader
3842 .seek(std::io::SeekFrom::End(0))
3843 .unwrap();
3844 request_value_reader
3845 .seek(std::io::SeekFrom::Start(0))
3846 .unwrap();
3847
3848 loop {
3849 let token = match self
3850 .hub
3851 .auth
3852 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
3853 .await
3854 {
3855 Ok(token) => token,
3856 Err(e) => match dlg.token(e) {
3857 Ok(token) => token,
3858 Err(e) => {
3859 dlg.finished(false);
3860 return Err(common::Error::MissingToken(e));
3861 }
3862 },
3863 };
3864 request_value_reader
3865 .seek(std::io::SeekFrom::Start(0))
3866 .unwrap();
3867 let mut req_result = {
3868 let client = &self.hub.client;
3869 dlg.pre_request();
3870 let mut req_builder = hyper::Request::builder()
3871 .method(hyper::Method::POST)
3872 .uri(url.as_str())
3873 .header(USER_AGENT, self.hub._user_agent.clone());
3874
3875 if let Some(token) = token.as_ref() {
3876 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
3877 }
3878
3879 let request = req_builder
3880 .header(CONTENT_TYPE, json_mime_type.to_string())
3881 .header(CONTENT_LENGTH, request_size as u64)
3882 .body(common::to_body(
3883 request_value_reader.get_ref().clone().into(),
3884 ));
3885
3886 client.request(request.unwrap()).await
3887 };
3888
3889 match req_result {
3890 Err(err) => {
3891 if let common::Retry::After(d) = dlg.http_error(&err) {
3892 sleep(d).await;
3893 continue;
3894 }
3895 dlg.finished(false);
3896 return Err(common::Error::HttpError(err));
3897 }
3898 Ok(res) => {
3899 let (mut parts, body) = res.into_parts();
3900 let mut body = common::Body::new(body);
3901 if !parts.status.is_success() {
3902 let bytes = common::to_bytes(body).await.unwrap_or_default();
3903 let error = serde_json::from_str(&common::to_string(&bytes));
3904 let response = common::to_response(parts, bytes.into());
3905
3906 if let common::Retry::After(d) =
3907 dlg.http_failure(&response, error.as_ref().ok())
3908 {
3909 sleep(d).await;
3910 continue;
3911 }
3912
3913 dlg.finished(false);
3914
3915 return Err(match error {
3916 Ok(value) => common::Error::BadRequest(value),
3917 _ => common::Error::Failure(response),
3918 });
3919 }
3920 let response = {
3921 let bytes = common::to_bytes(body).await.unwrap_or_default();
3922 let encoded = common::to_string(&bytes);
3923 match serde_json::from_str(&encoded) {
3924 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
3925 Err(error) => {
3926 dlg.response_json_decode_error(&encoded, &error);
3927 return Err(common::Error::JsonDecodeError(
3928 encoded.to_string(),
3929 error,
3930 ));
3931 }
3932 }
3933 };
3934
3935 dlg.finished(true);
3936 return Ok(response);
3937 }
3938 }
3939 }
3940 }
3941
3942 ///
3943 /// Sets the *request* property to the given value.
3944 ///
3945 /// Even though the property as already been set when instantiating this call,
3946 /// we provide this method for API completeness.
3947 pub fn request(
3948 mut self,
3949 new_value: SplitCapacityCommitmentRequest,
3950 ) -> ProjectLocationCapacityCommitmentSplitCall<'a, C> {
3951 self._request = new_value;
3952 self
3953 }
3954 /// Required. The resource name e.g.,: `projects/myproject/locations/US/capacityCommitments/123`
3955 ///
3956 /// Sets the *name* path property to the given value.
3957 ///
3958 /// Even though the property as already been set when instantiating this call,
3959 /// we provide this method for API completeness.
3960 pub fn name(mut self, new_value: &str) -> ProjectLocationCapacityCommitmentSplitCall<'a, C> {
3961 self._name = new_value.to_string();
3962 self
3963 }
3964 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
3965 /// while executing the actual API request.
3966 ///
3967 /// ````text
3968 /// It should be used to handle progress information, and to implement a certain level of resilience.
3969 /// ````
3970 ///
3971 /// Sets the *delegate* property to the given value.
3972 pub fn delegate(
3973 mut self,
3974 new_value: &'a mut dyn common::Delegate,
3975 ) -> ProjectLocationCapacityCommitmentSplitCall<'a, C> {
3976 self._delegate = Some(new_value);
3977 self
3978 }
3979
3980 /// Set any additional parameter of the query string used in the request.
3981 /// It should be used to set parameters which are not yet available through their own
3982 /// setters.
3983 ///
3984 /// Please note that this method must not be used to set any of the known parameters
3985 /// which have their own setter method. If done anyway, the request will fail.
3986 ///
3987 /// # Additional Parameters
3988 ///
3989 /// * *$.xgafv* (query-string) - V1 error format.
3990 /// * *access_token* (query-string) - OAuth access token.
3991 /// * *alt* (query-string) - Data format for response.
3992 /// * *callback* (query-string) - JSONP
3993 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
3994 /// * *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.
3995 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
3996 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
3997 /// * *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.
3998 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
3999 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4000 pub fn param<T>(
4001 mut self,
4002 name: T,
4003 value: T,
4004 ) -> ProjectLocationCapacityCommitmentSplitCall<'a, C>
4005 where
4006 T: AsRef<str>,
4007 {
4008 self._additional_params
4009 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4010 self
4011 }
4012
4013 /// Identifies the authorization scope for the method you are building.
4014 ///
4015 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4016 /// [`Scope::CloudPlatform`].
4017 ///
4018 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4019 /// tokens for more than one scope.
4020 ///
4021 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4022 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4023 /// sufficient, a read-write scope will do as well.
4024 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationCapacityCommitmentSplitCall<'a, C>
4025 where
4026 St: AsRef<str>,
4027 {
4028 self._scopes.insert(String::from(scope.as_ref()));
4029 self
4030 }
4031 /// Identifies the authorization scope(s) for the method you are building.
4032 ///
4033 /// See [`Self::add_scope()`] for details.
4034 pub fn add_scopes<I, St>(
4035 mut self,
4036 scopes: I,
4037 ) -> ProjectLocationCapacityCommitmentSplitCall<'a, C>
4038 where
4039 I: IntoIterator<Item = St>,
4040 St: AsRef<str>,
4041 {
4042 self._scopes
4043 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4044 self
4045 }
4046
4047 /// Removes all scopes, and no default scope will be used either.
4048 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4049 /// for details).
4050 pub fn clear_scopes(mut self) -> ProjectLocationCapacityCommitmentSplitCall<'a, C> {
4051 self._scopes.clear();
4052 self
4053 }
4054}
4055
4056/// Creates a new reservation group.
4057///
4058/// A builder for the *locations.reservationGroups.create* method supported by a *project* resource.
4059/// It is not used directly, but through a [`ProjectMethods`] instance.
4060///
4061/// # Example
4062///
4063/// Instantiate a resource method builder
4064///
4065/// ```test_harness,no_run
4066/// # extern crate hyper;
4067/// # extern crate hyper_rustls;
4068/// # extern crate google_bigqueryreservation1 as bigqueryreservation1;
4069/// use bigqueryreservation1::api::ReservationGroup;
4070/// # async fn dox() {
4071/// # use bigqueryreservation1::{BigQueryReservation, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4072///
4073/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4074/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4075/// # .with_native_roots()
4076/// # .unwrap()
4077/// # .https_only()
4078/// # .enable_http2()
4079/// # .build();
4080///
4081/// # let executor = hyper_util::rt::TokioExecutor::new();
4082/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4083/// # secret,
4084/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4085/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4086/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4087/// # ),
4088/// # ).build().await.unwrap();
4089///
4090/// # let client = hyper_util::client::legacy::Client::builder(
4091/// # hyper_util::rt::TokioExecutor::new()
4092/// # )
4093/// # .build(
4094/// # hyper_rustls::HttpsConnectorBuilder::new()
4095/// # .with_native_roots()
4096/// # .unwrap()
4097/// # .https_or_http()
4098/// # .enable_http2()
4099/// # .build()
4100/// # );
4101/// # let mut hub = BigQueryReservation::new(client, auth);
4102/// // As the method needs a request, you would usually fill it with the desired information
4103/// // into the respective structure. Some of the parts shown here might not be applicable !
4104/// // Values shown here are possibly random and not representative !
4105/// let mut req = ReservationGroup::default();
4106///
4107/// // You can configure optional parameters by calling the respective setters at will, and
4108/// // execute the final call using `doit()`.
4109/// // Values shown here are possibly random and not representative !
4110/// let result = hub.projects().locations_reservation_groups_create(req, "parent")
4111/// .reservation_group_id("ipsum")
4112/// .doit().await;
4113/// # }
4114/// ```
4115pub struct ProjectLocationReservationGroupCreateCall<'a, C>
4116where
4117 C: 'a,
4118{
4119 hub: &'a BigQueryReservation<C>,
4120 _request: ReservationGroup,
4121 _parent: String,
4122 _reservation_group_id: Option<String>,
4123 _delegate: Option<&'a mut dyn common::Delegate>,
4124 _additional_params: HashMap<String, String>,
4125 _scopes: BTreeSet<String>,
4126}
4127
4128impl<'a, C> common::CallBuilder for ProjectLocationReservationGroupCreateCall<'a, C> {}
4129
4130impl<'a, C> ProjectLocationReservationGroupCreateCall<'a, C>
4131where
4132 C: common::Connector,
4133{
4134 /// Perform the operation you have build so far.
4135 pub async fn doit(mut self) -> common::Result<(common::Response, ReservationGroup)> {
4136 use std::borrow::Cow;
4137 use std::io::{Read, Seek};
4138
4139 use common::{url::Params, ToParts};
4140 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4141
4142 let mut dd = common::DefaultDelegate;
4143 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4144 dlg.begin(common::MethodInfo {
4145 id: "bigqueryreservation.projects.locations.reservationGroups.create",
4146 http_method: hyper::Method::POST,
4147 });
4148
4149 for &field in ["alt", "parent", "reservationGroupId"].iter() {
4150 if self._additional_params.contains_key(field) {
4151 dlg.finished(false);
4152 return Err(common::Error::FieldClash(field));
4153 }
4154 }
4155
4156 let mut params = Params::with_capacity(5 + self._additional_params.len());
4157 params.push("parent", self._parent);
4158 if let Some(value) = self._reservation_group_id.as_ref() {
4159 params.push("reservationGroupId", value);
4160 }
4161
4162 params.extend(self._additional_params.iter());
4163
4164 params.push("alt", "json");
4165 let mut url = self.hub._base_url.clone() + "v1/{+parent}/reservationGroups";
4166 if self._scopes.is_empty() {
4167 self._scopes
4168 .insert(Scope::CloudPlatform.as_ref().to_string());
4169 }
4170
4171 #[allow(clippy::single_element_loop)]
4172 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
4173 url = params.uri_replacement(url, param_name, find_this, true);
4174 }
4175 {
4176 let to_remove = ["parent"];
4177 params.remove_params(&to_remove);
4178 }
4179
4180 let url = params.parse_with_url(&url);
4181
4182 let mut json_mime_type = mime::APPLICATION_JSON;
4183 let mut request_value_reader = {
4184 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
4185 common::remove_json_null_values(&mut value);
4186 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
4187 serde_json::to_writer(&mut dst, &value).unwrap();
4188 dst
4189 };
4190 let request_size = request_value_reader
4191 .seek(std::io::SeekFrom::End(0))
4192 .unwrap();
4193 request_value_reader
4194 .seek(std::io::SeekFrom::Start(0))
4195 .unwrap();
4196
4197 loop {
4198 let token = match self
4199 .hub
4200 .auth
4201 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4202 .await
4203 {
4204 Ok(token) => token,
4205 Err(e) => match dlg.token(e) {
4206 Ok(token) => token,
4207 Err(e) => {
4208 dlg.finished(false);
4209 return Err(common::Error::MissingToken(e));
4210 }
4211 },
4212 };
4213 request_value_reader
4214 .seek(std::io::SeekFrom::Start(0))
4215 .unwrap();
4216 let mut req_result = {
4217 let client = &self.hub.client;
4218 dlg.pre_request();
4219 let mut req_builder = hyper::Request::builder()
4220 .method(hyper::Method::POST)
4221 .uri(url.as_str())
4222 .header(USER_AGENT, self.hub._user_agent.clone());
4223
4224 if let Some(token) = token.as_ref() {
4225 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4226 }
4227
4228 let request = req_builder
4229 .header(CONTENT_TYPE, json_mime_type.to_string())
4230 .header(CONTENT_LENGTH, request_size as u64)
4231 .body(common::to_body(
4232 request_value_reader.get_ref().clone().into(),
4233 ));
4234
4235 client.request(request.unwrap()).await
4236 };
4237
4238 match req_result {
4239 Err(err) => {
4240 if let common::Retry::After(d) = dlg.http_error(&err) {
4241 sleep(d).await;
4242 continue;
4243 }
4244 dlg.finished(false);
4245 return Err(common::Error::HttpError(err));
4246 }
4247 Ok(res) => {
4248 let (mut parts, body) = res.into_parts();
4249 let mut body = common::Body::new(body);
4250 if !parts.status.is_success() {
4251 let bytes = common::to_bytes(body).await.unwrap_or_default();
4252 let error = serde_json::from_str(&common::to_string(&bytes));
4253 let response = common::to_response(parts, bytes.into());
4254
4255 if let common::Retry::After(d) =
4256 dlg.http_failure(&response, error.as_ref().ok())
4257 {
4258 sleep(d).await;
4259 continue;
4260 }
4261
4262 dlg.finished(false);
4263
4264 return Err(match error {
4265 Ok(value) => common::Error::BadRequest(value),
4266 _ => common::Error::Failure(response),
4267 });
4268 }
4269 let response = {
4270 let bytes = common::to_bytes(body).await.unwrap_or_default();
4271 let encoded = common::to_string(&bytes);
4272 match serde_json::from_str(&encoded) {
4273 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4274 Err(error) => {
4275 dlg.response_json_decode_error(&encoded, &error);
4276 return Err(common::Error::JsonDecodeError(
4277 encoded.to_string(),
4278 error,
4279 ));
4280 }
4281 }
4282 };
4283
4284 dlg.finished(true);
4285 return Ok(response);
4286 }
4287 }
4288 }
4289 }
4290
4291 ///
4292 /// Sets the *request* property to the given value.
4293 ///
4294 /// Even though the property as already been set when instantiating this call,
4295 /// we provide this method for API completeness.
4296 pub fn request(
4297 mut self,
4298 new_value: ReservationGroup,
4299 ) -> ProjectLocationReservationGroupCreateCall<'a, C> {
4300 self._request = new_value;
4301 self
4302 }
4303 /// Required. Project, location. E.g., `projects/myproject/locations/US`
4304 ///
4305 /// Sets the *parent* path property to the given value.
4306 ///
4307 /// Even though the property as already been set when instantiating this call,
4308 /// we provide this method for API completeness.
4309 pub fn parent(mut self, new_value: &str) -> ProjectLocationReservationGroupCreateCall<'a, C> {
4310 self._parent = new_value.to_string();
4311 self
4312 }
4313 /// Required. The reservation group ID. It must only contain lower case alphanumeric characters or dashes. It must start with a letter and must not end with a dash. Its maximum length is 64 characters.
4314 ///
4315 /// Sets the *reservation group id* query property to the given value.
4316 pub fn reservation_group_id(
4317 mut self,
4318 new_value: &str,
4319 ) -> ProjectLocationReservationGroupCreateCall<'a, C> {
4320 self._reservation_group_id = Some(new_value.to_string());
4321 self
4322 }
4323 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4324 /// while executing the actual API request.
4325 ///
4326 /// ````text
4327 /// It should be used to handle progress information, and to implement a certain level of resilience.
4328 /// ````
4329 ///
4330 /// Sets the *delegate* property to the given value.
4331 pub fn delegate(
4332 mut self,
4333 new_value: &'a mut dyn common::Delegate,
4334 ) -> ProjectLocationReservationGroupCreateCall<'a, C> {
4335 self._delegate = Some(new_value);
4336 self
4337 }
4338
4339 /// Set any additional parameter of the query string used in the request.
4340 /// It should be used to set parameters which are not yet available through their own
4341 /// setters.
4342 ///
4343 /// Please note that this method must not be used to set any of the known parameters
4344 /// which have their own setter method. If done anyway, the request will fail.
4345 ///
4346 /// # Additional Parameters
4347 ///
4348 /// * *$.xgafv* (query-string) - V1 error format.
4349 /// * *access_token* (query-string) - OAuth access token.
4350 /// * *alt* (query-string) - Data format for response.
4351 /// * *callback* (query-string) - JSONP
4352 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4353 /// * *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.
4354 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4355 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4356 /// * *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.
4357 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4358 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4359 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationReservationGroupCreateCall<'a, C>
4360 where
4361 T: AsRef<str>,
4362 {
4363 self._additional_params
4364 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4365 self
4366 }
4367
4368 /// Identifies the authorization scope for the method you are building.
4369 ///
4370 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4371 /// [`Scope::CloudPlatform`].
4372 ///
4373 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4374 /// tokens for more than one scope.
4375 ///
4376 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4377 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4378 /// sufficient, a read-write scope will do as well.
4379 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationReservationGroupCreateCall<'a, C>
4380 where
4381 St: AsRef<str>,
4382 {
4383 self._scopes.insert(String::from(scope.as_ref()));
4384 self
4385 }
4386 /// Identifies the authorization scope(s) for the method you are building.
4387 ///
4388 /// See [`Self::add_scope()`] for details.
4389 pub fn add_scopes<I, St>(
4390 mut self,
4391 scopes: I,
4392 ) -> ProjectLocationReservationGroupCreateCall<'a, C>
4393 where
4394 I: IntoIterator<Item = St>,
4395 St: AsRef<str>,
4396 {
4397 self._scopes
4398 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4399 self
4400 }
4401
4402 /// Removes all scopes, and no default scope will be used either.
4403 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4404 /// for details).
4405 pub fn clear_scopes(mut self) -> ProjectLocationReservationGroupCreateCall<'a, C> {
4406 self._scopes.clear();
4407 self
4408 }
4409}
4410
4411/// Deletes a reservation. Returns `google.rpc.Code.FAILED_PRECONDITION` when reservation has assignments.
4412///
4413/// A builder for the *locations.reservationGroups.delete* method supported by a *project* resource.
4414/// It is not used directly, but through a [`ProjectMethods`] instance.
4415///
4416/// # Example
4417///
4418/// Instantiate a resource method builder
4419///
4420/// ```test_harness,no_run
4421/// # extern crate hyper;
4422/// # extern crate hyper_rustls;
4423/// # extern crate google_bigqueryreservation1 as bigqueryreservation1;
4424/// # async fn dox() {
4425/// # use bigqueryreservation1::{BigQueryReservation, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4426///
4427/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4428/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4429/// # .with_native_roots()
4430/// # .unwrap()
4431/// # .https_only()
4432/// # .enable_http2()
4433/// # .build();
4434///
4435/// # let executor = hyper_util::rt::TokioExecutor::new();
4436/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4437/// # secret,
4438/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4439/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4440/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4441/// # ),
4442/// # ).build().await.unwrap();
4443///
4444/// # let client = hyper_util::client::legacy::Client::builder(
4445/// # hyper_util::rt::TokioExecutor::new()
4446/// # )
4447/// # .build(
4448/// # hyper_rustls::HttpsConnectorBuilder::new()
4449/// # .with_native_roots()
4450/// # .unwrap()
4451/// # .https_or_http()
4452/// # .enable_http2()
4453/// # .build()
4454/// # );
4455/// # let mut hub = BigQueryReservation::new(client, auth);
4456/// // You can configure optional parameters by calling the respective setters at will, and
4457/// // execute the final call using `doit()`.
4458/// // Values shown here are possibly random and not representative !
4459/// let result = hub.projects().locations_reservation_groups_delete("name")
4460/// .doit().await;
4461/// # }
4462/// ```
4463pub struct ProjectLocationReservationGroupDeleteCall<'a, C>
4464where
4465 C: 'a,
4466{
4467 hub: &'a BigQueryReservation<C>,
4468 _name: String,
4469 _delegate: Option<&'a mut dyn common::Delegate>,
4470 _additional_params: HashMap<String, String>,
4471 _scopes: BTreeSet<String>,
4472}
4473
4474impl<'a, C> common::CallBuilder for ProjectLocationReservationGroupDeleteCall<'a, C> {}
4475
4476impl<'a, C> ProjectLocationReservationGroupDeleteCall<'a, C>
4477where
4478 C: common::Connector,
4479{
4480 /// Perform the operation you have build so far.
4481 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
4482 use std::borrow::Cow;
4483 use std::io::{Read, Seek};
4484
4485 use common::{url::Params, ToParts};
4486 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4487
4488 let mut dd = common::DefaultDelegate;
4489 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4490 dlg.begin(common::MethodInfo {
4491 id: "bigqueryreservation.projects.locations.reservationGroups.delete",
4492 http_method: hyper::Method::DELETE,
4493 });
4494
4495 for &field in ["alt", "name"].iter() {
4496 if self._additional_params.contains_key(field) {
4497 dlg.finished(false);
4498 return Err(common::Error::FieldClash(field));
4499 }
4500 }
4501
4502 let mut params = Params::with_capacity(3 + self._additional_params.len());
4503 params.push("name", self._name);
4504
4505 params.extend(self._additional_params.iter());
4506
4507 params.push("alt", "json");
4508 let mut url = self.hub._base_url.clone() + "v1/{+name}";
4509 if self._scopes.is_empty() {
4510 self._scopes
4511 .insert(Scope::CloudPlatform.as_ref().to_string());
4512 }
4513
4514 #[allow(clippy::single_element_loop)]
4515 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4516 url = params.uri_replacement(url, param_name, find_this, true);
4517 }
4518 {
4519 let to_remove = ["name"];
4520 params.remove_params(&to_remove);
4521 }
4522
4523 let url = params.parse_with_url(&url);
4524
4525 loop {
4526 let token = match self
4527 .hub
4528 .auth
4529 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4530 .await
4531 {
4532 Ok(token) => token,
4533 Err(e) => match dlg.token(e) {
4534 Ok(token) => token,
4535 Err(e) => {
4536 dlg.finished(false);
4537 return Err(common::Error::MissingToken(e));
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::DELETE)
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 let request = req_builder
4554 .header(CONTENT_LENGTH, 0_u64)
4555 .body(common::to_body::<String>(None));
4556
4557 client.request(request.unwrap()).await
4558 };
4559
4560 match req_result {
4561 Err(err) => {
4562 if let common::Retry::After(d) = dlg.http_error(&err) {
4563 sleep(d).await;
4564 continue;
4565 }
4566 dlg.finished(false);
4567 return Err(common::Error::HttpError(err));
4568 }
4569 Ok(res) => {
4570 let (mut parts, body) = res.into_parts();
4571 let mut body = common::Body::new(body);
4572 if !parts.status.is_success() {
4573 let bytes = common::to_bytes(body).await.unwrap_or_default();
4574 let error = serde_json::from_str(&common::to_string(&bytes));
4575 let response = common::to_response(parts, bytes.into());
4576
4577 if let common::Retry::After(d) =
4578 dlg.http_failure(&response, error.as_ref().ok())
4579 {
4580 sleep(d).await;
4581 continue;
4582 }
4583
4584 dlg.finished(false);
4585
4586 return Err(match error {
4587 Ok(value) => common::Error::BadRequest(value),
4588 _ => common::Error::Failure(response),
4589 });
4590 }
4591 let response = {
4592 let bytes = common::to_bytes(body).await.unwrap_or_default();
4593 let encoded = common::to_string(&bytes);
4594 match serde_json::from_str(&encoded) {
4595 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4596 Err(error) => {
4597 dlg.response_json_decode_error(&encoded, &error);
4598 return Err(common::Error::JsonDecodeError(
4599 encoded.to_string(),
4600 error,
4601 ));
4602 }
4603 }
4604 };
4605
4606 dlg.finished(true);
4607 return Ok(response);
4608 }
4609 }
4610 }
4611 }
4612
4613 /// Required. Resource name of the reservation group to retrieve. E.g., `projects/myproject/locations/US/reservationGroups/team1-prod`
4614 ///
4615 /// Sets the *name* path property to the given value.
4616 ///
4617 /// Even though the property as already been set when instantiating this call,
4618 /// we provide this method for API completeness.
4619 pub fn name(mut self, new_value: &str) -> ProjectLocationReservationGroupDeleteCall<'a, C> {
4620 self._name = new_value.to_string();
4621 self
4622 }
4623 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4624 /// while executing the actual API request.
4625 ///
4626 /// ````text
4627 /// It should be used to handle progress information, and to implement a certain level of resilience.
4628 /// ````
4629 ///
4630 /// Sets the *delegate* property to the given value.
4631 pub fn delegate(
4632 mut self,
4633 new_value: &'a mut dyn common::Delegate,
4634 ) -> ProjectLocationReservationGroupDeleteCall<'a, C> {
4635 self._delegate = Some(new_value);
4636 self
4637 }
4638
4639 /// Set any additional parameter of the query string used in the request.
4640 /// It should be used to set parameters which are not yet available through their own
4641 /// setters.
4642 ///
4643 /// Please note that this method must not be used to set any of the known parameters
4644 /// which have their own setter method. If done anyway, the request will fail.
4645 ///
4646 /// # Additional Parameters
4647 ///
4648 /// * *$.xgafv* (query-string) - V1 error format.
4649 /// * *access_token* (query-string) - OAuth access token.
4650 /// * *alt* (query-string) - Data format for response.
4651 /// * *callback* (query-string) - JSONP
4652 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4653 /// * *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.
4654 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4655 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4656 /// * *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.
4657 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4658 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4659 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationReservationGroupDeleteCall<'a, C>
4660 where
4661 T: AsRef<str>,
4662 {
4663 self._additional_params
4664 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4665 self
4666 }
4667
4668 /// Identifies the authorization scope for the method you are building.
4669 ///
4670 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4671 /// [`Scope::CloudPlatform`].
4672 ///
4673 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4674 /// tokens for more than one scope.
4675 ///
4676 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4677 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4678 /// sufficient, a read-write scope will do as well.
4679 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationReservationGroupDeleteCall<'a, C>
4680 where
4681 St: AsRef<str>,
4682 {
4683 self._scopes.insert(String::from(scope.as_ref()));
4684 self
4685 }
4686 /// Identifies the authorization scope(s) for the method you are building.
4687 ///
4688 /// See [`Self::add_scope()`] for details.
4689 pub fn add_scopes<I, St>(
4690 mut self,
4691 scopes: I,
4692 ) -> ProjectLocationReservationGroupDeleteCall<'a, C>
4693 where
4694 I: IntoIterator<Item = St>,
4695 St: AsRef<str>,
4696 {
4697 self._scopes
4698 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4699 self
4700 }
4701
4702 /// Removes all scopes, and no default scope will be used either.
4703 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
4704 /// for details).
4705 pub fn clear_scopes(mut self) -> ProjectLocationReservationGroupDeleteCall<'a, C> {
4706 self._scopes.clear();
4707 self
4708 }
4709}
4710
4711/// Returns information about the reservation group.
4712///
4713/// A builder for the *locations.reservationGroups.get* method supported by a *project* resource.
4714/// It is not used directly, but through a [`ProjectMethods`] instance.
4715///
4716/// # Example
4717///
4718/// Instantiate a resource method builder
4719///
4720/// ```test_harness,no_run
4721/// # extern crate hyper;
4722/// # extern crate hyper_rustls;
4723/// # extern crate google_bigqueryreservation1 as bigqueryreservation1;
4724/// # async fn dox() {
4725/// # use bigqueryreservation1::{BigQueryReservation, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
4726///
4727/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
4728/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
4729/// # .with_native_roots()
4730/// # .unwrap()
4731/// # .https_only()
4732/// # .enable_http2()
4733/// # .build();
4734///
4735/// # let executor = hyper_util::rt::TokioExecutor::new();
4736/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
4737/// # secret,
4738/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
4739/// # yup_oauth2::client::CustomHyperClientBuilder::from(
4740/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
4741/// # ),
4742/// # ).build().await.unwrap();
4743///
4744/// # let client = hyper_util::client::legacy::Client::builder(
4745/// # hyper_util::rt::TokioExecutor::new()
4746/// # )
4747/// # .build(
4748/// # hyper_rustls::HttpsConnectorBuilder::new()
4749/// # .with_native_roots()
4750/// # .unwrap()
4751/// # .https_or_http()
4752/// # .enable_http2()
4753/// # .build()
4754/// # );
4755/// # let mut hub = BigQueryReservation::new(client, auth);
4756/// // You can configure optional parameters by calling the respective setters at will, and
4757/// // execute the final call using `doit()`.
4758/// // Values shown here are possibly random and not representative !
4759/// let result = hub.projects().locations_reservation_groups_get("name")
4760/// .doit().await;
4761/// # }
4762/// ```
4763pub struct ProjectLocationReservationGroupGetCall<'a, C>
4764where
4765 C: 'a,
4766{
4767 hub: &'a BigQueryReservation<C>,
4768 _name: String,
4769 _delegate: Option<&'a mut dyn common::Delegate>,
4770 _additional_params: HashMap<String, String>,
4771 _scopes: BTreeSet<String>,
4772}
4773
4774impl<'a, C> common::CallBuilder for ProjectLocationReservationGroupGetCall<'a, C> {}
4775
4776impl<'a, C> ProjectLocationReservationGroupGetCall<'a, C>
4777where
4778 C: common::Connector,
4779{
4780 /// Perform the operation you have build so far.
4781 pub async fn doit(mut self) -> common::Result<(common::Response, ReservationGroup)> {
4782 use std::borrow::Cow;
4783 use std::io::{Read, Seek};
4784
4785 use common::{url::Params, ToParts};
4786 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
4787
4788 let mut dd = common::DefaultDelegate;
4789 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
4790 dlg.begin(common::MethodInfo {
4791 id: "bigqueryreservation.projects.locations.reservationGroups.get",
4792 http_method: hyper::Method::GET,
4793 });
4794
4795 for &field in ["alt", "name"].iter() {
4796 if self._additional_params.contains_key(field) {
4797 dlg.finished(false);
4798 return Err(common::Error::FieldClash(field));
4799 }
4800 }
4801
4802 let mut params = Params::with_capacity(3 + self._additional_params.len());
4803 params.push("name", self._name);
4804
4805 params.extend(self._additional_params.iter());
4806
4807 params.push("alt", "json");
4808 let mut url = self.hub._base_url.clone() + "v1/{+name}";
4809 if self._scopes.is_empty() {
4810 self._scopes
4811 .insert(Scope::CloudPlatform.as_ref().to_string());
4812 }
4813
4814 #[allow(clippy::single_element_loop)]
4815 for &(find_this, param_name) in [("{+name}", "name")].iter() {
4816 url = params.uri_replacement(url, param_name, find_this, true);
4817 }
4818 {
4819 let to_remove = ["name"];
4820 params.remove_params(&to_remove);
4821 }
4822
4823 let url = params.parse_with_url(&url);
4824
4825 loop {
4826 let token = match self
4827 .hub
4828 .auth
4829 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
4830 .await
4831 {
4832 Ok(token) => token,
4833 Err(e) => match dlg.token(e) {
4834 Ok(token) => token,
4835 Err(e) => {
4836 dlg.finished(false);
4837 return Err(common::Error::MissingToken(e));
4838 }
4839 },
4840 };
4841 let mut req_result = {
4842 let client = &self.hub.client;
4843 dlg.pre_request();
4844 let mut req_builder = hyper::Request::builder()
4845 .method(hyper::Method::GET)
4846 .uri(url.as_str())
4847 .header(USER_AGENT, self.hub._user_agent.clone());
4848
4849 if let Some(token) = token.as_ref() {
4850 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
4851 }
4852
4853 let request = req_builder
4854 .header(CONTENT_LENGTH, 0_u64)
4855 .body(common::to_body::<String>(None));
4856
4857 client.request(request.unwrap()).await
4858 };
4859
4860 match req_result {
4861 Err(err) => {
4862 if let common::Retry::After(d) = dlg.http_error(&err) {
4863 sleep(d).await;
4864 continue;
4865 }
4866 dlg.finished(false);
4867 return Err(common::Error::HttpError(err));
4868 }
4869 Ok(res) => {
4870 let (mut parts, body) = res.into_parts();
4871 let mut body = common::Body::new(body);
4872 if !parts.status.is_success() {
4873 let bytes = common::to_bytes(body).await.unwrap_or_default();
4874 let error = serde_json::from_str(&common::to_string(&bytes));
4875 let response = common::to_response(parts, bytes.into());
4876
4877 if let common::Retry::After(d) =
4878 dlg.http_failure(&response, error.as_ref().ok())
4879 {
4880 sleep(d).await;
4881 continue;
4882 }
4883
4884 dlg.finished(false);
4885
4886 return Err(match error {
4887 Ok(value) => common::Error::BadRequest(value),
4888 _ => common::Error::Failure(response),
4889 });
4890 }
4891 let response = {
4892 let bytes = common::to_bytes(body).await.unwrap_or_default();
4893 let encoded = common::to_string(&bytes);
4894 match serde_json::from_str(&encoded) {
4895 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
4896 Err(error) => {
4897 dlg.response_json_decode_error(&encoded, &error);
4898 return Err(common::Error::JsonDecodeError(
4899 encoded.to_string(),
4900 error,
4901 ));
4902 }
4903 }
4904 };
4905
4906 dlg.finished(true);
4907 return Ok(response);
4908 }
4909 }
4910 }
4911 }
4912
4913 /// Required. Resource name of the reservation group to retrieve. E.g., `projects/myproject/locations/US/reservationGroups/team1-prod`
4914 ///
4915 /// Sets the *name* path property to the given value.
4916 ///
4917 /// Even though the property as already been set when instantiating this call,
4918 /// we provide this method for API completeness.
4919 pub fn name(mut self, new_value: &str) -> ProjectLocationReservationGroupGetCall<'a, C> {
4920 self._name = new_value.to_string();
4921 self
4922 }
4923 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
4924 /// while executing the actual API request.
4925 ///
4926 /// ````text
4927 /// It should be used to handle progress information, and to implement a certain level of resilience.
4928 /// ````
4929 ///
4930 /// Sets the *delegate* property to the given value.
4931 pub fn delegate(
4932 mut self,
4933 new_value: &'a mut dyn common::Delegate,
4934 ) -> ProjectLocationReservationGroupGetCall<'a, C> {
4935 self._delegate = Some(new_value);
4936 self
4937 }
4938
4939 /// Set any additional parameter of the query string used in the request.
4940 /// It should be used to set parameters which are not yet available through their own
4941 /// setters.
4942 ///
4943 /// Please note that this method must not be used to set any of the known parameters
4944 /// which have their own setter method. If done anyway, the request will fail.
4945 ///
4946 /// # Additional Parameters
4947 ///
4948 /// * *$.xgafv* (query-string) - V1 error format.
4949 /// * *access_token* (query-string) - OAuth access token.
4950 /// * *alt* (query-string) - Data format for response.
4951 /// * *callback* (query-string) - JSONP
4952 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
4953 /// * *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.
4954 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
4955 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
4956 /// * *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.
4957 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
4958 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
4959 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationReservationGroupGetCall<'a, C>
4960 where
4961 T: AsRef<str>,
4962 {
4963 self._additional_params
4964 .insert(name.as_ref().to_string(), value.as_ref().to_string());
4965 self
4966 }
4967
4968 /// Identifies the authorization scope for the method you are building.
4969 ///
4970 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
4971 /// [`Scope::CloudPlatform`].
4972 ///
4973 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
4974 /// tokens for more than one scope.
4975 ///
4976 /// Usually there is more than one suitable scope to authorize an operation, some of which may
4977 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
4978 /// sufficient, a read-write scope will do as well.
4979 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationReservationGroupGetCall<'a, C>
4980 where
4981 St: AsRef<str>,
4982 {
4983 self._scopes.insert(String::from(scope.as_ref()));
4984 self
4985 }
4986 /// Identifies the authorization scope(s) for the method you are building.
4987 ///
4988 /// See [`Self::add_scope()`] for details.
4989 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationReservationGroupGetCall<'a, C>
4990 where
4991 I: IntoIterator<Item = St>,
4992 St: AsRef<str>,
4993 {
4994 self._scopes
4995 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
4996 self
4997 }
4998
4999 /// Removes all scopes, and no default scope will be used either.
5000 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5001 /// for details).
5002 pub fn clear_scopes(mut self) -> ProjectLocationReservationGroupGetCall<'a, C> {
5003 self._scopes.clear();
5004 self
5005 }
5006}
5007
5008/// Lists all the reservation groups for the project in the specified location.
5009///
5010/// A builder for the *locations.reservationGroups.list* method supported by a *project* resource.
5011/// It is not used directly, but through a [`ProjectMethods`] instance.
5012///
5013/// # Example
5014///
5015/// Instantiate a resource method builder
5016///
5017/// ```test_harness,no_run
5018/// # extern crate hyper;
5019/// # extern crate hyper_rustls;
5020/// # extern crate google_bigqueryreservation1 as bigqueryreservation1;
5021/// # async fn dox() {
5022/// # use bigqueryreservation1::{BigQueryReservation, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5023///
5024/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5025/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5026/// # .with_native_roots()
5027/// # .unwrap()
5028/// # .https_only()
5029/// # .enable_http2()
5030/// # .build();
5031///
5032/// # let executor = hyper_util::rt::TokioExecutor::new();
5033/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5034/// # secret,
5035/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5036/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5037/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5038/// # ),
5039/// # ).build().await.unwrap();
5040///
5041/// # let client = hyper_util::client::legacy::Client::builder(
5042/// # hyper_util::rt::TokioExecutor::new()
5043/// # )
5044/// # .build(
5045/// # hyper_rustls::HttpsConnectorBuilder::new()
5046/// # .with_native_roots()
5047/// # .unwrap()
5048/// # .https_or_http()
5049/// # .enable_http2()
5050/// # .build()
5051/// # );
5052/// # let mut hub = BigQueryReservation::new(client, auth);
5053/// // You can configure optional parameters by calling the respective setters at will, and
5054/// // execute the final call using `doit()`.
5055/// // Values shown here are possibly random and not representative !
5056/// let result = hub.projects().locations_reservation_groups_list("parent")
5057/// .page_token("ipsum")
5058/// .page_size(-93)
5059/// .doit().await;
5060/// # }
5061/// ```
5062pub struct ProjectLocationReservationGroupListCall<'a, C>
5063where
5064 C: 'a,
5065{
5066 hub: &'a BigQueryReservation<C>,
5067 _parent: String,
5068 _page_token: Option<String>,
5069 _page_size: Option<i32>,
5070 _delegate: Option<&'a mut dyn common::Delegate>,
5071 _additional_params: HashMap<String, String>,
5072 _scopes: BTreeSet<String>,
5073}
5074
5075impl<'a, C> common::CallBuilder for ProjectLocationReservationGroupListCall<'a, C> {}
5076
5077impl<'a, C> ProjectLocationReservationGroupListCall<'a, C>
5078where
5079 C: common::Connector,
5080{
5081 /// Perform the operation you have build so far.
5082 pub async fn doit(
5083 mut self,
5084 ) -> common::Result<(common::Response, ListReservationGroupsResponse)> {
5085 use std::borrow::Cow;
5086 use std::io::{Read, Seek};
5087
5088 use common::{url::Params, ToParts};
5089 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5090
5091 let mut dd = common::DefaultDelegate;
5092 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5093 dlg.begin(common::MethodInfo {
5094 id: "bigqueryreservation.projects.locations.reservationGroups.list",
5095 http_method: hyper::Method::GET,
5096 });
5097
5098 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
5099 if self._additional_params.contains_key(field) {
5100 dlg.finished(false);
5101 return Err(common::Error::FieldClash(field));
5102 }
5103 }
5104
5105 let mut params = Params::with_capacity(5 + self._additional_params.len());
5106 params.push("parent", self._parent);
5107 if let Some(value) = self._page_token.as_ref() {
5108 params.push("pageToken", value);
5109 }
5110 if let Some(value) = self._page_size.as_ref() {
5111 params.push("pageSize", value.to_string());
5112 }
5113
5114 params.extend(self._additional_params.iter());
5115
5116 params.push("alt", "json");
5117 let mut url = self.hub._base_url.clone() + "v1/{+parent}/reservationGroups";
5118 if self._scopes.is_empty() {
5119 self._scopes
5120 .insert(Scope::CloudPlatform.as_ref().to_string());
5121 }
5122
5123 #[allow(clippy::single_element_loop)]
5124 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
5125 url = params.uri_replacement(url, param_name, find_this, true);
5126 }
5127 {
5128 let to_remove = ["parent"];
5129 params.remove_params(&to_remove);
5130 }
5131
5132 let url = params.parse_with_url(&url);
5133
5134 loop {
5135 let token = match self
5136 .hub
5137 .auth
5138 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5139 .await
5140 {
5141 Ok(token) => token,
5142 Err(e) => match dlg.token(e) {
5143 Ok(token) => token,
5144 Err(e) => {
5145 dlg.finished(false);
5146 return Err(common::Error::MissingToken(e));
5147 }
5148 },
5149 };
5150 let mut req_result = {
5151 let client = &self.hub.client;
5152 dlg.pre_request();
5153 let mut req_builder = hyper::Request::builder()
5154 .method(hyper::Method::GET)
5155 .uri(url.as_str())
5156 .header(USER_AGENT, self.hub._user_agent.clone());
5157
5158 if let Some(token) = token.as_ref() {
5159 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5160 }
5161
5162 let request = req_builder
5163 .header(CONTENT_LENGTH, 0_u64)
5164 .body(common::to_body::<String>(None));
5165
5166 client.request(request.unwrap()).await
5167 };
5168
5169 match req_result {
5170 Err(err) => {
5171 if let common::Retry::After(d) = dlg.http_error(&err) {
5172 sleep(d).await;
5173 continue;
5174 }
5175 dlg.finished(false);
5176 return Err(common::Error::HttpError(err));
5177 }
5178 Ok(res) => {
5179 let (mut parts, body) = res.into_parts();
5180 let mut body = common::Body::new(body);
5181 if !parts.status.is_success() {
5182 let bytes = common::to_bytes(body).await.unwrap_or_default();
5183 let error = serde_json::from_str(&common::to_string(&bytes));
5184 let response = common::to_response(parts, bytes.into());
5185
5186 if let common::Retry::After(d) =
5187 dlg.http_failure(&response, error.as_ref().ok())
5188 {
5189 sleep(d).await;
5190 continue;
5191 }
5192
5193 dlg.finished(false);
5194
5195 return Err(match error {
5196 Ok(value) => common::Error::BadRequest(value),
5197 _ => common::Error::Failure(response),
5198 });
5199 }
5200 let response = {
5201 let bytes = common::to_bytes(body).await.unwrap_or_default();
5202 let encoded = common::to_string(&bytes);
5203 match serde_json::from_str(&encoded) {
5204 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5205 Err(error) => {
5206 dlg.response_json_decode_error(&encoded, &error);
5207 return Err(common::Error::JsonDecodeError(
5208 encoded.to_string(),
5209 error,
5210 ));
5211 }
5212 }
5213 };
5214
5215 dlg.finished(true);
5216 return Ok(response);
5217 }
5218 }
5219 }
5220 }
5221
5222 /// Required. The parent resource name containing project and location, e.g.: `projects/myproject/locations/US`
5223 ///
5224 /// Sets the *parent* path property to the given value.
5225 ///
5226 /// Even though the property as already been set when instantiating this call,
5227 /// we provide this method for API completeness.
5228 pub fn parent(mut self, new_value: &str) -> ProjectLocationReservationGroupListCall<'a, C> {
5229 self._parent = new_value.to_string();
5230 self
5231 }
5232 /// The next_page_token value returned from a previous List request, if any.
5233 ///
5234 /// Sets the *page token* query property to the given value.
5235 pub fn page_token(mut self, new_value: &str) -> ProjectLocationReservationGroupListCall<'a, C> {
5236 self._page_token = Some(new_value.to_string());
5237 self
5238 }
5239 /// The maximum number of items to return per page.
5240 ///
5241 /// Sets the *page size* query property to the given value.
5242 pub fn page_size(mut self, new_value: i32) -> ProjectLocationReservationGroupListCall<'a, C> {
5243 self._page_size = Some(new_value);
5244 self
5245 }
5246 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5247 /// while executing the actual API request.
5248 ///
5249 /// ````text
5250 /// It should be used to handle progress information, and to implement a certain level of resilience.
5251 /// ````
5252 ///
5253 /// Sets the *delegate* property to the given value.
5254 pub fn delegate(
5255 mut self,
5256 new_value: &'a mut dyn common::Delegate,
5257 ) -> ProjectLocationReservationGroupListCall<'a, C> {
5258 self._delegate = Some(new_value);
5259 self
5260 }
5261
5262 /// Set any additional parameter of the query string used in the request.
5263 /// It should be used to set parameters which are not yet available through their own
5264 /// setters.
5265 ///
5266 /// Please note that this method must not be used to set any of the known parameters
5267 /// which have their own setter method. If done anyway, the request will fail.
5268 ///
5269 /// # Additional Parameters
5270 ///
5271 /// * *$.xgafv* (query-string) - V1 error format.
5272 /// * *access_token* (query-string) - OAuth access token.
5273 /// * *alt* (query-string) - Data format for response.
5274 /// * *callback* (query-string) - JSONP
5275 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5276 /// * *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.
5277 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5278 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5279 /// * *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.
5280 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5281 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5282 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationReservationGroupListCall<'a, C>
5283 where
5284 T: AsRef<str>,
5285 {
5286 self._additional_params
5287 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5288 self
5289 }
5290
5291 /// Identifies the authorization scope for the method you are building.
5292 ///
5293 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5294 /// [`Scope::CloudPlatform`].
5295 ///
5296 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5297 /// tokens for more than one scope.
5298 ///
5299 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5300 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5301 /// sufficient, a read-write scope will do as well.
5302 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationReservationGroupListCall<'a, C>
5303 where
5304 St: AsRef<str>,
5305 {
5306 self._scopes.insert(String::from(scope.as_ref()));
5307 self
5308 }
5309 /// Identifies the authorization scope(s) for the method you are building.
5310 ///
5311 /// See [`Self::add_scope()`] for details.
5312 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationReservationGroupListCall<'a, C>
5313 where
5314 I: IntoIterator<Item = St>,
5315 St: AsRef<str>,
5316 {
5317 self._scopes
5318 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5319 self
5320 }
5321
5322 /// Removes all scopes, and no default scope will be used either.
5323 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5324 /// for details).
5325 pub fn clear_scopes(mut self) -> ProjectLocationReservationGroupListCall<'a, C> {
5326 self._scopes.clear();
5327 self
5328 }
5329}
5330
5331/// Creates an assignment object which allows the given project to submit jobs of a certain type using slots from the specified reservation. Currently a resource (project, folder, organization) can only have one assignment per each (job_type, location) combination, and that reservation will be used for all jobs of the matching type. Different assignments can be created on different levels of the projects, folders or organization hierarchy. During query execution, the assignment is looked up at the project, folder and organization levels in that order. The first assignment found is applied to the query. When creating assignments, it does not matter if other assignments exist at higher levels. Example: * The organization `organizationA` contains two projects, `project1` and `project2`. * Assignments for all three entities (`organizationA`, `project1`, and `project2`) could all be created and mapped to the same or different reservations. "None" assignments represent an absence of the assignment. Projects assigned to None use on-demand pricing. To create a "None" assignment, use "none" as a reservation_id in the parent. Example parent: `projects/myproject/locations/US/reservations/none`. Returns `google.rpc.Code.PERMISSION_DENIED` if user does not have 'bigquery.admin' permissions on the project using the reservation and the project that owns this reservation. Returns `google.rpc.Code.INVALID_ARGUMENT` when location of the assignment does not match location of the reservation.
5332///
5333/// A builder for the *locations.reservations.assignments.create* method supported by a *project* resource.
5334/// It is not used directly, but through a [`ProjectMethods`] instance.
5335///
5336/// # Example
5337///
5338/// Instantiate a resource method builder
5339///
5340/// ```test_harness,no_run
5341/// # extern crate hyper;
5342/// # extern crate hyper_rustls;
5343/// # extern crate google_bigqueryreservation1 as bigqueryreservation1;
5344/// use bigqueryreservation1::api::Assignment;
5345/// # async fn dox() {
5346/// # use bigqueryreservation1::{BigQueryReservation, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5347///
5348/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5349/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5350/// # .with_native_roots()
5351/// # .unwrap()
5352/// # .https_only()
5353/// # .enable_http2()
5354/// # .build();
5355///
5356/// # let executor = hyper_util::rt::TokioExecutor::new();
5357/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5358/// # secret,
5359/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5360/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5361/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5362/// # ),
5363/// # ).build().await.unwrap();
5364///
5365/// # let client = hyper_util::client::legacy::Client::builder(
5366/// # hyper_util::rt::TokioExecutor::new()
5367/// # )
5368/// # .build(
5369/// # hyper_rustls::HttpsConnectorBuilder::new()
5370/// # .with_native_roots()
5371/// # .unwrap()
5372/// # .https_or_http()
5373/// # .enable_http2()
5374/// # .build()
5375/// # );
5376/// # let mut hub = BigQueryReservation::new(client, auth);
5377/// // As the method needs a request, you would usually fill it with the desired information
5378/// // into the respective structure. Some of the parts shown here might not be applicable !
5379/// // Values shown here are possibly random and not representative !
5380/// let mut req = Assignment::default();
5381///
5382/// // You can configure optional parameters by calling the respective setters at will, and
5383/// // execute the final call using `doit()`.
5384/// // Values shown here are possibly random and not representative !
5385/// let result = hub.projects().locations_reservations_assignments_create(req, "parent")
5386/// .assignment_id("gubergren")
5387/// .doit().await;
5388/// # }
5389/// ```
5390pub struct ProjectLocationReservationAssignmentCreateCall<'a, C>
5391where
5392 C: 'a,
5393{
5394 hub: &'a BigQueryReservation<C>,
5395 _request: Assignment,
5396 _parent: String,
5397 _assignment_id: Option<String>,
5398 _delegate: Option<&'a mut dyn common::Delegate>,
5399 _additional_params: HashMap<String, String>,
5400 _scopes: BTreeSet<String>,
5401}
5402
5403impl<'a, C> common::CallBuilder for ProjectLocationReservationAssignmentCreateCall<'a, C> {}
5404
5405impl<'a, C> ProjectLocationReservationAssignmentCreateCall<'a, C>
5406where
5407 C: common::Connector,
5408{
5409 /// Perform the operation you have build so far.
5410 pub async fn doit(mut self) -> common::Result<(common::Response, Assignment)> {
5411 use std::borrow::Cow;
5412 use std::io::{Read, Seek};
5413
5414 use common::{url::Params, ToParts};
5415 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5416
5417 let mut dd = common::DefaultDelegate;
5418 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5419 dlg.begin(common::MethodInfo {
5420 id: "bigqueryreservation.projects.locations.reservations.assignments.create",
5421 http_method: hyper::Method::POST,
5422 });
5423
5424 for &field in ["alt", "parent", "assignmentId"].iter() {
5425 if self._additional_params.contains_key(field) {
5426 dlg.finished(false);
5427 return Err(common::Error::FieldClash(field));
5428 }
5429 }
5430
5431 let mut params = Params::with_capacity(5 + self._additional_params.len());
5432 params.push("parent", self._parent);
5433 if let Some(value) = self._assignment_id.as_ref() {
5434 params.push("assignmentId", value);
5435 }
5436
5437 params.extend(self._additional_params.iter());
5438
5439 params.push("alt", "json");
5440 let mut url = self.hub._base_url.clone() + "v1/{+parent}/assignments";
5441 if self._scopes.is_empty() {
5442 self._scopes
5443 .insert(Scope::CloudPlatform.as_ref().to_string());
5444 }
5445
5446 #[allow(clippy::single_element_loop)]
5447 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
5448 url = params.uri_replacement(url, param_name, find_this, true);
5449 }
5450 {
5451 let to_remove = ["parent"];
5452 params.remove_params(&to_remove);
5453 }
5454
5455 let url = params.parse_with_url(&url);
5456
5457 let mut json_mime_type = mime::APPLICATION_JSON;
5458 let mut request_value_reader = {
5459 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
5460 common::remove_json_null_values(&mut value);
5461 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
5462 serde_json::to_writer(&mut dst, &value).unwrap();
5463 dst
5464 };
5465 let request_size = request_value_reader
5466 .seek(std::io::SeekFrom::End(0))
5467 .unwrap();
5468 request_value_reader
5469 .seek(std::io::SeekFrom::Start(0))
5470 .unwrap();
5471
5472 loop {
5473 let token = match self
5474 .hub
5475 .auth
5476 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5477 .await
5478 {
5479 Ok(token) => token,
5480 Err(e) => match dlg.token(e) {
5481 Ok(token) => token,
5482 Err(e) => {
5483 dlg.finished(false);
5484 return Err(common::Error::MissingToken(e));
5485 }
5486 },
5487 };
5488 request_value_reader
5489 .seek(std::io::SeekFrom::Start(0))
5490 .unwrap();
5491 let mut req_result = {
5492 let client = &self.hub.client;
5493 dlg.pre_request();
5494 let mut req_builder = hyper::Request::builder()
5495 .method(hyper::Method::POST)
5496 .uri(url.as_str())
5497 .header(USER_AGENT, self.hub._user_agent.clone());
5498
5499 if let Some(token) = token.as_ref() {
5500 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5501 }
5502
5503 let request = req_builder
5504 .header(CONTENT_TYPE, json_mime_type.to_string())
5505 .header(CONTENT_LENGTH, request_size as u64)
5506 .body(common::to_body(
5507 request_value_reader.get_ref().clone().into(),
5508 ));
5509
5510 client.request(request.unwrap()).await
5511 };
5512
5513 match req_result {
5514 Err(err) => {
5515 if let common::Retry::After(d) = dlg.http_error(&err) {
5516 sleep(d).await;
5517 continue;
5518 }
5519 dlg.finished(false);
5520 return Err(common::Error::HttpError(err));
5521 }
5522 Ok(res) => {
5523 let (mut parts, body) = res.into_parts();
5524 let mut body = common::Body::new(body);
5525 if !parts.status.is_success() {
5526 let bytes = common::to_bytes(body).await.unwrap_or_default();
5527 let error = serde_json::from_str(&common::to_string(&bytes));
5528 let response = common::to_response(parts, bytes.into());
5529
5530 if let common::Retry::After(d) =
5531 dlg.http_failure(&response, error.as_ref().ok())
5532 {
5533 sleep(d).await;
5534 continue;
5535 }
5536
5537 dlg.finished(false);
5538
5539 return Err(match error {
5540 Ok(value) => common::Error::BadRequest(value),
5541 _ => common::Error::Failure(response),
5542 });
5543 }
5544 let response = {
5545 let bytes = common::to_bytes(body).await.unwrap_or_default();
5546 let encoded = common::to_string(&bytes);
5547 match serde_json::from_str(&encoded) {
5548 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5549 Err(error) => {
5550 dlg.response_json_decode_error(&encoded, &error);
5551 return Err(common::Error::JsonDecodeError(
5552 encoded.to_string(),
5553 error,
5554 ));
5555 }
5556 }
5557 };
5558
5559 dlg.finished(true);
5560 return Ok(response);
5561 }
5562 }
5563 }
5564 }
5565
5566 ///
5567 /// Sets the *request* property to the given value.
5568 ///
5569 /// Even though the property as already been set when instantiating this call,
5570 /// we provide this method for API completeness.
5571 pub fn request(
5572 mut self,
5573 new_value: Assignment,
5574 ) -> ProjectLocationReservationAssignmentCreateCall<'a, C> {
5575 self._request = new_value;
5576 self
5577 }
5578 /// Required. The parent resource name of the assignment E.g. `projects/myproject/locations/US/reservations/team1-prod`
5579 ///
5580 /// Sets the *parent* path property to the given value.
5581 ///
5582 /// Even though the property as already been set when instantiating this call,
5583 /// we provide this method for API completeness.
5584 pub fn parent(
5585 mut self,
5586 new_value: &str,
5587 ) -> ProjectLocationReservationAssignmentCreateCall<'a, C> {
5588 self._parent = new_value.to_string();
5589 self
5590 }
5591 /// The optional assignment ID. Assignment name will be generated automatically if this field is empty. This field must only contain lower case alphanumeric characters or dashes. Max length is 64 characters.
5592 ///
5593 /// Sets the *assignment id* query property to the given value.
5594 pub fn assignment_id(
5595 mut self,
5596 new_value: &str,
5597 ) -> ProjectLocationReservationAssignmentCreateCall<'a, C> {
5598 self._assignment_id = Some(new_value.to_string());
5599 self
5600 }
5601 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5602 /// while executing the actual API request.
5603 ///
5604 /// ````text
5605 /// It should be used to handle progress information, and to implement a certain level of resilience.
5606 /// ````
5607 ///
5608 /// Sets the *delegate* property to the given value.
5609 pub fn delegate(
5610 mut self,
5611 new_value: &'a mut dyn common::Delegate,
5612 ) -> ProjectLocationReservationAssignmentCreateCall<'a, C> {
5613 self._delegate = Some(new_value);
5614 self
5615 }
5616
5617 /// Set any additional parameter of the query string used in the request.
5618 /// It should be used to set parameters which are not yet available through their own
5619 /// setters.
5620 ///
5621 /// Please note that this method must not be used to set any of the known parameters
5622 /// which have their own setter method. If done anyway, the request will fail.
5623 ///
5624 /// # Additional Parameters
5625 ///
5626 /// * *$.xgafv* (query-string) - V1 error format.
5627 /// * *access_token* (query-string) - OAuth access token.
5628 /// * *alt* (query-string) - Data format for response.
5629 /// * *callback* (query-string) - JSONP
5630 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5631 /// * *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.
5632 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5633 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5634 /// * *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.
5635 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5636 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5637 pub fn param<T>(
5638 mut self,
5639 name: T,
5640 value: T,
5641 ) -> ProjectLocationReservationAssignmentCreateCall<'a, C>
5642 where
5643 T: AsRef<str>,
5644 {
5645 self._additional_params
5646 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5647 self
5648 }
5649
5650 /// Identifies the authorization scope for the method you are building.
5651 ///
5652 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5653 /// [`Scope::CloudPlatform`].
5654 ///
5655 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5656 /// tokens for more than one scope.
5657 ///
5658 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5659 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5660 /// sufficient, a read-write scope will do as well.
5661 pub fn add_scope<St>(
5662 mut self,
5663 scope: St,
5664 ) -> ProjectLocationReservationAssignmentCreateCall<'a, C>
5665 where
5666 St: AsRef<str>,
5667 {
5668 self._scopes.insert(String::from(scope.as_ref()));
5669 self
5670 }
5671 /// Identifies the authorization scope(s) for the method you are building.
5672 ///
5673 /// See [`Self::add_scope()`] for details.
5674 pub fn add_scopes<I, St>(
5675 mut self,
5676 scopes: I,
5677 ) -> ProjectLocationReservationAssignmentCreateCall<'a, C>
5678 where
5679 I: IntoIterator<Item = St>,
5680 St: AsRef<str>,
5681 {
5682 self._scopes
5683 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5684 self
5685 }
5686
5687 /// Removes all scopes, and no default scope will be used either.
5688 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5689 /// for details).
5690 pub fn clear_scopes(mut self) -> ProjectLocationReservationAssignmentCreateCall<'a, C> {
5691 self._scopes.clear();
5692 self
5693 }
5694}
5695
5696/// Deletes a assignment. No expansion will happen. Example: * Organization `organizationA` contains two projects, `project1` and `project2`. * Reservation `res1` exists and was created previously. * CreateAssignment was used previously to define the following associations between entities and reservations: `` and `` In this example, deletion of the `` assignment won't affect the other assignment ``. After said deletion, queries from `project1` will still use `res1` while queries from `project2` will switch to use on-demand mode.
5697///
5698/// A builder for the *locations.reservations.assignments.delete* method supported by a *project* resource.
5699/// It is not used directly, but through a [`ProjectMethods`] instance.
5700///
5701/// # Example
5702///
5703/// Instantiate a resource method builder
5704///
5705/// ```test_harness,no_run
5706/// # extern crate hyper;
5707/// # extern crate hyper_rustls;
5708/// # extern crate google_bigqueryreservation1 as bigqueryreservation1;
5709/// # async fn dox() {
5710/// # use bigqueryreservation1::{BigQueryReservation, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
5711///
5712/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
5713/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
5714/// # .with_native_roots()
5715/// # .unwrap()
5716/// # .https_only()
5717/// # .enable_http2()
5718/// # .build();
5719///
5720/// # let executor = hyper_util::rt::TokioExecutor::new();
5721/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
5722/// # secret,
5723/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
5724/// # yup_oauth2::client::CustomHyperClientBuilder::from(
5725/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
5726/// # ),
5727/// # ).build().await.unwrap();
5728///
5729/// # let client = hyper_util::client::legacy::Client::builder(
5730/// # hyper_util::rt::TokioExecutor::new()
5731/// # )
5732/// # .build(
5733/// # hyper_rustls::HttpsConnectorBuilder::new()
5734/// # .with_native_roots()
5735/// # .unwrap()
5736/// # .https_or_http()
5737/// # .enable_http2()
5738/// # .build()
5739/// # );
5740/// # let mut hub = BigQueryReservation::new(client, auth);
5741/// // You can configure optional parameters by calling the respective setters at will, and
5742/// // execute the final call using `doit()`.
5743/// // Values shown here are possibly random and not representative !
5744/// let result = hub.projects().locations_reservations_assignments_delete("name")
5745/// .doit().await;
5746/// # }
5747/// ```
5748pub struct ProjectLocationReservationAssignmentDeleteCall<'a, C>
5749where
5750 C: 'a,
5751{
5752 hub: &'a BigQueryReservation<C>,
5753 _name: String,
5754 _delegate: Option<&'a mut dyn common::Delegate>,
5755 _additional_params: HashMap<String, String>,
5756 _scopes: BTreeSet<String>,
5757}
5758
5759impl<'a, C> common::CallBuilder for ProjectLocationReservationAssignmentDeleteCall<'a, C> {}
5760
5761impl<'a, C> ProjectLocationReservationAssignmentDeleteCall<'a, C>
5762where
5763 C: common::Connector,
5764{
5765 /// Perform the operation you have build so far.
5766 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
5767 use std::borrow::Cow;
5768 use std::io::{Read, Seek};
5769
5770 use common::{url::Params, ToParts};
5771 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
5772
5773 let mut dd = common::DefaultDelegate;
5774 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
5775 dlg.begin(common::MethodInfo {
5776 id: "bigqueryreservation.projects.locations.reservations.assignments.delete",
5777 http_method: hyper::Method::DELETE,
5778 });
5779
5780 for &field in ["alt", "name"].iter() {
5781 if self._additional_params.contains_key(field) {
5782 dlg.finished(false);
5783 return Err(common::Error::FieldClash(field));
5784 }
5785 }
5786
5787 let mut params = Params::with_capacity(3 + self._additional_params.len());
5788 params.push("name", self._name);
5789
5790 params.extend(self._additional_params.iter());
5791
5792 params.push("alt", "json");
5793 let mut url = self.hub._base_url.clone() + "v1/{+name}";
5794 if self._scopes.is_empty() {
5795 self._scopes
5796 .insert(Scope::CloudPlatform.as_ref().to_string());
5797 }
5798
5799 #[allow(clippy::single_element_loop)]
5800 for &(find_this, param_name) in [("{+name}", "name")].iter() {
5801 url = params.uri_replacement(url, param_name, find_this, true);
5802 }
5803 {
5804 let to_remove = ["name"];
5805 params.remove_params(&to_remove);
5806 }
5807
5808 let url = params.parse_with_url(&url);
5809
5810 loop {
5811 let token = match self
5812 .hub
5813 .auth
5814 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
5815 .await
5816 {
5817 Ok(token) => token,
5818 Err(e) => match dlg.token(e) {
5819 Ok(token) => token,
5820 Err(e) => {
5821 dlg.finished(false);
5822 return Err(common::Error::MissingToken(e));
5823 }
5824 },
5825 };
5826 let mut req_result = {
5827 let client = &self.hub.client;
5828 dlg.pre_request();
5829 let mut req_builder = hyper::Request::builder()
5830 .method(hyper::Method::DELETE)
5831 .uri(url.as_str())
5832 .header(USER_AGENT, self.hub._user_agent.clone());
5833
5834 if let Some(token) = token.as_ref() {
5835 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
5836 }
5837
5838 let request = req_builder
5839 .header(CONTENT_LENGTH, 0_u64)
5840 .body(common::to_body::<String>(None));
5841
5842 client.request(request.unwrap()).await
5843 };
5844
5845 match req_result {
5846 Err(err) => {
5847 if let common::Retry::After(d) = dlg.http_error(&err) {
5848 sleep(d).await;
5849 continue;
5850 }
5851 dlg.finished(false);
5852 return Err(common::Error::HttpError(err));
5853 }
5854 Ok(res) => {
5855 let (mut parts, body) = res.into_parts();
5856 let mut body = common::Body::new(body);
5857 if !parts.status.is_success() {
5858 let bytes = common::to_bytes(body).await.unwrap_or_default();
5859 let error = serde_json::from_str(&common::to_string(&bytes));
5860 let response = common::to_response(parts, bytes.into());
5861
5862 if let common::Retry::After(d) =
5863 dlg.http_failure(&response, error.as_ref().ok())
5864 {
5865 sleep(d).await;
5866 continue;
5867 }
5868
5869 dlg.finished(false);
5870
5871 return Err(match error {
5872 Ok(value) => common::Error::BadRequest(value),
5873 _ => common::Error::Failure(response),
5874 });
5875 }
5876 let response = {
5877 let bytes = common::to_bytes(body).await.unwrap_or_default();
5878 let encoded = common::to_string(&bytes);
5879 match serde_json::from_str(&encoded) {
5880 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
5881 Err(error) => {
5882 dlg.response_json_decode_error(&encoded, &error);
5883 return Err(common::Error::JsonDecodeError(
5884 encoded.to_string(),
5885 error,
5886 ));
5887 }
5888 }
5889 };
5890
5891 dlg.finished(true);
5892 return Ok(response);
5893 }
5894 }
5895 }
5896 }
5897
5898 /// Required. Name of the resource, e.g. `projects/myproject/locations/US/reservations/team1-prod/assignments/123`
5899 ///
5900 /// Sets the *name* path property to the given value.
5901 ///
5902 /// Even though the property as already been set when instantiating this call,
5903 /// we provide this method for API completeness.
5904 pub fn name(
5905 mut self,
5906 new_value: &str,
5907 ) -> ProjectLocationReservationAssignmentDeleteCall<'a, C> {
5908 self._name = new_value.to_string();
5909 self
5910 }
5911 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
5912 /// while executing the actual API request.
5913 ///
5914 /// ````text
5915 /// It should be used to handle progress information, and to implement a certain level of resilience.
5916 /// ````
5917 ///
5918 /// Sets the *delegate* property to the given value.
5919 pub fn delegate(
5920 mut self,
5921 new_value: &'a mut dyn common::Delegate,
5922 ) -> ProjectLocationReservationAssignmentDeleteCall<'a, C> {
5923 self._delegate = Some(new_value);
5924 self
5925 }
5926
5927 /// Set any additional parameter of the query string used in the request.
5928 /// It should be used to set parameters which are not yet available through their own
5929 /// setters.
5930 ///
5931 /// Please note that this method must not be used to set any of the known parameters
5932 /// which have their own setter method. If done anyway, the request will fail.
5933 ///
5934 /// # Additional Parameters
5935 ///
5936 /// * *$.xgafv* (query-string) - V1 error format.
5937 /// * *access_token* (query-string) - OAuth access token.
5938 /// * *alt* (query-string) - Data format for response.
5939 /// * *callback* (query-string) - JSONP
5940 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
5941 /// * *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.
5942 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
5943 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
5944 /// * *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.
5945 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
5946 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
5947 pub fn param<T>(
5948 mut self,
5949 name: T,
5950 value: T,
5951 ) -> ProjectLocationReservationAssignmentDeleteCall<'a, C>
5952 where
5953 T: AsRef<str>,
5954 {
5955 self._additional_params
5956 .insert(name.as_ref().to_string(), value.as_ref().to_string());
5957 self
5958 }
5959
5960 /// Identifies the authorization scope for the method you are building.
5961 ///
5962 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
5963 /// [`Scope::CloudPlatform`].
5964 ///
5965 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
5966 /// tokens for more than one scope.
5967 ///
5968 /// Usually there is more than one suitable scope to authorize an operation, some of which may
5969 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
5970 /// sufficient, a read-write scope will do as well.
5971 pub fn add_scope<St>(
5972 mut self,
5973 scope: St,
5974 ) -> ProjectLocationReservationAssignmentDeleteCall<'a, C>
5975 where
5976 St: AsRef<str>,
5977 {
5978 self._scopes.insert(String::from(scope.as_ref()));
5979 self
5980 }
5981 /// Identifies the authorization scope(s) for the method you are building.
5982 ///
5983 /// See [`Self::add_scope()`] for details.
5984 pub fn add_scopes<I, St>(
5985 mut self,
5986 scopes: I,
5987 ) -> ProjectLocationReservationAssignmentDeleteCall<'a, C>
5988 where
5989 I: IntoIterator<Item = St>,
5990 St: AsRef<str>,
5991 {
5992 self._scopes
5993 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
5994 self
5995 }
5996
5997 /// Removes all scopes, and no default scope will be used either.
5998 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
5999 /// for details).
6000 pub fn clear_scopes(mut self) -> ProjectLocationReservationAssignmentDeleteCall<'a, C> {
6001 self._scopes.clear();
6002 self
6003 }
6004}
6005
6006/// Gets the access control policy for a resource. May return: * A`NOT_FOUND` error if the resource doesn't exist or you don't have the permission to view it. * An empty policy if the resource exists but doesn't have a set policy. Supported resources are: - Reservations - ReservationAssignments To call this method, you must have the following Google IAM permissions: - `bigqueryreservation.reservations.getIamPolicy` to get policies on reservations.
6007///
6008/// A builder for the *locations.reservations.assignments.getIamPolicy* method supported by a *project* resource.
6009/// It is not used directly, but through a [`ProjectMethods`] instance.
6010///
6011/// # Example
6012///
6013/// Instantiate a resource method builder
6014///
6015/// ```test_harness,no_run
6016/// # extern crate hyper;
6017/// # extern crate hyper_rustls;
6018/// # extern crate google_bigqueryreservation1 as bigqueryreservation1;
6019/// # async fn dox() {
6020/// # use bigqueryreservation1::{BigQueryReservation, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6021///
6022/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6023/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6024/// # .with_native_roots()
6025/// # .unwrap()
6026/// # .https_only()
6027/// # .enable_http2()
6028/// # .build();
6029///
6030/// # let executor = hyper_util::rt::TokioExecutor::new();
6031/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6032/// # secret,
6033/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6034/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6035/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6036/// # ),
6037/// # ).build().await.unwrap();
6038///
6039/// # let client = hyper_util::client::legacy::Client::builder(
6040/// # hyper_util::rt::TokioExecutor::new()
6041/// # )
6042/// # .build(
6043/// # hyper_rustls::HttpsConnectorBuilder::new()
6044/// # .with_native_roots()
6045/// # .unwrap()
6046/// # .https_or_http()
6047/// # .enable_http2()
6048/// # .build()
6049/// # );
6050/// # let mut hub = BigQueryReservation::new(client, auth);
6051/// // You can configure optional parameters by calling the respective setters at will, and
6052/// // execute the final call using `doit()`.
6053/// // Values shown here are possibly random and not representative !
6054/// let result = hub.projects().locations_reservations_assignments_get_iam_policy("resource")
6055/// .options_requested_policy_version(-50)
6056/// .doit().await;
6057/// # }
6058/// ```
6059pub struct ProjectLocationReservationAssignmentGetIamPolicyCall<'a, C>
6060where
6061 C: 'a,
6062{
6063 hub: &'a BigQueryReservation<C>,
6064 _resource: String,
6065 _options_requested_policy_version: Option<i32>,
6066 _delegate: Option<&'a mut dyn common::Delegate>,
6067 _additional_params: HashMap<String, String>,
6068 _scopes: BTreeSet<String>,
6069}
6070
6071impl<'a, C> common::CallBuilder for ProjectLocationReservationAssignmentGetIamPolicyCall<'a, C> {}
6072
6073impl<'a, C> ProjectLocationReservationAssignmentGetIamPolicyCall<'a, C>
6074where
6075 C: common::Connector,
6076{
6077 /// Perform the operation you have build so far.
6078 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
6079 use std::borrow::Cow;
6080 use std::io::{Read, Seek};
6081
6082 use common::{url::Params, ToParts};
6083 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6084
6085 let mut dd = common::DefaultDelegate;
6086 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6087 dlg.begin(common::MethodInfo {
6088 id: "bigqueryreservation.projects.locations.reservations.assignments.getIamPolicy",
6089 http_method: hyper::Method::GET,
6090 });
6091
6092 for &field in ["alt", "resource", "options.requestedPolicyVersion"].iter() {
6093 if self._additional_params.contains_key(field) {
6094 dlg.finished(false);
6095 return Err(common::Error::FieldClash(field));
6096 }
6097 }
6098
6099 let mut params = Params::with_capacity(4 + self._additional_params.len());
6100 params.push("resource", self._resource);
6101 if let Some(value) = self._options_requested_policy_version.as_ref() {
6102 params.push("options.requestedPolicyVersion", value.to_string());
6103 }
6104
6105 params.extend(self._additional_params.iter());
6106
6107 params.push("alt", "json");
6108 let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
6109 if self._scopes.is_empty() {
6110 self._scopes
6111 .insert(Scope::CloudPlatform.as_ref().to_string());
6112 }
6113
6114 #[allow(clippy::single_element_loop)]
6115 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
6116 url = params.uri_replacement(url, param_name, find_this, true);
6117 }
6118 {
6119 let to_remove = ["resource"];
6120 params.remove_params(&to_remove);
6121 }
6122
6123 let url = params.parse_with_url(&url);
6124
6125 loop {
6126 let token = match self
6127 .hub
6128 .auth
6129 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6130 .await
6131 {
6132 Ok(token) => token,
6133 Err(e) => match dlg.token(e) {
6134 Ok(token) => token,
6135 Err(e) => {
6136 dlg.finished(false);
6137 return Err(common::Error::MissingToken(e));
6138 }
6139 },
6140 };
6141 let mut req_result = {
6142 let client = &self.hub.client;
6143 dlg.pre_request();
6144 let mut req_builder = hyper::Request::builder()
6145 .method(hyper::Method::GET)
6146 .uri(url.as_str())
6147 .header(USER_AGENT, self.hub._user_agent.clone());
6148
6149 if let Some(token) = token.as_ref() {
6150 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6151 }
6152
6153 let request = req_builder
6154 .header(CONTENT_LENGTH, 0_u64)
6155 .body(common::to_body::<String>(None));
6156
6157 client.request(request.unwrap()).await
6158 };
6159
6160 match req_result {
6161 Err(err) => {
6162 if let common::Retry::After(d) = dlg.http_error(&err) {
6163 sleep(d).await;
6164 continue;
6165 }
6166 dlg.finished(false);
6167 return Err(common::Error::HttpError(err));
6168 }
6169 Ok(res) => {
6170 let (mut parts, body) = res.into_parts();
6171 let mut body = common::Body::new(body);
6172 if !parts.status.is_success() {
6173 let bytes = common::to_bytes(body).await.unwrap_or_default();
6174 let error = serde_json::from_str(&common::to_string(&bytes));
6175 let response = common::to_response(parts, bytes.into());
6176
6177 if let common::Retry::After(d) =
6178 dlg.http_failure(&response, error.as_ref().ok())
6179 {
6180 sleep(d).await;
6181 continue;
6182 }
6183
6184 dlg.finished(false);
6185
6186 return Err(match error {
6187 Ok(value) => common::Error::BadRequest(value),
6188 _ => common::Error::Failure(response),
6189 });
6190 }
6191 let response = {
6192 let bytes = common::to_bytes(body).await.unwrap_or_default();
6193 let encoded = common::to_string(&bytes);
6194 match serde_json::from_str(&encoded) {
6195 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6196 Err(error) => {
6197 dlg.response_json_decode_error(&encoded, &error);
6198 return Err(common::Error::JsonDecodeError(
6199 encoded.to_string(),
6200 error,
6201 ));
6202 }
6203 }
6204 };
6205
6206 dlg.finished(true);
6207 return Ok(response);
6208 }
6209 }
6210 }
6211 }
6212
6213 /// 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.
6214 ///
6215 /// Sets the *resource* path property to the given value.
6216 ///
6217 /// Even though the property as already been set when instantiating this call,
6218 /// we provide this method for API completeness.
6219 pub fn resource(
6220 mut self,
6221 new_value: &str,
6222 ) -> ProjectLocationReservationAssignmentGetIamPolicyCall<'a, C> {
6223 self._resource = new_value.to_string();
6224 self
6225 }
6226 /// 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).
6227 ///
6228 /// Sets the *options.requested policy version* query property to the given value.
6229 pub fn options_requested_policy_version(
6230 mut self,
6231 new_value: i32,
6232 ) -> ProjectLocationReservationAssignmentGetIamPolicyCall<'a, C> {
6233 self._options_requested_policy_version = Some(new_value);
6234 self
6235 }
6236 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6237 /// while executing the actual API request.
6238 ///
6239 /// ````text
6240 /// It should be used to handle progress information, and to implement a certain level of resilience.
6241 /// ````
6242 ///
6243 /// Sets the *delegate* property to the given value.
6244 pub fn delegate(
6245 mut self,
6246 new_value: &'a mut dyn common::Delegate,
6247 ) -> ProjectLocationReservationAssignmentGetIamPolicyCall<'a, C> {
6248 self._delegate = Some(new_value);
6249 self
6250 }
6251
6252 /// Set any additional parameter of the query string used in the request.
6253 /// It should be used to set parameters which are not yet available through their own
6254 /// setters.
6255 ///
6256 /// Please note that this method must not be used to set any of the known parameters
6257 /// which have their own setter method. If done anyway, the request will fail.
6258 ///
6259 /// # Additional Parameters
6260 ///
6261 /// * *$.xgafv* (query-string) - V1 error format.
6262 /// * *access_token* (query-string) - OAuth access token.
6263 /// * *alt* (query-string) - Data format for response.
6264 /// * *callback* (query-string) - JSONP
6265 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6266 /// * *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.
6267 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6268 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6269 /// * *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.
6270 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6271 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6272 pub fn param<T>(
6273 mut self,
6274 name: T,
6275 value: T,
6276 ) -> ProjectLocationReservationAssignmentGetIamPolicyCall<'a, C>
6277 where
6278 T: AsRef<str>,
6279 {
6280 self._additional_params
6281 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6282 self
6283 }
6284
6285 /// Identifies the authorization scope for the method you are building.
6286 ///
6287 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6288 /// [`Scope::CloudPlatform`].
6289 ///
6290 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6291 /// tokens for more than one scope.
6292 ///
6293 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6294 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6295 /// sufficient, a read-write scope will do as well.
6296 pub fn add_scope<St>(
6297 mut self,
6298 scope: St,
6299 ) -> ProjectLocationReservationAssignmentGetIamPolicyCall<'a, C>
6300 where
6301 St: AsRef<str>,
6302 {
6303 self._scopes.insert(String::from(scope.as_ref()));
6304 self
6305 }
6306 /// Identifies the authorization scope(s) for the method you are building.
6307 ///
6308 /// See [`Self::add_scope()`] for details.
6309 pub fn add_scopes<I, St>(
6310 mut self,
6311 scopes: I,
6312 ) -> ProjectLocationReservationAssignmentGetIamPolicyCall<'a, C>
6313 where
6314 I: IntoIterator<Item = St>,
6315 St: AsRef<str>,
6316 {
6317 self._scopes
6318 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6319 self
6320 }
6321
6322 /// Removes all scopes, and no default scope will be used either.
6323 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6324 /// for details).
6325 pub fn clear_scopes(mut self) -> ProjectLocationReservationAssignmentGetIamPolicyCall<'a, C> {
6326 self._scopes.clear();
6327 self
6328 }
6329}
6330
6331/// Lists assignments. Only explicitly created assignments will be returned. Example: * Organization `organizationA` contains two projects, `project1` and `project2`. * Reservation `res1` exists and was created previously. * CreateAssignment was used previously to define the following associations between entities and reservations: `` and `` In this example, ListAssignments will just return the above two assignments for reservation `res1`, and no expansion/merge will happen. The wildcard "-" can be used for reservations in the request. In that case all assignments belongs to the specified project and location will be listed. **Note** "-" cannot be used for projects nor locations.
6332///
6333/// A builder for the *locations.reservations.assignments.list* method supported by a *project* resource.
6334/// It is not used directly, but through a [`ProjectMethods`] instance.
6335///
6336/// # Example
6337///
6338/// Instantiate a resource method builder
6339///
6340/// ```test_harness,no_run
6341/// # extern crate hyper;
6342/// # extern crate hyper_rustls;
6343/// # extern crate google_bigqueryreservation1 as bigqueryreservation1;
6344/// # async fn dox() {
6345/// # use bigqueryreservation1::{BigQueryReservation, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6346///
6347/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6348/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6349/// # .with_native_roots()
6350/// # .unwrap()
6351/// # .https_only()
6352/// # .enable_http2()
6353/// # .build();
6354///
6355/// # let executor = hyper_util::rt::TokioExecutor::new();
6356/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6357/// # secret,
6358/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6359/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6360/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6361/// # ),
6362/// # ).build().await.unwrap();
6363///
6364/// # let client = hyper_util::client::legacy::Client::builder(
6365/// # hyper_util::rt::TokioExecutor::new()
6366/// # )
6367/// # .build(
6368/// # hyper_rustls::HttpsConnectorBuilder::new()
6369/// # .with_native_roots()
6370/// # .unwrap()
6371/// # .https_or_http()
6372/// # .enable_http2()
6373/// # .build()
6374/// # );
6375/// # let mut hub = BigQueryReservation::new(client, auth);
6376/// // You can configure optional parameters by calling the respective setters at will, and
6377/// // execute the final call using `doit()`.
6378/// // Values shown here are possibly random and not representative !
6379/// let result = hub.projects().locations_reservations_assignments_list("parent")
6380/// .page_token("est")
6381/// .page_size(-62)
6382/// .doit().await;
6383/// # }
6384/// ```
6385pub struct ProjectLocationReservationAssignmentListCall<'a, C>
6386where
6387 C: 'a,
6388{
6389 hub: &'a BigQueryReservation<C>,
6390 _parent: String,
6391 _page_token: Option<String>,
6392 _page_size: Option<i32>,
6393 _delegate: Option<&'a mut dyn common::Delegate>,
6394 _additional_params: HashMap<String, String>,
6395 _scopes: BTreeSet<String>,
6396}
6397
6398impl<'a, C> common::CallBuilder for ProjectLocationReservationAssignmentListCall<'a, C> {}
6399
6400impl<'a, C> ProjectLocationReservationAssignmentListCall<'a, C>
6401where
6402 C: common::Connector,
6403{
6404 /// Perform the operation you have build so far.
6405 pub async fn doit(mut self) -> common::Result<(common::Response, ListAssignmentsResponse)> {
6406 use std::borrow::Cow;
6407 use std::io::{Read, Seek};
6408
6409 use common::{url::Params, ToParts};
6410 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6411
6412 let mut dd = common::DefaultDelegate;
6413 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6414 dlg.begin(common::MethodInfo {
6415 id: "bigqueryreservation.projects.locations.reservations.assignments.list",
6416 http_method: hyper::Method::GET,
6417 });
6418
6419 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
6420 if self._additional_params.contains_key(field) {
6421 dlg.finished(false);
6422 return Err(common::Error::FieldClash(field));
6423 }
6424 }
6425
6426 let mut params = Params::with_capacity(5 + self._additional_params.len());
6427 params.push("parent", self._parent);
6428 if let Some(value) = self._page_token.as_ref() {
6429 params.push("pageToken", value);
6430 }
6431 if let Some(value) = self._page_size.as_ref() {
6432 params.push("pageSize", value.to_string());
6433 }
6434
6435 params.extend(self._additional_params.iter());
6436
6437 params.push("alt", "json");
6438 let mut url = self.hub._base_url.clone() + "v1/{+parent}/assignments";
6439 if self._scopes.is_empty() {
6440 self._scopes
6441 .insert(Scope::CloudPlatform.as_ref().to_string());
6442 }
6443
6444 #[allow(clippy::single_element_loop)]
6445 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
6446 url = params.uri_replacement(url, param_name, find_this, true);
6447 }
6448 {
6449 let to_remove = ["parent"];
6450 params.remove_params(&to_remove);
6451 }
6452
6453 let url = params.parse_with_url(&url);
6454
6455 loop {
6456 let token = match self
6457 .hub
6458 .auth
6459 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6460 .await
6461 {
6462 Ok(token) => token,
6463 Err(e) => match dlg.token(e) {
6464 Ok(token) => token,
6465 Err(e) => {
6466 dlg.finished(false);
6467 return Err(common::Error::MissingToken(e));
6468 }
6469 },
6470 };
6471 let mut req_result = {
6472 let client = &self.hub.client;
6473 dlg.pre_request();
6474 let mut req_builder = hyper::Request::builder()
6475 .method(hyper::Method::GET)
6476 .uri(url.as_str())
6477 .header(USER_AGENT, self.hub._user_agent.clone());
6478
6479 if let Some(token) = token.as_ref() {
6480 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6481 }
6482
6483 let request = req_builder
6484 .header(CONTENT_LENGTH, 0_u64)
6485 .body(common::to_body::<String>(None));
6486
6487 client.request(request.unwrap()).await
6488 };
6489
6490 match req_result {
6491 Err(err) => {
6492 if let common::Retry::After(d) = dlg.http_error(&err) {
6493 sleep(d).await;
6494 continue;
6495 }
6496 dlg.finished(false);
6497 return Err(common::Error::HttpError(err));
6498 }
6499 Ok(res) => {
6500 let (mut parts, body) = res.into_parts();
6501 let mut body = common::Body::new(body);
6502 if !parts.status.is_success() {
6503 let bytes = common::to_bytes(body).await.unwrap_or_default();
6504 let error = serde_json::from_str(&common::to_string(&bytes));
6505 let response = common::to_response(parts, bytes.into());
6506
6507 if let common::Retry::After(d) =
6508 dlg.http_failure(&response, error.as_ref().ok())
6509 {
6510 sleep(d).await;
6511 continue;
6512 }
6513
6514 dlg.finished(false);
6515
6516 return Err(match error {
6517 Ok(value) => common::Error::BadRequest(value),
6518 _ => common::Error::Failure(response),
6519 });
6520 }
6521 let response = {
6522 let bytes = common::to_bytes(body).await.unwrap_or_default();
6523 let encoded = common::to_string(&bytes);
6524 match serde_json::from_str(&encoded) {
6525 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6526 Err(error) => {
6527 dlg.response_json_decode_error(&encoded, &error);
6528 return Err(common::Error::JsonDecodeError(
6529 encoded.to_string(),
6530 error,
6531 ));
6532 }
6533 }
6534 };
6535
6536 dlg.finished(true);
6537 return Ok(response);
6538 }
6539 }
6540 }
6541 }
6542
6543 /// Required. The parent resource name e.g.: `projects/myproject/locations/US/reservations/team1-prod` Or: `projects/myproject/locations/US/reservations/-`
6544 ///
6545 /// Sets the *parent* path property to the given value.
6546 ///
6547 /// Even though the property as already been set when instantiating this call,
6548 /// we provide this method for API completeness.
6549 pub fn parent(
6550 mut self,
6551 new_value: &str,
6552 ) -> ProjectLocationReservationAssignmentListCall<'a, C> {
6553 self._parent = new_value.to_string();
6554 self
6555 }
6556 /// The next_page_token value returned from a previous List request, if any.
6557 ///
6558 /// Sets the *page token* query property to the given value.
6559 pub fn page_token(
6560 mut self,
6561 new_value: &str,
6562 ) -> ProjectLocationReservationAssignmentListCall<'a, C> {
6563 self._page_token = Some(new_value.to_string());
6564 self
6565 }
6566 /// The maximum number of items to return per page.
6567 ///
6568 /// Sets the *page size* query property to the given value.
6569 pub fn page_size(
6570 mut self,
6571 new_value: i32,
6572 ) -> ProjectLocationReservationAssignmentListCall<'a, C> {
6573 self._page_size = Some(new_value);
6574 self
6575 }
6576 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6577 /// while executing the actual API request.
6578 ///
6579 /// ````text
6580 /// It should be used to handle progress information, and to implement a certain level of resilience.
6581 /// ````
6582 ///
6583 /// Sets the *delegate* property to the given value.
6584 pub fn delegate(
6585 mut self,
6586 new_value: &'a mut dyn common::Delegate,
6587 ) -> ProjectLocationReservationAssignmentListCall<'a, C> {
6588 self._delegate = Some(new_value);
6589 self
6590 }
6591
6592 /// Set any additional parameter of the query string used in the request.
6593 /// It should be used to set parameters which are not yet available through their own
6594 /// setters.
6595 ///
6596 /// Please note that this method must not be used to set any of the known parameters
6597 /// which have their own setter method. If done anyway, the request will fail.
6598 ///
6599 /// # Additional Parameters
6600 ///
6601 /// * *$.xgafv* (query-string) - V1 error format.
6602 /// * *access_token* (query-string) - OAuth access token.
6603 /// * *alt* (query-string) - Data format for response.
6604 /// * *callback* (query-string) - JSONP
6605 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6606 /// * *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.
6607 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6608 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6609 /// * *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.
6610 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6611 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6612 pub fn param<T>(
6613 mut self,
6614 name: T,
6615 value: T,
6616 ) -> ProjectLocationReservationAssignmentListCall<'a, C>
6617 where
6618 T: AsRef<str>,
6619 {
6620 self._additional_params
6621 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6622 self
6623 }
6624
6625 /// Identifies the authorization scope for the method you are building.
6626 ///
6627 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6628 /// [`Scope::CloudPlatform`].
6629 ///
6630 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6631 /// tokens for more than one scope.
6632 ///
6633 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6634 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6635 /// sufficient, a read-write scope will do as well.
6636 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationReservationAssignmentListCall<'a, C>
6637 where
6638 St: AsRef<str>,
6639 {
6640 self._scopes.insert(String::from(scope.as_ref()));
6641 self
6642 }
6643 /// Identifies the authorization scope(s) for the method you are building.
6644 ///
6645 /// See [`Self::add_scope()`] for details.
6646 pub fn add_scopes<I, St>(
6647 mut self,
6648 scopes: I,
6649 ) -> ProjectLocationReservationAssignmentListCall<'a, C>
6650 where
6651 I: IntoIterator<Item = St>,
6652 St: AsRef<str>,
6653 {
6654 self._scopes
6655 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
6656 self
6657 }
6658
6659 /// Removes all scopes, and no default scope will be used either.
6660 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
6661 /// for details).
6662 pub fn clear_scopes(mut self) -> ProjectLocationReservationAssignmentListCall<'a, C> {
6663 self._scopes.clear();
6664 self
6665 }
6666}
6667
6668/// Moves an assignment under a new reservation. This differs from removing an existing assignment and recreating a new one by providing a transactional change that ensures an assignee always has an associated reservation.
6669///
6670/// A builder for the *locations.reservations.assignments.move* method supported by a *project* resource.
6671/// It is not used directly, but through a [`ProjectMethods`] instance.
6672///
6673/// # Example
6674///
6675/// Instantiate a resource method builder
6676///
6677/// ```test_harness,no_run
6678/// # extern crate hyper;
6679/// # extern crate hyper_rustls;
6680/// # extern crate google_bigqueryreservation1 as bigqueryreservation1;
6681/// use bigqueryreservation1::api::MoveAssignmentRequest;
6682/// # async fn dox() {
6683/// # use bigqueryreservation1::{BigQueryReservation, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
6684///
6685/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
6686/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
6687/// # .with_native_roots()
6688/// # .unwrap()
6689/// # .https_only()
6690/// # .enable_http2()
6691/// # .build();
6692///
6693/// # let executor = hyper_util::rt::TokioExecutor::new();
6694/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
6695/// # secret,
6696/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
6697/// # yup_oauth2::client::CustomHyperClientBuilder::from(
6698/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
6699/// # ),
6700/// # ).build().await.unwrap();
6701///
6702/// # let client = hyper_util::client::legacy::Client::builder(
6703/// # hyper_util::rt::TokioExecutor::new()
6704/// # )
6705/// # .build(
6706/// # hyper_rustls::HttpsConnectorBuilder::new()
6707/// # .with_native_roots()
6708/// # .unwrap()
6709/// # .https_or_http()
6710/// # .enable_http2()
6711/// # .build()
6712/// # );
6713/// # let mut hub = BigQueryReservation::new(client, auth);
6714/// // As the method needs a request, you would usually fill it with the desired information
6715/// // into the respective structure. Some of the parts shown here might not be applicable !
6716/// // Values shown here are possibly random and not representative !
6717/// let mut req = MoveAssignmentRequest::default();
6718///
6719/// // You can configure optional parameters by calling the respective setters at will, and
6720/// // execute the final call using `doit()`.
6721/// // Values shown here are possibly random and not representative !
6722/// let result = hub.projects().locations_reservations_assignments_move(req, "name")
6723/// .doit().await;
6724/// # }
6725/// ```
6726pub struct ProjectLocationReservationAssignmentMoveCall<'a, C>
6727where
6728 C: 'a,
6729{
6730 hub: &'a BigQueryReservation<C>,
6731 _request: MoveAssignmentRequest,
6732 _name: String,
6733 _delegate: Option<&'a mut dyn common::Delegate>,
6734 _additional_params: HashMap<String, String>,
6735 _scopes: BTreeSet<String>,
6736}
6737
6738impl<'a, C> common::CallBuilder for ProjectLocationReservationAssignmentMoveCall<'a, C> {}
6739
6740impl<'a, C> ProjectLocationReservationAssignmentMoveCall<'a, C>
6741where
6742 C: common::Connector,
6743{
6744 /// Perform the operation you have build so far.
6745 pub async fn doit(mut self) -> common::Result<(common::Response, Assignment)> {
6746 use std::borrow::Cow;
6747 use std::io::{Read, Seek};
6748
6749 use common::{url::Params, ToParts};
6750 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
6751
6752 let mut dd = common::DefaultDelegate;
6753 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
6754 dlg.begin(common::MethodInfo {
6755 id: "bigqueryreservation.projects.locations.reservations.assignments.move",
6756 http_method: hyper::Method::POST,
6757 });
6758
6759 for &field in ["alt", "name"].iter() {
6760 if self._additional_params.contains_key(field) {
6761 dlg.finished(false);
6762 return Err(common::Error::FieldClash(field));
6763 }
6764 }
6765
6766 let mut params = Params::with_capacity(4 + self._additional_params.len());
6767 params.push("name", self._name);
6768
6769 params.extend(self._additional_params.iter());
6770
6771 params.push("alt", "json");
6772 let mut url = self.hub._base_url.clone() + "v1/{+name}:move";
6773 if self._scopes.is_empty() {
6774 self._scopes
6775 .insert(Scope::CloudPlatform.as_ref().to_string());
6776 }
6777
6778 #[allow(clippy::single_element_loop)]
6779 for &(find_this, param_name) in [("{+name}", "name")].iter() {
6780 url = params.uri_replacement(url, param_name, find_this, true);
6781 }
6782 {
6783 let to_remove = ["name"];
6784 params.remove_params(&to_remove);
6785 }
6786
6787 let url = params.parse_with_url(&url);
6788
6789 let mut json_mime_type = mime::APPLICATION_JSON;
6790 let mut request_value_reader = {
6791 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
6792 common::remove_json_null_values(&mut value);
6793 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
6794 serde_json::to_writer(&mut dst, &value).unwrap();
6795 dst
6796 };
6797 let request_size = request_value_reader
6798 .seek(std::io::SeekFrom::End(0))
6799 .unwrap();
6800 request_value_reader
6801 .seek(std::io::SeekFrom::Start(0))
6802 .unwrap();
6803
6804 loop {
6805 let token = match self
6806 .hub
6807 .auth
6808 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
6809 .await
6810 {
6811 Ok(token) => token,
6812 Err(e) => match dlg.token(e) {
6813 Ok(token) => token,
6814 Err(e) => {
6815 dlg.finished(false);
6816 return Err(common::Error::MissingToken(e));
6817 }
6818 },
6819 };
6820 request_value_reader
6821 .seek(std::io::SeekFrom::Start(0))
6822 .unwrap();
6823 let mut req_result = {
6824 let client = &self.hub.client;
6825 dlg.pre_request();
6826 let mut req_builder = hyper::Request::builder()
6827 .method(hyper::Method::POST)
6828 .uri(url.as_str())
6829 .header(USER_AGENT, self.hub._user_agent.clone());
6830
6831 if let Some(token) = token.as_ref() {
6832 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
6833 }
6834
6835 let request = req_builder
6836 .header(CONTENT_TYPE, json_mime_type.to_string())
6837 .header(CONTENT_LENGTH, request_size as u64)
6838 .body(common::to_body(
6839 request_value_reader.get_ref().clone().into(),
6840 ));
6841
6842 client.request(request.unwrap()).await
6843 };
6844
6845 match req_result {
6846 Err(err) => {
6847 if let common::Retry::After(d) = dlg.http_error(&err) {
6848 sleep(d).await;
6849 continue;
6850 }
6851 dlg.finished(false);
6852 return Err(common::Error::HttpError(err));
6853 }
6854 Ok(res) => {
6855 let (mut parts, body) = res.into_parts();
6856 let mut body = common::Body::new(body);
6857 if !parts.status.is_success() {
6858 let bytes = common::to_bytes(body).await.unwrap_or_default();
6859 let error = serde_json::from_str(&common::to_string(&bytes));
6860 let response = common::to_response(parts, bytes.into());
6861
6862 if let common::Retry::After(d) =
6863 dlg.http_failure(&response, error.as_ref().ok())
6864 {
6865 sleep(d).await;
6866 continue;
6867 }
6868
6869 dlg.finished(false);
6870
6871 return Err(match error {
6872 Ok(value) => common::Error::BadRequest(value),
6873 _ => common::Error::Failure(response),
6874 });
6875 }
6876 let response = {
6877 let bytes = common::to_bytes(body).await.unwrap_or_default();
6878 let encoded = common::to_string(&bytes);
6879 match serde_json::from_str(&encoded) {
6880 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
6881 Err(error) => {
6882 dlg.response_json_decode_error(&encoded, &error);
6883 return Err(common::Error::JsonDecodeError(
6884 encoded.to_string(),
6885 error,
6886 ));
6887 }
6888 }
6889 };
6890
6891 dlg.finished(true);
6892 return Ok(response);
6893 }
6894 }
6895 }
6896 }
6897
6898 ///
6899 /// Sets the *request* property to the given value.
6900 ///
6901 /// Even though the property as already been set when instantiating this call,
6902 /// we provide this method for API completeness.
6903 pub fn request(
6904 mut self,
6905 new_value: MoveAssignmentRequest,
6906 ) -> ProjectLocationReservationAssignmentMoveCall<'a, C> {
6907 self._request = new_value;
6908 self
6909 }
6910 /// Required. The resource name of the assignment, e.g. `projects/myproject/locations/US/reservations/team1-prod/assignments/123`
6911 ///
6912 /// Sets the *name* path property to the given value.
6913 ///
6914 /// Even though the property as already been set when instantiating this call,
6915 /// we provide this method for API completeness.
6916 pub fn name(mut self, new_value: &str) -> ProjectLocationReservationAssignmentMoveCall<'a, C> {
6917 self._name = new_value.to_string();
6918 self
6919 }
6920 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
6921 /// while executing the actual API request.
6922 ///
6923 /// ````text
6924 /// It should be used to handle progress information, and to implement a certain level of resilience.
6925 /// ````
6926 ///
6927 /// Sets the *delegate* property to the given value.
6928 pub fn delegate(
6929 mut self,
6930 new_value: &'a mut dyn common::Delegate,
6931 ) -> ProjectLocationReservationAssignmentMoveCall<'a, C> {
6932 self._delegate = Some(new_value);
6933 self
6934 }
6935
6936 /// Set any additional parameter of the query string used in the request.
6937 /// It should be used to set parameters which are not yet available through their own
6938 /// setters.
6939 ///
6940 /// Please note that this method must not be used to set any of the known parameters
6941 /// which have their own setter method. If done anyway, the request will fail.
6942 ///
6943 /// # Additional Parameters
6944 ///
6945 /// * *$.xgafv* (query-string) - V1 error format.
6946 /// * *access_token* (query-string) - OAuth access token.
6947 /// * *alt* (query-string) - Data format for response.
6948 /// * *callback* (query-string) - JSONP
6949 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
6950 /// * *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.
6951 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
6952 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
6953 /// * *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.
6954 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
6955 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
6956 pub fn param<T>(
6957 mut self,
6958 name: T,
6959 value: T,
6960 ) -> ProjectLocationReservationAssignmentMoveCall<'a, C>
6961 where
6962 T: AsRef<str>,
6963 {
6964 self._additional_params
6965 .insert(name.as_ref().to_string(), value.as_ref().to_string());
6966 self
6967 }
6968
6969 /// Identifies the authorization scope for the method you are building.
6970 ///
6971 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
6972 /// [`Scope::CloudPlatform`].
6973 ///
6974 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
6975 /// tokens for more than one scope.
6976 ///
6977 /// Usually there is more than one suitable scope to authorize an operation, some of which may
6978 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
6979 /// sufficient, a read-write scope will do as well.
6980 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationReservationAssignmentMoveCall<'a, C>
6981 where
6982 St: AsRef<str>,
6983 {
6984 self._scopes.insert(String::from(scope.as_ref()));
6985 self
6986 }
6987 /// Identifies the authorization scope(s) for the method you are building.
6988 ///
6989 /// See [`Self::add_scope()`] for details.
6990 pub fn add_scopes<I, St>(
6991 mut self,
6992 scopes: I,
6993 ) -> ProjectLocationReservationAssignmentMoveCall<'a, C>
6994 where
6995 I: IntoIterator<Item = St>,
6996 St: AsRef<str>,
6997 {
6998 self._scopes
6999 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7000 self
7001 }
7002
7003 /// Removes all scopes, and no default scope will be used either.
7004 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7005 /// for details).
7006 pub fn clear_scopes(mut self) -> ProjectLocationReservationAssignmentMoveCall<'a, C> {
7007 self._scopes.clear();
7008 self
7009 }
7010}
7011
7012/// Updates an existing assignment. Only the `priority` field can be updated.
7013///
7014/// A builder for the *locations.reservations.assignments.patch* method supported by a *project* resource.
7015/// It is not used directly, but through a [`ProjectMethods`] instance.
7016///
7017/// # Example
7018///
7019/// Instantiate a resource method builder
7020///
7021/// ```test_harness,no_run
7022/// # extern crate hyper;
7023/// # extern crate hyper_rustls;
7024/// # extern crate google_bigqueryreservation1 as bigqueryreservation1;
7025/// use bigqueryreservation1::api::Assignment;
7026/// # async fn dox() {
7027/// # use bigqueryreservation1::{BigQueryReservation, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7028///
7029/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7030/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7031/// # .with_native_roots()
7032/// # .unwrap()
7033/// # .https_only()
7034/// # .enable_http2()
7035/// # .build();
7036///
7037/// # let executor = hyper_util::rt::TokioExecutor::new();
7038/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7039/// # secret,
7040/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7041/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7042/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7043/// # ),
7044/// # ).build().await.unwrap();
7045///
7046/// # let client = hyper_util::client::legacy::Client::builder(
7047/// # hyper_util::rt::TokioExecutor::new()
7048/// # )
7049/// # .build(
7050/// # hyper_rustls::HttpsConnectorBuilder::new()
7051/// # .with_native_roots()
7052/// # .unwrap()
7053/// # .https_or_http()
7054/// # .enable_http2()
7055/// # .build()
7056/// # );
7057/// # let mut hub = BigQueryReservation::new(client, auth);
7058/// // As the method needs a request, you would usually fill it with the desired information
7059/// // into the respective structure. Some of the parts shown here might not be applicable !
7060/// // Values shown here are possibly random and not representative !
7061/// let mut req = Assignment::default();
7062///
7063/// // You can configure optional parameters by calling the respective setters at will, and
7064/// // execute the final call using `doit()`.
7065/// // Values shown here are possibly random and not representative !
7066/// let result = hub.projects().locations_reservations_assignments_patch(req, "name")
7067/// .update_mask(FieldMask::new::<&str>(&[]))
7068/// .doit().await;
7069/// # }
7070/// ```
7071pub struct ProjectLocationReservationAssignmentPatchCall<'a, C>
7072where
7073 C: 'a,
7074{
7075 hub: &'a BigQueryReservation<C>,
7076 _request: Assignment,
7077 _name: String,
7078 _update_mask: Option<common::FieldMask>,
7079 _delegate: Option<&'a mut dyn common::Delegate>,
7080 _additional_params: HashMap<String, String>,
7081 _scopes: BTreeSet<String>,
7082}
7083
7084impl<'a, C> common::CallBuilder for ProjectLocationReservationAssignmentPatchCall<'a, C> {}
7085
7086impl<'a, C> ProjectLocationReservationAssignmentPatchCall<'a, C>
7087where
7088 C: common::Connector,
7089{
7090 /// Perform the operation you have build so far.
7091 pub async fn doit(mut self) -> common::Result<(common::Response, Assignment)> {
7092 use std::borrow::Cow;
7093 use std::io::{Read, Seek};
7094
7095 use common::{url::Params, ToParts};
7096 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7097
7098 let mut dd = common::DefaultDelegate;
7099 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7100 dlg.begin(common::MethodInfo {
7101 id: "bigqueryreservation.projects.locations.reservations.assignments.patch",
7102 http_method: hyper::Method::PATCH,
7103 });
7104
7105 for &field in ["alt", "name", "updateMask"].iter() {
7106 if self._additional_params.contains_key(field) {
7107 dlg.finished(false);
7108 return Err(common::Error::FieldClash(field));
7109 }
7110 }
7111
7112 let mut params = Params::with_capacity(5 + self._additional_params.len());
7113 params.push("name", self._name);
7114 if let Some(value) = self._update_mask.as_ref() {
7115 params.push("updateMask", value.to_string());
7116 }
7117
7118 params.extend(self._additional_params.iter());
7119
7120 params.push("alt", "json");
7121 let mut url = self.hub._base_url.clone() + "v1/{+name}";
7122 if self._scopes.is_empty() {
7123 self._scopes
7124 .insert(Scope::CloudPlatform.as_ref().to_string());
7125 }
7126
7127 #[allow(clippy::single_element_loop)]
7128 for &(find_this, param_name) in [("{+name}", "name")].iter() {
7129 url = params.uri_replacement(url, param_name, find_this, true);
7130 }
7131 {
7132 let to_remove = ["name"];
7133 params.remove_params(&to_remove);
7134 }
7135
7136 let url = params.parse_with_url(&url);
7137
7138 let mut json_mime_type = mime::APPLICATION_JSON;
7139 let mut request_value_reader = {
7140 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7141 common::remove_json_null_values(&mut value);
7142 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7143 serde_json::to_writer(&mut dst, &value).unwrap();
7144 dst
7145 };
7146 let request_size = request_value_reader
7147 .seek(std::io::SeekFrom::End(0))
7148 .unwrap();
7149 request_value_reader
7150 .seek(std::io::SeekFrom::Start(0))
7151 .unwrap();
7152
7153 loop {
7154 let token = match self
7155 .hub
7156 .auth
7157 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7158 .await
7159 {
7160 Ok(token) => token,
7161 Err(e) => match dlg.token(e) {
7162 Ok(token) => token,
7163 Err(e) => {
7164 dlg.finished(false);
7165 return Err(common::Error::MissingToken(e));
7166 }
7167 },
7168 };
7169 request_value_reader
7170 .seek(std::io::SeekFrom::Start(0))
7171 .unwrap();
7172 let mut req_result = {
7173 let client = &self.hub.client;
7174 dlg.pre_request();
7175 let mut req_builder = hyper::Request::builder()
7176 .method(hyper::Method::PATCH)
7177 .uri(url.as_str())
7178 .header(USER_AGENT, self.hub._user_agent.clone());
7179
7180 if let Some(token) = token.as_ref() {
7181 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7182 }
7183
7184 let request = req_builder
7185 .header(CONTENT_TYPE, json_mime_type.to_string())
7186 .header(CONTENT_LENGTH, request_size as u64)
7187 .body(common::to_body(
7188 request_value_reader.get_ref().clone().into(),
7189 ));
7190
7191 client.request(request.unwrap()).await
7192 };
7193
7194 match req_result {
7195 Err(err) => {
7196 if let common::Retry::After(d) = dlg.http_error(&err) {
7197 sleep(d).await;
7198 continue;
7199 }
7200 dlg.finished(false);
7201 return Err(common::Error::HttpError(err));
7202 }
7203 Ok(res) => {
7204 let (mut parts, body) = res.into_parts();
7205 let mut body = common::Body::new(body);
7206 if !parts.status.is_success() {
7207 let bytes = common::to_bytes(body).await.unwrap_or_default();
7208 let error = serde_json::from_str(&common::to_string(&bytes));
7209 let response = common::to_response(parts, bytes.into());
7210
7211 if let common::Retry::After(d) =
7212 dlg.http_failure(&response, error.as_ref().ok())
7213 {
7214 sleep(d).await;
7215 continue;
7216 }
7217
7218 dlg.finished(false);
7219
7220 return Err(match error {
7221 Ok(value) => common::Error::BadRequest(value),
7222 _ => common::Error::Failure(response),
7223 });
7224 }
7225 let response = {
7226 let bytes = common::to_bytes(body).await.unwrap_or_default();
7227 let encoded = common::to_string(&bytes);
7228 match serde_json::from_str(&encoded) {
7229 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7230 Err(error) => {
7231 dlg.response_json_decode_error(&encoded, &error);
7232 return Err(common::Error::JsonDecodeError(
7233 encoded.to_string(),
7234 error,
7235 ));
7236 }
7237 }
7238 };
7239
7240 dlg.finished(true);
7241 return Ok(response);
7242 }
7243 }
7244 }
7245 }
7246
7247 ///
7248 /// Sets the *request* property to the given value.
7249 ///
7250 /// Even though the property as already been set when instantiating this call,
7251 /// we provide this method for API completeness.
7252 pub fn request(
7253 mut self,
7254 new_value: Assignment,
7255 ) -> ProjectLocationReservationAssignmentPatchCall<'a, C> {
7256 self._request = new_value;
7257 self
7258 }
7259 /// Output only. Name of the resource. E.g.: `projects/myproject/locations/US/reservations/team1-prod/assignments/123`. The assignment_id must only contain lower case alphanumeric characters or dashes and the max length is 64 characters.
7260 ///
7261 /// Sets the *name* path property to the given value.
7262 ///
7263 /// Even though the property as already been set when instantiating this call,
7264 /// we provide this method for API completeness.
7265 pub fn name(mut self, new_value: &str) -> ProjectLocationReservationAssignmentPatchCall<'a, C> {
7266 self._name = new_value.to_string();
7267 self
7268 }
7269 /// Standard field mask for the set of fields to be updated.
7270 ///
7271 /// Sets the *update mask* query property to the given value.
7272 pub fn update_mask(
7273 mut self,
7274 new_value: common::FieldMask,
7275 ) -> ProjectLocationReservationAssignmentPatchCall<'a, C> {
7276 self._update_mask = Some(new_value);
7277 self
7278 }
7279 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7280 /// while executing the actual API request.
7281 ///
7282 /// ````text
7283 /// It should be used to handle progress information, and to implement a certain level of resilience.
7284 /// ````
7285 ///
7286 /// Sets the *delegate* property to the given value.
7287 pub fn delegate(
7288 mut self,
7289 new_value: &'a mut dyn common::Delegate,
7290 ) -> ProjectLocationReservationAssignmentPatchCall<'a, C> {
7291 self._delegate = Some(new_value);
7292 self
7293 }
7294
7295 /// Set any additional parameter of the query string used in the request.
7296 /// It should be used to set parameters which are not yet available through their own
7297 /// setters.
7298 ///
7299 /// Please note that this method must not be used to set any of the known parameters
7300 /// which have their own setter method. If done anyway, the request will fail.
7301 ///
7302 /// # Additional Parameters
7303 ///
7304 /// * *$.xgafv* (query-string) - V1 error format.
7305 /// * *access_token* (query-string) - OAuth access token.
7306 /// * *alt* (query-string) - Data format for response.
7307 /// * *callback* (query-string) - JSONP
7308 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7309 /// * *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.
7310 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7311 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7312 /// * *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.
7313 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7314 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7315 pub fn param<T>(
7316 mut self,
7317 name: T,
7318 value: T,
7319 ) -> ProjectLocationReservationAssignmentPatchCall<'a, C>
7320 where
7321 T: AsRef<str>,
7322 {
7323 self._additional_params
7324 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7325 self
7326 }
7327
7328 /// Identifies the authorization scope for the method you are building.
7329 ///
7330 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7331 /// [`Scope::CloudPlatform`].
7332 ///
7333 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7334 /// tokens for more than one scope.
7335 ///
7336 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7337 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7338 /// sufficient, a read-write scope will do as well.
7339 pub fn add_scope<St>(
7340 mut self,
7341 scope: St,
7342 ) -> ProjectLocationReservationAssignmentPatchCall<'a, C>
7343 where
7344 St: AsRef<str>,
7345 {
7346 self._scopes.insert(String::from(scope.as_ref()));
7347 self
7348 }
7349 /// Identifies the authorization scope(s) for the method you are building.
7350 ///
7351 /// See [`Self::add_scope()`] for details.
7352 pub fn add_scopes<I, St>(
7353 mut self,
7354 scopes: I,
7355 ) -> ProjectLocationReservationAssignmentPatchCall<'a, C>
7356 where
7357 I: IntoIterator<Item = St>,
7358 St: AsRef<str>,
7359 {
7360 self._scopes
7361 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7362 self
7363 }
7364
7365 /// Removes all scopes, and no default scope will be used either.
7366 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7367 /// for details).
7368 pub fn clear_scopes(mut self) -> ProjectLocationReservationAssignmentPatchCall<'a, C> {
7369 self._scopes.clear();
7370 self
7371 }
7372}
7373
7374/// Sets an access control policy for a resource. Replaces any existing policy. Supported resources are: - Reservations To call this method, you must have the following Google IAM permissions: - `bigqueryreservation.reservations.setIamPolicy` to set policies on reservations.
7375///
7376/// A builder for the *locations.reservations.assignments.setIamPolicy* method supported by a *project* resource.
7377/// It is not used directly, but through a [`ProjectMethods`] instance.
7378///
7379/// # Example
7380///
7381/// Instantiate a resource method builder
7382///
7383/// ```test_harness,no_run
7384/// # extern crate hyper;
7385/// # extern crate hyper_rustls;
7386/// # extern crate google_bigqueryreservation1 as bigqueryreservation1;
7387/// use bigqueryreservation1::api::SetIamPolicyRequest;
7388/// # async fn dox() {
7389/// # use bigqueryreservation1::{BigQueryReservation, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7390///
7391/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7392/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7393/// # .with_native_roots()
7394/// # .unwrap()
7395/// # .https_only()
7396/// # .enable_http2()
7397/// # .build();
7398///
7399/// # let executor = hyper_util::rt::TokioExecutor::new();
7400/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7401/// # secret,
7402/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7403/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7404/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7405/// # ),
7406/// # ).build().await.unwrap();
7407///
7408/// # let client = hyper_util::client::legacy::Client::builder(
7409/// # hyper_util::rt::TokioExecutor::new()
7410/// # )
7411/// # .build(
7412/// # hyper_rustls::HttpsConnectorBuilder::new()
7413/// # .with_native_roots()
7414/// # .unwrap()
7415/// # .https_or_http()
7416/// # .enable_http2()
7417/// # .build()
7418/// # );
7419/// # let mut hub = BigQueryReservation::new(client, auth);
7420/// // As the method needs a request, you would usually fill it with the desired information
7421/// // into the respective structure. Some of the parts shown here might not be applicable !
7422/// // Values shown here are possibly random and not representative !
7423/// let mut req = SetIamPolicyRequest::default();
7424///
7425/// // You can configure optional parameters by calling the respective setters at will, and
7426/// // execute the final call using `doit()`.
7427/// // Values shown here are possibly random and not representative !
7428/// let result = hub.projects().locations_reservations_assignments_set_iam_policy(req, "resource")
7429/// .doit().await;
7430/// # }
7431/// ```
7432pub struct ProjectLocationReservationAssignmentSetIamPolicyCall<'a, C>
7433where
7434 C: 'a,
7435{
7436 hub: &'a BigQueryReservation<C>,
7437 _request: SetIamPolicyRequest,
7438 _resource: String,
7439 _delegate: Option<&'a mut dyn common::Delegate>,
7440 _additional_params: HashMap<String, String>,
7441 _scopes: BTreeSet<String>,
7442}
7443
7444impl<'a, C> common::CallBuilder for ProjectLocationReservationAssignmentSetIamPolicyCall<'a, C> {}
7445
7446impl<'a, C> ProjectLocationReservationAssignmentSetIamPolicyCall<'a, C>
7447where
7448 C: common::Connector,
7449{
7450 /// Perform the operation you have build so far.
7451 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
7452 use std::borrow::Cow;
7453 use std::io::{Read, Seek};
7454
7455 use common::{url::Params, ToParts};
7456 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7457
7458 let mut dd = common::DefaultDelegate;
7459 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7460 dlg.begin(common::MethodInfo {
7461 id: "bigqueryreservation.projects.locations.reservations.assignments.setIamPolicy",
7462 http_method: hyper::Method::POST,
7463 });
7464
7465 for &field in ["alt", "resource"].iter() {
7466 if self._additional_params.contains_key(field) {
7467 dlg.finished(false);
7468 return Err(common::Error::FieldClash(field));
7469 }
7470 }
7471
7472 let mut params = Params::with_capacity(4 + self._additional_params.len());
7473 params.push("resource", self._resource);
7474
7475 params.extend(self._additional_params.iter());
7476
7477 params.push("alt", "json");
7478 let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
7479 if self._scopes.is_empty() {
7480 self._scopes
7481 .insert(Scope::CloudPlatform.as_ref().to_string());
7482 }
7483
7484 #[allow(clippy::single_element_loop)]
7485 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
7486 url = params.uri_replacement(url, param_name, find_this, true);
7487 }
7488 {
7489 let to_remove = ["resource"];
7490 params.remove_params(&to_remove);
7491 }
7492
7493 let url = params.parse_with_url(&url);
7494
7495 let mut json_mime_type = mime::APPLICATION_JSON;
7496 let mut request_value_reader = {
7497 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7498 common::remove_json_null_values(&mut value);
7499 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7500 serde_json::to_writer(&mut dst, &value).unwrap();
7501 dst
7502 };
7503 let request_size = request_value_reader
7504 .seek(std::io::SeekFrom::End(0))
7505 .unwrap();
7506 request_value_reader
7507 .seek(std::io::SeekFrom::Start(0))
7508 .unwrap();
7509
7510 loop {
7511 let token = match self
7512 .hub
7513 .auth
7514 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7515 .await
7516 {
7517 Ok(token) => token,
7518 Err(e) => match dlg.token(e) {
7519 Ok(token) => token,
7520 Err(e) => {
7521 dlg.finished(false);
7522 return Err(common::Error::MissingToken(e));
7523 }
7524 },
7525 };
7526 request_value_reader
7527 .seek(std::io::SeekFrom::Start(0))
7528 .unwrap();
7529 let mut req_result = {
7530 let client = &self.hub.client;
7531 dlg.pre_request();
7532 let mut req_builder = hyper::Request::builder()
7533 .method(hyper::Method::POST)
7534 .uri(url.as_str())
7535 .header(USER_AGENT, self.hub._user_agent.clone());
7536
7537 if let Some(token) = token.as_ref() {
7538 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7539 }
7540
7541 let request = req_builder
7542 .header(CONTENT_TYPE, json_mime_type.to_string())
7543 .header(CONTENT_LENGTH, request_size as u64)
7544 .body(common::to_body(
7545 request_value_reader.get_ref().clone().into(),
7546 ));
7547
7548 client.request(request.unwrap()).await
7549 };
7550
7551 match req_result {
7552 Err(err) => {
7553 if let common::Retry::After(d) = dlg.http_error(&err) {
7554 sleep(d).await;
7555 continue;
7556 }
7557 dlg.finished(false);
7558 return Err(common::Error::HttpError(err));
7559 }
7560 Ok(res) => {
7561 let (mut parts, body) = res.into_parts();
7562 let mut body = common::Body::new(body);
7563 if !parts.status.is_success() {
7564 let bytes = common::to_bytes(body).await.unwrap_or_default();
7565 let error = serde_json::from_str(&common::to_string(&bytes));
7566 let response = common::to_response(parts, bytes.into());
7567
7568 if let common::Retry::After(d) =
7569 dlg.http_failure(&response, error.as_ref().ok())
7570 {
7571 sleep(d).await;
7572 continue;
7573 }
7574
7575 dlg.finished(false);
7576
7577 return Err(match error {
7578 Ok(value) => common::Error::BadRequest(value),
7579 _ => common::Error::Failure(response),
7580 });
7581 }
7582 let response = {
7583 let bytes = common::to_bytes(body).await.unwrap_or_default();
7584 let encoded = common::to_string(&bytes);
7585 match serde_json::from_str(&encoded) {
7586 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7587 Err(error) => {
7588 dlg.response_json_decode_error(&encoded, &error);
7589 return Err(common::Error::JsonDecodeError(
7590 encoded.to_string(),
7591 error,
7592 ));
7593 }
7594 }
7595 };
7596
7597 dlg.finished(true);
7598 return Ok(response);
7599 }
7600 }
7601 }
7602 }
7603
7604 ///
7605 /// Sets the *request* property to the given value.
7606 ///
7607 /// Even though the property as already been set when instantiating this call,
7608 /// we provide this method for API completeness.
7609 pub fn request(
7610 mut self,
7611 new_value: SetIamPolicyRequest,
7612 ) -> ProjectLocationReservationAssignmentSetIamPolicyCall<'a, C> {
7613 self._request = new_value;
7614 self
7615 }
7616 /// 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.
7617 ///
7618 /// Sets the *resource* path property to the given value.
7619 ///
7620 /// Even though the property as already been set when instantiating this call,
7621 /// we provide this method for API completeness.
7622 pub fn resource(
7623 mut self,
7624 new_value: &str,
7625 ) -> ProjectLocationReservationAssignmentSetIamPolicyCall<'a, C> {
7626 self._resource = new_value.to_string();
7627 self
7628 }
7629 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7630 /// while executing the actual API request.
7631 ///
7632 /// ````text
7633 /// It should be used to handle progress information, and to implement a certain level of resilience.
7634 /// ````
7635 ///
7636 /// Sets the *delegate* property to the given value.
7637 pub fn delegate(
7638 mut self,
7639 new_value: &'a mut dyn common::Delegate,
7640 ) -> ProjectLocationReservationAssignmentSetIamPolicyCall<'a, C> {
7641 self._delegate = Some(new_value);
7642 self
7643 }
7644
7645 /// Set any additional parameter of the query string used in the request.
7646 /// It should be used to set parameters which are not yet available through their own
7647 /// setters.
7648 ///
7649 /// Please note that this method must not be used to set any of the known parameters
7650 /// which have their own setter method. If done anyway, the request will fail.
7651 ///
7652 /// # Additional Parameters
7653 ///
7654 /// * *$.xgafv* (query-string) - V1 error format.
7655 /// * *access_token* (query-string) - OAuth access token.
7656 /// * *alt* (query-string) - Data format for response.
7657 /// * *callback* (query-string) - JSONP
7658 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
7659 /// * *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.
7660 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
7661 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
7662 /// * *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.
7663 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
7664 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
7665 pub fn param<T>(
7666 mut self,
7667 name: T,
7668 value: T,
7669 ) -> ProjectLocationReservationAssignmentSetIamPolicyCall<'a, C>
7670 where
7671 T: AsRef<str>,
7672 {
7673 self._additional_params
7674 .insert(name.as_ref().to_string(), value.as_ref().to_string());
7675 self
7676 }
7677
7678 /// Identifies the authorization scope for the method you are building.
7679 ///
7680 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
7681 /// [`Scope::CloudPlatform`].
7682 ///
7683 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
7684 /// tokens for more than one scope.
7685 ///
7686 /// Usually there is more than one suitable scope to authorize an operation, some of which may
7687 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
7688 /// sufficient, a read-write scope will do as well.
7689 pub fn add_scope<St>(
7690 mut self,
7691 scope: St,
7692 ) -> ProjectLocationReservationAssignmentSetIamPolicyCall<'a, C>
7693 where
7694 St: AsRef<str>,
7695 {
7696 self._scopes.insert(String::from(scope.as_ref()));
7697 self
7698 }
7699 /// Identifies the authorization scope(s) for the method you are building.
7700 ///
7701 /// See [`Self::add_scope()`] for details.
7702 pub fn add_scopes<I, St>(
7703 mut self,
7704 scopes: I,
7705 ) -> ProjectLocationReservationAssignmentSetIamPolicyCall<'a, C>
7706 where
7707 I: IntoIterator<Item = St>,
7708 St: AsRef<str>,
7709 {
7710 self._scopes
7711 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
7712 self
7713 }
7714
7715 /// Removes all scopes, and no default scope will be used either.
7716 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
7717 /// for details).
7718 pub fn clear_scopes(mut self) -> ProjectLocationReservationAssignmentSetIamPolicyCall<'a, C> {
7719 self._scopes.clear();
7720 self
7721 }
7722}
7723
7724/// Gets your permissions on a resource. Returns an empty set of permissions if the resource doesn't exist. Supported resources are: - Reservations No Google IAM permissions are required to call this method.
7725///
7726/// A builder for the *locations.reservations.assignments.testIamPermissions* method supported by a *project* resource.
7727/// It is not used directly, but through a [`ProjectMethods`] instance.
7728///
7729/// # Example
7730///
7731/// Instantiate a resource method builder
7732///
7733/// ```test_harness,no_run
7734/// # extern crate hyper;
7735/// # extern crate hyper_rustls;
7736/// # extern crate google_bigqueryreservation1 as bigqueryreservation1;
7737/// use bigqueryreservation1::api::TestIamPermissionsRequest;
7738/// # async fn dox() {
7739/// # use bigqueryreservation1::{BigQueryReservation, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
7740///
7741/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
7742/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
7743/// # .with_native_roots()
7744/// # .unwrap()
7745/// # .https_only()
7746/// # .enable_http2()
7747/// # .build();
7748///
7749/// # let executor = hyper_util::rt::TokioExecutor::new();
7750/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
7751/// # secret,
7752/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
7753/// # yup_oauth2::client::CustomHyperClientBuilder::from(
7754/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
7755/// # ),
7756/// # ).build().await.unwrap();
7757///
7758/// # let client = hyper_util::client::legacy::Client::builder(
7759/// # hyper_util::rt::TokioExecutor::new()
7760/// # )
7761/// # .build(
7762/// # hyper_rustls::HttpsConnectorBuilder::new()
7763/// # .with_native_roots()
7764/// # .unwrap()
7765/// # .https_or_http()
7766/// # .enable_http2()
7767/// # .build()
7768/// # );
7769/// # let mut hub = BigQueryReservation::new(client, auth);
7770/// // As the method needs a request, you would usually fill it with the desired information
7771/// // into the respective structure. Some of the parts shown here might not be applicable !
7772/// // Values shown here are possibly random and not representative !
7773/// let mut req = TestIamPermissionsRequest::default();
7774///
7775/// // You can configure optional parameters by calling the respective setters at will, and
7776/// // execute the final call using `doit()`.
7777/// // Values shown here are possibly random and not representative !
7778/// let result = hub.projects().locations_reservations_assignments_test_iam_permissions(req, "resource")
7779/// .doit().await;
7780/// # }
7781/// ```
7782pub struct ProjectLocationReservationAssignmentTestIamPermissionCall<'a, C>
7783where
7784 C: 'a,
7785{
7786 hub: &'a BigQueryReservation<C>,
7787 _request: TestIamPermissionsRequest,
7788 _resource: String,
7789 _delegate: Option<&'a mut dyn common::Delegate>,
7790 _additional_params: HashMap<String, String>,
7791 _scopes: BTreeSet<String>,
7792}
7793
7794impl<'a, C> common::CallBuilder
7795 for ProjectLocationReservationAssignmentTestIamPermissionCall<'a, C>
7796{
7797}
7798
7799impl<'a, C> ProjectLocationReservationAssignmentTestIamPermissionCall<'a, C>
7800where
7801 C: common::Connector,
7802{
7803 /// Perform the operation you have build so far.
7804 pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
7805 use std::borrow::Cow;
7806 use std::io::{Read, Seek};
7807
7808 use common::{url::Params, ToParts};
7809 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
7810
7811 let mut dd = common::DefaultDelegate;
7812 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
7813 dlg.begin(common::MethodInfo { id: "bigqueryreservation.projects.locations.reservations.assignments.testIamPermissions",
7814 http_method: hyper::Method::POST });
7815
7816 for &field in ["alt", "resource"].iter() {
7817 if self._additional_params.contains_key(field) {
7818 dlg.finished(false);
7819 return Err(common::Error::FieldClash(field));
7820 }
7821 }
7822
7823 let mut params = Params::with_capacity(4 + self._additional_params.len());
7824 params.push("resource", self._resource);
7825
7826 params.extend(self._additional_params.iter());
7827
7828 params.push("alt", "json");
7829 let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
7830 if self._scopes.is_empty() {
7831 self._scopes
7832 .insert(Scope::CloudPlatform.as_ref().to_string());
7833 }
7834
7835 #[allow(clippy::single_element_loop)]
7836 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
7837 url = params.uri_replacement(url, param_name, find_this, true);
7838 }
7839 {
7840 let to_remove = ["resource"];
7841 params.remove_params(&to_remove);
7842 }
7843
7844 let url = params.parse_with_url(&url);
7845
7846 let mut json_mime_type = mime::APPLICATION_JSON;
7847 let mut request_value_reader = {
7848 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
7849 common::remove_json_null_values(&mut value);
7850 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
7851 serde_json::to_writer(&mut dst, &value).unwrap();
7852 dst
7853 };
7854 let request_size = request_value_reader
7855 .seek(std::io::SeekFrom::End(0))
7856 .unwrap();
7857 request_value_reader
7858 .seek(std::io::SeekFrom::Start(0))
7859 .unwrap();
7860
7861 loop {
7862 let token = match self
7863 .hub
7864 .auth
7865 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
7866 .await
7867 {
7868 Ok(token) => token,
7869 Err(e) => match dlg.token(e) {
7870 Ok(token) => token,
7871 Err(e) => {
7872 dlg.finished(false);
7873 return Err(common::Error::MissingToken(e));
7874 }
7875 },
7876 };
7877 request_value_reader
7878 .seek(std::io::SeekFrom::Start(0))
7879 .unwrap();
7880 let mut req_result = {
7881 let client = &self.hub.client;
7882 dlg.pre_request();
7883 let mut req_builder = hyper::Request::builder()
7884 .method(hyper::Method::POST)
7885 .uri(url.as_str())
7886 .header(USER_AGENT, self.hub._user_agent.clone());
7887
7888 if let Some(token) = token.as_ref() {
7889 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
7890 }
7891
7892 let request = req_builder
7893 .header(CONTENT_TYPE, json_mime_type.to_string())
7894 .header(CONTENT_LENGTH, request_size as u64)
7895 .body(common::to_body(
7896 request_value_reader.get_ref().clone().into(),
7897 ));
7898
7899 client.request(request.unwrap()).await
7900 };
7901
7902 match req_result {
7903 Err(err) => {
7904 if let common::Retry::After(d) = dlg.http_error(&err) {
7905 sleep(d).await;
7906 continue;
7907 }
7908 dlg.finished(false);
7909 return Err(common::Error::HttpError(err));
7910 }
7911 Ok(res) => {
7912 let (mut parts, body) = res.into_parts();
7913 let mut body = common::Body::new(body);
7914 if !parts.status.is_success() {
7915 let bytes = common::to_bytes(body).await.unwrap_or_default();
7916 let error = serde_json::from_str(&common::to_string(&bytes));
7917 let response = common::to_response(parts, bytes.into());
7918
7919 if let common::Retry::After(d) =
7920 dlg.http_failure(&response, error.as_ref().ok())
7921 {
7922 sleep(d).await;
7923 continue;
7924 }
7925
7926 dlg.finished(false);
7927
7928 return Err(match error {
7929 Ok(value) => common::Error::BadRequest(value),
7930 _ => common::Error::Failure(response),
7931 });
7932 }
7933 let response = {
7934 let bytes = common::to_bytes(body).await.unwrap_or_default();
7935 let encoded = common::to_string(&bytes);
7936 match serde_json::from_str(&encoded) {
7937 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
7938 Err(error) => {
7939 dlg.response_json_decode_error(&encoded, &error);
7940 return Err(common::Error::JsonDecodeError(
7941 encoded.to_string(),
7942 error,
7943 ));
7944 }
7945 }
7946 };
7947
7948 dlg.finished(true);
7949 return Ok(response);
7950 }
7951 }
7952 }
7953 }
7954
7955 ///
7956 /// Sets the *request* property to the given value.
7957 ///
7958 /// Even though the property as already been set when instantiating this call,
7959 /// we provide this method for API completeness.
7960 pub fn request(
7961 mut self,
7962 new_value: TestIamPermissionsRequest,
7963 ) -> ProjectLocationReservationAssignmentTestIamPermissionCall<'a, C> {
7964 self._request = new_value;
7965 self
7966 }
7967 /// 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.
7968 ///
7969 /// Sets the *resource* path property to the given value.
7970 ///
7971 /// Even though the property as already been set when instantiating this call,
7972 /// we provide this method for API completeness.
7973 pub fn resource(
7974 mut self,
7975 new_value: &str,
7976 ) -> ProjectLocationReservationAssignmentTestIamPermissionCall<'a, C> {
7977 self._resource = new_value.to_string();
7978 self
7979 }
7980 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
7981 /// while executing the actual API request.
7982 ///
7983 /// ````text
7984 /// It should be used to handle progress information, and to implement a certain level of resilience.
7985 /// ````
7986 ///
7987 /// Sets the *delegate* property to the given value.
7988 pub fn delegate(
7989 mut self,
7990 new_value: &'a mut dyn common::Delegate,
7991 ) -> ProjectLocationReservationAssignmentTestIamPermissionCall<'a, C> {
7992 self._delegate = Some(new_value);
7993 self
7994 }
7995
7996 /// Set any additional parameter of the query string used in the request.
7997 /// It should be used to set parameters which are not yet available through their own
7998 /// setters.
7999 ///
8000 /// Please note that this method must not be used to set any of the known parameters
8001 /// which have their own setter method. If done anyway, the request will fail.
8002 ///
8003 /// # Additional Parameters
8004 ///
8005 /// * *$.xgafv* (query-string) - V1 error format.
8006 /// * *access_token* (query-string) - OAuth access token.
8007 /// * *alt* (query-string) - Data format for response.
8008 /// * *callback* (query-string) - JSONP
8009 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8010 /// * *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.
8011 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8012 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8013 /// * *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.
8014 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8015 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8016 pub fn param<T>(
8017 mut self,
8018 name: T,
8019 value: T,
8020 ) -> ProjectLocationReservationAssignmentTestIamPermissionCall<'a, C>
8021 where
8022 T: AsRef<str>,
8023 {
8024 self._additional_params
8025 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8026 self
8027 }
8028
8029 /// Identifies the authorization scope for the method you are building.
8030 ///
8031 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8032 /// [`Scope::CloudPlatform`].
8033 ///
8034 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8035 /// tokens for more than one scope.
8036 ///
8037 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8038 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8039 /// sufficient, a read-write scope will do as well.
8040 pub fn add_scope<St>(
8041 mut self,
8042 scope: St,
8043 ) -> ProjectLocationReservationAssignmentTestIamPermissionCall<'a, C>
8044 where
8045 St: AsRef<str>,
8046 {
8047 self._scopes.insert(String::from(scope.as_ref()));
8048 self
8049 }
8050 /// Identifies the authorization scope(s) for the method you are building.
8051 ///
8052 /// See [`Self::add_scope()`] for details.
8053 pub fn add_scopes<I, St>(
8054 mut self,
8055 scopes: I,
8056 ) -> ProjectLocationReservationAssignmentTestIamPermissionCall<'a, C>
8057 where
8058 I: IntoIterator<Item = St>,
8059 St: AsRef<str>,
8060 {
8061 self._scopes
8062 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8063 self
8064 }
8065
8066 /// Removes all scopes, and no default scope will be used either.
8067 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8068 /// for details).
8069 pub fn clear_scopes(
8070 mut self,
8071 ) -> ProjectLocationReservationAssignmentTestIamPermissionCall<'a, C> {
8072 self._scopes.clear();
8073 self
8074 }
8075}
8076
8077/// Creates a new reservation resource.
8078///
8079/// A builder for the *locations.reservations.create* method supported by a *project* resource.
8080/// It is not used directly, but through a [`ProjectMethods`] instance.
8081///
8082/// # Example
8083///
8084/// Instantiate a resource method builder
8085///
8086/// ```test_harness,no_run
8087/// # extern crate hyper;
8088/// # extern crate hyper_rustls;
8089/// # extern crate google_bigqueryreservation1 as bigqueryreservation1;
8090/// use bigqueryreservation1::api::Reservation;
8091/// # async fn dox() {
8092/// # use bigqueryreservation1::{BigQueryReservation, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8093///
8094/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8095/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8096/// # .with_native_roots()
8097/// # .unwrap()
8098/// # .https_only()
8099/// # .enable_http2()
8100/// # .build();
8101///
8102/// # let executor = hyper_util::rt::TokioExecutor::new();
8103/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8104/// # secret,
8105/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8106/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8107/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8108/// # ),
8109/// # ).build().await.unwrap();
8110///
8111/// # let client = hyper_util::client::legacy::Client::builder(
8112/// # hyper_util::rt::TokioExecutor::new()
8113/// # )
8114/// # .build(
8115/// # hyper_rustls::HttpsConnectorBuilder::new()
8116/// # .with_native_roots()
8117/// # .unwrap()
8118/// # .https_or_http()
8119/// # .enable_http2()
8120/// # .build()
8121/// # );
8122/// # let mut hub = BigQueryReservation::new(client, auth);
8123/// // As the method needs a request, you would usually fill it with the desired information
8124/// // into the respective structure. Some of the parts shown here might not be applicable !
8125/// // Values shown here are possibly random and not representative !
8126/// let mut req = Reservation::default();
8127///
8128/// // You can configure optional parameters by calling the respective setters at will, and
8129/// // execute the final call using `doit()`.
8130/// // Values shown here are possibly random and not representative !
8131/// let result = hub.projects().locations_reservations_create(req, "parent")
8132/// .reservation_id("sed")
8133/// .doit().await;
8134/// # }
8135/// ```
8136pub struct ProjectLocationReservationCreateCall<'a, C>
8137where
8138 C: 'a,
8139{
8140 hub: &'a BigQueryReservation<C>,
8141 _request: Reservation,
8142 _parent: String,
8143 _reservation_id: Option<String>,
8144 _delegate: Option<&'a mut dyn common::Delegate>,
8145 _additional_params: HashMap<String, String>,
8146 _scopes: BTreeSet<String>,
8147}
8148
8149impl<'a, C> common::CallBuilder for ProjectLocationReservationCreateCall<'a, C> {}
8150
8151impl<'a, C> ProjectLocationReservationCreateCall<'a, C>
8152where
8153 C: common::Connector,
8154{
8155 /// Perform the operation you have build so far.
8156 pub async fn doit(mut self) -> common::Result<(common::Response, Reservation)> {
8157 use std::borrow::Cow;
8158 use std::io::{Read, Seek};
8159
8160 use common::{url::Params, ToParts};
8161 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8162
8163 let mut dd = common::DefaultDelegate;
8164 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8165 dlg.begin(common::MethodInfo {
8166 id: "bigqueryreservation.projects.locations.reservations.create",
8167 http_method: hyper::Method::POST,
8168 });
8169
8170 for &field in ["alt", "parent", "reservationId"].iter() {
8171 if self._additional_params.contains_key(field) {
8172 dlg.finished(false);
8173 return Err(common::Error::FieldClash(field));
8174 }
8175 }
8176
8177 let mut params = Params::with_capacity(5 + self._additional_params.len());
8178 params.push("parent", self._parent);
8179 if let Some(value) = self._reservation_id.as_ref() {
8180 params.push("reservationId", value);
8181 }
8182
8183 params.extend(self._additional_params.iter());
8184
8185 params.push("alt", "json");
8186 let mut url = self.hub._base_url.clone() + "v1/{+parent}/reservations";
8187 if self._scopes.is_empty() {
8188 self._scopes
8189 .insert(Scope::CloudPlatform.as_ref().to_string());
8190 }
8191
8192 #[allow(clippy::single_element_loop)]
8193 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
8194 url = params.uri_replacement(url, param_name, find_this, true);
8195 }
8196 {
8197 let to_remove = ["parent"];
8198 params.remove_params(&to_remove);
8199 }
8200
8201 let url = params.parse_with_url(&url);
8202
8203 let mut json_mime_type = mime::APPLICATION_JSON;
8204 let mut request_value_reader = {
8205 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8206 common::remove_json_null_values(&mut value);
8207 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8208 serde_json::to_writer(&mut dst, &value).unwrap();
8209 dst
8210 };
8211 let request_size = request_value_reader
8212 .seek(std::io::SeekFrom::End(0))
8213 .unwrap();
8214 request_value_reader
8215 .seek(std::io::SeekFrom::Start(0))
8216 .unwrap();
8217
8218 loop {
8219 let token = match self
8220 .hub
8221 .auth
8222 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8223 .await
8224 {
8225 Ok(token) => token,
8226 Err(e) => match dlg.token(e) {
8227 Ok(token) => token,
8228 Err(e) => {
8229 dlg.finished(false);
8230 return Err(common::Error::MissingToken(e));
8231 }
8232 },
8233 };
8234 request_value_reader
8235 .seek(std::io::SeekFrom::Start(0))
8236 .unwrap();
8237 let mut req_result = {
8238 let client = &self.hub.client;
8239 dlg.pre_request();
8240 let mut req_builder = hyper::Request::builder()
8241 .method(hyper::Method::POST)
8242 .uri(url.as_str())
8243 .header(USER_AGENT, self.hub._user_agent.clone());
8244
8245 if let Some(token) = token.as_ref() {
8246 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8247 }
8248
8249 let request = req_builder
8250 .header(CONTENT_TYPE, json_mime_type.to_string())
8251 .header(CONTENT_LENGTH, request_size as u64)
8252 .body(common::to_body(
8253 request_value_reader.get_ref().clone().into(),
8254 ));
8255
8256 client.request(request.unwrap()).await
8257 };
8258
8259 match req_result {
8260 Err(err) => {
8261 if let common::Retry::After(d) = dlg.http_error(&err) {
8262 sleep(d).await;
8263 continue;
8264 }
8265 dlg.finished(false);
8266 return Err(common::Error::HttpError(err));
8267 }
8268 Ok(res) => {
8269 let (mut parts, body) = res.into_parts();
8270 let mut body = common::Body::new(body);
8271 if !parts.status.is_success() {
8272 let bytes = common::to_bytes(body).await.unwrap_or_default();
8273 let error = serde_json::from_str(&common::to_string(&bytes));
8274 let response = common::to_response(parts, bytes.into());
8275
8276 if let common::Retry::After(d) =
8277 dlg.http_failure(&response, error.as_ref().ok())
8278 {
8279 sleep(d).await;
8280 continue;
8281 }
8282
8283 dlg.finished(false);
8284
8285 return Err(match error {
8286 Ok(value) => common::Error::BadRequest(value),
8287 _ => common::Error::Failure(response),
8288 });
8289 }
8290 let response = {
8291 let bytes = common::to_bytes(body).await.unwrap_or_default();
8292 let encoded = common::to_string(&bytes);
8293 match serde_json::from_str(&encoded) {
8294 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8295 Err(error) => {
8296 dlg.response_json_decode_error(&encoded, &error);
8297 return Err(common::Error::JsonDecodeError(
8298 encoded.to_string(),
8299 error,
8300 ));
8301 }
8302 }
8303 };
8304
8305 dlg.finished(true);
8306 return Ok(response);
8307 }
8308 }
8309 }
8310 }
8311
8312 ///
8313 /// Sets the *request* property to the given value.
8314 ///
8315 /// Even though the property as already been set when instantiating this call,
8316 /// we provide this method for API completeness.
8317 pub fn request(
8318 mut self,
8319 new_value: Reservation,
8320 ) -> ProjectLocationReservationCreateCall<'a, C> {
8321 self._request = new_value;
8322 self
8323 }
8324 /// Required. Project, location. E.g., `projects/myproject/locations/US`
8325 ///
8326 /// Sets the *parent* path property to the given value.
8327 ///
8328 /// Even though the property as already been set when instantiating this call,
8329 /// we provide this method for API completeness.
8330 pub fn parent(mut self, new_value: &str) -> ProjectLocationReservationCreateCall<'a, C> {
8331 self._parent = new_value.to_string();
8332 self
8333 }
8334 /// The reservation ID. It must only contain lower case alphanumeric characters or dashes. It must start with a letter and must not end with a dash. Its maximum length is 64 characters.
8335 ///
8336 /// Sets the *reservation id* query property to the given value.
8337 pub fn reservation_id(
8338 mut self,
8339 new_value: &str,
8340 ) -> ProjectLocationReservationCreateCall<'a, C> {
8341 self._reservation_id = Some(new_value.to_string());
8342 self
8343 }
8344 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8345 /// while executing the actual API request.
8346 ///
8347 /// ````text
8348 /// It should be used to handle progress information, and to implement a certain level of resilience.
8349 /// ````
8350 ///
8351 /// Sets the *delegate* property to the given value.
8352 pub fn delegate(
8353 mut self,
8354 new_value: &'a mut dyn common::Delegate,
8355 ) -> ProjectLocationReservationCreateCall<'a, C> {
8356 self._delegate = Some(new_value);
8357 self
8358 }
8359
8360 /// Set any additional parameter of the query string used in the request.
8361 /// It should be used to set parameters which are not yet available through their own
8362 /// setters.
8363 ///
8364 /// Please note that this method must not be used to set any of the known parameters
8365 /// which have their own setter method. If done anyway, the request will fail.
8366 ///
8367 /// # Additional Parameters
8368 ///
8369 /// * *$.xgafv* (query-string) - V1 error format.
8370 /// * *access_token* (query-string) - OAuth access token.
8371 /// * *alt* (query-string) - Data format for response.
8372 /// * *callback* (query-string) - JSONP
8373 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8374 /// * *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.
8375 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8376 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8377 /// * *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.
8378 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8379 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8380 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationReservationCreateCall<'a, C>
8381 where
8382 T: AsRef<str>,
8383 {
8384 self._additional_params
8385 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8386 self
8387 }
8388
8389 /// Identifies the authorization scope for the method you are building.
8390 ///
8391 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8392 /// [`Scope::CloudPlatform`].
8393 ///
8394 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8395 /// tokens for more than one scope.
8396 ///
8397 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8398 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8399 /// sufficient, a read-write scope will do as well.
8400 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationReservationCreateCall<'a, C>
8401 where
8402 St: AsRef<str>,
8403 {
8404 self._scopes.insert(String::from(scope.as_ref()));
8405 self
8406 }
8407 /// Identifies the authorization scope(s) for the method you are building.
8408 ///
8409 /// See [`Self::add_scope()`] for details.
8410 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationReservationCreateCall<'a, C>
8411 where
8412 I: IntoIterator<Item = St>,
8413 St: AsRef<str>,
8414 {
8415 self._scopes
8416 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8417 self
8418 }
8419
8420 /// Removes all scopes, and no default scope will be used either.
8421 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8422 /// for details).
8423 pub fn clear_scopes(mut self) -> ProjectLocationReservationCreateCall<'a, C> {
8424 self._scopes.clear();
8425 self
8426 }
8427}
8428
8429/// Deletes a reservation. Returns `google.rpc.Code.FAILED_PRECONDITION` when reservation has assignments.
8430///
8431/// A builder for the *locations.reservations.delete* method supported by a *project* resource.
8432/// It is not used directly, but through a [`ProjectMethods`] instance.
8433///
8434/// # Example
8435///
8436/// Instantiate a resource method builder
8437///
8438/// ```test_harness,no_run
8439/// # extern crate hyper;
8440/// # extern crate hyper_rustls;
8441/// # extern crate google_bigqueryreservation1 as bigqueryreservation1;
8442/// # async fn dox() {
8443/// # use bigqueryreservation1::{BigQueryReservation, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8444///
8445/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8446/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8447/// # .with_native_roots()
8448/// # .unwrap()
8449/// # .https_only()
8450/// # .enable_http2()
8451/// # .build();
8452///
8453/// # let executor = hyper_util::rt::TokioExecutor::new();
8454/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8455/// # secret,
8456/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8457/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8458/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8459/// # ),
8460/// # ).build().await.unwrap();
8461///
8462/// # let client = hyper_util::client::legacy::Client::builder(
8463/// # hyper_util::rt::TokioExecutor::new()
8464/// # )
8465/// # .build(
8466/// # hyper_rustls::HttpsConnectorBuilder::new()
8467/// # .with_native_roots()
8468/// # .unwrap()
8469/// # .https_or_http()
8470/// # .enable_http2()
8471/// # .build()
8472/// # );
8473/// # let mut hub = BigQueryReservation::new(client, auth);
8474/// // You can configure optional parameters by calling the respective setters at will, and
8475/// // execute the final call using `doit()`.
8476/// // Values shown here are possibly random and not representative !
8477/// let result = hub.projects().locations_reservations_delete("name")
8478/// .doit().await;
8479/// # }
8480/// ```
8481pub struct ProjectLocationReservationDeleteCall<'a, C>
8482where
8483 C: 'a,
8484{
8485 hub: &'a BigQueryReservation<C>,
8486 _name: String,
8487 _delegate: Option<&'a mut dyn common::Delegate>,
8488 _additional_params: HashMap<String, String>,
8489 _scopes: BTreeSet<String>,
8490}
8491
8492impl<'a, C> common::CallBuilder for ProjectLocationReservationDeleteCall<'a, C> {}
8493
8494impl<'a, C> ProjectLocationReservationDeleteCall<'a, C>
8495where
8496 C: common::Connector,
8497{
8498 /// Perform the operation you have build so far.
8499 pub async fn doit(mut self) -> common::Result<(common::Response, Empty)> {
8500 use std::borrow::Cow;
8501 use std::io::{Read, Seek};
8502
8503 use common::{url::Params, ToParts};
8504 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8505
8506 let mut dd = common::DefaultDelegate;
8507 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8508 dlg.begin(common::MethodInfo {
8509 id: "bigqueryreservation.projects.locations.reservations.delete",
8510 http_method: hyper::Method::DELETE,
8511 });
8512
8513 for &field in ["alt", "name"].iter() {
8514 if self._additional_params.contains_key(field) {
8515 dlg.finished(false);
8516 return Err(common::Error::FieldClash(field));
8517 }
8518 }
8519
8520 let mut params = Params::with_capacity(3 + self._additional_params.len());
8521 params.push("name", self._name);
8522
8523 params.extend(self._additional_params.iter());
8524
8525 params.push("alt", "json");
8526 let mut url = self.hub._base_url.clone() + "v1/{+name}";
8527 if self._scopes.is_empty() {
8528 self._scopes
8529 .insert(Scope::CloudPlatform.as_ref().to_string());
8530 }
8531
8532 #[allow(clippy::single_element_loop)]
8533 for &(find_this, param_name) in [("{+name}", "name")].iter() {
8534 url = params.uri_replacement(url, param_name, find_this, true);
8535 }
8536 {
8537 let to_remove = ["name"];
8538 params.remove_params(&to_remove);
8539 }
8540
8541 let url = params.parse_with_url(&url);
8542
8543 loop {
8544 let token = match self
8545 .hub
8546 .auth
8547 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8548 .await
8549 {
8550 Ok(token) => token,
8551 Err(e) => match dlg.token(e) {
8552 Ok(token) => token,
8553 Err(e) => {
8554 dlg.finished(false);
8555 return Err(common::Error::MissingToken(e));
8556 }
8557 },
8558 };
8559 let mut req_result = {
8560 let client = &self.hub.client;
8561 dlg.pre_request();
8562 let mut req_builder = hyper::Request::builder()
8563 .method(hyper::Method::DELETE)
8564 .uri(url.as_str())
8565 .header(USER_AGENT, self.hub._user_agent.clone());
8566
8567 if let Some(token) = token.as_ref() {
8568 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8569 }
8570
8571 let request = req_builder
8572 .header(CONTENT_LENGTH, 0_u64)
8573 .body(common::to_body::<String>(None));
8574
8575 client.request(request.unwrap()).await
8576 };
8577
8578 match req_result {
8579 Err(err) => {
8580 if let common::Retry::After(d) = dlg.http_error(&err) {
8581 sleep(d).await;
8582 continue;
8583 }
8584 dlg.finished(false);
8585 return Err(common::Error::HttpError(err));
8586 }
8587 Ok(res) => {
8588 let (mut parts, body) = res.into_parts();
8589 let mut body = common::Body::new(body);
8590 if !parts.status.is_success() {
8591 let bytes = common::to_bytes(body).await.unwrap_or_default();
8592 let error = serde_json::from_str(&common::to_string(&bytes));
8593 let response = common::to_response(parts, bytes.into());
8594
8595 if let common::Retry::After(d) =
8596 dlg.http_failure(&response, error.as_ref().ok())
8597 {
8598 sleep(d).await;
8599 continue;
8600 }
8601
8602 dlg.finished(false);
8603
8604 return Err(match error {
8605 Ok(value) => common::Error::BadRequest(value),
8606 _ => common::Error::Failure(response),
8607 });
8608 }
8609 let response = {
8610 let bytes = common::to_bytes(body).await.unwrap_or_default();
8611 let encoded = common::to_string(&bytes);
8612 match serde_json::from_str(&encoded) {
8613 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8614 Err(error) => {
8615 dlg.response_json_decode_error(&encoded, &error);
8616 return Err(common::Error::JsonDecodeError(
8617 encoded.to_string(),
8618 error,
8619 ));
8620 }
8621 }
8622 };
8623
8624 dlg.finished(true);
8625 return Ok(response);
8626 }
8627 }
8628 }
8629 }
8630
8631 /// Required. Resource name of the reservation to retrieve. E.g., `projects/myproject/locations/US/reservations/team1-prod`
8632 ///
8633 /// Sets the *name* path property to the given value.
8634 ///
8635 /// Even though the property as already been set when instantiating this call,
8636 /// we provide this method for API completeness.
8637 pub fn name(mut self, new_value: &str) -> ProjectLocationReservationDeleteCall<'a, C> {
8638 self._name = new_value.to_string();
8639 self
8640 }
8641 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8642 /// while executing the actual API request.
8643 ///
8644 /// ````text
8645 /// It should be used to handle progress information, and to implement a certain level of resilience.
8646 /// ````
8647 ///
8648 /// Sets the *delegate* property to the given value.
8649 pub fn delegate(
8650 mut self,
8651 new_value: &'a mut dyn common::Delegate,
8652 ) -> ProjectLocationReservationDeleteCall<'a, C> {
8653 self._delegate = Some(new_value);
8654 self
8655 }
8656
8657 /// Set any additional parameter of the query string used in the request.
8658 /// It should be used to set parameters which are not yet available through their own
8659 /// setters.
8660 ///
8661 /// Please note that this method must not be used to set any of the known parameters
8662 /// which have their own setter method. If done anyway, the request will fail.
8663 ///
8664 /// # Additional Parameters
8665 ///
8666 /// * *$.xgafv* (query-string) - V1 error format.
8667 /// * *access_token* (query-string) - OAuth access token.
8668 /// * *alt* (query-string) - Data format for response.
8669 /// * *callback* (query-string) - JSONP
8670 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
8671 /// * *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.
8672 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
8673 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
8674 /// * *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.
8675 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
8676 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
8677 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationReservationDeleteCall<'a, C>
8678 where
8679 T: AsRef<str>,
8680 {
8681 self._additional_params
8682 .insert(name.as_ref().to_string(), value.as_ref().to_string());
8683 self
8684 }
8685
8686 /// Identifies the authorization scope for the method you are building.
8687 ///
8688 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
8689 /// [`Scope::CloudPlatform`].
8690 ///
8691 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
8692 /// tokens for more than one scope.
8693 ///
8694 /// Usually there is more than one suitable scope to authorize an operation, some of which may
8695 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
8696 /// sufficient, a read-write scope will do as well.
8697 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationReservationDeleteCall<'a, C>
8698 where
8699 St: AsRef<str>,
8700 {
8701 self._scopes.insert(String::from(scope.as_ref()));
8702 self
8703 }
8704 /// Identifies the authorization scope(s) for the method you are building.
8705 ///
8706 /// See [`Self::add_scope()`] for details.
8707 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationReservationDeleteCall<'a, C>
8708 where
8709 I: IntoIterator<Item = St>,
8710 St: AsRef<str>,
8711 {
8712 self._scopes
8713 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
8714 self
8715 }
8716
8717 /// Removes all scopes, and no default scope will be used either.
8718 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
8719 /// for details).
8720 pub fn clear_scopes(mut self) -> ProjectLocationReservationDeleteCall<'a, C> {
8721 self._scopes.clear();
8722 self
8723 }
8724}
8725
8726/// Fail over a reservation to the secondary location. The operation should be done in the current secondary location, which will be promoted to the new primary location for the reservation. Attempting to failover a reservation in the current primary location will fail with the error code `google.rpc.Code.FAILED_PRECONDITION`.
8727///
8728/// A builder for the *locations.reservations.failoverReservation* method supported by a *project* resource.
8729/// It is not used directly, but through a [`ProjectMethods`] instance.
8730///
8731/// # Example
8732///
8733/// Instantiate a resource method builder
8734///
8735/// ```test_harness,no_run
8736/// # extern crate hyper;
8737/// # extern crate hyper_rustls;
8738/// # extern crate google_bigqueryreservation1 as bigqueryreservation1;
8739/// use bigqueryreservation1::api::FailoverReservationRequest;
8740/// # async fn dox() {
8741/// # use bigqueryreservation1::{BigQueryReservation, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
8742///
8743/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
8744/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
8745/// # .with_native_roots()
8746/// # .unwrap()
8747/// # .https_only()
8748/// # .enable_http2()
8749/// # .build();
8750///
8751/// # let executor = hyper_util::rt::TokioExecutor::new();
8752/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
8753/// # secret,
8754/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
8755/// # yup_oauth2::client::CustomHyperClientBuilder::from(
8756/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
8757/// # ),
8758/// # ).build().await.unwrap();
8759///
8760/// # let client = hyper_util::client::legacy::Client::builder(
8761/// # hyper_util::rt::TokioExecutor::new()
8762/// # )
8763/// # .build(
8764/// # hyper_rustls::HttpsConnectorBuilder::new()
8765/// # .with_native_roots()
8766/// # .unwrap()
8767/// # .https_or_http()
8768/// # .enable_http2()
8769/// # .build()
8770/// # );
8771/// # let mut hub = BigQueryReservation::new(client, auth);
8772/// // As the method needs a request, you would usually fill it with the desired information
8773/// // into the respective structure. Some of the parts shown here might not be applicable !
8774/// // Values shown here are possibly random and not representative !
8775/// let mut req = FailoverReservationRequest::default();
8776///
8777/// // You can configure optional parameters by calling the respective setters at will, and
8778/// // execute the final call using `doit()`.
8779/// // Values shown here are possibly random and not representative !
8780/// let result = hub.projects().locations_reservations_failover_reservation(req, "name")
8781/// .doit().await;
8782/// # }
8783/// ```
8784pub struct ProjectLocationReservationFailoverReservationCall<'a, C>
8785where
8786 C: 'a,
8787{
8788 hub: &'a BigQueryReservation<C>,
8789 _request: FailoverReservationRequest,
8790 _name: String,
8791 _delegate: Option<&'a mut dyn common::Delegate>,
8792 _additional_params: HashMap<String, String>,
8793 _scopes: BTreeSet<String>,
8794}
8795
8796impl<'a, C> common::CallBuilder for ProjectLocationReservationFailoverReservationCall<'a, C> {}
8797
8798impl<'a, C> ProjectLocationReservationFailoverReservationCall<'a, C>
8799where
8800 C: common::Connector,
8801{
8802 /// Perform the operation you have build so far.
8803 pub async fn doit(mut self) -> common::Result<(common::Response, Reservation)> {
8804 use std::borrow::Cow;
8805 use std::io::{Read, Seek};
8806
8807 use common::{url::Params, ToParts};
8808 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
8809
8810 let mut dd = common::DefaultDelegate;
8811 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
8812 dlg.begin(common::MethodInfo {
8813 id: "bigqueryreservation.projects.locations.reservations.failoverReservation",
8814 http_method: hyper::Method::POST,
8815 });
8816
8817 for &field in ["alt", "name"].iter() {
8818 if self._additional_params.contains_key(field) {
8819 dlg.finished(false);
8820 return Err(common::Error::FieldClash(field));
8821 }
8822 }
8823
8824 let mut params = Params::with_capacity(4 + self._additional_params.len());
8825 params.push("name", self._name);
8826
8827 params.extend(self._additional_params.iter());
8828
8829 params.push("alt", "json");
8830 let mut url = self.hub._base_url.clone() + "v1/{+name}:failoverReservation";
8831 if self._scopes.is_empty() {
8832 self._scopes
8833 .insert(Scope::CloudPlatform.as_ref().to_string());
8834 }
8835
8836 #[allow(clippy::single_element_loop)]
8837 for &(find_this, param_name) in [("{+name}", "name")].iter() {
8838 url = params.uri_replacement(url, param_name, find_this, true);
8839 }
8840 {
8841 let to_remove = ["name"];
8842 params.remove_params(&to_remove);
8843 }
8844
8845 let url = params.parse_with_url(&url);
8846
8847 let mut json_mime_type = mime::APPLICATION_JSON;
8848 let mut request_value_reader = {
8849 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
8850 common::remove_json_null_values(&mut value);
8851 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
8852 serde_json::to_writer(&mut dst, &value).unwrap();
8853 dst
8854 };
8855 let request_size = request_value_reader
8856 .seek(std::io::SeekFrom::End(0))
8857 .unwrap();
8858 request_value_reader
8859 .seek(std::io::SeekFrom::Start(0))
8860 .unwrap();
8861
8862 loop {
8863 let token = match self
8864 .hub
8865 .auth
8866 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
8867 .await
8868 {
8869 Ok(token) => token,
8870 Err(e) => match dlg.token(e) {
8871 Ok(token) => token,
8872 Err(e) => {
8873 dlg.finished(false);
8874 return Err(common::Error::MissingToken(e));
8875 }
8876 },
8877 };
8878 request_value_reader
8879 .seek(std::io::SeekFrom::Start(0))
8880 .unwrap();
8881 let mut req_result = {
8882 let client = &self.hub.client;
8883 dlg.pre_request();
8884 let mut req_builder = hyper::Request::builder()
8885 .method(hyper::Method::POST)
8886 .uri(url.as_str())
8887 .header(USER_AGENT, self.hub._user_agent.clone());
8888
8889 if let Some(token) = token.as_ref() {
8890 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
8891 }
8892
8893 let request = req_builder
8894 .header(CONTENT_TYPE, json_mime_type.to_string())
8895 .header(CONTENT_LENGTH, request_size as u64)
8896 .body(common::to_body(
8897 request_value_reader.get_ref().clone().into(),
8898 ));
8899
8900 client.request(request.unwrap()).await
8901 };
8902
8903 match req_result {
8904 Err(err) => {
8905 if let common::Retry::After(d) = dlg.http_error(&err) {
8906 sleep(d).await;
8907 continue;
8908 }
8909 dlg.finished(false);
8910 return Err(common::Error::HttpError(err));
8911 }
8912 Ok(res) => {
8913 let (mut parts, body) = res.into_parts();
8914 let mut body = common::Body::new(body);
8915 if !parts.status.is_success() {
8916 let bytes = common::to_bytes(body).await.unwrap_or_default();
8917 let error = serde_json::from_str(&common::to_string(&bytes));
8918 let response = common::to_response(parts, bytes.into());
8919
8920 if let common::Retry::After(d) =
8921 dlg.http_failure(&response, error.as_ref().ok())
8922 {
8923 sleep(d).await;
8924 continue;
8925 }
8926
8927 dlg.finished(false);
8928
8929 return Err(match error {
8930 Ok(value) => common::Error::BadRequest(value),
8931 _ => common::Error::Failure(response),
8932 });
8933 }
8934 let response = {
8935 let bytes = common::to_bytes(body).await.unwrap_or_default();
8936 let encoded = common::to_string(&bytes);
8937 match serde_json::from_str(&encoded) {
8938 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
8939 Err(error) => {
8940 dlg.response_json_decode_error(&encoded, &error);
8941 return Err(common::Error::JsonDecodeError(
8942 encoded.to_string(),
8943 error,
8944 ));
8945 }
8946 }
8947 };
8948
8949 dlg.finished(true);
8950 return Ok(response);
8951 }
8952 }
8953 }
8954 }
8955
8956 ///
8957 /// Sets the *request* property to the given value.
8958 ///
8959 /// Even though the property as already been set when instantiating this call,
8960 /// we provide this method for API completeness.
8961 pub fn request(
8962 mut self,
8963 new_value: FailoverReservationRequest,
8964 ) -> ProjectLocationReservationFailoverReservationCall<'a, C> {
8965 self._request = new_value;
8966 self
8967 }
8968 /// Required. Resource name of the reservation to failover. E.g., `projects/myproject/locations/US/reservations/team1-prod`
8969 ///
8970 /// Sets the *name* path property to the given value.
8971 ///
8972 /// Even though the property as already been set when instantiating this call,
8973 /// we provide this method for API completeness.
8974 pub fn name(
8975 mut self,
8976 new_value: &str,
8977 ) -> ProjectLocationReservationFailoverReservationCall<'a, C> {
8978 self._name = new_value.to_string();
8979 self
8980 }
8981 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
8982 /// while executing the actual API request.
8983 ///
8984 /// ````text
8985 /// It should be used to handle progress information, and to implement a certain level of resilience.
8986 /// ````
8987 ///
8988 /// Sets the *delegate* property to the given value.
8989 pub fn delegate(
8990 mut self,
8991 new_value: &'a mut dyn common::Delegate,
8992 ) -> ProjectLocationReservationFailoverReservationCall<'a, C> {
8993 self._delegate = Some(new_value);
8994 self
8995 }
8996
8997 /// Set any additional parameter of the query string used in the request.
8998 /// It should be used to set parameters which are not yet available through their own
8999 /// setters.
9000 ///
9001 /// Please note that this method must not be used to set any of the known parameters
9002 /// which have their own setter method. If done anyway, the request will fail.
9003 ///
9004 /// # Additional Parameters
9005 ///
9006 /// * *$.xgafv* (query-string) - V1 error format.
9007 /// * *access_token* (query-string) - OAuth access token.
9008 /// * *alt* (query-string) - Data format for response.
9009 /// * *callback* (query-string) - JSONP
9010 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9011 /// * *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.
9012 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9013 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9014 /// * *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.
9015 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9016 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9017 pub fn param<T>(
9018 mut self,
9019 name: T,
9020 value: T,
9021 ) -> ProjectLocationReservationFailoverReservationCall<'a, C>
9022 where
9023 T: AsRef<str>,
9024 {
9025 self._additional_params
9026 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9027 self
9028 }
9029
9030 /// Identifies the authorization scope for the method you are building.
9031 ///
9032 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9033 /// [`Scope::CloudPlatform`].
9034 ///
9035 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9036 /// tokens for more than one scope.
9037 ///
9038 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9039 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9040 /// sufficient, a read-write scope will do as well.
9041 pub fn add_scope<St>(
9042 mut self,
9043 scope: St,
9044 ) -> ProjectLocationReservationFailoverReservationCall<'a, C>
9045 where
9046 St: AsRef<str>,
9047 {
9048 self._scopes.insert(String::from(scope.as_ref()));
9049 self
9050 }
9051 /// Identifies the authorization scope(s) for the method you are building.
9052 ///
9053 /// See [`Self::add_scope()`] for details.
9054 pub fn add_scopes<I, St>(
9055 mut self,
9056 scopes: I,
9057 ) -> ProjectLocationReservationFailoverReservationCall<'a, C>
9058 where
9059 I: IntoIterator<Item = St>,
9060 St: AsRef<str>,
9061 {
9062 self._scopes
9063 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9064 self
9065 }
9066
9067 /// Removes all scopes, and no default scope will be used either.
9068 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9069 /// for details).
9070 pub fn clear_scopes(mut self) -> ProjectLocationReservationFailoverReservationCall<'a, C> {
9071 self._scopes.clear();
9072 self
9073 }
9074}
9075
9076/// Returns information about the reservation.
9077///
9078/// A builder for the *locations.reservations.get* method supported by a *project* resource.
9079/// It is not used directly, but through a [`ProjectMethods`] instance.
9080///
9081/// # Example
9082///
9083/// Instantiate a resource method builder
9084///
9085/// ```test_harness,no_run
9086/// # extern crate hyper;
9087/// # extern crate hyper_rustls;
9088/// # extern crate google_bigqueryreservation1 as bigqueryreservation1;
9089/// # async fn dox() {
9090/// # use bigqueryreservation1::{BigQueryReservation, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9091///
9092/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9093/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9094/// # .with_native_roots()
9095/// # .unwrap()
9096/// # .https_only()
9097/// # .enable_http2()
9098/// # .build();
9099///
9100/// # let executor = hyper_util::rt::TokioExecutor::new();
9101/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9102/// # secret,
9103/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9104/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9105/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9106/// # ),
9107/// # ).build().await.unwrap();
9108///
9109/// # let client = hyper_util::client::legacy::Client::builder(
9110/// # hyper_util::rt::TokioExecutor::new()
9111/// # )
9112/// # .build(
9113/// # hyper_rustls::HttpsConnectorBuilder::new()
9114/// # .with_native_roots()
9115/// # .unwrap()
9116/// # .https_or_http()
9117/// # .enable_http2()
9118/// # .build()
9119/// # );
9120/// # let mut hub = BigQueryReservation::new(client, auth);
9121/// // You can configure optional parameters by calling the respective setters at will, and
9122/// // execute the final call using `doit()`.
9123/// // Values shown here are possibly random and not representative !
9124/// let result = hub.projects().locations_reservations_get("name")
9125/// .doit().await;
9126/// # }
9127/// ```
9128pub struct ProjectLocationReservationGetCall<'a, C>
9129where
9130 C: 'a,
9131{
9132 hub: &'a BigQueryReservation<C>,
9133 _name: String,
9134 _delegate: Option<&'a mut dyn common::Delegate>,
9135 _additional_params: HashMap<String, String>,
9136 _scopes: BTreeSet<String>,
9137}
9138
9139impl<'a, C> common::CallBuilder for ProjectLocationReservationGetCall<'a, C> {}
9140
9141impl<'a, C> ProjectLocationReservationGetCall<'a, C>
9142where
9143 C: common::Connector,
9144{
9145 /// Perform the operation you have build so far.
9146 pub async fn doit(mut self) -> common::Result<(common::Response, Reservation)> {
9147 use std::borrow::Cow;
9148 use std::io::{Read, Seek};
9149
9150 use common::{url::Params, ToParts};
9151 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9152
9153 let mut dd = common::DefaultDelegate;
9154 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9155 dlg.begin(common::MethodInfo {
9156 id: "bigqueryreservation.projects.locations.reservations.get",
9157 http_method: hyper::Method::GET,
9158 });
9159
9160 for &field in ["alt", "name"].iter() {
9161 if self._additional_params.contains_key(field) {
9162 dlg.finished(false);
9163 return Err(common::Error::FieldClash(field));
9164 }
9165 }
9166
9167 let mut params = Params::with_capacity(3 + self._additional_params.len());
9168 params.push("name", self._name);
9169
9170 params.extend(self._additional_params.iter());
9171
9172 params.push("alt", "json");
9173 let mut url = self.hub._base_url.clone() + "v1/{+name}";
9174 if self._scopes.is_empty() {
9175 self._scopes
9176 .insert(Scope::CloudPlatform.as_ref().to_string());
9177 }
9178
9179 #[allow(clippy::single_element_loop)]
9180 for &(find_this, param_name) in [("{+name}", "name")].iter() {
9181 url = params.uri_replacement(url, param_name, find_this, true);
9182 }
9183 {
9184 let to_remove = ["name"];
9185 params.remove_params(&to_remove);
9186 }
9187
9188 let url = params.parse_with_url(&url);
9189
9190 loop {
9191 let token = match self
9192 .hub
9193 .auth
9194 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9195 .await
9196 {
9197 Ok(token) => token,
9198 Err(e) => match dlg.token(e) {
9199 Ok(token) => token,
9200 Err(e) => {
9201 dlg.finished(false);
9202 return Err(common::Error::MissingToken(e));
9203 }
9204 },
9205 };
9206 let mut req_result = {
9207 let client = &self.hub.client;
9208 dlg.pre_request();
9209 let mut req_builder = hyper::Request::builder()
9210 .method(hyper::Method::GET)
9211 .uri(url.as_str())
9212 .header(USER_AGENT, self.hub._user_agent.clone());
9213
9214 if let Some(token) = token.as_ref() {
9215 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9216 }
9217
9218 let request = req_builder
9219 .header(CONTENT_LENGTH, 0_u64)
9220 .body(common::to_body::<String>(None));
9221
9222 client.request(request.unwrap()).await
9223 };
9224
9225 match req_result {
9226 Err(err) => {
9227 if let common::Retry::After(d) = dlg.http_error(&err) {
9228 sleep(d).await;
9229 continue;
9230 }
9231 dlg.finished(false);
9232 return Err(common::Error::HttpError(err));
9233 }
9234 Ok(res) => {
9235 let (mut parts, body) = res.into_parts();
9236 let mut body = common::Body::new(body);
9237 if !parts.status.is_success() {
9238 let bytes = common::to_bytes(body).await.unwrap_or_default();
9239 let error = serde_json::from_str(&common::to_string(&bytes));
9240 let response = common::to_response(parts, bytes.into());
9241
9242 if let common::Retry::After(d) =
9243 dlg.http_failure(&response, error.as_ref().ok())
9244 {
9245 sleep(d).await;
9246 continue;
9247 }
9248
9249 dlg.finished(false);
9250
9251 return Err(match error {
9252 Ok(value) => common::Error::BadRequest(value),
9253 _ => common::Error::Failure(response),
9254 });
9255 }
9256 let response = {
9257 let bytes = common::to_bytes(body).await.unwrap_or_default();
9258 let encoded = common::to_string(&bytes);
9259 match serde_json::from_str(&encoded) {
9260 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9261 Err(error) => {
9262 dlg.response_json_decode_error(&encoded, &error);
9263 return Err(common::Error::JsonDecodeError(
9264 encoded.to_string(),
9265 error,
9266 ));
9267 }
9268 }
9269 };
9270
9271 dlg.finished(true);
9272 return Ok(response);
9273 }
9274 }
9275 }
9276 }
9277
9278 /// Required. Resource name of the reservation to retrieve. E.g., `projects/myproject/locations/US/reservations/team1-prod`
9279 ///
9280 /// Sets the *name* path property to the given value.
9281 ///
9282 /// Even though the property as already been set when instantiating this call,
9283 /// we provide this method for API completeness.
9284 pub fn name(mut self, new_value: &str) -> ProjectLocationReservationGetCall<'a, C> {
9285 self._name = new_value.to_string();
9286 self
9287 }
9288 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9289 /// while executing the actual API request.
9290 ///
9291 /// ````text
9292 /// It should be used to handle progress information, and to implement a certain level of resilience.
9293 /// ````
9294 ///
9295 /// Sets the *delegate* property to the given value.
9296 pub fn delegate(
9297 mut self,
9298 new_value: &'a mut dyn common::Delegate,
9299 ) -> ProjectLocationReservationGetCall<'a, C> {
9300 self._delegate = Some(new_value);
9301 self
9302 }
9303
9304 /// Set any additional parameter of the query string used in the request.
9305 /// It should be used to set parameters which are not yet available through their own
9306 /// setters.
9307 ///
9308 /// Please note that this method must not be used to set any of the known parameters
9309 /// which have their own setter method. If done anyway, the request will fail.
9310 ///
9311 /// # Additional Parameters
9312 ///
9313 /// * *$.xgafv* (query-string) - V1 error format.
9314 /// * *access_token* (query-string) - OAuth access token.
9315 /// * *alt* (query-string) - Data format for response.
9316 /// * *callback* (query-string) - JSONP
9317 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9318 /// * *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.
9319 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9320 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9321 /// * *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.
9322 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9323 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9324 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationReservationGetCall<'a, C>
9325 where
9326 T: AsRef<str>,
9327 {
9328 self._additional_params
9329 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9330 self
9331 }
9332
9333 /// Identifies the authorization scope for the method you are building.
9334 ///
9335 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9336 /// [`Scope::CloudPlatform`].
9337 ///
9338 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9339 /// tokens for more than one scope.
9340 ///
9341 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9342 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9343 /// sufficient, a read-write scope will do as well.
9344 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationReservationGetCall<'a, C>
9345 where
9346 St: AsRef<str>,
9347 {
9348 self._scopes.insert(String::from(scope.as_ref()));
9349 self
9350 }
9351 /// Identifies the authorization scope(s) for the method you are building.
9352 ///
9353 /// See [`Self::add_scope()`] for details.
9354 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationReservationGetCall<'a, C>
9355 where
9356 I: IntoIterator<Item = St>,
9357 St: AsRef<str>,
9358 {
9359 self._scopes
9360 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9361 self
9362 }
9363
9364 /// Removes all scopes, and no default scope will be used either.
9365 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9366 /// for details).
9367 pub fn clear_scopes(mut self) -> ProjectLocationReservationGetCall<'a, C> {
9368 self._scopes.clear();
9369 self
9370 }
9371}
9372
9373/// Gets the access control policy for a resource. May return: * A`NOT_FOUND` error if the resource doesn't exist or you don't have the permission to view it. * An empty policy if the resource exists but doesn't have a set policy. Supported resources are: - Reservations - ReservationAssignments To call this method, you must have the following Google IAM permissions: - `bigqueryreservation.reservations.getIamPolicy` to get policies on reservations.
9374///
9375/// A builder for the *locations.reservations.getIamPolicy* method supported by a *project* resource.
9376/// It is not used directly, but through a [`ProjectMethods`] instance.
9377///
9378/// # Example
9379///
9380/// Instantiate a resource method builder
9381///
9382/// ```test_harness,no_run
9383/// # extern crate hyper;
9384/// # extern crate hyper_rustls;
9385/// # extern crate google_bigqueryreservation1 as bigqueryreservation1;
9386/// # async fn dox() {
9387/// # use bigqueryreservation1::{BigQueryReservation, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9388///
9389/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9390/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9391/// # .with_native_roots()
9392/// # .unwrap()
9393/// # .https_only()
9394/// # .enable_http2()
9395/// # .build();
9396///
9397/// # let executor = hyper_util::rt::TokioExecutor::new();
9398/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9399/// # secret,
9400/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9401/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9402/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9403/// # ),
9404/// # ).build().await.unwrap();
9405///
9406/// # let client = hyper_util::client::legacy::Client::builder(
9407/// # hyper_util::rt::TokioExecutor::new()
9408/// # )
9409/// # .build(
9410/// # hyper_rustls::HttpsConnectorBuilder::new()
9411/// # .with_native_roots()
9412/// # .unwrap()
9413/// # .https_or_http()
9414/// # .enable_http2()
9415/// # .build()
9416/// # );
9417/// # let mut hub = BigQueryReservation::new(client, auth);
9418/// // You can configure optional parameters by calling the respective setters at will, and
9419/// // execute the final call using `doit()`.
9420/// // Values shown here are possibly random and not representative !
9421/// let result = hub.projects().locations_reservations_get_iam_policy("resource")
9422/// .options_requested_policy_version(-13)
9423/// .doit().await;
9424/// # }
9425/// ```
9426pub struct ProjectLocationReservationGetIamPolicyCall<'a, C>
9427where
9428 C: 'a,
9429{
9430 hub: &'a BigQueryReservation<C>,
9431 _resource: String,
9432 _options_requested_policy_version: Option<i32>,
9433 _delegate: Option<&'a mut dyn common::Delegate>,
9434 _additional_params: HashMap<String, String>,
9435 _scopes: BTreeSet<String>,
9436}
9437
9438impl<'a, C> common::CallBuilder for ProjectLocationReservationGetIamPolicyCall<'a, C> {}
9439
9440impl<'a, C> ProjectLocationReservationGetIamPolicyCall<'a, C>
9441where
9442 C: common::Connector,
9443{
9444 /// Perform the operation you have build so far.
9445 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
9446 use std::borrow::Cow;
9447 use std::io::{Read, Seek};
9448
9449 use common::{url::Params, ToParts};
9450 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9451
9452 let mut dd = common::DefaultDelegate;
9453 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9454 dlg.begin(common::MethodInfo {
9455 id: "bigqueryreservation.projects.locations.reservations.getIamPolicy",
9456 http_method: hyper::Method::GET,
9457 });
9458
9459 for &field in ["alt", "resource", "options.requestedPolicyVersion"].iter() {
9460 if self._additional_params.contains_key(field) {
9461 dlg.finished(false);
9462 return Err(common::Error::FieldClash(field));
9463 }
9464 }
9465
9466 let mut params = Params::with_capacity(4 + self._additional_params.len());
9467 params.push("resource", self._resource);
9468 if let Some(value) = self._options_requested_policy_version.as_ref() {
9469 params.push("options.requestedPolicyVersion", value.to_string());
9470 }
9471
9472 params.extend(self._additional_params.iter());
9473
9474 params.push("alt", "json");
9475 let mut url = self.hub._base_url.clone() + "v1/{+resource}:getIamPolicy";
9476 if self._scopes.is_empty() {
9477 self._scopes
9478 .insert(Scope::CloudPlatform.as_ref().to_string());
9479 }
9480
9481 #[allow(clippy::single_element_loop)]
9482 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
9483 url = params.uri_replacement(url, param_name, find_this, true);
9484 }
9485 {
9486 let to_remove = ["resource"];
9487 params.remove_params(&to_remove);
9488 }
9489
9490 let url = params.parse_with_url(&url);
9491
9492 loop {
9493 let token = match self
9494 .hub
9495 .auth
9496 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9497 .await
9498 {
9499 Ok(token) => token,
9500 Err(e) => match dlg.token(e) {
9501 Ok(token) => token,
9502 Err(e) => {
9503 dlg.finished(false);
9504 return Err(common::Error::MissingToken(e));
9505 }
9506 },
9507 };
9508 let mut req_result = {
9509 let client = &self.hub.client;
9510 dlg.pre_request();
9511 let mut req_builder = hyper::Request::builder()
9512 .method(hyper::Method::GET)
9513 .uri(url.as_str())
9514 .header(USER_AGENT, self.hub._user_agent.clone());
9515
9516 if let Some(token) = token.as_ref() {
9517 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9518 }
9519
9520 let request = req_builder
9521 .header(CONTENT_LENGTH, 0_u64)
9522 .body(common::to_body::<String>(None));
9523
9524 client.request(request.unwrap()).await
9525 };
9526
9527 match req_result {
9528 Err(err) => {
9529 if let common::Retry::After(d) = dlg.http_error(&err) {
9530 sleep(d).await;
9531 continue;
9532 }
9533 dlg.finished(false);
9534 return Err(common::Error::HttpError(err));
9535 }
9536 Ok(res) => {
9537 let (mut parts, body) = res.into_parts();
9538 let mut body = common::Body::new(body);
9539 if !parts.status.is_success() {
9540 let bytes = common::to_bytes(body).await.unwrap_or_default();
9541 let error = serde_json::from_str(&common::to_string(&bytes));
9542 let response = common::to_response(parts, bytes.into());
9543
9544 if let common::Retry::After(d) =
9545 dlg.http_failure(&response, error.as_ref().ok())
9546 {
9547 sleep(d).await;
9548 continue;
9549 }
9550
9551 dlg.finished(false);
9552
9553 return Err(match error {
9554 Ok(value) => common::Error::BadRequest(value),
9555 _ => common::Error::Failure(response),
9556 });
9557 }
9558 let response = {
9559 let bytes = common::to_bytes(body).await.unwrap_or_default();
9560 let encoded = common::to_string(&bytes);
9561 match serde_json::from_str(&encoded) {
9562 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9563 Err(error) => {
9564 dlg.response_json_decode_error(&encoded, &error);
9565 return Err(common::Error::JsonDecodeError(
9566 encoded.to_string(),
9567 error,
9568 ));
9569 }
9570 }
9571 };
9572
9573 dlg.finished(true);
9574 return Ok(response);
9575 }
9576 }
9577 }
9578 }
9579
9580 /// 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.
9581 ///
9582 /// Sets the *resource* path property to the given value.
9583 ///
9584 /// Even though the property as already been set when instantiating this call,
9585 /// we provide this method for API completeness.
9586 pub fn resource(
9587 mut self,
9588 new_value: &str,
9589 ) -> ProjectLocationReservationGetIamPolicyCall<'a, C> {
9590 self._resource = new_value.to_string();
9591 self
9592 }
9593 /// 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).
9594 ///
9595 /// Sets the *options.requested policy version* query property to the given value.
9596 pub fn options_requested_policy_version(
9597 mut self,
9598 new_value: i32,
9599 ) -> ProjectLocationReservationGetIamPolicyCall<'a, C> {
9600 self._options_requested_policy_version = Some(new_value);
9601 self
9602 }
9603 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9604 /// while executing the actual API request.
9605 ///
9606 /// ````text
9607 /// It should be used to handle progress information, and to implement a certain level of resilience.
9608 /// ````
9609 ///
9610 /// Sets the *delegate* property to the given value.
9611 pub fn delegate(
9612 mut self,
9613 new_value: &'a mut dyn common::Delegate,
9614 ) -> ProjectLocationReservationGetIamPolicyCall<'a, C> {
9615 self._delegate = Some(new_value);
9616 self
9617 }
9618
9619 /// Set any additional parameter of the query string used in the request.
9620 /// It should be used to set parameters which are not yet available through their own
9621 /// setters.
9622 ///
9623 /// Please note that this method must not be used to set any of the known parameters
9624 /// which have their own setter method. If done anyway, the request will fail.
9625 ///
9626 /// # Additional Parameters
9627 ///
9628 /// * *$.xgafv* (query-string) - V1 error format.
9629 /// * *access_token* (query-string) - OAuth access token.
9630 /// * *alt* (query-string) - Data format for response.
9631 /// * *callback* (query-string) - JSONP
9632 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9633 /// * *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.
9634 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9635 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9636 /// * *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.
9637 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9638 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9639 pub fn param<T>(
9640 mut self,
9641 name: T,
9642 value: T,
9643 ) -> ProjectLocationReservationGetIamPolicyCall<'a, C>
9644 where
9645 T: AsRef<str>,
9646 {
9647 self._additional_params
9648 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9649 self
9650 }
9651
9652 /// Identifies the authorization scope for the method you are building.
9653 ///
9654 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9655 /// [`Scope::CloudPlatform`].
9656 ///
9657 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9658 /// tokens for more than one scope.
9659 ///
9660 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9661 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9662 /// sufficient, a read-write scope will do as well.
9663 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationReservationGetIamPolicyCall<'a, C>
9664 where
9665 St: AsRef<str>,
9666 {
9667 self._scopes.insert(String::from(scope.as_ref()));
9668 self
9669 }
9670 /// Identifies the authorization scope(s) for the method you are building.
9671 ///
9672 /// See [`Self::add_scope()`] for details.
9673 pub fn add_scopes<I, St>(
9674 mut self,
9675 scopes: I,
9676 ) -> ProjectLocationReservationGetIamPolicyCall<'a, C>
9677 where
9678 I: IntoIterator<Item = St>,
9679 St: AsRef<str>,
9680 {
9681 self._scopes
9682 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
9683 self
9684 }
9685
9686 /// Removes all scopes, and no default scope will be used either.
9687 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
9688 /// for details).
9689 pub fn clear_scopes(mut self) -> ProjectLocationReservationGetIamPolicyCall<'a, C> {
9690 self._scopes.clear();
9691 self
9692 }
9693}
9694
9695/// Lists all the reservations for the project in the specified location.
9696///
9697/// A builder for the *locations.reservations.list* method supported by a *project* resource.
9698/// It is not used directly, but through a [`ProjectMethods`] instance.
9699///
9700/// # Example
9701///
9702/// Instantiate a resource method builder
9703///
9704/// ```test_harness,no_run
9705/// # extern crate hyper;
9706/// # extern crate hyper_rustls;
9707/// # extern crate google_bigqueryreservation1 as bigqueryreservation1;
9708/// # async fn dox() {
9709/// # use bigqueryreservation1::{BigQueryReservation, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
9710///
9711/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
9712/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
9713/// # .with_native_roots()
9714/// # .unwrap()
9715/// # .https_only()
9716/// # .enable_http2()
9717/// # .build();
9718///
9719/// # let executor = hyper_util::rt::TokioExecutor::new();
9720/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
9721/// # secret,
9722/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
9723/// # yup_oauth2::client::CustomHyperClientBuilder::from(
9724/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
9725/// # ),
9726/// # ).build().await.unwrap();
9727///
9728/// # let client = hyper_util::client::legacy::Client::builder(
9729/// # hyper_util::rt::TokioExecutor::new()
9730/// # )
9731/// # .build(
9732/// # hyper_rustls::HttpsConnectorBuilder::new()
9733/// # .with_native_roots()
9734/// # .unwrap()
9735/// # .https_or_http()
9736/// # .enable_http2()
9737/// # .build()
9738/// # );
9739/// # let mut hub = BigQueryReservation::new(client, auth);
9740/// // You can configure optional parameters by calling the respective setters at will, and
9741/// // execute the final call using `doit()`.
9742/// // Values shown here are possibly random and not representative !
9743/// let result = hub.projects().locations_reservations_list("parent")
9744/// .page_token("sed")
9745/// .page_size(-24)
9746/// .doit().await;
9747/// # }
9748/// ```
9749pub struct ProjectLocationReservationListCall<'a, C>
9750where
9751 C: 'a,
9752{
9753 hub: &'a BigQueryReservation<C>,
9754 _parent: String,
9755 _page_token: Option<String>,
9756 _page_size: Option<i32>,
9757 _delegate: Option<&'a mut dyn common::Delegate>,
9758 _additional_params: HashMap<String, String>,
9759 _scopes: BTreeSet<String>,
9760}
9761
9762impl<'a, C> common::CallBuilder for ProjectLocationReservationListCall<'a, C> {}
9763
9764impl<'a, C> ProjectLocationReservationListCall<'a, C>
9765where
9766 C: common::Connector,
9767{
9768 /// Perform the operation you have build so far.
9769 pub async fn doit(mut self) -> common::Result<(common::Response, ListReservationsResponse)> {
9770 use std::borrow::Cow;
9771 use std::io::{Read, Seek};
9772
9773 use common::{url::Params, ToParts};
9774 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
9775
9776 let mut dd = common::DefaultDelegate;
9777 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
9778 dlg.begin(common::MethodInfo {
9779 id: "bigqueryreservation.projects.locations.reservations.list",
9780 http_method: hyper::Method::GET,
9781 });
9782
9783 for &field in ["alt", "parent", "pageToken", "pageSize"].iter() {
9784 if self._additional_params.contains_key(field) {
9785 dlg.finished(false);
9786 return Err(common::Error::FieldClash(field));
9787 }
9788 }
9789
9790 let mut params = Params::with_capacity(5 + self._additional_params.len());
9791 params.push("parent", self._parent);
9792 if let Some(value) = self._page_token.as_ref() {
9793 params.push("pageToken", value);
9794 }
9795 if let Some(value) = self._page_size.as_ref() {
9796 params.push("pageSize", value.to_string());
9797 }
9798
9799 params.extend(self._additional_params.iter());
9800
9801 params.push("alt", "json");
9802 let mut url = self.hub._base_url.clone() + "v1/{+parent}/reservations";
9803 if self._scopes.is_empty() {
9804 self._scopes
9805 .insert(Scope::CloudPlatform.as_ref().to_string());
9806 }
9807
9808 #[allow(clippy::single_element_loop)]
9809 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
9810 url = params.uri_replacement(url, param_name, find_this, true);
9811 }
9812 {
9813 let to_remove = ["parent"];
9814 params.remove_params(&to_remove);
9815 }
9816
9817 let url = params.parse_with_url(&url);
9818
9819 loop {
9820 let token = match self
9821 .hub
9822 .auth
9823 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
9824 .await
9825 {
9826 Ok(token) => token,
9827 Err(e) => match dlg.token(e) {
9828 Ok(token) => token,
9829 Err(e) => {
9830 dlg.finished(false);
9831 return Err(common::Error::MissingToken(e));
9832 }
9833 },
9834 };
9835 let mut req_result = {
9836 let client = &self.hub.client;
9837 dlg.pre_request();
9838 let mut req_builder = hyper::Request::builder()
9839 .method(hyper::Method::GET)
9840 .uri(url.as_str())
9841 .header(USER_AGENT, self.hub._user_agent.clone());
9842
9843 if let Some(token) = token.as_ref() {
9844 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
9845 }
9846
9847 let request = req_builder
9848 .header(CONTENT_LENGTH, 0_u64)
9849 .body(common::to_body::<String>(None));
9850
9851 client.request(request.unwrap()).await
9852 };
9853
9854 match req_result {
9855 Err(err) => {
9856 if let common::Retry::After(d) = dlg.http_error(&err) {
9857 sleep(d).await;
9858 continue;
9859 }
9860 dlg.finished(false);
9861 return Err(common::Error::HttpError(err));
9862 }
9863 Ok(res) => {
9864 let (mut parts, body) = res.into_parts();
9865 let mut body = common::Body::new(body);
9866 if !parts.status.is_success() {
9867 let bytes = common::to_bytes(body).await.unwrap_or_default();
9868 let error = serde_json::from_str(&common::to_string(&bytes));
9869 let response = common::to_response(parts, bytes.into());
9870
9871 if let common::Retry::After(d) =
9872 dlg.http_failure(&response, error.as_ref().ok())
9873 {
9874 sleep(d).await;
9875 continue;
9876 }
9877
9878 dlg.finished(false);
9879
9880 return Err(match error {
9881 Ok(value) => common::Error::BadRequest(value),
9882 _ => common::Error::Failure(response),
9883 });
9884 }
9885 let response = {
9886 let bytes = common::to_bytes(body).await.unwrap_or_default();
9887 let encoded = common::to_string(&bytes);
9888 match serde_json::from_str(&encoded) {
9889 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
9890 Err(error) => {
9891 dlg.response_json_decode_error(&encoded, &error);
9892 return Err(common::Error::JsonDecodeError(
9893 encoded.to_string(),
9894 error,
9895 ));
9896 }
9897 }
9898 };
9899
9900 dlg.finished(true);
9901 return Ok(response);
9902 }
9903 }
9904 }
9905 }
9906
9907 /// Required. The parent resource name containing project and location, e.g.: `projects/myproject/locations/US`
9908 ///
9909 /// Sets the *parent* path property to the given value.
9910 ///
9911 /// Even though the property as already been set when instantiating this call,
9912 /// we provide this method for API completeness.
9913 pub fn parent(mut self, new_value: &str) -> ProjectLocationReservationListCall<'a, C> {
9914 self._parent = new_value.to_string();
9915 self
9916 }
9917 /// The next_page_token value returned from a previous List request, if any.
9918 ///
9919 /// Sets the *page token* query property to the given value.
9920 pub fn page_token(mut self, new_value: &str) -> ProjectLocationReservationListCall<'a, C> {
9921 self._page_token = Some(new_value.to_string());
9922 self
9923 }
9924 /// The maximum number of items to return per page.
9925 ///
9926 /// Sets the *page size* query property to the given value.
9927 pub fn page_size(mut self, new_value: i32) -> ProjectLocationReservationListCall<'a, C> {
9928 self._page_size = Some(new_value);
9929 self
9930 }
9931 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
9932 /// while executing the actual API request.
9933 ///
9934 /// ````text
9935 /// It should be used to handle progress information, and to implement a certain level of resilience.
9936 /// ````
9937 ///
9938 /// Sets the *delegate* property to the given value.
9939 pub fn delegate(
9940 mut self,
9941 new_value: &'a mut dyn common::Delegate,
9942 ) -> ProjectLocationReservationListCall<'a, C> {
9943 self._delegate = Some(new_value);
9944 self
9945 }
9946
9947 /// Set any additional parameter of the query string used in the request.
9948 /// It should be used to set parameters which are not yet available through their own
9949 /// setters.
9950 ///
9951 /// Please note that this method must not be used to set any of the known parameters
9952 /// which have their own setter method. If done anyway, the request will fail.
9953 ///
9954 /// # Additional Parameters
9955 ///
9956 /// * *$.xgafv* (query-string) - V1 error format.
9957 /// * *access_token* (query-string) - OAuth access token.
9958 /// * *alt* (query-string) - Data format for response.
9959 /// * *callback* (query-string) - JSONP
9960 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
9961 /// * *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.
9962 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
9963 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
9964 /// * *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.
9965 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
9966 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
9967 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationReservationListCall<'a, C>
9968 where
9969 T: AsRef<str>,
9970 {
9971 self._additional_params
9972 .insert(name.as_ref().to_string(), value.as_ref().to_string());
9973 self
9974 }
9975
9976 /// Identifies the authorization scope for the method you are building.
9977 ///
9978 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
9979 /// [`Scope::CloudPlatform`].
9980 ///
9981 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
9982 /// tokens for more than one scope.
9983 ///
9984 /// Usually there is more than one suitable scope to authorize an operation, some of which may
9985 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
9986 /// sufficient, a read-write scope will do as well.
9987 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationReservationListCall<'a, C>
9988 where
9989 St: AsRef<str>,
9990 {
9991 self._scopes.insert(String::from(scope.as_ref()));
9992 self
9993 }
9994 /// Identifies the authorization scope(s) for the method you are building.
9995 ///
9996 /// See [`Self::add_scope()`] for details.
9997 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationReservationListCall<'a, C>
9998 where
9999 I: IntoIterator<Item = St>,
10000 St: AsRef<str>,
10001 {
10002 self._scopes
10003 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10004 self
10005 }
10006
10007 /// Removes all scopes, and no default scope will be used either.
10008 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10009 /// for details).
10010 pub fn clear_scopes(mut self) -> ProjectLocationReservationListCall<'a, C> {
10011 self._scopes.clear();
10012 self
10013 }
10014}
10015
10016/// Updates an existing reservation resource.
10017///
10018/// A builder for the *locations.reservations.patch* method supported by a *project* resource.
10019/// It is not used directly, but through a [`ProjectMethods`] instance.
10020///
10021/// # Example
10022///
10023/// Instantiate a resource method builder
10024///
10025/// ```test_harness,no_run
10026/// # extern crate hyper;
10027/// # extern crate hyper_rustls;
10028/// # extern crate google_bigqueryreservation1 as bigqueryreservation1;
10029/// use bigqueryreservation1::api::Reservation;
10030/// # async fn dox() {
10031/// # use bigqueryreservation1::{BigQueryReservation, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10032///
10033/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10034/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10035/// # .with_native_roots()
10036/// # .unwrap()
10037/// # .https_only()
10038/// # .enable_http2()
10039/// # .build();
10040///
10041/// # let executor = hyper_util::rt::TokioExecutor::new();
10042/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10043/// # secret,
10044/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10045/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10046/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10047/// # ),
10048/// # ).build().await.unwrap();
10049///
10050/// # let client = hyper_util::client::legacy::Client::builder(
10051/// # hyper_util::rt::TokioExecutor::new()
10052/// # )
10053/// # .build(
10054/// # hyper_rustls::HttpsConnectorBuilder::new()
10055/// # .with_native_roots()
10056/// # .unwrap()
10057/// # .https_or_http()
10058/// # .enable_http2()
10059/// # .build()
10060/// # );
10061/// # let mut hub = BigQueryReservation::new(client, auth);
10062/// // As the method needs a request, you would usually fill it with the desired information
10063/// // into the respective structure. Some of the parts shown here might not be applicable !
10064/// // Values shown here are possibly random and not representative !
10065/// let mut req = Reservation::default();
10066///
10067/// // You can configure optional parameters by calling the respective setters at will, and
10068/// // execute the final call using `doit()`.
10069/// // Values shown here are possibly random and not representative !
10070/// let result = hub.projects().locations_reservations_patch(req, "name")
10071/// .update_mask(FieldMask::new::<&str>(&[]))
10072/// .doit().await;
10073/// # }
10074/// ```
10075pub struct ProjectLocationReservationPatchCall<'a, C>
10076where
10077 C: 'a,
10078{
10079 hub: &'a BigQueryReservation<C>,
10080 _request: Reservation,
10081 _name: String,
10082 _update_mask: Option<common::FieldMask>,
10083 _delegate: Option<&'a mut dyn common::Delegate>,
10084 _additional_params: HashMap<String, String>,
10085 _scopes: BTreeSet<String>,
10086}
10087
10088impl<'a, C> common::CallBuilder for ProjectLocationReservationPatchCall<'a, C> {}
10089
10090impl<'a, C> ProjectLocationReservationPatchCall<'a, C>
10091where
10092 C: common::Connector,
10093{
10094 /// Perform the operation you have build so far.
10095 pub async fn doit(mut self) -> common::Result<(common::Response, Reservation)> {
10096 use std::borrow::Cow;
10097 use std::io::{Read, Seek};
10098
10099 use common::{url::Params, ToParts};
10100 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10101
10102 let mut dd = common::DefaultDelegate;
10103 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10104 dlg.begin(common::MethodInfo {
10105 id: "bigqueryreservation.projects.locations.reservations.patch",
10106 http_method: hyper::Method::PATCH,
10107 });
10108
10109 for &field in ["alt", "name", "updateMask"].iter() {
10110 if self._additional_params.contains_key(field) {
10111 dlg.finished(false);
10112 return Err(common::Error::FieldClash(field));
10113 }
10114 }
10115
10116 let mut params = Params::with_capacity(5 + self._additional_params.len());
10117 params.push("name", self._name);
10118 if let Some(value) = self._update_mask.as_ref() {
10119 params.push("updateMask", value.to_string());
10120 }
10121
10122 params.extend(self._additional_params.iter());
10123
10124 params.push("alt", "json");
10125 let mut url = self.hub._base_url.clone() + "v1/{+name}";
10126 if self._scopes.is_empty() {
10127 self._scopes
10128 .insert(Scope::CloudPlatform.as_ref().to_string());
10129 }
10130
10131 #[allow(clippy::single_element_loop)]
10132 for &(find_this, param_name) in [("{+name}", "name")].iter() {
10133 url = params.uri_replacement(url, param_name, find_this, true);
10134 }
10135 {
10136 let to_remove = ["name"];
10137 params.remove_params(&to_remove);
10138 }
10139
10140 let url = params.parse_with_url(&url);
10141
10142 let mut json_mime_type = mime::APPLICATION_JSON;
10143 let mut request_value_reader = {
10144 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10145 common::remove_json_null_values(&mut value);
10146 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10147 serde_json::to_writer(&mut dst, &value).unwrap();
10148 dst
10149 };
10150 let request_size = request_value_reader
10151 .seek(std::io::SeekFrom::End(0))
10152 .unwrap();
10153 request_value_reader
10154 .seek(std::io::SeekFrom::Start(0))
10155 .unwrap();
10156
10157 loop {
10158 let token = match self
10159 .hub
10160 .auth
10161 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10162 .await
10163 {
10164 Ok(token) => token,
10165 Err(e) => match dlg.token(e) {
10166 Ok(token) => token,
10167 Err(e) => {
10168 dlg.finished(false);
10169 return Err(common::Error::MissingToken(e));
10170 }
10171 },
10172 };
10173 request_value_reader
10174 .seek(std::io::SeekFrom::Start(0))
10175 .unwrap();
10176 let mut req_result = {
10177 let client = &self.hub.client;
10178 dlg.pre_request();
10179 let mut req_builder = hyper::Request::builder()
10180 .method(hyper::Method::PATCH)
10181 .uri(url.as_str())
10182 .header(USER_AGENT, self.hub._user_agent.clone());
10183
10184 if let Some(token) = token.as_ref() {
10185 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10186 }
10187
10188 let request = req_builder
10189 .header(CONTENT_TYPE, json_mime_type.to_string())
10190 .header(CONTENT_LENGTH, request_size as u64)
10191 .body(common::to_body(
10192 request_value_reader.get_ref().clone().into(),
10193 ));
10194
10195 client.request(request.unwrap()).await
10196 };
10197
10198 match req_result {
10199 Err(err) => {
10200 if let common::Retry::After(d) = dlg.http_error(&err) {
10201 sleep(d).await;
10202 continue;
10203 }
10204 dlg.finished(false);
10205 return Err(common::Error::HttpError(err));
10206 }
10207 Ok(res) => {
10208 let (mut parts, body) = res.into_parts();
10209 let mut body = common::Body::new(body);
10210 if !parts.status.is_success() {
10211 let bytes = common::to_bytes(body).await.unwrap_or_default();
10212 let error = serde_json::from_str(&common::to_string(&bytes));
10213 let response = common::to_response(parts, bytes.into());
10214
10215 if let common::Retry::After(d) =
10216 dlg.http_failure(&response, error.as_ref().ok())
10217 {
10218 sleep(d).await;
10219 continue;
10220 }
10221
10222 dlg.finished(false);
10223
10224 return Err(match error {
10225 Ok(value) => common::Error::BadRequest(value),
10226 _ => common::Error::Failure(response),
10227 });
10228 }
10229 let response = {
10230 let bytes = common::to_bytes(body).await.unwrap_or_default();
10231 let encoded = common::to_string(&bytes);
10232 match serde_json::from_str(&encoded) {
10233 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10234 Err(error) => {
10235 dlg.response_json_decode_error(&encoded, &error);
10236 return Err(common::Error::JsonDecodeError(
10237 encoded.to_string(),
10238 error,
10239 ));
10240 }
10241 }
10242 };
10243
10244 dlg.finished(true);
10245 return Ok(response);
10246 }
10247 }
10248 }
10249 }
10250
10251 ///
10252 /// Sets the *request* property to the given value.
10253 ///
10254 /// Even though the property as already been set when instantiating this call,
10255 /// we provide this method for API completeness.
10256 pub fn request(mut self, new_value: Reservation) -> ProjectLocationReservationPatchCall<'a, C> {
10257 self._request = new_value;
10258 self
10259 }
10260 /// Identifier. The resource name of the reservation, e.g., `projects/*/locations/*/reservations/team1-prod`. The reservation_id must only contain lower case alphanumeric characters or dashes. It must start with a letter and must not end with a dash. Its maximum length is 64 characters.
10261 ///
10262 /// Sets the *name* path property to the given value.
10263 ///
10264 /// Even though the property as already been set when instantiating this call,
10265 /// we provide this method for API completeness.
10266 pub fn name(mut self, new_value: &str) -> ProjectLocationReservationPatchCall<'a, C> {
10267 self._name = new_value.to_string();
10268 self
10269 }
10270 /// Standard field mask for the set of fields to be updated.
10271 ///
10272 /// Sets the *update mask* query property to the given value.
10273 pub fn update_mask(
10274 mut self,
10275 new_value: common::FieldMask,
10276 ) -> ProjectLocationReservationPatchCall<'a, C> {
10277 self._update_mask = Some(new_value);
10278 self
10279 }
10280 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10281 /// while executing the actual API request.
10282 ///
10283 /// ````text
10284 /// It should be used to handle progress information, and to implement a certain level of resilience.
10285 /// ````
10286 ///
10287 /// Sets the *delegate* property to the given value.
10288 pub fn delegate(
10289 mut self,
10290 new_value: &'a mut dyn common::Delegate,
10291 ) -> ProjectLocationReservationPatchCall<'a, C> {
10292 self._delegate = Some(new_value);
10293 self
10294 }
10295
10296 /// Set any additional parameter of the query string used in the request.
10297 /// It should be used to set parameters which are not yet available through their own
10298 /// setters.
10299 ///
10300 /// Please note that this method must not be used to set any of the known parameters
10301 /// which have their own setter method. If done anyway, the request will fail.
10302 ///
10303 /// # Additional Parameters
10304 ///
10305 /// * *$.xgafv* (query-string) - V1 error format.
10306 /// * *access_token* (query-string) - OAuth access token.
10307 /// * *alt* (query-string) - Data format for response.
10308 /// * *callback* (query-string) - JSONP
10309 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10310 /// * *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.
10311 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10312 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10313 /// * *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.
10314 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10315 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10316 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationReservationPatchCall<'a, C>
10317 where
10318 T: AsRef<str>,
10319 {
10320 self._additional_params
10321 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10322 self
10323 }
10324
10325 /// Identifies the authorization scope for the method you are building.
10326 ///
10327 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10328 /// [`Scope::CloudPlatform`].
10329 ///
10330 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10331 /// tokens for more than one scope.
10332 ///
10333 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10334 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10335 /// sufficient, a read-write scope will do as well.
10336 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationReservationPatchCall<'a, C>
10337 where
10338 St: AsRef<str>,
10339 {
10340 self._scopes.insert(String::from(scope.as_ref()));
10341 self
10342 }
10343 /// Identifies the authorization scope(s) for the method you are building.
10344 ///
10345 /// See [`Self::add_scope()`] for details.
10346 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationReservationPatchCall<'a, C>
10347 where
10348 I: IntoIterator<Item = St>,
10349 St: AsRef<str>,
10350 {
10351 self._scopes
10352 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10353 self
10354 }
10355
10356 /// Removes all scopes, and no default scope will be used either.
10357 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10358 /// for details).
10359 pub fn clear_scopes(mut self) -> ProjectLocationReservationPatchCall<'a, C> {
10360 self._scopes.clear();
10361 self
10362 }
10363}
10364
10365/// Sets an access control policy for a resource. Replaces any existing policy. Supported resources are: - Reservations To call this method, you must have the following Google IAM permissions: - `bigqueryreservation.reservations.setIamPolicy` to set policies on reservations.
10366///
10367/// A builder for the *locations.reservations.setIamPolicy* method supported by a *project* resource.
10368/// It is not used directly, but through a [`ProjectMethods`] instance.
10369///
10370/// # Example
10371///
10372/// Instantiate a resource method builder
10373///
10374/// ```test_harness,no_run
10375/// # extern crate hyper;
10376/// # extern crate hyper_rustls;
10377/// # extern crate google_bigqueryreservation1 as bigqueryreservation1;
10378/// use bigqueryreservation1::api::SetIamPolicyRequest;
10379/// # async fn dox() {
10380/// # use bigqueryreservation1::{BigQueryReservation, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10381///
10382/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10383/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10384/// # .with_native_roots()
10385/// # .unwrap()
10386/// # .https_only()
10387/// # .enable_http2()
10388/// # .build();
10389///
10390/// # let executor = hyper_util::rt::TokioExecutor::new();
10391/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10392/// # secret,
10393/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10394/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10395/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10396/// # ),
10397/// # ).build().await.unwrap();
10398///
10399/// # let client = hyper_util::client::legacy::Client::builder(
10400/// # hyper_util::rt::TokioExecutor::new()
10401/// # )
10402/// # .build(
10403/// # hyper_rustls::HttpsConnectorBuilder::new()
10404/// # .with_native_roots()
10405/// # .unwrap()
10406/// # .https_or_http()
10407/// # .enable_http2()
10408/// # .build()
10409/// # );
10410/// # let mut hub = BigQueryReservation::new(client, auth);
10411/// // As the method needs a request, you would usually fill it with the desired information
10412/// // into the respective structure. Some of the parts shown here might not be applicable !
10413/// // Values shown here are possibly random and not representative !
10414/// let mut req = SetIamPolicyRequest::default();
10415///
10416/// // You can configure optional parameters by calling the respective setters at will, and
10417/// // execute the final call using `doit()`.
10418/// // Values shown here are possibly random and not representative !
10419/// let result = hub.projects().locations_reservations_set_iam_policy(req, "resource")
10420/// .doit().await;
10421/// # }
10422/// ```
10423pub struct ProjectLocationReservationSetIamPolicyCall<'a, C>
10424where
10425 C: 'a,
10426{
10427 hub: &'a BigQueryReservation<C>,
10428 _request: SetIamPolicyRequest,
10429 _resource: String,
10430 _delegate: Option<&'a mut dyn common::Delegate>,
10431 _additional_params: HashMap<String, String>,
10432 _scopes: BTreeSet<String>,
10433}
10434
10435impl<'a, C> common::CallBuilder for ProjectLocationReservationSetIamPolicyCall<'a, C> {}
10436
10437impl<'a, C> ProjectLocationReservationSetIamPolicyCall<'a, C>
10438where
10439 C: common::Connector,
10440{
10441 /// Perform the operation you have build so far.
10442 pub async fn doit(mut self) -> common::Result<(common::Response, Policy)> {
10443 use std::borrow::Cow;
10444 use std::io::{Read, Seek};
10445
10446 use common::{url::Params, ToParts};
10447 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10448
10449 let mut dd = common::DefaultDelegate;
10450 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10451 dlg.begin(common::MethodInfo {
10452 id: "bigqueryreservation.projects.locations.reservations.setIamPolicy",
10453 http_method: hyper::Method::POST,
10454 });
10455
10456 for &field in ["alt", "resource"].iter() {
10457 if self._additional_params.contains_key(field) {
10458 dlg.finished(false);
10459 return Err(common::Error::FieldClash(field));
10460 }
10461 }
10462
10463 let mut params = Params::with_capacity(4 + self._additional_params.len());
10464 params.push("resource", self._resource);
10465
10466 params.extend(self._additional_params.iter());
10467
10468 params.push("alt", "json");
10469 let mut url = self.hub._base_url.clone() + "v1/{+resource}:setIamPolicy";
10470 if self._scopes.is_empty() {
10471 self._scopes
10472 .insert(Scope::CloudPlatform.as_ref().to_string());
10473 }
10474
10475 #[allow(clippy::single_element_loop)]
10476 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
10477 url = params.uri_replacement(url, param_name, find_this, true);
10478 }
10479 {
10480 let to_remove = ["resource"];
10481 params.remove_params(&to_remove);
10482 }
10483
10484 let url = params.parse_with_url(&url);
10485
10486 let mut json_mime_type = mime::APPLICATION_JSON;
10487 let mut request_value_reader = {
10488 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10489 common::remove_json_null_values(&mut value);
10490 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10491 serde_json::to_writer(&mut dst, &value).unwrap();
10492 dst
10493 };
10494 let request_size = request_value_reader
10495 .seek(std::io::SeekFrom::End(0))
10496 .unwrap();
10497 request_value_reader
10498 .seek(std::io::SeekFrom::Start(0))
10499 .unwrap();
10500
10501 loop {
10502 let token = match self
10503 .hub
10504 .auth
10505 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10506 .await
10507 {
10508 Ok(token) => token,
10509 Err(e) => match dlg.token(e) {
10510 Ok(token) => token,
10511 Err(e) => {
10512 dlg.finished(false);
10513 return Err(common::Error::MissingToken(e));
10514 }
10515 },
10516 };
10517 request_value_reader
10518 .seek(std::io::SeekFrom::Start(0))
10519 .unwrap();
10520 let mut req_result = {
10521 let client = &self.hub.client;
10522 dlg.pre_request();
10523 let mut req_builder = hyper::Request::builder()
10524 .method(hyper::Method::POST)
10525 .uri(url.as_str())
10526 .header(USER_AGENT, self.hub._user_agent.clone());
10527
10528 if let Some(token) = token.as_ref() {
10529 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10530 }
10531
10532 let request = req_builder
10533 .header(CONTENT_TYPE, json_mime_type.to_string())
10534 .header(CONTENT_LENGTH, request_size as u64)
10535 .body(common::to_body(
10536 request_value_reader.get_ref().clone().into(),
10537 ));
10538
10539 client.request(request.unwrap()).await
10540 };
10541
10542 match req_result {
10543 Err(err) => {
10544 if let common::Retry::After(d) = dlg.http_error(&err) {
10545 sleep(d).await;
10546 continue;
10547 }
10548 dlg.finished(false);
10549 return Err(common::Error::HttpError(err));
10550 }
10551 Ok(res) => {
10552 let (mut parts, body) = res.into_parts();
10553 let mut body = common::Body::new(body);
10554 if !parts.status.is_success() {
10555 let bytes = common::to_bytes(body).await.unwrap_or_default();
10556 let error = serde_json::from_str(&common::to_string(&bytes));
10557 let response = common::to_response(parts, bytes.into());
10558
10559 if let common::Retry::After(d) =
10560 dlg.http_failure(&response, error.as_ref().ok())
10561 {
10562 sleep(d).await;
10563 continue;
10564 }
10565
10566 dlg.finished(false);
10567
10568 return Err(match error {
10569 Ok(value) => common::Error::BadRequest(value),
10570 _ => common::Error::Failure(response),
10571 });
10572 }
10573 let response = {
10574 let bytes = common::to_bytes(body).await.unwrap_or_default();
10575 let encoded = common::to_string(&bytes);
10576 match serde_json::from_str(&encoded) {
10577 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10578 Err(error) => {
10579 dlg.response_json_decode_error(&encoded, &error);
10580 return Err(common::Error::JsonDecodeError(
10581 encoded.to_string(),
10582 error,
10583 ));
10584 }
10585 }
10586 };
10587
10588 dlg.finished(true);
10589 return Ok(response);
10590 }
10591 }
10592 }
10593 }
10594
10595 ///
10596 /// Sets the *request* property to the given value.
10597 ///
10598 /// Even though the property as already been set when instantiating this call,
10599 /// we provide this method for API completeness.
10600 pub fn request(
10601 mut self,
10602 new_value: SetIamPolicyRequest,
10603 ) -> ProjectLocationReservationSetIamPolicyCall<'a, C> {
10604 self._request = new_value;
10605 self
10606 }
10607 /// 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.
10608 ///
10609 /// Sets the *resource* path property to the given value.
10610 ///
10611 /// Even though the property as already been set when instantiating this call,
10612 /// we provide this method for API completeness.
10613 pub fn resource(
10614 mut self,
10615 new_value: &str,
10616 ) -> ProjectLocationReservationSetIamPolicyCall<'a, C> {
10617 self._resource = new_value.to_string();
10618 self
10619 }
10620 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10621 /// while executing the actual API request.
10622 ///
10623 /// ````text
10624 /// It should be used to handle progress information, and to implement a certain level of resilience.
10625 /// ````
10626 ///
10627 /// Sets the *delegate* property to the given value.
10628 pub fn delegate(
10629 mut self,
10630 new_value: &'a mut dyn common::Delegate,
10631 ) -> ProjectLocationReservationSetIamPolicyCall<'a, C> {
10632 self._delegate = Some(new_value);
10633 self
10634 }
10635
10636 /// Set any additional parameter of the query string used in the request.
10637 /// It should be used to set parameters which are not yet available through their own
10638 /// setters.
10639 ///
10640 /// Please note that this method must not be used to set any of the known parameters
10641 /// which have their own setter method. If done anyway, the request will fail.
10642 ///
10643 /// # Additional Parameters
10644 ///
10645 /// * *$.xgafv* (query-string) - V1 error format.
10646 /// * *access_token* (query-string) - OAuth access token.
10647 /// * *alt* (query-string) - Data format for response.
10648 /// * *callback* (query-string) - JSONP
10649 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10650 /// * *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.
10651 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10652 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
10653 /// * *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.
10654 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
10655 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
10656 pub fn param<T>(
10657 mut self,
10658 name: T,
10659 value: T,
10660 ) -> ProjectLocationReservationSetIamPolicyCall<'a, C>
10661 where
10662 T: AsRef<str>,
10663 {
10664 self._additional_params
10665 .insert(name.as_ref().to_string(), value.as_ref().to_string());
10666 self
10667 }
10668
10669 /// Identifies the authorization scope for the method you are building.
10670 ///
10671 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
10672 /// [`Scope::CloudPlatform`].
10673 ///
10674 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
10675 /// tokens for more than one scope.
10676 ///
10677 /// Usually there is more than one suitable scope to authorize an operation, some of which may
10678 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
10679 /// sufficient, a read-write scope will do as well.
10680 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationReservationSetIamPolicyCall<'a, C>
10681 where
10682 St: AsRef<str>,
10683 {
10684 self._scopes.insert(String::from(scope.as_ref()));
10685 self
10686 }
10687 /// Identifies the authorization scope(s) for the method you are building.
10688 ///
10689 /// See [`Self::add_scope()`] for details.
10690 pub fn add_scopes<I, St>(
10691 mut self,
10692 scopes: I,
10693 ) -> ProjectLocationReservationSetIamPolicyCall<'a, C>
10694 where
10695 I: IntoIterator<Item = St>,
10696 St: AsRef<str>,
10697 {
10698 self._scopes
10699 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
10700 self
10701 }
10702
10703 /// Removes all scopes, and no default scope will be used either.
10704 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
10705 /// for details).
10706 pub fn clear_scopes(mut self) -> ProjectLocationReservationSetIamPolicyCall<'a, C> {
10707 self._scopes.clear();
10708 self
10709 }
10710}
10711
10712/// Gets your permissions on a resource. Returns an empty set of permissions if the resource doesn't exist. Supported resources are: - Reservations No Google IAM permissions are required to call this method.
10713///
10714/// A builder for the *locations.reservations.testIamPermissions* method supported by a *project* resource.
10715/// It is not used directly, but through a [`ProjectMethods`] instance.
10716///
10717/// # Example
10718///
10719/// Instantiate a resource method builder
10720///
10721/// ```test_harness,no_run
10722/// # extern crate hyper;
10723/// # extern crate hyper_rustls;
10724/// # extern crate google_bigqueryreservation1 as bigqueryreservation1;
10725/// use bigqueryreservation1::api::TestIamPermissionsRequest;
10726/// # async fn dox() {
10727/// # use bigqueryreservation1::{BigQueryReservation, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
10728///
10729/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
10730/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
10731/// # .with_native_roots()
10732/// # .unwrap()
10733/// # .https_only()
10734/// # .enable_http2()
10735/// # .build();
10736///
10737/// # let executor = hyper_util::rt::TokioExecutor::new();
10738/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
10739/// # secret,
10740/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
10741/// # yup_oauth2::client::CustomHyperClientBuilder::from(
10742/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
10743/// # ),
10744/// # ).build().await.unwrap();
10745///
10746/// # let client = hyper_util::client::legacy::Client::builder(
10747/// # hyper_util::rt::TokioExecutor::new()
10748/// # )
10749/// # .build(
10750/// # hyper_rustls::HttpsConnectorBuilder::new()
10751/// # .with_native_roots()
10752/// # .unwrap()
10753/// # .https_or_http()
10754/// # .enable_http2()
10755/// # .build()
10756/// # );
10757/// # let mut hub = BigQueryReservation::new(client, auth);
10758/// // As the method needs a request, you would usually fill it with the desired information
10759/// // into the respective structure. Some of the parts shown here might not be applicable !
10760/// // Values shown here are possibly random and not representative !
10761/// let mut req = TestIamPermissionsRequest::default();
10762///
10763/// // You can configure optional parameters by calling the respective setters at will, and
10764/// // execute the final call using `doit()`.
10765/// // Values shown here are possibly random and not representative !
10766/// let result = hub.projects().locations_reservations_test_iam_permissions(req, "resource")
10767/// .doit().await;
10768/// # }
10769/// ```
10770pub struct ProjectLocationReservationTestIamPermissionCall<'a, C>
10771where
10772 C: 'a,
10773{
10774 hub: &'a BigQueryReservation<C>,
10775 _request: TestIamPermissionsRequest,
10776 _resource: String,
10777 _delegate: Option<&'a mut dyn common::Delegate>,
10778 _additional_params: HashMap<String, String>,
10779 _scopes: BTreeSet<String>,
10780}
10781
10782impl<'a, C> common::CallBuilder for ProjectLocationReservationTestIamPermissionCall<'a, C> {}
10783
10784impl<'a, C> ProjectLocationReservationTestIamPermissionCall<'a, C>
10785where
10786 C: common::Connector,
10787{
10788 /// Perform the operation you have build so far.
10789 pub async fn doit(mut self) -> common::Result<(common::Response, TestIamPermissionsResponse)> {
10790 use std::borrow::Cow;
10791 use std::io::{Read, Seek};
10792
10793 use common::{url::Params, ToParts};
10794 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
10795
10796 let mut dd = common::DefaultDelegate;
10797 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
10798 dlg.begin(common::MethodInfo {
10799 id: "bigqueryreservation.projects.locations.reservations.testIamPermissions",
10800 http_method: hyper::Method::POST,
10801 });
10802
10803 for &field in ["alt", "resource"].iter() {
10804 if self._additional_params.contains_key(field) {
10805 dlg.finished(false);
10806 return Err(common::Error::FieldClash(field));
10807 }
10808 }
10809
10810 let mut params = Params::with_capacity(4 + self._additional_params.len());
10811 params.push("resource", self._resource);
10812
10813 params.extend(self._additional_params.iter());
10814
10815 params.push("alt", "json");
10816 let mut url = self.hub._base_url.clone() + "v1/{+resource}:testIamPermissions";
10817 if self._scopes.is_empty() {
10818 self._scopes
10819 .insert(Scope::CloudPlatform.as_ref().to_string());
10820 }
10821
10822 #[allow(clippy::single_element_loop)]
10823 for &(find_this, param_name) in [("{+resource}", "resource")].iter() {
10824 url = params.uri_replacement(url, param_name, find_this, true);
10825 }
10826 {
10827 let to_remove = ["resource"];
10828 params.remove_params(&to_remove);
10829 }
10830
10831 let url = params.parse_with_url(&url);
10832
10833 let mut json_mime_type = mime::APPLICATION_JSON;
10834 let mut request_value_reader = {
10835 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
10836 common::remove_json_null_values(&mut value);
10837 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
10838 serde_json::to_writer(&mut dst, &value).unwrap();
10839 dst
10840 };
10841 let request_size = request_value_reader
10842 .seek(std::io::SeekFrom::End(0))
10843 .unwrap();
10844 request_value_reader
10845 .seek(std::io::SeekFrom::Start(0))
10846 .unwrap();
10847
10848 loop {
10849 let token = match self
10850 .hub
10851 .auth
10852 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
10853 .await
10854 {
10855 Ok(token) => token,
10856 Err(e) => match dlg.token(e) {
10857 Ok(token) => token,
10858 Err(e) => {
10859 dlg.finished(false);
10860 return Err(common::Error::MissingToken(e));
10861 }
10862 },
10863 };
10864 request_value_reader
10865 .seek(std::io::SeekFrom::Start(0))
10866 .unwrap();
10867 let mut req_result = {
10868 let client = &self.hub.client;
10869 dlg.pre_request();
10870 let mut req_builder = hyper::Request::builder()
10871 .method(hyper::Method::POST)
10872 .uri(url.as_str())
10873 .header(USER_AGENT, self.hub._user_agent.clone());
10874
10875 if let Some(token) = token.as_ref() {
10876 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
10877 }
10878
10879 let request = req_builder
10880 .header(CONTENT_TYPE, json_mime_type.to_string())
10881 .header(CONTENT_LENGTH, request_size as u64)
10882 .body(common::to_body(
10883 request_value_reader.get_ref().clone().into(),
10884 ));
10885
10886 client.request(request.unwrap()).await
10887 };
10888
10889 match req_result {
10890 Err(err) => {
10891 if let common::Retry::After(d) = dlg.http_error(&err) {
10892 sleep(d).await;
10893 continue;
10894 }
10895 dlg.finished(false);
10896 return Err(common::Error::HttpError(err));
10897 }
10898 Ok(res) => {
10899 let (mut parts, body) = res.into_parts();
10900 let mut body = common::Body::new(body);
10901 if !parts.status.is_success() {
10902 let bytes = common::to_bytes(body).await.unwrap_or_default();
10903 let error = serde_json::from_str(&common::to_string(&bytes));
10904 let response = common::to_response(parts, bytes.into());
10905
10906 if let common::Retry::After(d) =
10907 dlg.http_failure(&response, error.as_ref().ok())
10908 {
10909 sleep(d).await;
10910 continue;
10911 }
10912
10913 dlg.finished(false);
10914
10915 return Err(match error {
10916 Ok(value) => common::Error::BadRequest(value),
10917 _ => common::Error::Failure(response),
10918 });
10919 }
10920 let response = {
10921 let bytes = common::to_bytes(body).await.unwrap_or_default();
10922 let encoded = common::to_string(&bytes);
10923 match serde_json::from_str(&encoded) {
10924 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
10925 Err(error) => {
10926 dlg.response_json_decode_error(&encoded, &error);
10927 return Err(common::Error::JsonDecodeError(
10928 encoded.to_string(),
10929 error,
10930 ));
10931 }
10932 }
10933 };
10934
10935 dlg.finished(true);
10936 return Ok(response);
10937 }
10938 }
10939 }
10940 }
10941
10942 ///
10943 /// Sets the *request* property to the given value.
10944 ///
10945 /// Even though the property as already been set when instantiating this call,
10946 /// we provide this method for API completeness.
10947 pub fn request(
10948 mut self,
10949 new_value: TestIamPermissionsRequest,
10950 ) -> ProjectLocationReservationTestIamPermissionCall<'a, C> {
10951 self._request = new_value;
10952 self
10953 }
10954 /// 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.
10955 ///
10956 /// Sets the *resource* path property to the given value.
10957 ///
10958 /// Even though the property as already been set when instantiating this call,
10959 /// we provide this method for API completeness.
10960 pub fn resource(
10961 mut self,
10962 new_value: &str,
10963 ) -> ProjectLocationReservationTestIamPermissionCall<'a, C> {
10964 self._resource = new_value.to_string();
10965 self
10966 }
10967 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
10968 /// while executing the actual API request.
10969 ///
10970 /// ````text
10971 /// It should be used to handle progress information, and to implement a certain level of resilience.
10972 /// ````
10973 ///
10974 /// Sets the *delegate* property to the given value.
10975 pub fn delegate(
10976 mut self,
10977 new_value: &'a mut dyn common::Delegate,
10978 ) -> ProjectLocationReservationTestIamPermissionCall<'a, C> {
10979 self._delegate = Some(new_value);
10980 self
10981 }
10982
10983 /// Set any additional parameter of the query string used in the request.
10984 /// It should be used to set parameters which are not yet available through their own
10985 /// setters.
10986 ///
10987 /// Please note that this method must not be used to set any of the known parameters
10988 /// which have their own setter method. If done anyway, the request will fail.
10989 ///
10990 /// # Additional Parameters
10991 ///
10992 /// * *$.xgafv* (query-string) - V1 error format.
10993 /// * *access_token* (query-string) - OAuth access token.
10994 /// * *alt* (query-string) - Data format for response.
10995 /// * *callback* (query-string) - JSONP
10996 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
10997 /// * *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.
10998 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
10999 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11000 /// * *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.
11001 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11002 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11003 pub fn param<T>(
11004 mut self,
11005 name: T,
11006 value: T,
11007 ) -> ProjectLocationReservationTestIamPermissionCall<'a, C>
11008 where
11009 T: AsRef<str>,
11010 {
11011 self._additional_params
11012 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11013 self
11014 }
11015
11016 /// Identifies the authorization scope for the method you are building.
11017 ///
11018 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11019 /// [`Scope::CloudPlatform`].
11020 ///
11021 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11022 /// tokens for more than one scope.
11023 ///
11024 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11025 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11026 /// sufficient, a read-write scope will do as well.
11027 pub fn add_scope<St>(
11028 mut self,
11029 scope: St,
11030 ) -> ProjectLocationReservationTestIamPermissionCall<'a, C>
11031 where
11032 St: AsRef<str>,
11033 {
11034 self._scopes.insert(String::from(scope.as_ref()));
11035 self
11036 }
11037 /// Identifies the authorization scope(s) for the method you are building.
11038 ///
11039 /// See [`Self::add_scope()`] for details.
11040 pub fn add_scopes<I, St>(
11041 mut self,
11042 scopes: I,
11043 ) -> ProjectLocationReservationTestIamPermissionCall<'a, C>
11044 where
11045 I: IntoIterator<Item = St>,
11046 St: AsRef<str>,
11047 {
11048 self._scopes
11049 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11050 self
11051 }
11052
11053 /// Removes all scopes, and no default scope will be used either.
11054 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11055 /// for details).
11056 pub fn clear_scopes(mut self) -> ProjectLocationReservationTestIamPermissionCall<'a, C> {
11057 self._scopes.clear();
11058 self
11059 }
11060}
11061
11062/// Retrieves a BI reservation.
11063///
11064/// A builder for the *locations.getBiReservation* method supported by a *project* resource.
11065/// It is not used directly, but through a [`ProjectMethods`] instance.
11066///
11067/// # Example
11068///
11069/// Instantiate a resource method builder
11070///
11071/// ```test_harness,no_run
11072/// # extern crate hyper;
11073/// # extern crate hyper_rustls;
11074/// # extern crate google_bigqueryreservation1 as bigqueryreservation1;
11075/// # async fn dox() {
11076/// # use bigqueryreservation1::{BigQueryReservation, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11077///
11078/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11079/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11080/// # .with_native_roots()
11081/// # .unwrap()
11082/// # .https_only()
11083/// # .enable_http2()
11084/// # .build();
11085///
11086/// # let executor = hyper_util::rt::TokioExecutor::new();
11087/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11088/// # secret,
11089/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11090/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11091/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11092/// # ),
11093/// # ).build().await.unwrap();
11094///
11095/// # let client = hyper_util::client::legacy::Client::builder(
11096/// # hyper_util::rt::TokioExecutor::new()
11097/// # )
11098/// # .build(
11099/// # hyper_rustls::HttpsConnectorBuilder::new()
11100/// # .with_native_roots()
11101/// # .unwrap()
11102/// # .https_or_http()
11103/// # .enable_http2()
11104/// # .build()
11105/// # );
11106/// # let mut hub = BigQueryReservation::new(client, auth);
11107/// // You can configure optional parameters by calling the respective setters at will, and
11108/// // execute the final call using `doit()`.
11109/// // Values shown here are possibly random and not representative !
11110/// let result = hub.projects().locations_get_bi_reservation("name")
11111/// .doit().await;
11112/// # }
11113/// ```
11114pub struct ProjectLocationGetBiReservationCall<'a, C>
11115where
11116 C: 'a,
11117{
11118 hub: &'a BigQueryReservation<C>,
11119 _name: String,
11120 _delegate: Option<&'a mut dyn common::Delegate>,
11121 _additional_params: HashMap<String, String>,
11122 _scopes: BTreeSet<String>,
11123}
11124
11125impl<'a, C> common::CallBuilder for ProjectLocationGetBiReservationCall<'a, C> {}
11126
11127impl<'a, C> ProjectLocationGetBiReservationCall<'a, C>
11128where
11129 C: common::Connector,
11130{
11131 /// Perform the operation you have build so far.
11132 pub async fn doit(mut self) -> common::Result<(common::Response, BiReservation)> {
11133 use std::borrow::Cow;
11134 use std::io::{Read, Seek};
11135
11136 use common::{url::Params, ToParts};
11137 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11138
11139 let mut dd = common::DefaultDelegate;
11140 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11141 dlg.begin(common::MethodInfo {
11142 id: "bigqueryreservation.projects.locations.getBiReservation",
11143 http_method: hyper::Method::GET,
11144 });
11145
11146 for &field in ["alt", "name"].iter() {
11147 if self._additional_params.contains_key(field) {
11148 dlg.finished(false);
11149 return Err(common::Error::FieldClash(field));
11150 }
11151 }
11152
11153 let mut params = Params::with_capacity(3 + self._additional_params.len());
11154 params.push("name", self._name);
11155
11156 params.extend(self._additional_params.iter());
11157
11158 params.push("alt", "json");
11159 let mut url = self.hub._base_url.clone() + "v1/{+name}";
11160 if self._scopes.is_empty() {
11161 self._scopes
11162 .insert(Scope::CloudPlatform.as_ref().to_string());
11163 }
11164
11165 #[allow(clippy::single_element_loop)]
11166 for &(find_this, param_name) in [("{+name}", "name")].iter() {
11167 url = params.uri_replacement(url, param_name, find_this, true);
11168 }
11169 {
11170 let to_remove = ["name"];
11171 params.remove_params(&to_remove);
11172 }
11173
11174 let url = params.parse_with_url(&url);
11175
11176 loop {
11177 let token = match self
11178 .hub
11179 .auth
11180 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11181 .await
11182 {
11183 Ok(token) => token,
11184 Err(e) => match dlg.token(e) {
11185 Ok(token) => token,
11186 Err(e) => {
11187 dlg.finished(false);
11188 return Err(common::Error::MissingToken(e));
11189 }
11190 },
11191 };
11192 let mut req_result = {
11193 let client = &self.hub.client;
11194 dlg.pre_request();
11195 let mut req_builder = hyper::Request::builder()
11196 .method(hyper::Method::GET)
11197 .uri(url.as_str())
11198 .header(USER_AGENT, self.hub._user_agent.clone());
11199
11200 if let Some(token) = token.as_ref() {
11201 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11202 }
11203
11204 let request = req_builder
11205 .header(CONTENT_LENGTH, 0_u64)
11206 .body(common::to_body::<String>(None));
11207
11208 client.request(request.unwrap()).await
11209 };
11210
11211 match req_result {
11212 Err(err) => {
11213 if let common::Retry::After(d) = dlg.http_error(&err) {
11214 sleep(d).await;
11215 continue;
11216 }
11217 dlg.finished(false);
11218 return Err(common::Error::HttpError(err));
11219 }
11220 Ok(res) => {
11221 let (mut parts, body) = res.into_parts();
11222 let mut body = common::Body::new(body);
11223 if !parts.status.is_success() {
11224 let bytes = common::to_bytes(body).await.unwrap_or_default();
11225 let error = serde_json::from_str(&common::to_string(&bytes));
11226 let response = common::to_response(parts, bytes.into());
11227
11228 if let common::Retry::After(d) =
11229 dlg.http_failure(&response, error.as_ref().ok())
11230 {
11231 sleep(d).await;
11232 continue;
11233 }
11234
11235 dlg.finished(false);
11236
11237 return Err(match error {
11238 Ok(value) => common::Error::BadRequest(value),
11239 _ => common::Error::Failure(response),
11240 });
11241 }
11242 let response = {
11243 let bytes = common::to_bytes(body).await.unwrap_or_default();
11244 let encoded = common::to_string(&bytes);
11245 match serde_json::from_str(&encoded) {
11246 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11247 Err(error) => {
11248 dlg.response_json_decode_error(&encoded, &error);
11249 return Err(common::Error::JsonDecodeError(
11250 encoded.to_string(),
11251 error,
11252 ));
11253 }
11254 }
11255 };
11256
11257 dlg.finished(true);
11258 return Ok(response);
11259 }
11260 }
11261 }
11262 }
11263
11264 /// Required. Name of the requested reservation, for example: `projects/{project_id}/locations/{location_id}/biReservation`
11265 ///
11266 /// Sets the *name* path property to the given value.
11267 ///
11268 /// Even though the property as already been set when instantiating this call,
11269 /// we provide this method for API completeness.
11270 pub fn name(mut self, new_value: &str) -> ProjectLocationGetBiReservationCall<'a, C> {
11271 self._name = new_value.to_string();
11272 self
11273 }
11274 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11275 /// while executing the actual API request.
11276 ///
11277 /// ````text
11278 /// It should be used to handle progress information, and to implement a certain level of resilience.
11279 /// ````
11280 ///
11281 /// Sets the *delegate* property to the given value.
11282 pub fn delegate(
11283 mut self,
11284 new_value: &'a mut dyn common::Delegate,
11285 ) -> ProjectLocationGetBiReservationCall<'a, C> {
11286 self._delegate = Some(new_value);
11287 self
11288 }
11289
11290 /// Set any additional parameter of the query string used in the request.
11291 /// It should be used to set parameters which are not yet available through their own
11292 /// setters.
11293 ///
11294 /// Please note that this method must not be used to set any of the known parameters
11295 /// which have their own setter method. If done anyway, the request will fail.
11296 ///
11297 /// # Additional Parameters
11298 ///
11299 /// * *$.xgafv* (query-string) - V1 error format.
11300 /// * *access_token* (query-string) - OAuth access token.
11301 /// * *alt* (query-string) - Data format for response.
11302 /// * *callback* (query-string) - JSONP
11303 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11304 /// * *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.
11305 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11306 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11307 /// * *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.
11308 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11309 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11310 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationGetBiReservationCall<'a, C>
11311 where
11312 T: AsRef<str>,
11313 {
11314 self._additional_params
11315 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11316 self
11317 }
11318
11319 /// Identifies the authorization scope for the method you are building.
11320 ///
11321 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11322 /// [`Scope::CloudPlatform`].
11323 ///
11324 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11325 /// tokens for more than one scope.
11326 ///
11327 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11328 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11329 /// sufficient, a read-write scope will do as well.
11330 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationGetBiReservationCall<'a, C>
11331 where
11332 St: AsRef<str>,
11333 {
11334 self._scopes.insert(String::from(scope.as_ref()));
11335 self
11336 }
11337 /// Identifies the authorization scope(s) for the method you are building.
11338 ///
11339 /// See [`Self::add_scope()`] for details.
11340 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationGetBiReservationCall<'a, C>
11341 where
11342 I: IntoIterator<Item = St>,
11343 St: AsRef<str>,
11344 {
11345 self._scopes
11346 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11347 self
11348 }
11349
11350 /// Removes all scopes, and no default scope will be used either.
11351 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11352 /// for details).
11353 pub fn clear_scopes(mut self) -> ProjectLocationGetBiReservationCall<'a, C> {
11354 self._scopes.clear();
11355 self
11356 }
11357}
11358
11359/// Looks up assignments for a specified resource for a particular region. If the request is about a project: 1. Assignments created on the project will be returned if they exist. 2. Otherwise assignments created on the closest ancestor will be returned. 3. Assignments for different JobTypes will all be returned. The same logic applies if the request is about a folder. If the request is about an organization, then assignments created on the organization will be returned (organization doesn't have ancestors). Comparing to ListAssignments, there are some behavior differences: 1. permission on the assignee will be verified in this API. 2. Hierarchy lookup (project->folder->organization) happens in this API. 3. Parent here is `projects/*/locations/*`, instead of `projects/*/locations/*reservations/*`.
11360///
11361/// A builder for the *locations.searchAllAssignments* method supported by a *project* resource.
11362/// It is not used directly, but through a [`ProjectMethods`] instance.
11363///
11364/// # Example
11365///
11366/// Instantiate a resource method builder
11367///
11368/// ```test_harness,no_run
11369/// # extern crate hyper;
11370/// # extern crate hyper_rustls;
11371/// # extern crate google_bigqueryreservation1 as bigqueryreservation1;
11372/// # async fn dox() {
11373/// # use bigqueryreservation1::{BigQueryReservation, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11374///
11375/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11376/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11377/// # .with_native_roots()
11378/// # .unwrap()
11379/// # .https_only()
11380/// # .enable_http2()
11381/// # .build();
11382///
11383/// # let executor = hyper_util::rt::TokioExecutor::new();
11384/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11385/// # secret,
11386/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11387/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11388/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11389/// # ),
11390/// # ).build().await.unwrap();
11391///
11392/// # let client = hyper_util::client::legacy::Client::builder(
11393/// # hyper_util::rt::TokioExecutor::new()
11394/// # )
11395/// # .build(
11396/// # hyper_rustls::HttpsConnectorBuilder::new()
11397/// # .with_native_roots()
11398/// # .unwrap()
11399/// # .https_or_http()
11400/// # .enable_http2()
11401/// # .build()
11402/// # );
11403/// # let mut hub = BigQueryReservation::new(client, auth);
11404/// // You can configure optional parameters by calling the respective setters at will, and
11405/// // execute the final call using `doit()`.
11406/// // Values shown here are possibly random and not representative !
11407/// let result = hub.projects().locations_search_all_assignments("parent")
11408/// .query("dolore")
11409/// .page_token("et")
11410/// .page_size(-28)
11411/// .doit().await;
11412/// # }
11413/// ```
11414pub struct ProjectLocationSearchAllAssignmentCall<'a, C>
11415where
11416 C: 'a,
11417{
11418 hub: &'a BigQueryReservation<C>,
11419 _parent: String,
11420 _query: Option<String>,
11421 _page_token: Option<String>,
11422 _page_size: Option<i32>,
11423 _delegate: Option<&'a mut dyn common::Delegate>,
11424 _additional_params: HashMap<String, String>,
11425 _scopes: BTreeSet<String>,
11426}
11427
11428impl<'a, C> common::CallBuilder for ProjectLocationSearchAllAssignmentCall<'a, C> {}
11429
11430impl<'a, C> ProjectLocationSearchAllAssignmentCall<'a, C>
11431where
11432 C: common::Connector,
11433{
11434 /// Perform the operation you have build so far.
11435 pub async fn doit(
11436 mut self,
11437 ) -> common::Result<(common::Response, SearchAllAssignmentsResponse)> {
11438 use std::borrow::Cow;
11439 use std::io::{Read, Seek};
11440
11441 use common::{url::Params, ToParts};
11442 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11443
11444 let mut dd = common::DefaultDelegate;
11445 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11446 dlg.begin(common::MethodInfo {
11447 id: "bigqueryreservation.projects.locations.searchAllAssignments",
11448 http_method: hyper::Method::GET,
11449 });
11450
11451 for &field in ["alt", "parent", "query", "pageToken", "pageSize"].iter() {
11452 if self._additional_params.contains_key(field) {
11453 dlg.finished(false);
11454 return Err(common::Error::FieldClash(field));
11455 }
11456 }
11457
11458 let mut params = Params::with_capacity(6 + self._additional_params.len());
11459 params.push("parent", self._parent);
11460 if let Some(value) = self._query.as_ref() {
11461 params.push("query", value);
11462 }
11463 if let Some(value) = self._page_token.as_ref() {
11464 params.push("pageToken", value);
11465 }
11466 if let Some(value) = self._page_size.as_ref() {
11467 params.push("pageSize", value.to_string());
11468 }
11469
11470 params.extend(self._additional_params.iter());
11471
11472 params.push("alt", "json");
11473 let mut url = self.hub._base_url.clone() + "v1/{+parent}:searchAllAssignments";
11474 if self._scopes.is_empty() {
11475 self._scopes
11476 .insert(Scope::CloudPlatform.as_ref().to_string());
11477 }
11478
11479 #[allow(clippy::single_element_loop)]
11480 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
11481 url = params.uri_replacement(url, param_name, find_this, true);
11482 }
11483 {
11484 let to_remove = ["parent"];
11485 params.remove_params(&to_remove);
11486 }
11487
11488 let url = params.parse_with_url(&url);
11489
11490 loop {
11491 let token = match self
11492 .hub
11493 .auth
11494 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11495 .await
11496 {
11497 Ok(token) => token,
11498 Err(e) => match dlg.token(e) {
11499 Ok(token) => token,
11500 Err(e) => {
11501 dlg.finished(false);
11502 return Err(common::Error::MissingToken(e));
11503 }
11504 },
11505 };
11506 let mut req_result = {
11507 let client = &self.hub.client;
11508 dlg.pre_request();
11509 let mut req_builder = hyper::Request::builder()
11510 .method(hyper::Method::GET)
11511 .uri(url.as_str())
11512 .header(USER_AGENT, self.hub._user_agent.clone());
11513
11514 if let Some(token) = token.as_ref() {
11515 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11516 }
11517
11518 let request = req_builder
11519 .header(CONTENT_LENGTH, 0_u64)
11520 .body(common::to_body::<String>(None));
11521
11522 client.request(request.unwrap()).await
11523 };
11524
11525 match req_result {
11526 Err(err) => {
11527 if let common::Retry::After(d) = dlg.http_error(&err) {
11528 sleep(d).await;
11529 continue;
11530 }
11531 dlg.finished(false);
11532 return Err(common::Error::HttpError(err));
11533 }
11534 Ok(res) => {
11535 let (mut parts, body) = res.into_parts();
11536 let mut body = common::Body::new(body);
11537 if !parts.status.is_success() {
11538 let bytes = common::to_bytes(body).await.unwrap_or_default();
11539 let error = serde_json::from_str(&common::to_string(&bytes));
11540 let response = common::to_response(parts, bytes.into());
11541
11542 if let common::Retry::After(d) =
11543 dlg.http_failure(&response, error.as_ref().ok())
11544 {
11545 sleep(d).await;
11546 continue;
11547 }
11548
11549 dlg.finished(false);
11550
11551 return Err(match error {
11552 Ok(value) => common::Error::BadRequest(value),
11553 _ => common::Error::Failure(response),
11554 });
11555 }
11556 let response = {
11557 let bytes = common::to_bytes(body).await.unwrap_or_default();
11558 let encoded = common::to_string(&bytes);
11559 match serde_json::from_str(&encoded) {
11560 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11561 Err(error) => {
11562 dlg.response_json_decode_error(&encoded, &error);
11563 return Err(common::Error::JsonDecodeError(
11564 encoded.to_string(),
11565 error,
11566 ));
11567 }
11568 }
11569 };
11570
11571 dlg.finished(true);
11572 return Ok(response);
11573 }
11574 }
11575 }
11576 }
11577
11578 /// Required. The resource name with location (project name could be the wildcard '-'), e.g.: `projects/-/locations/US`.
11579 ///
11580 /// Sets the *parent* path property to the given value.
11581 ///
11582 /// Even though the property as already been set when instantiating this call,
11583 /// we provide this method for API completeness.
11584 pub fn parent(mut self, new_value: &str) -> ProjectLocationSearchAllAssignmentCall<'a, C> {
11585 self._parent = new_value.to_string();
11586 self
11587 }
11588 /// Please specify resource name as assignee in the query. Examples: * `assignee=projects/myproject` * `assignee=folders/123` * `assignee=organizations/456`
11589 ///
11590 /// Sets the *query* query property to the given value.
11591 pub fn query(mut self, new_value: &str) -> ProjectLocationSearchAllAssignmentCall<'a, C> {
11592 self._query = Some(new_value.to_string());
11593 self
11594 }
11595 /// The next_page_token value returned from a previous List request, if any.
11596 ///
11597 /// Sets the *page token* query property to the given value.
11598 pub fn page_token(mut self, new_value: &str) -> ProjectLocationSearchAllAssignmentCall<'a, C> {
11599 self._page_token = Some(new_value.to_string());
11600 self
11601 }
11602 /// The maximum number of items to return per page.
11603 ///
11604 /// Sets the *page size* query property to the given value.
11605 pub fn page_size(mut self, new_value: i32) -> ProjectLocationSearchAllAssignmentCall<'a, C> {
11606 self._page_size = Some(new_value);
11607 self
11608 }
11609 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11610 /// while executing the actual API request.
11611 ///
11612 /// ````text
11613 /// It should be used to handle progress information, and to implement a certain level of resilience.
11614 /// ````
11615 ///
11616 /// Sets the *delegate* property to the given value.
11617 pub fn delegate(
11618 mut self,
11619 new_value: &'a mut dyn common::Delegate,
11620 ) -> ProjectLocationSearchAllAssignmentCall<'a, C> {
11621 self._delegate = Some(new_value);
11622 self
11623 }
11624
11625 /// Set any additional parameter of the query string used in the request.
11626 /// It should be used to set parameters which are not yet available through their own
11627 /// setters.
11628 ///
11629 /// Please note that this method must not be used to set any of the known parameters
11630 /// which have their own setter method. If done anyway, the request will fail.
11631 ///
11632 /// # Additional Parameters
11633 ///
11634 /// * *$.xgafv* (query-string) - V1 error format.
11635 /// * *access_token* (query-string) - OAuth access token.
11636 /// * *alt* (query-string) - Data format for response.
11637 /// * *callback* (query-string) - JSONP
11638 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11639 /// * *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.
11640 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11641 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11642 /// * *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.
11643 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11644 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11645 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationSearchAllAssignmentCall<'a, C>
11646 where
11647 T: AsRef<str>,
11648 {
11649 self._additional_params
11650 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11651 self
11652 }
11653
11654 /// Identifies the authorization scope for the method you are building.
11655 ///
11656 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11657 /// [`Scope::CloudPlatform`].
11658 ///
11659 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11660 /// tokens for more than one scope.
11661 ///
11662 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11663 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11664 /// sufficient, a read-write scope will do as well.
11665 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSearchAllAssignmentCall<'a, C>
11666 where
11667 St: AsRef<str>,
11668 {
11669 self._scopes.insert(String::from(scope.as_ref()));
11670 self
11671 }
11672 /// Identifies the authorization scope(s) for the method you are building.
11673 ///
11674 /// See [`Self::add_scope()`] for details.
11675 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationSearchAllAssignmentCall<'a, C>
11676 where
11677 I: IntoIterator<Item = St>,
11678 St: AsRef<str>,
11679 {
11680 self._scopes
11681 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
11682 self
11683 }
11684
11685 /// Removes all scopes, and no default scope will be used either.
11686 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
11687 /// for details).
11688 pub fn clear_scopes(mut self) -> ProjectLocationSearchAllAssignmentCall<'a, C> {
11689 self._scopes.clear();
11690 self
11691 }
11692}
11693
11694/// Deprecated: Looks up assignments for a specified resource for a particular region. If the request is about a project: 1. Assignments created on the project will be returned if they exist. 2. Otherwise assignments created on the closest ancestor will be returned. 3. Assignments for different JobTypes will all be returned. The same logic applies if the request is about a folder. If the request is about an organization, then assignments created on the organization will be returned (organization doesn't have ancestors). Comparing to ListAssignments, there are some behavior differences: 1. permission on the assignee will be verified in this API. 2. Hierarchy lookup (project->folder->organization) happens in this API. 3. Parent here is `projects/*/locations/*`, instead of `projects/*/locations/*reservations/*`. **Note** "-" cannot be used for projects nor locations.
11695///
11696/// A builder for the *locations.searchAssignments* method supported by a *project* resource.
11697/// It is not used directly, but through a [`ProjectMethods`] instance.
11698///
11699/// # Example
11700///
11701/// Instantiate a resource method builder
11702///
11703/// ```test_harness,no_run
11704/// # extern crate hyper;
11705/// # extern crate hyper_rustls;
11706/// # extern crate google_bigqueryreservation1 as bigqueryreservation1;
11707/// # async fn dox() {
11708/// # use bigqueryreservation1::{BigQueryReservation, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
11709///
11710/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
11711/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
11712/// # .with_native_roots()
11713/// # .unwrap()
11714/// # .https_only()
11715/// # .enable_http2()
11716/// # .build();
11717///
11718/// # let executor = hyper_util::rt::TokioExecutor::new();
11719/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
11720/// # secret,
11721/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
11722/// # yup_oauth2::client::CustomHyperClientBuilder::from(
11723/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
11724/// # ),
11725/// # ).build().await.unwrap();
11726///
11727/// # let client = hyper_util::client::legacy::Client::builder(
11728/// # hyper_util::rt::TokioExecutor::new()
11729/// # )
11730/// # .build(
11731/// # hyper_rustls::HttpsConnectorBuilder::new()
11732/// # .with_native_roots()
11733/// # .unwrap()
11734/// # .https_or_http()
11735/// # .enable_http2()
11736/// # .build()
11737/// # );
11738/// # let mut hub = BigQueryReservation::new(client, auth);
11739/// // You can configure optional parameters by calling the respective setters at will, and
11740/// // execute the final call using `doit()`.
11741/// // Values shown here are possibly random and not representative !
11742/// let result = hub.projects().locations_search_assignments("parent")
11743/// .query("consetetur")
11744/// .page_token("diam")
11745/// .page_size(-49)
11746/// .doit().await;
11747/// # }
11748/// ```
11749pub struct ProjectLocationSearchAssignmentCall<'a, C>
11750where
11751 C: 'a,
11752{
11753 hub: &'a BigQueryReservation<C>,
11754 _parent: String,
11755 _query: Option<String>,
11756 _page_token: Option<String>,
11757 _page_size: Option<i32>,
11758 _delegate: Option<&'a mut dyn common::Delegate>,
11759 _additional_params: HashMap<String, String>,
11760 _scopes: BTreeSet<String>,
11761}
11762
11763impl<'a, C> common::CallBuilder for ProjectLocationSearchAssignmentCall<'a, C> {}
11764
11765impl<'a, C> ProjectLocationSearchAssignmentCall<'a, C>
11766where
11767 C: common::Connector,
11768{
11769 /// Perform the operation you have build so far.
11770 pub async fn doit(mut self) -> common::Result<(common::Response, SearchAssignmentsResponse)> {
11771 use std::borrow::Cow;
11772 use std::io::{Read, Seek};
11773
11774 use common::{url::Params, ToParts};
11775 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
11776
11777 let mut dd = common::DefaultDelegate;
11778 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
11779 dlg.begin(common::MethodInfo {
11780 id: "bigqueryreservation.projects.locations.searchAssignments",
11781 http_method: hyper::Method::GET,
11782 });
11783
11784 for &field in ["alt", "parent", "query", "pageToken", "pageSize"].iter() {
11785 if self._additional_params.contains_key(field) {
11786 dlg.finished(false);
11787 return Err(common::Error::FieldClash(field));
11788 }
11789 }
11790
11791 let mut params = Params::with_capacity(6 + self._additional_params.len());
11792 params.push("parent", self._parent);
11793 if let Some(value) = self._query.as_ref() {
11794 params.push("query", value);
11795 }
11796 if let Some(value) = self._page_token.as_ref() {
11797 params.push("pageToken", value);
11798 }
11799 if let Some(value) = self._page_size.as_ref() {
11800 params.push("pageSize", value.to_string());
11801 }
11802
11803 params.extend(self._additional_params.iter());
11804
11805 params.push("alt", "json");
11806 let mut url = self.hub._base_url.clone() + "v1/{+parent}:searchAssignments";
11807 if self._scopes.is_empty() {
11808 self._scopes
11809 .insert(Scope::CloudPlatform.as_ref().to_string());
11810 }
11811
11812 #[allow(clippy::single_element_loop)]
11813 for &(find_this, param_name) in [("{+parent}", "parent")].iter() {
11814 url = params.uri_replacement(url, param_name, find_this, true);
11815 }
11816 {
11817 let to_remove = ["parent"];
11818 params.remove_params(&to_remove);
11819 }
11820
11821 let url = params.parse_with_url(&url);
11822
11823 loop {
11824 let token = match self
11825 .hub
11826 .auth
11827 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
11828 .await
11829 {
11830 Ok(token) => token,
11831 Err(e) => match dlg.token(e) {
11832 Ok(token) => token,
11833 Err(e) => {
11834 dlg.finished(false);
11835 return Err(common::Error::MissingToken(e));
11836 }
11837 },
11838 };
11839 let mut req_result = {
11840 let client = &self.hub.client;
11841 dlg.pre_request();
11842 let mut req_builder = hyper::Request::builder()
11843 .method(hyper::Method::GET)
11844 .uri(url.as_str())
11845 .header(USER_AGENT, self.hub._user_agent.clone());
11846
11847 if let Some(token) = token.as_ref() {
11848 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
11849 }
11850
11851 let request = req_builder
11852 .header(CONTENT_LENGTH, 0_u64)
11853 .body(common::to_body::<String>(None));
11854
11855 client.request(request.unwrap()).await
11856 };
11857
11858 match req_result {
11859 Err(err) => {
11860 if let common::Retry::After(d) = dlg.http_error(&err) {
11861 sleep(d).await;
11862 continue;
11863 }
11864 dlg.finished(false);
11865 return Err(common::Error::HttpError(err));
11866 }
11867 Ok(res) => {
11868 let (mut parts, body) = res.into_parts();
11869 let mut body = common::Body::new(body);
11870 if !parts.status.is_success() {
11871 let bytes = common::to_bytes(body).await.unwrap_or_default();
11872 let error = serde_json::from_str(&common::to_string(&bytes));
11873 let response = common::to_response(parts, bytes.into());
11874
11875 if let common::Retry::After(d) =
11876 dlg.http_failure(&response, error.as_ref().ok())
11877 {
11878 sleep(d).await;
11879 continue;
11880 }
11881
11882 dlg.finished(false);
11883
11884 return Err(match error {
11885 Ok(value) => common::Error::BadRequest(value),
11886 _ => common::Error::Failure(response),
11887 });
11888 }
11889 let response = {
11890 let bytes = common::to_bytes(body).await.unwrap_or_default();
11891 let encoded = common::to_string(&bytes);
11892 match serde_json::from_str(&encoded) {
11893 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
11894 Err(error) => {
11895 dlg.response_json_decode_error(&encoded, &error);
11896 return Err(common::Error::JsonDecodeError(
11897 encoded.to_string(),
11898 error,
11899 ));
11900 }
11901 }
11902 };
11903
11904 dlg.finished(true);
11905 return Ok(response);
11906 }
11907 }
11908 }
11909 }
11910
11911 /// Required. The resource name of the admin project(containing project and location), e.g.: `projects/myproject/locations/US`.
11912 ///
11913 /// Sets the *parent* path property to the given value.
11914 ///
11915 /// Even though the property as already been set when instantiating this call,
11916 /// we provide this method for API completeness.
11917 pub fn parent(mut self, new_value: &str) -> ProjectLocationSearchAssignmentCall<'a, C> {
11918 self._parent = new_value.to_string();
11919 self
11920 }
11921 /// Please specify resource name as assignee in the query. Examples: * `assignee=projects/myproject` * `assignee=folders/123` * `assignee=organizations/456`
11922 ///
11923 /// Sets the *query* query property to the given value.
11924 pub fn query(mut self, new_value: &str) -> ProjectLocationSearchAssignmentCall<'a, C> {
11925 self._query = Some(new_value.to_string());
11926 self
11927 }
11928 /// The next_page_token value returned from a previous List request, if any.
11929 ///
11930 /// Sets the *page token* query property to the given value.
11931 pub fn page_token(mut self, new_value: &str) -> ProjectLocationSearchAssignmentCall<'a, C> {
11932 self._page_token = Some(new_value.to_string());
11933 self
11934 }
11935 /// The maximum number of items to return per page.
11936 ///
11937 /// Sets the *page size* query property to the given value.
11938 pub fn page_size(mut self, new_value: i32) -> ProjectLocationSearchAssignmentCall<'a, C> {
11939 self._page_size = Some(new_value);
11940 self
11941 }
11942 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
11943 /// while executing the actual API request.
11944 ///
11945 /// ````text
11946 /// It should be used to handle progress information, and to implement a certain level of resilience.
11947 /// ````
11948 ///
11949 /// Sets the *delegate* property to the given value.
11950 pub fn delegate(
11951 mut self,
11952 new_value: &'a mut dyn common::Delegate,
11953 ) -> ProjectLocationSearchAssignmentCall<'a, C> {
11954 self._delegate = Some(new_value);
11955 self
11956 }
11957
11958 /// Set any additional parameter of the query string used in the request.
11959 /// It should be used to set parameters which are not yet available through their own
11960 /// setters.
11961 ///
11962 /// Please note that this method must not be used to set any of the known parameters
11963 /// which have their own setter method. If done anyway, the request will fail.
11964 ///
11965 /// # Additional Parameters
11966 ///
11967 /// * *$.xgafv* (query-string) - V1 error format.
11968 /// * *access_token* (query-string) - OAuth access token.
11969 /// * *alt* (query-string) - Data format for response.
11970 /// * *callback* (query-string) - JSONP
11971 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
11972 /// * *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.
11973 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
11974 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
11975 /// * *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.
11976 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
11977 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
11978 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationSearchAssignmentCall<'a, C>
11979 where
11980 T: AsRef<str>,
11981 {
11982 self._additional_params
11983 .insert(name.as_ref().to_string(), value.as_ref().to_string());
11984 self
11985 }
11986
11987 /// Identifies the authorization scope for the method you are building.
11988 ///
11989 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
11990 /// [`Scope::CloudPlatform`].
11991 ///
11992 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
11993 /// tokens for more than one scope.
11994 ///
11995 /// Usually there is more than one suitable scope to authorize an operation, some of which may
11996 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
11997 /// sufficient, a read-write scope will do as well.
11998 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationSearchAssignmentCall<'a, C>
11999 where
12000 St: AsRef<str>,
12001 {
12002 self._scopes.insert(String::from(scope.as_ref()));
12003 self
12004 }
12005 /// Identifies the authorization scope(s) for the method you are building.
12006 ///
12007 /// See [`Self::add_scope()`] for details.
12008 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationSearchAssignmentCall<'a, C>
12009 where
12010 I: IntoIterator<Item = St>,
12011 St: AsRef<str>,
12012 {
12013 self._scopes
12014 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12015 self
12016 }
12017
12018 /// Removes all scopes, and no default scope will be used either.
12019 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12020 /// for details).
12021 pub fn clear_scopes(mut self) -> ProjectLocationSearchAssignmentCall<'a, C> {
12022 self._scopes.clear();
12023 self
12024 }
12025}
12026
12027/// Updates a BI reservation. Only fields specified in the `field_mask` are updated. A singleton BI reservation always exists with default size 0. In order to reserve BI capacity it needs to be updated to an amount greater than 0. In order to release BI capacity reservation size must be set to 0.
12028///
12029/// A builder for the *locations.updateBiReservation* method supported by a *project* resource.
12030/// It is not used directly, but through a [`ProjectMethods`] instance.
12031///
12032/// # Example
12033///
12034/// Instantiate a resource method builder
12035///
12036/// ```test_harness,no_run
12037/// # extern crate hyper;
12038/// # extern crate hyper_rustls;
12039/// # extern crate google_bigqueryreservation1 as bigqueryreservation1;
12040/// use bigqueryreservation1::api::BiReservation;
12041/// # async fn dox() {
12042/// # use bigqueryreservation1::{BigQueryReservation, FieldMask, hyper_rustls, hyper_util, yup_oauth2};
12043///
12044/// # let secret: yup_oauth2::ApplicationSecret = Default::default();
12045/// # let connector = hyper_rustls::HttpsConnectorBuilder::new()
12046/// # .with_native_roots()
12047/// # .unwrap()
12048/// # .https_only()
12049/// # .enable_http2()
12050/// # .build();
12051///
12052/// # let executor = hyper_util::rt::TokioExecutor::new();
12053/// # let auth = yup_oauth2::InstalledFlowAuthenticator::with_client(
12054/// # secret,
12055/// # yup_oauth2::InstalledFlowReturnMethod::HTTPRedirect,
12056/// # yup_oauth2::client::CustomHyperClientBuilder::from(
12057/// # hyper_util::client::legacy::Client::builder(executor).build(connector),
12058/// # ),
12059/// # ).build().await.unwrap();
12060///
12061/// # let client = hyper_util::client::legacy::Client::builder(
12062/// # hyper_util::rt::TokioExecutor::new()
12063/// # )
12064/// # .build(
12065/// # hyper_rustls::HttpsConnectorBuilder::new()
12066/// # .with_native_roots()
12067/// # .unwrap()
12068/// # .https_or_http()
12069/// # .enable_http2()
12070/// # .build()
12071/// # );
12072/// # let mut hub = BigQueryReservation::new(client, auth);
12073/// // As the method needs a request, you would usually fill it with the desired information
12074/// // into the respective structure. Some of the parts shown here might not be applicable !
12075/// // Values shown here are possibly random and not representative !
12076/// let mut req = BiReservation::default();
12077///
12078/// // You can configure optional parameters by calling the respective setters at will, and
12079/// // execute the final call using `doit()`.
12080/// // Values shown here are possibly random and not representative !
12081/// let result = hub.projects().locations_update_bi_reservation(req, "name")
12082/// .update_mask(FieldMask::new::<&str>(&[]))
12083/// .doit().await;
12084/// # }
12085/// ```
12086pub struct ProjectLocationUpdateBiReservationCall<'a, C>
12087where
12088 C: 'a,
12089{
12090 hub: &'a BigQueryReservation<C>,
12091 _request: BiReservation,
12092 _name: String,
12093 _update_mask: Option<common::FieldMask>,
12094 _delegate: Option<&'a mut dyn common::Delegate>,
12095 _additional_params: HashMap<String, String>,
12096 _scopes: BTreeSet<String>,
12097}
12098
12099impl<'a, C> common::CallBuilder for ProjectLocationUpdateBiReservationCall<'a, C> {}
12100
12101impl<'a, C> ProjectLocationUpdateBiReservationCall<'a, C>
12102where
12103 C: common::Connector,
12104{
12105 /// Perform the operation you have build so far.
12106 pub async fn doit(mut self) -> common::Result<(common::Response, BiReservation)> {
12107 use std::borrow::Cow;
12108 use std::io::{Read, Seek};
12109
12110 use common::{url::Params, ToParts};
12111 use hyper::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE, LOCATION, USER_AGENT};
12112
12113 let mut dd = common::DefaultDelegate;
12114 let mut dlg: &mut dyn common::Delegate = self._delegate.unwrap_or(&mut dd);
12115 dlg.begin(common::MethodInfo {
12116 id: "bigqueryreservation.projects.locations.updateBiReservation",
12117 http_method: hyper::Method::PATCH,
12118 });
12119
12120 for &field in ["alt", "name", "updateMask"].iter() {
12121 if self._additional_params.contains_key(field) {
12122 dlg.finished(false);
12123 return Err(common::Error::FieldClash(field));
12124 }
12125 }
12126
12127 let mut params = Params::with_capacity(5 + self._additional_params.len());
12128 params.push("name", self._name);
12129 if let Some(value) = self._update_mask.as_ref() {
12130 params.push("updateMask", value.to_string());
12131 }
12132
12133 params.extend(self._additional_params.iter());
12134
12135 params.push("alt", "json");
12136 let mut url = self.hub._base_url.clone() + "v1/{+name}";
12137 if self._scopes.is_empty() {
12138 self._scopes
12139 .insert(Scope::CloudPlatform.as_ref().to_string());
12140 }
12141
12142 #[allow(clippy::single_element_loop)]
12143 for &(find_this, param_name) in [("{+name}", "name")].iter() {
12144 url = params.uri_replacement(url, param_name, find_this, true);
12145 }
12146 {
12147 let to_remove = ["name"];
12148 params.remove_params(&to_remove);
12149 }
12150
12151 let url = params.parse_with_url(&url);
12152
12153 let mut json_mime_type = mime::APPLICATION_JSON;
12154 let mut request_value_reader = {
12155 let mut value = serde_json::value::to_value(&self._request).expect("serde to work");
12156 common::remove_json_null_values(&mut value);
12157 let mut dst = std::io::Cursor::new(Vec::with_capacity(128));
12158 serde_json::to_writer(&mut dst, &value).unwrap();
12159 dst
12160 };
12161 let request_size = request_value_reader
12162 .seek(std::io::SeekFrom::End(0))
12163 .unwrap();
12164 request_value_reader
12165 .seek(std::io::SeekFrom::Start(0))
12166 .unwrap();
12167
12168 loop {
12169 let token = match self
12170 .hub
12171 .auth
12172 .get_token(&self._scopes.iter().map(String::as_str).collect::<Vec<_>>()[..])
12173 .await
12174 {
12175 Ok(token) => token,
12176 Err(e) => match dlg.token(e) {
12177 Ok(token) => token,
12178 Err(e) => {
12179 dlg.finished(false);
12180 return Err(common::Error::MissingToken(e));
12181 }
12182 },
12183 };
12184 request_value_reader
12185 .seek(std::io::SeekFrom::Start(0))
12186 .unwrap();
12187 let mut req_result = {
12188 let client = &self.hub.client;
12189 dlg.pre_request();
12190 let mut req_builder = hyper::Request::builder()
12191 .method(hyper::Method::PATCH)
12192 .uri(url.as_str())
12193 .header(USER_AGENT, self.hub._user_agent.clone());
12194
12195 if let Some(token) = token.as_ref() {
12196 req_builder = req_builder.header(AUTHORIZATION, format!("Bearer {}", token));
12197 }
12198
12199 let request = req_builder
12200 .header(CONTENT_TYPE, json_mime_type.to_string())
12201 .header(CONTENT_LENGTH, request_size as u64)
12202 .body(common::to_body(
12203 request_value_reader.get_ref().clone().into(),
12204 ));
12205
12206 client.request(request.unwrap()).await
12207 };
12208
12209 match req_result {
12210 Err(err) => {
12211 if let common::Retry::After(d) = dlg.http_error(&err) {
12212 sleep(d).await;
12213 continue;
12214 }
12215 dlg.finished(false);
12216 return Err(common::Error::HttpError(err));
12217 }
12218 Ok(res) => {
12219 let (mut parts, body) = res.into_parts();
12220 let mut body = common::Body::new(body);
12221 if !parts.status.is_success() {
12222 let bytes = common::to_bytes(body).await.unwrap_or_default();
12223 let error = serde_json::from_str(&common::to_string(&bytes));
12224 let response = common::to_response(parts, bytes.into());
12225
12226 if let common::Retry::After(d) =
12227 dlg.http_failure(&response, error.as_ref().ok())
12228 {
12229 sleep(d).await;
12230 continue;
12231 }
12232
12233 dlg.finished(false);
12234
12235 return Err(match error {
12236 Ok(value) => common::Error::BadRequest(value),
12237 _ => common::Error::Failure(response),
12238 });
12239 }
12240 let response = {
12241 let bytes = common::to_bytes(body).await.unwrap_or_default();
12242 let encoded = common::to_string(&bytes);
12243 match serde_json::from_str(&encoded) {
12244 Ok(decoded) => (common::to_response(parts, bytes.into()), decoded),
12245 Err(error) => {
12246 dlg.response_json_decode_error(&encoded, &error);
12247 return Err(common::Error::JsonDecodeError(
12248 encoded.to_string(),
12249 error,
12250 ));
12251 }
12252 }
12253 };
12254
12255 dlg.finished(true);
12256 return Ok(response);
12257 }
12258 }
12259 }
12260 }
12261
12262 ///
12263 /// Sets the *request* property to the given value.
12264 ///
12265 /// Even though the property as already been set when instantiating this call,
12266 /// we provide this method for API completeness.
12267 pub fn request(
12268 mut self,
12269 new_value: BiReservation,
12270 ) -> ProjectLocationUpdateBiReservationCall<'a, C> {
12271 self._request = new_value;
12272 self
12273 }
12274 /// Identifier. The resource name of the singleton BI reservation. Reservation names have the form `projects/{project_id}/locations/{location_id}/biReservation`.
12275 ///
12276 /// Sets the *name* path property to the given value.
12277 ///
12278 /// Even though the property as already been set when instantiating this call,
12279 /// we provide this method for API completeness.
12280 pub fn name(mut self, new_value: &str) -> ProjectLocationUpdateBiReservationCall<'a, C> {
12281 self._name = new_value.to_string();
12282 self
12283 }
12284 /// A list of fields to be updated in this request.
12285 ///
12286 /// Sets the *update mask* query property to the given value.
12287 pub fn update_mask(
12288 mut self,
12289 new_value: common::FieldMask,
12290 ) -> ProjectLocationUpdateBiReservationCall<'a, C> {
12291 self._update_mask = Some(new_value);
12292 self
12293 }
12294 /// The delegate implementation is consulted whenever there is an intermediate result, or if something goes wrong
12295 /// while executing the actual API request.
12296 ///
12297 /// ````text
12298 /// It should be used to handle progress information, and to implement a certain level of resilience.
12299 /// ````
12300 ///
12301 /// Sets the *delegate* property to the given value.
12302 pub fn delegate(
12303 mut self,
12304 new_value: &'a mut dyn common::Delegate,
12305 ) -> ProjectLocationUpdateBiReservationCall<'a, C> {
12306 self._delegate = Some(new_value);
12307 self
12308 }
12309
12310 /// Set any additional parameter of the query string used in the request.
12311 /// It should be used to set parameters which are not yet available through their own
12312 /// setters.
12313 ///
12314 /// Please note that this method must not be used to set any of the known parameters
12315 /// which have their own setter method. If done anyway, the request will fail.
12316 ///
12317 /// # Additional Parameters
12318 ///
12319 /// * *$.xgafv* (query-string) - V1 error format.
12320 /// * *access_token* (query-string) - OAuth access token.
12321 /// * *alt* (query-string) - Data format for response.
12322 /// * *callback* (query-string) - JSONP
12323 /// * *fields* (query-string) - Selector specifying which fields to include in a partial response.
12324 /// * *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.
12325 /// * *oauth_token* (query-string) - OAuth 2.0 token for the current user.
12326 /// * *prettyPrint* (query-boolean) - Returns response with indentations and line breaks.
12327 /// * *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.
12328 /// * *uploadType* (query-string) - Legacy upload protocol for media (e.g. "media", "multipart").
12329 /// * *upload_protocol* (query-string) - Upload protocol for media (e.g. "raw", "multipart").
12330 pub fn param<T>(mut self, name: T, value: T) -> ProjectLocationUpdateBiReservationCall<'a, C>
12331 where
12332 T: AsRef<str>,
12333 {
12334 self._additional_params
12335 .insert(name.as_ref().to_string(), value.as_ref().to_string());
12336 self
12337 }
12338
12339 /// Identifies the authorization scope for the method you are building.
12340 ///
12341 /// Use this method to actively specify which scope should be used, instead of the default [`Scope`] variant
12342 /// [`Scope::CloudPlatform`].
12343 ///
12344 /// The `scope` will be added to a set of scopes. This is important as one can maintain access
12345 /// tokens for more than one scope.
12346 ///
12347 /// Usually there is more than one suitable scope to authorize an operation, some of which may
12348 /// encompass more rights than others. For example, for listing resources, a *read-only* scope will be
12349 /// sufficient, a read-write scope will do as well.
12350 pub fn add_scope<St>(mut self, scope: St) -> ProjectLocationUpdateBiReservationCall<'a, C>
12351 where
12352 St: AsRef<str>,
12353 {
12354 self._scopes.insert(String::from(scope.as_ref()));
12355 self
12356 }
12357 /// Identifies the authorization scope(s) for the method you are building.
12358 ///
12359 /// See [`Self::add_scope()`] for details.
12360 pub fn add_scopes<I, St>(mut self, scopes: I) -> ProjectLocationUpdateBiReservationCall<'a, C>
12361 where
12362 I: IntoIterator<Item = St>,
12363 St: AsRef<str>,
12364 {
12365 self._scopes
12366 .extend(scopes.into_iter().map(|s| String::from(s.as_ref())));
12367 self
12368 }
12369
12370 /// Removes all scopes, and no default scope will be used either.
12371 /// In this case, you have to specify your API-key using the `key` parameter (see [`Self::param()`]
12372 /// for details).
12373 pub fn clear_scopes(mut self) -> ProjectLocationUpdateBiReservationCall<'a, C> {
12374 self._scopes.clear();
12375 self
12376 }
12377}