Interface IWorkspaceRepository
An interface that provides asynchronous methods to request, create, delete, and update IWorkspace.
Namespace: Unity.Cloud.Storage
Syntax
public interface IWorkspaceRepository
Methods
CreateWorkspaceAsync(IWorkspaceCreation, CancellationToken)
Creates and adds an IWorkspace to the repository.
Declaration
Task<IWorkspace> CreateWorkspaceAsync(IWorkspaceCreation workspaceCreation, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
IWorkspaceCreation | workspaceCreation | The IWorkspaceCreation object that contains the necessary information to create the new workspace. |
CancellationToken | cancellationToken | An optional cancellation token. |
Returns
Type | Description |
---|---|
Task<IWorkspace> | A task that results in the created IWorkspace when completed. |
Examples
Exceptions
Type | Condition |
---|---|
HttpRequestException | Thrown when the request fails to complete. See the returned StatusCode for more details. |
UnauthorizedException | |
ConnectionException | |
ForbiddenException | |
ServiceException | Thrown when service failed to execute the request. See the returned StatusCode for more details. |
DeleteWorkspaceAsync(WorkspaceId, CancellationToken)
Deletes an IWorkspace with a specified ID from the repository.
Declaration
Task DeleteWorkspaceAsync(WorkspaceId workspaceId, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
WorkspaceId | workspaceId | The ID of the workspace to delete. |
CancellationToken | cancellationToken | An optional cancellation token. |
Returns
Type | Description |
---|---|
Task | A task with no result. |
Examples
Exceptions
Type | Condition |
---|---|
HttpRequestException | Thrown when the request fails to complete. See the returned StatusCode for more details. |
UnauthorizedException | |
ConnectionException | |
ForbiddenException |
GetWorkspaceAsync(WorkspaceId, CancellationToken)
Asynchronously requests an IWorkspace with a specified ID.
Declaration
Task<IWorkspace> GetWorkspaceAsync(WorkspaceId workspaceId, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
WorkspaceId | workspaceId | A workspace Id. |
CancellationToken | cancellationToken | An optional cancellation token. |
Returns
Type | Description |
---|---|
Task<IWorkspace> | Returns a Task that results in an IWorkspace when completed. |
Examples
Exceptions
Type | Condition |
---|---|
HttpRequestException | Thrown when the request fails to complete. See the returned StatusCode for more details. |
UnauthorizedException | |
ConnectionException | |
ForbiddenException |
GetWorkspacesCountAsync(CancellationToken)
Asynchronously requests the amount of workspaces in the repository.
Declaration
Task<int> GetWorkspacesCountAsync(CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken | An optional cancellation token. |
Returns
Type | Description |
---|---|
Task<Int32> |
Examples
Exceptions
Type | Condition |
---|---|
HttpRequestException | Thrown when the request fails to complete. See the returned StatusCode for more details. |
UnauthorizedException | |
ConnectionException | |
ForbiddenException |
ListWorkspacesAsync(Range, CancellationToken)
Requests an asynchronous list of IWorkspace.
Declaration
IAsyncEnumerable<IWorkspace> ListWorkspacesAsync(Range range, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
Range | range | A range of workspaces to request. For example, Range.All will return all workspaces available, while Range(0,10) will return the first 10, if exist |
CancellationToken | cancellationToken | An optional cancellation token. |
Returns
Type | Description |
---|---|
IAsyncEnumerable<IWorkspace> | Returns an asynchronous collection of IWorkspace. |
Remarks
If the requested range cannot be served due to the existing amount of items, the results will be clamped. For example, if the repository contains 5 workspaces then Range(0,10) will return only 5 existing items and Range(10, 100) will return an empty collection.
Examples
Exceptions
Type | Condition |
---|---|
HttpRequestException | Thrown when the request fails to complete. See the returned StatusCode for more details. |
UnauthorizedException | |
ConnectionException | |
ForbiddenException |
UpdateWorkspaceAsync(WorkspaceId, IWorkspaceUpdate, CancellationToken)
Updates an IWorkspace in the repository.
Declaration
Task<IWorkspace> UpdateWorkspaceAsync(WorkspaceId workspaceId, IWorkspaceUpdate workspaceUpdate, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
WorkspaceId | workspaceId | The ID of the workspace to be updated. |
IWorkspaceUpdate | workspaceUpdate | The IWorkspaceUpdate object that contains the necessary information to update the workspace. |
CancellationToken | cancellationToken | An optional cancellation token. |
Returns
Type | Description |
---|---|
Task<IWorkspace> | A task that results in the updated IWorkspace when completed. |
Examples
Exceptions
Type | Condition |
---|---|
HttpRequestException | Thrown when the request fails to complete. See the returned StatusCode for more details. |
UnauthorizedException | |
ConnectionException | |
ForbiddenException | |
ServiceException | Thrown when service failed to execute the request. See the returned StatusCode for more details. |