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
// Generated by wuapi-codegen from the OpenAPI spec. Do not edit: run `bun run codegen`.
use crate::http::{HttpClient, Method, Request, RequestParts};
use crate::types;
/// Billable usage, and the per-project export for rebilling.
#[derive(Clone, Debug)]
pub struct UsageResource {
http: HttpClient,
}
impl UsageResource {
pub(crate) fn new(http: HttpClient) -> Self {
Self { http }
}
/// Get usage
///
/// Billable usage for the current calendar month (UTC). Organization keys only (project keys get `403 forbidden`); the `Wuapi-Project` header does not change the result.
///
/// `GET /v1/usage`
///
/// Safe to repeat: retried on timeouts, network errors, `429` and `5xx`.
pub fn get(&self) -> Request<types::Usage> {
let parts = RequestParts::new(Method::Get, "/v1/usage").retryable();
self.http.request(parts)
}
/// Get usage by project
///
/// The rebilling export for `month` (default the current month): one line per project, plus unassigned resources and totals. Organization keys only (project keys get `403 forbidden`); the `Wuapi-Project` header does not change the result.
///
/// `GET /v1/usage/by-project`
///
/// Safe to repeat: retried on timeouts, network errors, `429` and `5xx`.
pub fn by_project(&self, params: types::UsageByProjectParams) -> Request<types::UsageReport> {
let parts = RequestParts::new(Method::Get, "/v1/usage/by-project")
.query_opt("month", params.month.as_ref())
.retryable();
self.http.request(parts)
}
}