CloudEndure API - C# Client

Basic Usage

  • Add the following using statements:

    using CloudEndure.Api
    using CloudEndure.Client
    using CloudEndure.Model
  • Add the FubarCoder.RestSharp.Portable.HttpClient NuGet package

  • Use this sample code as a reference:

    // Create a new configuration object so that we can share it across our API instances
    Configuration configuration = new Configuration();
    
    // By default it targets /api/latest/ but the website seems to use /api/v5/
    // Honestly, it's probably safer to explicitly set the version.
    configuration.BasePath = "https://console.cloudendure.com/api/v5";
    
    // Create instances of the API classes you intend to use
    // At a minimum, you need an instance of AuthenticationApi
    // Make sure to provide a common Configuration instance in the constructor!
    var apiAuth = new AuthenticationApi(configuration);
    var apiProjects = new ProjectApi(configuration);
    var apiMachines = new MachinesApi(configuration);
    
    // We need access to the cookie container used by the internal RestSharp instance
    // We'll just create our own and then assign it to the underlying object.
    var cookieContainer = new System.Net.CookieContainer();
    configuration.ApiClient.RestClient.CookieContainer = cookieContainer;
    
    // Before you can make any API calls, you have to login first.
    var resultAuth = await apiAuth.LoginPostAsync(new Body1 { UserApiToken = apiToken });
    
    // The official API documentation says that the response from the /Login endpoint returns a cookie
    // It does, but the cookie doesn't actually work for authentication; all methods return HTTP 403 Unauthorized.
    // After some digging, I determined that the API doesn't expect a cookie, it expects a custom HTTP header.
    // The name of the custom header is SIMILAR to the cookie, but prefixed with "X-"
    // That said, we now have to enumerate the cookies and copy the value of the "XSRF-TOKEN" cookie.
    // We'll add a default header to our shared Configuration object so that it's passed to all subsequent API calls
    var cookies = cookieContainer.GetCookies(new Uri("https://console.cloudendure.com/"));
    foreach (Cookie cookie in cookies)
    {
        if(cookie.Name != "XSRF-TOKEN") { continue; }
        configuration.AddDefaultHeader("X-XSRF-TOKEN", cookie.Value);
    }
    
    // From here on out, you should be able to call all the API endpoints.
    // I didn't test them all, so you're on your own.
    var projectResult = await apiProjects.ProjectsGetAsync();

General

  • Request authentication in CloudEndure's API is done using session cookies.
  • A session cookie is returned upon successful execution of the "login" method.
  • This value must then be provided within the request headers of all subsequent API requests.

NOTICE: The above bullet points regarding authentication are incorrect!

Errors

Some errors are not specifically written in every method since they may always return. Those are:

  • 401 (Unauthorized) - for unauthenticated requests.
  • 405 (Method Not Allowed) - for using a method that is not supported (POST instead of GET).
  • 403 (Forbidden) - request is authenticated, but the user is not allowed to access.
  • 422 (Unprocessable Entity) - for invalid input.

Formats

All strings with date-time format are according to RFC3339. All strings with "duration" format are according to ISO8601. For example, a full day duration can be specified with "PNNNND".

This C# SDK is automatically generated by the Swagger Codegen project:

  • API version: 5
  • SDK version: 1.0.0
  • Build package: io.swagger.codegen.v3.generators.dotnet.CSharpClientCodegen

Frameworks supported

  • .NET Core >=1.0
  • .NET Framework >=4.6
  • Mono/Xamarin >=vNext
  • UWP >=10.0

Dependencies

  • FubarCoder.RestSharp.Portable.Core >=4.0.7
  • FubarCoder.RestSharp.Portable.HttpClient >=4.0.7
  • Newtonsoft.Json >=10.0.3

Installation

Generate the DLL using your preferred tool

Then include the DLL (under the bin folder) in the C# project, and use the namespaces:

using CloudEndure.Api;
using CloudEndure.Client;
using CloudEndure.Model;

Getting Started

using System;
using System.Diagnostics;
using CloudEndure.Api;
using CloudEndure.Client;
using CloudEndure.Model;

namespace Example
{
    public class Example
    {
        public void main()
        {
            var apiInstance = new AccountApi();
            var accountId = accountId_example;  // string |

            try
            {
                // Get Account information
                Account result = apiInstance.AccountsAccountIdGet(accountId);
                Debug.WriteLine(result);
            }
            catch (Exception e)
            {
                Debug.Print("Exception when calling AccountApi.AccountsAccountIdGet: " + e.Message );
            }
        }
    }
}

