mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-29 05:41:40 +00:00
Add Dedicated Gateway Type
This commit is contained in:
@@ -8,6 +8,7 @@
|
||||
"DedicatedGatewayPricing": "Learn more about dedicated gateway pricing.",
|
||||
"SKUs": "SKUs",
|
||||
"SKUsPlaceHolder": "Select SKUs",
|
||||
"DedicatedGatewayTypePlaceHolder": "Select Dedicated Gateway Type",
|
||||
"NumberOfInstances": "Number of instances",
|
||||
"CosmosD4s": "Cosmos.D4s (General Purpose Cosmos Compute with 4 vCPUs, 16 GB Memory)",
|
||||
"CosmosD8s": "Cosmos.D8s (General Purpose Cosmos Compute with 8 vCPUs, 32 GB Memory)",
|
||||
|
||||
@@ -33,11 +33,12 @@ export const getPath = (subscriptionId: string, resourceGroup: string, name: str
|
||||
return `/subscriptions/${subscriptionId}/resourceGroups/${resourceGroup}/providers/Microsoft.DocumentDB/databaseAccounts/${name}/services/SqlDedicatedGateway`;
|
||||
};
|
||||
|
||||
export const updateDedicatedGatewayResource = async (sku: string, instances: number): Promise<string> => {
|
||||
export const updateDedicatedGatewayResource = async (sku: string, dedicatedGatewayType: string, instances: number): Promise<string> => {
|
||||
const path = getPath(userContext.subscriptionId, userContext.resourceGroup, userContext.databaseAccount.name);
|
||||
const body: UpdateDedicatedGatewayRequestParameters = {
|
||||
properties: {
|
||||
instanceSize: sku,
|
||||
// TODO: pass in DedicatedGatewayType into the properties on Update
|
||||
instanceCount: instances,
|
||||
serviceType: "SqlDedicatedGateway",
|
||||
},
|
||||
|
||||
@@ -70,6 +70,14 @@ const onSKUChange = (newValue: InputType, currentValues: Map<string, SmartUiInpu
|
||||
return currentValues;
|
||||
};
|
||||
|
||||
const IntegratedCache = "IntegratedCache";
|
||||
const DistributedQuery = "DistributedQuery";
|
||||
|
||||
const onDedicatedGatewayTypeChange = (newValue: InputType, currentValues: Map<string, SmartUiInput>): Map<string, SmartUiInput> => {
|
||||
currentValues.set("dedicatedGatewayType", { value: newValue });
|
||||
return currentValues;
|
||||
};
|
||||
|
||||
const onNumberOfInstancesChange = (
|
||||
newValue: InputType,
|
||||
currentValues: Map<string, SmartUiInput>,
|
||||
@@ -109,6 +117,7 @@ const onEnableDedicatedGatewayChange = (
|
||||
const dedicatedGatewayOriginallyEnabled = baselineValues.get("enableDedicatedGateway")?.value as boolean;
|
||||
if (dedicatedGatewayOriginallyEnabled === newValue) {
|
||||
currentValues.set("sku", baselineValues.get("sku"));
|
||||
currentValues.set("dedicatedGatewayType", baselineValues.get("dedicatedGatewayType"));
|
||||
currentValues.set("instances", baselineValues.get("instances"));
|
||||
currentValues.set("costPerHour", baselineValues.get("costPerHour"));
|
||||
currentValues.set("warningBanner", baselineValues.get("warningBanner"));
|
||||
@@ -149,6 +158,7 @@ const onEnableDedicatedGatewayChange = (
|
||||
currentValues.set("costPerHour", { value: costPerHourDefaultValue, hidden: true });
|
||||
}
|
||||
const sku = currentValues.get("sku");
|
||||
const dedicatedGatewayType = currentValues.get("dedicatedGatewayType");
|
||||
const instances = currentValues.get("instances");
|
||||
const hideAttributes = newValue === undefined || !(newValue as boolean);
|
||||
currentValues.set("sku", {
|
||||
@@ -156,6 +166,11 @@ const onEnableDedicatedGatewayChange = (
|
||||
hidden: hideAttributes,
|
||||
disabled: dedicatedGatewayOriginallyEnabled,
|
||||
});
|
||||
currentValues.set("dedicatedGatewayType", {
|
||||
value: dedicatedGatewayType.value,
|
||||
hidden: hideAttributes,
|
||||
disabled: dedicatedGatewayOriginallyEnabled,
|
||||
});
|
||||
currentValues.set("instances", {
|
||||
value: instances.value,
|
||||
hidden: hideAttributes,
|
||||
@@ -185,6 +200,15 @@ const getSkus = async (): Promise<ChoiceItem[]> => {
|
||||
return skuDropDownItems;
|
||||
};
|
||||
|
||||
const dedicatedGatewayTypeDropDownItems: ChoiceItem[] = [
|
||||
{ labelTKey: "Integrated Cache", key: IntegratedCache },
|
||||
{ labelTKey: "Distributed Query", key: DistributedQuery }
|
||||
];
|
||||
|
||||
const getDedicatedGatewayType = async (): Promise<ChoiceItem[]> => {
|
||||
return dedicatedGatewayTypeDropDownItems;
|
||||
};
|
||||
|
||||
const getInstancesMin = async (): Promise<number> => {
|
||||
return 1;
|
||||
};
|
||||
@@ -312,8 +336,9 @@ export default class SqlX extends SelfServeBaseClass {
|
||||
};
|
||||
} else {
|
||||
const sku = currentValues.get("sku")?.value as string;
|
||||
const dedicatedGatewayType = currentValues.get("dedicatedGatewayType")?.value as string;
|
||||
const instances = currentValues.get("instances").value as number;
|
||||
const operationStatusUrl = await updateDedicatedGatewayResource(sku, instances);
|
||||
const operationStatusUrl = await updateDedicatedGatewayResource(sku, dedicatedGatewayType, instances);
|
||||
return {
|
||||
operationStatusUrl: operationStatusUrl,
|
||||
portalNotification: {
|
||||
@@ -334,8 +359,9 @@ export default class SqlX extends SelfServeBaseClass {
|
||||
}
|
||||
} else {
|
||||
const sku = currentValues.get("sku")?.value as string;
|
||||
const dedicatedGatewayType = currentValues.get("dedicatedGatewayType")?.value as string;
|
||||
const instances = currentValues.get("instances").value as number;
|
||||
const operationStatusUrl = await updateDedicatedGatewayResource(sku, instances);
|
||||
const operationStatusUrl = await updateDedicatedGatewayResource(sku, dedicatedGatewayType, instances);
|
||||
return {
|
||||
operationStatusUrl: operationStatusUrl,
|
||||
portalNotification: {
|
||||
@@ -361,6 +387,7 @@ export default class SqlX extends SelfServeBaseClass {
|
||||
const defaults = new Map<string, SmartUiInput>();
|
||||
defaults.set("enableDedicatedGateway", { value: false });
|
||||
defaults.set("sku", { value: CosmosD4s, hidden: true });
|
||||
defaults.set("dedicatedGatewayType", { value: IntegratedCache, hidden: true });
|
||||
defaults.set("instances", { value: await getInstancesMin(), hidden: true });
|
||||
defaults.set("costPerHour", undefined);
|
||||
defaults.set("connectionString", undefined);
|
||||
@@ -378,6 +405,8 @@ export default class SqlX extends SelfServeBaseClass {
|
||||
if (response.status && response.status !== "Deleting") {
|
||||
defaults.set("enableDedicatedGateway", { value: true });
|
||||
defaults.set("sku", { value: response.sku, disabled: true });
|
||||
// TODO: Replace mocked value with real API response value later on initilization
|
||||
defaults.set("dedicatedGatewayType", { value: IntegratedCache, disabled: true });
|
||||
defaults.set("instances", { value: response.instances, disabled: false });
|
||||
defaults.set("costPerHour", { value: calculateCost(response.sku, response.instances) });
|
||||
defaults.set("connectionString", {
|
||||
@@ -427,6 +456,14 @@ export default class SqlX extends SelfServeBaseClass {
|
||||
})
|
||||
sku: ChoiceItem;
|
||||
|
||||
@OnChange(onDedicatedGatewayTypeChange)
|
||||
@Values({
|
||||
labelTKey: "Dedicated Gateway Type",
|
||||
choices: getDedicatedGatewayType,
|
||||
placeholderTKey: "DedicatedGatewayTypePlaceHolder",
|
||||
})
|
||||
dedicatedGatewayType: ChoiceItem;
|
||||
|
||||
@OnChange(onNumberOfInstancesChange)
|
||||
@PropertyInfo(NumberOfInstancesDropdownInfo)
|
||||
@Values({
|
||||
|
||||
Reference in New Issue
Block a user