getServiceAccountSecret method

Future<Secret> getServiceAccountSecret(
  1. String projectId,
  2. String serviceAccountId,
  3. String secretId, {
  4. bool includeValue = false,
})

Implementation

Future<Secret> getServiceAccountSecret(String projectId, String serviceAccountId, String secretId, {bool includeValue = false}) async {
  final encodedProjectId = Uri.encodeComponent(projectId);
  final encodedServiceAccountId = Uri.encodeComponent(serviceAccountId);
  final encodedSecretId = Uri.encodeComponent(secretId);
  final uri = Uri.parse(
    '$baseUrl/accounts/projects/$encodedProjectId/service-accounts/$encodedServiceAccountId/secrets/$encodedSecretId',
  ).replace(queryParameters: includeValue ? <String, String>{'include_value': 'true'} : null);
  final response = await httpClient.get(uri);

  if (response.statusCode >= 400) {
    throw MeshagentException('Failed to get service account secret. Status code: ${response.statusCode}, body: ${response.body}');
  }

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