Documentation for API Endpoints

All URIs are relative to https://console.cloudendure.com/api/latest

Class Method HTTP request Description
AccountApi AccountsAccountIdGet GET /accounts/{accountId} Get Account information
ActionsApi ProjectsProjectIdJobsGet GET /projects/{projectId}/jobs List Jobs
ActionsApi ProjectsProjectIdJobsJobIdGet GET /projects/{projectId}/jobs/{jobId} Get Job
ActionsApi ProjectsProjectIdLaunchMachinesPost POST /projects/{projectId}/launchMachines Launch target machines
ActionsApi ProjectsProjectIdLaunchRestoreServersPost POST /projects/{projectId}/launchRestoreServers Launch restore servers
ActionsApi ProjectsProjectIdMoveMachinesPost POST /projects/{projectId}/moveMachines Moves machines to another project
ActionsApi ProjectsProjectIdPauseReplicationPost POST /projects/{projectId}/pauseReplication Pause replication
ActionsApi ProjectsProjectIdReplicasDelete DELETE /projects/{projectId}/replicas Perform Cleanup
ActionsApi ProjectsProjectIdReverseReplicationPost POST /projects/{projectId}/reverseReplication Reverse replication direction
ActionsApi ProjectsProjectIdStartReplicationPost POST /projects/{projectId}/startReplication Start replication
ActionsApi ProjectsProjectIdStopReplicationPost POST /projects/{projectId}/stopReplication Stop replication
AuthenticationApi LoginPost POST /login Login
AuthenticationApi LogoutPost POST /logout Logout
BlueprintApi ProjectsProjectIdBlueprintsBlueprintIdGet GET /projects/{projectId}/blueprints/{blueprintId} Get Blueprint
BlueprintApi ProjectsProjectIdBlueprintsBlueprintIdPatch PATCH /projects/{projectId}/blueprints/{blueprintId} Configure Blueprint
BlueprintApi ProjectsProjectIdBlueprintsGet GET /projects/{projectId}/blueprints List Blueprints
BlueprintApi ProjectsProjectIdBlueprintsPost POST /projects/{projectId}/blueprints Create Blueprint
CloudApi CloudCredentialsCredsIdRegionsGet GET /cloudCredentials/{credsId}/regions List Regions
CloudApi CloudCredentialsCredsIdRegionsRegionIdDelete DELETE /cloudCredentials/{credsId}/regions/{regionId} Delete region (VCenter)
CloudApi CloudCredentialsCredsIdRegionsRegionIdGet GET /cloudCredentials/{credsId}/regions/{regionId} Get Region
CloudApi CloudCredentialsCredsIdRegionsRegionIdPatch PATCH /cloudCredentials/{credsId}/regions/{regionId} Patch region (rename)
CloudApi CloudsGet GET /clouds List Clouds
CloudCredentialsApi CloudCredentialsCredsIdGet GET /cloudCredentials/{credsId} Get Credentials
CloudCredentialsApi CloudCredentialsCredsIdPatch PATCH /cloudCredentials/{credsId} Change Credentials
CloudCredentialsApi CloudCredentialsGet GET /cloudCredentials List Credentials
CloudCredentialsApi CloudCredentialsPost POST /cloudCredentials Create Credentials
DefaultApi AccountsAccountIdAccessGet GET /accounts/{accountId}/access get a temporary token by email
DefaultApi ExtendedAccountInfoGet GET /extendedAccountInfo Returns the extended current account information.
DefaultApi ProjectsAssignUsersPost POST /projects/assignUsers Assign User
DefaultApi ProjectsProjectIdAuditLogGet GET /projects/{projectId}/auditLog Get audit log
DefaultApi ProjectsProjectIdMachinesMachineIdForceRescanPost POST /projects/{projectId}/machines/{machineId}/forceRescan Force rescan of machine volumes.
DefaultApi ProjectsProjectIdStorageGet GET /projects/{projectId}/storage project's storage
DefaultApi ProjectsRemoveUsersPost POST /projects/removeUsers Remove User
DefaultApi ReplaceApiTokenPost POST /replaceApiToken Replaces API token
DefaultApi SetPasswordPost POST /setPassword Set password for invited user
DefaultApi UsersAssignRolesPost POST /users/assignRoles Add roles to users
DefaultApi UsersPost POST /users Create a new User
DefaultApi UsersRevokeRolesPost POST /users/revokeRoles Revoke roles from users
LicensingApi LicensesGet GET /licenses List Licenses
LicensingApi LicensesLicenseIdGet GET /licenses/{licenseId} Get License
MachinesApi ProjectsProjectIdMachinesDelete DELETE /projects/{projectId}/machines Uninstall multiple agents
MachinesApi ProjectsProjectIdMachinesGet GET /projects/{projectId}/machines List Machines
MachinesApi ProjectsProjectIdMachinesMachineIdDelete DELETE /projects/{projectId}/machines/{machineId} Uninstall agent
MachinesApi ProjectsProjectIdMachinesMachineIdGet GET /projects/{projectId}/machines/{machineId} Get a specific machine.
MachinesApi ProjectsProjectIdMachinesMachineIdPatch PATCH /projects/{projectId}/machines/{machineId} Update a machine. Accepts only Launch time updates.
MachinesApi ProjectsProjectIdMachinesPatch PATCH /projects/{projectId}/machines Batch-update multiple machines
MachinesApi ProjectsProjectIdReplicasReplicaIdGet GET /projects/{projectId}/replicas/{replicaId} Get Target Machine
ProjectApi ProjectsGet GET /projects List Projects
ProjectApi ProjectsPost POST /projects Create Project
ProjectApi ProjectsProjectIdDelete DELETE /projects/{projectId} Delete Project and all sub-resources including cloud assets other than launched target machines
ProjectApi ProjectsProjectIdGet GET /projects/{projectId} Get Project
ProjectApi ProjectsProjectIdPatch PATCH /projects/{projectId} Update Project (including partial update)
ProjectApi ProjectsProjectIdTagsGet GET /projects/{projectId}/tags Gets all instance tags of all machines in the project.
ProjectApi ProjectsProjectIdTargetCloudCredentialsPost POST /projects/{projectId}/targetCloudCredentials Set target cloud credentials
RecoveryPlansApi ProjectsProjectIdRecoveryPlansGet GET /projects/{projectId}/recoveryPlans Gets all recovery plans for the project.
RecoveryPlansApi ProjectsProjectIdRecoveryPlansPost POST /projects/{projectId}/recoveryPlans Creates a new recovery plan.
RecoveryPlansApi ProjectsProjectIdRecoveryPlansRecoveryPlanIdDelete DELETE /projects/{projectId}/recoveryPlans/{recoveryPlanId} Deletes a recovery plan.
RecoveryPlansApi ProjectsProjectIdRecoveryPlansRecoveryPlanIdGet GET /projects/{projectId}/recoveryPlans/{recoveryPlanId} Gets a recovery plan.
RecoveryPlansApi ProjectsProjectIdRecoveryPlansRecoveryPlanIdPatch PATCH /projects/{projectId}/recoveryPlans/{recoveryPlanId} Updates a new recovery plan.
RecoveryPlansApi ProjectsProjectIdRunRecoveryPlanPost POST /projects/{projectId}/runRecoveryPlan Launch a recovery plan.
ReplicationApi ProjectsProjectIdMachinesMachineIdBandwidthThrottlingGet GET /projects/{projectId}/machines/{machineId}/bandwidthThrottling Get value of network bandwidth throttling setting for Machine
ReplicationApi ProjectsProjectIdMachinesMachineIdBandwidthThrottlingPatch PATCH /projects/{projectId}/machines/{machineId}/bandwidthThrottling Set value of network bandwidth throttling setting for Machine
ReplicationApi ProjectsProjectIdMachinesMachineIdDelete DELETE /projects/{projectId}/machines/{machineId} Uninstall agent
ReplicationApi ProjectsProjectIdMachinesMachineIdPointsintimeGet GET /projects/{projectId}/machines/{machineId}/pointsintime List Available Points-in-time
ReplicationApi ProjectsProjectIdReplicationConfigurationsGet GET /projects/{projectId}/replicationConfigurations List Replication Configurations
ReplicationApi ProjectsProjectIdReplicationConfigurationsPost POST /projects/{projectId}/replicationConfigurations Create Replication Configuration
ReplicationApi ProjectsProjectIdReplicationConfigurationsReplicationConfigurationIdPatch PATCH /projects/{projectId}/replicationConfigurations/{replicationConfigurationId} Modify Replication Configuration
UserApi ChangePasswordPost POST /changePassword Change Password
UserApi MeGet GET /me Me
UserApi UsersUserIdDelete DELETE /users/{userId} Delete a User
UserApi UsersUserIdPatch PATCH /users/{userId} Modify user settings

Documentation for Models