This C# API client for the UpCloud API provides a web service interface using HTTPS. It allows extensively featured resource management on UpCloud's IaaS with easy to use functions. The API client follows the RESTful web service principles wherever possible.
The base URL for all API operations is https://api.upcloud.com/ and require basic authentication using UpCloud username and password. We recommend creating a subaccount dedicated for the API communication for security purposes. This allows you to restrict API access by servers, storages, and tags ensuring you will never accidentally affect critical systems.
- .NET 4.0 or later
- Windows Phone 7.1 (Mango)
The DLLs included in the package may not be the latest version. We recommend using [NuGet] (https://docs.nuget.org/consume/installing-nuget) to obtain the latest version of the packages:
Install-Package RestSharp
Install-Package Newtonsoft.Json
NOTE: RestSharp versions greater than 105.1.0 have a bug which causes file uploads to fail. See RestSharp#742
Run the following command to generate the DLL.
- [Mac/Linux]
/bin/sh build.sh
- [Windows]
build.bat
Then include the DLL (under the bin
folder) in the C# project, and use the namespaces:
using Upcloud.Api;
using Upcloud.Client;
using Upcloud.Model;
A .nuspec
is included with the project. You can follow the Nuget quickstart to create and publish packages.
This .nuspec
uses placeholders from the .csproj
, so build the .csproj
directly:
nuget pack -Build -OutputDirectory out Upcloud.csproj
Then, publish to a local feed or other host and consume the new package via Nuget as usual.
using System;
using System.Diagnostics;
using Upcloud.Api;
using Upcloud.Client;
using Upcloud.Model;
namespace Example
{
public class Example
{
public void main()
{
// Configure HTTP basic authorization: baseAuth
Configuration.Default.Username = Environment.GetEnvironmentVariable("UPCLOUD_USERNAME");
Configuration.Default.Password = Environment.GetEnvironmentVariable("UPCLOUD_PASSWORD");
var apiInstance = new AccountApi();
try
{
// Account information
AccountResponse result = apiInstance.GetAccount();
Debug.WriteLine(result);
}
catch (Exception e)
{
Debug.Print("Exception when calling AccountApi.GetAccount: " + e.Message );
}
}
}
}
All URIs are relative to https://api.upcloud.com/1.2
Class | Method | HTTP request | Description |
---|---|---|---|
AccountApi | GetAccount | GET /account | Account information |
FirewallApi | CreateFirewallRule | POST /server/{serverId}/firewall_rule | Create firewall rule |
FirewallApi | DeleteFirewallRule | DELETE /server/{serverId}/firewall_rule/{firewallRuleNumber} | Remove firewall rule |
FirewallApi | GetFirewallRule | GET /server/{serverId}/firewall_rule/{firewallRuleNumber} | Get firewall rule details |
FirewallApi | ServerServerIdFirewallRuleGet | GET /server/{serverId}/firewall_rule | List firewall rules |
IPAddressApi | AddIp | POST /ip_address | Assign IP address |
IPAddressApi | DeleteIp | DELETE /ip_address/{ip} | Release IP address |
IPAddressApi | GetDetails | GET /ip_address/{ip} | Get IP address details |
IPAddressApi | ListIps | GET /ip_address | List IP addresses |
IPAddressApi | ModifyIp | PUT /ip_address/{ip} | Modify IP address |
PlanApi | ListPlans | GET /plan | List available plans |
PricesApi | ListPrices | GET /price | List prices |
ServerApi | AssignTag | POST /server/{serverId}/tag/{tagList} | Assign tag to a server |
ServerApi | AttachStorage | POST /server/{serverId}/storage/attach | Attach storage |
ServerApi | CreateFirewallRule | POST /server/{serverId}/firewall_rule | Create firewall rule |
ServerApi | CreateServer | POST /server | Create server |
ServerApi | DeleteFirewallRule | DELETE /server/{serverId}/firewall_rule/{firewallRuleNumber} | Remove firewall rule |
ServerApi | DeleteServer | DELETE /server/{serverId} | Delete server |
ServerApi | DetachStorage | POST /server/{serverId}/storage/detach | Detach storage |
ServerApi | EjectCdrom | POST /server/{serverId}/cdrom/eject | Eject CD-ROM |
ServerApi | GetFirewallRule | GET /server/{serverId}/firewall_rule/{firewallRuleNumber} | Get firewall rule details |
ServerApi | ListServerConfigurations | GET /server_size | List server configurations |
ServerApi | ListServers | GET /server | List of servers |
ServerApi | LoadCdrom | POST /server/{serverId}/storage/cdrom/load | Load CD-ROM |
ServerApi | ModifyServer | PUT /server/{serverId} | Modify server |
ServerApi | RestartServer | POST /server/{serverId}/restart | Restart server |
ServerApi | ServerDetails | GET /server/{serverId} | Get server details |
ServerApi | ServerServerIdFirewallRuleGet | GET /server/{serverId}/firewall_rule | List firewall rules |
ServerApi | StartServer | POST /server/{serverId}/start | Start server |
ServerApi | StopServer | POST /server/{serverId}/stop | Stop server |
ServerApi | Untag | POST /server/{serverId}/untag/{tagName} | Remove tag from server |
StorageApi | AttachStorage | POST /server/{serverId}/storage/attach | Attach storage |
StorageApi | BackupStorage | POST /storage/{storageId}/backup | Create backup |
StorageApi | CancelOperation | POST /storage/{storageId}/cancel | Cancel storage operation |
StorageApi | CloneStorage | POST /storage/{storageId}/clone | Clone storage |
StorageApi | CreateStorage | POST /storage | Create storage |
StorageApi | DeleteStorage | DELETE /storage/{storageId} | Delete storage |
StorageApi | DetachStorage | POST /server/{serverId}/storage/detach | Detach storage |
StorageApi | EjectCdrom | POST /server/{serverId}/cdrom/eject | Eject CD-ROM |
StorageApi | FavoriteStorage | POST /storage/{storageId}/favorite | Add storage to favorites |
StorageApi | GetStorageDetails | GET /storage/{storageId} | Get storage details |
StorageApi | ListStorageTypes | GET /storage/{type}/ | List of storages by type |
StorageApi | ListStorages | GET /storage | List of storages |
StorageApi | LoadCdrom | POST /server/{serverId}/storage/cdrom/load | Load CD-ROM |
StorageApi | ModifyStorage | PUT /storage/{storageId} | Modify storage |
StorageApi | RestoreStorage | POST /storage/{storageId}/restore | Restore backup |
StorageApi | TemplatizeStorage | POST /storage/{storageId}/templatize | Templatize storage |
StorageApi | UnfavoriteStorage | DELETE /storage/{storageId}/favorite | Remove storage from favorites |
TagApi | AssignTag | POST /server/{serverId}/tag/{tagList} | Assign tag to a server |
TagApi | CreateTag | POST /tag | Create a new tag |
TagApi | DeleteTag | DELETE /tag/{tagName} | Delete tag |
TagApi | ListTags | GET /tag | List existing tags |
TagApi | ModifyTag | PUT /tag/{tagName} | Modify existing tag |
TagApi | Untag | POST /server/{serverId}/untag/{tagName} | Remove tag from server |
TimezoneApi | ListTimezones | GET /timezone | List timezones |
ZoneApi | ListZones | GET /zone | List available zones |
- Model.Account
- Model.AccountResponse
- Model.AddIpRequest
- Model.AddressFamily
- Model.AssignIpResponse
- Model.AttachStorageDeviceRequest
- Model.AvailablePlanListResponse
- Model.AvailablePlanListResponsePlans
- Model.BackupRule
- Model.CloneStorageRequest
- Model.ConfigurationListResponse
- Model.ConfigurationListResponseServerSizes
- Model.CreateBackupStorageRequest
- Model.CreateNewTagResponse
- Model.CreateServerRequest
- Model.CreateServerResponse
- Model.CreateStorageRequest
- Model.CreateStorageResponse
- Model.Error
- Model.ErrorCode
- Model.ErrorError
- Model.ErrorStatus
- Model.FirewallRule
- Model.FirewallRuleCreateResponse
- Model.FirewallRuleListResponse
- Model.FirewallRuleListResponseFirewallRules
- Model.FirewallRuleRequest
- Model.IpAddress
- Model.IpAddressListResponse
- Model.IpAddresses
- Model.ModifyIpRequest
- Model.ModifyStorageRequest
- Model.ModifyTagRequest
- Model.Plan
- Model.Price
- Model.PriceListResponse
- Model.PriceListResponsePrices
- Model.PriceZone
- Model.RestartServer
- Model.Server
- Model.ServerListResponse
- Model.ServerListResponseServers
- Model.ServerSize
- Model.ServerState
- Model.ServerStorageDevices
- Model.ServerTags
- Model.StopServer
- Model.StopServerRequest
- Model.Storage
- Model.StorageAccessType
- Model.StorageBackups
- Model.StorageDevice
- Model.StorageDeviceDetachRequest
- Model.StorageDeviceLoadRequest
- Model.StorageServers
- Model.StorageState
- Model.StorageTier
- Model.StorageType
- Model.SuccessStoragesResponse
- Model.SuccessStoragesResponseStorages
- Model.Tag
- Model.TagCreateRequest
- Model.TagListResponse
- Model.TagListResponseTags
- Model.TagServers
- Model.TemplitizeStorageRequest
- Model.Timezone
- Model.TimezoneListResponse
- Model.TimezoneListResponseTimezones
- Model.Zone
- Model.ZoneListResponse
- Model.ZoneListResponseZones
It's recommended to store the username and password as environmental variables while developing API applications to avoid accidentally publishing your account credentials.
- Type: HTTP basic authentication
- Username: Your UpCloud API username
- Password: Your UpCloud API user's password
Found a bug, have a problem using the client, or anything else about the library you would want to mention? Open a new issue here to get in contact.
This project is distributed under the MIT License, see LICENSE.txt for more information.