deleteApiKey method

Future<void> deleteApiKey(
  1. String projectId,
  2. String serviceAccountId,
  3. String tokenId
)

Corresponds to: DELETE /accounts/projects/{project_id}/service-accounts/{service_account_id}/api-keys/{token_id} Returns 204 No Content on success (no JSON body).

Implementation

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

  if (response.statusCode >= 400) {
    throw MeshagentException(
      'Failed to delete project API key. '
      'Status code: ${response.statusCode}, body: ${response.body}',
    );
  }
  // 204 No Content -> no need to parse response body.
  return;
}