Table of Contents

Interface IVpnProfilesApi

Namespace
VpnHood.AppLib.Api
Assembly
VpnHood.AppLib.Api.dll

Represents the app's API for its VPN profiles: each an access key the app connects with.

public interface IVpnProfilesApi

Remarks

A failure comes as IAppApi describes, in process and over HTTP.

Methods

AddByAccessKey(string, CancellationToken)

Adds a VPN profile for an access key, or updates the one the app has for it.

Task<VpnProfileInfo> AddByAccessKey(string accessKey, CancellationToken cancellationToken)

Parameters

accessKey string

The access key.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<VpnProfileInfo>

A task whose result is the profile.

Exceptions

UnauthorizedAccessException

The access key is a built-in VPN profile's.

OverflowException

A duration in the access key is out of range.

InvalidDataException

accessKey holds an empty access key.

JsonException

accessKey holds no valid access key.

NotSupportedException

The access key's version is not one the app reads.

FormatException

accessKey is no valid Base64, or an endpoint or a duration in it is not valid.

ApiException

Over HTTP, the app failed with an exception of a type the transport does not rebuild, which ExceptionTypeName names, or answered with an error it does not name.

OperationCanceledException

cancellationToken was canceled: over HTTP always, in process where the call honours it.

Delete(Guid, CancellationToken)

Deletes a VPN profile, and disconnects first where it is the one connected.

Task Delete(Guid vpnProfileId, CancellationToken cancellationToken)

Parameters

vpnProfileId Guid

The VPN profile's ID.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task

A task that represents the asynchronous operation.

Remarks

It disconnects first where the VPN profile is the connected one, even where the delete then fails.

Exceptions

InvalidOperationException

The VPN profile is built into the app.

NotExistsException

No VPN profile has vpnProfileId.

ApiException

Over HTTP, the app failed with an exception of a type the transport does not rebuild, which ExceptionTypeName names, or answered with an error it does not name.

OperationCanceledException

cancellationToken was canceled: over HTTP always, in process where the call honours it.

Get(Guid, CancellationToken)

Gets a VPN profile.

Task<VpnProfileInfo> Get(Guid vpnProfileId, CancellationToken cancellationToken)

Parameters

vpnProfileId Guid

The VPN profile's ID.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<VpnProfileInfo>

A task whose result is the profile.

Exceptions

NotExistsException

No VPN profile has vpnProfileId.

ApiException

Over HTTP, the app failed with an exception of a type the transport does not rebuild, which ExceptionTypeName names, or answered with an error it does not name.

OperationCanceledException

cancellationToken was canceled: over HTTP always, in process where the call honours it.

GetAccessCode(Guid, CancellationToken)

Gets the premium code a VPN profile connects with.

Task<string> GetAccessCode(Guid vpnProfileId, CancellationToken cancellationToken)

Parameters

vpnProfileId Guid

The VPN profile's ID.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<string>

A task whose result is the premium code, or an empty string where the profile has none.

Exceptions

NotExistsException

No VPN profile has vpnProfileId.

ApiException

Over HTTP, the app failed with an exception of a type the transport does not rebuild, which ExceptionTypeName names, or answered with an error it does not name.

OperationCanceledException

cancellationToken was canceled: over HTTP always, in process where the call honours it.

GetPurchaseOptions(Guid, CancellationToken)

Gets where the person can buy a premium plan for a VPN profile.

Task<AppPurchaseOptions> GetPurchaseOptions(Guid vpnProfileId, CancellationToken cancellationToken)

Parameters

vpnProfileId Guid

The VPN profile's ID.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<AppPurchaseOptions>

A task whose result is the purchase options.

Exceptions

NotExistsException

No VPN profile has vpnProfileId.

ApiException

Over HTTP, the app failed with an exception of a type the transport does not rebuild, which ExceptionTypeName names, or answered with an error it does not name.

OperationCanceledException

cancellationToken was canceled: over HTTP always, in process where the call honours it.

Update(Guid, VpnProfileUpdateParams, CancellationToken)

Changes a VPN profile.

Task<VpnProfileInfo> Update(Guid vpnProfileId, VpnProfileUpdateParams updateParams, CancellationToken cancellationToken)

Parameters

vpnProfileId Guid

The VPN profile's ID.

updateParams VpnProfileUpdateParams

What to change; what it leaves out stays.

cancellationToken CancellationToken

The token to monitor for cancellation requests.

Returns

Task<VpnProfileInfo>

A task whose result is the profile afterwards.

Exceptions

FormatException

updateParams sets a server address that is not valid.

ArgumentException

updateParams sets a premium code that is not valid.

NotExistsException

No VPN profile has vpnProfileId.

ApiException

Over HTTP, the app failed with an exception of a type the transport does not rebuild, which ExceptionTypeName names, or answered with an error it does not name.

OperationCanceledException

cancellationToken was canceled: over HTTP always, in process where the call honours it.