Skip to content

Commit

Permalink
Add support for setting 'auto-increase-up-to' in quotas
Browse files Browse the repository at this point in the history
  • Loading branch information
annesylvie committed Feb 16, 2024
1 parent 5942b1c commit 3cd5c33
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions api/src/resources/quota.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u64>,
}

#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq, Hash, Copy)]
Expand Down
6 changes: 6 additions & 0 deletions cli/src/commands/create/quota.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u64>,
}

pub fn create(client: &Client, args: &CreateQuotaArgs) -> Result<()> {
Expand All @@ -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) {
Expand All @@ -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")?;
Expand Down

0 comments on commit 3cd5c33

Please sign in to comment.