getUsageSamples method
Is the PER-PROVIDER view: one connected account's own consumption of its own plan — "my plan is 47% through its 6h window, resets at 14:20".
Is the PER-PROVIDER view: one connected account's own consumption of its own plan — "my plan is 47% through its 6h window, resets at 14:20". current is the newest instance of each lane (the headline); windows is the history behind it. Both come from ONE deduped read, so they can never disagree. The rows are the caller's OWN linked accounts, scoped to the validated principal and its subject — never another user's, and never another org's.
Parameters:
-
String account: Account narrows to ONE linked account of that provider. Empty covers every account the caller has linked there.
-
String provider: Provider is the upstream to read, e.g. anthropic. Required.
-
String range: Range is the window to read: a count and a unit — 1h, 24h, 90d, any
-
String window: Window narrows to ONE window class: 6h, day, week or month. Empty covers every class.
Implementation
Future<DashResp?> getUsageSamples({ String? account, String? provider, String? range, String? window, }) async {
final response = await getUsageSamplesWithHttpInfo( account: account, provider: provider, range: range, window: window, );
if (response.statusCode >= HttpStatus.badRequest) {
throw ApiException(response.statusCode, await _decodeBodyBytes(response));
}
// When a remote server returns no body with a status of 204, we shall not decode it.
// At the time of writing this, `dart:convert` will throw an "Unexpected end of input"
// FormatException when trying to decode an empty string.
if (response.body.isNotEmpty && response.statusCode != HttpStatus.noContent) {
return await apiClient.deserializeAsync(await _decodeBodyBytes(response), 'DashResp',) as DashResp;
}
return null;
}