TypedRest for .NET 1.3.5
build type-safe fluent-style REST API clients
TypedRest.Endpoints.Raw.BlobEndpoint Class Reference

Endpoint for a binary blob that can be downloaded or uploaded. More...

Inheritance diagram for TypedRest.Endpoints.Raw.BlobEndpoint:
TypedRest.Endpoints.EndpointBase TypedRest.Endpoints.Raw.IBlobEndpoint TypedRest.Endpoints.IEndpoint TypedRest.Endpoints.IEndpoint

Public Member Functions

 BlobEndpoint (IEndpoint referrer, Uri relativeUri)
 Creates a new blob endpoint. More...
 
 BlobEndpoint (IEndpoint referrer, string relativeUri)
 Creates a new blob endpoint. More...
 
async Task ProbeAsync (CancellationToken cancellationToken=default)
 Queries the server about capabilities of the endpoint without performing any action. More...
 
async Task< Stream > DownloadAsync (CancellationToken cancellationToken=default)
 Downloads the blob's content to a stream. More...
 
async Task UploadFromAsync (Stream stream, string? mimeType=null, CancellationToken cancellationToken=default)
 Uploads data as the blob's content from a stream. More...
 
async Task DeleteAsync (CancellationToken cancellationToken=default)
 Deletes the blob from the server. More...
 
- Public Member Functions inherited from TypedRest.Endpoints.EndpointBase
void SetDefaultLink (string rel, string? href)
 Registers one or more default links for a specific relation type. These links are used when no links with this relation type are provided by the server. This should only be called during initial setup of the endpoint. More...
 
void SetDefaultLinkTemplate (string rel, string? href)
 Registers a default link template for a specific relation type. This template is used when no template with this relation type is provided by the server. This should only be called during initial setup of the endpoint. More...
 
IReadOnlyList<(Uri uri, string? title)> GetLinks (string rel)
 Resolves all links with a specific relation type. Uses cached data from last response. More...
 
Uri Link (string rel)
 Resolves a single link with a specific relation type. Uses cached data from last response if possible. Tries lazy lookup with HTTP HEAD on cache miss. More...
 
UriTemplate GetLinkTemplate (string rel)
 Retrieves a link template with a specific relation type. Prefer IEndpoint.LinkTemplate(string,object) when possible. More...
 
Uri LinkTemplate (string rel, IDictionary< string, object > variables)
 Resolves a link template with a specific relation type. Uses cached data from last response if possible. Tries lazy lookup with HTTP HEAD on cache miss. More...
 
Uri LinkTemplate (string rel, object variables)
 Resolves a link template with a specific relation type. More...
 
override string ToString ()
 

Properties

bool? DownloadAllowed [get]
 
bool? UploadAllowed [get]
 
bool? DeleteAllowed [get]
 
- Properties inherited from TypedRest.Endpoints.EndpointBase
Uri Uri [get]
 
HttpClient HttpClient [get]
 
MediaTypeFormatter Serializer [get]
 
IErrorHandler ErrorHandler [get]
 
ILinkExtractor LinkExtractor [get]
 
- Properties inherited from TypedRest.Endpoints.IEndpoint
Uri Uri [get]
 The HTTP URI of the remote resource.
 
HttpClient HttpClient [get]
 The HTTP client used to communicate with the remote resource.
 
MediaTypeFormatter Serializer [get]
 Controls the serialization of entities sent to and received from the server.
 
IErrorHandler ErrorHandler [get]
 Handles errors in responses.
 
ILinkExtractor LinkExtractor [get]
 Extracts links from responses.
 
- Properties inherited from TypedRest.Endpoints.Raw.IBlobEndpoint
bool? DownloadAllowed [get]
 Shows whether the server has indicated that DownloadAsync is currently allowed. More...
 
bool? UploadAllowed [get]
 Shows whether the server has indicated that UploadFromAsync is currently allowed. More...
 
bool? DeleteAllowed [get]
 Shows whether the server has indicated that DeleteAsync is currently allowed. More...
 

Additional Inherited Members

- Protected Member Functions inherited from TypedRest.Endpoints.EndpointBase
 EndpointBase (Uri uri, HttpClient httpClient, MediaTypeFormatter serializer, IErrorHandler errorHandler, ILinkExtractor linkExtractor)
 Creates a new endpoint with an absolute URI. More...
 
 EndpointBase (IEndpoint referrer, Uri relativeUri)
 Creates a new endpoint with a relative URI. More...
 
 EndpointBase (IEndpoint referrer, string relativeUri)
 Creates a new endpoint with a relative URI. More...
 
