getBotRuns method
List returns the caller org's live bot runs, read from the bot runtime and projected into the console contract with each run's live session URL derived here.
List returns the caller org's live bot runs, read from the bot runtime and projected into the console contract with each run's live session URL derived here. The org is ALWAYS the validated principal's org, NEVER a request field, and it is what scopes the runtime's answer — so one tenant can never enumerate another's runs. A runtime that cannot answer is an error, not an empty list: [] would tell the caller "your org has no runs", which is a different claim from "we could not ask", and the difference is the whole reason this endpoint exists.
Implementation
Future<BotRuns?> getBotRuns() async {
final response = await getBotRunsWithHttpInfo();
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), 'BotRuns',) as BotRuns;
}
return null;
}