Show / Hide Table of Contents

Class RestClientBase

Shared base class for REST clients. It implements common functionality for REST based communication over HTTP.

Inheritance
System.Object
RestClientBase
OneComputePlatformClient
Namespace: DNVGL.One.Compute.RestClient
Assembly: DNVGL.One.Compute.WorkerHost.AzureBatch.dll
Syntax
public abstract class RestClientBase : object

Constructors

View Source

RestClientBase(Nullable<TimeSpan>)

Initializes a new instance of the RestClientBase class.

Declaration
protected RestClientBase(TimeSpan? httpClientTimeout = null)
Parameters
Type Name Description
System.Nullable<TimeSpan> httpClientTimeout

The HTTP client timeout.

Properties

View Source

HttpClient

Gets the HTTP client used for the REST calls.

Declaration
protected HttpClient HttpClient { get; }
Property Value
Type Description
HttpClient

Methods

View Source

GetAsync(String, CancellationToken)

Gets the resource at the specified path.

Declaration
protected async Task<dynamic> GetAsync(string path, CancellationToken cancellationToken = null)
Parameters
Type Name Description
System.String path

The path.

CancellationToken cancellationToken

The cancellation token.

Returns
Type Description
Task<System.Object>

The response content, null if the resource is not found.

View Source

GetAsync<T>(String, CancellationToken)

Gets the resource of the specified type from the specified REST API path.

Declaration
protected async Task<T> GetAsync<T>(string path, CancellationToken cancellationToken = null)
Parameters
Type Name Description
System.String path

The path within the REST API.

CancellationToken cancellationToken

The cancellation token.

Returns
Type Description
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.

View Source

PostAsync(String, Object, CancellationToken)

Posts the specified body at the specified path.

Declaration
protected async Task<HttpResponseMessage> PostAsync(string path, object body, CancellationToken cancellationToken = null)
Parameters
Type Name Description
System.String path

The path.

System.Object body

The body.

CancellationToken cancellationToken

The cancellation token.

Returns
Type Description
Task<HttpResponseMessage>

The response message.

  • View Source
In This Article
Back to top Copyright © DNV AS. All rights reserved.