listApiKeysPage method

Future<MeshagentApiKeysPage> listApiKeysPage(
  1. String projectId,
  2. String serviceAccountId
)

Corresponds to: GET /accounts/projects/{project_id}/service-accounts/{service_account_id}/api-keys Returns a JSON dict like: { "tokens": { ... }, ... }.

Implementation

Future<MeshagentApiKeysPage> listApiKeysPage(String projectId, String serviceAccountId) async {
  final encodedProjectId = Uri.encodeComponent(projectId);
  final encodedServiceAccountId = Uri.encodeComponent(serviceAccountId);
  final uri = Uri.parse('$baseUrl/accounts/projects/$encodedProjectId/service-accounts/$encodedServiceAccountId/api-keys');
  final response = await httpClient.get(uri);

  if (response.statusCode >= 400) {
    throw MeshagentException(
      'Failed to list project API keys. '
      'Status code: ${response.statusCode}, body: ${response.body}',
    );
  }

  return MeshagentApiKeysPage.fromJson(jsonDecode(response.body) as Map<String, dynamic>);
}