mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-25 11:51:07 +00:00
* assign default throughput based on workload type * combined common logic * fix unit tests * add tests * update tests * npm run format * Update ci.yml --------- Co-authored-by: Asier Isayas <aisayas@microsoft.com>
29 lines
975 B
TypeScript
29 lines
975 B
TypeScript
import { TagNames, WorkloadType } from "Common/Constants";
|
|
import { Tags } from "Contracts/DataModels";
|
|
import { userContext } from "../UserContext";
|
|
|
|
function isVirtualNetworkFilterEnabled() {
|
|
return userContext.databaseAccount?.properties?.isVirtualNetworkFilterEnabled;
|
|
}
|
|
|
|
function isIpRulesEnabled() {
|
|
return userContext.databaseAccount?.properties?.ipRules?.length > 0;
|
|
}
|
|
|
|
function isPrivateEndpointConnectionsEnabled() {
|
|
return userContext.databaseAccount?.properties?.privateEndpointConnections?.length > 0;
|
|
}
|
|
|
|
export function isPublicInternetAccessAllowed(): boolean {
|
|
return !isVirtualNetworkFilterEnabled() && !isIpRulesEnabled() && !isPrivateEndpointConnectionsEnabled();
|
|
}
|
|
|
|
export function getWorkloadType(): WorkloadType {
|
|
const tags: Tags = userContext?.databaseAccount?.tags;
|
|
const workloadType: WorkloadType = tags && (tags[TagNames.WorkloadType] as WorkloadType);
|
|
if (!workloadType) {
|
|
return WorkloadType.None;
|
|
}
|
|
return workloadType;
|
|
}
|