From 1f565ec76fa1c060953e5fe61f334c8218f682b3 Mon Sep 17 00:00:00 2001 From: Marcelo Date: Tue, 21 Oct 2025 20:00:44 -0300 Subject: [PATCH 1/4] add new fields --- .../bigquery/reservation/v1/src/model.rs | 160 ++++++++++++++++++ 1 file changed, 160 insertions(+) diff --git a/src/generated/cloud/bigquery/reservation/v1/src/model.rs b/src/generated/cloud/bigquery/reservation/v1/src/model.rs index f33b8395e1..61cbfd6940 100755 --- a/src/generated/cloud/bigquery/reservation/v1/src/model.rs +++ b/src/generated/cloud/bigquery/reservation/v1/src/model.rs @@ -129,7 +129,82 @@ pub struct Reservation { /// for the failover reservation will be applied to this location. #[serde(skip_serializing_if = "std::string::String::is_empty")] pub original_primary_location: std::string::String, + + /// 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. + #[serde_as(as = "std::option::Option")] + #[serde(default, skip_serializing_if = "std::option::Option::is_none")] + pub max_slots: std::option::Option, + + + /// 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`. + pub scaling_mode: crate::model::reservation::ScalingMode, + + /// 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. + pub labels: std::collections::HashMap, + + /// 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} + pub reservation_group: std::string::String, } +fn deserialize_optional_i64<'de, D>(deserializer: D) -> std::result::Result, D::Error> +where + D: serde::Deserializer<'de>, +{ + use serde::Deserialize; + std::option::Option::::deserialize(deserializer) +} + impl Reservation { pub fn new() -> Self { @@ -282,6 +357,91 @@ pub mod reservation { "type.googleapis.com/google.cloud.bigquery.reservation.v1.Reservation.Autoscale" } } + + /// The type of scaling modes. + /// Different scaling behaviors are provided for different modes. + #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + pub struct ScalingMode(std::borrow::Cow<'static, str>); + + impl ScalingMode { + /// Creates a new ScalingMode instance. + pub const fn new(v: &'static str) -> Self { + Self(std::borrow::Cow::Borrowed(v)) + } + + /// Gets the enum value. + pub fn value(&self) -> &str { + &self.0 + } + } + + /// Useful constants to work with [ScalingMode](ScalingMode) + pub mod scaling_mode { + use super::ScalingMode; + + /// Default value of ScalingMode. + pub const SCALING_MODE_UNSPECIFIED: ScalingMode = ScalingMode::new("SCALING_MODE_UNSPECIFIED"); + + /// The reservation will scale up only using slots from autoscaling. It will + /// not use any idle slots even if there may be some available. The upper + /// limit that autoscaling can scale up to will be max_slots - baseline. + /// For example, if max_slots is 1000, baseline is 200 and customer sets + /// ScalingMode to AUTOSCALE_ONLY, then autoscalerg will scale up to 800 + /// slots and no idle slots will be used. + /// + /// Please note, in this mode, the ignore_idle_slots field must be set to + /// true. Otherwise the request will be rejected with error code + /// `google.rpc.Code.INVALID_ARGUMENT`. + pub const AUTOSCALE_ONLY: ScalingMode = ScalingMode::new("AUTOSCALE_ONLY"); + + /// The reservation will scale up using only idle slots contributed by + /// other reservations or from unassigned commitments. If no idle slots are + /// available it will not scale up further. If the idle slots which it is + /// using are reclaimed by the contributing reservation(s) it may be forced + /// to scale down. The max idle slots the reservation can be max_slots - + /// baseline capacity. For example, if max_slots is 1000, baseline is 200 and + /// customer sets ScalingMode to IDLE_SLOTS_ONLY, + /// + /// 1. if there are 1000 idle slots available in other reservations, the + /// reservation will scale up to 1000 slots with 200 baseline and 800 idle + /// slots. + /// 1. if there are 500 idle slots available in other reservations, the + /// reservation will scale up to 700 slots with 200 baseline and 300 idle + /// slots. + /// Please note, in this mode, the reservation might not be able to scale up + /// to max_slots. + /// + /// Please note, in this mode, the ignore_idle_slots field must be set to + /// false. Otherwise the request will be rejected with error code + /// `google.rpc.Code.INVALID_ARGUMENT`. + pub const IDLE_SLOTS_ONLY: ScalingMode = ScalingMode::new("IDLE_SLOTS_ONLY"); + + /// The reservation will scale up using all slots available to it. It will + /// use idle slots contributed by other reservations or from unassigned + /// commitments first. If no idle slots are available it will scale up using + /// autoscaling. For example, if max_slots is 1000, baseline is 200 and + /// customer sets ScalingMode to ALL_SLOTS, + /// + /// 1. if there are 800 idle slots available in other reservations, the + /// reservation will scale up to 1000 slots with 200 baseline and 800 idle + /// slots. + /// 1. if there are 500 idle slots available in other reservations, the + /// reservation will scale up to 1000 slots with 200 baseline, 500 idle + /// slots and 300 autoscaling slots. + /// 1. if there are no idle slots available in other reservations, it will + /// scale up to 1000 slots with 200 baseline and 800 autoscaling slots. + /// + /// Please note, in this mode, the ignore_idle_slots field must be set to + /// false. Otherwise the request will be rejected with error code + /// `google.rpc.Code.INVALID_ARGUMENT`. + pub const ALL_SLOTS: ScalingMode = ScalingMode::new("ALL_SLOTS"); + } + + impl std::convert::From for ScalingMode { + fn from(value: std::string::String) -> Self { + Self(std::borrow::Cow::Owned(value)) + } + } } /// Capacity commitment is a way to purchase compute capacity for BigQuery jobs From 08e6d00a24f75f72f7abefaef41e50ca298114f2 Mon Sep 17 00:00:00 2001 From: Marcelo Date: Tue, 21 Oct 2025 20:02:04 -0300 Subject: [PATCH 2/4] unused --- src/generated/cloud/bigquery/reservation/v1/src/model.rs | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/generated/cloud/bigquery/reservation/v1/src/model.rs b/src/generated/cloud/bigquery/reservation/v1/src/model.rs index 61cbfd6940..74939137f2 100755 --- a/src/generated/cloud/bigquery/reservation/v1/src/model.rs +++ b/src/generated/cloud/bigquery/reservation/v1/src/model.rs @@ -197,13 +197,6 @@ pub struct Reservation { /// or just {reservation_group} pub reservation_group: std::string::String, } -fn deserialize_optional_i64<'de, D>(deserializer: D) -> std::result::Result, D::Error> -where - D: serde::Deserializer<'de>, -{ - use serde::Deserialize; - std::option::Option::::deserialize(deserializer) -} impl Reservation { From fd51f750200878af132ca3cdafd77e19d414b977 Mon Sep 17 00:00:00 2001 From: Marcelo Date: Tue, 21 Oct 2025 20:24:04 -0300 Subject: [PATCH 3/4] fix --- .../bigquery/reservation/v1/src/model.rs | 56 ++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/src/generated/cloud/bigquery/reservation/v1/src/model.rs b/src/generated/cloud/bigquery/reservation/v1/src/model.rs index 74939137f2..772d5549d8 100755 --- a/src/generated/cloud/bigquery/reservation/v1/src/model.rs +++ b/src/generated/cloud/bigquery/reservation/v1/src/model.rs @@ -295,6 +295,54 @@ impl Reservation { self.original_primary_location = v.into(); self } + + /// Sets the value of [max_slots][crate::model::Reservation::max_slots]. + pub fn set_max_slots(mut self, v: T) -> Self + where + T: std::convert::Into, + { + self.max_slots = std::option::Option::Some(v.into()); + self + } + + /// Sets or clears the value of [max_slots][crate::model::Reservation::max_slots]. + pub fn set_or_clear_max_slots(mut self, v: std::option::Option) -> Self + where + T: std::convert::Into, + { + self.max_slots = v.map(|x| x.into()); + self + } + + /// Sets the value of [scaling_mode][crate::model::Reservation::scaling_mode]. + pub fn set_scaling_mode>( + mut self, + v: T, + ) -> Self { + self.scaling_mode = v.into(); + self + } + + /// Sets the value of [labels][crate::model::Reservation::labels]. + pub fn set_labels(mut self, v: T) -> Self + where + T: std::iter::IntoIterator, + K: std::convert::Into, + V: std::convert::Into, + { + use std::iter::Iterator; + self.labels = v.into_iter().map(|(k, v)| (k.into(), v.into())).collect(); + self + } + + /// Sets the value of [reservation_group][crate::model::Reservation::reservation_group]. + pub fn set_reservation_group>( + mut self, + v: T, + ) -> Self { + self.reservation_group = v.into(); + self + } } impl wkt::message::Message for Reservation { @@ -353,9 +401,15 @@ pub mod reservation { /// The type of scaling modes. /// Different scaling behaviors are provided for different modes. - #[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)] + #[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)] pub struct ScalingMode(std::borrow::Cow<'static, str>); + impl std::default::Default for ScalingMode { + fn default() -> Self { + scaling_mode::SCALING_MODE_UNSPECIFIED + } + } + impl ScalingMode { /// Creates a new ScalingMode instance. pub const fn new(v: &'static str) -> Self { From 15e8b6d84b8e28974ca2e8e3b1d9eec64870ebbf Mon Sep 17 00:00:00 2001 From: Marcelo Date: Tue, 21 Oct 2025 20:30:08 -0300 Subject: [PATCH 4/4] format --- src/generated/cloud/bigquery/reservation/v1/src/model.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/generated/cloud/bigquery/reservation/v1/src/model.rs b/src/generated/cloud/bigquery/reservation/v1/src/model.rs index 772d5549d8..eb93e5db3e 100755 --- a/src/generated/cloud/bigquery/reservation/v1/src/model.rs +++ b/src/generated/cloud/bigquery/reservation/v1/src/model.rs @@ -178,7 +178,6 @@ pub struct Reservation { #[serde(default, skip_serializing_if = "std::option::Option::is_none")] pub max_slots: std::option::Option, - /// 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`. @@ -198,7 +197,6 @@ pub struct Reservation { pub reservation_group: std::string::String, } - impl Reservation { pub fn new() -> Self { std::default::Default::default() @@ -427,7 +425,8 @@ pub mod reservation { use super::ScalingMode; /// Default value of ScalingMode. - pub const SCALING_MODE_UNSPECIFIED: ScalingMode = ScalingMode::new("SCALING_MODE_UNSPECIFIED"); + pub const SCALING_MODE_UNSPECIFIED: ScalingMode = + ScalingMode::new("SCALING_MODE_UNSPECIFIED"); /// The reservation will scale up only using slots from autoscaling. It will /// not use any idle slots even if there may be some available. The upper