Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 8 additions & 56 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,57 +1,9 @@
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff:
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/dictionaries
.idea/misc.xml
.idea/inspectionProfiles/

# Sensitive or high-churn files:
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml

# Gradle:
.idea/**/gradle.xml
.idea/**/libraries

# CMake
cmake-build-debug/
cmake-build-release/

# Mongo Explorer plugin:
.idea/**/mongoSettings.xml

## File-based project format:
*.iws

## Plugin-specific files:

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

config.properties

target/

src/test
out
.idea_modules
hs_err*
*.idea
*.iml
*.log
target
dependency-reduced-pom.xml
11 changes: 0 additions & 11 deletions .idea/artifacts/Ptero4J_jar.xml

This file was deleted.

16 changes: 0 additions & 16 deletions .idea/compiler.xml

This file was deleted.

13 changes: 0 additions & 13 deletions .idea/misc.xml

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

18 changes: 0 additions & 18 deletions Ptero4J.iml

This file was deleted.

17 changes: 15 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

Expand Down Expand Up @@ -34,6 +34,19 @@
</plugins>
</build>

<distributionManagement>
<repository>
<id>vector-repo</id>
<name>Vector Private Repository</name>
<url>https://repo.vectormc.net/artifactory/private</url>
</repository>
<snapshotRepository>
<id>vector-repo</id>
<name>Vector Private Repository</name>
<url>https://repo.vectormc.net/artifactory/private</url>
</snapshotRepository>
</distributionManagement>

<dependencies>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
Expand Down
15 changes: 12 additions & 3 deletions src/main/java/com/stanjg/ptero4j/PteroAdminAPI.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package com.stanjg.ptero4j;

import com.stanjg.ptero4j.controllers.GenericController;
import com.stanjg.ptero4j.controllers.admin.*;
import com.stanjg.ptero4j.controllers.TestController;
import com.stanjg.ptero4j.controllers.admin.LocationsController;
import com.stanjg.ptero4j.controllers.admin.NodesController;
import com.stanjg.ptero4j.controllers.admin.ServersController;
import com.stanjg.ptero4j.controllers.admin.UsersController;

import java.io.IOException;

Expand All @@ -18,12 +21,13 @@ public class PteroAdminAPI {

/**
* Create an instance of AdminAPI
*
* @param baseURL URL of the panel (like https://panel.myhost.com)
* @param key The application API Key from the panel
* @param key The application API Key from the panel
*/
public PteroAdminAPI(String baseURL, String key) {

this.baseURL = baseURL.endsWith("/") ? baseURL + "api/application" : baseURL + "/api/application";
this.baseURL = baseURL.endsWith("/") ? baseURL + "api/application" : baseURL + "/api/application";
this.key = "Bearer " + key;

try {
Expand All @@ -41,6 +45,7 @@ public PteroAdminAPI(String baseURL, String key) {

/**
* Get the UsersController used to fetch users and execute user actions
*
* @return UsersController
*/
public UsersController getUsersController() {
Expand All @@ -49,6 +54,7 @@ public UsersController getUsersController() {

/**
* Get the GenericController used to execute generic actions
*
* @return GenericController
*/
public GenericController getGenericController() {
Expand All @@ -57,6 +63,7 @@ public GenericController getGenericController() {

/**
* Get the ServersController used to fetch servers and execute server actions
*
* @return ServersController
*/
public ServersController getServersController() {
Expand All @@ -65,6 +72,7 @@ public ServersController getServersController() {

/**
* Get the NodesController used to fetch nodes and execute node actions
*
* @return NodesController
*/
public NodesController getNodesController() {
Expand All @@ -73,6 +81,7 @@ public NodesController getNodesController() {

/**
* Get the LocationsController used to fetch locations and execute location actions
*
* @return LocationsController
*/
public LocationsController getLocationsController() {
Expand Down
7 changes: 5 additions & 2 deletions src/main/java/com/stanjg/ptero4j/PteroUserAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ public class PteroUserAPI {

/**
* Create an instance of UserAPI
*
* @param baseURL URL of the panel (like https://panel.myhost.com)
* @param key The client API Key from the panel
* @param key The client API Key from the panel
*/
public PteroUserAPI(String baseURL, String key) {

this.baseURL = baseURL.endsWith("/") ? baseURL + "api/client" : baseURL + "/api/client";
this.baseURL = baseURL.endsWith("/") ? baseURL + "api/client" : baseURL + "/api/client";
this.key = "Bearer " + key;

try {
Expand All @@ -35,6 +36,7 @@ public PteroUserAPI(String baseURL, String key) {

/**
* Get the ServersController used to fetch servers and execute server actions
*
* @return ServersController
*/
public UserServersController getServersController() {
Expand All @@ -43,6 +45,7 @@ public UserServersController getServersController() {

/**
* Get the GenericController used to execute generic actions
*
* @return GenericController
*/
public GenericController getGenericController() {
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/stanjg/ptero4j/actions/PteroAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,28 @@ public interface PteroAction<T> {

/**
* The method to execute the action, should return the updated or created instance of an entity.
*
* @return Updated or create instance of entity.
*/
T execute();

/**
* Define the data to be sent in the request in a JSON form
*
* @return request body data
*/
JSONObject getAsJSON();

/**
* Define the endpoint that the http request should be made to
*
* @return endpoint
*/
String getEndpoint();

/**
* Define what HTTP method should be used to make the request
*
* @return
*/
HTTPMethod getMethod();
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/stanjg/ptero4j/actions/PteroVoidAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,28 @@ public interface PteroVoidAction {

/**
* The method to execute the action, should return the returned http status code.
*
* @return
*/
int execute();

/**
* Define the data to be sent in the request in a JSON form
*
* @return request body data
*/
JSONObject getAsJSON();

/**
* Define the endpoint that the http request should be made to
*
* @return endpoint
*/
String getEndpoint();

/**
* Define what HTTP method should be used to make the request
*
* @return
*/
HTTPMethod getMethod();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ public JSONObject getAsJSON() {

@Override
public String getEndpoint() {
return "/servers/"+serverId+"/build";
return "/servers/" + serverId + "/build";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public ServerUpdateDetailsAction(PteroAdminAPI api, Server server) {

json.put("name", server.getName());
json.put("description", server.getDescription());
json.put("external_id", server.getExternalId() == -1 ? null : server.getExternalId());
json.put("external_id", server.getExternalId());
json.put("user", server.getOwnerId());
}

Expand Down Expand Up @@ -68,7 +68,7 @@ public JSONObject getAsJSON() {

@Override
public String getEndpoint() {
return "/servers/"+serverId+"/details";
return "/servers/" + serverId + "/details";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public JSONObject getAsJSON() {

@Override
public String getEndpoint() {
return "/servers/"+serverId+"/startup";
return "/servers/" + serverId + "/startup";
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public JSONObject getAsJSON() {

@Override
public String getEndpoint() {
return "/users/"+user.getId();
return "/users/" + user.getId();
}

@Override
Expand Down
Loading