virtual async Task< HttpResponseMessage > HandleAsync (Func< Task< HttpResponseMessage > > request, [CallerMemberName] string caller="unknown")
 Handles various cross-cutting concerns regarding a response message such as discovering links and handling errors. More...
 
Activity? StartActivity ([CallerMemberName] string caller="unknown")
 Starts a new Activity if there is any listener registered (e.g. OpenTelemetry), returns null otherwise. More...
 
virtual void HandleCapabilities (HttpResponseMessage response)
 Handles allowed HTTP methods and other capabilities reported by the server. More...
 
bool? IsMethodAllowed (HttpMethod method)
 Shows whether the server has indicated that a specific HTTP method is currently allowed. More...
 
- Static Protected Member Functions inherited from TypedRest.Endpoints.EndpointBase
static Func< IEndpoint, Uri, TEndpoint > GetConstructor< TEndpoint > ()
 Returns a constructor for TEndpoint as a function with a referrer an a relative URI as input. More...
 

Detailed Description

Endpoint for a binary blob that can be downloaded or uploaded.

Constructor & Destructor Documentation

◆ BlobEndpoint() [1/2]

TypedRest.Endpoints.Raw.BlobEndpoint.BlobEndpoint ( IEndpoint  referrer,
Uri  relativeUri 
)
inline

Creates a new blob endpoint.

Parameters
referrerThe endpoint used to navigate to this one.
relativeUriThe URI of this endpoint relative to the referrer 's.

◆ BlobEndpoint() [2/2]

TypedRest.Endpoints.Raw.BlobEndpoint.BlobEndpoint ( IEndpoint  referrer,
string  relativeUri 
)
inline

Creates a new blob endpoint.

Parameters
referrerThe endpoint used to navigate to this one.
relativeUriThe URI of this endpoint relative to the referrer 's. Add a ./ prefix here to imply a trailing slash referrer 's URI.

Member Function Documentation

◆ DeleteAsync()

async Task TypedRest.Endpoints.Raw.BlobEndpoint.DeleteAsync ( CancellationToken  cancellationToken = default)

Deletes the blob from the server.

Parameters
cancellationTokenUsed to cancel the request.
Exceptions
InvalidDataExceptionHttpStatusCode.BadRequest
AuthenticationExceptionHttpStatusCode.Unauthorized
UnauthorizedAccessExceptionHttpStatusCode.Forbidden
KeyNotFoundExceptionHttpStatusCode.NotFound or HttpStatusCode.Gone
HttpRequestExceptionOther non-success status code.

Implements TypedRest.Endpoints.Raw.IBlobEndpoint.

◆ DownloadAsync()

async Task< Stream > TypedRest.Endpoints.Raw.BlobEndpoint.DownloadAsync ( CancellationToken  cancellationToken = default)
inline

Downloads the blob's content to a stream.

Parameters
cancellationTokenUsed to cancel the request.
Returns
A stream with the blob's content.
Exceptions
InvalidDataExceptionHttpStatusCode.BadRequest
AuthenticationExceptionHttpStatusCode.Unauthorized
UnauthorizedAccessExceptionHttpStatusCode.Forbidden
KeyNotFoundExceptionHttpStatusCode.NotFound or HttpStatusCode.Gone
HttpRequestExceptionOther non-success status code.

Implements TypedRest.Endpoints.Raw.IBlobEndpoint.

◆ ProbeAsync()

async Task TypedRest.Endpoints.Raw.BlobEndpoint.ProbeAsync ( CancellationToken  cancellationToken = default)

Queries the server about capabilities of the endpoint without performing any action.

Parameters
cancellationTokenUsed to cancel the request.
Exceptions
AuthenticationExceptionHttpStatusCode.Unauthorized
UnauthorizedAccessExceptionHttpStatusCode.Forbidden
KeyNotFoundExceptionHttpStatusCode.NotFound or HttpStatusCode.Gone
HttpRequestExceptionOther non-success status code.

Implements TypedRest.Endpoints.Raw.IBlobEndpoint.

◆ UploadFromAsync()

async Task TypedRest.Endpoints.Raw.BlobEndpoint.UploadFromAsync ( Stream  stream,
string?  mimeType = null,
CancellationToken  cancellationToken = default 
)
inline

Uploads data as the blob's content from a stream.

Parameters
streamThe stream to read the upload data from.
mimeTypeThe MIME type of the data to upload.
cancellationTokenUsed to cancel the request.
Exceptions
InvalidDataExceptionHttpStatusCode.BadRequest
AuthenticationExceptionHttpStatusCode.Unauthorized
UnauthorizedAccessExceptionHttpStatusCode.Forbidden
HttpRequestExceptionOther non-success status code.

Implements TypedRest.Endpoints.Raw.IBlobEndpoint.


The documentation for this class was generated from the following file: