getAgentSecret method
Implementation
Future<ManagedSecret> getAgentSecret({
required String projectId,
required String agentId,
required String secretId,
String? delegatedTo,
}) async {
final encodedProjectId = Uri.encodeComponent(projectId);
final encodedAgentId = Uri.encodeComponent(agentId);
final encodedSecretId = Uri.encodeComponent(secretId);
final query = <String, String>{};
if (delegatedTo != null) query['delegated_to'] = delegatedTo;
final uri = Uri.parse(
'$baseUrl/accounts/projects/$encodedProjectId/agents/$encodedAgentId/secrets/$encodedSecretId',
).replace(queryParameters: query.isEmpty ? null : query);
final response = await httpClient.get(uri);
if (response.statusCode >= 400) {
throw MeshagentException(
'Failed to get agent secret. '
'Status code: ${response.statusCode}, body: ${response.body}',
);
}
return ManagedSecret.fromJson(jsonDecode(response.body) as Map<String, dynamic>);
}