diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml
deleted file mode 100644
index 2581fba..0000000
--- a/.github/workflows/maven.yml
+++ /dev/null
@@ -1,23 +0,0 @@
-name: Java CI
-
-on:
- push:
- branches: [ master ]
- pull_request:
-jobs:
- build:
- runs-on: ubuntu-latest
- strategy:
- matrix:
- java: [8, 11, 16, 17]
- steps:
- - name: Checkout
- uses: actions/checkout@v2
- - name: Set up JDK
- uses: actions/setup-java@v2.4.0
- with:
- distribution: 'temurin'
- java-version: ${{matrix.java}}
- cache: 'maven'
- - name: Build with Maven
- run: mvn verify -B -e -V --file pom.xml -Dgpg.skip=true
diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml
deleted file mode 100644
index fb9fbe9..0000000
--- a/.github/workflows/pages.yml
+++ /dev/null
@@ -1,23 +0,0 @@
-name: Publish Pages
-on:
- push:
- branches:
- - master
-jobs:
- build-and-deploy:
- runs-on: ubuntu-latest
- steps:
- - name: Checkout
- uses: actions/checkout@v2
-
- - name: Build
- run: |
- sudo apt-get update && sudo apt-get install -y pandoc
- mkdir ghpages
- pandoc -o ghpages/index.html README.md
-
- - name: Deploy
- uses: JamesIves/github-pages-deploy-action@4.1.5
- with:
- branch: gh-pages
- folder: ghpages
diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index 05900eb..0000000
--- a/.gitignore
+++ /dev/null
@@ -1,12 +0,0 @@
-/.classpath
-/.project
-/.settings
-/.idea
-*.iml
-/target
-/src/main/java/com/softlayer/api/service
-/gen/target
-/gen/build.log
-/examples/target
-settings.xml
-.DS_Store
diff --git a/CHANGELOG.md b/CHANGELOG.md
deleted file mode 100644
index b8b5301..0000000
--- a/CHANGELOG.md
+++ /dev/null
@@ -1,56 +0,0 @@
-# Changelog
-
-Note that new releases update the API types and services and may change or remove classes, methods, and types without
-notice.
-
-## [Unreleased]
-
-## [0.3.4] - 2021-12-17
-
-### Changed
-* Add deprecation annotations to types, properties, and methods. Deprecations may be removed in future changes to the
- API.
-
-### Changed
-* New service definitions.
-
-## [0.3.3] - 2021-09-15
-
-### Changed
-* Updated services and types.
-* Updated dependencies.
-
-## [0.3.2] - 2021-01-20
-
-### Added
-* Added support for Bearer Authentication Token Support.
-
-```java
-import com.softlayer.api.*;
-ApiClient client = new RestApiClient().withBearerToken("qqqqwwwweeeaaassddd....");
-```
-
-### Changed
-* Updated services and types.
-
-## [0.3.1] - 2020-11-09
-
-### Changed
-* Updated services and types.
-
-## [0.3.0] - 2020-03-25
-
-### Added
-* Added a new `RestApiClient.BASE_SERVICE_URL` constant to use the client with the classic infrastructure private
- network.
-
-### Changed
-* A breaking change has been made. Coerce return types to whatever the API metadata says should be returned, even if
- the type returned by the API does not match (#64).
-
-* Updated services and types.
-
-## [0.2.9] - 2020-01-21
-
-### Changed
-* Updated generated services and types.
diff --git a/LICENSE b/LICENSE
deleted file mode 100644
index 213959f..0000000
--- a/LICENSE
+++ /dev/null
@@ -1,21 +0,0 @@
-The MIT License (MIT)
-
-Copyright (c) 2021 The SoftLayer Developer Network
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
diff --git a/README.md b/README.md
deleted file mode 100644
index a771bf3..0000000
--- a/README.md
+++ /dev/null
@@ -1,315 +0,0 @@
-# SoftLayer API Client for Java
-
-[](https://github.com/softlayer/softlayer-java/actions/workflows/maven.yml)
-[](https://search.maven.org/artifact/com.softlayer.api/softlayer-api-client)
-[](https://www.javadoc.io/doc/com.softlayer.api/softlayer-api-client)
-
-## Introduction
-
-This library provides a JVM client for the [SoftLayer API](https://sldn.softlayer.com/article/getting-started/). It
-has code generated and compiled via Maven. The client can work with any Java 8+ runtime. It uses the code generation
-project in `gen/` to generate the service and type related code. Although likely to work in resource-constrained
-environments (i.e. Android, J2ME, etc), using this is not recommended; Use the
-[REST](https://sldn.softlayer.com/article/rest/) API instead.
-
-By default the HTTP client is the Java `HttpUrlConnection` and the JSON marshalling is done by
-[Gson](https://github.com/google/gson). Both of these pieces can be exchanged for alternative implementations
-(see below).
-
-The `examples/` project has sample uses of the API. It can be executed from Maven while inside the `examples/` folder
-via a command:
-
- mvn -q compile exec:java -Dexec.args="EXAMPLE_NAME API_USER API_KEY"
-
-Where `EXAMPLE_NAME` is the unqualified class name of an example in the `com.softlayer.api.example` package (e.g.
-`ListServers`), `API_USER` is your API username, and `API_KEY` is your API key. NOTE: Some examples order virtual
-servers and may charge your account.
-
-## Using
-
-Add the library as a dependency using your favorite build tooling.
-
-Note that the published client library is built upon the state of the API at the time of the version's release.
-It will contain the generated artifacts as of that time only.
-See "Building" for more information on how to regenerate the artifacts to get regular
-additions to the SoftLayer API.
-
-### Maven
-
-```xml
-
- com.softlayer.api
- softlayer-api-client
- 0.3.4
-
-```
-
-### Gradle
-
-```groovy
-implementation 'com.softlayer.api:softlayer-api-client:0.3.4'
-```
-
-### Kotlin
-
-```kotlin
-compile("com.softlayer.api:softlayer-api-client:0.3.4")
-```
-
-### Creating a Client
-
-All clients are instances of `ApiClient`. Currently there is only one implementation, the `RestApiClient`. Simply
-instantiate it and provide your credentials:
-
-
-#### Username and API Key
-For using a Classic Infrastructure or IBM Cloud API key. When using the IBM Cloud Api key, your username is the literal string `apikey`, more information about that can be found on the SLDN [Authenticating to the SoftLayer API](https://sldn.softlayer.com/article/authenticating-softlayer-api/#cloud-api) article.
-
-:warning: Make sure to avoid hard coding your username and API key when using the client! Always pull credentials from the environment, secure config, or other source.
-
-```java
-import com.softlayer.api.*;
-
-ApiClient client = new RestApiClient().withCredentials(myUser, myApiKey);
-```
-
-#### Access Token
-Information on how to get a temporary api token can be found on the SLDN
-[Authenticating to the SoftLayer API](https://sldn.softlayer.com/article/authenticating-softlayer-api/#temp-token)
-article.
-
-```java
-import com.softlayer.api.*;
-ApiClient client = new RestApiClient().withBearerToken(myBearerToken);
-```
-
-If the end point isn't at the normal SoftLayer API, you can provide the prefix to the constructor of the
-`RestApiClient`. By default, it is set to the public API endpoint, `https://api.softlayer.com/rest/v3.1/`.
-
-If you are using the classic infrastructure private network, you can communicate with the API over that network by using the service URL instead:
-
-```java
-ApiClient client = new RestApiClient(RestApiClient.BASE_SERVICE_URL)
- .withCredentials(myUser, myApiKey);
-```
-
-### Making API Calls
-
-Once a client is created, it can be used to access services. There are hundreds of services to control your SoftLayer
-account. A simple one is the `Account` service. Here's a call to get all of the hardware on the account:
-
-```java
-import com.softlayer.api.service.Account;
-import com.softlayer.api.service.Hardware;
-
-for (Hardware hardware : Account.service(client).getHardware()) {
- System.out.println("Hardware: " + hardware.getFullyQualifiedDomainName());
-}
-```
-
-Some calls on a service require an ID to know what object to act on. This can be obtained by passing in the numeric ID
-into the `service` method or by calling `asService` on an object that has an ID. Here's an example of soft-rebooting a
-virtual server with "reboot-test" as the hostname:
-
-```java
-import com.softlayer.api.service.virtual.Guest;
-
-for (Guest guest : Account.service(client).getVirtualGuests()) {
- if ("reboot-test".equals(guest.getHostname())) {
- guest.asService(client).rebootSoft();
- }
-}
-```
-
-Some calls require sending in data. This is done by just instantiating the object and populating the data. Here's an
-example of ordering a new virtual server: (Note running this can charge your account)
-
-```java
-import com.softlayer.api.service.virtual.Guest;
-
-Guest guest = new Guest();
-guest.setHostname("myhostname");
-guest.setDomain("example.com");
-guest.setStartCpus(1);
-guest.setMaxMemory(1024);
-guest.setHourlyBillingFlag(true);
-guest.setOperatingSystemReferenceCode("UBUNTU_LATEST");
-guest.setLocalDiskFlag(false);
-guest.setDatacenter(new Location());
-guest.getDatacenter().setName("dal05");
-guest = Guest.service(client).createObject(guest);
-System.out.println("Virtual server ordered with ID: " + guest.getId());
-```
-
-### Using Object Masks
-
-Object masks are a great way to reduce the number of API calls to traverse the data graph of an object. For example,
-here's how by just asking for an account, you can retrieve all your VLANs, their datacenter, and the firewall rules that
-are on them:
-
-```java
-import com.softlayer.api.service.Account;
-import com.softlayer.api.service.network.Vlan;
-import com.softlayer.api.service.network.vlan.firewall.Rule;
-
-Account.Service service = Account.service(client);
-service.withMask().networkVlans().vlanNumber();
-service.withMask().networkVlans().primaryRouter().datacenter().longName();
-service.withMask().networkVlans().firewallRules().
- orderValue().
- sourceIpAddress().
- sourceIpCidr();
-
-for (Vlan vlan : service.getObject().getNetworkVlans()) {
- for (Rule rule : vlan.getFirewallRules()) {
- System.out.format("Rule %d on VLAN %d in %s has some restriction on subnet %s/%d\n",
- rule.getOrderValue(), vlan.getVlanNumber(),
- vlan.getPrimaryRouter().getDatacenter().getLongName(),
- rule.getSourceIpAddress(), rule.getSourceIpCidr());
- }
-}
-```
-
-All values of a type can be masked upon. If a value represents a primitive or collection of primitives, the same mask
-it is called on is returned. Otherwise the mask of the other type is given. These translate into SoftLayer's
-[string-based object mask format](https://sldn.softlayer.com/article/object-masks/). A string or an instance of a mask
-can be given directly by calling `setMask` on the service. Note, when object masks are added on a service object, they
-will be sent with every service call unless removed via `clearMask` or overwritten via `withNewMask` or `setMask`.
-
-### Asynchronous Invocation
-
-All services also provide an asynchronous interface. This can be obtained from a service by calling `asAsync`. Here's an
-example of getting all top level billing items and listing when they were created:
-
-```java
-import java.util.List;
-import com.softlayer.api.service.ResponseHandler;
-import com.softlayer.api.service.Account;
-import com.softlayer.api.service.billing.Item;
-
-Account.service(client).asAsync().getAllTopLevelBillingItems(new ResponseHandler>() {
- @Override
- public void onError(Exception ex) {
- ex.printStackTrace();
- }
-
- @Override
- public void onSuccess(List items) {
- for (Item item : items) {
- System.out.format("Billing item %s created on %s\n", item.getDescription(), item.getCreateDate());
- }
- }
-}).get();
-```
-
-Using the default HTTP client, this runs the call in a separate thread and calls the handler parameter upon completion.
-The `get` at the end basically makes it wait forever so the application doesn't exit out from under us. With the default
-HTTP client the asynchronous invocations are handled by a simple thread pool that defaults to a cached thread pool that
-creates daemon threads. It can be changed:
-
-```java
-import java.util.concurrent.Executors;
-import java.util.concurrent.ExecutorService;
-import com.softlayer.api.service.RestApiClient;
-import com.softlayer.api.service.http.ThreadPoolHttpClientFactory;
-import com.softlayer.api.service.billing.Item;
-
-RestApiClient client = new RestApiClient();
-ExecutorService threadPool = Executors.newFixedThreadPool(3);
-((ThreadPoolHttpClientFactory) client.getHttpClientFactory()).setThreadPool(threadPool);
-```
-
-Unlike using the default thread pool, you will be responsible for shutting down this overridden thread pool as
-necessary. Other HTTP client implementations may handle asynchrony differently and not use thread pools at all.
-
-In addition to the callback-style above, can also get the response as a `Future`. Here's an example of waiting 10
-seconds to get all top level billing items:
-
-```java
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.Future;
-import com.softlayer.api.service.Account;
-import com.softlayer.api.service.billing.Item;
-
-Future> response = Account.service(client).asAsync().getAllTopLevelBillingItems();
-List items = response.get(10, TimeUnit.SECONDS);
-for (Item item : items) {
- System.out.format("Billing item %s created on %s\n", item.getDescription(), item.getCreateDate());
-}
-```
-
-### Thread Safety
-
-No class in this library is guaranteed to be thread-safe. Callers are expected to keep this in mind when developing
-with the library and to never use the same `ApiClient` (or any other object created with it) concurrently across
-threads.
-
-### Pagination
-
-Sometimes there is a need to get the responses from the SoftLayer API in a paginated way instead of all at once. This
-can be done by utilizing result limits. A result limit can be passed in with the number of results requested and the
-offset to start reading from. Requesting smaller amounts of data will increase the performance of the call. Here is an
-example of obtaining the first 10 tickets and outputting the total:
-
-```java
-import com.softlayer.api.ResultLimit;
-import com.softlayer.api.service.Account;
-import com.softlayer.api.service.Ticket;
-
-Account.Service service = Account.service(client);
-service.setResultLimit(new ResultLimit(10));
-for (Ticket ticket : service.getTickets()) {
- System.out.println("Got ticket " + ticket.getTitle());
-}
-System.out.println("Total tickets on the account: " + service.getLastResponseTotalItemCount());
-```
-
-The services are not guaranteed to be thread-safe on their own, so it is difficult to obtain the total with
-`getLastResponseTotalItemCount` when using the service asynchronously. To assist with this when using the callback
-style, the `ResponseHandlerWithHeaders` can be used instead of `ResponseHandler`. But the safest way is to only use a
-single service per thread.
-
-### Differences from the API
-
-Due to restrictions on identifiers in Java, some properties, methods, classes, and packages will be named differently
-from the naming used by the API. For example, an API property that starts with a number will be prepended with 'z'.
-[Java keywords](https://docs.oracle.com/javase/specs/jls/se8/html/jls-3.html#jls-3.9) that appear in identifiers may
-also be replaced.
-
-## Building
-
-This project is intentionally provided without all of the service code. Normal Maven `install` and `package` commands
-work properly and will regenerate the client. To specifically regenerate the Java service-related files, run:
-
- mvn generate-sources
-
-## Customization
-
-### Logging
-
-Logging the requests and response to stdout can be enabled by invoking `withLoggingEnabled` on the `RestApiClient`. In
-order to log elsewhere, simply make your own implementation of `RestApiClient` with `logRequest` and `logResponse`
-overridden.
-
-### HTTP Client
-
-The default HTTP client that is used is the JVM's native `HttpUrlConnection`. In order to create your own, alternative
-implementation you must implement `com.softlayer.api.http.HttpClientFactory`. Once implemented, this can be explicitly
-set on the `RestApiClient` by calling `setHttpClientFactory`. Instead of setting the factory manually, you can also
-leverage Java's `ServiceLoader` mechanism to have it used by default. This involves adding the fully qualified class
-name of your implementation on a single line in a file in the JAR at
-`META-INF/com.softlayer.api.http.HttpClientFactory`.
-
-### JSON Marshalling
-
-The default JSON marshaller that is used is [Gson](https://github.com/google/gson). In order to create your own,
-alternative implementation you must implement `com.softlayer.api.json.JsonMarshallerFactory`. Once implemented, this
-can be explicitly set on the `RestApiClient` by calling `setJsonMarshallerFactory`. Instead of setting the factory
-manually, you can also leverage Java's `ServiceLoader` mechanism to have it used by default. This involves adding the
-fully qualified class name of your implementation on a single line in a file in the JAR at
-`META-INF/com.softlayer.api.json.JsonMarshallerFactory`.
-
-## Copyright
-
-This software is Copyright (c) 2021 The SoftLayer Developer Network. See the bundled LICENSE file for more information.
diff --git a/examples/pom.xml b/examples/pom.xml
deleted file mode 100644
index f90f564..0000000
--- a/examples/pom.xml
+++ /dev/null
@@ -1,65 +0,0 @@
-
- 4.0.0
-
- 3.3.9
-
- com.softlayer.api
- softlayer-api-client-examples
- jar
-
- 0.3.4
- softlayer-api-client-examples
- https://sldn.softlayer.com/
-
-
- The MIT License (MIT)
- https://opensource.org/licenses/MIT
- repo
-
-
-
- UTF-8
- 8
-
-
-
- com.softlayer.api
- softlayer-api-client
- LATEST
-
-
-
-
-
- org.apache.maven.plugins
- maven-resources-plugin
- 3.1.0
-
-
- org.codehaus.mojo
- exec-maven-plugin
- 3.0.0
-
-
-
- java
-
-
-
-
- com.softlayer.api.example.Main
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.8.1
-
- ${java.version}
- ${java.version}
-
-
-
-
-
diff --git a/examples/src/main/java/com/softlayer/api/example/AddSecurityGroupRule.java b/examples/src/main/java/com/softlayer/api/example/AddSecurityGroupRule.java
deleted file mode 100644
index c5d21e6..0000000
--- a/examples/src/main/java/com/softlayer/api/example/AddSecurityGroupRule.java
+++ /dev/null
@@ -1,45 +0,0 @@
-package com.softlayer.api.example;
-
-import com.softlayer.api.ApiClient;
-import com.softlayer.api.service.network.SecurityGroup;
-import com.softlayer.api.service.network.securitygroup.Rule;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/** Create a simple security group */
-public class AddSecurityGroupRule extends Example {
-
- @Override
- public void run(ApiClient client) throws Exception {
- SecurityGroup.Service service = SecurityGroup.service(client);
-
- // create a new security group
- SecurityGroup sg = new SecurityGroup();
- sg.setName("javaTest");
- sg.setDescription("javaTestDescription");
-
- // create that security group
- SecurityGroup sgOut = service.createObject(sg);
- System.out.format("Created security group with ID: %s\n", sgOut.getId());
-
- // bind the service to the id of the newly created security group
- service = sgOut.asService(client);
-
- // Create a security group rule
- Rule rule = new Rule();
- rule.setDirection("ingress");
- rule.setProtocol("udp");
-
- List newRules = new ArrayList<>();
- newRules.add(rule);
-
- // Now add the rule(s) to the security group
- System.out.println("Adding rule(s) to security group");
- service.addRules(newRules);
- }
-
- public static void main(String[] args) throws Exception {
- new AddSecurityGroupRule().start(args);
- }
-}
diff --git a/examples/src/main/java/com/softlayer/api/example/CreateSecurityGroup.java b/examples/src/main/java/com/softlayer/api/example/CreateSecurityGroup.java
deleted file mode 100644
index eadbb99..0000000
--- a/examples/src/main/java/com/softlayer/api/example/CreateSecurityGroup.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package com.softlayer.api.example;
-
-import com.softlayer.api.ApiClient;
-import com.softlayer.api.service.network.SecurityGroup;
-
-/** Create security group example. */
-public class CreateSecurityGroup extends Example {
-
- @Override
- public void run(ApiClient client) throws Exception {
- SecurityGroup.Service service = SecurityGroup.service(client);
-
- // Create a java object representing the new security group
- SecurityGroup sg = new SecurityGroup();
- sg.setName("javaTest");
- sg.setDescription("javaTestDescription");
-
- // Now call the security group service to create it
- System.out.println("Make call to create security group");
- SecurityGroup sgOut = service.createObject(sg);
- System.out.format("Created security group with name = %s\n", sgOut.getName());
- }
-
- public static void main(String[] args) throws Exception {
- new CreateSecurityGroup().start(args);
- }
-}
diff --git a/examples/src/main/java/com/softlayer/api/example/Example.java b/examples/src/main/java/com/softlayer/api/example/Example.java
deleted file mode 100644
index 32566fc..0000000
--- a/examples/src/main/java/com/softlayer/api/example/Example.java
+++ /dev/null
@@ -1,32 +0,0 @@
-package com.softlayer.api.example;
-
-import com.softlayer.api.ApiClient;
-import com.softlayer.api.RestApiClient;
-
-/** Base class for all examples that parses the command-line arguments */
-public abstract class Example {
-
- public void start(String[] args) throws Exception {
- // Args are username, api key, and (optional) base URL
- if (args.length < 2 || args.length > 3) {
- throw new RuntimeException("Username and api key required. Base URL can optionally be provided");
- }
- String baseUrl = args.length == 3 ? args[2] : RestApiClient.BASE_URL;
- // Add trailing slash if not present
- if (!baseUrl.endsWith("/")) {
- baseUrl += '/';
- }
-
- RestApiClient client;
- // mvn -e -q compile exec:java -Dexec.args="QuickTest Bearer eyJraWQ.....
- if (args[0].trim().equals("Bearer")) {
- client = new RestApiClient(baseUrl).withBearerToken(args[1]);
- } else {
- client = new RestApiClient(baseUrl).withCredentials(args[0], args[1]);
- }
- run(client);
- }
-
- /** Run the example with the given client */
- public abstract void run(ApiClient client) throws Exception;
-}
diff --git a/examples/src/main/java/com/softlayer/api/example/ListSecurityGroups.java b/examples/src/main/java/com/softlayer/api/example/ListSecurityGroups.java
deleted file mode 100644
index a7f4f4e..0000000
--- a/examples/src/main/java/com/softlayer/api/example/ListSecurityGroups.java
+++ /dev/null
@@ -1,31 +0,0 @@
-package com.softlayer.api.example;
-
-import com.softlayer.api.ApiClient;
-import com.softlayer.api.service.Account;
-import com.softlayer.api.service.network.SecurityGroup;
-
-/** List all security groups for an account */
-public class ListSecurityGroups extends Example {
-
- @Override
- public void run(ApiClient client) throws Exception {
- // Get the Account service
- Account.Service service = Account.service(client);
-
- // To get specific information on an account (security groups in this case) a mask is provided
- service.withMask().securityGroups();
-
- // Calling getObject will now use the mask
- Account account = service.getObject();
-
- System.out.format("\nFound %d security groups\n", account.getSecurityGroups().size());
-
- for (SecurityGroup sg : account.getSecurityGroups()) {
- System.out.format("id: %s name: %s \n", sg.getId(), sg.getName());
- }
- }
-
- public static void main(String[] args) throws Exception {
- new ListSecurityGroups().start(args);
- }
-}
diff --git a/examples/src/main/java/com/softlayer/api/example/ListServers.java b/examples/src/main/java/com/softlayer/api/example/ListServers.java
deleted file mode 100644
index fd04277..0000000
--- a/examples/src/main/java/com/softlayer/api/example/ListServers.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package com.softlayer.api.example;
-
-import com.softlayer.api.ApiClient;
-import com.softlayer.api.service.Account;
-import com.softlayer.api.service.Hardware;
-import com.softlayer.api.service.virtual.Guest;
-
-/** List all physical and virtual servers on an account */
-public class ListServers extends Example {
-
- @Override
- public void run(ApiClient client) throws Exception {
- Account.Service service = Account.service(client);
-
- // To get specific information on an account (servers in this case) a mask is provided
- service.withMask().hardware().
- fullyQualifiedDomainName().
- primaryIpAddress().
- primaryBackendIpAddress();
- service.withMask().hardware().operatingSystem().softwareLicense().softwareDescription().
- manufacturer().
- name().
- version();
- service.withMask().virtualGuests().
- fullyQualifiedDomainName().
- primaryIpAddress().
- primaryBackendIpAddress();
- service.withMask().virtualGuests().operatingSystem().softwareLicense().softwareDescription().
- manufacturer().
- name().
- version();
-
- // Calling getObject will now use the mask
- Account account = service.getObject();
-
- System.out.format("\n%d physical servers\n", account.getHardware().size());
- for (Hardware hardware : account.getHardware()) {
- System.out.format("Host: %s, IP: %s (%s)\n", hardware.getFullyQualifiedDomainName(),
- hardware.getPrimaryIpAddress(), hardware.getPrimaryBackendIpAddress());
- }
- System.out.format("\n%d virtual servers\n", account.getVirtualGuests().size());
- for (Guest guest : account.getVirtualGuests()) {
- System.out.format("Host: %s, IP: %s (%s)\n", guest.getFullyQualifiedDomainName(),
- guest.getPrimaryIpAddress(), guest.getPrimaryBackendIpAddress());
- }
- }
-
- public static void main(String[] args) throws Exception {
- new ListServers().start(args);
- }
-}
diff --git a/examples/src/main/java/com/softlayer/api/example/ListServersAsync.java b/examples/src/main/java/com/softlayer/api/example/ListServersAsync.java
deleted file mode 100644
index 75daa49..0000000
--- a/examples/src/main/java/com/softlayer/api/example/ListServersAsync.java
+++ /dev/null
@@ -1,63 +0,0 @@
-package com.softlayer.api.example;
-
-import com.softlayer.api.ApiClient;
-import com.softlayer.api.ResponseHandler;
-import com.softlayer.api.service.Account;
-import com.softlayer.api.service.Hardware;
-import com.softlayer.api.service.virtual.Guest;
-
-/** Asynchronous version of {@link ListServers} */
-public class ListServersAsync extends Example {
-
- @Override
- public void run(ApiClient client) throws Exception {
- Account.Service service = Account.service(client);
-
- // To get specific information on an account (servers in this case) a mask is provided
- service.withMask().hardware().
- fullyQualifiedDomainName().
- primaryIpAddress().
- primaryBackendIpAddress();
- service.withMask().hardware().operatingSystem().softwareLicense().softwareDescription().
- manufacturer().
- name().
- version();
- service.withMask().virtualGuests().
- fullyQualifiedDomainName().
- primaryIpAddress().
- primaryBackendIpAddress();
- service.withMask().virtualGuests().operatingSystem().softwareLicense().softwareDescription().
- manufacturer().
- name().
- version();
-
- // Calling getObject will now use the mask
- // By using asAsync this runs on a separate thread pool, and get() is called on the resulting future
- // to wait until completion. In most cases other processing would continue before finishing.
- service.asAsync().getObject(new ResponseHandler() {
-
- @Override
- public void onSuccess(Account account) {
- System.out.format("\n%d physical servers\n", account.getHardware().size());
- for (Hardware hardware : account.getHardware()) {
- System.out.format("Host: %s, IP: %s (%s)\n", hardware.getFullyQualifiedDomainName(),
- hardware.getPrimaryIpAddress(), hardware.getPrimaryBackendIpAddress());
- }
- System.out.format("\n%d virtual servers\n", account.getVirtualGuests().size());
- for (Guest guest : account.getVirtualGuests()) {
- System.out.format("Host: %s, IP: %s (%s)\n", guest.getFullyQualifiedDomainName(),
- guest.getPrimaryIpAddress(), guest.getPrimaryBackendIpAddress());
- }
- }
-
- @Override
- public void onError(Exception ex) {
- ex.printStackTrace();
- }
- }).get();
- }
-
- public static void main(String[] args) throws Exception {
- new ListServersAsync().start(args);
- }
-}
diff --git a/examples/src/main/java/com/softlayer/api/example/Main.java b/examples/src/main/java/com/softlayer/api/example/Main.java
deleted file mode 100644
index ae6ab06..0000000
--- a/examples/src/main/java/com/softlayer/api/example/Main.java
+++ /dev/null
@@ -1,17 +0,0 @@
-package com.softlayer.api.example;
-
-import java.lang.reflect.Method;
-import java.util.Arrays;
-
-/** Alternate entry point for examples that has the class name as the first argument */
-public class Main {
- public static void main(String[] args) throws Exception {
- if (args.length == 0) {
- throw new IllegalArgumentException("First parameter must be example name");
- }
- Method main = Class.forName(Main.class.getPackage().getName() + "." + args[0]).
- getDeclaredMethod("main", String[].class);
- // Take the class name off the front
- main.invoke(null, (Object) Arrays.copyOfRange(args, 1, args.length));
- }
-}
diff --git a/examples/src/main/java/com/softlayer/api/example/OrderVirtualServer.java b/examples/src/main/java/com/softlayer/api/example/OrderVirtualServer.java
deleted file mode 100644
index 8ca59e0..0000000
--- a/examples/src/main/java/com/softlayer/api/example/OrderVirtualServer.java
+++ /dev/null
@@ -1,113 +0,0 @@
-package com.softlayer.api.example;
-
-import java.util.concurrent.TimeUnit;
-
-import com.softlayer.api.ApiClient;
-import com.softlayer.api.service.Location;
-import com.softlayer.api.service.container.virtual.guest.Configuration;
-import com.softlayer.api.service.container.virtual.guest.configuration.Option;
-import com.softlayer.api.service.software.component.Password;
-import com.softlayer.api.service.virtual.Guest;
-import com.softlayer.api.service.virtual.guest.block.Device;
-
-/** Order an hourly virtual server and wait for it to complete provisioning */
-public class OrderVirtualServer extends Example {
-
- @Override
- public void run(ApiClient client) throws Exception {
- Guest.Service service = Guest.service(client);
-
- // This call helps by giving possible options that can be placed on the order
- Configuration orderOptions = service.getCreateObjectOptions();
-
- // A guest object represents a virtual server. The code below is an order for a virtual server
- // with 2 cores, billed hourly, with local disk and the latest Ubuntu distribution.
- // Ref: http://sldn.softlayer.com/reference/services/SoftLayer_Virtual_Guest/createObject
- Guest guest = new Guest();
- guest.setHostname("api-test");
- guest.setDomain("example.com");
- guest.setStartCpus(2L);
- guest.setHourlyBillingFlag(true);
- guest.setLocalDiskFlag(true);
- guest.setOperatingSystemReferenceCode("UBUNTU_LATEST");
-
- // By using the options we can get the smallest amount of memory without hardcoding it
- for (Option option : orderOptions.getMemory()) {
- if (guest.getMaxMemory() == null || guest.getMaxMemory() > option.getTemplate().getMaxMemory()) {
- guest.setMaxMemory(option.getTemplate().getMaxMemory());
- }
- }
-
- // Datacenters are represented by their name. Here the Amsterdam datacenter is used.
- guest.setDatacenter(new Location());
- guest.getDatacenter().setName("ams01");
-
- // Block devices are indexed starting at 0, but 1 is reserved for swap usage. Options can be used
- // here also to set the smallest disk size allowed for the disk at index 0.
- Device device = null;
- for (Option option : orderOptions.getBlockDevices()) {
- for (Device candidate : option.getTemplate().getBlockDevices()) {
- if ("0".equals(candidate.getDevice()) && (device == null ||
- device.getDiskImage().getCapacity() > candidate.getDiskImage().getCapacity())) {
- device = candidate;
- }
- }
- }
- guest.getBlockDevices().add(device);
-
- System.out.println("Ordering virtual server");
- guest = service.createObject(guest);
- System.out.format("Order completed for virtual server with UUID: %s\n", guest.getGlobalIdentifier());
-
- // Asking for the service of a result binds the identifier (the "id" in this case) to the resulting
- // service. Some calls require an ID which can also be done using the services constructor or
- // withId/setId. This is the equivalent of Guest.service(client, guest.getId()).
- service = guest.asService(client);
-
- // Once guests are ordered, they take a couple of minutes to provision. This waits 15 minutes just
- // to be safe.
- int minutesToWait = 15;
- System.out.format("Waiting for completion for a max of %d minutes\n", minutesToWait);
- int timesChecked = 0;
- service.withMask().status().name();
- service.withMask().provisionDate();
- do {
- TimeUnit.MINUTES.sleep(1);
- guest = service.getObject();
- System.out.format("Virtual server %d is not provisioned after %d minutes; Waiting one minute\n",
- guest.getId(), timesChecked + 1);
- } while (++timesChecked < minutesToWait &&
- (!"Active".equals(guest.getStatus().getName()) || guest.getProvisionDate() == null));
-
- // Either the virtual server became active or we timed out
- if (!"Active".equals(guest.getStatus().getName()) || guest.getProvisionDate() == null) {
- System.out.format("Virtual server %d is still not provisioned after %d minutes; Quitting\n",
- guest.getId(), minutesToWait);
- } else {
- // Using a mask, we can ask for the operating system password
- service.withNewMask().primaryIpAddress().operatingSystem().passwords();
- guest = service.getObject();
- if (guest.getOperatingSystem() == null) {
- System.out.println("Unable to find operating system on completed guest");
- } else {
- Password root = null;
- for (Password password : guest.getOperatingSystem().getPasswords()) {
- if ("root".equals(password.getUsername())) {
- root = password;
- break;
- }
- }
- if (root == null) {
- System.out.println("Unable to find root password");
- } else {
- System.out.format("Virtual server done, can now login to %s with root password %s\n",
- guest.getPrimaryIpAddress(), root.getPassword());
- }
- }
- }
- }
-
- public static void main(String[] args) throws Exception {
- new OrderVirtualServer().start(args);
- }
-}
diff --git a/examples/src/main/java/com/softlayer/api/example/Pagination.java b/examples/src/main/java/com/softlayer/api/example/Pagination.java
deleted file mode 100644
index b9b7b09..0000000
--- a/examples/src/main/java/com/softlayer/api/example/Pagination.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package com.softlayer.api.example;
-
-import java.util.List;
-
-import com.softlayer.api.ApiClient;
-import com.softlayer.api.ResultLimit;
-import com.softlayer.api.service.product.Package;
-
-/** Get all product packages in paginated form */
-public class Pagination extends Example {
-
- private static final int PAGE_SIZE = 10;
-
- @Override
- public void run(ApiClient client) throws Exception {
- Package.Service service = Package.service(client);
-
- int offset = 0;
- int total;
- do {
- // Result limits can include a limit and a 0-based offset
- service.setResultLimit(new ResultLimit(offset, PAGE_SIZE));
- List packages = service.getAllObjects();
-
- // The service contains the total item count that would return if a result limit wasn't present
- total = service.getLastResponseTotalItemCount();
-
- System.out.format("Retrieved %d-%d of %d items\n", offset + 1, offset + packages.size(), total);
- for (Package pkg : packages) {
- System.out.println("Package: " + pkg.getName());
- }
- offset += packages.size();
- } while (offset < total);
- }
-
- public static void main(String[] args) throws Exception {
- new Pagination().start(args);
- }
-}
diff --git a/examples/src/main/java/com/softlayer/api/example/PaginationAsyncCallback.java b/examples/src/main/java/com/softlayer/api/example/PaginationAsyncCallback.java
deleted file mode 100644
index 8848d90..0000000
--- a/examples/src/main/java/com/softlayer/api/example/PaginationAsyncCallback.java
+++ /dev/null
@@ -1,89 +0,0 @@
-package com.softlayer.api.example;
-
-import java.util.List;
-import java.util.NavigableSet;
-import java.util.Set;
-import java.util.concurrent.ConcurrentSkipListSet;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.TimeUnit;
-
-import com.softlayer.api.ApiClient;
-import com.softlayer.api.ResponseHandlerWithHeaders;
-import com.softlayer.api.ResultLimit;
-import com.softlayer.api.http.HttpClientFactory;
-import com.softlayer.api.http.ThreadPooledHttpClientFactory;
-import com.softlayer.api.service.product.Package;
-
-/** Asynchronous version of {@link Pagination} using the callback approach */
-public class PaginationAsyncCallback extends Example {
-
- private static final int PAGE_SIZE = 10;
-
- @Override
- public void run(ApiClient client) throws Exception {
- // Let's give the default HTTP client factory a fixed thread pool of 3 threads
- ExecutorService threadPool = Executors.newFixedThreadPool(3);
- ((ThreadPooledHttpClientFactory) HttpClientFactory.getDefault()).setThreadPool(threadPool);
-
- // A thread-safe set is needed to hold the resulting packages ordered by name
- final NavigableSet packages = new ConcurrentSkipListSet<>(
- (pkg1, pkg2) -> pkg1.getName().compareToIgnoreCase(pkg2.getName())
- );
-
- // To know how many calls have to be made to get all items, an initial call is required to get the
- // first set of data AND the total count
- System.out.format("Retrieving first %d items\n", PAGE_SIZE);
- PackageHandler first = new PackageHandler(packages, 0);
- Package.Service service = Package.service(client);
- service.setResultLimit(new ResultLimit(0, PAGE_SIZE));
- service.asAsync().getAllObjects(first).get();
-
- // Once the total is obtained, a call for all pages after the first can happen
- for (int i = PAGE_SIZE; i < first.total; i += PAGE_SIZE) {
- // We create a new service each time because the result limit is specific to the service, not the call
- // so it may be overwritten if we reused it
- System.out.format("Retrieving %d-%d of %d items\n", i + 1, PAGE_SIZE, first.total);
- service = Package.service(client);
- service.setResultLimit(new ResultLimit(i, PAGE_SIZE));
- service.asAsync().getAllObjects(new PackageHandler(packages, i));
- }
-
- // It can take a few seconds to obtain all the information, wait 3 minutes just to be safe
- threadPool.shutdown();
- threadPool.awaitTermination(3, TimeUnit.MINUTES);
-
- System.out.println("Packages:");
- for (Package pkg : packages) {
- System.out.println(" " + pkg.getName());
- }
- }
-
- /** Asynchronous handler for handling a subset of packages */
- static class PackageHandler extends ResponseHandlerWithHeaders> {
- private final int offset;
- private final Set packages;
- private Integer total;
-
- public PackageHandler(Set packages, int offset) {
- this.packages = packages;
- this.offset = offset;
- }
-
- @Override
- public void onError(Exception ex) {
- ex.printStackTrace();
- }
-
- @Override
- public void onSuccess(List value) {
- packages.addAll(value);
- total = getLastResponseTotalItemCount();
- System.out.format("Retrieved %d-%d of %d items\n", offset + 1, offset + value.size(), total);
- }
- }
-
- public static void main(String[] args) throws Exception {
- new PaginationAsyncCallback().start(args);
- }
-}
diff --git a/examples/src/main/java/com/softlayer/api/example/PaginationAsyncPolling.java b/examples/src/main/java/com/softlayer/api/example/PaginationAsyncPolling.java
deleted file mode 100644
index 7187441..0000000
--- a/examples/src/main/java/com/softlayer/api/example/PaginationAsyncPolling.java
+++ /dev/null
@@ -1,89 +0,0 @@
-package com.softlayer.api.example;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.NavigableSet;
-import java.util.TreeSet;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-import java.util.concurrent.Future;
-
-import com.softlayer.api.ApiClient;
-import com.softlayer.api.ResultLimit;
-import com.softlayer.api.http.HttpClientFactory;
-import com.softlayer.api.http.ThreadPooledHttpClientFactory;
-import com.softlayer.api.service.product.Package;
-
-/** Asynchronous version of {@link Pagination} using the polling approach */
-public class PaginationAsyncPolling extends Example {
-
- private static final int PAGE_SIZE = 10;
-
- @Override
- public void run(ApiClient client) throws Exception {
- // Let's give the default HTTP client factory a fixed thread pool of 3 threads
- ExecutorService threadPool = Executors.newFixedThreadPool(3);
- ((ThreadPooledHttpClientFactory) HttpClientFactory.getDefault()).setThreadPool(threadPool);
-
- // Asynchronous responses are held so they can be waited on once all are submitted
- List responses = new ArrayList<>();
-
- // To know how many calls have to be made to get all items, an initial call is required to get the
- // first set of data AND the total count
- System.out.format("Retrieving first %d items\n", PAGE_SIZE);
- Package.ServiceAsync service = Package.service(client).asAsync();
- service.setResultLimit(new ResultLimit(0, PAGE_SIZE));
- PackageResponseWrapper first = new PackageResponseWrapper(0, service.getAllObjects(), service);
- responses.add(first);
- first.response.get();
-
- // Once the total is obtained, a call for all pages after the first can happen
- for (int i = PAGE_SIZE; i < first.service.getLastResponseTotalItemCount(); i += PAGE_SIZE) {
- // We create a new service each time because the result limit is specific to the service, not the call
- // so it may be overwritten if we reused it
- System.out.format("Retrieving %d-%d of %d items\n", i + 1, i + PAGE_SIZE,
- first.service.getLastResponseTotalItemCount());
- service = Package.service(client).asAsync();
- service.setResultLimit(new ResultLimit(i, PAGE_SIZE));
- responses.add(new PackageResponseWrapper(i, service.getAllObjects(), service));
- }
-
- // The thread pool needs to be closed so nothing more can be added to it and it terminates after last call
- threadPool.shutdown();
-
- // A set is needed to hold the resulting packages ordered by name
- final NavigableSet packages = new TreeSet<>(
- (pkg1, pkg2) -> pkg1.getName().compareToIgnoreCase(pkg2.getName())
- );
-
- // Unlike the callback approach, this approach guarantees they come in the order requested since a blocking
- // call to get() is in the request order
- for (PackageResponseWrapper response : responses) {
- packages.addAll(response.response.get());
- System.out.format("Retrieved %d-%d of %d items\n", response.offset + 1, response.offset +
- response.response.get().size(), first.service.getLastResponseTotalItemCount());
- }
-
- System.out.println("Packages:");
- for (Package pkg : packages) {
- System.out.println(" " + pkg.getName());
- }
- }
-
- /** Simple wrapper to hold the response and the offset */
- static class PackageResponseWrapper {
- public final Future> response;
- public final int offset;
- public final Package.ServiceAsync service;
-
- public PackageResponseWrapper(int offset, Future> response, Package.ServiceAsync service) {
- this.offset = offset;
- this.response = response;
- this.service = service;
- }
- }
-
- public static void main(String[] args) throws Exception {
- new PaginationAsyncPolling().start(args);
- }
-}
diff --git a/examples/src/main/java/com/softlayer/api/example/QuickTest.java b/examples/src/main/java/com/softlayer/api/example/QuickTest.java
deleted file mode 100644
index 24701da..0000000
--- a/examples/src/main/java/com/softlayer/api/example/QuickTest.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package com.softlayer.api.example;
-
-import com.softlayer.api.ApiClient;
-import com.softlayer.api.RestApiClient;
-import com.softlayer.api.service.Account;
-
-
-/** A quick example for testing if authentication works.
-
-cd softlayer-java/examples
-mvn -e -q compile exec:java -Dexec.args="QuickTest Bearer eyJraWQ.....
-*/
-public class QuickTest extends Example {
-
- @Override
- public void run(ApiClient client) throws Exception {
- client.withLoggingEnabled();
- System.out.format("Authorization: %s\n", client.getCredentials());
- Account.Service service = Account.service(client);
-
- Account account = service.getObject();
- System.out.format("Account Name: %s\n", account.getCompanyName());
- }
-
- public static void main(String[] args) throws Exception {
- new QuickTest().start(args);
- }
-}
diff --git a/gen/pom.xml b/gen/pom.xml
deleted file mode 100644
index 768a3a5..0000000
--- a/gen/pom.xml
+++ /dev/null
@@ -1,80 +0,0 @@
-
- 4.0.0
-
- 3.3.9
-
- com.softlayer.api
- softlayer-api-client-gen
- jar
-
- 0.3.4
- softlayer-api-client-gen
- https://sldn.softlayer.com/
-
-
- The MIT License (MIT)
- http://opensource.org/licenses/MIT
- repo
-
-
-
- UTF-8
- 8
- com.softlayer.api.gen.Main
-
-
-
- com.squareup
- javawriter
- 2.5.0
-
-
- com.google.code.gson
- gson
- 2.8.9
-
-
- junit
- junit
- 4.13.2
- test
-
-
-
-
-
- org.codehaus.mojo
- exec-maven-plugin
- 3.0.0
-
-
-
- java
-
-
-
-
- com.softlayer.api.gen.Main
-
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
- 3.3.1
-
- ${java.version}
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.8.1
-
- ${java.version}
- ${java.version}
-
-
-
-
-
diff --git a/gen/src/main/java/com/softlayer/api/gen/ClassWriter.java b/gen/src/main/java/com/softlayer/api/gen/ClassWriter.java
deleted file mode 100644
index 2d4ef46..0000000
--- a/gen/src/main/java/com/softlayer/api/gen/ClassWriter.java
+++ /dev/null
@@ -1,493 +0,0 @@
-package com.softlayer.api.gen;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.nio.charset.StandardCharsets;
-import java.util.Arrays;
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import javax.lang.model.element.Modifier;
-
-import com.squareup.javawriter.JavaWriter;
-
-public class ClassWriter extends JavaWriter {
-
- public static final String SLDN_URL_BASE_PATH = "http://sldn.softlayer.com/reference/";
-
- public static final String TYPE_API_CLIENT = "com.softlayer.api.ApiClient";
- public static final String TYPE_API_METHOD = "com.softlayer.api.annotation.ApiMethod";
- public static final String TYPE_API_PROPERTY = "com.softlayer.api.annotation.ApiProperty";
- public static final String TYPE_API_SERVICE = "com.softlayer.api.annotation.ApiService";
- public static final String TYPE_API_TYPE = "com.softlayer.api.annotation.ApiType";
- public static final String TYPE_API_TYPES = "com.softlayer.api.annotation.ApiTypes";
- public static final String TYPE_CALLABLE = "java.util.concurrent.Callable";
- public static final String TYPE_FUTURE = "java.util.concurrent.Future";
- public static final String TYPE_MASK = "com.softlayer.api.Mask";
- public static final String TYPE_RESPONSE_HANDLER = "com.softlayer.api.ResponseHandler";
- public static final String TYPE_SERVICE = "com.softlayer.api.Service";
- public static final String TYPE_SERVICE_ASYNC = "com.softlayer.api.ServiceAsync";
- public static final String TYPE_TYPE = "com.softlayer.api.Type";
-
- private static final Set PROTECTED = EnumSet.of(Modifier.PROTECTED);
- private static final Set PUBLIC = EnumSet.of(Modifier.PUBLIC);
- private static final Set PUBLIC_STATIC = EnumSet.of(Modifier.PUBLIC, Modifier.STATIC);
-
- public static void emitPackageInfo(File baseDir, List classes) throws IOException {
- // Do this manually, the Java writer doesn't help us here
- StringBuilder types = new StringBuilder();
- for (TypeClass type : classes) {
- if (types.length() != 0) {
- types.append(",\n");
- }
- types.append(" ").append(type.getFullClassName()).append(".class");
- }
- Writer writer = new BufferedWriter(
- new FileWriter(new File(baseDir, "com/softlayer/api/service/package-info.java")));
- try {
- writer.append("@ApiTypes({\n").append(types).append("\n})\npackage ").
- append(Generator.BASE_PKG).append(";\nimport ").append(TYPE_API_TYPES).append(";\n");
- } finally {
- try { writer.close(); } catch (Exception e) { }
- }
- }
-
- public static void emitType(File baseDir, TypeClass type, Meta meta) throws IOException {
- File fileDir = new File(baseDir, type.packageName.replace('.', '/'));
- fileDir.mkdirs();
- Writer writer = new BufferedWriter(new OutputStreamWriter(
- new FileOutputStream(new File(fileDir, type.className + ".java")), StandardCharsets.UTF_8));
- try {
- new ClassWriter(writer, type, meta).emitType();
- } finally {
- try { writer.close(); } catch (Exception e) { }
- }
- }
-
- public static String getClassName(String typeName) {
- // Just the last name after the underscore
- int lastUnderscore = typeName.lastIndexOf('_');
- if (lastUnderscore == -1) {
- return typeName;
- } else {
- return typeName.substring(lastUnderscore + 1);
- }
- }
-
- public static String getClassName(Meta.Type type) {
- return getClassName(type.name);
- }
-
- public final TypeClass type;
- private final Meta meta;
-
- public ClassWriter(Writer out, TypeClass type, Meta meta) {
- super(out);
- this.type = type;
- this.meta = meta;
- setIndent(" ");
- }
-
- public ClassWriter emitAnnotationWithAttrs(String annotationType, Object... attributes) throws IOException {
- int i = 0;
- Map attrMap = new HashMap<>(attributes.length / 2 + 1);
- while (i < attributes.length) {
- String key = attributes[i++].toString();
- attrMap.put(key, attributes[i++]);
- }
- emitAnnotation(annotationType, attrMap);
- return this;
- }
-
- public ClassWriter emitMask() throws IOException {
-
- String baseMask = type.baseJavaType != null ? type.baseJavaType + ".Mask" : TYPE_MASK;
- beginType("Mask", "class", PUBLIC_STATIC, baseMask).emitEmptyLine();
-
- for (TypeClass.Property property : type.properties) {
- if (property.nonArrayJavaType.startsWith("com.")) {
- beginMethod(property.nonArrayJavaType + ".Mask", property.name, PUBLIC).
- emitStatement("return withSubMask(%s, %s.class)", stringLiteral(property.meta.name),
- compressType(property.nonArrayJavaType + ".Mask")).
- endMethod().emitEmptyLine();
- } else {
- beginMethod("Mask", property.name, PUBLIC).
- emitStatement("withLocalProperty(%s)", stringLiteral(property.meta.name)).
- emitStatement("return this").
- endMethod().emitEmptyLine();
- }
- }
-
- endType().emitEmptyLine();
- return this;
- }
-
- public ClassWriter emitProperty(TypeClass.Property property) throws IOException {
- if (property.meta.doc != null) {
- emitJavadoc(property.meta.doc.replace("\n", " \n"));
- }
-
- if (property.meta.deprecated) {
- emitAnnotation("Deprecated");
- }
-
- Map params = new HashMap<>(2);
- if (!property.name.equals(property.meta.name)) {
- params.put("value", stringLiteral(property.meta.name));
- }
- if (property.meta.form == Meta.PropertyForm.LOCAL) {
- params.put("canBeNullOrNotSet", true);
- }
- emitAnnotation("ApiProperty", params);
- emitField(property.javaType, property.name, PROTECTED).emitEmptyLine();
-
- // Getter
- String capitalized = Character.toUpperCase(property.name.charAt(0)) +
- property.name.substring(1);
- beginMethod(property.javaType, "get" + capitalized, PUBLIC);
- // If it's an array, we lazily create it here and do not allow it to be set
- if (property.meta.typeArray) {
- beginControlFlow("if (" + property.name + " == null)").
- emitStatement(property.name + " = new " + compressType(
- property.javaType.replace("List<", "ArrayList<")) + "()").
- endControlFlow().emitStatement("return " + property.name);
- endMethod().emitEmptyLine();
- } else {
- emitStatement("return " + property.name);
- endMethod().emitEmptyLine();
-
- // Setter (which may have to set specified boolean)
- beginMethod("void", "set" + capitalized, PUBLIC, property.javaType, property.name);
- if (property.meta.form == Meta.PropertyForm.LOCAL) {
- emitStatement(property.name + "Specified = true");
- }
- emitStatement("this." + property.name + " = " + property.name).
- endMethod().emitEmptyLine();
- }
-
- // Make the XSpecified boolean property if needed
- if (property.meta.form == Meta.PropertyForm.LOCAL) {
- emitField("boolean", property.name + "Specified", PROTECTED).emitEmptyLine();
- beginMethod("boolean", "is" + capitalized + "Specified", PUBLIC).
- emitStatement("return " + property.name + "Specified").
- endMethod().emitEmptyLine();
- beginMethod("void", "unset" + capitalized, PUBLIC).
- emitStatement(property.name + " = null").
- emitStatement(property.name + "Specified = false").
- endMethod().emitEmptyLine();
- }
-
- return this;
- }
-
- public ClassWriter emitJavadoc(String javadoc, Object... params) throws IOException {
- //Since the base class formats, we have to double-up our percent signs
- return (ClassWriter) super.emitJavadoc(javadoc.replace("%", "%%"), params);
- }
-
- public ClassWriter emitService() throws IOException {
- String javadoc = type.meta.serviceDoc;
- if (javadoc == null) {
- javadoc = "";
- } else {
- javadoc = javadoc.replace("\n", " \n") + "\n\n";
- }
- javadoc += "@see " + type.meta.name + "";
- emitJavadoc(javadoc);
-
- emitAnnotation(TYPE_API_SERVICE, stringLiteral(type.meta.name));
- String base;
- if (type.baseServiceJavaType != null) {
- base = compressType(type.baseServiceJavaType) + ".Service";
- } else {
- base = TYPE_SERVICE;
- }
- beginType("Service", "interface", PUBLIC_STATIC, base).emitEmptyLine();
-
- // Covariant return overrides
- beginMethod("ServiceAsync", "asAsync", PUBLIC).endMethod();
- beginMethod("Mask", "withNewMask", PUBLIC).endMethod();
- beginMethod("Mask", "withMask", PUBLIC).endMethod();
- beginMethod("void", "setMask", PUBLIC, "Mask", "mask").endMethod().emitEmptyLine();
-
- for (TypeClass.Method method : type.methods) {
- emitServiceMethod(method, false);
- }
- // Method for every non-local property too...
- for (TypeClass.Property property : type.properties) {
- // Only relational properties support getters
- if (property.meta.form == Meta.PropertyForm.RELATIONAL) {
- emitServiceMethod(property, false);
- }
- }
- endType().emitEmptyLine();
-
- // And the async one...
- if (type.baseServiceJavaType != null) {
- base = compressType(type.baseServiceJavaType) + ".ServiceAsync";
- } else {
- base = TYPE_SERVICE_ASYNC;
- }
- beginType("ServiceAsync", "interface", PUBLIC_STATIC, base).emitEmptyLine();
-
- // Covariant return overrides
- beginMethod("Mask", "withNewMask", PUBLIC).endMethod();
- beginMethod("Mask", "withMask", PUBLIC).endMethod();
- beginMethod("void", "setMask", PUBLIC, "Mask", "mask").endMethod().emitEmptyLine();
-
- for (TypeClass.Method method : type.methods) {
- emitServiceMethod(method, true);
- }
- // Method for every non-local property too...
- for (TypeClass.Property property : type.properties) {
- // Only relational properties support getters
- if (property.meta.form == Meta.PropertyForm.RELATIONAL) {
- emitServiceMethod(property, true);
- }
- }
- endType().emitEmptyLine();
-
- return this;
- }
-
- public ClassWriter emitServiceMethod(TypeClass.Method method, boolean async) throws IOException {
- if (!async) {
- // Only non-async get service docs and annotation
- String javadoc = method.meta.doc;
- if (javadoc == null) {
- javadoc = "";
- } else {
- javadoc = javadoc.replace("\n", " \n") + "\n\n";
- }
- javadoc += "@see " + type.meta.name + "::" + method.meta.name + "";
- emitJavadoc(javadoc);
-
- if (method.meta.deprecated) {
- emitAnnotation("Deprecated");
- }
-
- Map params = new HashMap<>(2);
- if (!method.name.equals(method.meta.name)) {
- params.put("value", stringLiteral(method.meta.name));
- }
- if (!method.meta.isstatic && !"SoftLayer_Resource_Metadata".equals(type.meta.name)) {
- params.put("instanceRequired", true);
- }
- emitAnnotation(TYPE_API_METHOD, params);
- } else {
- // Otherwise, just a javadoc link
- emitJavadoc("Async version of {@link Service#" + method.name + "}");
-
- if (method.meta.deprecated) {
- emitAnnotation("Deprecated");
- }
- }
-
- String[] parameters = new String[method.parameters.size() * 2];
- for (int i = 0; i < method.parameters.size(); i++) {
- TypeClass.Parameter param = method.parameters.get(i);
- parameters[i * 2] = param.javaType;
- parameters[i * 2 + 1] = param.meta.name;
- }
-
- String returnType = method.javaType;
- if (async) {
- returnType = TYPE_FUTURE + '<' + returnType + '>';
- }
- beginMethod(returnType, method.name, PUBLIC, parameters).endMethod().emitEmptyLine();
-
- // Async has an extra callback method
- if (async) {
- if (method.meta.deprecated) {
- emitAnnotation("Deprecated");
- }
- parameters = Arrays.copyOf(parameters, parameters.length + 2);
- parameters[parameters.length - 2] = TYPE_RESPONSE_HANDLER + '<' + method.javaType + '>';
- parameters[parameters.length - 1] = "callback";
- beginMethod(TYPE_FUTURE + ">", method.name, PUBLIC, parameters).endMethod().emitEmptyLine();
- }
-
- return this;
- }
-
- public ClassWriter emitServiceMethod(TypeClass.Property property, boolean async) throws IOException {
- String capitalized = Character.toUpperCase(property.name.charAt(0)) +
- property.name.substring(1);
- String name = "get" + capitalized;
- if (type.meta.methods.containsKey(name)) {
- return this;
- }
-
- if (!async) {
- // Only non-async get service docs and annotation
- String javadoc = property.meta.doc;
- if (javadoc == null) {
- javadoc = "";
- } else {
- javadoc = javadoc.replace("\n", " \n") + "\n\n";
- }
- javadoc += "@see " + type.meta.name + "::" + name + "";
- emitJavadoc(javadoc);
-
- if (property.meta.deprecated) {
- emitAnnotation("Deprecated");
- }
-
- // Instance is only required if it's not an account property
- if ("SoftLayer_Account".equals(type.meta.name)) {
- emitAnnotation(TYPE_API_METHOD);
- } else {
- emitAnnotationWithAttrs(TYPE_API_METHOD, "instanceRequired", true);
- }
- } else {
- // Otherwise, just a javadoc link
- emitJavadoc("Async version of {@link Service#" + name + "}");
-
- if (property.meta.deprecated) {
- emitAnnotation("Deprecated");
- }
- }
-
- String returnType = property.javaType;
- if (async) {
- returnType = TYPE_FUTURE + '<' + returnType + '>';
- }
- beginMethod(returnType, name, PUBLIC).endMethod().emitEmptyLine();
-
- // Async has an extra callback method
- if (async) {
- emitJavadoc("Async callback version of {@link Service#" + name + "}");
- beginMethod(TYPE_FUTURE + ">", name, PUBLIC, TYPE_RESPONSE_HANDLER + '<' + property.javaType + '>',
- "callback").endMethod().emitEmptyLine();
- }
- return this;
- }
-
- public ClassWriter emitType() throws IOException {
- emitPackage(type.packageName);
-
- emitTypeImports();
-
- emitJavadoc(getTypeJavadoc());
-
- if (type.meta.deprecated) {
- emitAnnotation("Deprecated");
- }
-
- // Each type has a type attribute
- emitAnnotation("ApiType", stringLiteral(type.meta.name));
-
- String baseType = type.baseJavaType == null ? TYPE_TYPE : type.baseJavaType;
- beginType(type.className, "class", PUBLIC, baseType).emitEmptyLine();
-
- // Write all the API properties
- for (TypeClass.Property property : type.properties) {
- emitProperty(property);
- }
-
- // Now the service
- if (!type.meta.noservice) {
-
- // Check if the type or any of its' parent types have id or globalIdentifier properties
- Boolean containsId = false;
- Boolean containsGlobalIdentifier = false;
- Meta.Type searchType = type.meta;
- while (searchType != null) {
- if (searchType.properties.containsKey("id")) {
- containsId = true;
- if (searchType.properties.containsKey("globalIdentifier")) {
- containsGlobalIdentifier = true;
- }
- break;
- }
- searchType = meta.types.get(searchType.base);
- }
-
- if (containsId) {
- if (containsGlobalIdentifier) {
- beginMethod("Service", "asService", PUBLIC, TYPE_API_CLIENT, "client").
- beginControlFlow("if (id != null)").
- emitStatement("return service(client, id)").
- nextControlFlow("else").
- emitStatement("return service(client, globalIdentifier)").
- endControlFlow().endMethod().emitEmptyLine();
- } else {
- beginMethod("Service", "asService", PUBLIC, TYPE_API_CLIENT, "client").
- emitStatement("return service(client, id)").endMethod().emitEmptyLine();
- }
- }
-
- beginMethod("Service", "service", PUBLIC_STATIC, TYPE_API_CLIENT, "client").
- emitStatement("return client.createService(Service.class, null)").
- endMethod().emitEmptyLine();
-
- if (containsId) {
- beginMethod("Service", "service", PUBLIC_STATIC, TYPE_API_CLIENT, "client", "Long", "id").
- emitStatement("return client.createService(Service.class, id == null ? null : id.toString())").
- endMethod().emitEmptyLine();
- if (containsGlobalIdentifier) {
- beginMethod("Service", "service", PUBLIC_STATIC, TYPE_API_CLIENT,
- "client", "String", "globalIdentifier").
- emitStatement("return client.createService(Service.class, globalIdentifier)").
- endMethod().emitEmptyLine();
- }
- }
-
- emitService();
- }
-
- emitMask().endType();
- return this;
- }
-
- protected String getTypeJavadoc() {
- String javadoc = type.meta.typeDoc != null ? type.meta.typeDoc : type.meta.serviceDoc;
- if (javadoc == null) {
- javadoc = "";
- } else {
- javadoc = javadoc.replace("\n", " \n") + "\n\n";
- }
- javadoc += "@see " + type.meta.name + "";
- return javadoc;
- }
-
- public ClassWriter emitTypeImports() throws IOException {
- Map imports = new HashMap<>(type.imports);
-
- imports.remove("Mask");
- imports.remove(type.className);
- imports.put("ApiType", TYPE_API_TYPE);
-
- // If we have properties or methods...
- if (!type.properties.isEmpty()) {
- imports.put("ApiProperty", TYPE_API_PROPERTY);
- }
- if (!type.methods.isEmpty()) {
- imports.put("ApiMethod", TYPE_API_METHOD);
- imports.put("Future", TYPE_FUTURE);
- imports.put("ResponseHandler", TYPE_RESPONSE_HANDLER);
- }
-
- // Remove Service if we have one
- if (!type.meta.noservice) {
- imports.remove("Service");
- imports.remove("ServiceAsync");
- imports.put("ApiClient", TYPE_API_CLIENT);
- }
-
- emitImports(imports.values()).emitEmptyLine();
- return this;
- }
-}
diff --git a/gen/src/main/java/com/softlayer/api/gen/Generator.java b/gen/src/main/java/com/softlayer/api/gen/Generator.java
deleted file mode 100644
index 1ba77d5..0000000
--- a/gen/src/main/java/com/softlayer/api/gen/Generator.java
+++ /dev/null
@@ -1,109 +0,0 @@
-package com.softlayer.api.gen;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.URL;
-import java.nio.file.FileVisitResult;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.SimpleFileVisitor;
-import java.nio.file.attribute.BasicFileAttributes;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-
-public class Generator {
-
- public static final String BASE_PKG = "com.softlayer.api.service";
-
- private final File dir;
- private final URL metadataUrl;
- private final Restriction whitelist;
- private final Restriction blacklist;
-
- /**
- * @param dir The directory to generate classes into.
- * @param metadataUrl The metadata to generate from.
- * @param whitelist
- * @param blacklist
- */
- public Generator(File dir, URL metadataUrl, Restriction whitelist, Restriction blacklist) {
- this.dir = dir;
- this.metadataUrl = metadataUrl;
- this.whitelist = whitelist;
- this.blacklist = blacklist;
- }
-
- public void buildClient() throws IOException {
- log("Deleting existing service files");
- recursivelyDelete(new File(dir, "com/softlayer/api/service"));
-
- log("Loading metadata");
- Meta meta = Meta.fromUrl(metadataUrl);
- applyRestrictions(meta);
-
- log("Generating source code");
- List classes = new ArrayList<>(meta.types.size());
- for (Meta.Type type : meta.types.values()) {
- TypeClass typeClass = new MetaConverter(BASE_PKG, meta, type).buildTypeClass();
- ClassWriter.emitType(dir, typeClass, meta);
- classes.add(typeClass);
- }
- ClassWriter.emitPackageInfo(dir, classes);
- log("Done");
- }
-
- public void applyRestrictions(Meta meta) {
- if (whitelist != null) {
- if (!whitelist.types.isEmpty()) {
- meta.types.keySet().retainAll(whitelist.types);
- }
- for (Meta.Type type : meta.types.values()) {
- Set properties = whitelist.properties.get(type.name);
- if (properties != null) {
- type.properties.keySet().retainAll(properties);
- }
- Set methods = whitelist.methods.get(type.name);
- if (methods != null) {
- type.methods.keySet().retainAll(methods);
- }
- }
- }
- if (blacklist != null) {
- meta.types.keySet().removeAll(blacklist.types);
- for (Meta.Type type : meta.types.values()) {
- Set properties = blacklist.properties.get(type.name);
- if (properties != null) {
- type.properties.keySet().removeAll(properties);
- }
- Set methods = blacklist.methods.get(type.name);
- if (methods != null) {
- type.methods.keySet().removeAll(methods);
- }
- }
- }
- }
-
- protected void log(String contents) {
- System.out.println(contents);
- }
-
- public void recursivelyDelete(File file) throws IOException {
- if (!file.exists()) {
- return;
- }
- Files.walkFileTree(file.toPath(), new SimpleFileVisitor() {
- @Override
- public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
- Files.delete(file);
- return FileVisitResult.CONTINUE;
- }
-
- @Override
- public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
- Files.delete(dir);
- return FileVisitResult.CONTINUE;
- }
- });
- }
-}
diff --git a/gen/src/main/java/com/softlayer/api/gen/Main.java b/gen/src/main/java/com/softlayer/api/gen/Main.java
deleted file mode 100644
index 3fa541a..0000000
--- a/gen/src/main/java/com/softlayer/api/gen/Main.java
+++ /dev/null
@@ -1,109 +0,0 @@
-package com.softlayer.api.gen;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileReader;
-import java.io.IOException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/** Entry point for the code generator */
-public class Main {
-
- protected static final String METADATA_URL = "https://api.softlayer.com/metadata/v3.1/";
- protected static final String DEFAULT_SOURCE_PATH = "../src/main/java";
-
- public static final String USAGE =
- "Arguments:\n\n" +
- " --help - Show this.\n" +
- " --src DIR - Optional directory to generate source into. The com.softlayer.api.service package\n" +
- " underneath this directory will be cleaned before code is generated. If not given,\n" +
- " ../src/main/java is used\n" +
- " --url URL - Optional metadata URL. If not given, http://api.softlayer.com/metadata/v3.1/ is used.\n" +
- " --whitelist FILENAME - Optional set of types, properties, and methods to whitelist. It is one\n" +
- " entry per line and anything not entered will not be included in the generated client. Simply\n" +
- " give the type name, the property as type_name.propertyName, or the method as type_name::methodName.\n" +
- " This is mutually exclusive with --blacklist.\n" +
- " --blacklist FILENAME - Similar to, and mututally exclusive with, --whitelist. Anything included\n" +
- " here will NOT be generated.\n";
-
- public static void main(String[] args) throws Exception {
- // Load up args
- File dir;
- URL url;
- Restriction whitelist;
- Restriction blacklist;
- try {
- List argList = Arrays.asList(args);
- if (argList.contains("--help")) {
- System.out.println(USAGE);
- return;
- }
- String dirString = getArg("--src", argList);
- dir = new File(dirString != null ? dirString : DEFAULT_SOURCE_PATH);
- String urlString = getArg("--url", argList);
- url = new URL(urlString != null ? urlString : METADATA_URL);
- whitelist = getRestriction(getArg("--whitelist", argList));
- blacklist = getRestriction(getArg("--blacklist", argList));
- if (whitelist != null && blacklist != null) {
- throw new IllegalArgumentException("Can't have whitelist and blacklist");
- }
- } catch (Exception e) {
- System.out.println(USAGE);
- throw e;
- }
-
- new Generator(dir, url, whitelist, blacklist).buildClient();
- }
-
- private static String getArg(String argName, List argList) {
- int index = argList.indexOf(argName);
- if (index == -1) {
- return null;
- } else if (argList.size() == index + 1) {
- throw new IllegalArgumentException("No value found for argument " + argName);
- } else {
- argList.remove(index);
- return argList.remove(index);
- }
- }
-
- private static Restriction getRestriction(String filename) throws IOException {
- if (filename == null) {
- return null;
- }
- Restriction restriction = new Restriction();
- BufferedReader reader = new BufferedReader(new FileReader(filename));
- try {
- String line;
- do {
- line = reader.readLine();
- if (line != null) {
- line = line.trim();
- if (line.contains("::")) {
- String pieces[] = line.split("::", 2);
- Set methods = restriction.methods.computeIfAbsent(pieces[0], key -> new HashSet<>());
- methods.add(pieces[1]);
- } else if (line.contains(".")) {
- String pieces[] = line.split(".", 2);
- Set properties = restriction.properties.get(pieces[0]);
- if (properties == null) {
- properties = new HashSet<>();
- restriction.methods.put(pieces[0], properties);
- }
- properties.add(pieces[1]);
- } else if (!line.isEmpty()) {
- restriction.types.add(line);
- }
- }
- } while (line != null);
- return restriction;
- } finally {
- try { reader.close(); } catch (Exception e) { }
- }
- }
-}
diff --git a/gen/src/main/java/com/softlayer/api/gen/Meta.java b/gen/src/main/java/com/softlayer/api/gen/Meta.java
deleted file mode 100644
index 838af47..0000000
--- a/gen/src/main/java/com/softlayer/api/gen/Meta.java
+++ /dev/null
@@ -1,127 +0,0 @@
-package com.softlayer.api.gen;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.URL;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
-import com.google.gson.TypeAdapter;
-import com.google.gson.annotations.SerializedName;
-import com.google.gson.reflect.TypeToken;
-import com.google.gson.stream.JsonReader;
-import com.google.gson.stream.JsonWriter;
-
-/**
- * Represents the structure of the metadata provided by the API.
- */
-public class Meta {
-
- /**
- * Reads a JSON object from the given metadata URL and generates a new Meta object containing all types.
- *
- * @param url The API metadata URL.
- * @return Meta
- */
- public static Meta fromUrl(URL url) {
- InputStream stream = null;
- try {
- stream = url.openStream();
- Gson gson = new GsonBuilder().registerTypeAdapter(PropertyForm.class, new TypeAdapter() {
- @Override
- public void write(JsonWriter out, PropertyForm value) throws IOException {
- out.value(value.name().toLowerCase());
- }
-
- @Override
- public PropertyForm read(JsonReader in) throws IOException {
- return PropertyForm.valueOf(in.nextString().toUpperCase());
- }
- }).create();
- Map types = gson.fromJson(
- new InputStreamReader(stream),
- new TypeToken