public void UpdateProjectConfiguration() { var projectUid = new Guid("560c2a6c-6b7e-48d8-b1a5-e4009e2d4c97"); var projectConfigurationFileRequestModel = new ProjectConfigurationFileRequestModel { MachineControlFilespaceId = Guid.NewGuid().ToString() }; var projectConfigurationModel = new ProjectConfigurationModel { FileName = "MyTestFilename.dc", FileDownloadLink = "http//whatever", FileType = ProjectConfigurationFileType.CALIBRATION.ToString(), CreatedAt = DateTime.UtcNow.ToString(), UpdatedAt = DateTime.UtcNow.ToString(), Size = 66 }; string route = $"/projects/{TRNHelper.MakeTRN(projectUid)}/configuration/CALIBRATION"; var expectedUrl = $"{baseUrl}{route}"; mockServiceResolution.Setup(m => m.ResolveRemoteServiceEndpoint( It.IsAny <string>(), It.IsAny <ApiType>(), It.IsAny <ApiVersion>(), route, It.IsAny <IList <KeyValuePair <string, string> > >())).Returns(Task.FromResult(expectedUrl)); MockUtilities.TestRequestSendsCorrectJson("update a project calibration file", mockWebRequest, null, expectedUrl, HttpMethod.Put, projectConfigurationModel, async() => { var client = ServiceProvider.GetRequiredService <ICwsProfileSettingsClient>(); var result = await client.UpdateProjectConfiguration(projectUid, ProjectConfigurationFileType.CALIBRATION, projectConfigurationFileRequestModel); Assert.NotNull(result); Assert.Equal(projectConfigurationModel.FileName, result.FileName); return(true); }); }
public Task <ProjectConfigurationModel> UpdateProjectConfiguration(Guid projectUid, ProjectConfigurationFileType projectConfigurationFileType, ProjectConfigurationFileRequestModel projectConfigurationFileRequest, IHeaderDictionary customHeaders = null) { log.LogDebug($"{nameof(UpdateProjectConfiguration)} Mock: projectUid {projectUid} projectConfigurationFileType {JsonConvert.SerializeObject(projectConfigurationFileType)} projectConfigurationFileRequest {JsonConvert.SerializeObject(projectConfigurationFileRequest)}"); var projectConfigurationModel = new ProjectConfigurationModel { FileName = "MyTestFilename.dc", FileDownloadLink = "http//whatever", FileType = ProjectConfigurationFileType.CALIBRATION.ToString(), CreatedAt = DateTime.UtcNow.ToString(), UpdatedAt = DateTime.UtcNow.ToString(), Size = 66 }; log.LogDebug($"{nameof(UpdateProjectConfiguration)} Mock: projectConfigurationModel {JsonConvert.SerializeObject(projectConfigurationModel)}"); return(Task.FromResult(projectConfigurationModel)); }
public void DeleteProjectConfiguration() { var projectUid = new Guid("560c2a6c-6b7e-48d8-b1a5-e4009e2d4c97"); var projectConfigurationFileRequestModel = new ProjectConfigurationFileRequestModel { MachineControlFilespaceId = Guid.NewGuid().ToString() }; string route = $"/projects/{TRNHelper.MakeTRN(projectUid)}/configuration/CALIBRATION"; var expectedUrl = $"{baseUrl}{route}"; mockServiceResolution.Setup(m => m.ResolveRemoteServiceEndpoint( It.IsAny <string>(), It.IsAny <ApiType>(), It.IsAny <ApiVersion>(), route, It.IsAny <IList <KeyValuePair <string, string> > >())).Returns(Task.FromResult(expectedUrl)); MockUtilities.TestRequestSendsCorrectJson("Delete a project calibration file", mockWebRequest, null, expectedUrl, HttpMethod.Delete, async() => { var client = ServiceProvider.GetRequiredService <ICwsProfileSettingsClient>(); await client.DeleteProjectConfiguration(projectUid, ProjectConfigurationFileType.CALIBRATION); return(true); }); }
///// <summary> ///// PUT https://trimble.com/connectedsiteprofilesettings/1.0/projects/{projectId}/configuration/{fileType} ///// user token ///// used by ProjectSvc v6 and v5TBC ///// </summary> public async Task <ProjectConfigurationModel> UpdateProjectConfiguration(Guid projectUid, ProjectConfigurationFileType projectConfigurationFileType, ProjectConfigurationFileRequestModel projectConfigurationFileRequest, IHeaderDictionary customHeaders = null) { log.LogDebug($"{nameof(UpdateProjectConfiguration)}: projectUid {projectUid} projectConfigurationFileType {projectConfigurationFileType} projectConfigurationFileRequest {JsonConvert.SerializeObject(projectConfigurationFileRequest)}"); var projectTrn = TRNHelper.MakeTRN(projectUid); var projectConfigurationResponse = await UpdateData <ProjectConfigurationFileRequestModel, ProjectConfigurationModel>($"/projects/{projectTrn}/configuration/{projectConfigurationFileType.ToString().ToUpper()}", projectConfigurationFileRequest, null, customHeaders); log.LogDebug($"{nameof(UpdateProjectConfiguration)}: projectConfigurationResponse {JsonConvert.SerializeObject(projectConfigurationResponse)}"); return(projectConfigurationResponse); }
public Mvc.ActionResult <ProjectConfigurationModel> UpdateProjectConfiguration(string projectTrn, string projectConfigurationType, [Mvc.FromBody] ProjectConfigurationFileRequestModel projectConfigurationFileRequest) { ProjectConfigurationModel projectConfigurationModel = null; if (_projectConfigFilesMap.ContainsKey(projectTrn) && _projectConfigFilesMap[projectTrn].ContainsKey(projectConfigurationType)) { projectConfigurationModel = _projectConfigFilesMap[projectTrn][projectConfigurationType]; if (!string.IsNullOrEmpty(projectConfigurationFileRequest.MachineControlFilespaceId)) { projectConfigurationModel.FileName = _fileSpaceIdNameMap[projectConfigurationFileRequest.MachineControlFilespaceId]; projectConfigurationModel.FileDownloadLink = $"{_baseUrl}/another_fake_download_signed_url"; } if (!string.IsNullOrEmpty(projectConfigurationFileRequest.SiteCollectorFilespaceId)) { projectConfigurationModel.SiteCollectorFileName = _fileSpaceIdNameMap[projectConfigurationFileRequest.SiteCollectorFilespaceId]; projectConfigurationModel.SiteCollectorFileDownloadLink = $"{_baseUrl}/another_fake_download_signed_url"; } } Logger.LogInformation($"{nameof(UpdateProjectConfiguration)}: projectTrn {projectTrn} projectConfigurationType {projectConfigurationType} projectConfigurationFileRequest {JsonConvert.SerializeObject(projectConfigurationFileRequest)} projectConfigurationModel {JsonConvert.SerializeObject(projectConfigurationModel)}"); if (projectConfigurationModel == null) { return(NotFound()); } return(Ok(projectConfigurationModel)); }
public ProjectConfigurationModel SaveProjectConfiguration(string projectTrn, string projectConfigurationType, [Mvc.FromBody] ProjectConfigurationFileRequestModel projectConfigurationFileRequest) { var projectConfigurationModel = new ProjectConfigurationModel { FileType = projectConfigurationType, FileName = !string.IsNullOrEmpty(projectConfigurationFileRequest.MachineControlFilespaceId) ? _fileSpaceIdNameMap[projectConfigurationFileRequest.MachineControlFilespaceId] : null, FileDownloadLink = !string.IsNullOrEmpty(projectConfigurationFileRequest.MachineControlFilespaceId) ? $"{_baseUrl}/another_fake_download_signed_url" : null, SiteCollectorFileName = !string.IsNullOrEmpty(projectConfigurationFileRequest.SiteCollectorFilespaceId) ? _fileSpaceIdNameMap[projectConfigurationFileRequest.SiteCollectorFilespaceId] : null, SiteCollectorFileDownloadLink = !string.IsNullOrEmpty(projectConfigurationFileRequest.SiteCollectorFilespaceId) ? $"{_baseUrl}/another_fake_download_signed_url" : null, }; if (!_projectConfigFilesMap.ContainsKey(projectTrn)) { _projectConfigFilesMap.Add(projectTrn, new Dictionary <string, ProjectConfigurationModel>()); } if (!_projectConfigFilesMap[projectTrn].ContainsKey(projectConfigurationType)) { _projectConfigFilesMap[projectTrn].Add(projectConfigurationType, projectConfigurationModel); } Logger.LogInformation($"{nameof(SaveProjectConfiguration)}: projectTrn {projectTrn} projectConfigurationType {projectConfigurationType} projectConfigurationFileRequest {JsonConvert.SerializeObject(projectConfigurationFileRequest)} projectConfigurationModel {JsonConvert.SerializeObject(projectConfigurationModel)}"); return(projectConfigurationModel); }