From 3cd5c338dff1f1b59be5ca95d8a4b68ef30e6dbb Mon Sep 17 00:00:00 2001 From: Anne-Sylvie Deutsch Date: Fri, 16 Feb 2024 16:55:06 +0000 Subject: [PATCH] Add support for setting 'auto-increase-up-to' in quotas --- api/src/resources/quota.rs | 7 +++++++ cli/src/commands/create/quota.rs | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/api/src/resources/quota.rs b/api/src/resources/quota.rs index 4fdb7354..a79715c3 100644 --- a/api/src/resources/quota.rs +++ b/api/src/resources/quota.rs @@ -93,6 +93,13 @@ impl Display for TenantQuotaKind { #[derive(Debug, Clone, Serialize, PartialEq, Eq, Default)] pub struct CreateQuota { pub hard_limit: u64, + + // It is very important for this value not to be serialized if it is `None`. + // This is because the API will interpret `null` as "reset the auto-increase-up-to" value to + // its default value. If the field is not set, then the value will be left unchanged (which is + // what we want). + #[serde(skip_serializing_if = "Option::is_none")] + pub auto_increase_up_to: Option, } #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash, Copy)] diff --git a/cli/src/commands/create/quota.rs b/cli/src/commands/create/quota.rs index 010ba0ad..8a8cf981 100644 --- a/cli/src/commands/create/quota.rs +++ b/cli/src/commands/create/quota.rs @@ -27,6 +27,10 @@ pub struct CreateQuotaArgs { #[structopt(long = "limit")] /// New value of the quota to set hard_limit: u64, + + #[structopt(long = "auto-increase-up-to")] + /// If set, will also change the `auto-increase-up-to` value of the quota + auto_increase_up_to: Option, } pub fn create(client: &Client, args: &CreateQuotaArgs) -> Result<()> { @@ -35,6 +39,7 @@ pub fn create(client: &Client, args: &CreateQuotaArgs) -> Result<()> { uipath_tenant_id, tenant_quota_kind, hard_limit, + auto_increase_up_to, } = args; let tenant_id: TenantId = match (reinfer_tenant_id, uipath_tenant_id) { @@ -53,6 +58,7 @@ pub fn create(client: &Client, args: &CreateQuotaArgs) -> Result<()> { *tenant_quota_kind, CreateQuota { hard_limit: *hard_limit, + auto_increase_up_to: *auto_increase_up_to, }, ) .context("Operation to set quota has failed")?;