Add strongly-typed HTTP API methods to ReCClient
Introduce async/sync methods for all major API controllers in ReCClient, supporting GET, POST, PUT, and DELETE with JSON serialization. Add utility methods for query building and JSON content. Mark sync wrappers as [Obsolete]. Add System.Net.Http.Json dependency and supporting usings. Introduce ResultType enum. This greatly expands ReCClient's API coverage and usability.
This commit is contained in:
@@ -30,8 +30,9 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
|
||||
<PackageReference Include="System.Net.Http" Version="4.3.4" />
|
||||
</ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="10.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Http" Version="8.0.0" />
|
||||
<PackageReference Include="System.Net.Http" Version="4.3.4" />
|
||||
<PackageReference Include="System.Net.Http.Json" Version="8.0.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@@ -1,10 +1,13 @@
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
|
||||
#if NETFRAMEWORK
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Net.Http.Json;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
#if NETFRAMEWORK
|
||||
using System.Net.Http;
|
||||
#endif
|
||||
|
||||
namespace ReC.Client
|
||||
@@ -30,6 +33,19 @@ namespace ReC.Client
|
||||
_http = httpClientFactory.CreateClient(ClientName);
|
||||
}
|
||||
|
||||
private static string BuildQuery(params (string Key, object Value)[] parameters)
|
||||
{
|
||||
var parts = parameters
|
||||
.Where(p => p.Value != null)
|
||||
.Select(p => $"{Uri.EscapeDataString(p.Key)}={Uri.EscapeDataString(Convert.ToString(p.Value, CultureInfo.InvariantCulture) ?? string.Empty)}");
|
||||
|
||||
var query = string.Join("&", parts);
|
||||
return string.IsNullOrWhiteSpace(query) ? string.Empty : $"?{query}";
|
||||
}
|
||||
|
||||
private static HttpContent ToJsonContent<T>(T payload) => JsonContent.Create(payload);
|
||||
|
||||
#region RecActionController
|
||||
/// <summary>
|
||||
/// Asynchronously invokes a ReC action for a specific profile.
|
||||
/// </summary>
|
||||
@@ -61,6 +77,690 @@ namespace ReC.Client
|
||||
return resp.IsSuccessStatusCode;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously retrieves a list of ReC actions for the configured profile.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method sends a GET request to the <c>api/RecAction</c> endpoint with optional query parameters.
|
||||
/// </remarks>
|
||||
/// <param name="profileId">The ID of the profile to retrieve actions for. If <c>null</c>, actions for all profiles are retrieved.</param>
|
||||
/// <param name="invoked">Filter for invoked actions. If <c>null</c>, both invoked and not invoked actions are retrieved.</param>
|
||||
/// <param name="cancel">A token to cancel the asynchronous operation.</param>
|
||||
/// <returns>A task representing the asynchronous operation, with a <see cref="HttpResponseMessage"/> result containing the response data.</returns>
|
||||
public Task<HttpResponseMessage> GetRecActionsAsync(long? profileId = null, bool? invoked = null, CancellationToken cancel = default)
|
||||
{
|
||||
var query = BuildQuery(("ProfileId", profileId), ("Invoked", invoked));
|
||||
return _http.GetAsync($"api/RecAction{query}", cancel);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Synchronously retrieves a list of ReC actions for the configured profile.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method sends a GET request to the <c>api/RecAction</c> endpoint with optional query parameters.
|
||||
/// This is the synchronous version of <see cref="GetRecActionsAsync(long?, bool?, CancellationToken)"/>.
|
||||
/// </remarks>
|
||||
/// <param name="profileId">The ID of the profile to retrieve actions for. If <c>null</c>, actions for all profiles are retrieved.</param>
|
||||
/// <param name="invoked">Filter for invoked actions. If <c>null</c>, both invoked and not invoked actions are retrieved.</param>
|
||||
/// <returns>A <see cref="HttpResponseMessage"/> containing the response data.</returns>
|
||||
[Obsolete("Use GetRecActionsAsync instead.")]
|
||||
public HttpResponseMessage GetRecActions(long? profileId = null, bool? invoked = null)
|
||||
=> GetRecActionsAsync(profileId, invoked).GetAwaiter().GetResult();
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously creates a new ReC action.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method sends a POST request to the <c>api/RecAction</c> endpoint with the action data as JSON.
|
||||
/// </remarks>
|
||||
/// <param name="procedure">The action data to create.</param>
|
||||
/// <param name="cancel">A token to cancel the asynchronous operation.</param>
|
||||
/// <returns>A task representing the asynchronous operation, with a <see cref="HttpResponseMessage"/> result containing the response data.</returns>
|
||||
public Task<HttpResponseMessage> CreateRecActionAsync<T>(T procedure, CancellationToken cancel = default)
|
||||
=> _http.PostAsync("api/RecAction", ToJsonContent(procedure), cancel);
|
||||
|
||||
/// <summary>
|
||||
/// Synchronously creates a new ReC action.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method sends a POST request to the <c>api/RecAction</c> endpoint with the action data as JSON.
|
||||
/// This is the synchronous version of <see cref="CreateRecActionAsync{T}(T, CancellationToken)"/>.
|
||||
/// </remarks>
|
||||
/// <param name="procedure">The action data to create.</param>
|
||||
/// <returns>A <see cref="HttpResponseMessage"/> containing the response data.</returns>
|
||||
[Obsolete("Use CreateRecActionAsync instead.")]
|
||||
public HttpResponseMessage CreateRecAction<T>(T procedure)
|
||||
=> CreateRecActionAsync(procedure).GetAwaiter().GetResult();
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously updates an existing ReC action.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method sends a PUT request to the <c>api/RecAction/{id}</c> endpoint with the updated action data as JSON.
|
||||
/// </remarks>
|
||||
/// <param name="id">The ID of the action to update.</param>
|
||||
/// <param name="procedure">The updated action data.</param>
|
||||
/// <param name="cancel">A token to cancel the asynchronous operation.</param>
|
||||
/// <returns>A task representing the asynchronous operation, with a <see cref="HttpResponseMessage"/> result containing the response data.</returns>
|
||||
public Task<HttpResponseMessage> UpdateRecActionAsync<T>(long id, T procedure, CancellationToken cancel = default)
|
||||
=> _http.PutAsync($"api/RecAction/{id}", ToJsonContent(procedure), cancel);
|
||||
|
||||
/// <summary>
|
||||
/// Synchronously updates an existing ReC action.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method sends a PUT request to the <c>api/RecAction/{id}</c> endpoint with the updated action data as JSON.
|
||||
/// This is the synchronous version of <see cref="UpdateRecActionAsync{T}(long, T, CancellationToken)"/>.
|
||||
/// </remarks>
|
||||
/// <param name="id">The ID of the action to update.</param>
|
||||
/// <param name="procedure">The updated action data.</param>
|
||||
/// <returns>A <see cref="HttpResponseMessage"/> containing the response data.</returns>
|
||||
[Obsolete("Use UpdateRecActionAsync instead.")]
|
||||
public HttpResponseMessage UpdateRecAction<T>(long id, T procedure)
|
||||
=> UpdateRecActionAsync(id, procedure).GetAwaiter().GetResult();
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously deletes one or more ReC actions.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method sends a DELETE request to the <c>api/RecAction</c> endpoint with the IDs of the actions to delete as JSON.
|
||||
/// </remarks>
|
||||
/// <param name="procedure">An object containing the IDs of the actions to delete.</param>
|
||||
/// <param name="cancel">A token to cancel the asynchronous operation.</param>
|
||||
/// <returns>A task representing the asynchronous operation, with a <see cref="HttpResponseMessage"/> result containing the response data.</returns>
|
||||
public Task<HttpResponseMessage> DeleteRecActionsAsync<T>(T procedure, CancellationToken cancel = default)
|
||||
{
|
||||
var request = new HttpRequestMessage(HttpMethod.Delete, "api/RecAction")
|
||||
{
|
||||
Content = ToJsonContent(procedure)
|
||||
};
|
||||
return _http.SendAsync(request, cancel);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Synchronously deletes one or more ReC actions.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method sends a DELETE request to the <c>api/RecAction</c> endpoint with the IDs of the actions to delete as JSON.
|
||||
/// This is the synchronous version of <see cref="DeleteRecActionsAsync{T}(T, CancellationToken)"/>.
|
||||
/// </remarks>
|
||||
/// <param name="procedure">An object containing the IDs of the actions to delete.</param>
|
||||
/// <returns>A <see cref="HttpResponseMessage"/> containing the response data.</returns>
|
||||
[Obsolete("Use DeleteRecActionsAsync instead.")]
|
||||
public HttpResponseMessage DeleteRecActions<T>(T procedure)
|
||||
=> DeleteRecActionsAsync(procedure).GetAwaiter().GetResult();
|
||||
#endregion
|
||||
|
||||
#region OutResController
|
||||
/// <summary>
|
||||
/// Asynchronously retrieves results for the configured profile.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method sends a GET request to the <c>api/OutRes</c> endpoint with optional query parameters.
|
||||
/// </remarks>
|
||||
/// <param name="id">Filter by result ID.</param>
|
||||
/// <param name="actionId">Filter by action ID.</param>
|
||||
/// <param name="profileId">Filter by profile ID.</param>
|
||||
/// <param name="cancel">A token to cancel the asynchronous operation.</param>
|
||||
/// <returns>A task representing the asynchronous operation, with a <see cref="HttpResponseMessage"/> result containing the response data.</returns>
|
||||
public Task<HttpResponseMessage> GetResultsAsync(long? id = null, long? actionId = null, long? profileId = null, CancellationToken cancel = default)
|
||||
{
|
||||
var query = BuildQuery(("Id", id), ("ActionId", actionId), ("ProfileId", profileId));
|
||||
return _http.GetAsync($"api/OutRes{query}", cancel);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Synchronously retrieves results for the configured profile.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method sends a GET request to the <c>api/OutRes</c> endpoint with optional query parameters.
|
||||
/// This is the synchronous version of <see cref="GetResultsAsync(long?, long?, long?, CancellationToken)"/>.
|
||||
/// </remarks>
|
||||
/// <param name="id">Filter by result ID.</param>
|
||||
/// <param name="actionId">Filter by action ID.</param>
|
||||
/// <param name="profileId">Filter by profile ID.</param>
|
||||
/// <returns>A <see cref="HttpResponseMessage"/> containing the response data.</returns>
|
||||
[Obsolete("Use GetResultsAsync instead.")]
|
||||
public HttpResponseMessage GetResults(long? id = null, long? actionId = null, long? profileId = null)
|
||||
=> GetResultsAsync(id, actionId, profileId).GetAwaiter().GetResult();
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously creates a new result.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method sends a POST request to the <c>api/OutRes</c> endpoint with the result data as JSON.
|
||||
/// </remarks>
|
||||
/// <param name="procedure">The result data to create.</param>
|
||||
/// <param name="cancel">A token to cancel the asynchronous operation.</param>
|
||||
/// <returns>A task representing the asynchronous operation, with a <see cref="HttpResponseMessage"/> result containing the response data.</returns>
|
||||
public Task<HttpResponseMessage> CreateResultAsync<T>(T procedure, CancellationToken cancel = default)
|
||||
=> _http.PostAsync("api/OutRes", ToJsonContent(procedure), cancel);
|
||||
|
||||
/// <summary>
|
||||
/// Synchronously creates a new result.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method sends a POST request to the <c>api/OutRes</c> endpoint with the result data as JSON.
|
||||
/// This is the synchronous version of <see cref="CreateResultAsync{T}(T, CancellationToken)"/>.
|
||||
/// </remarks>
|
||||
/// <param name="procedure">The result data to create.</param>
|
||||
/// <returns>A <see cref="HttpResponseMessage"/> containing the response data.</returns>
|
||||
[Obsolete("Use CreateResultAsync instead.")]
|
||||
public HttpResponseMessage CreateResult<T>(T procedure)
|
||||
=> CreateResultAsync(procedure).GetAwaiter().GetResult();
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously updates an existing result.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method sends a PUT request to the <c>api/OutRes/{id}</c> endpoint with the updated result data as JSON.
|
||||
/// </remarks>
|
||||
/// <param name="id">The ID of the result to update.</param>
|
||||
/// <param name="procedure">The updated result data.</param>
|
||||
/// <param name="cancel">A token to cancel the asynchronous operation.</param>
|
||||
/// <returns>A task representing the asynchronous operation, with a <see cref="HttpResponseMessage"/> result containing the response data.</returns>
|
||||
public Task<HttpResponseMessage> UpdateResultAsync<T>(long id, T procedure, CancellationToken cancel = default)
|
||||
=> _http.PutAsync($"api/OutRes/{id}", ToJsonContent(procedure), cancel);
|
||||
|
||||
/// <summary>
|
||||
/// Synchronously updates an existing result.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method sends a PUT request to the <c>api/OutRes/{id}</c> endpoint with the updated result data as JSON.
|
||||
/// This is the synchronous version of <see cref="UpdateResultAsync{T}(long, T, CancellationToken)"/>.
|
||||
/// </remarks>
|
||||
/// <param name="id">The ID of the result to update.</param>
|
||||
/// <param name="procedure">The updated result data.</param>
|
||||
/// <returns>A <see cref="HttpResponseMessage"/> containing the response data.</returns>
|
||||
[Obsolete("Use UpdateResultAsync instead.")]
|
||||
public HttpResponseMessage UpdateResult<T>(long id, T procedure)
|
||||
=> UpdateResultAsync(id, procedure).GetAwaiter().GetResult();
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously deletes one or more results.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method sends a DELETE request to the <c>api/OutRes</c> endpoint with the IDs of the results to delete as JSON.
|
||||
/// </remarks>
|
||||
/// <param name="procedure">An object containing the IDs of the results to delete.</param>
|
||||
/// <param name="cancel">A token to cancel the asynchronous operation.</param>
|
||||
/// <returns>A task representing the asynchronous operation, with a <see cref="HttpResponseMessage"/> result containing the response data.</returns>
|
||||
public Task<HttpResponseMessage> DeleteResultsAsync<T>(T procedure, CancellationToken cancel = default)
|
||||
{
|
||||
var request = new HttpRequestMessage(HttpMethod.Delete, "api/OutRes")
|
||||
{
|
||||
Content = ToJsonContent(procedure)
|
||||
};
|
||||
return _http.SendAsync(request, cancel);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Synchronously deletes one or more results.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method sends a DELETE request to the <c>api/OutRes</c> endpoint with the IDs of the results to delete as JSON.
|
||||
/// This is the synchronous version of <see cref="DeleteResultsAsync{T}(T, CancellationToken)"/>.
|
||||
/// </remarks>
|
||||
/// <param name="procedure">An object containing the IDs of the results to delete.</param>
|
||||
/// <returns>A <see cref="HttpResponseMessage"/> containing the response data.</returns>
|
||||
[Obsolete("Use DeleteResultsAsync instead.")]
|
||||
public HttpResponseMessage DeleteResults<T>(T procedure)
|
||||
=> DeleteResultsAsync(procedure).GetAwaiter().GetResult();
|
||||
#endregion
|
||||
|
||||
#region ProfileController
|
||||
/// <summary>
|
||||
/// Asynchronously retrieves a profile by ID.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method sends a GET request to the <c>api/Profile</c> endpoint with the profile ID as a query parameter.
|
||||
/// </remarks>
|
||||
/// <param name="id">The ID of the profile to retrieve.</param>
|
||||
/// <param name="includeActions">Whether to include associated actions in the response.</param>
|
||||
/// <param name="cancel">A token to cancel the asynchronous operation.</param>
|
||||
/// <returns>A task representing the asynchronous operation, with a <see cref="HttpResponseMessage"/> result containing the response data.</returns>
|
||||
public Task<HttpResponseMessage> GetProfileAsync(long id, bool includeActions = false, CancellationToken cancel = default)
|
||||
{
|
||||
var query = BuildQuery(("Id", id), ("IncludeActions", includeActions));
|
||||
return _http.GetAsync($"api/Profile{query}", cancel);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Synchronously retrieves a profile by ID.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method sends a GET request to the <c>api/Profile</c> endpoint with the profile ID as a query parameter.
|
||||
/// This is the synchronous version of <see cref="GetProfileAsync(long, bool, CancellationToken)"/>.
|
||||
/// </remarks>
|
||||
/// <param name="id">The ID of the profile to retrieve.</param>
|
||||
/// <param name="includeActions">Whether to include associated actions in the response.</param>
|
||||
/// <returns>A <see cref="HttpResponseMessage"/> containing the response data.</returns>
|
||||
[Obsolete("Use GetProfileAsync instead.")]
|
||||
public HttpResponseMessage GetProfile(long id, bool includeActions = false)
|
||||
=> GetProfileAsync(id, includeActions).GetAwaiter().GetResult();
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously creates a new profile.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method sends a POST request to the <c>api/Profile</c> endpoint with the profile data as JSON.
|
||||
/// </remarks>
|
||||
/// <param name="procedure">The profile data to create.</param>
|
||||
/// <param name="cancel">A token to cancel the asynchronous operation.</param>
|
||||
/// <returns>A task representing the asynchronous operation, with a <see cref="HttpResponseMessage"/> result containing the response data.</returns>
|
||||
public Task<HttpResponseMessage> CreateProfileAsync<T>(T procedure, CancellationToken cancel = default)
|
||||
=> _http.PostAsync("api/Profile", ToJsonContent(procedure), cancel);
|
||||
|
||||
/// <summary>
|
||||
/// Synchronously creates a new profile.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method sends a POST request to the <c>api/Profile</c> endpoint with the profile data as JSON.
|
||||
/// This is the synchronous version of <see cref="CreateProfileAsync{T}(T, CancellationToken)"/>.
|
||||
/// </remarks>
|
||||
/// <param name="procedure">The profile data to create.</param>
|
||||
/// <returns>A <see cref="HttpResponseMessage"/> containing the response data.</returns>
|
||||
[Obsolete("Use CreateProfileAsync instead.")]
|
||||
public HttpResponseMessage CreateProfile<T>(T procedure)
|
||||
=> CreateProfileAsync(procedure).GetAwaiter().GetResult();
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously updates an existing profile.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method sends a PUT request to the <c>api/Profile/{id}</c> endpoint with the updated profile data as JSON.
|
||||
/// </remarks>
|
||||
/// <param name="id">The ID of the profile to update.</param>
|
||||
/// <param name="procedure">The updated profile data.</param>
|
||||
/// <param name="cancel">A token to cancel the asynchronous operation.</param>
|
||||
/// <returns>A task representing the asynchronous operation, with a <see cref="HttpResponseMessage"/> result containing the response data.</returns>
|
||||
public Task<HttpResponseMessage> UpdateProfileAsync<T>(long id, T procedure, CancellationToken cancel = default)
|
||||
=> _http.PutAsync($"api/Profile/{id}", ToJsonContent(procedure), cancel);
|
||||
|
||||
/// <summary>
|
||||
/// Synchronously updates an existing profile.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method sends a PUT request to the <c>api/Profile/{id}</c> endpoint with the updated profile data as JSON.
|
||||
/// This is the synchronous version of <see cref="UpdateProfileAsync{T}(long, T, CancellationToken)"/>.
|
||||
/// </remarks>
|
||||
/// <param name="id">The ID of the profile to update.</param>
|
||||
/// <param name="procedure">The updated profile data.</param>
|
||||
/// <returns>A <see cref="HttpResponseMessage"/> containing the response data.</returns>
|
||||
[Obsolete("Use UpdateProfileAsync instead.")]
|
||||
public HttpResponseMessage UpdateProfile<T>(long id, T procedure)
|
||||
=> UpdateProfileAsync(id, procedure).GetAwaiter().GetResult();
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously deletes one or more profiles.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method sends a DELETE request to the <c>api/Profile</c> endpoint with the IDs of the profiles to delete as JSON.
|
||||
/// </remarks>
|
||||
/// <param name="procedure">An object containing the IDs of the profiles to delete.</param>
|
||||
/// <param name="cancel">A token to cancel the asynchronous operation.</param>
|
||||
/// <returns>A task representing the asynchronous operation, with a <see cref="HttpResponseMessage"/> result containing the response data.</returns>
|
||||
public Task<HttpResponseMessage> DeleteProfilesAsync<T>(T procedure, CancellationToken cancel = default)
|
||||
{
|
||||
var request = new HttpRequestMessage(HttpMethod.Delete, "api/Profile")
|
||||
{
|
||||
Content = ToJsonContent(procedure)
|
||||
};
|
||||
return _http.SendAsync(request, cancel);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Synchronously deletes one or more profiles.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method sends a DELETE request to the <c>api/Profile</c> endpoint with the IDs of the profiles to delete as JSON.
|
||||
/// This is the synchronous version of <see cref="DeleteProfilesAsync{T}(T, CancellationToken)"/>.
|
||||
/// </remarks>
|
||||
/// <param name="procedure">An object containing the IDs of the profiles to delete.</param>
|
||||
/// <returns>A <see cref="HttpResponseMessage"/> containing the response data.</returns>
|
||||
[Obsolete("Use DeleteProfilesAsync instead.")]
|
||||
public HttpResponseMessage DeleteProfiles<T>(T procedure)
|
||||
=> DeleteProfilesAsync(procedure).GetAwaiter().GetResult();
|
||||
#endregion
|
||||
|
||||
#region EndpointAuthController
|
||||
/// <summary>
|
||||
/// Asynchronously creates a new endpoint authentication.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method sends a POST request to the <c>api/EndpointAuth</c> endpoint with the authentication data as JSON.
|
||||
/// </remarks>
|
||||
/// <param name="procedure">The authentication data to create.</param>
|
||||
/// <param name="cancel">A token to cancel the asynchronous operation.</param>
|
||||
/// <returns>A task representing the asynchronous operation, with a <see cref="HttpResponseMessage"/> result containing the response data.</returns>
|
||||
public Task<HttpResponseMessage> CreateEndpointAuthAsync<T>(T procedure, CancellationToken cancel = default)
|
||||
=> _http.PostAsync("api/EndpointAuth", ToJsonContent(procedure), cancel);
|
||||
|
||||
/// <summary>
|
||||
/// Synchronously creates a new endpoint authentication.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method sends a POST request to the <c>api/EndpointAuth</c> endpoint with the authentication data as JSON.
|
||||
/// This is the synchronous version of <see cref="CreateEndpointAuthAsync{T}(T, CancellationToken)"/>.
|
||||
/// </remarks>
|
||||
/// <param name="procedure">The authentication data to create.</param>
|
||||
/// <returns>A <see cref="HttpResponseMessage"/> containing the response data.</returns>
|
||||
[Obsolete("Use CreateEndpointAuthAsync instead.")]
|
||||
public HttpResponseMessage CreateEndpointAuth<T>(T procedure)
|
||||
=> CreateEndpointAuthAsync(procedure).GetAwaiter().GetResult();
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously updates an existing endpoint authentication.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method sends a PUT request to the <c>api/EndpointAuth/{id}</c> endpoint with the updated authentication data as JSON.
|
||||
/// </remarks>
|
||||
/// <param name="id">The ID of the authentication to update.</param>
|
||||
/// <param name="procedure">The updated authentication data.</param>
|
||||
/// <param name="cancel">A token to cancel the asynchronous operation.</param>
|
||||
/// <returns>A task representing the asynchronous operation, with a <see cref="HttpResponseMessage"/> result containing the response data.</returns>
|
||||
public Task<HttpResponseMessage> UpdateEndpointAuthAsync<T>(long id, T procedure, CancellationToken cancel = default)
|
||||
=> _http.PutAsync($"api/EndpointAuth/{id}", ToJsonContent(procedure), cancel);
|
||||
|
||||
/// <summary>
|
||||
/// Synchronously updates an existing endpoint authentication.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method sends a PUT request to the <c>api/EndpointAuth/{id}</c> endpoint with the updated authentication data as JSON.
|
||||
/// This is the synchronous version of <see cref="UpdateEndpointAuthAsync{T}(long, T, CancellationToken)"/>.
|
||||
/// </remarks>
|
||||
/// <param name="id">The ID of the authentication to update.</param>
|
||||
/// <param name="procedure">The updated authentication data.</param>
|
||||
/// <returns>A <see cref="HttpResponseMessage"/> containing the response data.</returns>
|
||||
[Obsolete("Use UpdateEndpointAuthAsync instead.")]
|
||||
public HttpResponseMessage UpdateEndpointAuth<T>(long id, T procedure)
|
||||
=> UpdateEndpointAuthAsync(id, procedure).GetAwaiter().GetResult();
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously deletes one or more endpoint authentications.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method sends a DELETE request to the <c>api/EndpointAuth</c> endpoint with the IDs of the authentications to delete as JSON.
|
||||
/// </remarks>
|
||||
/// <param name="procedure">An object containing the IDs of the authentications to delete.</param>
|
||||
/// <param name="cancel">A token to cancel the asynchronous operation.</param>
|
||||
/// <returns>A task representing the asynchronous operation, with a <see cref="HttpResponseMessage"/> result containing the response data.</returns>
|
||||
public Task<HttpResponseMessage> DeleteEndpointAuthAsync<T>(T procedure, CancellationToken cancel = default)
|
||||
{
|
||||
var request = new HttpRequestMessage(HttpMethod.Delete, "api/EndpointAuth")
|
||||
{
|
||||
Content = ToJsonContent(procedure)
|
||||
};
|
||||
return _http.SendAsync(request, cancel);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Synchronously deletes one or more endpoint authentications.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method sends a DELETE request to the <c>api/EndpointAuth</c> endpoint with the IDs of the authentications to delete as JSON.
|
||||
/// This is the synchronous version of <see cref="DeleteEndpointAuthAsync{T}(T, CancellationToken)"/>.
|
||||
/// </remarks>
|
||||
/// <param name="procedure">An object containing the IDs of the authentications to delete.</param>
|
||||
/// <returns>A <see cref="HttpResponseMessage"/> containing the response data.</returns>
|
||||
[Obsolete("Use DeleteEndpointAuthAsync instead.")]
|
||||
public HttpResponseMessage DeleteEndpointAuth<T>(T procedure)
|
||||
=> DeleteEndpointAuthAsync(procedure).GetAwaiter().GetResult();
|
||||
#endregion
|
||||
|
||||
#region EndpointParamsController
|
||||
/// <summary>
|
||||
/// Asynchronously creates new endpoint parameters.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method sends a POST request to the <c>api/EndpointParams</c> endpoint with the parameters data as JSON.
|
||||
/// </remarks>
|
||||
/// <param name="procedure">The parameters data to create.</param>
|
||||
/// <param name="cancel">A token to cancel the asynchronous operation.</param>
|
||||
/// <returns>A task representing the asynchronous operation, with a <see cref="HttpResponseMessage"/> result containing the response data.</returns>
|
||||
public Task<HttpResponseMessage> CreateEndpointParamsAsync<T>(T procedure, CancellationToken cancel = default)
|
||||
=> _http.PostAsync("api/EndpointParams", ToJsonContent(procedure), cancel);
|
||||
|
||||
/// <summary>
|
||||
/// Synchronously creates new endpoint parameters.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method sends a POST request to the <c>api/EndpointParams</c> endpoint with the parameters data as JSON.
|
||||
/// This is the synchronous version of <see cref="CreateEndpointParamsAsync{T}(T, CancellationToken)"/>.
|
||||
/// </remarks>
|
||||
/// <param name="procedure">The parameters data to create.</param>
|
||||
/// <returns>A <see cref="HttpResponseMessage"/> containing the response data.</returns>
|
||||
[Obsolete("Use CreateEndpointParamsAsync instead.")]
|
||||
public HttpResponseMessage CreateEndpointParams<T>(T procedure)
|
||||
=> CreateEndpointParamsAsync(procedure).GetAwaiter().GetResult();
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously updates existing endpoint parameters.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method sends a PUT request to the <c>api/EndpointParams/{id}</c> endpoint with the updated parameters data as JSON.
|
||||
/// </remarks>
|
||||
/// <param name="id">The ID of the parameters to update.</param>
|
||||
/// <param name="procedure">The updated parameters data.</param>
|
||||
/// <param name="cancel">A token to cancel the asynchronous operation.</param>
|
||||
/// <returns>A task representing the asynchronous operation, with a <see cref="HttpResponseMessage"/> result containing the response data.</returns>
|
||||
public Task<HttpResponseMessage> UpdateEndpointParamsAsync<T>(long id, T procedure, CancellationToken cancel = default)
|
||||
=> _http.PutAsync($"api/EndpointParams/{id}", ToJsonContent(procedure), cancel);
|
||||
|
||||
/// <summary>
|
||||
/// Synchronously updates existing endpoint parameters.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method sends a PUT request to the <c>api/EndpointParams/{id}</c> endpoint with the updated parameters data as JSON.
|
||||
/// This is the synchronous version of <see cref="UpdateEndpointParamsAsync{T}(long, T, CancellationToken)"/>.
|
||||
/// </remarks>
|
||||
/// <param name="id">The ID of the parameters to update.</param>
|
||||
/// <param name="procedure">The updated parameters data.</param>
|
||||
/// <returns>A <see cref="HttpResponseMessage"/> containing the response data.</returns>
|
||||
[Obsolete("Use UpdateEndpointParamsAsync instead.")]
|
||||
public HttpResponseMessage UpdateEndpointParams<T>(long id, T procedure)
|
||||
=> UpdateEndpointParamsAsync(id, procedure).GetAwaiter().GetResult();
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously deletes one or more endpoint parameters.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method sends a DELETE request to the <c>api/EndpointParams</c> endpoint with the IDs of the parameters to delete as JSON.
|
||||
/// </remarks>
|
||||
/// <param name="procedure">An object containing the IDs of the parameters to delete.</param>
|
||||
/// <param name="cancel">A token to cancel the asynchronous operation.</param>
|
||||
/// <returns>A task representing the asynchronous operation, with a <see cref="HttpResponseMessage"/> result containing the response data.</returns>
|
||||
public Task<HttpResponseMessage> DeleteEndpointParamsAsync<T>(T procedure, CancellationToken cancel = default)
|
||||
{
|
||||
var request = new HttpRequestMessage(HttpMethod.Delete, "api/EndpointParams")
|
||||
{
|
||||
Content = ToJsonContent(procedure)
|
||||
};
|
||||
return _http.SendAsync(request, cancel);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Synchronously deletes one or more endpoint parameters.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method sends a DELETE request to the <c>api/EndpointParams</c> endpoint with the IDs of the parameters to delete as JSON.
|
||||
/// This is the synchronous version of <see cref="DeleteEndpointParamsAsync{T}(T, CancellationToken)"/>.
|
||||
/// </remarks>
|
||||
/// <param name="procedure">An object containing the IDs of the parameters to delete.</param>
|
||||
/// <returns>A <see cref="HttpResponseMessage"/> containing the response data.</returns>
|
||||
[Obsolete("Use DeleteEndpointParamsAsync instead.")]
|
||||
public HttpResponseMessage DeleteEndpointParams<T>(T procedure)
|
||||
=> DeleteEndpointParamsAsync(procedure).GetAwaiter().GetResult();
|
||||
#endregion
|
||||
|
||||
#region EndpointsController
|
||||
/// <summary>
|
||||
/// Asynchronously creates a new endpoint.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method sends a POST request to the <c>api/Endpoints</c> endpoint with the endpoint data as JSON.
|
||||
/// </remarks>
|
||||
/// <param name="procedure">The endpoint data to create.</param>
|
||||
/// <param name="cancel">A token to cancel the asynchronous operation.</param>
|
||||
/// <returns>A task representing the asynchronous operation, with a <see cref="HttpResponseMessage"/> result containing the response data.</returns>
|
||||
public Task<HttpResponseMessage> CreateEndpointAsync<T>(T procedure, CancellationToken cancel = default)
|
||||
=> _http.PostAsync("api/Endpoints", ToJsonContent(procedure), cancel);
|
||||
|
||||
/// <summary>
|
||||
/// Synchronously creates a new endpoint.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method sends a POST request to the <c>api/Endpoints</c> endpoint with the endpoint data as JSON.
|
||||
/// This is the synchronous version of <see cref="CreateEndpointAsync{T}(T, CancellationToken)"/>.
|
||||
/// </remarks>
|
||||
/// <param name="procedure">The endpoint data to create.</param>
|
||||
/// <returns>A <see cref="HttpResponseMessage"/> containing the response data.</returns>
|
||||
[Obsolete("Use CreateEndpointAsync instead.")]
|
||||
public HttpResponseMessage CreateEndpoint<T>(T procedure)
|
||||
=> CreateEndpointAsync(procedure).GetAwaiter().GetResult();
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously updates an existing endpoint.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method sends a PUT request to the <c>api/Endpoints/{id}</c> endpoint with the updated endpoint data as JSON.
|
||||
/// </remarks>
|
||||
/// <param name="id">The ID of the endpoint to update.</param>
|
||||
/// <param name="procedure">The updated endpoint data.</param>
|
||||
/// <param name="cancel">A token to cancel the asynchronous operation.</param>
|
||||
/// <returns>A task representing the asynchronous operation, with a <see cref="HttpResponseMessage"/> result containing the response data.</returns>
|
||||
public Task<HttpResponseMessage> UpdateEndpointAsync<T>(long id, T procedure, CancellationToken cancel = default)
|
||||
=> _http.PutAsync($"api/Endpoints/{id}", ToJsonContent(procedure), cancel);
|
||||
|
||||
/// <summary>
|
||||
/// Synchronously updates an existing endpoint.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method sends a PUT request to the <c>api/Endpoints/{id}</c> endpoint with the updated endpoint data as JSON.
|
||||
/// This is the synchronous version of <see cref="UpdateEndpointAsync{T}(long, T, CancellationToken)"/>.
|
||||
/// </remarks>
|
||||
/// <param name="id">The ID of the endpoint to update.</param>
|
||||
/// <param name="procedure">The updated endpoint data.</param>
|
||||
/// <returns>A <see cref="HttpResponseMessage"/> containing the response data.</returns>
|
||||
[Obsolete("Use UpdateEndpointAsync instead.")]
|
||||
public HttpResponseMessage UpdateEndpoint<T>(long id, T procedure)
|
||||
=> UpdateEndpointAsync(id, procedure).GetAwaiter().GetResult();
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously deletes one or more endpoints.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method sends a DELETE request to the <c>api/Endpoints</c> endpoint with the IDs of the endpoints to delete as JSON.
|
||||
/// </remarks>
|
||||
/// <param name="procedure">An object containing the IDs of the endpoints to delete.</param>
|
||||
/// <param name="cancel">A token to cancel the asynchronous operation.</param>
|
||||
/// <returns>A task representing the asynchronous operation, with a <see cref="HttpResponseMessage"/> result containing the response data.</returns>
|
||||
public Task<HttpResponseMessage> DeleteEndpointAsync<T>(T procedure, CancellationToken cancel = default)
|
||||
{
|
||||
var request = new HttpRequestMessage(HttpMethod.Delete, "api/Endpoints")
|
||||
{
|
||||
Content = ToJsonContent(procedure)
|
||||
};
|
||||
return _http.SendAsync(request, cancel);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Synchronously deletes one or more endpoints.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method sends a DELETE request to the <c>api/Endpoints</c> endpoint with the IDs of the endpoints to delete as JSON.
|
||||
/// This is the synchronous version of <see cref="DeleteEndpointAsync{T}(T, CancellationToken)"/>.
|
||||
/// </remarks>
|
||||
/// <param name="procedure">An object containing the IDs of the endpoints to delete.</param>
|
||||
/// <returns>A <see cref="HttpResponseMessage"/> containing the response data.</returns>
|
||||
[Obsolete("Use DeleteEndpointAsync instead.")]
|
||||
public HttpResponseMessage DeleteEndpoint<T>(T procedure)
|
||||
=> DeleteEndpointAsync(procedure).GetAwaiter().GetResult();
|
||||
#endregion
|
||||
|
||||
#region CommonController
|
||||
/// <summary>
|
||||
/// Asynchronously creates a new object.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method sends a POST request to the <c>api/Common</c> endpoint with the object data as JSON.
|
||||
/// </remarks>
|
||||
/// <param name="procedure">The object data to create.</param>
|
||||
/// <param name="cancel">A token to cancel the asynchronous operation.</param>
|
||||
/// <returns>A task representing the asynchronous operation, with a <see cref="HttpResponseMessage"/> result containing the response data.</returns>
|
||||
public Task<HttpResponseMessage> CreateObjectAsync<T>(T procedure, CancellationToken cancel = default)
|
||||
=> _http.PostAsync("api/Common", ToJsonContent(procedure), cancel);
|
||||
|
||||
/// <summary>
|
||||
/// Synchronously creates a new object.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method sends a POST request to the <c>api/Common</c> endpoint with the object data as JSON.
|
||||
/// This is the synchronous version of <see cref="CreateObjectAsync{T}(T, CancellationToken)"/>.
|
||||
/// </remarks>
|
||||
/// <param name="procedure">The object data to create.</param>
|
||||
/// <returns>A <see cref="HttpResponseMessage"/> containing the response data.</returns>
|
||||
[Obsolete("Use CreateObjectAsync instead.")]
|
||||
public HttpResponseMessage CreateObject<T>(T procedure)
|
||||
=> CreateObjectAsync(procedure).GetAwaiter().GetResult();
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously updates an existing object.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method sends a PUT request to the <c>api/Common</c> endpoint with the updated object data as JSON.
|
||||
/// </remarks>
|
||||
/// <param name="procedure">The updated object data.</param>
|
||||
/// <param name="cancel">A token to cancel the asynchronous operation.</param>
|
||||
/// <returns>A task representing the asynchronous operation, with a <see cref="HttpResponseMessage"/> result containing the response data.</returns>
|
||||
public Task<HttpResponseMessage> UpdateObjectAsync<T>(T procedure, CancellationToken cancel = default)
|
||||
=> _http.PutAsync("api/Common", ToJsonContent(procedure), cancel);
|
||||
|
||||
/// <summary>
|
||||
/// Synchronously updates an existing object.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method sends a PUT request to the <c>api/Common</c> endpoint with the updated object data as JSON.
|
||||
/// This is the synchronous version of <see cref="UpdateObjectAsync{T}(T, CancellationToken)"/>.
|
||||
/// </remarks>
|
||||
/// <param name="procedure">The updated object data.</param>
|
||||
/// <returns>A <see cref="HttpResponseMessage"/> containing the response data.</returns>
|
||||
[Obsolete("Use UpdateObjectAsync instead.")]
|
||||
public HttpResponseMessage UpdateObject<T>(T procedure)
|
||||
=> UpdateObjectAsync(procedure).GetAwaiter().GetResult();
|
||||
|
||||
/// <summary>
|
||||
/// Asynchronously deletes one or more objects.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method sends a DELETE request to the <c>api/Common</c> endpoint with the IDs of the objects to delete as JSON.
|
||||
/// </remarks>
|
||||
/// <param name="procedure">An object containing the IDs of the objects to delete.</param>
|
||||
/// <param name="cancel">A token to cancel the asynchronous operation.</param>
|
||||
/// <returns>A task representing the asynchronous operation, with a <see cref="HttpResponseMessage"/> result containing the response data.</returns>
|
||||
public Task<HttpResponseMessage> DeleteObjectAsync<T>(T procedure, CancellationToken cancel = default)
|
||||
{
|
||||
var request = new HttpRequestMessage(HttpMethod.Delete, "api/Common")
|
||||
{
|
||||
Content = ToJsonContent(procedure)
|
||||
};
|
||||
return _http.SendAsync(request, cancel);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Synchronously deletes one or more objects.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This method sends a DELETE request to the <c>api/Common</c> endpoint with the IDs of the objects to delete as JSON.
|
||||
/// This is the synchronous version of <see cref="DeleteObjectAsync{T}(T, CancellationToken)"/>.
|
||||
/// </remarks>
|
||||
/// <param name="procedure">An object containing the IDs of the objects to delete.</param>
|
||||
/// <returns>A <see cref="HttpResponseMessage"/> containing the response data.</returns>
|
||||
[Obsolete("Use DeleteObjectAsync instead.")]
|
||||
public HttpResponseMessage DeleteObject<T>(T procedure)
|
||||
=> DeleteObjectAsync(procedure).GetAwaiter().GetResult();
|
||||
#endregion
|
||||
|
||||
#region Static
|
||||
private static readonly IServiceCollection Services = new ServiceCollection();
|
||||
|
||||
@@ -121,4 +821,14 @@ namespace ReC.Client
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Specifies which part of the result to return for result view endpoints.
|
||||
/// </summary>
|
||||
public enum ResultType
|
||||
{
|
||||
Full,
|
||||
OnlyHeader,
|
||||
OnlyBody
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user