mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
feat(datasync): add the DataSync management plane (#3377)
* feat(datasync): add the DataSync management plane Emulates the AWS DataSync management API over JSON (X-Amz-Target FmrsService.<Action>, signing name datasync): agents, the eleven CreateLocation/DescribeLocation/UpdateLocation trios plus the shared ListLocations and DeleteLocation, tasks, and resource tagging. Each DescribeLocation* projects the create request that produced the location, so the configuration that went in is the configuration that comes back, and LocationUri is derived from that request per the scheme AWS documents for the type. DescribeAgent reports ONLINE and DescribeTask reports AVAILABLE from the first read, which is what the Terraform provider's aws_datasync_task waits on. Credential members (Password, SecretKey, SasConfiguration, the Kerberos files and the nested Protocol.SMB.Password) are dropped before the configuration is stored, as AWS never reads them back either. Errors use InvalidRequestException, the only client error the DataSync model declares. The task-execution data plane (StartTaskExecution, DescribeTaskExecution, ListTaskExecutions, CancelTaskExecution, UpdateTaskExecution) transfers real bytes between real storage systems and keeps raising UnknownOperationException rather than a stub success. * fix(datasync): default VerifyMode from the task mode The DataSync model documents two VerifyMode defaults, not one: POINT_IN_TIME_CONSISTENT for a BASIC task and ONLY_FILES_TRANSFERRED for an ENHANCED one, which also cannot use POINT_IN_TIME_CONSISTENT at all. CreateTask applied the BASIC default to every task, so an ENHANCED task created without an explicit VerifyMode read back wrong. The default now follows TaskMode, and a VerifyMode the mode does not support is rejected with InvalidRequestException, the only client error this API declares. UpdateTaskRequest carries no TaskMode, so a task keeps the mode it was created with and UpdateTask applies the same rule against the stored mode. An unrecognized TaskMode is rejected rather than silently treated as BASIC. * test(datasync): add the SDK compatibility test Drives an agent, an S3 and an NFS location, both task modes and the tag round trip through the AWS SDK v2 DataSync client, which is the one piece of real-SDK verification the RestAssured tests do not cover. It asserts the VerifyMode default for a BASIC and an ENHANCED task, and that an ENHANCED task rejects POINT_IN_TIME_CONSISTENT on create and on update. --------- Co-authored-by: lex00 <artigues.dev@gmail.com>
This commit is contained in:
1 parent
e096e08690
commit
128d3ef181
22 files changed
+3049
-1
No files matched your search
@@ -743,6 +743,7 @@ public interface EmulatorConfig {
|
||||
AppIntegrationsServiceConfig appintegrations();
|
||||
CognitoIdentityServiceConfig cognitoidentity();
|
||||
GlobalAcceleratorServiceConfig globalaccelerator();
|
||||
DataSyncServiceConfig datasync();
|
||||
|
||||
ApsServiceConfig aps();
|
||||
|
||||
@@ -772,6 +773,11 @@ public interface EmulatorConfig {
|
||||
boolean enabled();
|
||||
}
|
||||
|
||||
interface DataSyncServiceConfig {
|
||||
@WithDefault("true")
|
||||
boolean enabled();
|
||||
}
|
||||
|
||||
interface SsoAdminServiceConfig {
|
||||
@WithDefault("true")
|
||||
boolean enabled();
|
||||
|
||||
@@ -52,6 +52,7 @@ import io.github.hectorvent.floci.services.secretsmanager.SecretsManagerJsonHand
|
||||
import io.github.hectorvent.floci.services.organizations.OrganizationsJsonHandler;
|
||||
import io.github.hectorvent.floci.services.cognitoidentity.CognitoIdentityJsonHandler;
|
||||
import io.github.hectorvent.floci.services.globalaccelerator.GlobalAcceleratorJsonHandler;
|
||||
import io.github.hectorvent.floci.services.datasync.DataSyncJsonHandler;
|
||||
import io.github.hectorvent.floci.services.route53resolver.Route53ResolverJsonHandler;
|
||||
import io.github.hectorvent.floci.services.networkfirewall.NetworkFirewallJsonHandler;
|
||||
import io.github.hectorvent.floci.services.servicecatalog.ServiceCatalogJsonHandler;
|
||||
@@ -125,6 +126,7 @@ public class AwsJson11Controller {
|
||||
private final Route53ResolverJsonHandler route53ResolverJsonHandler;
|
||||
private final CognitoIdentityJsonHandler cognitoIdentityJsonHandler;
|
||||
private final GlobalAcceleratorJsonHandler globalAcceleratorJsonHandler;
|
||||
private final DataSyncJsonHandler dataSyncJsonHandler;
|
||||
private final NetworkFirewallJsonHandler networkFirewallJsonHandler;
|
||||
private final ServiceCatalogJsonHandler serviceCatalogJsonHandler;
|
||||
private final CloudControlJsonHandler cloudControlJsonHandler;
|
||||
@@ -178,6 +180,7 @@ public class AwsJson11Controller {
|
||||
Route53ResolverJsonHandler route53ResolverJsonHandler,
|
||||
CognitoIdentityJsonHandler cognitoIdentityJsonHandler,
|
||||
GlobalAcceleratorJsonHandler globalAcceleratorJsonHandler,
|
||||
DataSyncJsonHandler dataSyncJsonHandler,
|
||||
NetworkFirewallJsonHandler networkFirewallJsonHandler,
|
||||
ServiceCatalogJsonHandler serviceCatalogJsonHandler,
|
||||
CloudControlJsonHandler cloudControlJsonHandler,
|
||||
@@ -235,6 +238,7 @@ public class AwsJson11Controller {
|
||||
this.route53ResolverJsonHandler = route53ResolverJsonHandler;
|
||||
this.cognitoIdentityJsonHandler = cognitoIdentityJsonHandler;
|
||||
this.globalAcceleratorJsonHandler = globalAcceleratorJsonHandler;
|
||||
this.dataSyncJsonHandler = dataSyncJsonHandler;
|
||||
this.networkFirewallJsonHandler = networkFirewallJsonHandler;
|
||||
this.serviceCatalogJsonHandler = serviceCatalogJsonHandler;
|
||||
this.cloudControlJsonHandler = cloudControlJsonHandler;
|
||||
@@ -327,6 +331,7 @@ public class AwsJson11Controller {
|
||||
// segment and are never partitioned by the region the caller signed with, so the
|
||||
// handler takes no region.
|
||||
case "globalaccelerator" -> globalAcceleratorJsonHandler.handle(action, request);
|
||||
case "datasync" -> dataSyncJsonHandler.handle(action, request, region);
|
||||
case "network-firewall" -> networkFirewallJsonHandler.handle(
|
||||
action, request, region, regionResolver.getAccountId());
|
||||
case "servicecatalog" -> serviceCatalogJsonHandler.handle(
|
||||
|
||||
@@ -636,6 +636,12 @@ public class ResolvedServiceCatalog {
|
||||
"globalaccelerator", config.storage().mode(), 5000L, null, ServiceProtocol.JSON,
|
||||
protocols(ServiceProtocol.JSON),
|
||||
Set.of("GlobalAccelerator_V20180706."), Set.of("globalaccelerator"), Set.of(), Set.of()),
|
||||
// DataSync's Smithy service shape is FmrsService, so that is the target prefix
|
||||
// the SDK sends, not the service name.
|
||||
descriptor("datasync", "datasync", config.services().datasync().enabled(), true,
|
||||
"datasync", config.storage().mode(), 5000L, null, ServiceProtocol.JSON,
|
||||
protocols(ServiceProtocol.JSON),
|
||||
Set.of("FmrsService."), Set.of("datasync"), Set.of(), Set.of()),
|
||||
descriptor("network-firewall", "networkfirewall", config.services().networkfirewall().enabled(), true,
|
||||
"networkfirewall", config.storage().mode(), 5000L, null, ServiceProtocol.JSON,
|
||||
protocols(ServiceProtocol.JSON),
|
||||
|
||||
@@ -0,0 +1,265 @@
|
||||
package io.github.hectorvent.floci.services.datasync;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.services.datasync.model.DataSyncAgent;
|
||||
import io.github.hectorvent.floci.services.datasync.model.DataSyncLocation;
|
||||
import io.github.hectorvent.floci.services.datasync.model.DataSyncLocationType;
|
||||
import io.github.hectorvent.floci.services.datasync.model.DataSyncTask;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Translates the DataSync JSON wire protocol ({@code X-Amz-Target: FmrsService.<Action>})
|
||||
* to and from {@link DataSyncService}.
|
||||
*
|
||||
* <p>The task-execution data plane ({@code StartTaskExecution}, {@code DescribeTaskExecution},
|
||||
* {@code ListTaskExecutions}, {@code CancelTaskExecution}, {@code UpdateTaskExecution}) moves
|
||||
* real bytes between real storage systems and is not emulated. Those operations fall through
|
||||
* to a clean {@code UnknownOperationException} rather than a stub success, so callers fail
|
||||
* fast instead of stranding a waiter on a transfer that will never progress.
|
||||
*
|
||||
* <p>Every location action is spelled out as its own switch label rather than matched by
|
||||
* prefix: the action tables in {@code docs/services/datasync.md} are generated from these
|
||||
* labels, and a prefix match would document none of them.
|
||||
*/
|
||||
@ApplicationScoped
|
||||
public class DataSyncJsonHandler {
|
||||
|
||||
private static final String CREATE_LOCATION = "CreateLocation";
|
||||
private static final String DESCRIBE_LOCATION = "DescribeLocation";
|
||||
private static final String UPDATE_LOCATION = "UpdateLocation";
|
||||
|
||||
private final DataSyncService dataSyncService;
|
||||
private final ObjectMapper mapper;
|
||||
|
||||
@Inject
|
||||
public DataSyncJsonHandler(DataSyncService dataSyncService, ObjectMapper mapper) {
|
||||
this.dataSyncService = dataSyncService;
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
public Response handle(String action, JsonNode request, String region) {
|
||||
return switch (action) {
|
||||
case "CreateAgent" -> {
|
||||
DataSyncAgent agent = dataSyncService.createAgent(request, region);
|
||||
yield ok(mapper.createObjectNode().put("AgentArn", agent.getAgentArn()));
|
||||
}
|
||||
case "DescribeAgent" -> ok(describeAgent(dataSyncService.getAgent(text(request, "AgentArn"))));
|
||||
case "UpdateAgent" -> {
|
||||
dataSyncService.updateAgent(text(request, "AgentArn"), text(request, "Name"));
|
||||
yield ok(mapper.createObjectNode());
|
||||
}
|
||||
case "DeleteAgent" -> {
|
||||
dataSyncService.deleteAgent(text(request, "AgentArn"));
|
||||
yield ok(mapper.createObjectNode());
|
||||
}
|
||||
case "ListAgents" -> {
|
||||
var page = dataSyncService.listAgents(text(request, "NextToken"),
|
||||
request.path("MaxResults").asInt(0));
|
||||
ObjectNode response = mapper.createObjectNode();
|
||||
ArrayNode entries = response.putArray("Agents");
|
||||
for (DataSyncAgent agent : page.items()) {
|
||||
ObjectNode entry = entries.addObject();
|
||||
entry.put("AgentArn", agent.getAgentArn());
|
||||
entry.put("Name", agent.getName() != null ? agent.getName() : "");
|
||||
entry.put("Status", agent.getStatus());
|
||||
entry.putObject("Platform").put("Version", agent.getPlatformVersion());
|
||||
}
|
||||
putNextToken(response, page.nextToken());
|
||||
yield ok(response);
|
||||
}
|
||||
|
||||
case "CreateLocationAzureBlob", "CreateLocationEfs", "CreateLocationFsxLustre",
|
||||
"CreateLocationFsxOntap", "CreateLocationFsxOpenZfs", "CreateLocationFsxWindows",
|
||||
"CreateLocationHdfs", "CreateLocationNfs", "CreateLocationObjectStorage",
|
||||
"CreateLocationS3", "CreateLocationSmb" -> {
|
||||
DataSyncLocation location = dataSyncService.createLocation(
|
||||
locationType(action, CREATE_LOCATION), request, region);
|
||||
yield ok(mapper.createObjectNode().put("LocationArn", location.getLocationArn()));
|
||||
}
|
||||
case "DescribeLocationAzureBlob", "DescribeLocationEfs", "DescribeLocationFsxLustre",
|
||||
"DescribeLocationFsxOntap", "DescribeLocationFsxOpenZfs", "DescribeLocationFsxWindows",
|
||||
"DescribeLocationHdfs", "DescribeLocationNfs", "DescribeLocationObjectStorage",
|
||||
"DescribeLocationS3", "DescribeLocationSmb" -> ok(describeLocation(dataSyncService.getLocation(
|
||||
text(request, "LocationArn"), locationType(action, DESCRIBE_LOCATION))));
|
||||
case "UpdateLocationAzureBlob", "UpdateLocationEfs", "UpdateLocationFsxLustre",
|
||||
"UpdateLocationFsxOntap", "UpdateLocationFsxOpenZfs", "UpdateLocationFsxWindows",
|
||||
"UpdateLocationHdfs", "UpdateLocationNfs", "UpdateLocationObjectStorage",
|
||||
"UpdateLocationS3", "UpdateLocationSmb" -> {
|
||||
dataSyncService.updateLocation(locationType(action, UPDATE_LOCATION), request);
|
||||
yield ok(mapper.createObjectNode());
|
||||
}
|
||||
case "ListLocations" -> {
|
||||
var page = dataSyncService.listLocations(request.get("Filters"),
|
||||
text(request, "NextToken"), request.path("MaxResults").asInt(0));
|
||||
ObjectNode response = mapper.createObjectNode();
|
||||
ArrayNode entries = response.putArray("Locations");
|
||||
for (DataSyncLocation location : page.items()) {
|
||||
ObjectNode entry = entries.addObject();
|
||||
entry.put("LocationArn", location.getLocationArn());
|
||||
entry.put("LocationUri", location.getLocationUri());
|
||||
}
|
||||
putNextToken(response, page.nextToken());
|
||||
yield ok(response);
|
||||
}
|
||||
case "DeleteLocation" -> {
|
||||
dataSyncService.deleteLocation(text(request, "LocationArn"));
|
||||
yield ok(mapper.createObjectNode());
|
||||
}
|
||||
|
||||
case "CreateTask" -> {
|
||||
DataSyncTask task = dataSyncService.createTask(request, region);
|
||||
yield ok(mapper.createObjectNode().put("TaskArn", task.getTaskArn()));
|
||||
}
|
||||
case "DescribeTask" -> ok(describeTask(dataSyncService.getTask(text(request, "TaskArn"))));
|
||||
case "UpdateTask" -> {
|
||||
dataSyncService.updateTask(request);
|
||||
yield ok(mapper.createObjectNode());
|
||||
}
|
||||
case "DeleteTask" -> {
|
||||
dataSyncService.deleteTask(text(request, "TaskArn"));
|
||||
yield ok(mapper.createObjectNode());
|
||||
}
|
||||
case "ListTasks" -> {
|
||||
var page = dataSyncService.listTasks(request.get("Filters"),
|
||||
text(request, "NextToken"), request.path("MaxResults").asInt(0));
|
||||
ObjectNode response = mapper.createObjectNode();
|
||||
ArrayNode entries = response.putArray("Tasks");
|
||||
for (DataSyncTask task : page.items()) {
|
||||
ObjectNode entry = entries.addObject();
|
||||
entry.put("TaskArn", task.getTaskArn());
|
||||
entry.put("Status", task.getStatus());
|
||||
entry.put("Name", task.getName() != null ? task.getName() : "");
|
||||
entry.put("TaskMode", task.getTaskMode());
|
||||
}
|
||||
putNextToken(response, page.nextToken());
|
||||
yield ok(response);
|
||||
}
|
||||
|
||||
case "TagResource" -> {
|
||||
dataSyncService.tagResource(text(request, "ResourceArn"),
|
||||
DataSyncService.tagsOf(request.path("Tags")));
|
||||
yield ok(mapper.createObjectNode());
|
||||
}
|
||||
case "UntagResource" -> {
|
||||
dataSyncService.untagResource(text(request, "ResourceArn"),
|
||||
DataSyncService.stringList(request.path("Keys")));
|
||||
yield ok(mapper.createObjectNode());
|
||||
}
|
||||
case "ListTagsForResource" -> {
|
||||
Map<String, String> tags = dataSyncService.listTagsForResource(text(request, "ResourceArn"));
|
||||
ObjectNode response = mapper.createObjectNode();
|
||||
ArrayNode entries = response.putArray("Tags");
|
||||
tags.forEach((key, value) -> entries.addObject().put("Key", key).put("Value", value));
|
||||
yield ok(response);
|
||||
}
|
||||
|
||||
default -> throw new AwsException("UnknownOperationException",
|
||||
"Operation " + action + " is not supported by floci", 400);
|
||||
};
|
||||
}
|
||||
|
||||
private static DataSyncLocationType locationType(String action, String operationPrefix) {
|
||||
String suffix = action.substring(operationPrefix.length());
|
||||
return DataSyncLocationType.fromOperationSuffix(suffix)
|
||||
.orElseThrow(() -> new AwsException("UnknownOperationException",
|
||||
"Operation " + action + " is not supported by floci", 400));
|
||||
}
|
||||
|
||||
private ObjectNode describeAgent(DataSyncAgent agent) {
|
||||
ObjectNode response = mapper.createObjectNode();
|
||||
response.put("AgentArn", agent.getAgentArn());
|
||||
response.put("Name", agent.getName() != null ? agent.getName() : "");
|
||||
response.put("Status", agent.getStatus());
|
||||
response.put("CreationTime", epochSeconds(agent.getCreationTime()));
|
||||
response.put("LastConnectionTime", epochSeconds(agent.getLastConnectionTime()));
|
||||
response.put("EndpointType", agent.getEndpointType());
|
||||
response.putObject("Platform").put("Version", agent.getPlatformVersion());
|
||||
if (agent.getVpcEndpointId() != null) {
|
||||
ObjectNode privateLink = response.putObject("PrivateLinkConfig");
|
||||
privateLink.put("VpcEndpointId", agent.getVpcEndpointId());
|
||||
putStrings(privateLink, "SubnetArns", agent.getSubnetArns());
|
||||
putStrings(privateLink, "SecurityGroupArns", agent.getSecurityGroupArns());
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
private ObjectNode describeLocation(DataSyncLocation location) {
|
||||
ObjectNode response = mapper.createObjectNode();
|
||||
response.put("LocationArn", location.getLocationArn());
|
||||
response.put("LocationUri", location.getLocationUri());
|
||||
JsonNode configuration = location.getConfiguration();
|
||||
for (String member : location.getLocationType().describeMembers()) {
|
||||
JsonNode value = configuration.get(member);
|
||||
if (value != null && !value.isNull()) {
|
||||
response.set(member, value.deepCopy());
|
||||
}
|
||||
}
|
||||
response.put("CreationTime", epochSeconds(location.getCreationTime()));
|
||||
return response;
|
||||
}
|
||||
|
||||
private ObjectNode describeTask(DataSyncTask task) {
|
||||
ObjectNode response = mapper.createObjectNode();
|
||||
response.put("TaskArn", task.getTaskArn());
|
||||
response.put("Status", task.getStatus());
|
||||
response.put("Name", task.getName() != null ? task.getName() : "");
|
||||
response.put("TaskMode", task.getTaskMode());
|
||||
response.put("SourceLocationArn", task.getSourceLocationArn());
|
||||
response.put("DestinationLocationArn", task.getDestinationLocationArn());
|
||||
if (task.getCloudWatchLogGroupArn() != null) {
|
||||
response.put("CloudWatchLogGroupArn", task.getCloudWatchLogGroupArn());
|
||||
}
|
||||
response.putArray("SourceNetworkInterfaceArns");
|
||||
response.putArray("DestinationNetworkInterfaceArns");
|
||||
response.set("Options", task.getOptions() != null
|
||||
? task.getOptions().deepCopy() : mapper.createObjectNode());
|
||||
response.set("Excludes", task.getExcludes() != null
|
||||
? task.getExcludes().deepCopy() : mapper.createArrayNode());
|
||||
response.set("Includes", task.getIncludes() != null
|
||||
? task.getIncludes().deepCopy() : mapper.createArrayNode());
|
||||
if (task.getSchedule() != null) {
|
||||
response.set("Schedule", task.getSchedule().deepCopy());
|
||||
}
|
||||
if (task.getManifestConfig() != null) {
|
||||
response.set("ManifestConfig", task.getManifestConfig().deepCopy());
|
||||
}
|
||||
if (task.getTaskReportConfig() != null) {
|
||||
response.set("TaskReportConfig", task.getTaskReportConfig().deepCopy());
|
||||
}
|
||||
response.put("CreationTime", epochSeconds(task.getCreationTime()));
|
||||
return response;
|
||||
}
|
||||
|
||||
private static void putStrings(ObjectNode parent, String member, List<String> values) {
|
||||
ArrayNode array = parent.putArray(member);
|
||||
values.forEach(array::add);
|
||||
}
|
||||
|
||||
private static void putNextToken(ObjectNode response, String nextToken) {
|
||||
if (nextToken != null) {
|
||||
response.put("NextToken", nextToken);
|
||||
}
|
||||
}
|
||||
|
||||
private static double epochSeconds(Instant instant) {
|
||||
return (instant != null ? instant : Instant.EPOCH).toEpochMilli() / 1000.0;
|
||||
}
|
||||
|
||||
private static String text(JsonNode request, String member) {
|
||||
return request.hasNonNull(member) ? request.get(member).asText() : null;
|
||||
}
|
||||
|
||||
private static Response ok(ObjectNode body) {
|
||||
return Response.ok(body).build();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,739 @@
|
||||
package io.github.hectorvent.floci.services.datasync;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
import io.github.hectorvent.floci.core.storage.StorageBackend;
|
||||
import io.github.hectorvent.floci.core.storage.StorageFactory;
|
||||
import io.github.hectorvent.floci.services.datasync.model.DataSyncAgent;
|
||||
import io.github.hectorvent.floci.services.datasync.model.DataSyncLocation;
|
||||
import io.github.hectorvent.floci.services.datasync.model.DataSyncLocationType;
|
||||
import io.github.hectorvent.floci.services.datasync.model.DataSyncTaggable;
|
||||
import io.github.hectorvent.floci.services.datasync.model.DataSyncTask;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import java.security.SecureRandom;
|
||||
import java.time.Instant;
|
||||
import java.time.format.DateTimeParseException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* AWS DataSync management plane.
|
||||
*
|
||||
* <p>Agents report {@code ONLINE} and tasks {@code AVAILABLE} from the moment they are
|
||||
* created, so SDK and Terraform waiters finish on their first poll. Every
|
||||
* {@code DescribeLocation*} answer is projected out of the create request that produced
|
||||
* the location, with the location's {@code LocationUri} derived from the same request.
|
||||
* Credential members ({@code Password}, {@code SecretKey}, SAS tokens, Kerberos files)
|
||||
* are dropped before the configuration is stored, matching AWS, which never reads them
|
||||
* back.
|
||||
*/
|
||||
@ApplicationScoped
|
||||
public class DataSyncService {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(DataSyncService.class);
|
||||
|
||||
private static final String HEX_ALPHABET = "0123456789abcdef";
|
||||
private static final int RESOURCE_ID_LENGTH = 17;
|
||||
private static final SecureRandom RANDOM = new SecureRandom();
|
||||
|
||||
public static final String AGENT_STATUS_ONLINE = "ONLINE";
|
||||
public static final String TASK_STATUS_AVAILABLE = "AVAILABLE";
|
||||
public static final String DEFAULT_TASK_MODE = "BASIC";
|
||||
public static final String TASK_MODE_ENHANCED = "ENHANCED";
|
||||
public static final String VERIFY_MODE_POINT_IN_TIME_CONSISTENT = "POINT_IN_TIME_CONSISTENT";
|
||||
public static final String VERIFY_MODE_ONLY_FILES_TRANSFERRED = "ONLY_FILES_TRANSFERRED";
|
||||
|
||||
private static final Set<String> TASK_MODES = Set.of(DEFAULT_TASK_MODE, TASK_MODE_ENHANCED);
|
||||
|
||||
/** Reported by DescribeAgent and ListAgents; floci runs no agent software. */
|
||||
public static final String AGENT_PLATFORM_VERSION = "1.0.0";
|
||||
|
||||
private static final int DEFAULT_MAX_RESULTS = 100;
|
||||
|
||||
private static final Set<String> CREDENTIAL_MEMBERS = Set.of(
|
||||
"Password", "SecretKey", "SasConfiguration", "KerberosKeytab", "KerberosKrb5Conf");
|
||||
|
||||
private final StorageBackend<String, DataSyncAgent> agents;
|
||||
private final StorageBackend<String, DataSyncLocation> locations;
|
||||
private final StorageBackend<String, DataSyncTask> tasks;
|
||||
private final RegionResolver regionResolver;
|
||||
private final ObjectMapper mapper;
|
||||
|
||||
@Inject
|
||||
public DataSyncService(StorageFactory storageFactory, RegionResolver regionResolver, ObjectMapper mapper) {
|
||||
this.agents = storageFactory.create("datasync", "datasync-agents.json",
|
||||
new TypeReference<Map<String, DataSyncAgent>>() {});
|
||||
this.locations = storageFactory.create("datasync", "datasync-locations.json",
|
||||
new TypeReference<Map<String, DataSyncLocation>>() {});
|
||||
this.tasks = storageFactory.create("datasync", "datasync-tasks.json",
|
||||
new TypeReference<Map<String, DataSyncTask>>() {});
|
||||
this.regionResolver = regionResolver;
|
||||
this.mapper = mapper;
|
||||
}
|
||||
|
||||
/** A page of list results plus the token that resumes after it, or {@code null} at the end. */
|
||||
public record Page<T>(List<T> items, String nextToken) {
|
||||
}
|
||||
|
||||
// ---- Agents ----
|
||||
|
||||
public DataSyncAgent createAgent(JsonNode request, String region) {
|
||||
String activationKey = requiredText(request, "ActivationKey", "CreateAgent");
|
||||
DataSyncAgent agent = new DataSyncAgent();
|
||||
agent.setAgentArn(regionResolver.buildArn("datasync", region, "agent/agent-" + randomResourceId()));
|
||||
agent.setName(request.path("AgentName").asText(""));
|
||||
agent.setStatus(AGENT_STATUS_ONLINE);
|
||||
agent.setActivationKey(activationKey);
|
||||
agent.setVpcEndpointId(optionalText(request, "VpcEndpointId"));
|
||||
agent.setSubnetArns(stringList(request.path("SubnetArns")));
|
||||
agent.setSecurityGroupArns(stringList(request.path("SecurityGroupArns")));
|
||||
agent.setEndpointType(agent.getVpcEndpointId() != null ? "PRIVATE_LINK" : "PUBLIC");
|
||||
agent.setPlatformVersion(AGENT_PLATFORM_VERSION);
|
||||
agent.setCreationTime(Instant.now());
|
||||
agent.setLastConnectionTime(agent.getCreationTime());
|
||||
agent.setTags(tagsOf(request.path("Tags")));
|
||||
|
||||
agents.put(agent.getAgentArn(), agent);
|
||||
LOG.infov("Created DataSync agent: {0}", agent.getAgentArn());
|
||||
return agent;
|
||||
}
|
||||
|
||||
public DataSyncAgent getAgent(String agentArn) {
|
||||
requireArn(agentArn, "AgentArn");
|
||||
return agents.get(agentArn).orElseThrow(() -> new AwsException("InvalidRequestException",
|
||||
"Agent " + agentArn + " is not found.", 400));
|
||||
}
|
||||
|
||||
public DataSyncAgent updateAgent(String agentArn, String name) {
|
||||
DataSyncAgent agent = getAgent(agentArn);
|
||||
if (name != null) {
|
||||
agent.setName(name);
|
||||
}
|
||||
agents.put(agentArn, agent);
|
||||
return agent;
|
||||
}
|
||||
|
||||
public void deleteAgent(String agentArn) {
|
||||
getAgent(agentArn);
|
||||
agents.delete(agentArn);
|
||||
LOG.infov("Deleted DataSync agent: {0}", agentArn);
|
||||
}
|
||||
|
||||
public Page<DataSyncAgent> listAgents(String nextToken, int maxResults) {
|
||||
List<DataSyncAgent> all = agents.scan(key -> true);
|
||||
all.sort(Comparator.comparing(DataSyncAgent::getAgentArn));
|
||||
return paginate(all, DataSyncAgent::getAgentArn, nextToken, maxResults);
|
||||
}
|
||||
|
||||
// ---- Locations ----
|
||||
|
||||
public DataSyncLocation createLocation(DataSyncLocationType type, JsonNode request, String region) {
|
||||
for (String member : type.requiredMembers()) {
|
||||
if (!hasValue(request, member)) {
|
||||
throw new AwsException("InvalidRequestException",
|
||||
member + " is required for CreateLocation" + type.operationSuffix() + ".", 400);
|
||||
}
|
||||
}
|
||||
|
||||
ObjectNode configuration = mapper.createObjectNode();
|
||||
request.properties().forEach(member -> {
|
||||
if (!"Tags".equals(member.getKey())) {
|
||||
configuration.set(member.getKey(), member.getValue().deepCopy());
|
||||
}
|
||||
});
|
||||
stripCredentials(configuration);
|
||||
applyLocationDefaults(type, configuration, region);
|
||||
|
||||
DataSyncLocation location = new DataSyncLocation();
|
||||
location.setLocationArn(regionResolver.buildArn("datasync", region, "location/loc-" + randomResourceId()));
|
||||
location.setLocationType(type);
|
||||
location.setRegion(region);
|
||||
location.setConfiguration(configuration);
|
||||
location.setLocationUri(buildLocationUri(type, configuration, region));
|
||||
location.setCreationTime(Instant.now());
|
||||
location.setTags(tagsOf(request.path("Tags")));
|
||||
|
||||
locations.put(location.getLocationArn(), location);
|
||||
LOG.infov("Created DataSync {0} location: {1}", type.operationSuffix(), location.getLocationArn());
|
||||
return location;
|
||||
}
|
||||
|
||||
public DataSyncLocation getLocation(String locationArn) {
|
||||
requireArn(locationArn, "LocationArn");
|
||||
return locations.get(locationArn).orElseThrow(() -> new AwsException("InvalidRequestException",
|
||||
"Location " + locationArn + " is not found.", 400));
|
||||
}
|
||||
|
||||
public DataSyncLocation getLocation(String locationArn, DataSyncLocationType expected) {
|
||||
DataSyncLocation location = getLocation(locationArn);
|
||||
if (location.getLocationType() != expected) {
|
||||
throw new AwsException("InvalidRequestException",
|
||||
"Location " + locationArn + " is a " + location.getLocationType().operationSuffix()
|
||||
+ " location, not a " + expected.operationSuffix() + " location.", 400);
|
||||
}
|
||||
return location;
|
||||
}
|
||||
|
||||
public DataSyncLocation updateLocation(DataSyncLocationType type, JsonNode request) {
|
||||
String locationArn = requiredText(request, "LocationArn", "UpdateLocation" + type.operationSuffix());
|
||||
DataSyncLocation location = getLocation(locationArn, type);
|
||||
|
||||
ObjectNode configuration = location.getConfiguration().deepCopy();
|
||||
request.properties().forEach(member -> {
|
||||
if (!"LocationArn".equals(member.getKey())) {
|
||||
configuration.set(member.getKey(), member.getValue().deepCopy());
|
||||
}
|
||||
});
|
||||
stripCredentials(configuration);
|
||||
applyLocationDefaults(type, configuration, location.getRegion());
|
||||
|
||||
location.setConfiguration(configuration);
|
||||
location.setLocationUri(buildLocationUri(type, configuration, location.getRegion()));
|
||||
locations.put(locationArn, location);
|
||||
LOG.infov("Updated DataSync {0} location: {1}", type.operationSuffix(), locationArn);
|
||||
return location;
|
||||
}
|
||||
|
||||
public void deleteLocation(String locationArn) {
|
||||
getLocation(locationArn);
|
||||
locations.delete(locationArn);
|
||||
LOG.infov("Deleted DataSync location: {0}", locationArn);
|
||||
}
|
||||
|
||||
public Page<DataSyncLocation> listLocations(JsonNode filters, String nextToken, int maxResults) {
|
||||
List<DataSyncLocation> all = new ArrayList<>();
|
||||
for (DataSyncLocation location : locations.scan(key -> true)) {
|
||||
if (matchesLocationFilters(location, filters)) {
|
||||
all.add(location);
|
||||
}
|
||||
}
|
||||
all.sort(Comparator.comparing(DataSyncLocation::getLocationArn));
|
||||
return paginate(all, DataSyncLocation::getLocationArn, nextToken, maxResults);
|
||||
}
|
||||
|
||||
// ---- Tasks ----
|
||||
|
||||
public DataSyncTask createTask(JsonNode request, String region) {
|
||||
String sourceArn = requiredText(request, "SourceLocationArn", "CreateTask");
|
||||
String destinationArn = requiredText(request, "DestinationLocationArn", "CreateTask");
|
||||
getLocation(sourceArn);
|
||||
getLocation(destinationArn);
|
||||
|
||||
DataSyncTask task = new DataSyncTask();
|
||||
task.setTaskArn(regionResolver.buildArn("datasync", region, "task/task-" + randomResourceId()));
|
||||
task.setName(request.path("Name").asText(""));
|
||||
task.setStatus(TASK_STATUS_AVAILABLE);
|
||||
String taskMode = requestedTaskMode(request);
|
||||
task.setTaskMode(taskMode);
|
||||
task.setSourceLocationArn(sourceArn);
|
||||
task.setDestinationLocationArn(destinationArn);
|
||||
task.setCloudWatchLogGroupArn(optionalText(request, "CloudWatchLogGroupArn"));
|
||||
task.setOptions(mergedOptions(request.get("Options"), taskMode));
|
||||
task.setExcludes(filterList(request.get("Excludes")));
|
||||
task.setIncludes(filterList(request.get("Includes")));
|
||||
task.setSchedule(copyOrNull(request.get("Schedule")));
|
||||
task.setManifestConfig(copyOrNull(request.get("ManifestConfig")));
|
||||
task.setTaskReportConfig(copyOrNull(request.get("TaskReportConfig")));
|
||||
task.setCreationTime(Instant.now());
|
||||
task.setTags(tagsOf(request.path("Tags")));
|
||||
|
||||
tasks.put(task.getTaskArn(), task);
|
||||
LOG.infov("Created DataSync task: {0}", task.getTaskArn());
|
||||
return task;
|
||||
}
|
||||
|
||||
public DataSyncTask getTask(String taskArn) {
|
||||
requireArn(taskArn, "TaskArn");
|
||||
return tasks.get(taskArn).orElseThrow(() -> new AwsException("InvalidRequestException",
|
||||
"Task " + taskArn + " is not found.", 400));
|
||||
}
|
||||
|
||||
public DataSyncTask updateTask(JsonNode request) {
|
||||
String taskArn = requiredText(request, "TaskArn", "UpdateTask");
|
||||
DataSyncTask task = getTask(taskArn);
|
||||
|
||||
if (request.hasNonNull("Name")) {
|
||||
task.setName(request.get("Name").asText());
|
||||
}
|
||||
if (request.hasNonNull("CloudWatchLogGroupArn")) {
|
||||
task.setCloudWatchLogGroupArn(request.get("CloudWatchLogGroupArn").asText());
|
||||
}
|
||||
if (request.hasNonNull("Options")) {
|
||||
task.setOptions(mergedOptions(request.get("Options"), taskModeOf(task)));
|
||||
}
|
||||
if (request.hasNonNull("Excludes")) {
|
||||
task.setExcludes(filterList(request.get("Excludes")));
|
||||
}
|
||||
if (request.hasNonNull("Includes")) {
|
||||
task.setIncludes(filterList(request.get("Includes")));
|
||||
}
|
||||
if (request.hasNonNull("Schedule")) {
|
||||
task.setSchedule(copyOrNull(request.get("Schedule")));
|
||||
}
|
||||
if (request.hasNonNull("ManifestConfig")) {
|
||||
task.setManifestConfig(copyOrNull(request.get("ManifestConfig")));
|
||||
}
|
||||
if (request.hasNonNull("TaskReportConfig")) {
|
||||
task.setTaskReportConfig(copyOrNull(request.get("TaskReportConfig")));
|
||||
}
|
||||
|
||||
tasks.put(taskArn, task);
|
||||
LOG.infov("Updated DataSync task: {0}", taskArn);
|
||||
return task;
|
||||
}
|
||||
|
||||
public void deleteTask(String taskArn) {
|
||||
getTask(taskArn);
|
||||
tasks.delete(taskArn);
|
||||
LOG.infov("Deleted DataSync task: {0}", taskArn);
|
||||
}
|
||||
|
||||
public Page<DataSyncTask> listTasks(JsonNode filters, String nextToken, int maxResults) {
|
||||
List<DataSyncTask> all = new ArrayList<>();
|
||||
for (DataSyncTask task : tasks.scan(key -> true)) {
|
||||
if (matchesTaskFilters(task, filters)) {
|
||||
all.add(task);
|
||||
}
|
||||
}
|
||||
all.sort(Comparator.comparing(DataSyncTask::getTaskArn));
|
||||
return paginate(all, DataSyncTask::getTaskArn, nextToken, maxResults);
|
||||
}
|
||||
|
||||
// ---- Tags ----
|
||||
|
||||
public Map<String, String> listTagsForResource(String resourceArn) {
|
||||
return new LinkedHashMap<>(findTaggable(resourceArn).getTags());
|
||||
}
|
||||
|
||||
public void tagResource(String resourceArn, Map<String, String> tags) {
|
||||
DataSyncTaggable resource = findTaggable(resourceArn);
|
||||
resource.getTags().putAll(tags);
|
||||
persist(resourceArn, resource);
|
||||
}
|
||||
|
||||
public void untagResource(String resourceArn, List<String> tagKeys) {
|
||||
DataSyncTaggable resource = findTaggable(resourceArn);
|
||||
tagKeys.forEach(resource.getTags()::remove);
|
||||
persist(resourceArn, resource);
|
||||
}
|
||||
|
||||
private DataSyncTaggable findTaggable(String resourceArn) {
|
||||
requireArn(resourceArn, "ResourceArn");
|
||||
return agents.get(resourceArn).<DataSyncTaggable>map(agent -> agent)
|
||||
.or(() -> locations.get(resourceArn).map(location -> location))
|
||||
.or(() -> tasks.get(resourceArn).map(task -> task))
|
||||
.orElseThrow(() -> new AwsException("InvalidRequestException",
|
||||
"Resource " + resourceArn + " is not found.", 400));
|
||||
}
|
||||
|
||||
private void persist(String resourceArn, DataSyncTaggable resource) {
|
||||
if (resource instanceof DataSyncAgent agent) {
|
||||
agents.put(resourceArn, agent);
|
||||
} else if (resource instanceof DataSyncLocation location) {
|
||||
locations.put(resourceArn, location);
|
||||
} else {
|
||||
tasks.put(resourceArn, (DataSyncTask) resource);
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Location derivation ----
|
||||
|
||||
private void applyLocationDefaults(DataSyncLocationType type, ObjectNode configuration, String region) {
|
||||
switch (type) {
|
||||
case AZURE_BLOB -> {
|
||||
defaultText(configuration, "BlobType", "BLOCK");
|
||||
defaultText(configuration, "AccessTier", "HOT");
|
||||
}
|
||||
case EFS -> defaultText(configuration, "InTransitEncryption", "NONE");
|
||||
case FSX_ONTAP -> {
|
||||
String svmArn = configuration.path("StorageVirtualMachineArn").asText("");
|
||||
String fileSystemId = fsxFileSystemId(svmArn);
|
||||
if (!fileSystemId.isEmpty()) {
|
||||
configuration.put("FsxFilesystemArn", "arn:aws:fsx:" + arnRegion(svmArn, region) + ":"
|
||||
+ arnAccountId(svmArn) + ":file-system/" + fileSystemId);
|
||||
}
|
||||
}
|
||||
case HDFS -> {
|
||||
if (!configuration.hasNonNull("BlockSize")) {
|
||||
configuration.put("BlockSize", 134217728);
|
||||
}
|
||||
if (!configuration.hasNonNull("ReplicationFactor")) {
|
||||
configuration.put("ReplicationFactor", 3);
|
||||
}
|
||||
ObjectNode qop = objectMember(configuration, "QopConfiguration");
|
||||
defaultText(qop, "RpcProtection", "PRIVACY");
|
||||
defaultText(qop, "DataTransferProtection", "PRIVACY");
|
||||
}
|
||||
case NFS -> defaultMountOptions(configuration);
|
||||
case OBJECT_STORAGE -> {
|
||||
defaultText(configuration, "ServerProtocol", "HTTPS");
|
||||
if (!configuration.hasNonNull("ServerPort")) {
|
||||
configuration.put("ServerPort",
|
||||
"HTTP".equals(configuration.path("ServerProtocol").asText()) ? 80 : 443);
|
||||
}
|
||||
}
|
||||
case S3 -> defaultText(configuration, "S3StorageClass", "STANDARD");
|
||||
case SMB -> {
|
||||
defaultText(configuration, "AuthenticationType", "NTLM");
|
||||
defaultMountOptions(configuration);
|
||||
}
|
||||
default -> {
|
||||
// FSx Lustre, FSx Windows and FSx OpenZFS carry no server-side defaults.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void defaultMountOptions(ObjectNode configuration) {
|
||||
defaultText(objectMember(configuration, "MountOptions"), "Version", "AUTOMATIC");
|
||||
}
|
||||
|
||||
private static ObjectNode objectMember(ObjectNode parent, String member) {
|
||||
return parent.get(member) instanceof ObjectNode existing ? existing : parent.putObject(member);
|
||||
}
|
||||
|
||||
private static void defaultText(ObjectNode node, String member, String value) {
|
||||
if (!node.hasNonNull(member) || node.get(member).asText().isEmpty()) {
|
||||
node.put(member, value);
|
||||
}
|
||||
}
|
||||
|
||||
private void stripCredentials(ObjectNode configuration) {
|
||||
CREDENTIAL_MEMBERS.forEach(configuration::remove);
|
||||
JsonNode protocol = configuration.get("Protocol");
|
||||
if (protocol instanceof ObjectNode protocolNode && protocolNode.get("SMB") instanceof ObjectNode smb) {
|
||||
smb.remove("Password");
|
||||
}
|
||||
}
|
||||
|
||||
String buildLocationUri(DataSyncLocationType type, JsonNode configuration, String region) {
|
||||
return switch (type) {
|
||||
case AZURE_BLOB -> {
|
||||
String authority = configuration.path("ContainerUrl").asText("")
|
||||
.replaceFirst("^https?://", "");
|
||||
yield "azure-blob://" + trimTrailingSlashes(authority) + subdirectory(configuration);
|
||||
}
|
||||
case EFS -> fileSystemUri(type, configuration.path("EfsFilesystemArn").asText(""), region, configuration);
|
||||
case FSX_LUSTRE, FSX_OPEN_ZFS, FSX_WINDOWS ->
|
||||
fileSystemUri(type, configuration.path("FsxFilesystemArn").asText(""), region, configuration);
|
||||
case FSX_ONTAP -> {
|
||||
String svmArn = configuration.path("StorageVirtualMachineArn").asText("");
|
||||
yield "fsxn://" + arnRegion(svmArn, region) + "." + fsxFileSystemId(svmArn) + "."
|
||||
+ fsxStorageVirtualMachineId(svmArn) + subdirectory(configuration);
|
||||
}
|
||||
case HDFS -> {
|
||||
JsonNode nameNode = configuration.path("NameNodes").path(0);
|
||||
int port = nameNode.path("Port").asInt(0);
|
||||
yield "hdfs://" + nameNode.path("Hostname").asText("")
|
||||
+ (port > 0 ? ":" + port : "") + subdirectory(configuration);
|
||||
}
|
||||
case NFS -> "nfs://" + configuration.path("ServerHostname").asText("") + subdirectory(configuration);
|
||||
case SMB -> "smb://" + configuration.path("ServerHostname").asText("") + subdirectory(configuration);
|
||||
case OBJECT_STORAGE -> "object-storage://" + configuration.path("ServerHostname").asText("")
|
||||
+ "/" + configuration.path("BucketName").asText("") + subdirectory(configuration);
|
||||
case S3 -> {
|
||||
String subdirectory = subdirectory(configuration);
|
||||
yield "s3://" + s3BucketName(configuration.path("S3BucketArn").asText(""))
|
||||
+ ("/".equals(subdirectory) ? "" : subdirectory);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private String fileSystemUri(DataSyncLocationType type, String fileSystemArn, String region,
|
||||
JsonNode configuration) {
|
||||
String fileSystemId = arnResource(fileSystemArn);
|
||||
int slash = fileSystemId.lastIndexOf('/');
|
||||
if (slash >= 0) {
|
||||
fileSystemId = fileSystemId.substring(slash + 1);
|
||||
}
|
||||
return type.uriScheme() + "://" + arnRegion(fileSystemArn, region) + "." + fileSystemId
|
||||
+ subdirectory(configuration);
|
||||
}
|
||||
|
||||
private static String subdirectory(JsonNode configuration) {
|
||||
String subdirectory = configuration.path("Subdirectory").asText("").trim();
|
||||
while (subdirectory.endsWith("/")) {
|
||||
subdirectory = subdirectory.substring(0, subdirectory.length() - 1);
|
||||
}
|
||||
if (subdirectory.isEmpty()) {
|
||||
return "/";
|
||||
}
|
||||
return subdirectory.startsWith("/") ? subdirectory : "/" + subdirectory;
|
||||
}
|
||||
|
||||
private static String trimTrailingSlashes(String value) {
|
||||
String trimmed = value;
|
||||
while (trimmed.endsWith("/")) {
|
||||
trimmed = trimmed.substring(0, trimmed.length() - 1);
|
||||
}
|
||||
return trimmed;
|
||||
}
|
||||
|
||||
private static String s3BucketName(String bucketArn) {
|
||||
String resource = arnResource(bucketArn);
|
||||
return resource.isEmpty() ? bucketArn : resource;
|
||||
}
|
||||
|
||||
private static String fsxFileSystemId(String storageVirtualMachineArn) {
|
||||
String[] segments = arnResource(storageVirtualMachineArn).split("/");
|
||||
return segments.length > 1 ? segments[1] : "";
|
||||
}
|
||||
|
||||
private static String fsxStorageVirtualMachineId(String storageVirtualMachineArn) {
|
||||
String[] segments = arnResource(storageVirtualMachineArn).split("/");
|
||||
return segments.length > 2 ? segments[2] : "";
|
||||
}
|
||||
|
||||
private static String arnRegion(String arn, String fallback) {
|
||||
String[] segments = arn.split(":", 6);
|
||||
return segments.length > 3 && !segments[3].isEmpty() ? segments[3] : fallback;
|
||||
}
|
||||
|
||||
private String arnAccountId(String arn) {
|
||||
String[] segments = arn.split(":", 6);
|
||||
return segments.length > 4 && !segments[4].isEmpty() ? segments[4] : regionResolver.getAccountId();
|
||||
}
|
||||
|
||||
private static String arnResource(String arn) {
|
||||
String[] segments = arn.split(":", 6);
|
||||
return segments.length > 5 ? segments[5] : "";
|
||||
}
|
||||
|
||||
// ---- Filters ----
|
||||
|
||||
private boolean matchesLocationFilters(DataSyncLocation location, JsonNode filters) {
|
||||
if (filters == null || !filters.isArray()) {
|
||||
return true;
|
||||
}
|
||||
for (JsonNode filter : filters) {
|
||||
String name = filter.path("Name").asText("");
|
||||
List<String> values = stringList(filter.path("Values"));
|
||||
String operator = filter.path("Operator").asText("Equals");
|
||||
boolean matched = switch (name) {
|
||||
case "LocationUri" -> matchesString(location.getLocationUri(), values, operator);
|
||||
case "LocationType" -> matchesString(location.getLocationType().operationSuffix(), values, operator)
|
||||
|| matchesString(location.getLocationType().uriScheme(), values, operator);
|
||||
case "CreationTime" -> matchesInstant(location.getCreationTime(), values, operator);
|
||||
default -> throw new AwsException("InvalidRequestException",
|
||||
"Unsupported ListLocations filter name: " + name, 400);
|
||||
};
|
||||
if (!matched) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean matchesTaskFilters(DataSyncTask task, JsonNode filters) {
|
||||
if (filters == null || !filters.isArray()) {
|
||||
return true;
|
||||
}
|
||||
for (JsonNode filter : filters) {
|
||||
String name = filter.path("Name").asText("");
|
||||
List<String> values = stringList(filter.path("Values"));
|
||||
String operator = filter.path("Operator").asText("Equals");
|
||||
boolean matched = switch (name) {
|
||||
case "LocationId" -> matchesString(task.getSourceLocationArn(), values, operator)
|
||||
|| matchesString(task.getDestinationLocationArn(), values, operator);
|
||||
case "CreationTime" -> matchesInstant(task.getCreationTime(), values, operator);
|
||||
default -> throw new AwsException("InvalidRequestException",
|
||||
"Unsupported ListTasks filter name: " + name, 400);
|
||||
};
|
||||
if (!matched) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static boolean matchesString(String attribute, List<String> values, String operator) {
|
||||
String actual = attribute != null ? attribute : "";
|
||||
return switch (operator) {
|
||||
case "Equals", "In" -> values.stream().anyMatch(actual::equalsIgnoreCase);
|
||||
case "NotEquals" -> values.stream().noneMatch(actual::equalsIgnoreCase);
|
||||
case "Contains" -> values.stream()
|
||||
.anyMatch(value -> actual.toLowerCase(Locale.ROOT).contains(value.toLowerCase(Locale.ROOT)));
|
||||
case "NotContains" -> values.stream()
|
||||
.noneMatch(value -> actual.toLowerCase(Locale.ROOT).contains(value.toLowerCase(Locale.ROOT)));
|
||||
case "BeginsWith" -> values.stream()
|
||||
.anyMatch(value -> actual.toLowerCase(Locale.ROOT).startsWith(value.toLowerCase(Locale.ROOT)));
|
||||
default -> throw new AwsException("InvalidRequestException",
|
||||
"Unsupported filter operator for a string attribute: " + operator, 400);
|
||||
};
|
||||
}
|
||||
|
||||
private static boolean matchesInstant(Instant attribute, List<String> values, String operator) {
|
||||
Instant actual = attribute != null ? attribute : Instant.EPOCH;
|
||||
return switch (operator) {
|
||||
case "Equals", "In" -> values.stream().anyMatch(value -> actual.equals(parseInstant(value)));
|
||||
case "NotEquals" -> values.stream().noneMatch(value -> actual.equals(parseInstant(value)));
|
||||
case "LessThan" -> values.stream().allMatch(value -> actual.isBefore(parseInstant(value)));
|
||||
case "LessThanOrEqual" -> values.stream().allMatch(value -> !actual.isAfter(parseInstant(value)));
|
||||
case "GreaterThan" -> values.stream().allMatch(value -> actual.isAfter(parseInstant(value)));
|
||||
case "GreaterThanOrEqual" -> values.stream().allMatch(value -> !actual.isBefore(parseInstant(value)));
|
||||
default -> throw new AwsException("InvalidRequestException",
|
||||
"Unsupported filter operator for CreationTime: " + operator, 400);
|
||||
};
|
||||
}
|
||||
|
||||
private static Instant parseInstant(String value) {
|
||||
try {
|
||||
return Instant.parse(value);
|
||||
} catch (DateTimeParseException notIso) {
|
||||
try {
|
||||
return Instant.ofEpochMilli((long) (Double.parseDouble(value) * 1000));
|
||||
} catch (NumberFormatException notEpoch) {
|
||||
throw new AwsException("InvalidRequestException",
|
||||
"CreationTime filter value is neither an ISO-8601 instant nor an epoch timestamp: "
|
||||
+ value, 400);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ---- Helpers ----
|
||||
|
||||
private JsonNode mergedOptions(JsonNode requested, String taskMode) {
|
||||
ObjectNode options = mapper.createObjectNode();
|
||||
options.put("VerifyMode", defaultVerifyMode(taskMode));
|
||||
options.put("OverwriteMode", "ALWAYS");
|
||||
options.put("Atime", "BEST_EFFORT");
|
||||
options.put("Mtime", "PRESERVE");
|
||||
options.put("Uid", "INT_VALUE");
|
||||
options.put("Gid", "INT_VALUE");
|
||||
options.put("PreserveDeletedFiles", "PRESERVE");
|
||||
options.put("PreserveDevices", "NONE");
|
||||
options.put("PosixPermissions", "PRESERVE");
|
||||
options.put("BytesPerSecond", -1L);
|
||||
options.put("TaskQueueing", "ENABLED");
|
||||
options.put("LogLevel", "OFF");
|
||||
options.put("TransferMode", "CHANGED");
|
||||
options.put("SecurityDescriptorCopyFlags", "OWNER_DACL");
|
||||
options.put("ObjectTags", "PRESERVE");
|
||||
if (requested != null && requested.isObject()) {
|
||||
requested.properties().forEach(member -> options.set(member.getKey(), member.getValue().deepCopy()));
|
||||
}
|
||||
requireSupportedVerifyMode(options.path("VerifyMode").asText(), taskMode);
|
||||
return options;
|
||||
}
|
||||
|
||||
private static String requestedTaskMode(JsonNode request) {
|
||||
String taskMode = request.path("TaskMode").asText(DEFAULT_TASK_MODE);
|
||||
if (!TASK_MODES.contains(taskMode)) {
|
||||
throw new AwsException("InvalidRequestException",
|
||||
"TaskMode " + taskMode + " is not a supported task mode. Supported modes are "
|
||||
+ DEFAULT_TASK_MODE + " and " + TASK_MODE_ENHANCED + ".", 400);
|
||||
}
|
||||
return taskMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* The mode a stored task was created with. {@code UpdateTaskRequest} carries no
|
||||
* {@code TaskMode}, so a task keeps the mode it was created with for life.
|
||||
*/
|
||||
private static String taskModeOf(DataSyncTask task) {
|
||||
return task.getTaskMode() != null ? task.getTaskMode() : DEFAULT_TASK_MODE;
|
||||
}
|
||||
|
||||
private static String defaultVerifyMode(String taskMode) {
|
||||
return TASK_MODE_ENHANCED.equals(taskMode)
|
||||
? VERIFY_MODE_ONLY_FILES_TRANSFERRED
|
||||
: VERIFY_MODE_POINT_IN_TIME_CONSISTENT;
|
||||
}
|
||||
|
||||
private static void requireSupportedVerifyMode(String verifyMode, String taskMode) {
|
||||
if (TASK_MODE_ENHANCED.equals(taskMode) && VERIFY_MODE_POINT_IN_TIME_CONSISTENT.equals(verifyMode)) {
|
||||
throw new AwsException("InvalidRequestException",
|
||||
"VerifyMode " + VERIFY_MODE_POINT_IN_TIME_CONSISTENT + " is not supported for "
|
||||
+ TASK_MODE_ENHANCED + " mode tasks.", 400);
|
||||
}
|
||||
}
|
||||
|
||||
private JsonNode filterList(JsonNode requested) {
|
||||
return requested != null && requested.isArray() ? requested.deepCopy() : mapper.createArrayNode();
|
||||
}
|
||||
|
||||
private static JsonNode copyOrNull(JsonNode requested) {
|
||||
return requested != null && !requested.isNull() ? requested.deepCopy() : null;
|
||||
}
|
||||
|
||||
private static <T> Page<T> paginate(List<T> all, Function<T, String> identity,
|
||||
String nextToken, int maxResults) {
|
||||
int start = 0;
|
||||
if (nextToken != null && !nextToken.isEmpty()) {
|
||||
for (int i = 0; i < all.size(); i++) {
|
||||
if (identity.apply(all.get(i)).equals(nextToken)) {
|
||||
start = i + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
int limit = maxResults > 0 ? maxResults : DEFAULT_MAX_RESULTS;
|
||||
int end = Math.min(start + limit, all.size());
|
||||
List<T> page = new ArrayList<>(all.subList(Math.min(start, all.size()), end));
|
||||
String token = end < all.size() && !page.isEmpty() ? identity.apply(page.get(page.size() - 1)) : null;
|
||||
return new Page<>(page, token);
|
||||
}
|
||||
|
||||
public static Map<String, String> tagsOf(JsonNode tagList) {
|
||||
Map<String, String> tags = new LinkedHashMap<>();
|
||||
if (tagList != null && tagList.isArray()) {
|
||||
for (JsonNode tag : tagList) {
|
||||
String key = tag.path("Key").asText("");
|
||||
if (!key.isEmpty()) {
|
||||
tags.put(key, tag.path("Value").asText(""));
|
||||
}
|
||||
}
|
||||
}
|
||||
return tags;
|
||||
}
|
||||
|
||||
public static List<String> stringList(JsonNode arrayNode) {
|
||||
List<String> values = new ArrayList<>();
|
||||
if (arrayNode != null && arrayNode.isArray()) {
|
||||
arrayNode.forEach(element -> values.add(element.asText("")));
|
||||
}
|
||||
return values;
|
||||
}
|
||||
|
||||
private static boolean hasValue(JsonNode request, String member) {
|
||||
JsonNode value = request.get(member);
|
||||
return value != null && !value.isNull() && !(value.isTextual() && value.asText().isEmpty());
|
||||
}
|
||||
|
||||
private static String requiredText(JsonNode request, String member, String operation) {
|
||||
if (!hasValue(request, member)) {
|
||||
throw new AwsException("InvalidRequestException", member + " is required for " + operation + ".", 400);
|
||||
}
|
||||
return request.get(member).asText();
|
||||
}
|
||||
|
||||
private static String optionalText(JsonNode request, String member) {
|
||||
return request.hasNonNull(member) ? request.get(member).asText() : null;
|
||||
}
|
||||
|
||||
private static void requireArn(String arn, String member) {
|
||||
if (arn == null || arn.isBlank()) {
|
||||
throw new AwsException("InvalidRequestException", member + " is required.", 400);
|
||||
}
|
||||
}
|
||||
|
||||
private static String randomResourceId() {
|
||||
StringBuilder id = new StringBuilder(RESOURCE_ID_LENGTH);
|
||||
for (int i = 0; i < RESOURCE_ID_LENGTH; i++) {
|
||||
id.append(HEX_ALPHABET.charAt(RANDOM.nextInt(HEX_ALPHABET.length())));
|
||||
}
|
||||
return id.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,126 @@
|
||||
package io.github.hectorvent.floci.services.datasync.model;
|
||||
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RegisterForReflection
|
||||
public class DataSyncAgent implements DataSyncTaggable {
|
||||
|
||||
private String agentArn;
|
||||
private String name;
|
||||
private String status;
|
||||
private String activationKey;
|
||||
private String endpointType;
|
||||
private String vpcEndpointId;
|
||||
private List<String> subnetArns = new ArrayList<>();
|
||||
private List<String> securityGroupArns = new ArrayList<>();
|
||||
private String platformVersion;
|
||||
private Instant creationTime;
|
||||
private Instant lastConnectionTime;
|
||||
private Map<String, String> tags = new LinkedHashMap<>();
|
||||
|
||||
public String getAgentArn() {
|
||||
return agentArn;
|
||||
}
|
||||
|
||||
public void setAgentArn(String agentArn) {
|
||||
this.agentArn = agentArn;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getActivationKey() {
|
||||
return activationKey;
|
||||
}
|
||||
|
||||
public void setActivationKey(String activationKey) {
|
||||
this.activationKey = activationKey;
|
||||
}
|
||||
|
||||
public String getEndpointType() {
|
||||
return endpointType;
|
||||
}
|
||||
|
||||
public void setEndpointType(String endpointType) {
|
||||
this.endpointType = endpointType;
|
||||
}
|
||||
|
||||
public String getVpcEndpointId() {
|
||||
return vpcEndpointId;
|
||||
}
|
||||
|
||||
public void setVpcEndpointId(String vpcEndpointId) {
|
||||
this.vpcEndpointId = vpcEndpointId;
|
||||
}
|
||||
|
||||
public List<String> getSubnetArns() {
|
||||
return subnetArns;
|
||||
}
|
||||
|
||||
public void setSubnetArns(List<String> subnetArns) {
|
||||
this.subnetArns = subnetArns != null ? subnetArns : new ArrayList<>();
|
||||
}
|
||||
|
||||
public List<String> getSecurityGroupArns() {
|
||||
return securityGroupArns;
|
||||
}
|
||||
|
||||
public void setSecurityGroupArns(List<String> securityGroupArns) {
|
||||
this.securityGroupArns = securityGroupArns != null ? securityGroupArns : new ArrayList<>();
|
||||
}
|
||||
|
||||
public String getPlatformVersion() {
|
||||
return platformVersion;
|
||||
}
|
||||
|
||||
public void setPlatformVersion(String platformVersion) {
|
||||
this.platformVersion = platformVersion;
|
||||
}
|
||||
|
||||
public Instant getCreationTime() {
|
||||
return creationTime;
|
||||
}
|
||||
|
||||
public void setCreationTime(Instant creationTime) {
|
||||
this.creationTime = creationTime;
|
||||
}
|
||||
|
||||
public Instant getLastConnectionTime() {
|
||||
return lastConnectionTime;
|
||||
}
|
||||
|
||||
public void setLastConnectionTime(Instant lastConnectionTime) {
|
||||
this.lastConnectionTime = lastConnectionTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getTags() {
|
||||
if (tags == null) {
|
||||
tags = new LinkedHashMap<>();
|
||||
}
|
||||
return tags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTags(Map<String, String> tags) {
|
||||
this.tags = tags != null ? tags : new LinkedHashMap<>();
|
||||
}
|
||||
}
|
||||
+86
@@ -0,0 +1,86 @@
|
||||
package io.github.hectorvent.floci.services.datasync.model;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
import java.time.Instant;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A DataSync transfer location. {@code configuration} holds the create request with its
|
||||
* credential members stripped and the service's documented defaults applied; every
|
||||
* {@code DescribeLocation*} answer is projected out of it.
|
||||
*/
|
||||
@RegisterForReflection
|
||||
public class DataSyncLocation implements DataSyncTaggable {
|
||||
|
||||
private String locationArn;
|
||||
private DataSyncLocationType locationType;
|
||||
private String locationUri;
|
||||
private String region;
|
||||
private JsonNode configuration;
|
||||
private Instant creationTime;
|
||||
private Map<String, String> tags = new LinkedHashMap<>();
|
||||
|
||||
public String getLocationArn() {
|
||||
return locationArn;
|
||||
}
|
||||
|
||||
public void setLocationArn(String locationArn) {
|
||||
this.locationArn = locationArn;
|
||||
}
|
||||
|
||||
public DataSyncLocationType getLocationType() {
|
||||
return locationType;
|
||||
}
|
||||
|
||||
public void setLocationType(DataSyncLocationType locationType) {
|
||||
this.locationType = locationType;
|
||||
}
|
||||
|
||||
public String getLocationUri() {
|
||||
return locationUri;
|
||||
}
|
||||
|
||||
public void setLocationUri(String locationUri) {
|
||||
this.locationUri = locationUri;
|
||||
}
|
||||
|
||||
public String getRegion() {
|
||||
return region;
|
||||
}
|
||||
|
||||
public void setRegion(String region) {
|
||||
this.region = region;
|
||||
}
|
||||
|
||||
public JsonNode getConfiguration() {
|
||||
return configuration;
|
||||
}
|
||||
|
||||
public void setConfiguration(JsonNode configuration) {
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
public Instant getCreationTime() {
|
||||
return creationTime;
|
||||
}
|
||||
|
||||
public void setCreationTime(Instant creationTime) {
|
||||
this.creationTime = creationTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getTags() {
|
||||
if (tags == null) {
|
||||
tags = new LinkedHashMap<>();
|
||||
}
|
||||
return tags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTags(Map<String, String> tags) {
|
||||
this.tags = tags != null ? tags : new LinkedHashMap<>();
|
||||
}
|
||||
}
|
||||
+104
@@ -0,0 +1,104 @@
|
||||
package io.github.hectorvent.floci.services.datasync.model;
|
||||
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* The DataSync location families, one per {@code CreateLocation*} operation.
|
||||
*
|
||||
* <p>Each constant carries the operation suffix that names its Create/Describe/Update
|
||||
* trio, the URI scheme AWS builds the location's {@code LocationUri} from, the members
|
||||
* the model marks required on create, and the members its {@code DescribeLocation*}
|
||||
* response echoes back from the create request.
|
||||
*/
|
||||
@RegisterForReflection
|
||||
public enum DataSyncLocationType {
|
||||
|
||||
AZURE_BLOB("AzureBlob", "azure-blob",
|
||||
List.of("ContainerUrl", "AuthenticationType"),
|
||||
List.of("AuthenticationType", "BlobType", "AccessTier", "AgentArns",
|
||||
"CmkSecretConfig", "CustomSecretConfig")),
|
||||
|
||||
EFS("Efs", "efs",
|
||||
List.of("EfsFilesystemArn", "Ec2Config"),
|
||||
List.of("Ec2Config", "AccessPointArn", "FileSystemAccessRoleArn", "InTransitEncryption")),
|
||||
|
||||
FSX_LUSTRE("FsxLustre", "fsxl",
|
||||
List.of("FsxFilesystemArn", "SecurityGroupArns"),
|
||||
List.of("SecurityGroupArns")),
|
||||
|
||||
FSX_ONTAP("FsxOntap", "fsxn",
|
||||
List.of("Protocol", "SecurityGroupArns", "StorageVirtualMachineArn"),
|
||||
List.of("Protocol", "SecurityGroupArns", "StorageVirtualMachineArn", "FsxFilesystemArn")),
|
||||
|
||||
FSX_OPEN_ZFS("FsxOpenZfs", "fsxz",
|
||||
List.of("FsxFilesystemArn", "Protocol", "SecurityGroupArns"),
|
||||
List.of("SecurityGroupArns", "Protocol")),
|
||||
|
||||
FSX_WINDOWS("FsxWindows", "fsxw",
|
||||
List.of("FsxFilesystemArn", "SecurityGroupArns", "User"),
|
||||
List.of("SecurityGroupArns", "User", "Domain")),
|
||||
|
||||
HDFS("Hdfs", "hdfs",
|
||||
List.of("NameNodes", "AuthenticationType", "AgentArns"),
|
||||
List.of("NameNodes", "BlockSize", "ReplicationFactor", "KmsKeyProviderUri",
|
||||
"QopConfiguration", "AuthenticationType", "SimpleUser", "KerberosPrincipal",
|
||||
"AgentArns")),
|
||||
|
||||
NFS("Nfs", "nfs",
|
||||
List.of("Subdirectory", "ServerHostname", "OnPremConfig"),
|
||||
List.of("OnPremConfig", "MountOptions")),
|
||||
|
||||
OBJECT_STORAGE("ObjectStorage", "object-storage",
|
||||
List.of("ServerHostname", "BucketName"),
|
||||
List.of("AccessKey", "ServerPort", "ServerProtocol", "AgentArns", "ServerCertificate",
|
||||
"CmkSecretConfig", "CustomSecretConfig")),
|
||||
|
||||
S3("S3", "s3",
|
||||
List.of("S3BucketArn", "S3Config"),
|
||||
List.of("S3StorageClass", "S3Config", "AgentArns")),
|
||||
|
||||
SMB("Smb", "smb",
|
||||
List.of("Subdirectory", "ServerHostname", "AgentArns"),
|
||||
List.of("AgentArns", "User", "Domain", "MountOptions", "DnsIpAddresses",
|
||||
"KerberosPrincipal", "AuthenticationType", "CmkSecretConfig", "CustomSecretConfig"));
|
||||
|
||||
private final String operationSuffix;
|
||||
private final String uriScheme;
|
||||
private final List<String> requiredMembers;
|
||||
private final List<String> describeMembers;
|
||||
|
||||
DataSyncLocationType(String operationSuffix, String uriScheme,
|
||||
List<String> requiredMembers, List<String> describeMembers) {
|
||||
this.operationSuffix = operationSuffix;
|
||||
this.uriScheme = uriScheme;
|
||||
this.requiredMembers = requiredMembers;
|
||||
this.describeMembers = describeMembers;
|
||||
}
|
||||
|
||||
public static Optional<DataSyncLocationType> fromOperationSuffix(String suffix) {
|
||||
for (DataSyncLocationType type : values()) {
|
||||
if (type.operationSuffix.equals(suffix)) {
|
||||
return Optional.of(type);
|
||||
}
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
public String operationSuffix() {
|
||||
return operationSuffix;
|
||||
}
|
||||
|
||||
public String uriScheme() {
|
||||
return uriScheme;
|
||||
}
|
||||
|
||||
public List<String> requiredMembers() {
|
||||
return requiredMembers;
|
||||
}
|
||||
|
||||
public List<String> describeMembers() {
|
||||
return describeMembers;
|
||||
}
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package io.github.hectorvent.floci.services.datasync.model;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* A DataSync resource addressable by the service's own {@code TagResource},
|
||||
* {@code UntagResource} and {@code ListTagsForResource} operations.
|
||||
*/
|
||||
public interface DataSyncTaggable {
|
||||
|
||||
Map<String, String> getTags();
|
||||
|
||||
void setTags(Map<String, String> tags);
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
package io.github.hectorvent.floci.services.datasync.model;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
import java.time.Instant;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@RegisterForReflection
|
||||
public class DataSyncTask implements DataSyncTaggable {
|
||||
|
||||
private String taskArn;
|
||||
private String name;
|
||||
private String status;
|
||||
private String taskMode;
|
||||
private String sourceLocationArn;
|
||||
private String destinationLocationArn;
|
||||
private String cloudWatchLogGroupArn;
|
||||
private JsonNode options;
|
||||
private JsonNode excludes;
|
||||
private JsonNode includes;
|
||||
private JsonNode schedule;
|
||||
private JsonNode manifestConfig;
|
||||
private JsonNode taskReportConfig;
|
||||
private Instant creationTime;
|
||||
private Map<String, String> tags = new LinkedHashMap<>();
|
||||
|
||||
public String getTaskArn() {
|
||||
return taskArn;
|
||||
}
|
||||
|
||||
public void setTaskArn(String taskArn) {
|
||||
this.taskArn = taskArn;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getTaskMode() {
|
||||
return taskMode;
|
||||
}
|
||||
|
||||
public void setTaskMode(String taskMode) {
|
||||
this.taskMode = taskMode;
|
||||
}
|
||||
|
||||
public String getSourceLocationArn() {
|
||||
return sourceLocationArn;
|
||||
}
|
||||
|
||||
public void setSourceLocationArn(String sourceLocationArn) {
|
||||
this.sourceLocationArn = sourceLocationArn;
|
||||
}
|
||||
|
||||
public String getDestinationLocationArn() {
|
||||
return destinationLocationArn;
|
||||
}
|
||||
|
||||
public void setDestinationLocationArn(String destinationLocationArn) {
|
||||
this.destinationLocationArn = destinationLocationArn;
|
||||
}
|
||||
|
||||
public String getCloudWatchLogGroupArn() {
|
||||
return cloudWatchLogGroupArn;
|
||||
}
|
||||
|
||||
public void setCloudWatchLogGroupArn(String cloudWatchLogGroupArn) {
|
||||
this.cloudWatchLogGroupArn = cloudWatchLogGroupArn;
|
||||
}
|
||||
|
||||
public JsonNode getOptions() {
|
||||
return options;
|
||||
}
|
||||
|
||||
public void setOptions(JsonNode options) {
|
||||
this.options = options;
|
||||
}
|
||||
|
||||
public JsonNode getExcludes() {
|
||||
return excludes;
|
||||
}
|
||||
|
||||
public void setExcludes(JsonNode excludes) {
|
||||
this.excludes = excludes;
|
||||
}
|
||||
|
||||
public JsonNode getIncludes() {
|
||||
return includes;
|
||||
}
|
||||
|
||||
public void setIncludes(JsonNode includes) {
|
||||
this.includes = includes;
|
||||
}
|
||||
|
||||
public JsonNode getSchedule() {
|
||||
return schedule;
|
||||
}
|
||||
|
||||
public void setSchedule(JsonNode schedule) {
|
||||
this.schedule = schedule;
|
||||
}
|
||||
|
||||
public JsonNode getManifestConfig() {
|
||||
return manifestConfig;
|
||||
}
|
||||
|
||||
public void setManifestConfig(JsonNode manifestConfig) {
|
||||
this.manifestConfig = manifestConfig;
|
||||
}
|
||||
|
||||
public JsonNode getTaskReportConfig() {
|
||||
return taskReportConfig;
|
||||
}
|
||||
|
||||
public void setTaskReportConfig(JsonNode taskReportConfig) {
|
||||
this.taskReportConfig = taskReportConfig;
|
||||
}
|
||||
|
||||
public Instant getCreationTime() {
|
||||
return creationTime;
|
||||
}
|
||||
|
||||
public void setCreationTime(Instant creationTime) {
|
||||
this.creationTime = creationTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getTags() {
|
||||
if (tags == null) {
|
||||
tags = new LinkedHashMap<>();
|
||||
}
|
||||
return tags;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTags(Map<String, String> tags) {
|
||||
this.tags = tags != null ? tags : new LinkedHashMap<>();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user