Skip to content

Commit 5edd712

Browse files
committed
Added JavaDocs Everywhere
1 parent e463315 commit 5edd712

26 files changed

+387
-6
lines changed

src/main/java/dev/le_app/mcss_api_java/Backup.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
import java.time.LocalDateTime;
2020
import java.util.ArrayList;
2121

22+
/**
23+
* This class contains information about a server's backup
24+
*/
2225
public class Backup {
2326

2427
//BACKUP CLASS
@@ -919,6 +922,13 @@ private HttpURLConnection createPutConnection(URL url) throws IOException {
919922
}
920923

921924

925+
/**
926+
* Delete the backup - NOTE: This won't delete the backup files, just the backup information in MCSS
927+
* @throws APIUnauthorizedException If the API key is invalid
928+
* @throws APINotFoundException If the server or backup does not exist
929+
* @throws APINoServerAccessException If the API key does not have access to the server
930+
* @throws IOException If there is an error connecting to the API
931+
*/
922932
public void deleteBackup() throws APIUnauthorizedException, APINotFoundException, APINoServerAccessException, IOException {
923933
if (deleted) {
924934
throw new IllegalStateException("Backup has already been deleted");
@@ -947,6 +957,13 @@ public void deleteBackup() throws APIUnauthorizedException, APINotFoundException
947957
}
948958
}
949959

960+
/**
961+
* Manually run a backup
962+
* @throws APIUnauthorizedException If the API key is invalid
963+
* @throws APINotFoundException If the server or backup does not exist
964+
* @throws APINoServerAccessException If the API key does not have access to the server
965+
* @throws IOException If there is an error connecting to the API
966+
*/
950967
public void runBackup() throws APIUnauthorizedException, APINotFoundException, APINoServerAccessException, IOException {
951968
if (deleted) {
952969
throw new IllegalStateException("Backup has already been deleted");

src/main/java/dev/le_app/mcss_api_java/BackupCompressionType.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
11
package dev.le_app.mcss_api_java;
22

3+
/**
4+
* The type of compression used for backups.
5+
*/
36
public enum BackupCompressionType {
7+
/**
8+
* The backup is very compressed.
9+
*/
410
HIGH(0),
11+
/**
12+
* The backup is compressed normally.
13+
*/
514
LOW(1),
15+
/**
16+
* The backup is not compressed.
17+
*/
618
NONE(2);
719

820
private final int compressionType;
@@ -11,10 +23,19 @@ public enum BackupCompressionType {
1123
this.compressionType = compressionType;
1224
}
1325

26+
/**
27+
* Gets associated valye for the compression type - Used for API requests.
28+
* @return The compression type as INT.
29+
*/
1430
public int getValue() {
1531
return compressionType;
1632
}
1733

34+
/**
35+
* Gets the compression type from the value.
36+
* @param abbr The value to get the compression type from.
37+
* @return The compression type.
38+
*/
1839
public static BackupCompressionType findByVal(int abbr){
1940
for(BackupCompressionType v : values()){
2041
if( v.getValue() == abbr ){

src/main/java/dev/le_app/mcss_api_java/BackupJob.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,22 @@
1212
import java.net.URL;
1313
import java.util.ArrayList;
1414

15+
/**
16+
* Represents a backup job.
17+
*/
1518
public class BackupJob extends Job {
1619

1720
private final MCSSApi api;
1821
private final String GUID;
1922
private final String TaskID;
2023

2124

25+
/**
26+
* Constructs a new BackupJob.
27+
* @param api instance of MCSSApi
28+
* @param GUID GUID of the backup job
29+
* @param TaskID TaskID of the backup job
30+
*/
2231
public BackupJob(MCSSApi api, String GUID, String TaskID) {
2332
this.api = api;
2433
this.GUID = GUID;

src/main/java/dev/le_app/mcss_api_java/Endpoints.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,61 @@
11
package dev.le_app.mcss_api_java;
22

3+
/** List of endpoints for the API. */
34
public enum Endpoints {
5+
/** Root endpoint of the API */
46
ROOT("https://{IP}/api/v1"),
7+
/** Endpoint for getting server list */
58
SERVERS("https://{IP}/api/v1/servers"),
9+
/** Endpoint for getting server details */
610
SERVER_DETAILS("https://{IP}/api/v1/servers/{SERVER_ID}"),
11+
/** Endpoint for getting server count*/
712
SERVER_COUNT("https://{IP}/api/v1/servers/count"),
13+
/** Endpoint for getting server count with filter */
814
SERVER_COUNT_FILTER("https://{IP}/api/v1/servers/count?filter={FILTER}"),
15+
/** Endpoint for getting server list with filter and servertype */
916
SERVER_COUNT_FILTER_SRVTYPE("https://{IP}/api/v1/servers/count?filter={FILTER}&serverTypeID={SRVTYPE}"),
17+
/** Endpoint for executing a server action */
1018
EXECUTE_SERVER_ACTION("https://{IP}/api/v1/servers/{SERVER_ID}/execute/action"),
19+
/** Endpoint for executing a server command */
1120
EXECUTE_SERVER_COMMAND("https://{IP}/api/v1/servers/{SERVER_ID}/execute/command"),
21+
/** Endpoint for executing multiple commands */
1222
EXECUTE_SERVER_COMMANDS("https://{IP}/api/v1/servers/{SERVER_ID}/execute/commands"),
23+
/** Endpoint for getting server backup list */
1324
SERVER_BACKUPS("https://{IP}/api/v1/servers/{SERVER_ID}/backups"),
25+
/** Endpoint for getting server backup details */
1426
SERVER_BACKUP_DETAILS("https://{IP}/api/v1/servers/{SERVER_ID}/backups/{BACKUP_ID}"),
27+
/** Endpoint for getting the server stats */
1528
GET_STATS("https://{IP}/api/v1/servers/{SERVER_ID}/stats"),
29+
/** Endpoint for getting the server icon */
1630
GET_ICON("https://{IP}/api/v1/servers/{SERVER_ID}/icon"),
31+
/** Endpoint for getting the server console */
1732
GET_CONSOLE("https://{IP}/api/v1/servers/{SERVER_ID}/console?AmountOfLines={AMOUNT_OF_LINES}"),
33+
/** Endpoint for getting the server console from beginning */
1834
GET_CONSOLE_FROM_BEGINNING("https://{IP}/api/v1/servers/{SERVER_ID}/console?AmountOfLines={AMOUNT_OF_LINES}" +
1935
"&takeFromBeginning={BEGINNING}"),
36+
/** Endpoint for getting the server console reversed */
2037
GET_CONSOLE_REVERSED("https://{IP}/api/v1/servers/{SERVER_ID}/console?AmountOfLines={AMOUNT_OF_LINES}" +
2138
"&reversed={REVERSED}"),
39+
/** Endpoint for getting the server console from beginning reversed */
2240
GET_CONSOLE_FROM_BEGINNING_REVERSED("https://{IP}/api/v1/servers/{SERVER_ID}/console?AmountOfLines={AMOUNT_OF_LINES}" +
2341
"&takeFromBeginning={BEGINNING}&reversed={REVERSED}"),
2442

43+
/** Endpoint for checking if the console is outdated */
2544
IS_CONSOLE_OUTDATED("https://{IP}/api/v1/servers/{SERVER_ID}/console/outdated?lastLine={LAST_LINE}" +
2645
"&secondLastLine={SECOND_LAST_LINE}"),
2746

47+
/** Endpoint for getting the server scheduler */
2848
GET_SCHEDULER("https://{IP}/api/v1/servers/{SERVER_ID}/scheduler"),
2949

50+
/** Endpoint for getting the task amount filtered */
3051
GET_TASK_AMOUNT_FILTER("https://{IP}/api/v1/servers/{SERVER_ID}/scheduler/tasks/count?filter={FILTER}"),
3152

53+
/** Endpoint for getting the task list */
3254
GET_TASK_LIST("https://{IP}/api/v1/servers/{SERVER_ID}/scheduler/tasks"),
55+
/** Endpoint for creating a task */
3356
CREATE_TASK("https://{IP}/api/v1/servers/{SERVER_ID}/scheduler/tasks"),
3457

58+
/** Endpoint for getting the task details */
3559
GET_TASK("https://{IP}/api/v1/servers/{SERVER_ID}/scheduler/tasks/{TASK_ID}");
3660

3761

@@ -41,6 +65,10 @@ public enum Endpoints {
4165
this.endpoint = endpoint;
4266
}
4367

68+
/**
69+
* Returns the endpoint as string.
70+
* @return The endpoint as string.
71+
*/
4472
public String getEndpoint() {
4573
return endpoint;
4674
}

src/main/java/dev/le_app/mcss_api_java/Errors.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,86 @@
11
package dev.le_app.mcss_api_java;
22

3+
/** List of possible errors of the API */
34
public enum Errors {
45

56
//General Purpose
7+
8+
/** Unauthorized */
69
UNAUTHORIZED("API Token is invalid or expired. (ERR_401)"),
10+
/** Not Found */
711
NOT_FOUND("TaskID / ServerID / BackupID invalid. (ERR_404)"),
12+
/** Version not supported */
813
VERSION_MISMATCH("API version mismatch. Expected version: {VERSION}, got {GOT}"),
14+
/** Error code was not recognized */
915
NOT_RECOGNIZED("Error code not recognized. (ERR_UNKNOWN): "),
16+
/** API doesn't have access to this server */
1017
NO_SERVER_ACCESS("You do not have access to this server. (ERR_403)"),
1118

19+
/** Filter error */
1220
ID_FILTER_ERROR("The serverTypeID is only required if the filter is set to FILTER"),
1321

1422
//Tasks - Job Messages
23+
/** Task details are invalid */
1524
INVALID_TASK_DETAILS("Task details are invalid. (ERR_409)"),
25+
/** Task name contains special chars */
1626
NAME_SPECIAL_CHAR("Task name cannot contain special characters."),
1727

28+
/** Task is already deleted */
1829
TASK_ALREADY_DELETED("Task has already been deleted."),
30+
/** Task has been deleted */
1931
TASK_DELETED("Cannot edit/execute a deleted task."),
32+
/** Task Deleted - JOB */
2033
JOB_DELETED("Cannot get Job of a deleted task."),
34+
/** Task Deleted - ENABLE */
2135
ENABLE_DELETED("Cannot enable a deleted task."),
36+
/** Task Deleted - DISABLE */
2237
DISABLE_DELETED("Cannot disable a deleted task."),
38+
/** Task Deleted - REPEAT */
2339
REPEAT_DELETED("Cannot repeat a deleted task."),
40+
/** Task Deleted - RUN */
2441
RUN_DELETED("Cannot run a deleted task."),
42+
/** Task Deleted - CHANGE NAME */
2543
CHANGE_NAME_DELETED("Cannot change name of a deleted task."),
44+
/** Task Deleted - TIMING */
2645
INTERVAL_DELETED("Cannot get/set interval of a deleted task."),
46+
/** Task Deleted - TIMING */
2747
TIME_DELETED("Cannot get/set time of a deleted task."),
2848

49+
/** Task doesn't have a valid job type */
2950
INVALID_JOB_TYPE("Task has invalid Job type."),
51+
/** Task has no timing information */
3052
NO_TIMING_INFORMATION("Task has no timing information."),
53+
/** Task time was invalid */
3154
COULD_NOT_PARSE_TIME("Could not parse time to LocalTime."),
3255

56+
/** Cannot repeat a timeless task */
3357
REPEAT_TIMELESS("Timeless tasks cannot be repeated."),
58+
/** Cannot get time for a timeless task */
3459
TIME_TIMELESS("Timeless tasks don't have time details."),
60+
/** Cannot get interval for a timeless task */
3561
INTERVAL_TIMELESS("Timeless tasks don't have an interval."),
62+
/** Cannot enable a timeless task */
3663
ENABLE_TIMELESS("Timeless tasks cannot be enabled."),
64+
/** Cannot disable a timeless task */
3765
DISABLE_TIMELESS("Timeless tasks cannot be disabled."),
3866

67+
/** Cannot get time of interval task */
3968
TIME_INTERVAL("Interval tasks don't have time details."),
69+
/** Interval must be more than 0 */
4070
INTERVAL_GREATER_0("Interval must be greater than 0."),
4171

72+
/** Cannot get interval of time task */
4273
INTERVAL_FIXED_TIME("Fixed time tasks don't have an interval."),
4374

75+
/** No Commands found for task */
4476
COMMANDS_NOT_FOUND("No commands found for this task."),
77+
/** No Commands given for task */
4578
COMMANDS_NOT_GIVEN("No commands were supplied for this task."),
4679

80+
/** Method not available for this job type */
4781
METHOD_NOT_SUPPORTED("This method is not supported for this job type."),
4882

83+
/** Task doesn't have an action */
4984
ACTION_NOT_FOUND("No action found for this task.");
5085

5186
private final String message;
@@ -54,6 +89,10 @@ public enum Errors {
5489
this.message = message;
5590
}
5691

92+
/**
93+
* Gets the message of the error.
94+
* @return The message of the error.
95+
*/
5796
public String getMessage() {
5897
return message;
5998
}

src/main/java/dev/le_app/mcss_api_java/Info.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package dev.le_app.mcss_api_java;
22

3-
3+
/**
4+
* The information about the API.
5+
*/
46
public class Info {
57

68
private boolean isDev = false;
@@ -46,6 +48,9 @@ public String getUniqueID() {
4648
return UniqueID;
4749
}
4850

51+
/**
52+
* @return the youAreAwesome
53+
*/
4954
public boolean getYouAreAwesome() {
5055
return youAreAwesome;
5156
}

src/main/java/dev/le_app/mcss_api_java/Job.java

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,71 @@
77
import java.io.IOException;
88
import java.util.ArrayList;
99

10+
/**
11+
* Represents a job.
12+
*/
1013
public abstract class Job {
1114

15+
/**
16+
* Get the action of the task.
17+
* @return The action of the task.
18+
* @throws APIUnauthorizedException If the API key is not valid.
19+
* @throws APINotFoundException If the server is not found.
20+
* @throws IOException If there is an IO error (e.g. server is offline).
21+
* @throws APIInvalidTaskDetailsException If the task details are invalid.
22+
*/
1223
public abstract ServerAction getAction() throws APIUnauthorizedException, APINotFoundException, IOException, APIInvalidTaskDetailsException;
1324

25+
/**
26+
* Get the commands of the task.
27+
* @return The commands of the task.
28+
* @throws APIUnauthorizedException If the API key is not valid.
29+
* @throws APINotFoundException If the server is not found.
30+
* @throws IOException If there is an IO error (e.g. server is offline).
31+
* @throws APIInvalidTaskDetailsException If the task details are invalid.
32+
*/
1433
public abstract ArrayList<String> getCommands() throws APIUnauthorizedException, APINotFoundException, IOException, APIInvalidTaskDetailsException;
1534

35+
/**
36+
* Get the Backup ID of the backup executed by the task
37+
* @return The Backup ID of the backup executed by the task
38+
* @throws APIUnauthorizedException If the API key is not valid.
39+
* @throws APINotFoundException If the server is not found.
40+
* @throws IOException If there is an IO error (e.g. server is offline).
41+
*/
1642
public abstract String getBackupGUID() throws APIUnauthorizedException, APINotFoundException, IOException;
1743

44+
/**
45+
* Set the new action to execute
46+
* @param action The new action to execute
47+
* @return this.Job (used for concatenating)
48+
* @throws APIUnauthorizedException If the API key is not valid.
49+
* @throws APINotFoundException If the server is not found.
50+
* @throws APIInvalidTaskDetailsException If the task details are invalid.
51+
* @throws IOException If there is an IO error (e.g. server is offline).
52+
*/
1853
public abstract Job setAction(ServerAction action) throws APIUnauthorizedException, APINotFoundException, APIInvalidTaskDetailsException, IOException;
1954

55+
/**
56+
* Set the new commands to execute
57+
* @param commands The new commands to execute
58+
* @return this.Job (used for concatenating)
59+
* @throws APIUnauthorizedException If the API key is not valid.
60+
* @throws APINotFoundException If the server is not found.
61+
* @throws APIInvalidTaskDetailsException If the task details are invalid.
62+
* @throws IOException If there is an IO error (e.g. server is offline).
63+
*/
2064
public abstract Job setCommands(String... commands) throws APIUnauthorizedException, APINotFoundException, APIInvalidTaskDetailsException, IOException;
2165

66+
/**
67+
* Set the new backup to execute
68+
* @param backupGUID The new backup to execute
69+
* @return this.Job (used for concatenating)
70+
* @throws APIUnauthorizedException If the API key is not valid.
71+
* @throws APINotFoundException If the server is not found.
72+
* @throws APIInvalidTaskDetailsException If the task details are invalid.
73+
* @throws IOException If there is an IO error (e.g. server is offline).
74+
*/
2275
public abstract Job setBackupGUID(String backupGUID) throws APIUnauthorizedException, APINotFoundException, IOException, APIInvalidTaskDetailsException;
2376

2477

src/main/java/dev/le_app/mcss_api_java/KeepOnline.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
package dev.le_app.mcss_api_java;
22

3+
/**
4+
* The keep online behaviour of a server
5+
*/
36
public enum KeepOnline {
47

8+
/** Server can shutdown / crash */
59
NONE(0),
10+
/** Server will be restarted if it crashes */
611
ELEVATED(1),
12+
/** Server will be restarted if it crashes or is shutdown */
713
AGGRESSIVE(2);
814

915
private final int value;
@@ -12,8 +18,17 @@ public enum KeepOnline {
1218
value = newValue;
1319
}
1420

21+
/**
22+
* Gets associated value for the keep online behaviour - Used for API requests.
23+
* @return The keep online behaviour as INT.
24+
*/
1525
public int getValue() { return value; }
1626

27+
/**
28+
* Gets the keep online behaviour from the value.
29+
* @param abbr The value to get the keep online behaviour from.
30+
* @return The keep online behaviour.
31+
*/
1732
public static KeepOnline findByVal(int abbr){
1833
for(KeepOnline v : values()){
1934
if( v.getValue() == abbr ){

0 commit comments

Comments
 (0)