Class RestClientBase
Shared base class for REST clients. It implements common functionality for REST based communication over HTTP.
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: DNVGL.One.Compute.RestClient
Assembly: DNVGL.One.Compute.WorkerHost.AzureBatch.dll
Syntax
public abstract class RestClientBase
Properties
View SourceHttpClient
Gets the HTTP client used for the REST calls.
Declaration
protected HttpClient HttpClient { get; }
Property Value
Type | Description |
---|---|
HttpClient |
Methods
View SourceGetAsync(String, CancellationToken)
Gets the resource at the specified path.
Declaration
protected Task<dynamic> GetAsync(string path, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.String | path | The path. |
System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<System.Object> | The response content, null if the resource is not found. |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | Could not get the specified resource. |
GetAsync<T>(String, CancellationToken)
Gets the resource of the specified type from the specified REST API path.
Declaration
protected Task<T> GetAsync<T>(string path, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.String | path | The path within the REST API. |
System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<T> | The response content deserialized to the specified type or default{T} if the resource is not found. |
Type Parameters
Name | Description |
---|---|
T | The type of the response content. |
Exceptions
Type | Condition |
---|---|
System.InvalidOperationException | Could not get the specified resource. |
PostAsync(String, Object, CancellationToken)
Posts the specified body at the specified path.
Declaration
protected Task<HttpResponseMessage> PostAsync(string path, object body, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
System.String | path | The path. |
System.Object | body | The body. |
System.Threading.CancellationToken | cancellationToken | The cancellation token. |
Returns
Type | Description |
---|---|
System.Threading.Tasks.Task<HttpResponseMessage> | The response message. |