|
| 1 | +# stackit-sdk-iaas |
| 2 | + |
| 3 | +IaaS-API |
| 4 | + |
| 5 | +- API version: 1 |
| 6 | + |
| 7 | +This API allows you to create and modify IaaS resources. |
| 8 | + |
| 9 | +For more information, please visit [https://support.stackit.cloud/servicedesk](https://support.stackit.cloud/servicedesk) |
| 10 | + |
| 11 | +This package is part of the STACKIT Java SDK. For additional information, please visit the [GitHub repository](https://github.com/stackitcloud/stackit-sdk-java) of the SDK. |
| 12 | + |
| 13 | + |
| 14 | +## Requirements |
| 15 | + |
| 16 | +Building the API client library requires: |
| 17 | +1. Java SDK (version 11 to 21 should be supported) installed on your system |
| 18 | + |
| 19 | +## Installation |
| 20 | + |
| 21 | +To install the API client library to your local Maven repository, simply execute: |
| 22 | + |
| 23 | +```shell |
| 24 | +./gradlew publishToMavenLocal |
| 25 | +``` |
| 26 | + |
| 27 | +To deploy it to a remote Maven repository instead, configure the settings of the repository and execute: |
| 28 | + |
| 29 | +```shell |
| 30 | +# TODO: follow up story |
| 31 | +# ./gradlew publishToMavenCentral |
| 32 | +``` |
| 33 | + |
| 34 | +Refer to the [OSSRH Guide](http://central.sonatype.org/pages/ossrh-guide.html) for more information. |
| 35 | + |
| 36 | +### Maven users |
| 37 | + |
| 38 | +Add this dependency to your project's POM: |
| 39 | + |
| 40 | +```xml |
| 41 | +<dependency> |
| 42 | + <groupId>cloud.stackit</groupId> |
| 43 | + <artifactId>stackit-sdk-iaas</artifactId> |
| 44 | + <version><SDK_VERSION></version> |
| 45 | + <scope>compile</scope> |
| 46 | +</dependency> |
| 47 | +``` |
| 48 | + |
| 49 | +### Gradle users |
| 50 | + |
| 51 | +Add this dependency to your project's build file: |
| 52 | + |
| 53 | +```groovy |
| 54 | + repositories { |
| 55 | + mavenCentral() // Needed if the 'stackit-sdk-iaas' jar has been published to maven central. |
| 56 | + mavenLocal() // Needed if the 'stackit-sdk-iaas' jar has been published to the local maven repo. |
| 57 | + } |
| 58 | +
|
| 59 | + dependencies { |
| 60 | + implementation "cloud.stackit:stackit-sdk-iaas:<SDK_VERSION>" |
| 61 | + } |
| 62 | +``` |
| 63 | + |
| 64 | +### Others |
| 65 | + |
| 66 | +At first generate the JAR by executing: |
| 67 | + |
| 68 | +```shell |
| 69 | +mvn clean package |
| 70 | +``` |
| 71 | + |
| 72 | +Then manually install the following JARs: |
| 73 | + |
| 74 | +- `target/stackit-sdk-iaas-<SDK_VERSION>.jar` |
| 75 | +- `target/lib/*.jar` |
| 76 | + |
| 77 | +## Getting Started |
| 78 | + |
| 79 | +Please follow the [installation](#installation) instruction and execute the following Java code: |
| 80 | + |
| 81 | +```java |
| 82 | + |
| 83 | +import cloud.stackit.sdk.iaas.*; |
| 84 | +import cloud.stackit.sdk.iaas.auth.*; |
| 85 | +import cloud.stackit.sdk.iaas.model.*; |
| 86 | +import cloud.stackit.sdk.iaas.api.DefaultApi; |
| 87 | + |
| 88 | +public class DefaultApiExample { |
| 89 | + |
| 90 | + public static void main(String[] args) { |
| 91 | + ApiClient defaultClient = Configuration.getDefaultApiClient(); |
| 92 | + defaultClient.setBasePath("https://iaas.api.eu01.stackit.cloud"); |
| 93 | + |
| 94 | + DefaultApi apiInstance = new DefaultApi(defaultClient); |
| 95 | + UUID projectId = UUID.randomUUID(); // UUID | The identifier (ID) of a STACKIT Project. |
| 96 | + UUID serverId = UUID.randomUUID(); // UUID | The identifier (ID) of a STACKIT Server. |
| 97 | + UUID networkId = UUID.randomUUID(); // UUID | The identifier (ID) of a STACKIT Network. |
| 98 | + try { |
| 99 | + apiInstance.addNetworkToServer(projectId, serverId, networkId); |
| 100 | + } catch (ApiException e) { |
| 101 | + System.err.println("Exception when calling DefaultApi#addNetworkToServer"); |
| 102 | + System.err.println("Status code: " + e.getCode()); |
| 103 | + System.err.println("Reason: " + e.getResponseBody()); |
| 104 | + System.err.println("Response headers: " + e.getResponseHeaders()); |
| 105 | + e.printStackTrace(); |
| 106 | + } |
| 107 | + } |
| 108 | +} |
| 109 | + |
| 110 | +``` |
| 111 | + |
| 112 | +## Recommendation |
| 113 | + |
| 114 | +It's recommended to create an instance of `ApiClient` per thread in a multithreaded environment to avoid any potential issues. |
0 commit comments