diff --git a/src/backend/function/Fusion.Resources.Functions/ApiClients/LineOrgApiClient.cs b/src/backend/function/Fusion.Resources.Functions/ApiClients/LineOrgApiClient.cs index 14e840d26..3a1518fd5 100644 --- a/src/backend/function/Fusion.Resources.Functions/ApiClients/LineOrgApiClient.cs +++ b/src/backend/function/Fusion.Resources.Functions/ApiClients/LineOrgApiClient.cs @@ -1,4 +1,5 @@ #nullable enable +using System; using System.Collections.Generic; using System.Linq; using System.Net.Http; @@ -15,6 +16,7 @@ public class LineOrgApiClient : ILineOrgApiClient public LineOrgApiClient(IHttpClientFactory httpClientFactory) { lineOrgClient = httpClientFactory.CreateClient(HttpClientNames.Application.LineOrg); + lineOrgClient.Timeout = TimeSpan.FromMinutes(5); } public async Task> GetOrgUnitDepartmentsAsync() diff --git a/src/backend/function/Fusion.Resources.Functions/ApiClients/NotificationApiClient.cs b/src/backend/function/Fusion.Resources.Functions/ApiClients/NotificationApiClient.cs index 324bf608a..ca870790b 100644 --- a/src/backend/function/Fusion.Resources.Functions/ApiClients/NotificationApiClient.cs +++ b/src/backend/function/Fusion.Resources.Functions/ApiClients/NotificationApiClient.cs @@ -14,6 +14,7 @@ public class NotificationApiClient : INotificationApiClient public NotificationApiClient(IHttpClientFactory httpClientFactory) { _client = httpClientFactory.CreateClient(HttpClientNames.Application.Notifications); + _client.Timeout = TimeSpan.FromMinutes(5); } public async Task SendNotification(SendNotificationsRequest request, Guid azureUniqueId) diff --git a/src/backend/function/Fusion.Resources.Functions/ApiClients/PeopleApiClient.cs b/src/backend/function/Fusion.Resources.Functions/ApiClients/PeopleApiClient.cs index 476d4cccc..eede90d34 100644 --- a/src/backend/function/Fusion.Resources.Functions/ApiClients/PeopleApiClient.cs +++ b/src/backend/function/Fusion.Resources.Functions/ApiClients/PeopleApiClient.cs @@ -12,11 +12,13 @@ public class PeopleApiClient : IPeopleApiClient public PeopleApiClient(IHttpClientFactory httpClientFactory) { peopleClient = httpClientFactory.CreateClient(HttpClientNames.Application.People); + peopleClient.Timeout = TimeSpan.FromMinutes(5); } public async Task GetPersonFullDepartmentAsync(Guid? personAzureUniqueId) { - var data = await peopleClient.GetAsJsonAsync($"persons/{personAzureUniqueId}?api-version=3.0"); + var data = await peopleClient.GetAsJsonAsync( + $"persons/{personAzureUniqueId}?api-version=3.0"); return data.FullDepartment; } diff --git a/src/backend/function/Fusion.Resources.Functions/ApiClients/ResourcesApiClient.cs b/src/backend/function/Fusion.Resources.Functions/ApiClients/ResourcesApiClient.cs index 3cc1f60b4..368ea2240 100644 --- a/src/backend/function/Fusion.Resources.Functions/ApiClients/ResourcesApiClient.cs +++ b/src/backend/function/Fusion.Resources.Functions/ApiClients/ResourcesApiClient.cs @@ -19,6 +19,7 @@ internal class ResourcesApiClient : IResourcesApiClient public ResourcesApiClient(IHttpClientFactory httpClientFactory, ILoggerFactory loggerFactory) { resourcesClient = httpClientFactory.CreateClient(HttpClientNames.Application.Resources); + resourcesClient.Timeout = System.TimeSpan.FromMinutes(5); log = loggerFactory.CreateLogger(); } @@ -27,7 +28,8 @@ public async Task> GetProjectsAsync() return await resourcesClient.GetAsJsonAsync>("projects"); } - public async Task> GetIncompleteDepartmentAssignedResourceAllocationRequestsForProjectAsync(ProjectReference project) + public async Task> + GetIncompleteDepartmentAssignedResourceAllocationRequestsForProjectAsync(ProjectReference project) { var data = await resourcesClient.GetAsJsonAsync>( $"projects/{project.Id}/resources/requests/?$filter=state.IsComplete eq false and isDraft eq false&$expand=orgPosition,orgPositionInstance&$top={int.MaxValue}"); @@ -35,21 +37,22 @@ public async Task> GetIncompleteDepartmen return data.Value.Where(x => x.AssignedDepartment is not null); } - public async Task> GetAllRequestsForDepartment(string departmentIdentifier) + public async Task> GetAllRequestsForDepartment( + string departmentIdentifier) { var response = await resourcesClient.GetAsJsonAsync>( $"departments/{departmentIdentifier}/resources/requests?$expand=orgPosition,orgPositionInstance,actions"); - + return response.Value.ToList(); } - public async Task> GetAllPersonnelForDepartment(string departmentIdentifier) + public async Task> GetAllPersonnelForDepartment( + string departmentIdentifier) { var response = await resourcesClient.GetAsJsonAsync>( $"departments/{departmentIdentifier}/resources/personnel?api-version=2.0&$includeCurrentAllocations=true"); return response.Value.ToList(); - } public async Task ReassignRequestAsync(ResourceAllocationRequest item, string? department) @@ -57,7 +60,8 @@ public async Task ReassignRequestAsync(ResourceAllocationRequest item, str var content = JsonConvert.SerializeObject(new { AssignedDepartment = department }); var stringContent = new StringContent(content, Encoding.UTF8, "application/json"); - var result = await resourcesClient.PatchAsync($"/projects/{item.OrgPosition!.ProjectId}/requests/{item.Id}", stringContent); + var result = await resourcesClient.PatchAsync($"/projects/{item.OrgPosition!.ProjectId}/requests/{item.Id}", + stringContent); if (result.IsSuccessStatusCode) { @@ -79,6 +83,5 @@ public InternalCollection(IEnumerable items) public IEnumerable Value { get; set; } } - } -} +} \ No newline at end of file