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
11 changes: 11 additions & 0 deletions api/src/main/java/app/simplecloud/api/CloudApi.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package app.simplecloud.api;

import app.simplecloud.api.blueprint.BlueprintApi;
import app.simplecloud.api.cache.QueryCache;
import app.simplecloud.api.cache.QueryKey;
import app.simplecloud.api.event.EventApi;
Expand Down Expand Up @@ -96,6 +97,16 @@ static CloudApi create(CloudApiOptions options) {
*/
PersistentServerApi persistentServer();

/**
* Returns the blueprint management API.
*
* <p>Use this to create, read, update, and delete blueprints that groups and servers can use
* as reusable source templates.
*
* @return the blueprint API
*/
BlueprintApi blueprint();

/**
* Returns the event subscription API.
*
Expand Down
61 changes: 61 additions & 0 deletions api/src/main/java/app/simplecloud/api/blueprint/BlueprintApi.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
package app.simplecloud.api.blueprint;

import java.util.List;
import java.util.concurrent.CompletableFuture;

/**
* API for managing blueprints.
*
* <p>Blueprints define reusable runtime and software templates that groups and servers can use
* as their base source configuration.
*/
public interface BlueprintApi {

/**
* Retrieves a blueprint by its unique identifier.
*
* @param id the blueprint ID
* @return a CompletableFuture that completes with the blueprint, or fails if not found
*/
CompletableFuture<Blueprint> getBlueprintById(String id);

/**
* Retrieves a blueprint by its name.
*
* @param name the blueprint name
* @return a CompletableFuture that completes with the blueprint, or fails if not found
*/
CompletableFuture<Blueprint> getBlueprintByName(String name);

/**
* Retrieves all blueprints.
*
* @return a CompletableFuture that completes with all available blueprints
*/
CompletableFuture<List<Blueprint>> getAllBlueprints();

/**
* Creates a new blueprint.
*
* @param request the blueprint configuration to create
* @return a CompletableFuture that completes with the created blueprint
*/
CompletableFuture<Blueprint> createBlueprint(CreateBlueprintRequest request);

/**
* Updates an existing blueprint.
*
* @param id the blueprint ID to update
* @param request the fields to update
* @return a CompletableFuture that completes with the updated blueprint
*/
CompletableFuture<Blueprint> updateBlueprint(String id, UpdateBlueprintRequest request);

/**
* Deletes a blueprint.
*
* @param id the blueprint ID to delete
* @return a CompletableFuture that completes when the blueprint has been deleted
*/
CompletableFuture<Void> deleteBlueprint(String id);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
package app.simplecloud.api.blueprint;

import org.jetbrains.annotations.Nullable;

import java.util.List;

/**
* Request to create a new blueprint.
*/
public class CreateBlueprintRequest {
private final String name;
private final String configurator;
private final String minecraftVersion;
private final String serverSoftware;
private final String serverUrl;
private final String softwareVersion;
private final RuntimeConfig runtimeConfig;
private final List<String> workflowSteps;

private CreateBlueprintRequest(Builder builder) {
this.name = builder.name;
this.configurator = builder.configurator;
this.minecraftVersion = builder.minecraftVersion;
this.serverSoftware = builder.serverSoftware;
this.serverUrl = builder.serverUrl;
this.softwareVersion = builder.softwareVersion;
this.runtimeConfig = builder.runtimeConfig;
this.workflowSteps = builder.workflowSteps;
}

public String getName() {
return name;
}

@Nullable
public String getConfigurator() {
return configurator;
}

@Nullable
public String getMinecraftVersion() {
return minecraftVersion;
}

@Nullable
public String getServerSoftware() {
return serverSoftware;
}

@Nullable
public String getServerUrl() {
return serverUrl;
}

@Nullable
public String getSoftwareVersion() {
return softwareVersion;
}

@Nullable
public RuntimeConfig getRuntimeConfig() {
return runtimeConfig;
}

@Nullable
public List<String> getWorkflowSteps() {
return workflowSteps;
}

public static Builder builder() {
return new Builder();
}

public static class Builder {
private String name;
private String configurator;
private String minecraftVersion;
private String serverSoftware;
private String serverUrl;
private String softwareVersion;
private RuntimeConfig runtimeConfig;
private List<String> workflowSteps;

public Builder name(String name) {
this.name = name;
return this;
}

public Builder configurator(String configurator) {
this.configurator = configurator;
return this;
}

public Builder minecraftVersion(String minecraftVersion) {
this.minecraftVersion = minecraftVersion;
return this;
}

public Builder serverSoftware(String serverSoftware) {
this.serverSoftware = serverSoftware;
return this;
}

public Builder serverUrl(String serverUrl) {
this.serverUrl = serverUrl;
return this;
}

public Builder softwareVersion(String softwareVersion) {
this.softwareVersion = softwareVersion;
return this;
}

public Builder runtimeConfig(RuntimeConfig runtimeConfig) {
this.runtimeConfig = runtimeConfig;
return this;
}

public Builder workflowSteps(List<String> workflowSteps) {
this.workflowSteps = workflowSteps;
return this;
}

public CreateBlueprintRequest build() {
if (name == null) {
throw new IllegalStateException("name is required");
}
return new CreateBlueprintRequest(this);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
package app.simplecloud.api.blueprint;

import org.jetbrains.annotations.Nullable;

import java.util.List;

/**
* Request to update an existing blueprint.
* All fields are optional.
*/
public class UpdateBlueprintRequest {
private final String name;
private final String configurator;
private final String minecraftVersion;
private final String serverSoftware;
private final String serverUrl;
private final String softwareVersion;
private final RuntimeConfig runtimeConfig;
private final List<String> workflowSteps;

private UpdateBlueprintRequest(Builder builder) {
this.name = builder.name;
this.configurator = builder.configurator;
this.minecraftVersion = builder.minecraftVersion;
this.serverSoftware = builder.serverSoftware;
this.serverUrl = builder.serverUrl;
this.softwareVersion = builder.softwareVersion;
this.runtimeConfig = builder.runtimeConfig;
this.workflowSteps = builder.workflowSteps;
}

@Nullable
public String getName() {
return name;
}

@Nullable
public String getConfigurator() {
return configurator;
}

@Nullable
public String getMinecraftVersion() {
return minecraftVersion;
}

@Nullable
public String getServerSoftware() {
return serverSoftware;
}

@Nullable
public String getServerUrl() {
return serverUrl;
}

@Nullable
public String getSoftwareVersion() {
return softwareVersion;
}

@Nullable
public RuntimeConfig getRuntimeConfig() {
return runtimeConfig;
}

@Nullable
public List<String> getWorkflowSteps() {
return workflowSteps;
}

public static Builder builder() {
return new Builder();
}

public static class Builder {
private String name;
private String configurator;
private String minecraftVersion;
private String serverSoftware;
private String serverUrl;
private String softwareVersion;
private RuntimeConfig runtimeConfig;
private List<String> workflowSteps;

public Builder name(String name) {
this.name = name;
return this;
}

public Builder configurator(String configurator) {
this.configurator = configurator;
return this;
}

public Builder minecraftVersion(String minecraftVersion) {
this.minecraftVersion = minecraftVersion;
return this;
}

public Builder serverSoftware(String serverSoftware) {
this.serverSoftware = serverSoftware;
return this;
}

public Builder serverUrl(String serverUrl) {
this.serverUrl = serverUrl;
return this;
}

public Builder softwareVersion(String softwareVersion) {
this.softwareVersion = softwareVersion;
return this;
}

public Builder runtimeConfig(RuntimeConfig runtimeConfig) {
this.runtimeConfig = runtimeConfig;
return this;
}

public Builder workflowSteps(List<String> workflowSteps) {
this.workflowSteps = workflowSteps;
return this;
}

public UpdateBlueprintRequest build() {
return new UpdateBlueprintRequest(this);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
public enum EntityType {
SERVER,
GROUP,
BLUEPRINT,
PERSISTENT_SERVER,
PLAYER
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public interface QueryCache {
* For example, {@code invalidateAll(QueryKey.of("servers"))} invalidates:
* <ul>
* <li>{@code QueryKey.of("servers")}</li>
* <li>{@code QueryKey.of("servers", "group", "Lobby")}</li>
* <li>{@code QueryKey.of("servers", "serverBaseName", "Lobby")}</li>
* <li>{@code QueryKey.of("servers", "query", ...)}</li>
* </ul>
*
Expand Down
Loading