mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
feat(fis): add AWS FIS support (#2435)
* feat(fis): add AWS FIS support * refactor: add typed FIS persistence models * ci(fis): retrigger timed-out build * fix(fis): reject trailing JSON request bodies
This commit is contained in:
1 parent
d0a96d87b1
commit
04d120fdd5
48 files changed
+6225
-13
No files matched your search
@@ -266,6 +266,7 @@ public interface EmulatorConfig {
|
||||
Ec2StorageConfig ec2();
|
||||
NeptuneStorageConfig neptune();
|
||||
BackupStorageConfig backup();
|
||||
FisStorageConfig fis();
|
||||
CloudFrontStorageConfig cloudfront();
|
||||
AppSyncStorageConfig appsync();
|
||||
BatchStorageConfig batch();
|
||||
@@ -404,6 +405,13 @@ public interface EmulatorConfig {
|
||||
long flushIntervalMs();
|
||||
}
|
||||
|
||||
interface FisStorageConfig {
|
||||
Optional<String> mode();
|
||||
|
||||
@WithDefault("5000")
|
||||
long flushIntervalMs();
|
||||
}
|
||||
|
||||
interface CloudFrontStorageConfig {
|
||||
Optional<String> mode();
|
||||
}
|
||||
@@ -601,6 +609,7 @@ public interface EmulatorConfig {
|
||||
ApplicationAutoScalingServiceConfig applicationautoscaling();
|
||||
ElasticBeanstalkServiceConfig elasticbeanstalk();
|
||||
BackupServiceConfig backup();
|
||||
FisServiceConfig fis();
|
||||
NeptuneServiceConfig neptune();
|
||||
DocDbServiceConfig docdb();
|
||||
Route53ServiceConfig route53();
|
||||
@@ -703,6 +712,11 @@ public interface EmulatorConfig {
|
||||
int jobCompletionDelaySeconds();
|
||||
}
|
||||
|
||||
interface FisServiceConfig {
|
||||
@WithDefault("true")
|
||||
boolean enabled();
|
||||
}
|
||||
|
||||
interface Route53ServiceConfig {
|
||||
@WithDefault("true")
|
||||
boolean enabled();
|
||||
|
||||
+80
@@ -0,0 +1,80 @@
|
||||
package io.github.hectorvent.floci.core.common;
|
||||
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.container.ContainerRequestContext;
|
||||
import jakarta.ws.rs.container.ContainerResponseContext;
|
||||
import jakarta.ws.rs.container.ContainerResponseFilter;
|
||||
import jakarta.ws.rs.container.ResourceInfo;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import jakarta.ws.rs.ext.Provider;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/** Adds the modeled AWS error type header to REST JSON error responses. */
|
||||
@Provider
|
||||
public class AwsRestJsonErrorHeaderFilter implements ContainerResponseFilter {
|
||||
|
||||
private static final String ERROR_TYPE_HEADER = "X-Amzn-Errortype";
|
||||
|
||||
@Context
|
||||
ResourceInfo resourceInfo;
|
||||
|
||||
private final ResolvedServiceCatalog catalog;
|
||||
|
||||
@Inject
|
||||
public AwsRestJsonErrorHeaderFilter(ResolvedServiceCatalog catalog) {
|
||||
this.catalog = catalog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void filter(ContainerRequestContext request, ContainerResponseContext response) {
|
||||
if (response.getStatus() < 400 || response.getHeaderString(ERROR_TYPE_HEADER) != null) {
|
||||
return;
|
||||
}
|
||||
Object claimValue = request.getProperty(AwsProtocolClaimFilter.CLAIM_PROPERTY);
|
||||
if (claimValue instanceof ProtocolClaim claim && claim.protocol() != WireProtocol.REST) {
|
||||
return;
|
||||
}
|
||||
if (resolveDescriptor(request)
|
||||
.filter(descriptor -> descriptor.supportsProtocol(ServiceProtocol.REST_JSON))
|
||||
.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
errorType(response.getEntity()).ifPresent(type ->
|
||||
response.getHeaders().putSingle(ERROR_TYPE_HEADER, normalize(type)));
|
||||
}
|
||||
|
||||
private Optional<ServiceDescriptor> resolveDescriptor(ContainerRequestContext request) {
|
||||
Object claimValue = request.getProperty(AwsProtocolClaimFilter.CLAIM_PROPERTY);
|
||||
if (claimValue instanceof ProtocolClaim claim && claim.service() != null) {
|
||||
return Optional.of(claim.service());
|
||||
}
|
||||
if (resourceInfo != null && resourceInfo.getResourceClass() != null) {
|
||||
Optional<ServiceDescriptor> descriptor = catalog.byResourceClass(resourceInfo.getResourceClass());
|
||||
if (descriptor.isPresent()) {
|
||||
return descriptor;
|
||||
}
|
||||
}
|
||||
return SigV4CredentialScope.serviceName(request.getHeaderString("Authorization"))
|
||||
.flatMap(catalog::byCredentialScope);
|
||||
}
|
||||
|
||||
private Optional<String> errorType(Object entity) {
|
||||
if (entity instanceof AwsErrorResponse error) {
|
||||
return Optional.ofNullable(error.type());
|
||||
}
|
||||
if (entity instanceof JsonNode node && node.hasNonNull("__type")) {
|
||||
return Optional.of(node.path("__type").asText());
|
||||
}
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
private String normalize(String type) {
|
||||
int hash = type.lastIndexOf('#');
|
||||
String normalized = hash >= 0 ? type.substring(hash + 1) : type;
|
||||
int colon = normalized.indexOf(':');
|
||||
return colon >= 0 ? normalized.substring(0, colon) : normalized;
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ import io.github.hectorvent.floci.services.bedrockruntime.BedrockRuntimeControll
|
||||
import io.github.hectorvent.floci.services.cognito.CognitoOAuthController;
|
||||
import io.github.hectorvent.floci.services.cognito.CognitoWellKnownController;
|
||||
import io.github.hectorvent.floci.services.eks.EksController;
|
||||
import io.github.hectorvent.floci.services.fis.FisController;
|
||||
import io.github.hectorvent.floci.services.mwaa.MwaaController;
|
||||
import io.github.hectorvent.floci.services.iot.IotController;
|
||||
import io.github.hectorvent.floci.services.iot.IotDataController;
|
||||
@@ -395,6 +396,11 @@ public class ResolvedServiceCatalog {
|
||||
config.storage().services().backup().flushIntervalMs(), null, ServiceProtocol.REST_JSON,
|
||||
protocols(ServiceProtocol.REST_JSON),
|
||||
Set.of(), Set.of("backup"), Set.of(), Set.of(BackupController.class)),
|
||||
descriptor("fis", "fis", config.services().fis().enabled(), true,
|
||||
"fis", storageMode(config.storage().services().fis().mode(), config.storage().mode()),
|
||||
config.storage().services().fis().flushIntervalMs(), null, ServiceProtocol.REST_JSON,
|
||||
protocols(ServiceProtocol.REST_JSON),
|
||||
Set.of(), Set.of("fis"), Set.of(), Set.of(FisController.class)),
|
||||
descriptor("ec2messages", "ec2messages", config.services().ssm().enabled(), false,
|
||||
null, null, 5000L, null, ServiceProtocol.JSON,
|
||||
protocols(ServiceProtocol.JSON),
|
||||
|
||||
@@ -101,7 +101,8 @@ public class SharedTagsController {
|
||||
throw new AwsException("MethodNotAllowedException",
|
||||
"POST is not supported for " + handler.serviceKey() + " tag resources; use PUT.", 405);
|
||||
}
|
||||
return doTagResource(headers, handler, arn, body, Response.noContent().build());
|
||||
return doTagResource(headers, handler, arn, body,
|
||||
Response.status(handler.tagResourceSuccessStatus()).build());
|
||||
}
|
||||
|
||||
@PUT
|
||||
@@ -115,7 +116,8 @@ public class SharedTagsController {
|
||||
throw new AwsException("MethodNotAllowedException",
|
||||
"PUT is not supported for " + handler.serviceKey() + " tag resources; use POST.", 405);
|
||||
}
|
||||
return doTagResource(headers, handler, arn, body, Response.noContent().build());
|
||||
return doTagResource(headers, handler, arn, body,
|
||||
Response.status(handler.tagResourceSuccessStatus()).build());
|
||||
}
|
||||
|
||||
private Response doTagResource(HttpHeaders headers, TagHandler handler, String arn, String body, Response successResponse) {
|
||||
@@ -146,11 +148,17 @@ public class SharedTagsController {
|
||||
public Response untagResource(@Context HttpHeaders headers,
|
||||
@Context UriInfo uriInfo,
|
||||
@PathParam("arn") String arn) {
|
||||
return untagResourceForArn(headers, uriInfo, arn, Response.noContent().build());
|
||||
TagHandler handler = resolveHandler(arn);
|
||||
return untagResourceForArn(headers, uriInfo, arn,
|
||||
Response.status(handler.untagResourceSuccessStatus()).build(), handler);
|
||||
}
|
||||
|
||||
private Response untagResourceForArn(HttpHeaders headers, UriInfo uriInfo, String arn, Response successResponse) {
|
||||
TagHandler handler = resolveHandler(arn);
|
||||
return untagResourceForArn(headers, uriInfo, arn, successResponse, resolveHandler(arn));
|
||||
}
|
||||
|
||||
private Response untagResourceForArn(HttpHeaders headers, UriInfo uriInfo, String arn,
|
||||
Response successResponse, TagHandler handler) {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
List<String> tagKeys = readTagKeys(handler, uriInfo);
|
||||
handler.untagResource(region, arn, tagKeys);
|
||||
@@ -207,6 +215,11 @@ public class SharedTagsController {
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (handler.strictTagValidation() && (!k.isTextual() || !v.isTextual())) {
|
||||
throw new AwsException("ValidationException",
|
||||
"1 validation error detected: Tag entries at '" + key
|
||||
+ "' must contain string Key and Value members", 400);
|
||||
}
|
||||
tags.put(k.asText(), v.asText());
|
||||
}
|
||||
} else {
|
||||
@@ -217,7 +230,13 @@ public class SharedTagsController {
|
||||
}
|
||||
return tags;
|
||||
}
|
||||
tagNode.fields().forEachRemaining(e -> tags.put(e.getKey(), e.getValue().asText()));
|
||||
tagNode.fields().forEachRemaining(e -> {
|
||||
if (handler.strictTagValidation() && !e.getValue().isTextual()) {
|
||||
throw new AwsException("ValidationException",
|
||||
"1 validation error detected: Tag values at '" + key + "' must be strings", 400);
|
||||
}
|
||||
tags.put(e.getKey(), e.getValue().asText());
|
||||
});
|
||||
}
|
||||
return tags;
|
||||
}
|
||||
@@ -225,7 +244,8 @@ public class SharedTagsController {
|
||||
private List<String> readTagKeys(TagHandler handler, UriInfo uriInfo) {
|
||||
String paramName = handler.tagKeysQueryName();
|
||||
List<String> values = uriInfo.getQueryParameters().get(paramName);
|
||||
if (handler.strictTagValidation() && (values == null || values.isEmpty())) {
|
||||
if (handler.strictTagValidation() && !handler.allowEmptyTagKeys()
|
||||
&& (values == null || values.isEmpty())) {
|
||||
throw new AwsException("ValidationException",
|
||||
"1 validation error detected: Value null at '" + paramName + "' failed to satisfy constraint: Member must not be null", 400);
|
||||
}
|
||||
|
||||
@@ -76,6 +76,14 @@ public interface TagHandler {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether an {@code UntagResource} request may omit the tag-key query parameter.
|
||||
* Defaults to {@code false} so strict handlers retain their existing validation.
|
||||
*/
|
||||
default boolean allowEmptyTagKeys() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Query parameter name for {@code UntagResource}. Defaults to lowercase
|
||||
* {@code "tagKeys"}, which matches the great majority of AWS services — including
|
||||
@@ -98,6 +106,16 @@ public interface TagHandler {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** HTTP status for successful path-based TagResource requests. */
|
||||
default int tagResourceSuccessStatus() {
|
||||
return 204;
|
||||
}
|
||||
|
||||
/** HTTP status for successful path-based UntagResource requests. */
|
||||
default int untagResourceSuccessStatus() {
|
||||
return 204;
|
||||
}
|
||||
|
||||
Map<String, String> listTags(String region, String arn);
|
||||
|
||||
void tagResource(String region, String arn, Map<String, String> tags);
|
||||
|
||||
@@ -0,0 +1,491 @@
|
||||
package io.github.hectorvent.floci.services.fis;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
import jakarta.enterprise.context.ApplicationScoped;
|
||||
import jakarta.inject.Inject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/** Static AWS FIS action and target-resource-type catalog. */
|
||||
@ApplicationScoped
|
||||
public class FisCatalog {
|
||||
|
||||
private static final String WAIT_DESCRIPTION = "Runs the AWS FIS wait action.";
|
||||
private static final String STOP_INSTANCES_DESCRIPTION =
|
||||
"Runs the Amazon EC2 API action StopInstances on the target EC2 instances.";
|
||||
private static final String DURATION_DESCRIPTION = "The action duration in ISO 8601 format.";
|
||||
private static final String KUBERNETES_SERVICE_ACCOUNT_DESCRIPTION =
|
||||
"The Kubernetes service account used by the fault injection pod.";
|
||||
|
||||
private static final Map<String, ActionDefinition> ACTIONS = buildActions();
|
||||
private static final Map<String, TargetResourceTypeDefinition> RESOURCE_TYPES = buildResourceTypes();
|
||||
|
||||
private final ObjectMapper mapper;
|
||||
private final RegionResolver regionResolver;
|
||||
|
||||
@Inject
|
||||
public FisCatalog(ObjectMapper mapper, RegionResolver regionResolver) {
|
||||
this.mapper = mapper;
|
||||
this.regionResolver = regionResolver;
|
||||
}
|
||||
|
||||
public boolean containsAction(String actionId) {
|
||||
return actionId != null && ACTIONS.containsKey(actionId);
|
||||
}
|
||||
|
||||
public Set<String> actionIds() {
|
||||
return ACTIONS.keySet();
|
||||
}
|
||||
|
||||
public ObjectNode action(String region, String actionId) {
|
||||
ActionDefinition definition = ACTIONS.get(actionId);
|
||||
if (definition == null) {
|
||||
return null;
|
||||
}
|
||||
ObjectNode action = actionSummary(region, actionId, definition);
|
||||
action.set("parameters", parameterNodes(definition.parameters()));
|
||||
return action;
|
||||
}
|
||||
|
||||
public List<ObjectNode> actionSummaries(String region) {
|
||||
List<ObjectNode> result = new ArrayList<>(ACTIONS.size());
|
||||
ACTIONS.forEach((id, definition) -> result.add(actionSummary(region, id, definition)));
|
||||
return result;
|
||||
}
|
||||
|
||||
public boolean containsTargetResourceType(String resourceType) {
|
||||
return resourceType != null && RESOURCE_TYPES.containsKey(resourceType);
|
||||
}
|
||||
|
||||
public ObjectNode targetResourceType(String resourceType) {
|
||||
TargetResourceTypeDefinition definition = RESOURCE_TYPES.get(resourceType);
|
||||
if (definition == null) {
|
||||
return null;
|
||||
}
|
||||
ObjectNode node = targetResourceTypeSummary(resourceType, definition.description());
|
||||
node.set("parameters", parameterNodes(definition.parameters()));
|
||||
return node;
|
||||
}
|
||||
|
||||
public List<ObjectNode> targetResourceTypeSummaries() {
|
||||
List<ObjectNode> result = new ArrayList<>(RESOURCE_TYPES.size());
|
||||
RESOURCE_TYPES.forEach((resourceType, definition) ->
|
||||
result.add(targetResourceTypeSummary(resourceType, definition.description())));
|
||||
return result;
|
||||
}
|
||||
|
||||
private ObjectNode parameterNodes(Map<String, ParameterDefinition> definitions) {
|
||||
ObjectNode parameters = mapper.createObjectNode();
|
||||
definitions.forEach((name, parameter) -> {
|
||||
ObjectNode value = parameters.putObject(name);
|
||||
value.put("description", parameter.description());
|
||||
value.put("required", parameter.required());
|
||||
});
|
||||
return parameters;
|
||||
}
|
||||
|
||||
private ObjectNode actionSummary(String region, String actionId, ActionDefinition definition) {
|
||||
ObjectNode action = mapper.createObjectNode();
|
||||
action.put("id", actionId);
|
||||
action.put("arn", regionResolver.buildArn("fis", region, "action/" + actionId));
|
||||
action.put("description", definition.description());
|
||||
ObjectNode targets = action.putObject("targets");
|
||||
definition.targets().forEach((name, resourceType) ->
|
||||
targets.putObject(name).put("resourceType", resourceType));
|
||||
action.putObject("tags");
|
||||
return action;
|
||||
}
|
||||
|
||||
private ObjectNode targetResourceTypeSummary(String resourceType, String description) {
|
||||
ObjectNode node = mapper.createObjectNode();
|
||||
node.put("resourceType", resourceType);
|
||||
node.put("description", description);
|
||||
return node;
|
||||
}
|
||||
|
||||
private static Map<String, ActionDefinition> buildActions() {
|
||||
Map<String, ActionDefinition> actions = new LinkedHashMap<>();
|
||||
|
||||
Map<String, ParameterDefinition> injectApiParameters = parameters(
|
||||
required("duration", DURATION_DESCRIPTION),
|
||||
required("service", "The target AWS API namespace."),
|
||||
required("percentage", "The percentage of API calls to impair."),
|
||||
required("operations", "The comma-separated API operations to impair."));
|
||||
add(actions, "aws:fis:inject-api-internal-error",
|
||||
"Injects internal errors into supported AWS API calls.",
|
||||
target("Roles", "aws:iam:role"), injectApiParameters);
|
||||
add(actions, "aws:fis:inject-api-throttle-error",
|
||||
"Injects throttling errors into supported AWS API calls.",
|
||||
target("Roles", "aws:iam:role"), injectApiParameters);
|
||||
add(actions, "aws:fis:inject-api-unavailable-error",
|
||||
"Injects unavailable errors into supported AWS API calls.",
|
||||
target("Roles", "aws:iam:role"), injectApiParameters);
|
||||
add(actions, "aws:arc:start-zonal-autoshift",
|
||||
"Starts an ARC zonal autoshift for the target managed resources.",
|
||||
target("ManagedResources", "aws:arc:zonal-shift-managed-resource"), parameters(
|
||||
required("duration", DURATION_DESCRIPTION),
|
||||
required("availabilityZoneIdentifier", "The Availability Zone to shift traffic away from."),
|
||||
optional("managedResourceTypes", "The comma-separated managed resource types to shift."),
|
||||
optional("zonalAutoshiftStatus", "The zonal autoshift status used to select resources.")));
|
||||
add(actions, "aws:fis:wait", WAIT_DESCRIPTION, Map.of(),
|
||||
parameters(required("duration",
|
||||
"The duration, from one minute to 12 hours, in ISO 8601 format.")));
|
||||
add(actions, "aws:cloudwatch:assert-alarm-state",
|
||||
"Verifies that the specified alarms are in the specified alarm states.", Map.of(), parameters(
|
||||
required("alarmArns", "The comma-separated ARNs of up to five CloudWatch alarms."),
|
||||
required("alarmStates", "The comma-separated alarm states to assert.")));
|
||||
add(actions, "aws:dynamodb:global-table-pause-replication",
|
||||
"Pauses replication for the target DynamoDB global table.",
|
||||
target("Tables", "aws:dynamodb:global-table"), durationParameters());
|
||||
add(actions, "aws:dsql:cluster-connection-failure",
|
||||
"Injects connection failures into the target Amazon Aurora DSQL clusters.",
|
||||
target("Clusters", "aws:dsql:cluster"), parameters(
|
||||
required("duration", DURATION_DESCRIPTION),
|
||||
required("percentage", "The percentage of calls to impair.")));
|
||||
add(actions, "aws:ebs:pause-volume-io", "Pauses I/O operations on the target EBS volumes.",
|
||||
target("Volumes", "aws:ec2:ebs-volume"), durationParameters());
|
||||
add(actions, "aws:ebs:volume-io-latency", "Injects I/O latency into the target EBS volumes.",
|
||||
target("Volumes", "aws:ec2:ebs-volume"), parameters(
|
||||
optional("readIOPercentage", "The percentage of read I/O operations to impair."),
|
||||
optional("readIOLatencyMilliseconds", "The latency added to read I/O operations."),
|
||||
optional("writeIOPercentage", "The percentage of write I/O operations to impair."),
|
||||
optional("writeIOLatencyMilliseconds", "The latency added to write I/O operations."),
|
||||
required("duration", DURATION_DESCRIPTION)));
|
||||
add(actions, "aws:ec2:api-insufficient-instance-capacity-error",
|
||||
"Injects insufficient instance capacity errors into EC2 API calls.",
|
||||
target("Roles", "aws:iam:role"), parameters(
|
||||
required("duration", DURATION_DESCRIPTION),
|
||||
required("availabilityZoneIdentifiers", "The comma-separated Availability Zones to impair."),
|
||||
required("percentage", "The percentage of calls to impair.")));
|
||||
add(actions, "aws:ec2:asg-insufficient-instance-capacity-error",
|
||||
"Injects insufficient instance capacity errors for target Auto Scaling groups.",
|
||||
target("AutoScalingGroups", "aws:ec2:autoscaling-group"), parameters(
|
||||
required("duration", DURATION_DESCRIPTION),
|
||||
required("availabilityZoneIdentifiers", "The comma-separated Availability Zones to impair."),
|
||||
optional("percentage", "The percentage of launch requests to impair.")));
|
||||
add(actions, "aws:ec2:reboot-instances",
|
||||
"Runs the Amazon EC2 API action RebootInstances on the target EC2 instances.",
|
||||
target("Instances", "aws:ec2:instance"), Map.of());
|
||||
add(actions, "aws:ec2:send-spot-instance-interruptions",
|
||||
"Sends Spot Instance interruption notices to the target EC2 Spot Instances.",
|
||||
target("SpotInstances", "aws:ec2:spot-instance"), parameters(
|
||||
required("durationBeforeInterruption", "The delay before interruption in ISO 8601 format.")));
|
||||
add(actions, "aws:ec2:stop-instances", STOP_INSTANCES_DESCRIPTION,
|
||||
target("Instances", "aws:ec2:instance"), parameters(
|
||||
optional("startInstancesAfterDuration", "The delay before restarting the instances."),
|
||||
optional("completeIfInstancesTerminated",
|
||||
"Whether the action completes if target instances were terminated.")));
|
||||
add(actions, "aws:ec2:terminate-instances",
|
||||
"Runs the Amazon EC2 API action TerminateInstances on the target EC2 instances.",
|
||||
target("Instances", "aws:ec2:instance"), Map.of());
|
||||
add(actions, "aws:ecs:drain-container-instances",
|
||||
"Drains container instances in the target ECS clusters.",
|
||||
target("Clusters", "aws:ecs:cluster"), parameters(
|
||||
required("drainagePercentage", "The percentage of container instances to drain."),
|
||||
required("duration", DURATION_DESCRIPTION)));
|
||||
add(actions, "aws:ecs:stop-task", "Stops the target Amazon ECS tasks.",
|
||||
target("Tasks", "aws:ecs:task"), Map.of());
|
||||
add(actions, "aws:ecs:task-cpu-stress", "Runs CPU stress on the target Amazon ECS tasks.",
|
||||
target("Tasks", "aws:ecs:task"), parameters(
|
||||
required("duration", DURATION_DESCRIPTION),
|
||||
optional("percent", "The target CPU load percentage."),
|
||||
optional("workers", "The number of CPU stress workers."),
|
||||
optional("installDependencies", "Whether to install required dependencies.")));
|
||||
add(actions, "aws:ecs:task-io-stress", "Runs I/O stress on the target Amazon ECS tasks.",
|
||||
target("Tasks", "aws:ecs:task"), parameters(
|
||||
required("duration", DURATION_DESCRIPTION),
|
||||
optional("percent", "The percentage of free file-system space to use."),
|
||||
optional("workers", "The number of I/O stress workers."),
|
||||
optional("installDependencies", "Whether to install required dependencies.")));
|
||||
add(actions, "aws:ecs:task-kill-process", "Kills a process in the target Amazon ECS tasks.",
|
||||
target("Tasks", "aws:ecs:task"), parameters(
|
||||
required("processName", "The process name to stop."),
|
||||
optional("signal", "The signal to send to the process."),
|
||||
optional("installDependencies", "Whether to install required dependencies.")));
|
||||
add(actions, "aws:ecs:task-network-blackhole-port",
|
||||
"Drops network traffic on a port in the target Amazon ECS tasks.",
|
||||
target("Tasks", "aws:ecs:task"), parameters(
|
||||
required("duration", DURATION_DESCRIPTION),
|
||||
required("port", "The port number to impair."),
|
||||
required("trafficType", "The ingress or egress traffic direction."),
|
||||
optional("protocol", "The tcp or udp protocol."),
|
||||
optional("installDependencies", "Whether to install required dependencies."),
|
||||
optional("useEcsFaultInjectionEndpoints", "Whether to use ECS fault injection endpoints.")));
|
||||
add(actions, "aws:ecs:task-network-latency",
|
||||
"Injects network latency into the target Amazon ECS tasks.",
|
||||
target("Tasks", "aws:ecs:task"), parameters(
|
||||
required("duration", DURATION_DESCRIPTION),
|
||||
optional("delayMilliseconds", "The network delay in milliseconds."),
|
||||
optional("jitterMilliseconds", "The network jitter in milliseconds."),
|
||||
optional("flowsPercent", "The percentage of network flows to impair."),
|
||||
optional("sources", "The comma-separated traffic sources to impair."),
|
||||
optional("installDependencies", "Whether to install required dependencies."),
|
||||
optional("useEcsFaultInjectionEndpoints", "Whether to use ECS fault injection endpoints.")));
|
||||
add(actions, "aws:ecs:task-network-packet-loss",
|
||||
"Injects network packet loss into the target Amazon ECS tasks.",
|
||||
target("Tasks", "aws:ecs:task"), parameters(
|
||||
required("duration", DURATION_DESCRIPTION),
|
||||
optional("lossPercent", "The packet loss percentage."),
|
||||
optional("flowsPercent", "The percentage of network flows to impair."),
|
||||
optional("sources", "The comma-separated traffic sources to impair."),
|
||||
optional("installDependencies", "Whether to install required dependencies."),
|
||||
optional("useEcsFaultInjectionEndpoints", "Whether to use ECS fault injection endpoints.")));
|
||||
add(actions, "aws:eks:inject-kubernetes-custom-resource",
|
||||
"Injects a Kubernetes custom resource into the target EKS cluster.",
|
||||
target("Cluster", "aws:eks:cluster"), parameters(
|
||||
required("kubernetesApiVersion", "The Kubernetes custom resource API version."),
|
||||
required("kubernetesKind", "The Kubernetes custom resource kind."),
|
||||
required("kubernetesNamespace", "The Kubernetes namespace."),
|
||||
required("kubernetesSpec", "The custom resource spec in JSON format."),
|
||||
required("maxDuration", "The maximum automation duration in ISO 8601 format.")));
|
||||
add(actions, "aws:eks:pod-cpu-stress", "Runs CPU stress on the target Kubernetes pods.",
|
||||
target("Pods", "aws:eks:pod"), eksPodParameters(true,
|
||||
required("duration", DURATION_DESCRIPTION),
|
||||
optional("percent", "The target CPU load percentage."),
|
||||
optional("workers", "The number of CPU stress workers.")));
|
||||
add(actions, "aws:eks:pod-delete", "Deletes the target Kubernetes pods.",
|
||||
target("Pods", "aws:eks:pod"), eksPodParameters(true,
|
||||
optional("gracePeriodSeconds", "The graceful pod termination period in seconds.")));
|
||||
add(actions, "aws:eks:pod-io-stress", "Runs I/O stress on the target Kubernetes pods.",
|
||||
target("Pods", "aws:eks:pod"), eksPodParameters(true,
|
||||
required("duration", DURATION_DESCRIPTION),
|
||||
optional("workers", "The number of I/O stress workers."),
|
||||
optional("percent", "The percentage of free file-system space to use.")));
|
||||
add(actions, "aws:eks:pod-memory-stress", "Runs memory stress on the target Kubernetes pods.",
|
||||
target("Pods", "aws:eks:pod"), eksPodParameters(true,
|
||||
required("duration", DURATION_DESCRIPTION),
|
||||
optional("workers", "The number of memory stress workers."),
|
||||
optional("percent", "The percentage of virtual memory to use.")));
|
||||
add(actions, "aws:eks:pod-network-blackhole-port",
|
||||
"Drops network traffic on a port in the target Kubernetes pods.",
|
||||
target("Pods", "aws:eks:pod"), eksPodParameters(false,
|
||||
required("duration", DURATION_DESCRIPTION),
|
||||
required("protocol", "The tcp or udp protocol."),
|
||||
required("trafficType", "The ingress or egress traffic direction."),
|
||||
required("port", "The port number to impair.")));
|
||||
add(actions, "aws:eks:pod-network-latency",
|
||||
"Injects network latency into the target Kubernetes pods.",
|
||||
target("Pods", "aws:eks:pod"), eksPodParameters(false,
|
||||
required("duration", DURATION_DESCRIPTION),
|
||||
optional("interface", "The network interfaces to impair."),
|
||||
optional("delayMilliseconds", "The network delay in milliseconds."),
|
||||
optional("jitterMilliseconds", "The network jitter in milliseconds."),
|
||||
optional("flowsPercent", "The percentage of network flows to impair."),
|
||||
optional("sources", "The comma-separated traffic sources to impair.")));
|
||||
add(actions, "aws:eks:pod-network-packet-loss",
|
||||
"Injects network packet loss into the target Kubernetes pods.",
|
||||
target("Pods", "aws:eks:pod"), eksPodParameters(false,
|
||||
required("duration", DURATION_DESCRIPTION),
|
||||
optional("interface", "The network interfaces to impair."),
|
||||
optional("lossPercent", "The packet loss percentage."),
|
||||
optional("flowsPercent", "The percentage of network flows to impair."),
|
||||
optional("sources", "The comma-separated traffic sources to impair.")));
|
||||
add(actions, "aws:eks:terminate-nodegroup-instances",
|
||||
"Terminates instances in the target Amazon EKS node groups.",
|
||||
target("Nodegroups", "aws:eks:nodegroup"), parameters(
|
||||
required("instanceTerminationPercentage", "The percentage of instances to terminate.")));
|
||||
add(actions, "aws:elasticache:replicationgroup-interrupt-az-power",
|
||||
"Interrupts Availability Zone power for the target ElastiCache replication groups.",
|
||||
target("ReplicationGroups", "aws:elasticache:replicationgroup"), durationParameters());
|
||||
add(actions, "aws:kinesis:stream-provisioned-throughput-exception",
|
||||
"Injects ProvisionedThroughputExceededException errors into target Kinesis streams.",
|
||||
target("KinesisStreams", "aws:kinesis:stream"), parameters(
|
||||
required("duration", DURATION_DESCRIPTION),
|
||||
required("percentage", "The percentage of calls to impair.")));
|
||||
add(actions, "aws:kinesis:stream-expired-iterator-exception",
|
||||
"Injects ExpiredIteratorException errors into target Kinesis streams.",
|
||||
target("KinesisStreams", "aws:kinesis:stream"), parameters(
|
||||
required("duration", DURATION_DESCRIPTION),
|
||||
required("percentage", "The percentage of calls to impair.")));
|
||||
add(actions, "aws:lambda:invocation-add-delay",
|
||||
"Adds a delay to invocations of the target Lambda functions.",
|
||||
target("Functions", "aws:lambda:function"), parameters(
|
||||
required("duration", DURATION_DESCRIPTION),
|
||||
optional("invocationPercentage", "The percentage of function invocations to impair."),
|
||||
optional("startupDelayMilliseconds", "The invocation delay in milliseconds.")));
|
||||
add(actions, "aws:lambda:invocation-error",
|
||||
"Injects errors into invocations of the target Lambda functions.",
|
||||
target("Functions", "aws:lambda:function"), parameters(
|
||||
required("duration", DURATION_DESCRIPTION),
|
||||
optional("invocationPercentage", "The percentage of function invocations to impair."),
|
||||
required("preventExecution", "Whether to return the error without executing the function.")));
|
||||
add(actions, "aws:lambda:invocation-http-integration-response",
|
||||
"Injects HTTP integration responses into invocations of the target Lambda functions.",
|
||||
target("Functions", "aws:lambda:function"), parameters(
|
||||
required("contentTypeHeader", "The HTTP content type header to return."),
|
||||
required("duration", DURATION_DESCRIPTION),
|
||||
optional("invocationPercentage", "The percentage of function invocations to impair."),
|
||||
required("preventExecution", "Whether to return without executing the function."),
|
||||
required("statusCode", "The HTTP status code to return.")));
|
||||
add(actions, "aws:memorydb:multi-region-cluster-pause-replication",
|
||||
"Pauses replication for the target MemoryDB multi-Region clusters.",
|
||||
target("MultiRegionClusters", "aws:memorydb:multi-region-cluster"), durationParameters());
|
||||
add(actions, "aws:network:disrupt-connectivity", "Disrupts network connectivity for the target subnets.",
|
||||
target("Subnets", "aws:ec2:subnet"), parameters(
|
||||
required("scope", "The type of traffic to deny."),
|
||||
required("duration", DURATION_DESCRIPTION),
|
||||
optional("prefixListIdentifier", "The prefix list used when scope is prefix-list.")));
|
||||
add(actions, "aws:network:route-table-disrupt-cross-region-connectivity",
|
||||
"Disrupts cross-Region connectivity for the target subnets using route tables.",
|
||||
target("Subnets", "aws:ec2:subnet"), parameters(
|
||||
required("region", "The Region to isolate."),
|
||||
required("duration", DURATION_DESCRIPTION)));
|
||||
add(actions, "aws:network:transit-gateway-disrupt-cross-region-connectivity",
|
||||
"Disrupts cross-Region connectivity for the target transit gateways.",
|
||||
target("TransitGateways", "aws:ec2:transit-gateway"), parameters(
|
||||
required("region", "The Region to isolate."),
|
||||
required("duration", DURATION_DESCRIPTION)));
|
||||
add(actions, "aws:network:disrupt-vpc-endpoint",
|
||||
"Disrupts connectivity for the target VPC endpoints.",
|
||||
target("VPCEndpoints", "aws:ec2:vpc-endpoint"), durationParameters());
|
||||
add(actions, "aws:rds:failover-db-cluster", "Fails over the target Amazon RDS DB clusters.",
|
||||
target("Clusters", "aws:rds:cluster"), Map.of());
|
||||
add(actions, "aws:rds:reboot-db-instances", "Reboots the target Amazon RDS DB instances.",
|
||||
target("DBInstances", "aws:rds:db"), parameters(
|
||||
optional("forceFailover", "Whether to force a Multi-AZ failover.")));
|
||||
add(actions, "aws:s3:bucket-pause-replication",
|
||||
"Pauses replication for the target Amazon S3 buckets.",
|
||||
target("Buckets", "aws:s3:bucket"), parameters(
|
||||
required("duration", DURATION_DESCRIPTION),
|
||||
required("region", "The Region containing destination buckets."),
|
||||
optional("destinationBuckets", "The comma-separated destination bucket names."),
|
||||
optional("prefixes", "The comma-separated replication rule prefixes.")));
|
||||
add(actions, "aws:ssm:send-command", "Runs an Amazon Systems Manager command on the target resources.",
|
||||
target("Instances", "aws:ec2:instance"), parameters(
|
||||
required("documentArn", "The ARN of the Systems Manager document to run."),
|
||||
optional("documentVersion", "The Systems Manager document version."),
|
||||
optional("documentParameters", "The parameters accepted by the document."),
|
||||
required("duration", DURATION_DESCRIPTION)));
|
||||
add(actions, "aws:ssm:start-automation-execution",
|
||||
"Starts an Amazon Systems Manager automation execution.", Map.of(), parameters(
|
||||
required("documentArn", "The ARN of the Systems Manager automation document to run."),
|
||||
optional("documentVersion", "The Systems Manager automation document version."),
|
||||
optional("documentParameters", "The parameters accepted by the document."),
|
||||
required("maxDuration", "The maximum automation duration in ISO 8601 format.")));
|
||||
add(actions, "aws:directconnect:virtual-interface-disconnect",
|
||||
"Disconnects the target Direct Connect virtual interfaces.",
|
||||
target("VirtualInterfaces", "aws:directconnect:virtual-interface"), durationParameters());
|
||||
|
||||
if (actions.size() != 50) {
|
||||
throw new IllegalStateException("The AWS FIS action catalog must contain exactly 50 actions");
|
||||
}
|
||||
return Collections.unmodifiableMap(actions);
|
||||
}
|
||||
|
||||
private static Map<String, TargetResourceTypeDefinition> buildResourceTypes() {
|
||||
Map<String, TargetResourceTypeDefinition> types = new LinkedHashMap<>();
|
||||
resourceType(types, "aws:arc:zonal-shift-managed-resource", "An ARC zonal shift managed resource.");
|
||||
resourceType(types, "aws:directconnect:virtual-interface", "A Direct Connect virtual interface.");
|
||||
resourceType(types, "aws:dsql:cluster", "An Amazon Aurora DSQL cluster.");
|
||||
resourceType(types, "aws:dynamodb:global-table", "A DynamoDB multi-Region global table.");
|
||||
resourceType(types, "aws:ec2:autoscaling-group", "An EC2 Auto Scaling group.");
|
||||
resourceType(types, "aws:ec2:ebs-volume", "An Amazon EBS volume.", parameters(
|
||||
optional("availabilityZoneIdentifier", "The Availability Zone containing the target volumes.")));
|
||||
resourceType(types, "aws:ec2:instance", "An Amazon EC2 instance.");
|
||||
resourceType(types, "aws:ec2:spot-instance", "An Amazon EC2 Spot Instance.");
|
||||
resourceType(types, "aws:ec2:subnet", "An Amazon VPC subnet.", parameters(
|
||||
optional("availabilityZoneIdentifier", "The Availability Zone containing the target subnets."),
|
||||
optional("vpc", "The VPC containing the target subnets.")));
|
||||
resourceType(types, "aws:ec2:transit-gateway", "An Amazon VPC transit gateway.");
|
||||
resourceType(types, "aws:ec2:vpc-endpoint", "An Amazon VPC endpoint.");
|
||||
resourceType(types, "aws:ecs:cluster", "An Amazon ECS cluster.");
|
||||
resourceType(types, "aws:ecs:task", "An Amazon ECS task.", parameters(
|
||||
optional("cluster", "The cluster containing the target tasks."),
|
||||
optional("service", "The service containing the target tasks.")));
|
||||
resourceType(types, "aws:eks:cluster", "An Amazon EKS cluster.");
|
||||
resourceType(types, "aws:eks:nodegroup", "An Amazon EKS node group.");
|
||||
resourceType(types, "aws:eks:pod", "A Kubernetes pod.", parameters(
|
||||
optional("availabilityZoneIdentifier", "The Availability Zone containing the target pods."),
|
||||
required("clusterIdentifier", "The name or ARN of the target EKS cluster."),
|
||||
required("namespace", "The Kubernetes namespace of the target pods."),
|
||||
required("selectorType", "The selector type used to identify target pods."),
|
||||
required("selectorValue", "The selector value used to identify target pods."),
|
||||
optional("targetContainerName", "The target container name from the pod spec.")));
|
||||
resourceType(types, "aws:elasticache:replicationgroup", "An ElastiCache replication group.", parameters(
|
||||
required("availabilityZoneIdentifier", "The Availability Zone containing the target nodes.")));
|
||||
resourceType(types, "aws:iam:role", "An IAM role.");
|
||||
resourceType(types, "aws:kinesis:stream", "An Amazon Kinesis data stream.");
|
||||
resourceType(types, "aws:lambda:function", "An AWS Lambda function.", parameters(
|
||||
optional("functionQualifier", "The version or alias of the function to target.")));
|
||||
resourceType(types, "aws:memorydb:multi-region-cluster", "A MemoryDB multi-Region cluster.");
|
||||
resourceType(types, "aws:rds:cluster", "An Amazon Aurora DB cluster.", parameters(
|
||||
optional("writerAvailabilityZoneIdentifiers", "The Availability Zones of the DB cluster writer.")));
|
||||
resourceType(types, "aws:rds:db", "An Amazon RDS DB instance.", parameters(
|
||||
optional("availabilityZoneIdentifiers", "The Availability Zones of the DB instance.")));
|
||||
resourceType(types, "aws:s3:bucket", "An Amazon S3 bucket.");
|
||||
return Collections.unmodifiableMap(types);
|
||||
}
|
||||
|
||||
private static Map<String, ParameterDefinition> eksPodParameters(
|
||||
boolean includeSecurityPolicy, NamedParameter... actionParameters) {
|
||||
List<NamedParameter> definitions = new ArrayList<>(List.of(actionParameters));
|
||||
definitions.add(required("kubernetesServiceAccount", KUBERNETES_SERVICE_ACCOUNT_DESCRIPTION));
|
||||
definitions.add(optional("fisPodContainerImage", "The fault injector pod container image."));
|
||||
definitions.add(optional("maxErrorsPercent", "The percentage of targets that may fail."));
|
||||
definitions.add(optional("fisPodLabels", "Labels applied to the fault orchestration pod."));
|
||||
definitions.add(optional("fisPodAnnotations", "Annotations applied to the fault orchestration pod."));
|
||||
if (includeSecurityPolicy) {
|
||||
definitions.add(optional("fisPodSecurityPolicy",
|
||||
"The Kubernetes security policy for the fault orchestration pod."));
|
||||
}
|
||||
return parameters(definitions.toArray(NamedParameter[]::new));
|
||||
}
|
||||
|
||||
private static void resourceType(Map<String, TargetResourceTypeDefinition> types,
|
||||
String resourceType, String description) {
|
||||
resourceType(types, resourceType, description, Map.of());
|
||||
}
|
||||
|
||||
private static void resourceType(Map<String, TargetResourceTypeDefinition> types,
|
||||
String resourceType, String description,
|
||||
Map<String, ParameterDefinition> parameters) {
|
||||
types.put(resourceType, new TargetResourceTypeDefinition(description, parameters));
|
||||
}
|
||||
|
||||
private static void add(Map<String, ActionDefinition> actions, String id, String description,
|
||||
Map<String, String> targets, Map<String, ParameterDefinition> parameters) {
|
||||
actions.put(id, new ActionDefinition(description, targets, parameters));
|
||||
}
|
||||
|
||||
private static Map<String, String> target(String name, String resourceType) {
|
||||
return Map.of(name, resourceType);
|
||||
}
|
||||
|
||||
private static Map<String, ParameterDefinition> durationParameters() {
|
||||
return parameters(required("duration", DURATION_DESCRIPTION));
|
||||
}
|
||||
|
||||
private static Map<String, ParameterDefinition> parameters(NamedParameter... definitions) {
|
||||
Map<String, ParameterDefinition> parameters = new LinkedHashMap<>();
|
||||
for (NamedParameter definition : definitions) {
|
||||
parameters.put(definition.name(),
|
||||
new ParameterDefinition(definition.description(), definition.required()));
|
||||
}
|
||||
return Collections.unmodifiableMap(parameters);
|
||||
}
|
||||
|
||||
private static NamedParameter required(String name, String description) {
|
||||
return new NamedParameter(name, description, true);
|
||||
}
|
||||
|
||||
private static NamedParameter optional(String name, String description) {
|
||||
return new NamedParameter(name, description, false);
|
||||
}
|
||||
|
||||
private record ActionDefinition(String description, Map<String, String> targets,
|
||||
Map<String, ParameterDefinition> parameters) {}
|
||||
|
||||
private record TargetResourceTypeDefinition(String description,
|
||||
Map<String, ParameterDefinition> parameters) {}
|
||||
|
||||
private record NamedParameter(String name, String description, boolean required) {}
|
||||
|
||||
private record ParameterDefinition(String description, boolean required) {}
|
||||
}
|
||||
@@ -0,0 +1,272 @@
|
||||
package io.github.hectorvent.floci.services.fis;
|
||||
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.ObjectReader;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
import jakarta.inject.Inject;
|
||||
import jakarta.ws.rs.Consumes;
|
||||
import jakarta.ws.rs.DELETE;
|
||||
import jakarta.ws.rs.GET;
|
||||
import jakarta.ws.rs.PATCH;
|
||||
import jakarta.ws.rs.POST;
|
||||
import jakarta.ws.rs.Path;
|
||||
import jakarta.ws.rs.PathParam;
|
||||
import jakarta.ws.rs.Produces;
|
||||
import jakarta.ws.rs.QueryParam;
|
||||
import jakarta.ws.rs.core.Context;
|
||||
import jakarta.ws.rs.core.HttpHeaders;
|
||||
import jakarta.ws.rs.core.MediaType;
|
||||
import jakarta.ws.rs.core.Response;
|
||||
|
||||
@Path("/")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
@Consumes(MediaType.APPLICATION_JSON)
|
||||
public class FisController {
|
||||
|
||||
private final FisService service;
|
||||
private final ObjectMapper objectMapper;
|
||||
private final ObjectReader requestReader;
|
||||
private final RegionResolver regionResolver;
|
||||
|
||||
@Inject
|
||||
public FisController(FisService service, ObjectMapper objectMapper, RegionResolver regionResolver) {
|
||||
this.service = service;
|
||||
this.objectMapper = objectMapper;
|
||||
this.requestReader = objectMapper.reader()
|
||||
.with(DeserializationFeature.FAIL_ON_TRAILING_TOKENS);
|
||||
this.regionResolver = regionResolver;
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/experimentTemplates")
|
||||
public Response createExperimentTemplate(@Context HttpHeaders headers, String body) {
|
||||
return ok(service.createExperimentTemplate(region(headers), parse(body)));
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/experimentTemplates/{experimentTemplateId}/targetAccountConfigurations/{accountId}")
|
||||
public Response createTargetAccountConfiguration(
|
||||
@Context HttpHeaders headers,
|
||||
@PathParam("experimentTemplateId") String experimentTemplateId,
|
||||
@PathParam("accountId") String accountId,
|
||||
String body) {
|
||||
return ok(service.createTargetAccountConfiguration(
|
||||
region(headers), experimentTemplateId, accountId, parse(body)));
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@Path("/experimentTemplates/{id}")
|
||||
public Response deleteExperimentTemplate(
|
||||
@Context HttpHeaders headers, @PathParam("id") String id) {
|
||||
return ok(service.deleteExperimentTemplate(region(headers), id));
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@Path("/experimentTemplates/{experimentTemplateId}/targetAccountConfigurations/{accountId}")
|
||||
public Response deleteTargetAccountConfiguration(
|
||||
@Context HttpHeaders headers,
|
||||
@PathParam("experimentTemplateId") String experimentTemplateId,
|
||||
@PathParam("accountId") String accountId) {
|
||||
return ok(service.deleteTargetAccountConfiguration(region(headers), experimentTemplateId, accountId));
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/actions/{id}")
|
||||
public Response getAction(@Context HttpHeaders headers, @PathParam("id") String id) {
|
||||
return ok(service.getAction(region(headers), id));
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/experiments/{id}")
|
||||
public Response getExperiment(@Context HttpHeaders headers, @PathParam("id") String id) {
|
||||
return ok(service.getExperiment(region(headers), id));
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/experiments/{experimentId}/targetAccountConfigurations/{accountId}")
|
||||
public Response getExperimentTargetAccountConfiguration(
|
||||
@Context HttpHeaders headers,
|
||||
@PathParam("experimentId") String experimentId,
|
||||
@PathParam("accountId") String accountId) {
|
||||
return ok(service.getExperimentTargetAccountConfiguration(region(headers), experimentId, accountId));
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/experimentTemplates/{id}")
|
||||
public Response getExperimentTemplate(
|
||||
@Context HttpHeaders headers, @PathParam("id") String id) {
|
||||
return ok(service.getExperimentTemplate(region(headers), id));
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/safetyLevers/{id}")
|
||||
public Response getSafetyLever(@Context HttpHeaders headers, @PathParam("id") String id) {
|
||||
return ok(service.getSafetyLever(region(headers), id));
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/experimentTemplates/{experimentTemplateId}/targetAccountConfigurations/{accountId}")
|
||||
public Response getTargetAccountConfiguration(
|
||||
@Context HttpHeaders headers,
|
||||
@PathParam("experimentTemplateId") String experimentTemplateId,
|
||||
@PathParam("accountId") String accountId) {
|
||||
return ok(service.getTargetAccountConfiguration(region(headers), experimentTemplateId, accountId));
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/targetResourceTypes/{resourceType}")
|
||||
public Response getTargetResourceType(
|
||||
@Context HttpHeaders headers, @PathParam("resourceType") String resourceType) {
|
||||
return ok(service.getTargetResourceType(region(headers), resourceType));
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/actions")
|
||||
public Response listActions(
|
||||
@Context HttpHeaders headers,
|
||||
@QueryParam("maxResults") String maxResults,
|
||||
@QueryParam("nextToken") String nextToken) {
|
||||
return ok(service.listActions(region(headers), parseMaxResults(maxResults), nextToken));
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/experiments/{experimentId}/resolvedTargets")
|
||||
public Response listExperimentResolvedTargets(
|
||||
@Context HttpHeaders headers,
|
||||
@PathParam("experimentId") String experimentId,
|
||||
@QueryParam("maxResults") String maxResults,
|
||||
@QueryParam("nextToken") String nextToken,
|
||||
@QueryParam("targetName") String targetName) {
|
||||
return ok(service.listExperimentResolvedTargets(
|
||||
region(headers), experimentId, parseMaxResults(maxResults), nextToken, targetName));
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/experiments/{experimentId}/targetAccountConfigurations")
|
||||
public Response listExperimentTargetAccountConfigurations(
|
||||
@Context HttpHeaders headers,
|
||||
@PathParam("experimentId") String experimentId,
|
||||
@QueryParam("nextToken") String nextToken) {
|
||||
return ok(service.listExperimentTargetAccountConfigurations(region(headers), experimentId, nextToken));
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/experimentTemplates")
|
||||
public Response listExperimentTemplates(
|
||||
@Context HttpHeaders headers,
|
||||
@QueryParam("maxResults") String maxResults,
|
||||
@QueryParam("nextToken") String nextToken) {
|
||||
return ok(service.listExperimentTemplates(region(headers), parseMaxResults(maxResults), nextToken));
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/experiments")
|
||||
public Response listExperiments(
|
||||
@Context HttpHeaders headers,
|
||||
@QueryParam("experimentTemplateId") String experimentTemplateId,
|
||||
@QueryParam("maxResults") String maxResults,
|
||||
@QueryParam("nextToken") String nextToken) {
|
||||
return ok(service.listExperiments(
|
||||
region(headers), parseMaxResults(maxResults), nextToken, experimentTemplateId));
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/experimentTemplates/{experimentTemplateId}/targetAccountConfigurations")
|
||||
public Response listTargetAccountConfigurations(
|
||||
@Context HttpHeaders headers,
|
||||
@PathParam("experimentTemplateId") String experimentTemplateId,
|
||||
@QueryParam("maxResults") String maxResults,
|
||||
@QueryParam("nextToken") String nextToken) {
|
||||
return ok(service.listTargetAccountConfigurations(
|
||||
region(headers), experimentTemplateId, parseMaxResults(maxResults), nextToken));
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/targetResourceTypes")
|
||||
public Response listTargetResourceTypes(
|
||||
@Context HttpHeaders headers,
|
||||
@QueryParam("maxResults") String maxResults,
|
||||
@QueryParam("nextToken") String nextToken) {
|
||||
return ok(service.listTargetResourceTypes(region(headers), parseMaxResults(maxResults), nextToken));
|
||||
}
|
||||
|
||||
@POST
|
||||
@Path("/experiments")
|
||||
public Response startExperiment(@Context HttpHeaders headers, String body) {
|
||||
return ok(service.startExperiment(region(headers), parse(body)));
|
||||
}
|
||||
|
||||
@DELETE
|
||||
@Path("/experiments/{id}")
|
||||
public Response stopExperiment(@Context HttpHeaders headers, @PathParam("id") String id) {
|
||||
return ok(service.stopExperiment(region(headers), id));
|
||||
}
|
||||
|
||||
@PATCH
|
||||
@Path("/experimentTemplates/{id}")
|
||||
public Response updateExperimentTemplate(
|
||||
@Context HttpHeaders headers, @PathParam("id") String id, String body) {
|
||||
return ok(service.updateExperimentTemplate(region(headers), id, parse(body)));
|
||||
}
|
||||
|
||||
@PATCH
|
||||
@Path("/safetyLevers/{id}/state")
|
||||
public Response updateSafetyLeverState(
|
||||
@Context HttpHeaders headers, @PathParam("id") String id, String body) {
|
||||
return ok(service.updateSafetyLeverState(region(headers), id, parse(body)));
|
||||
}
|
||||
|
||||
@PATCH
|
||||
@Path("/experimentTemplates/{experimentTemplateId}/targetAccountConfigurations/{accountId}")
|
||||
public Response updateTargetAccountConfiguration(
|
||||
@Context HttpHeaders headers,
|
||||
@PathParam("experimentTemplateId") String experimentTemplateId,
|
||||
@PathParam("accountId") String accountId,
|
||||
String body) {
|
||||
return ok(service.updateTargetAccountConfiguration(
|
||||
region(headers), experimentTemplateId, accountId, parse(body)));
|
||||
}
|
||||
|
||||
private JsonNode parse(String body) {
|
||||
if (body == null || body.isBlank()) {
|
||||
return objectMapper.createObjectNode();
|
||||
}
|
||||
try {
|
||||
JsonNode request = requestReader.readTree(body);
|
||||
if (request == null || !request.isObject()) {
|
||||
throw validation("Request body must be a JSON object.");
|
||||
}
|
||||
return request;
|
||||
} catch (AwsException e) {
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
throw validation("Request body is not valid JSON.");
|
||||
}
|
||||
}
|
||||
|
||||
private Integer parseMaxResults(String value) {
|
||||
if (value == null || value.isBlank()) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
return Integer.valueOf(value);
|
||||
} catch (NumberFormatException e) {
|
||||
throw validation("maxResults must be an integer between 1 and 100.");
|
||||
}
|
||||
}
|
||||
|
||||
private String region(HttpHeaders headers) {
|
||||
return regionResolver.resolveRegion(headers);
|
||||
}
|
||||
|
||||
private Response ok(JsonNode entity) {
|
||||
return Response.ok(entity).build();
|
||||
}
|
||||
|
||||
private AwsException validation(String message) {
|
||||
return new AwsException("ValidationException", message, 400);
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,70 @@
|
||||
package io.github.hectorvent.floci.services.fis;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import io.github.hectorvent.floci.core.storage.InMemoryStorage;
|
||||
import io.github.hectorvent.floci.core.storage.StorageBackend;
|
||||
import io.github.hectorvent.floci.core.storage.StorageFactory;
|
||||
import io.github.hectorvent.floci.services.fis.model.Experiment;
|
||||
import io.github.hectorvent.floci.services.fis.model.ExperimentTemplate;
|
||||
import io.github.hectorvent.floci.services.fis.model.IdempotencyRecord;
|
||||
import io.github.hectorvent.floci.services.fis.model.ResolvedTarget;
|
||||
import io.github.hectorvent.floci.services.fis.model.SafetyLever;
|
||||
import io.github.hectorvent.floci.services.fis.model.TargetAccountConfiguration;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
final class FisStores {
|
||||
final StorageBackend<String, ExperimentTemplate> templates;
|
||||
final StorageBackend<String, Experiment> experiments;
|
||||
final StorageBackend<String, TargetAccountConfiguration> targetAccounts;
|
||||
final StorageBackend<String, ResolvedTarget> resolvedTargets;
|
||||
final StorageBackend<String, SafetyLever> safetyLevers;
|
||||
final StorageBackend<String, Map<String, String>> actionTags;
|
||||
final StorageBackend<String, IdempotencyRecord> idempotency;
|
||||
|
||||
FisStores(StorageFactory storageFactory) {
|
||||
this(
|
||||
storageFactory.create("fis", "fis-experiment-templates.json",
|
||||
new TypeReference<Map<String, ExperimentTemplate>>() {}),
|
||||
storageFactory.create("fis", "fis-experiments.json",
|
||||
new TypeReference<Map<String, Experiment>>() {}),
|
||||
storageFactory.create("fis", "fis-target-account-configurations.json",
|
||||
new TypeReference<Map<String, TargetAccountConfiguration>>() {}),
|
||||
storageFactory.create("fis", "fis-resolved-targets.json",
|
||||
new TypeReference<Map<String, ResolvedTarget>>() {}),
|
||||
storageFactory.create("fis", "fis-safety-levers.json",
|
||||
new TypeReference<Map<String, SafetyLever>>() {}),
|
||||
storageFactory.create("fis", "fis-action-tags.json",
|
||||
new TypeReference<Map<String, Map<String, String>>>() {}),
|
||||
storageFactory.create("fis", "fis-idempotency.json",
|
||||
new TypeReference<Map<String, IdempotencyRecord>>() {}));
|
||||
}
|
||||
|
||||
FisStores(
|
||||
StorageBackend<String, ExperimentTemplate> templates,
|
||||
StorageBackend<String, Experiment> experiments,
|
||||
StorageBackend<String, TargetAccountConfiguration> targetAccounts,
|
||||
StorageBackend<String, ResolvedTarget> resolvedTargets,
|
||||
StorageBackend<String, SafetyLever> safetyLevers,
|
||||
StorageBackend<String, Map<String, String>> actionTags,
|
||||
StorageBackend<String, IdempotencyRecord> idempotency) {
|
||||
this.templates = templates;
|
||||
this.experiments = experiments;
|
||||
this.targetAccounts = targetAccounts;
|
||||
this.resolvedTargets = resolvedTargets;
|
||||
this.safetyLevers = safetyLevers;
|
||||
this.actionTags = actionTags;
|
||||
this.idempotency = idempotency;
|
||||
}
|
||||
|
||||
static FisStores inMemory() {
|
||||
return new FisStores(
|
||||
new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>(),
|
||||
new InMemoryStorage<>());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
package io.github.hectorvent.floci.services.fis.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class Experiment {
|
||||
private String id;
|
||||
private String arn;
|
||||
private String experimentTemplateId;
|
||||
private String roleArn;
|
||||
private ExperimentState state;
|
||||
private Map<String, ExperimentTarget> targets;
|
||||
private Map<String, ExperimentAction> actions;
|
||||
private List<StopCondition> stopConditions;
|
||||
private double creationTime;
|
||||
private Double startTime;
|
||||
private Double endTime;
|
||||
private Map<String, String> tags;
|
||||
private JsonNode logConfiguration;
|
||||
private ExperimentOptions experimentOptions;
|
||||
private long targetAccountConfigurationsCount;
|
||||
private JsonNode experimentReportConfiguration;
|
||||
private JsonNode experimentReport;
|
||||
|
||||
public Experiment() {
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getArn() {
|
||||
return arn;
|
||||
}
|
||||
|
||||
public void setArn(String arn) {
|
||||
this.arn = arn;
|
||||
}
|
||||
|
||||
public String getExperimentTemplateId() {
|
||||
return experimentTemplateId;
|
||||
}
|
||||
|
||||
public void setExperimentTemplateId(String experimentTemplateId) {
|
||||
this.experimentTemplateId = experimentTemplateId;
|
||||
}
|
||||
|
||||
public String getRoleArn() {
|
||||
return roleArn;
|
||||
}
|
||||
|
||||
public void setRoleArn(String roleArn) {
|
||||
this.roleArn = roleArn;
|
||||
}
|
||||
|
||||
public ExperimentState getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(ExperimentState state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public Map<String, ExperimentTarget> getTargets() {
|
||||
return targets;
|
||||
}
|
||||
|
||||
public void setTargets(Map<String, ExperimentTarget> targets) {
|
||||
this.targets = targets;
|
||||
}
|
||||
|
||||
public Map<String, ExperimentAction> getActions() {
|
||||
return actions;
|
||||
}
|
||||
|
||||
public void setActions(Map<String, ExperimentAction> actions) {
|
||||
this.actions = actions;
|
||||
}
|
||||
|
||||
public List<StopCondition> getStopConditions() {
|
||||
return stopConditions;
|
||||
}
|
||||
|
||||
public void setStopConditions(List<StopCondition> stopConditions) {
|
||||
this.stopConditions = stopConditions;
|
||||
}
|
||||
|
||||
public double getCreationTime() {
|
||||
return creationTime;
|
||||
}
|
||||
|
||||
public void setCreationTime(double creationTime) {
|
||||
this.creationTime = creationTime;
|
||||
}
|
||||
|
||||
public Double getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(Double startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public Double getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(Double endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
|
||||
public Map<String, String> getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public void setTags(Map<String, String> tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
public JsonNode getLogConfiguration() {
|
||||
return logConfiguration;
|
||||
}
|
||||
|
||||
public void setLogConfiguration(JsonNode logConfiguration) {
|
||||
this.logConfiguration = logConfiguration;
|
||||
}
|
||||
|
||||
public ExperimentOptions getExperimentOptions() {
|
||||
return experimentOptions;
|
||||
}
|
||||
|
||||
public void setExperimentOptions(ExperimentOptions experimentOptions) {
|
||||
this.experimentOptions = experimentOptions;
|
||||
}
|
||||
|
||||
public long getTargetAccountConfigurationsCount() {
|
||||
return targetAccountConfigurationsCount;
|
||||
}
|
||||
|
||||
public void setTargetAccountConfigurationsCount(long targetAccountConfigurationsCount) {
|
||||
this.targetAccountConfigurationsCount = targetAccountConfigurationsCount;
|
||||
}
|
||||
|
||||
public JsonNode getExperimentReportConfiguration() {
|
||||
return experimentReportConfiguration;
|
||||
}
|
||||
|
||||
public void setExperimentReportConfiguration(JsonNode experimentReportConfiguration) {
|
||||
this.experimentReportConfiguration = experimentReportConfiguration;
|
||||
}
|
||||
|
||||
public JsonNode getExperimentReport() {
|
||||
return experimentReport;
|
||||
}
|
||||
|
||||
public void setExperimentReport(JsonNode experimentReport) {
|
||||
this.experimentReport = experimentReport;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
package io.github.hectorvent.floci.services.fis.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class ExperimentAction {
|
||||
private String actionId;
|
||||
private String description;
|
||||
private Map<String, String> parameters;
|
||||
private Map<String, String> targets;
|
||||
private List<String> startAfter;
|
||||
private ExperimentActionState state;
|
||||
private Double startTime;
|
||||
private Double endTime;
|
||||
|
||||
public ExperimentAction() {
|
||||
}
|
||||
|
||||
public String getActionId() {
|
||||
return actionId;
|
||||
}
|
||||
|
||||
public void setActionId(String actionId) {
|
||||
this.actionId = actionId;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Map<String, String> getParameters() {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
public void setParameters(Map<String, String> parameters) {
|
||||
this.parameters = parameters;
|
||||
}
|
||||
|
||||
public Map<String, String> getTargets() {
|
||||
return targets;
|
||||
}
|
||||
|
||||
public void setTargets(Map<String, String> targets) {
|
||||
this.targets = targets;
|
||||
}
|
||||
|
||||
public List<String> getStartAfter() {
|
||||
return startAfter;
|
||||
}
|
||||
|
||||
public void setStartAfter(List<String> startAfter) {
|
||||
this.startAfter = startAfter;
|
||||
}
|
||||
|
||||
public ExperimentActionState getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(ExperimentActionState state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public Double getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public void setStartTime(Double startTime) {
|
||||
this.startTime = startTime;
|
||||
}
|
||||
|
||||
public Double getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
public void setEndTime(Double endTime) {
|
||||
this.endTime = endTime;
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package io.github.hectorvent.floci.services.fis.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class ExperimentActionState {
|
||||
private String status;
|
||||
private String reason;
|
||||
|
||||
public ExperimentActionState() {
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getReason() {
|
||||
return reason;
|
||||
}
|
||||
|
||||
public void setReason(String reason) {
|
||||
this.reason = reason;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package io.github.hectorvent.floci.services.fis.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class ExperimentOptions {
|
||||
private String accountTargeting;
|
||||
private String emptyTargetResolutionMode;
|
||||
private String actionsMode;
|
||||
|
||||
public ExperimentOptions() {
|
||||
}
|
||||
|
||||
public String getAccountTargeting() {
|
||||
return accountTargeting;
|
||||
}
|
||||
|
||||
public void setAccountTargeting(String accountTargeting) {
|
||||
this.accountTargeting = accountTargeting;
|
||||
}
|
||||
|
||||
public String getEmptyTargetResolutionMode() {
|
||||
return emptyTargetResolutionMode;
|
||||
}
|
||||
|
||||
public void setEmptyTargetResolutionMode(String emptyTargetResolutionMode) {
|
||||
this.emptyTargetResolutionMode = emptyTargetResolutionMode;
|
||||
}
|
||||
|
||||
public String getActionsMode() {
|
||||
return actionsMode;
|
||||
}
|
||||
|
||||
public void setActionsMode(String actionsMode) {
|
||||
this.actionsMode = actionsMode;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package io.github.hectorvent.floci.services.fis.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class ExperimentState {
|
||||
private String status;
|
||||
private String reason;
|
||||
private JsonNode error;
|
||||
|
||||
public ExperimentState() {
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getReason() {
|
||||
return reason;
|
||||
}
|
||||
|
||||
public void setReason(String reason) {
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
public JsonNode getError() {
|
||||
return error;
|
||||
}
|
||||
|
||||
public void setError(JsonNode error) {
|
||||
this.error = error;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package io.github.hectorvent.floci.services.fis.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class ExperimentTarget {
|
||||
private String resourceType;
|
||||
private List<String> resourceArns;
|
||||
private Map<String, String> resourceTags;
|
||||
private List<TargetFilter> filters;
|
||||
private String selectionMode;
|
||||
private Map<String, String> parameters;
|
||||
|
||||
public ExperimentTarget() {
|
||||
}
|
||||
|
||||
public String getResourceType() {
|
||||
return resourceType;
|
||||
}
|
||||
|
||||
public void setResourceType(String resourceType) {
|
||||
this.resourceType = resourceType;
|
||||
}
|
||||
|
||||
public List<String> getResourceArns() {
|
||||
return resourceArns;
|
||||
}
|
||||
|
||||
public void setResourceArns(List<String> resourceArns) {
|
||||
this.resourceArns = resourceArns;
|
||||
}
|
||||
|
||||
public Map<String, String> getResourceTags() {
|
||||
return resourceTags;
|
||||
}
|
||||
|
||||
public void setResourceTags(Map<String, String> resourceTags) {
|
||||
this.resourceTags = resourceTags;
|
||||
}
|
||||
|
||||
public List<TargetFilter> getFilters() {
|
||||
return filters;
|
||||
}
|
||||
|
||||
public void setFilters(List<TargetFilter> filters) {
|
||||
this.filters = filters;
|
||||
}
|
||||
|
||||
public String getSelectionMode() {
|
||||
return selectionMode;
|
||||
}
|
||||
|
||||
public void setSelectionMode(String selectionMode) {
|
||||
this.selectionMode = selectionMode;
|
||||
}
|
||||
|
||||
public Map<String, String> getParameters() {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
public void setParameters(Map<String, String> parameters) {
|
||||
this.parameters = parameters;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
package io.github.hectorvent.floci.services.fis.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.databind.JsonNode;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class ExperimentTemplate {
|
||||
private String id;
|
||||
private String arn;
|
||||
private String description;
|
||||
private Map<String, ExperimentTemplateTarget> targets;
|
||||
private Map<String, ExperimentTemplateAction> actions;
|
||||
private List<StopCondition> stopConditions;
|
||||
private double creationTime;
|
||||
private double lastUpdateTime;
|
||||
private String roleArn;
|
||||
private Map<String, String> tags;
|
||||
private JsonNode logConfiguration;
|
||||
private ExperimentTemplateOptions experimentOptions;
|
||||
private long targetAccountConfigurationsCount;
|
||||
private JsonNode experimentReportConfiguration;
|
||||
|
||||
public ExperimentTemplate() {
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getArn() {
|
||||
return arn;
|
||||
}
|
||||
|
||||
public void setArn(String arn) {
|
||||
this.arn = arn;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Map<String, ExperimentTemplateTarget> getTargets() {
|
||||
return targets;
|
||||
}
|
||||
|
||||
public void setTargets(Map<String, ExperimentTemplateTarget> targets) {
|
||||
this.targets = targets;
|
||||
}
|
||||
|
||||
public Map<String, ExperimentTemplateAction> getActions() {
|
||||
return actions;
|
||||
}
|
||||
|
||||
public void setActions(Map<String, ExperimentTemplateAction> actions) {
|
||||
this.actions = actions;
|
||||
}
|
||||
|
||||
public List<StopCondition> getStopConditions() {
|
||||
return stopConditions;
|
||||
}
|
||||
|
||||
public void setStopConditions(List<StopCondition> stopConditions) {
|
||||
this.stopConditions = stopConditions;
|
||||
}
|
||||
|
||||
public double getCreationTime() {
|
||||
return creationTime;
|
||||
}
|
||||
|
||||
public void setCreationTime(double creationTime) {
|
||||
this.creationTime = creationTime;
|
||||
}
|
||||
|
||||
public double getLastUpdateTime() {
|
||||
return lastUpdateTime;
|
||||
}
|
||||
|
||||
public void setLastUpdateTime(double lastUpdateTime) {
|
||||
this.lastUpdateTime = lastUpdateTime;
|
||||
}
|
||||
|
||||
public String getRoleArn() {
|
||||
return roleArn;
|
||||
}
|
||||
|
||||
public void setRoleArn(String roleArn) {
|
||||
this.roleArn = roleArn;
|
||||
}
|
||||
|
||||
public Map<String, String> getTags() {
|
||||
return tags;
|
||||
}
|
||||
|
||||
public void setTags(Map<String, String> tags) {
|
||||
this.tags = tags;
|
||||
}
|
||||
|
||||
public JsonNode getLogConfiguration() {
|
||||
return logConfiguration;
|
||||
}
|
||||
|
||||
public void setLogConfiguration(JsonNode logConfiguration) {
|
||||
this.logConfiguration = logConfiguration;
|
||||
}
|
||||
|
||||
public ExperimentTemplateOptions getExperimentOptions() {
|
||||
return experimentOptions;
|
||||
}
|
||||
|
||||
public void setExperimentOptions(ExperimentTemplateOptions experimentOptions) {
|
||||
this.experimentOptions = experimentOptions;
|
||||
}
|
||||
|
||||
public long getTargetAccountConfigurationsCount() {
|
||||
return targetAccountConfigurationsCount;
|
||||
}
|
||||
|
||||
public void setTargetAccountConfigurationsCount(long targetAccountConfigurationsCount) {
|
||||
this.targetAccountConfigurationsCount = targetAccountConfigurationsCount;
|
||||
}
|
||||
|
||||
public JsonNode getExperimentReportConfiguration() {
|
||||
return experimentReportConfiguration;
|
||||
}
|
||||
|
||||
public void setExperimentReportConfiguration(JsonNode experimentReportConfiguration) {
|
||||
this.experimentReportConfiguration = experimentReportConfiguration;
|
||||
}
|
||||
}
|
||||
+60
@@ -0,0 +1,60 @@
|
||||
package io.github.hectorvent.floci.services.fis.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class ExperimentTemplateAction {
|
||||
private String actionId;
|
||||
private String description;
|
||||
private Map<String, String> parameters;
|
||||
private Map<String, String> targets;
|
||||
private List<String> startAfter;
|
||||
|
||||
public ExperimentTemplateAction() {
|
||||
}
|
||||
|
||||
public String getActionId() {
|
||||
return actionId;
|
||||
}
|
||||
|
||||
public void setActionId(String actionId) {
|
||||
this.actionId = actionId;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public Map<String, String> getParameters() {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
public void setParameters(Map<String, String> parameters) {
|
||||
this.parameters = parameters;
|
||||
}
|
||||
|
||||
public Map<String, String> getTargets() {
|
||||
return targets;
|
||||
}
|
||||
|
||||
public void setTargets(Map<String, String> targets) {
|
||||
this.targets = targets;
|
||||
}
|
||||
|
||||
public List<String> getStartAfter() {
|
||||
return startAfter;
|
||||
}
|
||||
|
||||
public void setStartAfter(List<String> startAfter) {
|
||||
this.startAfter = startAfter;
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package io.github.hectorvent.floci.services.fis.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class ExperimentTemplateOptions {
|
||||
private String accountTargeting;
|
||||
private String emptyTargetResolutionMode;
|
||||
|
||||
public ExperimentTemplateOptions() {
|
||||
}
|
||||
|
||||
public String getAccountTargeting() {
|
||||
return accountTargeting;
|
||||
}
|
||||
|
||||
public void setAccountTargeting(String accountTargeting) {
|
||||
this.accountTargeting = accountTargeting;
|
||||
}
|
||||
|
||||
public String getEmptyTargetResolutionMode() {
|
||||
return emptyTargetResolutionMode;
|
||||
}
|
||||
|
||||
public void setEmptyTargetResolutionMode(String emptyTargetResolutionMode) {
|
||||
this.emptyTargetResolutionMode = emptyTargetResolutionMode;
|
||||
}
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
package io.github.hectorvent.floci.services.fis.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class ExperimentTemplateTarget {
|
||||
private String resourceType;
|
||||
private List<String> resourceArns;
|
||||
private Map<String, String> resourceTags;
|
||||
private List<TargetFilter> filters;
|
||||
private String selectionMode;
|
||||
private Map<String, String> parameters;
|
||||
|
||||
public ExperimentTemplateTarget() {
|
||||
}
|
||||
|
||||
public String getResourceType() {
|
||||
return resourceType;
|
||||
}
|
||||
|
||||
public void setResourceType(String resourceType) {
|
||||
this.resourceType = resourceType;
|
||||
}
|
||||
|
||||
public List<String> getResourceArns() {
|
||||
return resourceArns;
|
||||
}
|
||||
|
||||
public void setResourceArns(List<String> resourceArns) {
|
||||
this.resourceArns = resourceArns;
|
||||
}
|
||||
|
||||
public Map<String, String> getResourceTags() {
|
||||
return resourceTags;
|
||||
}
|
||||
|
||||
public void setResourceTags(Map<String, String> resourceTags) {
|
||||
this.resourceTags = resourceTags;
|
||||
}
|
||||
|
||||
public List<TargetFilter> getFilters() {
|
||||
return filters;
|
||||
}
|
||||
|
||||
public void setFilters(List<TargetFilter> filters) {
|
||||
this.filters = filters;
|
||||
}
|
||||
|
||||
public String getSelectionMode() {
|
||||
return selectionMode;
|
||||
}
|
||||
|
||||
public void setSelectionMode(String selectionMode) {
|
||||
this.selectionMode = selectionMode;
|
||||
}
|
||||
|
||||
public Map<String, String> getParameters() {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
public void setParameters(Map<String, String> parameters) {
|
||||
this.parameters = parameters;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package io.github.hectorvent.floci.services.fis.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class IdempotencyRecord {
|
||||
private ObjectNode request;
|
||||
private ObjectNode response;
|
||||
|
||||
public IdempotencyRecord() {
|
||||
}
|
||||
|
||||
public IdempotencyRecord(ObjectNode request, ObjectNode response) {
|
||||
this.request = request;
|
||||
this.response = response;
|
||||
}
|
||||
|
||||
public ObjectNode getRequest() {
|
||||
return request;
|
||||
}
|
||||
|
||||
public void setRequest(ObjectNode request) {
|
||||
this.request = request;
|
||||
}
|
||||
|
||||
public ObjectNode getResponse() {
|
||||
return response;
|
||||
}
|
||||
|
||||
public void setResponse(ObjectNode response) {
|
||||
this.response = response;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package io.github.hectorvent.floci.services.fis.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class ResolvedTarget {
|
||||
private String resourceType;
|
||||
private String targetName;
|
||||
private Map<String, String> targetInformation;
|
||||
|
||||
public ResolvedTarget() {
|
||||
}
|
||||
|
||||
public String getResourceType() {
|
||||
return resourceType;
|
||||
}
|
||||
|
||||
public void setResourceType(String resourceType) {
|
||||
this.resourceType = resourceType;
|
||||
}
|
||||
|
||||
public String getTargetName() {
|
||||
return targetName;
|
||||
}
|
||||
|
||||
public void setTargetName(String targetName) {
|
||||
this.targetName = targetName;
|
||||
}
|
||||
|
||||
public Map<String, String> getTargetInformation() {
|
||||
return targetInformation;
|
||||
}
|
||||
|
||||
public void setTargetInformation(Map<String, String> targetInformation) {
|
||||
this.targetInformation = targetInformation;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package io.github.hectorvent.floci.services.fis.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class SafetyLever {
|
||||
private String id;
|
||||
private String arn;
|
||||
private SafetyLeverState state;
|
||||
|
||||
public SafetyLever() {
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getArn() {
|
||||
return arn;
|
||||
}
|
||||
|
||||
public void setArn(String arn) {
|
||||
this.arn = arn;
|
||||
}
|
||||
|
||||
public SafetyLeverState getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
public void setState(SafetyLeverState state) {
|
||||
this.state = state;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package io.github.hectorvent.floci.services.fis.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class SafetyLeverState {
|
||||
private String status;
|
||||
private String reason;
|
||||
|
||||
public SafetyLeverState() {
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getReason() {
|
||||
return reason;
|
||||
}
|
||||
|
||||
public void setReason(String reason) {
|
||||
this.reason = reason;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package io.github.hectorvent.floci.services.fis.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class StopCondition {
|
||||
private String source;
|
||||
private String value;
|
||||
|
||||
public StopCondition() {
|
||||
}
|
||||
|
||||
public String getSource() {
|
||||
return source;
|
||||
}
|
||||
|
||||
public void setSource(String source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
public String getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
package io.github.hectorvent.floci.services.fis.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class TargetAccountConfiguration {
|
||||
private String roleArn;
|
||||
private String accountId;
|
||||
private String description;
|
||||
|
||||
public TargetAccountConfiguration() {
|
||||
}
|
||||
|
||||
public String getRoleArn() {
|
||||
return roleArn;
|
||||
}
|
||||
|
||||
public void setRoleArn(String roleArn) {
|
||||
this.roleArn = roleArn;
|
||||
}
|
||||
|
||||
public String getAccountId() {
|
||||
return accountId;
|
||||
}
|
||||
|
||||
public void setAccountId(String accountId) {
|
||||
this.accountId = accountId;
|
||||
}
|
||||
|
||||
public String getDescription() {
|
||||
return description;
|
||||
}
|
||||
|
||||
public void setDescription(String description) {
|
||||
this.description = description;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package io.github.hectorvent.floci.services.fis.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import io.quarkus.runtime.annotations.RegisterForReflection;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@RegisterForReflection
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
public class TargetFilter {
|
||||
private String path;
|
||||
private List<String> values;
|
||||
|
||||
public TargetFilter() {
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return path;
|
||||
}
|
||||
|
||||
public void setPath(String path) {
|
||||
this.path = path;
|
||||
}
|
||||
|
||||
public List<String> getValues() {
|
||||
return values;
|
||||
}
|
||||
|
||||
public void setValues(List<String> values) {
|
||||
this.values = values;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user