mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-20 01:11:25 +00:00
Get collection usage size with ARM metrics call (#327)
- Removed `readCollectionQuotaInfo` call. The only data we need is the usage size which we can get via the ARM metrics call instead. - Added `getCollectionUsageSize` which fetches the `DataUsage` and `IndexUsage` metrics, converts them to KB, and returns the sum as the total usage size
This commit is contained in:
@@ -33,18 +33,36 @@ export class ARMError extends Error {
|
||||
public code: string | number;
|
||||
}
|
||||
|
||||
interface ARMQueryParams {
|
||||
filter?: string;
|
||||
metricNames?: string;
|
||||
}
|
||||
|
||||
interface Options {
|
||||
host: string;
|
||||
path: string;
|
||||
apiVersion: string;
|
||||
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE" | "HEAD";
|
||||
body?: unknown;
|
||||
queryParams?: ARMQueryParams;
|
||||
}
|
||||
|
||||
// TODO: This is very similar to what is happening in ResourceProviderClient.ts. Should probably merge them.
|
||||
export async function armRequest<T>({ host, path, apiVersion, method, body: requestBody }: Options): Promise<T> {
|
||||
export async function armRequest<T>({
|
||||
host,
|
||||
path,
|
||||
apiVersion,
|
||||
method,
|
||||
body: requestBody,
|
||||
queryParams
|
||||
}: Options): Promise<T> {
|
||||
const url = new URL(path, host);
|
||||
url.searchParams.append("api-version", configContext.armAPIVersion || apiVersion);
|
||||
if (queryParams) {
|
||||
queryParams.filter && url.searchParams.append("$filter", queryParams.filter);
|
||||
queryParams.metricNames && url.searchParams.append("metricnames", queryParams.metricNames);
|
||||
}
|
||||
|
||||
const response = await window.fetch(url.href, {
|
||||
method,
|
||||
headers: {
|
||||
|
||||
Reference in New Issue
Block a user