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
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

Constructors

View Source

RestClientBase(Nullable<TimeSpan>)

Initializes a new instance of the RestClientBase class.

Declaration
protected RestClientBase(TimeSpan? httpClientTimeout = default(TimeSpan? ))
Parameters
Type Name Description
System.Nullable<System.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 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.

View Source

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.

View Source

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.

  • View Source
Back to top Copyright © DNV GL AS. All rights reserved.