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