Skip to content

Commit

Permalink
REL-996124 Updated samples
Browse files Browse the repository at this point in the history
  • Loading branch information
HueByte committed Sep 9, 2024
1 parent 49f57be commit 440d703
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Samples/DotNetClientConsole/Helpers/RelativityImportEndpoints.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,21 @@ public static class RelativityImportEndpoints
/// <returns>String representing the uri to get import sources for specified job.</returns>
public static string GetImportSourcesForJobUri(int workspaceId, Guid importId) => $"api/import-service/v1/workspaces/{workspaceId}/import-jobs/{importId}/sources";

/// <summary>
/// Get import job default location uri.
/// </summary>
/// <param name="workspaceId">Workspace ID.</param>
/// <returns>String representing the uri to get import location for specified job.</returns>
public static string GetImportJobDefaultLocationUri(int workspaceId) => $"api/import-service/v1/workspaces/{workspaceId}/import-jobs/location";

/// <summary>
/// Get import's job source default location uri.
/// </summary>
/// <param name="workspaceId">Workspace ID.</param>
/// <param name="importId">Import job ID.</param>
/// <returns>String representing the uri to get import location for specified job.</returns>
public static string GetImportSourceDefaultLocationUri(int workspaceId, Guid importId) => $"api/import-service/v1/workspaces/{workspaceId}/import-jobs/{importId}/location";

// Document Configuration section

/// <summary>
Expand Down Expand Up @@ -133,5 +148,14 @@ public static class RelativityImportEndpoints
/// <param name="sourceId">Source ID.</param>
/// <returns>String representing the uri to get errors reported during import for a single source.</returns>
public static string GetImportSourceItemErrorsUri(int workspaceId, Guid importId, Guid sourceId, int start, int length) => $"api/import-service/v1/workspaces/{workspaceId}/import-jobs/{importId}/sources/{sourceId}/itemerrors?start={start}&length={length}";

/// <summary>
/// Get import source delete uri.
/// </summary>
/// <param name="workspaceId">Workspace ID.</param>
/// <param name="importId">Import job ID.</param>
/// <param name="sourceId">Source ID.</param>
/// <returns>String representing the uri to delete parent folder of import source.</returns>
public static string GetImportSourceDeleteUri(int workspaceId, Guid importId, Guid sourceId) => $"api/import-service/v1/workspaces/{workspaceId}/import-jobs/{importId}/sources/{sourceId}/delete";
}
}
6 changes: 6 additions & 0 deletions Samples/DotNetClientConsole/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ private static void Main(string[] args)
// await sampleCollection.Sample22_ReadResponse();
// await sampleCollection.Sample23_GetDataSourceErrors();
// await sampleCollection.Sample24_DeleteSource();
// await sampleCollection.Sample25_GetLocation_Job();
// await sampleCollection.Sample26_GetLocation_Workspace();
});

try
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// <copyright file="Sample24_DeleteSource.cs" company="Relativity ODA LLC">
// © Relativity All Rights Reserved.
// </copyright>

namespace Relativity.Import.Samples.DotNetClient.SampleCollection;

using System.Text;
using Relativity.Import.Samples.DotNetClient.Helpers;

/// <summary>
/// Class containing examples of using import service SDK.
/// </summary>
public partial class ImportServiceSample
{
/// <summary>
/// Example of deleting a folder associated with a specific workspace, job, and source in Relativity.
/// </summary>
/// <returns>A <see cref="Task"/> representing the result of the asynchronous operation.</returns>
public async Task Sample24_DeleteSource()
{
// Targetted workspace ID
int workspaceId = 1036722;

// Targetted job GUID
Guid jobID = Guid.Parse("c107191e-242f-450d-bddd-b1e6d4d58e96");

// Targetted job source GUID
Guid sourceID = Guid.Parse("644eca0b-33fa-40dc-ab6f-116b6f55b421");

using HttpClient client = HttpClientHelper.CreateHttpClient();
var content = new StringContent(string.Empty, Encoding.UTF8, "application/json");

var requestUri = RelativityImportEndpoints.GetImportSourceDeleteUri(workspaceId, jobID, sourceID);
var response = await client.PostAsync(requestUri, content);
await ImportJobSampleHelper.EnsureSuccessResponse(response);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// <copyright file="Sample25_GetLocation_Job.cs" company="Relativity ODA LLC">
// © Relativity All Rights Reserved.
// </copyright>

namespace Relativity.Import.Samples.DotNetClient.SampleCollection;

using System.Text;
using Relativity.Import.Samples.DotNetClient.Helpers;

/// <summary>
/// Class containing examples of using import service SDK.
/// </summary>
public partial class ImportServiceSample
{
/// <summary>
/// Example of getting default location for import job.
/// </summary>
/// <returns>A <see cref="Task"/> representing the result of the asynchronous operation.</returns>
public async Task Sample25_GetLocation_Job()
{
// Targetted workspace ID
int workspaceId = 1036722;

// Targetted job GUID
Guid jobID = Guid.Parse("c107191e-242f-450d-bddd-b1e6d4d58e96");

using HttpClient client = HttpClientHelper.CreateHttpClient();
var content = new StringContent(string.Empty, Encoding.UTF8, "application/json");

var requestUri = RelativityImportEndpoints.GetImportSourceDefaultLocationUri(workspaceId, jobID);
var response = await client.GetAsync(requestUri);
var result = await ImportJobSampleHelper.EnsureSuccessValueResponse<string>(response);

Console.WriteLine("Default location for job with ID {0} is: {1}", jobID, result.Value);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// <copyright file="Sample26_GetLocation_Workspace.cs" company="Relativity ODA LLC">
// © Relativity All Rights Reserved.
// </copyright>

namespace Relativity.Import.Samples.DotNetClient.SampleCollection;

using System.Text;
using Relativity.Import.Samples.DotNetClient.Helpers;

/// <summary>
/// Class containing examples of using import service SDK.
/// </summary>
public partial class ImportServiceSample
{
/// <summary>
/// Example of getting default import location for workspace.
/// </summary>
/// <returns>A <see cref="Task"/> representing the result of the asynchronous operation.</returns>
public async Task Sample26_GetLocation_Workspace()
{
// Targetted workspace ID
int workspaceId = 1036722;

using HttpClient client = HttpClientHelper.CreateHttpClient();
var content = new StringContent(string.Empty, Encoding.UTF8, "application/json");

var requestUri = RelativityImportEndpoints.GetImportJobDefaultLocationUri(workspaceId);
var response = await client.GetAsync(requestUri);
var result = await ImportJobSampleHelper.EnsureSuccessValueResponse<string>(response);

Console.WriteLine("Default import location for workspace with ID {0} is: {1}", workspaceId, result.Value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@

namespace Relativity.Import.Samples.DotNetFrameworkClient.SamplesCollection
{
/// <summary>
/// Class containing examples of using import service SDK.
/// </summary>
public partial class ImportServiceSample
{
/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ namespace Relativity.Import.Samples.DotNetFrameworkClient.SamplesCollection
using System;
using System.Threading.Tasks;

/// <summary>
/// Class containing examples of using import service SDK.
/// </summary>
public partial class ImportServiceSample
{
/// <summary>
Expand Down

0 comments on commit 440d703

Please sign in to comment.