updateServiceAccount method
Implementation
Future<void> updateServiceAccount(
String projectId,
String serviceAccountId, {
required String name,
String? displayName,
String? description,
Map<String, dynamic>? metadata,
Map<String, String>? annotations,
}) async {
final encodedProjectId = Uri.encodeComponent(projectId);
final encodedServiceAccountId = Uri.encodeComponent(serviceAccountId);
final uri = Uri.parse('$baseUrl/accounts/projects/$encodedProjectId/service-accounts/$encodedServiceAccountId');
final body = <String, dynamic>{'name': name};
if (displayName != null) {
body['display_name'] = displayName;
}
if (description != null) {
body['description'] = description;
}
if (metadata != null) {
body['metadata'] = metadata;
}
if (annotations != null) {
body['annotations'] = annotations;
}
final response = await httpClient.put(uri, body: jsonEncode(body));
if (response.statusCode >= 400) {
throw MeshagentException(
'Failed to update service account. '
'Status code: ${response.statusCode}, body: ${response.body}',
);
}
}