From 4da3363cf780411ada15602b57b818f386e077c9 Mon Sep 17 00:00:00 2001 From: sunghyunkang1111 <114709653+sunghyunkang1111@users.noreply.github.com> Date: Fri, 17 May 2024 12:19:23 -0500 Subject: [PATCH] add capacityMode (#1826) * add capacityMode * add check for capacityMode for serverless --- src/Common/Constants.ts | 5 +++++ src/Contracts/DataModels.ts | 3 ++- src/Utils/CapabilityUtils.ts | 8 +++++++- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Common/Constants.ts b/src/Common/Constants.ts index 69bd5ed49..0658d28c5 100644 --- a/src/Common/Constants.ts +++ b/src/Common/Constants.ts @@ -90,6 +90,11 @@ export class CapabilityNames { public static readonly EnableServerless: string = "EnableServerless"; } +export enum CapacityMode { + Provisioned = "Provisioned", + Serverless = "Serverless", +} + // flight names returned from the portal are always lowercase export class Flights { public static readonly SettingsV2 = "settingsv2"; diff --git a/src/Contracts/DataModels.ts b/src/Contracts/DataModels.ts index 3c8a5175d..e85f56964 100644 --- a/src/Contracts/DataModels.ts +++ b/src/Contracts/DataModels.ts @@ -1,4 +1,4 @@ -import { ConnectionStatusType, ContainerStatusType } from "../Common/Constants"; +import { CapacityMode, ConnectionStatusType, ContainerStatusType } from "../Common/Constants"; export interface ArmEntity { id: string; @@ -35,6 +35,7 @@ export interface DatabaseAccountExtendedProperties { ipRules?: IpRule[]; privateEndpointConnections?: unknown[]; capacity?: { totalThroughputLimit: number }; + capacityMode?: CapacityMode; locations?: DatabaseAccountResponseLocation[]; postgresqlEndpoint?: string; publicNetworkAccess?: string; diff --git a/src/Utils/CapabilityUtils.ts b/src/Utils/CapabilityUtils.ts index fc2de8149..216eff13d 100644 --- a/src/Utils/CapabilityUtils.ts +++ b/src/Utils/CapabilityUtils.ts @@ -9,4 +9,10 @@ export const isCapabilityEnabled = (capabilityName: string): boolean => { return false; }; -export const isServerlessAccount = (): boolean => isCapabilityEnabled(Constants.CapabilityNames.EnableServerless); +export const isServerlessAccount = (): boolean => { + const { databaseAccount } = userContext; + return ( + databaseAccount?.properties?.capacityMode === Constants.CapacityMode.Serverless || + isCapabilityEnabled(Constants.CapabilityNames.EnableServerless) + ); +};