-
Notifications
You must be signed in to change notification settings - Fork 401
Expand file tree
/
Copy pathquotas.ts
More file actions
68 lines (64 loc) · 2.17 KB
/
quotas.ts
File metadata and controls
68 lines (64 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import { BETA_API_ROOT } from '../constants';
import Request, { setMethod, setParams, setURL, setXFilter } from '../request';
import type { Quota, QuotaServiceType, QuotaUsage } from './types';
import type { Filter, ResourcePage as Page, Params } from 'src/types';
/**
* getQuota
*
* Returns the details for a single quota within a particular service specified by `type`.
*
* @param quotaService { QuotaServiceType } retrieve a quota within this service type.
* @param id { number } the quota ID to look up.
* @param apiCollection { string } quota collection name (quotas/global-quotas).
*/
export const getQuota = (
quotaService: QuotaServiceType,
apiCollection: string,
id: number,
) =>
Request<Quota>(
setURL(`${BETA_API_ROOT}/${quotaService}/${apiCollection}/${id}`),
setMethod('GET'),
);
/**
* getQuotas
*
* Returns a paginated list of quotas for a particular service specified by `quotaService`.
*
* This request can be filtered on `quota_name`, `service_name` and `scope`.
*
* @param quotaService { QuotaServiceType } retrieve quotas within this service quotaService.
* @param apiCollection { string } quota API collection name (e.g. quotas, global-quotas, etc.).
* @param params { Params } query params to include in the request.
* @param filter { Filter } filters to include in the request.
*/
export const getQuotas = (
quotaService: QuotaServiceType,
apiCollection: string,
params: Params = {},
filter: Filter = {},
) =>
Request<Page<Quota>>(
setURL(`${BETA_API_ROOT}/${quotaService}/${apiCollection}`),
setMethod('GET'),
setXFilter(filter),
setParams(params),
);
/**
* getQuotaUsage
*
* Returns the usage for a single quota within a particular service specified by `type`.
*
* @param quotaService { QuotaServiceType } retrieve a quota within this service type.
* @param apiCollection { string } quota collection name (quotas/global-quotas).
* @param id { string } the quota ID to look up.
*/
export const getQuotaUsage = (
quotaService: QuotaServiceType,
apiCollection: string,
id: string,
) =>
Request<QuotaUsage>(
setURL(`${BETA_API_ROOT}/${quotaService}/${apiCollection}/${id}/usage`),
setMethod('GET'),
);