Skip to content
This repository has been archived by the owner on May 25, 2021. It is now read-only.

UpCloudLtd/upcloud-java-api

Repository files navigation

UpCloud Java API client library

DEPRECATION NOTICE

This SDK has been deprecated and won't receive more fixes, features or version updates. We suggest using our other SDK:s like UpCloud Go API, UpCloud Python API or just call UpCloud API directly.

Build Status License

This is a Java API client library that provides integration with the UpCloud API. It allows cloud resource management on UpCloud's IaaS with easy to use objects and functions for the Java programming language.

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.

Table of content

Requirements

Using the client library requires by minimum Java SE 7 while the tests need version 8.

Building the API client requires the software project management tool Maven to be installed. Follow the install instructions at their documentation.

Installation

To install the API client library onto your local Maven repository, simply execute the following command:

mvn install

To deploy it to a remote Maven repository instead, configure the settings of the repository and run the command below:

mvn deploy

Refer to the official documentation for more information.

Maven users

Add this dependency to your project's POM file:

<dependency>
    <groupId>com.upcloud</groupId>
    <artifactId>UpcloudApi</artifactId>
    <version>1.2.0</version>
    <scope>compile</scope>
</dependency>

Gradle users

Add this dependency to your project's build file:

compile "com.upcloud:UpcloudApi:1.2.0"

Others

First, generate the JAR by executing the command underneath:

mvn package

Then manually install the following JARs:

  • target/UpcloudApi-1.2.0.jar
  • target/lib/*.jar

Usage

Please follow the installation instruction and execute the following Java code:

import com.upcloud.client.*;
import com.upcloud.client.auth.*;
import com.upcloud.client.models.*;
import com.upcloud.client.api.AccountApi;

import java.io.File;
import java.util.*;

public class AccountApiExample {

    public static void main(String[] args) {
        ApiClient defaultClient = Configuration.getDefaultApiClient();

        // Configure HTTP basic authorization: baseAuth
        HttpBasicAuth baseAuth = (HttpBasicAuth) defaultClient.getAuthentication("baseAuth");
        baseAuth.setUsername(System.getenv("UPCLOUD_API_USERNAME"));
        baseAuth.setPassword(System.getenv("UPCLOUD_API_PASSWORD"));

        AccountApi apiInstance = new AccountApi();
        try {
            AccountResponse result = apiInstance.getAccount();
            System.out.println(result);
        } catch (ApiException e) {
            System.err.println("Exception when calling AccountApi#getAccount");
            e.printStackTrace();
        }
    }
}

Documentation

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

Documentation of the models

Documentation for authorization

The username and password should be saved as environmental variables while developing API applications to avoid accidentally publishing your account details.

Authentication schemes defined for the API:

baseAuth

  • Type: HTTP basic authentication

Recommendations

It's recommended to create an instance of ApiClient per thread in a multithreaded environment to avoid any potential issues.

Issues

This SDK has been deprecated so no new issues can be opened.

License

This project is distributed under the MIT License, see LICENSE.txt for more information.

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages