mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
refactor(core): centralize millisecond epoch seconds (#7150)
This commit is contained in:
1 parent
0f94440442
commit
08d45041d5
41 files changed
+217
-136
No files matched your search
@@ -0,0 +1,14 @@
|
||||
package io.github.hectorvent.floci.core.common;
|
||||
|
||||
import java.time.Instant;
|
||||
|
||||
/** Converts an Instant to millisecond-precision epoch seconds for AWS JSON timestamps. */
|
||||
public final class EpochSeconds {
|
||||
|
||||
private EpochSeconds() {
|
||||
}
|
||||
|
||||
public static double fromInstant(Instant instant) {
|
||||
return instant.toEpochMilli() / 1000.0;
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.github.hectorvent.floci.core.common.AwsErrorResponse;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.EpochSeconds;
|
||||
import io.github.hectorvent.floci.core.common.SmithyValidationErrors;
|
||||
import io.github.hectorvent.floci.services.acm.model.Certificate;
|
||||
import io.github.hectorvent.floci.services.acm.model.CertificateOptions;
|
||||
@@ -385,19 +386,19 @@ public class AcmJsonHandler {
|
||||
}
|
||||
|
||||
if (cert.getCreatedAt() != null) {
|
||||
node.put("CreatedAt", cert.getCreatedAt().toEpochMilli() / 1000.0);
|
||||
node.put("CreatedAt", EpochSeconds.fromInstant(cert.getCreatedAt()));
|
||||
}
|
||||
if (cert.getIssuedAt() != null) {
|
||||
node.put("IssuedAt", cert.getIssuedAt().toEpochMilli() / 1000.0);
|
||||
node.put("IssuedAt", EpochSeconds.fromInstant(cert.getIssuedAt()));
|
||||
}
|
||||
if (cert.getImportedAt() != null) {
|
||||
node.put("ImportedAt", cert.getImportedAt().toEpochMilli() / 1000.0);
|
||||
node.put("ImportedAt", EpochSeconds.fromInstant(cert.getImportedAt()));
|
||||
}
|
||||
if (cert.getNotBefore() != null) {
|
||||
node.put("NotBefore", cert.getNotBefore().toEpochMilli() / 1000.0);
|
||||
node.put("NotBefore", EpochSeconds.fromInstant(cert.getNotBefore()));
|
||||
}
|
||||
if (cert.getNotAfter() != null) {
|
||||
node.put("NotAfter", cert.getNotAfter().toEpochMilli() / 1000.0);
|
||||
node.put("NotAfter", EpochSeconds.fromInstant(cert.getNotAfter()));
|
||||
}
|
||||
|
||||
ArrayNode inUseBy = objectMapper.createArrayNode();
|
||||
@@ -492,19 +493,19 @@ public class AcmJsonHandler {
|
||||
node.set("ExtendedKeyUsages", extKeyUsages);
|
||||
|
||||
if (cert.getCreatedAt() != null) {
|
||||
node.put("CreatedAt", cert.getCreatedAt().toEpochMilli() / 1000.0);
|
||||
node.put("CreatedAt", EpochSeconds.fromInstant(cert.getCreatedAt()));
|
||||
}
|
||||
if (cert.getIssuedAt() != null) {
|
||||
node.put("IssuedAt", cert.getIssuedAt().toEpochMilli() / 1000.0);
|
||||
node.put("IssuedAt", EpochSeconds.fromInstant(cert.getIssuedAt()));
|
||||
}
|
||||
if (cert.getImportedAt() != null) {
|
||||
node.put("ImportedAt", cert.getImportedAt().toEpochMilli() / 1000.0);
|
||||
node.put("ImportedAt", EpochSeconds.fromInstant(cert.getImportedAt()));
|
||||
}
|
||||
if (cert.getNotBefore() != null) {
|
||||
node.put("NotBefore", cert.getNotBefore().toEpochMilli() / 1000.0);
|
||||
node.put("NotBefore", EpochSeconds.fromInstant(cert.getNotBefore()));
|
||||
}
|
||||
if (cert.getNotAfter() != null) {
|
||||
node.put("NotAfter", cert.getNotAfter().toEpochMilli() / 1000.0);
|
||||
node.put("NotAfter", EpochSeconds.fromInstant(cert.getNotAfter()));
|
||||
}
|
||||
|
||||
node.put("RenewalEligibility", "INELIGIBLE");
|
||||
|
||||
@@ -3,6 +3,7 @@ package io.github.hectorvent.floci.services.aps;
|
||||
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.EpochSeconds;
|
||||
import io.github.hectorvent.floci.core.common.PaginatedResult;
|
||||
import io.github.hectorvent.floci.core.common.Pagination;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
@@ -208,8 +209,8 @@ public class ApsController {
|
||||
node.put("name", namespace.getName());
|
||||
node.set("status", namespaceStatusNode(namespace));
|
||||
node.set("tags", objectMapper.valueToTree(namespace.getTags()));
|
||||
node.put("createdAt", namespace.getCreatedAt().toEpochMilli() / 1000.0);
|
||||
node.put("modifiedAt", namespace.getModifiedAt().toEpochMilli() / 1000.0);
|
||||
node.put("createdAt", EpochSeconds.fromInstant(namespace.getCreatedAt()));
|
||||
node.put("modifiedAt", EpochSeconds.fromInstant(namespace.getModifiedAt()));
|
||||
return node;
|
||||
}
|
||||
|
||||
@@ -237,7 +238,7 @@ public class ApsController {
|
||||
node.set("status", statusNode(workspace));
|
||||
// Smithy restJson1 timestamps with no timestampFormat trait are epoch-seconds; an ISO
|
||||
// string here fails deserialization inside the AWS SDKs.
|
||||
node.put("createdAt", workspace.getCreatedAt().toEpochMilli() / 1000.0);
|
||||
node.put("createdAt", EpochSeconds.fromInstant(workspace.getCreatedAt()));
|
||||
node.set("tags", objectMapper.valueToTree(workspace.getTags()));
|
||||
if (workspace.getKmsKeyArn() != null) {
|
||||
node.put("kmsKeyArn", workspace.getKmsKeyArn());
|
||||
|
||||
+6
-5
@@ -7,6 +7,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.github.hectorvent.floci.core.common.AwsArnUtils;
|
||||
import io.github.hectorvent.floci.core.common.AwsErrorResponse;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.EpochSeconds;
|
||||
import io.github.hectorvent.floci.core.common.JsonErrorResponseUtils;
|
||||
import io.github.hectorvent.floci.services.cloudhsmv2.model.Backup;
|
||||
import io.github.hectorvent.floci.services.cloudhsmv2.model.BackupRetentionPolicy;
|
||||
@@ -242,7 +243,7 @@ public class CloudHsmV2JsonHandler {
|
||||
node.put("SecurityGroup", cluster.getSecurityGroup());
|
||||
}
|
||||
if (cluster.getCreateTimestamp() != null) {
|
||||
node.put("CreateTimestamp", cluster.getCreateTimestamp().toEpochMilli() / 1000.0);
|
||||
node.put("CreateTimestamp", EpochSeconds.fromInstant(cluster.getCreateTimestamp()));
|
||||
}
|
||||
if (cluster.getBackupPolicy() != null) {
|
||||
node.put("BackupPolicy", cluster.getBackupPolicy());
|
||||
@@ -431,7 +432,7 @@ public class CloudHsmV2JsonHandler {
|
||||
Backup backup = service.copyBackupToRegion(destRegion, backupId, region);
|
||||
ObjectNode response = objectMapper.createObjectNode();
|
||||
ObjectNode destBackup = objectMapper.createObjectNode();
|
||||
destBackup.put("CreateTimestamp", backup.getCreateTimestamp().toEpochMilli() / 1000.0);
|
||||
destBackup.put("CreateTimestamp", EpochSeconds.fromInstant(backup.getCreateTimestamp()));
|
||||
destBackup.put("SourceBackup", backup.getSourceBackup());
|
||||
destBackup.put("SourceCluster", backup.getSourceCluster());
|
||||
destBackup.put("SourceRegion", backup.getSourceRegion());
|
||||
@@ -479,13 +480,13 @@ public class CloudHsmV2JsonHandler {
|
||||
node.put("HsmType", backup.getHsmType());
|
||||
}
|
||||
if (backup.getCreateTimestamp() != null) {
|
||||
node.put("CreateTimestamp", backup.getCreateTimestamp().toEpochMilli() / 1000.0);
|
||||
node.put("CreateTimestamp", EpochSeconds.fromInstant(backup.getCreateTimestamp()));
|
||||
}
|
||||
if (backup.getDeleteTimestamp() != null) {
|
||||
node.put("DeleteTimestamp", backup.getDeleteTimestamp().toEpochMilli() / 1000.0);
|
||||
node.put("DeleteTimestamp", EpochSeconds.fromInstant(backup.getDeleteTimestamp()));
|
||||
}
|
||||
if (backup.getCopyTimestamp() != null) {
|
||||
node.put("CopyTimestamp", backup.getCopyTimestamp().toEpochMilli() / 1000.0);
|
||||
node.put("CopyTimestamp", EpochSeconds.fromInstant(backup.getCopyTimestamp()));
|
||||
}
|
||||
if (backup.getNeverExpires() != null) {
|
||||
node.put("NeverExpires", "True".equalsIgnoreCase(backup.getNeverExpires()));
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.github.hectorvent.floci.config.EmulatorConfig;
|
||||
import io.github.hectorvent.floci.core.common.AwsArnUtils;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.EpochSeconds;
|
||||
import io.github.hectorvent.floci.core.storage.StorageBackedMap;
|
||||
import io.github.hectorvent.floci.core.storage.StorageFactory;
|
||||
import io.github.hectorvent.floci.services.codebuild.model.Build;
|
||||
@@ -159,7 +160,7 @@ public class CodeBuildService {
|
||||
throw new AwsException("InvalidInputException", "artifacts.type is required", 400);
|
||||
}
|
||||
|
||||
double now = Instant.now().toEpochMilli() / 1000.0;
|
||||
double now = EpochSeconds.fromInstant(Instant.now());
|
||||
Project project = new Project();
|
||||
project.setName(name);
|
||||
project.setArn(AwsArnUtils.Arn.of("codebuild", region, account, "project/" + name).toString());
|
||||
@@ -221,7 +222,7 @@ public class CodeBuildService {
|
||||
if (logsConfig != null) { project.setLogsConfig(logsConfig); }
|
||||
if (vpcConfig != null) { project.setVpcConfig(vpcConfig); }
|
||||
if (concurrentBuildLimit != null) { project.setConcurrentBuildLimit(concurrentBuildLimit); }
|
||||
project.setLastModified(Instant.now().toEpochMilli() / 1000.0);
|
||||
project.setLastModified(EpochSeconds.fromInstant(Instant.now()));
|
||||
|
||||
persistRegion(projects, region);
|
||||
return project;
|
||||
@@ -308,7 +309,7 @@ public class CodeBuildService {
|
||||
throw new AwsException("InvalidInputException", "type is required", 400);
|
||||
}
|
||||
|
||||
double now = Instant.now().toEpochMilli() / 1000.0;
|
||||
double now = EpochSeconds.fromInstant(Instant.now());
|
||||
ReportGroup rg = new ReportGroup();
|
||||
rg.setArn(arn);
|
||||
rg.setName(name);
|
||||
@@ -334,7 +335,7 @@ public class CodeBuildService {
|
||||
}
|
||||
if (exportConfig != null) { rg.setExportConfig(exportConfig); }
|
||||
if (tags != null) { rg.setTags(tags); }
|
||||
rg.setLastModified(Instant.now().toEpochMilli() / 1000.0);
|
||||
rg.setLastModified(EpochSeconds.fromInstant(Instant.now()));
|
||||
persistRegion(reportGroups, region);
|
||||
return rg;
|
||||
}
|
||||
@@ -579,7 +580,7 @@ public class CodeBuildService {
|
||||
build.setCurrentPhase("SUBMITTED");
|
||||
build.setProjectName(projectName);
|
||||
build.setInitiator("user");
|
||||
build.setStartTime(Instant.now().toEpochMilli() / 1000.0);
|
||||
build.setStartTime(EpochSeconds.fromInstant(Instant.now()));
|
||||
build.setSource(project.getSource());
|
||||
build.setArtifacts(artifactsOverride != null ? artifactsOverride : project.getArtifacts());
|
||||
build.setTimeoutInMinutes(timeoutOverride != null ? timeoutOverride : project.getTimeoutInMinutes());
|
||||
|
||||
+28
-27
@@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
|
||||
import io.github.hectorvent.floci.core.common.AwsArnUtils;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.EpochSeconds;
|
||||
import io.github.hectorvent.floci.core.common.PaginatedResult;
|
||||
import io.github.hectorvent.floci.core.common.Pagination;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
@@ -173,7 +174,7 @@ public class CodeDeployService {
|
||||
if (store == null) {
|
||||
continue;
|
||||
}
|
||||
double now = Instant.now().toEpochMilli() / 1000.0;
|
||||
double now = EpochSeconds.fromInstant(Instant.now());
|
||||
boolean changed = false;
|
||||
for (String name : BUILT_IN_CONFIG_NAMES) {
|
||||
if (!store.containsKey(name)) {
|
||||
@@ -263,7 +264,7 @@ public class CodeDeployService {
|
||||
private Map<String, DeploymentConfig> deploymentConfigsFor(String region) {
|
||||
return deploymentConfigs.computeIfAbsent(region, r -> {
|
||||
ConcurrentHashMap<String, DeploymentConfig> store = new ConcurrentHashMap<>();
|
||||
double now = Instant.now().toEpochMilli() / 1000.0;
|
||||
double now = EpochSeconds.fromInstant(Instant.now());
|
||||
for (String name : BUILT_IN_CONFIG_NAMES) {
|
||||
store.put(name, buildBuiltInConfig(name, now));
|
||||
}
|
||||
@@ -338,7 +339,7 @@ public class CodeDeployService {
|
||||
Application app = new Application();
|
||||
app.setApplicationId(UUID.randomUUID().toString());
|
||||
app.setApplicationName(name);
|
||||
app.setCreateTime(Instant.now().toEpochMilli() / 1000.0);
|
||||
app.setCreateTime(EpochSeconds.fromInstant(Instant.now()));
|
||||
app.setLinkedToGitHub(false);
|
||||
app.setComputePlatform(computePlatform != null ? computePlatform : "Server");
|
||||
store.put(name, app);
|
||||
@@ -520,7 +521,7 @@ public class CodeDeployService {
|
||||
cfg.setDeploymentConfigId(UUID.randomUUID().toString());
|
||||
cfg.setDeploymentConfigName(name);
|
||||
cfg.setMinimumHealthyHosts(minimumHealthyHosts);
|
||||
cfg.setCreateTime(Instant.now().toEpochMilli() / 1000.0);
|
||||
cfg.setCreateTime(EpochSeconds.fromInstant(Instant.now()));
|
||||
cfg.setComputePlatform(computePlatform != null ? computePlatform : "Server");
|
||||
cfg.setTrafficRoutingConfig(trafficRoutingConfig);
|
||||
cfg.setZonalConfig(zonalConfig);
|
||||
@@ -590,7 +591,7 @@ public class CodeDeployService {
|
||||
String effectiveConfig = configName != null ? configName : group.getDeploymentConfigName();
|
||||
|
||||
String deploymentId = generateDeploymentId();
|
||||
double now = Instant.now().toEpochMilli() / 1000.0;
|
||||
double now = EpochSeconds.fromInstant(Instant.now());
|
||||
|
||||
Deployment deployment = new Deployment();
|
||||
deployment.setDeploymentId(deploymentId);
|
||||
@@ -723,7 +724,7 @@ public class CodeDeployService {
|
||||
"instance/" + instanceName).toString());
|
||||
inst.setIamSessionArn(iamSessionArn);
|
||||
inst.setIamUserArn(iamUserArn);
|
||||
inst.setRegisterTime(Instant.now().toEpochMilli() / 1000.0);
|
||||
inst.setRegisterTime(EpochSeconds.fromInstant(Instant.now()));
|
||||
inst.setRegistrationStatus("Registered");
|
||||
store.put(instanceName, inst);
|
||||
persistRegion(onPremisesInstances, region);
|
||||
@@ -732,7 +733,7 @@ public class CodeDeployService {
|
||||
|
||||
public void deregisterOnPremisesInstance(String region, String instanceName) {
|
||||
OnPremisesInstance inst = requireOnPremisesInstance(region, instanceName);
|
||||
inst.setDeregisterTime(Instant.now().toEpochMilli() / 1000.0);
|
||||
inst.setDeregisterTime(EpochSeconds.fromInstant(Instant.now()));
|
||||
inst.setRegistrationStatus("Deregistered");
|
||||
persistRegion(onPremisesInstances, region);
|
||||
}
|
||||
@@ -793,7 +794,7 @@ public class CodeDeployService {
|
||||
String effectiveConfig = configName != null ? configName : group.getDeploymentConfigName();
|
||||
|
||||
String deploymentId = generateDeploymentId();
|
||||
double now = Instant.now().toEpochMilli() / 1000.0;
|
||||
double now = EpochSeconds.fromInstant(Instant.now());
|
||||
|
||||
Deployment deployment = new Deployment();
|
||||
deployment.setDeploymentId(deploymentId);
|
||||
@@ -853,7 +854,7 @@ public class CodeDeployService {
|
||||
String deploymentId = deployment.getDeploymentId();
|
||||
try {
|
||||
deployment.setStatus("InProgress");
|
||||
deployment.setStartTime(Instant.now().toEpochMilli() / 1000.0);
|
||||
deployment.setStartTime(EpochSeconds.fromInstant(Instant.now()));
|
||||
instanceTargetMaps.forEach(m -> updateTargetStatus(m, "InProgress"));
|
||||
|
||||
boolean anyFailed = false;
|
||||
@@ -861,7 +862,7 @@ public class CodeDeployService {
|
||||
if (stopFlag.get()) {
|
||||
instanceTargetMaps.forEach(m -> updateTargetStatus(m, "Skipped"));
|
||||
deployment.setStatus("Stopped");
|
||||
deployment.setCompleteTime(Instant.now().toEpochMilli() / 1000.0);
|
||||
deployment.setCompleteTime(EpochSeconds.fromInstant(Instant.now()));
|
||||
return;
|
||||
}
|
||||
String instanceId = instanceIds.get(i);
|
||||
@@ -881,18 +882,18 @@ public class CodeDeployService {
|
||||
} else {
|
||||
deployment.setStatus("Succeeded");
|
||||
}
|
||||
deployment.setCompleteTime(Instant.now().toEpochMilli() / 1000.0);
|
||||
deployment.setCompleteTime(EpochSeconds.fromInstant(Instant.now()));
|
||||
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
instanceTargetMaps.forEach(m -> updateTargetStatus(m, "Skipped"));
|
||||
deployment.setStatus("Stopped");
|
||||
deployment.setCompleteTime(Instant.now().toEpochMilli() / 1000.0);
|
||||
deployment.setCompleteTime(EpochSeconds.fromInstant(Instant.now()));
|
||||
} catch (Exception e) {
|
||||
LOG.warnv("Server deployment {0} failed: {1}", deploymentId, e.getMessage());
|
||||
instanceTargetMaps.forEach(m -> updateTargetStatus(m, "Failed"));
|
||||
deployment.setStatus("Failed");
|
||||
deployment.setCompleteTime(Instant.now().toEpochMilli() / 1000.0);
|
||||
deployment.setCompleteTime(EpochSeconds.fromInstant(Instant.now()));
|
||||
deployment.setErrorInformation(Map.of("code", "DeploymentFailed",
|
||||
"message", e.getMessage() != null ? e.getMessage() : "Unknown error"));
|
||||
} finally {
|
||||
@@ -1238,7 +1239,7 @@ public class CodeDeployService {
|
||||
String effectiveConfig = configName != null ? configName : group.getDeploymentConfigName();
|
||||
|
||||
String deploymentId = generateDeploymentId();
|
||||
double now = Instant.now().toEpochMilli() / 1000.0;
|
||||
double now = EpochSeconds.fromInstant(Instant.now());
|
||||
|
||||
Deployment deployment = new Deployment();
|
||||
deployment.setDeploymentId(deploymentId);
|
||||
@@ -1338,7 +1339,7 @@ public class CodeDeployService {
|
||||
TaskSet blueTaskSet = null;
|
||||
try {
|
||||
deployment.setStatus("InProgress");
|
||||
deployment.setStartTime(Instant.now().toEpochMilli() / 1000.0);
|
||||
deployment.setStartTime(EpochSeconds.fromInstant(Instant.now()));
|
||||
updateEcsTargetStatus(ecsTargetMap, "InProgress");
|
||||
|
||||
if (stopFlag.get()) { finishEcsStopped(deployment, ecsTargetMap); return; }
|
||||
@@ -1455,7 +1456,7 @@ public class CodeDeployService {
|
||||
|
||||
updateEcsTargetStatus(ecsTargetMap, "Succeeded");
|
||||
deployment.setStatus("Succeeded");
|
||||
deployment.setCompleteTime(Instant.now().toEpochMilli() / 1000.0);
|
||||
deployment.setCompleteTime(EpochSeconds.fromInstant(Instant.now()));
|
||||
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
@@ -1546,20 +1547,20 @@ public class CodeDeployService {
|
||||
|
||||
private void updateEcsTargetStatus(Map<String, Object> ecsTargetMap, String status) {
|
||||
ecsTargetMap.put("status", status);
|
||||
ecsTargetMap.put("lastUpdatedAt", Instant.now().toEpochMilli() / 1000.0);
|
||||
ecsTargetMap.put("lastUpdatedAt", EpochSeconds.fromInstant(Instant.now()));
|
||||
}
|
||||
|
||||
private void finishEcsStopped(Deployment deployment, Map<String, Object> ecsTargetMap) {
|
||||
updateEcsTargetStatus(ecsTargetMap, "Skipped");
|
||||
deployment.setStatus("Stopped");
|
||||
deployment.setCompleteTime(Instant.now().toEpochMilli() / 1000.0);
|
||||
deployment.setCompleteTime(EpochSeconds.fromInstant(Instant.now()));
|
||||
}
|
||||
|
||||
private void finishEcsFailed(Deployment deployment, Map<String, Object> ecsTargetMap,
|
||||
String errorCode, String message) {
|
||||
updateEcsTargetStatus(ecsTargetMap, "Failed");
|
||||
deployment.setStatus("Failed");
|
||||
deployment.setCompleteTime(Instant.now().toEpochMilli() / 1000.0);
|
||||
deployment.setCompleteTime(EpochSeconds.fromInstant(Instant.now()));
|
||||
deployment.setErrorInformation(Map.of("code", errorCode, "message", message != null ? message : ""));
|
||||
}
|
||||
|
||||
@@ -1598,7 +1599,7 @@ public class CodeDeployService {
|
||||
String deploymentId = deployment.getDeploymentId();
|
||||
try {
|
||||
deployment.setStatus("InProgress");
|
||||
deployment.setStartTime(Instant.now().toEpochMilli() / 1000.0);
|
||||
deployment.setStartTime(EpochSeconds.fromInstant(Instant.now()));
|
||||
updateTargetStatus(lambdaTargetMap, "InProgress");
|
||||
|
||||
if (stopFlag.get()) { finishStopped(deployment, lambdaTargetMap); return; }
|
||||
@@ -1627,7 +1628,7 @@ public class CodeDeployService {
|
||||
|
||||
updateTargetStatus(lambdaTargetMap, "Succeeded");
|
||||
deployment.setStatus("Succeeded");
|
||||
deployment.setCompleteTime(Instant.now().toEpochMilli() / 1000.0);
|
||||
deployment.setCompleteTime(EpochSeconds.fromInstant(Instant.now()));
|
||||
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
@@ -1773,18 +1774,18 @@ public class CodeDeployService {
|
||||
private Map<String, Object> addLifecycleEvent(Map<String, Object> lambdaTargetMap, String name) {
|
||||
Map<String, Object> event = new ConcurrentHashMap<>();
|
||||
event.put("lifecycleEventName", name);
|
||||
event.put("startTime", Instant.now().toEpochMilli() / 1000.0);
|
||||
event.put("startTime", EpochSeconds.fromInstant(Instant.now()));
|
||||
event.put("status", "InProgress");
|
||||
List<Map<String, Object>> events = (List<Map<String, Object>>) lambdaTargetMap.get("lifecycleEvents");
|
||||
if (events != null) {
|
||||
events.add(event);
|
||||
}
|
||||
lambdaTargetMap.put("lastUpdatedAt", Instant.now().toEpochMilli() / 1000.0);
|
||||
lambdaTargetMap.put("lastUpdatedAt", EpochSeconds.fromInstant(Instant.now()));
|
||||
return event;
|
||||
}
|
||||
|
||||
private void finishLifecycleEvent(Map<String, Object> event, String status) {
|
||||
event.put("endTime", Instant.now().toEpochMilli() / 1000.0);
|
||||
event.put("endTime", EpochSeconds.fromInstant(Instant.now()));
|
||||
event.put("status", status);
|
||||
}
|
||||
|
||||
@@ -1796,20 +1797,20 @@ public class CodeDeployService {
|
||||
|
||||
private void updateTargetStatus(Map<String, Object> lambdaTargetMap, String status) {
|
||||
lambdaTargetMap.put("status", status);
|
||||
lambdaTargetMap.put("lastUpdatedAt", Instant.now().toEpochMilli() / 1000.0);
|
||||
lambdaTargetMap.put("lastUpdatedAt", EpochSeconds.fromInstant(Instant.now()));
|
||||
}
|
||||
|
||||
private void finishStopped(Deployment deployment, Map<String, Object> lambdaTargetMap) {
|
||||
updateTargetStatus(lambdaTargetMap, "Skipped");
|
||||
deployment.setStatus("Stopped");
|
||||
deployment.setCompleteTime(Instant.now().toEpochMilli() / 1000.0);
|
||||
deployment.setCompleteTime(EpochSeconds.fromInstant(Instant.now()));
|
||||
}
|
||||
|
||||
private void finishFailed(Deployment deployment, Map<String, Object> lambdaTargetMap,
|
||||
String errorCode, String message) {
|
||||
updateTargetStatus(lambdaTargetMap, "Failed");
|
||||
deployment.setStatus("Failed");
|
||||
deployment.setCompleteTime(Instant.now().toEpochMilli() / 1000.0);
|
||||
deployment.setCompleteTime(EpochSeconds.fromInstant(Instant.now()));
|
||||
deployment.setErrorInformation(Map.of("code", errorCode, "message", message != null ? message : ""));
|
||||
}
|
||||
|
||||
|
||||
+3
-2
@@ -9,6 +9,7 @@ import io.github.hectorvent.floci.config.EmulatorConfig;
|
||||
import io.github.hectorvent.floci.core.common.AwsArnUtils;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.DeadlineCharSequence;
|
||||
import io.github.hectorvent.floci.core.common.EpochSeconds;
|
||||
import io.github.hectorvent.floci.core.storage.AccountAwareStorageBackend;
|
||||
import io.github.hectorvent.floci.core.storage.StorageBackend;
|
||||
import io.github.hectorvent.floci.core.storage.StorageFactory;
|
||||
@@ -2037,7 +2038,7 @@ public class CodePipelineService {
|
||||
revision.put("revisionChangeIdentifier", unquoteETag(object.getETag()));
|
||||
revision.put("revisionSummary", bucket + "/" + key);
|
||||
revision.put("revisionUrl", "s3://" + bucket + "/" + key);
|
||||
revision.put("created", object.getLastModified().toEpochMilli() / 1000.0);
|
||||
revision.put("created", EpochSeconds.fromInstant(object.getLastModified()));
|
||||
execution.getArtifactRevisions().add(revision);
|
||||
upsertSourceRevision(execution, state.getActionName(), revisionId, bucket, key, object);
|
||||
pinResolvedS3Version(execution, state.getActionName(), object.getVersionId());
|
||||
@@ -3164,7 +3165,7 @@ public class CodePipelineService {
|
||||
}
|
||||
|
||||
private static double now() {
|
||||
return Instant.now().toEpochMilli() / 1000.0;
|
||||
return EpochSeconds.fromInstant(Instant.now());
|
||||
}
|
||||
|
||||
private static void putIfNotNull(ObjectNode node, String field, Object value) {
|
||||
|
||||
@@ -5,6 +5,7 @@ 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.core.common.EpochSeconds;
|
||||
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;
|
||||
@@ -252,7 +253,7 @@ public class DataSyncJsonHandler {
|
||||
}
|
||||
|
||||
private static double epochSeconds(Instant instant) {
|
||||
return (instant != null ? instant : Instant.EPOCH).toEpochMilli() / 1000.0;
|
||||
return EpochSeconds.fromInstant((instant != null ? instant : Instant.EPOCH));
|
||||
}
|
||||
|
||||
private static String text(JsonNode request, String member) {
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.fasterxml.jackson.databind.node.JsonNodeFactory;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.github.hectorvent.floci.core.common.AwsArnUtils;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.EpochSeconds;
|
||||
import io.github.hectorvent.floci.core.common.PaginatedResult;
|
||||
import io.github.hectorvent.floci.core.common.Pagination;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
@@ -778,7 +779,7 @@ public class DmsService implements Resettable {
|
||||
}
|
||||
|
||||
private static double now() {
|
||||
return Instant.now().toEpochMilli() / 1000.0;
|
||||
return EpochSeconds.fromInstant(Instant.now());
|
||||
}
|
||||
|
||||
/** DMS-generated ARN suffixes are 26 characters of the base32 alphabet. */
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package io.github.hectorvent.floci.services.dsql;
|
||||
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.EpochSeconds;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
import io.github.hectorvent.floci.services.dsql.model.DsqlCluster;
|
||||
import jakarta.inject.Inject;
|
||||
@@ -220,7 +221,7 @@ public class DsqlController {
|
||||
}
|
||||
|
||||
private static double epochSeconds(DsqlCluster cluster) {
|
||||
return cluster.getCreationTime().toEpochMilli() / 1000.0;
|
||||
return EpochSeconds.fromInstant(cluster.getCreationTime());
|
||||
}
|
||||
|
||||
private static String string(Object value) {
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.github.hectorvent.floci.core.common.AwsArnUtils;
|
||||
import io.github.hectorvent.floci.core.common.AwsErrorResponse;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.EpochSeconds;
|
||||
import io.github.hectorvent.floci.core.common.PaginatedResult;
|
||||
import io.github.hectorvent.floci.services.ecr.model.AuthorizationData;
|
||||
import io.github.hectorvent.floci.services.ecr.model.Image;
|
||||
@@ -728,7 +729,7 @@ public class EcrJsonHandler {
|
||||
request.path("principalArn").asText(null), region);
|
||||
ObjectNode response = objectMapper.createObjectNode();
|
||||
response.put("principalArn", exclusion.principalArn());
|
||||
response.put("createdAt", exclusion.createdAt().toEpochMilli() / 1000.0);
|
||||
response.put("createdAt", EpochSeconds.fromInstant(exclusion.createdAt()));
|
||||
return Response.ok(response).build();
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.github.hectorvent.floci.core.common.AwsErrorResponse;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.EpochSeconds;
|
||||
import io.github.hectorvent.floci.core.common.SmithyValidationErrors;
|
||||
import io.github.hectorvent.floci.services.ecs.container.HostVolumePolicy;
|
||||
import io.github.hectorvent.floci.services.ecs.model.Attribute;
|
||||
@@ -1140,9 +1141,9 @@ public class EcsJsonHandler {
|
||||
brief.put("serviceArn", d.getServiceArn());
|
||||
brief.put("clusterArn", d.getClusterArn());
|
||||
brief.put("status", d.getStatus());
|
||||
if (d.getCreatedAt() != null) { brief.put("createdAt", d.getCreatedAt().toEpochMilli() / 1000.0); }
|
||||
if (d.getStartedAt() != null) { brief.put("startedAt", d.getStartedAt().toEpochMilli() / 1000.0); }
|
||||
if (d.getFinishedAt() != null) { brief.put("finishedAt", d.getFinishedAt().toEpochMilli() / 1000.0); }
|
||||
if (d.getCreatedAt() != null) { brief.put("createdAt", EpochSeconds.fromInstant(d.getCreatedAt())); }
|
||||
if (d.getStartedAt() != null) { brief.put("startedAt", EpochSeconds.fromInstant(d.getStartedAt())); }
|
||||
if (d.getFinishedAt() != null) { brief.put("finishedAt", EpochSeconds.fromInstant(d.getFinishedAt())); }
|
||||
if (d.getTargetServiceRevisionArn() != null) {
|
||||
brief.put("targetServiceRevisionArn", d.getTargetServiceRevisionArn());
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package io.github.hectorvent.floci.services.ecs;
|
||||
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.EpochSeconds;
|
||||
import io.github.hectorvent.floci.services.ecs.model.Attribute;
|
||||
import io.github.hectorvent.floci.services.ecs.model.AwsVpcConfiguration;
|
||||
import io.github.hectorvent.floci.services.ecs.model.CapacityProvider;
|
||||
@@ -1167,7 +1168,7 @@ public class EcsResponseWriter {
|
||||
/** ECS timestamps go on the wire as epoch seconds with a fractional part. */
|
||||
private static void putInstant(ObjectNode target, String field, Instant value) {
|
||||
if (value != null) {
|
||||
target.put(field, value.toEpochMilli() / 1000.0);
|
||||
target.put(field, EpochSeconds.fromInstant(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.github.hectorvent.floci.core.common.AwsArnUtils;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.EpochSeconds;
|
||||
import io.github.hectorvent.floci.core.common.PaginatedResult;
|
||||
import io.github.hectorvent.floci.core.common.Pagination;
|
||||
import io.github.hectorvent.floci.core.storage.StorageBackend;
|
||||
@@ -134,7 +135,7 @@ public class EksAddonService {
|
||||
|
||||
List<String> associationArns = createOrLinkPodIdentityAssociations(cluster, addonName, request.podIdentityAssociations());
|
||||
|
||||
double now = Instant.now().toEpochMilli() / 1000.0;
|
||||
double now = EpochSeconds.fromInstant(Instant.now());
|
||||
String addonArn = generateAddonArn(cluster, addonName);
|
||||
Optional<AddonInfo> addonInfo = catalog.findAddon(addonName);
|
||||
String owner = addonInfo.map(AddonInfo::owner).orElse("aws");
|
||||
@@ -257,7 +258,7 @@ public class EksAddonService {
|
||||
params.add(new UpdateParam("PodIdentityAssociations", serializeAssociations(request.podIdentityAssociations())));
|
||||
}
|
||||
|
||||
double now = Instant.now().toEpochMilli() / 1000.0;
|
||||
double now = EpochSeconds.fromInstant(Instant.now());
|
||||
Addon updatedAddon = new Addon(
|
||||
current.addonArn(),
|
||||
current.addonName(),
|
||||
@@ -324,7 +325,7 @@ public class EksAddonService {
|
||||
"DELETING",
|
||||
current.health(),
|
||||
current.createdAt(),
|
||||
Instant.now().toEpochMilli() / 1000.0,
|
||||
EpochSeconds.fromInstant(Instant.now()),
|
||||
current.serviceAccountRoleArn(),
|
||||
current.configurationValues(),
|
||||
current.tags(),
|
||||
|
||||
+3
-2
@@ -4,6 +4,7 @@ import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import io.github.hectorvent.floci.core.common.AwsArnUtils;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.Base64Url;
|
||||
import io.github.hectorvent.floci.core.common.EpochSeconds;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
import io.github.hectorvent.floci.core.storage.StorageBackend;
|
||||
import io.github.hectorvent.floci.core.storage.StorageFactory;
|
||||
@@ -129,7 +130,7 @@ public class EksPodIdentityAssociationService {
|
||||
cluster.getAccountId() != null ? cluster.getAccountId() : regionResolver.getDefaultAccountId());
|
||||
String associationArn = AwsArnUtils.Arn.of("eks", region, accountId,
|
||||
"podidentityassociation/" + cluster.getName() + "/" + associationId).toString();
|
||||
double now = Instant.now().toEpochMilli() / 1000.0;
|
||||
double now = EpochSeconds.fromInstant(Instant.now());
|
||||
String externalId = UUID.randomUUID().toString();
|
||||
|
||||
PodIdentityAssociation association = new PodIdentityAssociation(
|
||||
@@ -206,7 +207,7 @@ public class EksPodIdentityAssociationService {
|
||||
? request.disableSessionTags() : current.disableSessionTags();
|
||||
String newPolicy = request.policy() != null ? request.policy() : current.policy();
|
||||
|
||||
double now = Instant.now().toEpochMilli() / 1000.0;
|
||||
double now = EpochSeconds.fromInstant(Instant.now());
|
||||
PodIdentityAssociation updated = new PodIdentityAssociation(
|
||||
current.clusterName(),
|
||||
current.namespace(),
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.github.hectorvent.floci.core.common.AwsArnUtils;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.Base64Url;
|
||||
import io.github.hectorvent.floci.core.common.EpochSeconds;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
import io.github.hectorvent.floci.core.common.TagHandler;
|
||||
import io.github.hectorvent.floci.core.storage.StorageBackend;
|
||||
@@ -1655,7 +1656,7 @@ public class FisService implements TagHandler {
|
||||
}
|
||||
|
||||
private double now() {
|
||||
return Instant.now().toEpochMilli() / 1000.0;
|
||||
return EpochSeconds.fromInstant(Instant.now());
|
||||
}
|
||||
|
||||
private String key(String region, String type, String id) {
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.AwsJsonTimestamp;
|
||||
import io.github.hectorvent.floci.core.common.EpochSeconds;
|
||||
import io.github.hectorvent.floci.services.glue.model.*;
|
||||
import io.github.hectorvent.floci.services.glue.schemaregistry.GlueSchemaRegistryService;
|
||||
import io.github.hectorvent.floci.services.glue.schemaregistry.model.Registry;
|
||||
@@ -1179,7 +1180,7 @@ public class GlueJsonHandler {
|
||||
}
|
||||
|
||||
private static double epochSeconds(Instant instant) {
|
||||
return instant.toEpochMilli() / 1000.0;
|
||||
return EpochSeconds.fromInstant(instant);
|
||||
}
|
||||
|
||||
private static String iso(Instant instant) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.github.hectorvent.floci.core.common.AwsArnUtils;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.Base64Url;
|
||||
import io.github.hectorvent.floci.core.common.EpochSeconds;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
import io.github.hectorvent.floci.core.storage.StorageBackend;
|
||||
import io.github.hectorvent.floci.core.storage.StorageFactory;
|
||||
@@ -1930,7 +1931,7 @@ public class GlueService {
|
||||
|
||||
Map<String, Object> details = new LinkedHashMap<>(classifier.selectedDetails());
|
||||
validateClassifierDetails(classifier.selectedKind(), details);
|
||||
double now = Instant.now().toEpochMilli() / 1000.0d;
|
||||
double now = EpochSeconds.fromInstant(Instant.now());
|
||||
details.put("CreationTime", now);
|
||||
details.put("LastUpdated", now);
|
||||
details.put("Version", 1L);
|
||||
@@ -1969,7 +1970,7 @@ public class GlueService {
|
||||
validateClassifierDetails(existing.selectedKind(), details);
|
||||
Number version = (Number) existing.selectedDetails().get("Version");
|
||||
details.put("CreationTime", existing.selectedDetails().get("CreationTime"));
|
||||
details.put("LastUpdated", Instant.now().toEpochMilli() / 1000.0d);
|
||||
details.put("LastUpdated", EpochSeconds.fromInstant(Instant.now()));
|
||||
details.put("Version", (version == null ? 1L : version.longValue()) + 1L);
|
||||
classifierStore.put(name, existing.copyWithDetails(details));
|
||||
LOG.infov("Updated Glue Classifier: {0}", name);
|
||||
|
||||
@@ -2,6 +2,7 @@ package io.github.hectorvent.floci.services.glue;
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.EpochSeconds;
|
||||
import io.github.hectorvent.floci.core.storage.StorageBackend;
|
||||
import io.github.hectorvent.floci.core.storage.StorageFactory;
|
||||
import io.github.hectorvent.floci.core.storage.WriteProfile;
|
||||
@@ -673,7 +674,7 @@ public class GlueTriggerService {
|
||||
}
|
||||
|
||||
private static double epochSeconds(Instant instant) {
|
||||
return instant.toEpochMilli() / 1000.0;
|
||||
return EpochSeconds.fromInstant(instant);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+2
-1
@@ -5,6 +5,7 @@ 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.core.common.EpochSeconds;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
import io.github.hectorvent.floci.services.guardduty.model.Detector;
|
||||
import io.github.hectorvent.floci.services.guardduty.model.DetectorFeature;
|
||||
@@ -336,7 +337,7 @@ public class GuardDutyController {
|
||||
}
|
||||
response.put("arn", plan.getArn());
|
||||
// The model types createdAt as a timestamp, which restJson1 carries as epoch seconds.
|
||||
response.put("createdAt", Instant.parse(plan.getCreatedAt()).toEpochMilli() / 1000.0);
|
||||
response.put("createdAt", EpochSeconds.fromInstant(Instant.parse(plan.getCreatedAt())));
|
||||
ObjectNode bucket = response.putObject("protectedResource").putObject("s3Bucket");
|
||||
bucket.put("bucketName", plan.getBucketName());
|
||||
if (plan.getObjectPrefixes() != null) {
|
||||
|
||||
@@ -3,6 +3,7 @@ package io.github.hectorvent.floci.services.iot;
|
||||
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.EpochSeconds;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
import io.github.hectorvent.floci.services.iot.model.IotAuthorizer;
|
||||
import jakarta.inject.Inject;
|
||||
@@ -137,9 +138,9 @@ public class IotAuthorizerController {
|
||||
description.put("authorizerArn", authorizer.getAuthorizerArn());
|
||||
description.put("authorizerFunctionArn", authorizer.getAuthorizerFunctionArn());
|
||||
description.put("authorizerName", authorizer.getAuthorizerName());
|
||||
description.put("creationDate", authorizer.getCreationDate().toEpochMilli() / 1000.0);
|
||||
description.put("creationDate", EpochSeconds.fromInstant(authorizer.getCreationDate()));
|
||||
description.put("enableCachingForHttp", authorizer.isEnableCachingForHttp());
|
||||
description.put("lastModifiedDate", authorizer.getLastModifiedDate().toEpochMilli() / 1000.0);
|
||||
description.put("lastModifiedDate", EpochSeconds.fromInstant(authorizer.getLastModifiedDate()));
|
||||
description.put("signingDisabled", authorizer.isSigningDisabled());
|
||||
description.put("status", authorizer.getStatus());
|
||||
description.put("tokenKeyName", authorizer.getTokenKeyName());
|
||||
|
||||
@@ -6,6 +6,7 @@ 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.core.common.EpochSeconds;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
import io.github.hectorvent.floci.services.iot.model.IotCertificate;
|
||||
import io.github.hectorvent.floci.services.iot.model.IotJob;
|
||||
@@ -1224,7 +1225,7 @@ public class IotController {
|
||||
|
||||
private void putEpoch(ObjectNode node, String field, Instant instant) {
|
||||
if (instant != null) {
|
||||
node.put(field, instant.toEpochMilli() / 1000.0);
|
||||
node.put(field, EpochSeconds.fromInstant(instant));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -3,6 +3,7 @@ package io.github.hectorvent.floci.services.iot;
|
||||
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.EpochSeconds;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
import io.github.hectorvent.floci.services.iot.model.IotDomainConfiguration;
|
||||
import io.github.hectorvent.floci.services.iot.model.IotDomainConfiguration.AuthorizerConfig;
|
||||
@@ -137,7 +138,7 @@ public class IotDomainConfigurationController {
|
||||
response.put("serviceType", configuration.getServiceType());
|
||||
response.put("domainType", configuration.getDomainType());
|
||||
if (configuration.getLastStatusChangeDate() != null) {
|
||||
response.put("lastStatusChangeDate", configuration.getLastStatusChangeDate().toEpochMilli() / 1000.0);
|
||||
response.put("lastStatusChangeDate", EpochSeconds.fromInstant(configuration.getLastStatusChangeDate()));
|
||||
}
|
||||
if (configuration.getTlsConfig() != null) {
|
||||
putIfPresent(response.putObject("tlsConfig"), "securityPolicy", configuration.getTlsConfig().securityPolicy());
|
||||
|
||||
@@ -9,6 +9,7 @@ import io.github.hectorvent.floci.core.common.AwsErrorResponse;
|
||||
import io.github.hectorvent.floci.core.common.AwsEventStreamEncoder;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.Base64Url;
|
||||
import io.github.hectorvent.floci.core.common.EpochSeconds;
|
||||
import io.github.hectorvent.floci.services.kinesis.model.KinesisConsumer;
|
||||
import io.github.hectorvent.floci.services.kinesis.model.KinesisRecord;
|
||||
import io.github.hectorvent.floci.services.kinesis.model.KinesisShard;
|
||||
@@ -471,7 +472,7 @@ public class KinesisJsonHandler {
|
||||
node.put("ConsumerName", c.getConsumerName());
|
||||
node.put("ConsumerARN", c.getConsumerArn());
|
||||
node.put("ConsumerStatus", c.getConsumerStatus());
|
||||
node.put("ConsumerCreationTimestamp", c.getConsumerCreationTimestamp().toEpochMilli() / 1000.0);
|
||||
node.put("ConsumerCreationTimestamp", EpochSeconds.fromInstant(c.getConsumerCreationTimestamp()));
|
||||
if (c.getStreamArn() != null) {
|
||||
node.put("StreamARN", c.getStreamArn());
|
||||
}
|
||||
|
||||
+4
-3
@@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.github.hectorvent.floci.core.common.AwsArnUtils;
|
||||
import io.github.hectorvent.floci.core.common.AwsErrorResponse;
|
||||
import io.github.hectorvent.floci.core.common.EpochSeconds;
|
||||
import io.github.hectorvent.floci.core.common.PaginatedResult;
|
||||
import io.github.hectorvent.floci.core.common.Pagination;
|
||||
import io.github.hectorvent.floci.services.kinesisanalytics.model.FlinkApplication;
|
||||
@@ -238,7 +239,7 @@ public class KinesisAnalyticsV2JsonHandler {
|
||||
node.put("SnapshotStatus", snapshot.getSnapshotStatus().name());
|
||||
node.put("ApplicationVersionId", snapshot.getApplicationVersionId());
|
||||
if (snapshot.getSnapshotCreationTimestamp() != null) {
|
||||
node.put("SnapshotCreationTimestamp", snapshot.getSnapshotCreationTimestamp().toEpochMilli() / 1000.0);
|
||||
node.put("SnapshotCreationTimestamp", EpochSeconds.fromInstant(snapshot.getSnapshotCreationTimestamp()));
|
||||
}
|
||||
if (snapshot.getRuntimeEnvironment() != null) {
|
||||
node.put("RuntimeEnvironment", snapshot.getRuntimeEnvironment());
|
||||
@@ -319,10 +320,10 @@ public class KinesisAnalyticsV2JsonHandler {
|
||||
detail.put("ApplicationMode", app.getApplicationMode());
|
||||
}
|
||||
if (app.getCreateTimestamp() != null) {
|
||||
detail.put("CreateTimestamp", app.getCreateTimestamp().toEpochMilli() / 1000.0);
|
||||
detail.put("CreateTimestamp", EpochSeconds.fromInstant(app.getCreateTimestamp()));
|
||||
}
|
||||
if (app.getLastUpdateTimestamp() != null) {
|
||||
detail.put("LastUpdateTimestamp", app.getLastUpdateTimestamp().toEpochMilli() / 1000.0);
|
||||
detail.put("LastUpdateTimestamp", EpochSeconds.fromInstant(app.getLastUpdateTimestamp()));
|
||||
}
|
||||
if (app.hasCode()) {
|
||||
detail.set("ApplicationConfigurationDescription", applicationConfigurationNode(app));
|
||||
|
||||
+2
-1
@@ -9,6 +9,7 @@ import io.github.hectorvent.floci.config.EmulatorConfig;
|
||||
import io.github.hectorvent.floci.core.common.AwsArnUtils;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.AwsRegions;
|
||||
import io.github.hectorvent.floci.core.common.EpochSeconds;
|
||||
import io.github.hectorvent.floci.core.common.Resettable;
|
||||
import io.github.hectorvent.floci.services.kinesis.KinesisService;
|
||||
import io.github.hectorvent.floci.services.kinesis.model.KinesisRecord;
|
||||
@@ -422,7 +423,7 @@ public class KinesisEventSourcePoller implements Resettable {
|
||||
kinesisNode.put("sequenceNumber", rec.getSequenceNumber());
|
||||
kinesisNode.put("data", Base64.getEncoder().encodeToString(rec.getData()));
|
||||
kinesisNode.put("approximateArrivalTimestamp",
|
||||
rec.getApproximateArrivalTimestamp().toEpochMilli() / 1000.0);
|
||||
EpochSeconds.fromInstant(rec.getApproximateArrivalTimestamp()));
|
||||
ObjectNode record = objectMapper.createObjectNode();
|
||||
record.set("kinesis", kinesisNode);
|
||||
record.put("eventSource", "aws:kinesis");
|
||||
|
||||
+2
-1
@@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.github.hectorvent.floci.core.common.AwsArnUtils;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.EpochSeconds;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
import io.github.hectorvent.floci.services.lambdamicrovms.LambdaMicrovmsService.Microvm;
|
||||
import io.github.hectorvent.floci.services.lambdamicrovms.LambdaMicrovmsService.MicrovmBuild;
|
||||
@@ -534,7 +535,7 @@ public class LambdaMicrovmsController {
|
||||
}
|
||||
|
||||
private double epoch(Instant instant) {
|
||||
return instant.toEpochMilli() / 1000.0;
|
||||
return EpochSeconds.fromInstant(instant);
|
||||
}
|
||||
|
||||
private JsonNode parse(String body) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.github.hectorvent.floci.core.common.AwsArnUtils;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.AwsPartitions;
|
||||
import io.github.hectorvent.floci.core.common.EpochSeconds;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
import io.github.hectorvent.floci.core.resource.ExplorerResource;
|
||||
import io.github.hectorvent.floci.core.resource.ResourceProvider;
|
||||
@@ -879,7 +880,7 @@ public class LightsailService implements ResourceProvider {
|
||||
}
|
||||
|
||||
private static double epochSeconds(Instant instant) {
|
||||
return instant.toEpochMilli() / 1000.0;
|
||||
return EpochSeconds.fromInstant(instant);
|
||||
}
|
||||
|
||||
private static String privateIpFor(String name) {
|
||||
|
||||
+3
-2
@@ -6,6 +6,7 @@ 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.core.common.EpochSeconds;
|
||||
import io.github.hectorvent.floci.core.common.RequestContext;
|
||||
import io.github.hectorvent.floci.core.common.Resettable;
|
||||
import io.github.hectorvent.floci.core.storage.AccountAwareStorageBackend;
|
||||
@@ -771,7 +772,7 @@ public class MarketplaceAgreementService implements Resettable {
|
||||
return Double.parseDouble(value);
|
||||
} catch (NumberFormatException e) {
|
||||
try {
|
||||
return Instant.parse(value).toEpochMilli() / 1000.0d;
|
||||
return EpochSeconds.fromInstant(Instant.parse(value));
|
||||
} catch (Exception ignored) {
|
||||
throw validation("Time filters must be valid timestamps.");
|
||||
}
|
||||
@@ -792,7 +793,7 @@ public class MarketplaceAgreementService implements Resettable {
|
||||
}
|
||||
|
||||
private static double epoch() {
|
||||
return Instant.now().toEpochMilli() / 1000.0d;
|
||||
return EpochSeconds.fromInstant(Instant.now());
|
||||
}
|
||||
|
||||
private static String compactId() {
|
||||
|
||||
+2
-1
@@ -5,6 +5,7 @@ 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.core.common.EpochSeconds;
|
||||
import io.github.hectorvent.floci.core.common.JsonErrorResponseUtils;
|
||||
import io.github.hectorvent.floci.core.common.PaginatedResult;
|
||||
import io.github.hectorvent.floci.core.common.Pagination;
|
||||
@@ -782,7 +783,7 @@ public class OrganizationsJsonHandler {
|
||||
|
||||
private void putTimestamp(ObjectNode node, String field, Instant timestamp) {
|
||||
if (timestamp != null) {
|
||||
node.put(field, timestamp.toEpochMilli() / 1000.0);
|
||||
node.put(field, EpochSeconds.fromInstant(timestamp));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ import com.fasterxml.jackson.databind.ObjectReader;
|
||||
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.core.common.EpochSeconds;
|
||||
import io.github.hectorvent.floci.core.common.PaginatedResult;
|
||||
import io.github.hectorvent.floci.core.common.Pagination;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
@@ -235,8 +236,8 @@ public class RamController {
|
||||
node.put("associatedEntity", association.associatedEntity());
|
||||
node.put("associationType", association.associationType());
|
||||
node.put("status", "ASSOCIATED");
|
||||
node.put("creationTime", association.creationTime().toEpochMilli() / 1000.0);
|
||||
node.put("lastUpdatedTime", association.lastUpdatedTime().toEpochMilli() / 1000.0);
|
||||
node.put("creationTime", EpochSeconds.fromInstant(association.creationTime()));
|
||||
node.put("lastUpdatedTime", EpochSeconds.fromInstant(association.lastUpdatedTime()));
|
||||
node.put("external", false);
|
||||
associations.add(node);
|
||||
}
|
||||
@@ -265,8 +266,8 @@ public class RamController {
|
||||
ObjectNode node = objectMapper.createObjectNode();
|
||||
node.put("id", principal.id());
|
||||
node.put("resourceShareArn", principal.resourceShareArn());
|
||||
node.put("creationTime", principal.creationTime().toEpochMilli() / 1000.0);
|
||||
node.put("lastUpdatedTime", principal.lastUpdatedTime().toEpochMilli() / 1000.0);
|
||||
node.put("creationTime", EpochSeconds.fromInstant(principal.creationTime()));
|
||||
node.put("lastUpdatedTime", EpochSeconds.fromInstant(principal.lastUpdatedTime()));
|
||||
node.put("external", principal.external());
|
||||
array.add(node);
|
||||
}
|
||||
@@ -293,8 +294,8 @@ public class RamController {
|
||||
node.put("name", permission.name());
|
||||
node.put("resourceType", permission.resourceType());
|
||||
node.put("status", "ATTACHABLE");
|
||||
node.put("creationTime", permission.creationTime().toEpochMilli() / 1000.0);
|
||||
node.put("lastUpdatedTime", permission.lastUpdatedTime().toEpochMilli() / 1000.0);
|
||||
node.put("creationTime", EpochSeconds.fromInstant(permission.creationTime()));
|
||||
node.put("lastUpdatedTime", EpochSeconds.fromInstant(permission.lastUpdatedTime()));
|
||||
node.put("isResourceTypeDefault", true);
|
||||
node.put("permissionType", "AWS_MANAGED");
|
||||
node.put("featureSet", "STANDARD");
|
||||
@@ -387,7 +388,7 @@ public class RamController {
|
||||
node.put("resourceShareName", invitation.resourceShareName());
|
||||
node.put("senderAccountId", invitation.senderAccountId());
|
||||
node.put("receiverAccountId", invitation.receiverAccountId());
|
||||
node.put("invitationTimestamp", invitation.invitationTimestamp().toEpochMilli() / 1000.0);
|
||||
node.put("invitationTimestamp", EpochSeconds.fromInstant(invitation.invitationTimestamp()));
|
||||
node.put("status", invitation.status());
|
||||
return node;
|
||||
}
|
||||
@@ -427,8 +428,8 @@ public class RamController {
|
||||
// Shares created through the API are STANDARD; CREATED_FROM_POLICY covers shares RAM
|
||||
// derives from a resource policy, which floci has no path to produce.
|
||||
node.put("featureSet", "STANDARD");
|
||||
node.put("creationTime", share.getCreationTime().toEpochMilli() / 1000.0);
|
||||
node.put("lastUpdatedTime", share.getLastUpdatedTime().toEpochMilli() / 1000.0);
|
||||
node.put("creationTime", EpochSeconds.fromInstant(share.getCreationTime()));
|
||||
node.put("lastUpdatedTime", EpochSeconds.fromInstant(share.getLastUpdatedTime()));
|
||||
ArrayNode tags = objectMapper.createArrayNode();
|
||||
share.getTags().forEach((key, value) -> {
|
||||
ObjectNode tag = objectMapper.createObjectNode();
|
||||
@@ -444,7 +445,7 @@ public class RamController {
|
||||
private ArrayNode associationArray(ResourceShare share, List<String> resourceArns,
|
||||
List<String> principals, String status) {
|
||||
ArrayNode array = objectMapper.createArrayNode();
|
||||
double now = share.getLastUpdatedTime().toEpochMilli() / 1000.0;
|
||||
double now = EpochSeconds.fromInstant(share.getLastUpdatedTime());
|
||||
for (String resourceArn : resourceArns) {
|
||||
array.add(associationNode(share, resourceArn, "RESOURCE", status, now));
|
||||
}
|
||||
|
||||
+2
-1
@@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.github.hectorvent.floci.core.common.AwsArnUtils;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.EpochSeconds;
|
||||
import io.github.hectorvent.floci.core.common.RequestContext;
|
||||
import io.github.hectorvent.floci.core.common.Resettable;
|
||||
import io.github.hectorvent.floci.core.common.SqlParameterParser.ParsedSql;
|
||||
@@ -1344,7 +1345,7 @@ public class RedshiftDataService implements Resettable {
|
||||
}
|
||||
|
||||
static double epochSeconds(Instant instant) {
|
||||
return instant.toEpochMilli() / 1000.0;
|
||||
return EpochSeconds.fromInstant(instant);
|
||||
}
|
||||
|
||||
private String clusterIdentifierOrNull(JsonNode request) {
|
||||
|
||||
+2
-1
@@ -5,6 +5,7 @@ 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.AwsJsonTimestamp;
|
||||
import io.github.hectorvent.floci.core.common.EpochSeconds;
|
||||
import io.github.hectorvent.floci.core.common.PaginatedResult;
|
||||
import io.github.hectorvent.floci.core.common.Pagination;
|
||||
import io.github.hectorvent.floci.services.redshiftserverless.model.CustomDomainAssociation;
|
||||
@@ -387,7 +388,7 @@ public class RedshiftServerlessAdminJsonHandler {
|
||||
}
|
||||
|
||||
private static double epoch(Instant instant) {
|
||||
return instant.toEpochMilli() / 1000.0;
|
||||
return EpochSeconds.fromInstant(instant);
|
||||
}
|
||||
// ── Tracks, managed workgroups and reservations ────────────────────────
|
||||
|
||||
|
||||
+5
-4
@@ -3,6 +3,7 @@ package io.github.hectorvent.floci.services.s3vectors;
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.EpochSeconds;
|
||||
import io.github.hectorvent.floci.core.common.RegionResolver;
|
||||
import io.github.hectorvent.floci.services.s3vectors.model.VectorBucket;
|
||||
import io.github.hectorvent.floci.services.s3vectors.model.VectorData;
|
||||
@@ -291,7 +292,7 @@ public class S3VectorsController {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
VectorBucket bucket = service.getVectorBucket(request.vectorBucketName(), region);
|
||||
VectorBucketRepresentation rep = new VectorBucketRepresentation(bucket.getVectorBucketName(),
|
||||
bucket.getVectorBucketArn(), bucket.getCreationTime().toEpochMilli() / 1000.0, bucket.getEncryptionConfiguration());
|
||||
bucket.getVectorBucketArn(), EpochSeconds.fromInstant(bucket.getCreationTime()), bucket.getEncryptionConfiguration());
|
||||
return Response.ok(new GetVectorBucketResponse(rep)).build();
|
||||
}
|
||||
|
||||
@@ -302,7 +303,7 @@ public class S3VectorsController {
|
||||
List<VectorBucket> buckets = service.listVectorBuckets(region);
|
||||
List<VectorBucketSummary> reps = buckets.stream()
|
||||
.map(b -> new VectorBucketSummary(b.getVectorBucketName(), b.getVectorBucketArn(),
|
||||
b.getCreationTime().toEpochMilli() / 1000.0))
|
||||
EpochSeconds.fromInstant(b.getCreationTime())))
|
||||
.toList();
|
||||
return Response.ok(new ListVectorBucketsResponse(reps, null)).build();
|
||||
}
|
||||
@@ -340,7 +341,7 @@ public class S3VectorsController {
|
||||
String region = regionResolver.resolveRegion(headers);
|
||||
VectorIndex index = service.getIndex(request.vectorBucketName(), request.indexName(), region);
|
||||
IndexRepresentation rep = new IndexRepresentation(
|
||||
index.getCreationTime().toEpochMilli() / 1000.0,
|
||||
EpochSeconds.fromInstant(index.getCreationTime()),
|
||||
index.getVectorBucketName(),
|
||||
index.getIndexName(),
|
||||
index.getIndexArn(),
|
||||
@@ -361,7 +362,7 @@ public class S3VectorsController {
|
||||
List<VectorIndex> indexes = service.listIndexes(request.vectorBucketName(), region);
|
||||
List<IndexSummary> reps = indexes.stream()
|
||||
.map(i -> new IndexSummary(
|
||||
i.getCreationTime().toEpochMilli() / 1000.0,
|
||||
EpochSeconds.fromInstant(i.getCreationTime()),
|
||||
i.getVectorBucketName(),
|
||||
i.getIndexName(),
|
||||
i.getIndexArn()
|
||||
|
||||
+18
-17
@@ -7,6 +7,7 @@ import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.github.hectorvent.floci.core.common.AwsErrorResponse;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.EpochSeconds;
|
||||
import io.github.hectorvent.floci.core.common.IamEnforcementFilter;
|
||||
import io.github.hectorvent.floci.services.secretsmanager.model.Secret;
|
||||
import io.github.hectorvent.floci.services.secretsmanager.model.SecretVersion;
|
||||
@@ -185,7 +186,7 @@ public class SecretsManagerJsonHandler {
|
||||
node.put("SecretBinary", value.secretBinary());
|
||||
}
|
||||
if (value.createdDate() != null) {
|
||||
node.put("CreatedDate", value.createdDate().toEpochMilli() / 1000.0);
|
||||
node.put("CreatedDate", EpochSeconds.fromInstant(value.createdDate()));
|
||||
}
|
||||
putVersionStages(node, value.versionStages());
|
||||
secretValues.add(node);
|
||||
@@ -259,7 +260,7 @@ public class SecretsManagerJsonHandler {
|
||||
response.put("SecretBinary", version.getSecretBinary());
|
||||
}
|
||||
if (version.getCreatedDate() != null) {
|
||||
response.put("CreatedDate", version.getCreatedDate().toEpochMilli() / 1000.0);
|
||||
response.put("CreatedDate", EpochSeconds.fromInstant(version.getCreatedDate()));
|
||||
}
|
||||
putVersionStages(response, version.getVersionStages());
|
||||
return Response.ok(response).build();
|
||||
@@ -361,21 +362,21 @@ public class SecretsManagerJsonHandler {
|
||||
response.set("RotationRules", rotationRulesNode(secret.getRotationRules()));
|
||||
}
|
||||
if (secret.getLastRotatedDate() != null) {
|
||||
response.put("LastRotatedDate", secret.getLastRotatedDate().toEpochMilli() / 1000.0);
|
||||
response.put("LastRotatedDate", EpochSeconds.fromInstant(secret.getLastRotatedDate()));
|
||||
}
|
||||
|
||||
Instant nextRotationDate = nextRotationDate(secret);
|
||||
if (nextRotationDate != null) {
|
||||
response.put("NextRotationDate", nextRotationDate.toEpochMilli() / 1000.0);
|
||||
response.put("NextRotationDate", EpochSeconds.fromInstant(nextRotationDate));
|
||||
}
|
||||
if (secret.getCreatedDate() != null) {
|
||||
response.put("CreatedDate", secret.getCreatedDate().toEpochMilli() / 1000.0);
|
||||
response.put("CreatedDate", EpochSeconds.fromInstant(secret.getCreatedDate()));
|
||||
}
|
||||
if (secret.getLastChangedDate() != null) {
|
||||
response.put("LastChangedDate", secret.getLastChangedDate().toEpochMilli() / 1000.0);
|
||||
response.put("LastChangedDate", EpochSeconds.fromInstant(secret.getLastChangedDate()));
|
||||
}
|
||||
if (secret.getDeletedDate() != null) {
|
||||
response.put("DeletedDate", secret.getDeletedDate().toEpochMilli() / 1000.0);
|
||||
response.put("DeletedDate", EpochSeconds.fromInstant(secret.getDeletedDate()));
|
||||
}
|
||||
if (secret.getOwningService() != null) {
|
||||
response.put("OwningService", secret.getOwningService());
|
||||
@@ -573,23 +574,23 @@ public class SecretsManagerJsonHandler {
|
||||
node.set("RotationRules", rotationRulesNode(secret.getRotationRules()));
|
||||
}
|
||||
if (secret.getLastRotatedDate() != null) {
|
||||
node.put("LastRotatedDate", secret.getLastRotatedDate().toEpochMilli() / 1000.0);
|
||||
node.put("LastRotatedDate", EpochSeconds.fromInstant(secret.getLastRotatedDate()));
|
||||
}
|
||||
Instant nextRotation = nextRotationDate(secret);
|
||||
if (nextRotation != null) {
|
||||
node.put("NextRotationDate", nextRotation.toEpochMilli() / 1000.0);
|
||||
node.put("NextRotationDate", EpochSeconds.fromInstant(nextRotation));
|
||||
}
|
||||
if (secret.getCreatedDate() != null) {
|
||||
node.put("CreatedDate", secret.getCreatedDate().toEpochMilli() / 1000.0);
|
||||
node.put("CreatedDate", EpochSeconds.fromInstant(secret.getCreatedDate()));
|
||||
}
|
||||
if (secret.getLastChangedDate() != null) {
|
||||
node.put("LastChangedDate", secret.getLastChangedDate().toEpochMilli() / 1000.0);
|
||||
node.put("LastChangedDate", EpochSeconds.fromInstant(secret.getLastChangedDate()));
|
||||
}
|
||||
if (secret.getLastAccessedDate() != null) {
|
||||
node.put("LastAccessedDate", secret.getLastAccessedDate().toEpochMilli() / 1000.0);
|
||||
node.put("LastAccessedDate", EpochSeconds.fromInstant(secret.getLastAccessedDate()));
|
||||
}
|
||||
if (secret.getDeletedDate() != null) {
|
||||
node.put("DeletedDate", secret.getDeletedDate().toEpochMilli() / 1000.0);
|
||||
node.put("DeletedDate", EpochSeconds.fromInstant(secret.getDeletedDate()));
|
||||
}
|
||||
if (secret.getOwningService() != null) {
|
||||
node.put("OwningService", secret.getOwningService());
|
||||
@@ -623,7 +624,7 @@ public class SecretsManagerJsonHandler {
|
||||
response.put("ARN", secret.getArn());
|
||||
response.put("Name", secret.getName());
|
||||
if (secret.getDeletedDate() != null) {
|
||||
response.put("DeletionDate", secret.getDeletedDate().toEpochMilli() / 1000.0);
|
||||
response.put("DeletionDate", EpochSeconds.fromInstant(secret.getDeletedDate()));
|
||||
}
|
||||
return Response.ok(response).build();
|
||||
}
|
||||
@@ -804,10 +805,10 @@ public class SecretsManagerJsonHandler {
|
||||
}
|
||||
SecretVersion sv = secret.getVersions() != null ? secret.getVersions().get(versionId) : null;
|
||||
if (sv != null && sv.getCreatedDate() != null) {
|
||||
versionNode.put("CreatedDate", sv.getCreatedDate().toEpochMilli() / 1000.0);
|
||||
versionNode.put("CreatedDate", EpochSeconds.fromInstant(sv.getCreatedDate()));
|
||||
}
|
||||
if (sv != null && sv.getLastAccessedDate() != null) {
|
||||
versionNode.put("LastAccessedDate", sv.getLastAccessedDate().toEpochMilli() / 1000.0);
|
||||
versionNode.put("LastAccessedDate", EpochSeconds.fromInstant(sv.getLastAccessedDate()));
|
||||
}
|
||||
versions.add(versionNode);
|
||||
}
|
||||
@@ -935,7 +936,7 @@ public class SecretsManagerJsonHandler {
|
||||
node.put("StatusMessage", status.statusMessage());
|
||||
}
|
||||
if (status.lastAccessedDate() != null) {
|
||||
node.put("LastAccessedDate", status.lastAccessedDate().toEpochMilli() / 1000.0);
|
||||
node.put("LastAccessedDate", EpochSeconds.fromInstant(status.lastAccessedDate()));
|
||||
}
|
||||
statuses.add(node);
|
||||
}
|
||||
|
||||
+2
-1
@@ -7,6 +7,7 @@ import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.github.hectorvent.floci.core.common.AwsArnUtils;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.EpochSeconds;
|
||||
import io.github.hectorvent.floci.core.storage.StorageBackend;
|
||||
import io.github.hectorvent.floci.core.storage.StorageFactory;
|
||||
import io.github.hectorvent.floci.services.iam.PassedRoleLookup;
|
||||
@@ -71,7 +72,7 @@ public class ServiceCatalogService implements PassedRoleLookup {
|
||||
}
|
||||
|
||||
private double nowEpochSeconds() {
|
||||
return Instant.now(clock).toEpochMilli() / 1000.0;
|
||||
return EpochSeconds.fromInstant(Instant.now(clock));
|
||||
}
|
||||
|
||||
public ObjectNode createPortfolio(JsonNode request, String region, String accountId) {
|
||||
|
||||
@@ -6,6 +6,7 @@ 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.EpochSeconds;
|
||||
import io.github.hectorvent.floci.core.common.SmithyValidationErrors;
|
||||
import io.github.hectorvent.floci.services.ses.model.Tag;
|
||||
|
||||
@@ -358,7 +359,7 @@ final class SesV2Json {
|
||||
* ISO string, as the v1 Query path writes, breaks the SDK's unixTimestamp unmarshaller.
|
||||
*/
|
||||
static double epochSeconds(Instant instant) {
|
||||
return instant.toEpochMilli() / 1000.0;
|
||||
return EpochSeconds.fromInstant(instant);
|
||||
}
|
||||
|
||||
static void putTimestamp(ObjectNode node, String field, Instant value) {
|
||||
|
||||
@@ -8,6 +8,7 @@ import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import io.github.hectorvent.floci.core.common.AwsErrorResponse;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.EpochSeconds;
|
||||
import io.github.hectorvent.floci.core.common.IamEnforcementFilter;
|
||||
import io.github.hectorvent.floci.core.common.PaginatedResult;
|
||||
import io.github.hectorvent.floci.core.common.Pagination;
|
||||
@@ -314,7 +315,7 @@ public class SsmJsonHandler {
|
||||
if (h.getKeyId() != null) {
|
||||
node.put("KeyId", h.getKeyId());
|
||||
}
|
||||
node.put("LastModifiedDate", h.getLastModifiedDate().toEpochMilli() / 1000.0);
|
||||
node.put("LastModifiedDate", EpochSeconds.fromInstant(h.getLastModifiedDate()));
|
||||
if (h.getDescription() != null) {
|
||||
node.put("Description", h.getDescription());
|
||||
}
|
||||
@@ -402,7 +403,7 @@ public class SsmJsonHandler {
|
||||
node.put("ARN", p.getArn());
|
||||
node.put("Type", p.getType());
|
||||
node.put("Version", p.getVersion());
|
||||
node.put("LastModifiedDate", p.getLastModifiedDate().toEpochMilli() / 1000.0);
|
||||
node.put("LastModifiedDate", EpochSeconds.fromInstant(p.getLastModifiedDate()));
|
||||
if (p.getDescription() != null) {
|
||||
node.put("Description", p.getDescription());
|
||||
}
|
||||
@@ -773,7 +774,7 @@ public class SsmJsonHandler {
|
||||
ObjectNode docNode = objectMapper.createObjectNode();
|
||||
docNode.put("Name", d.getName());
|
||||
if (d.getCreatedDate() != null) {
|
||||
docNode.put("CreatedDate", d.getCreatedDate().toEpochMilli() / 1000.0);
|
||||
docNode.put("CreatedDate", EpochSeconds.fromInstant(d.getCreatedDate()));
|
||||
}
|
||||
docNode.put("DocumentType", d.getDocumentType());
|
||||
docNode.put("DocumentVersion", String.valueOf(d.getDocumentVersion()));
|
||||
@@ -998,7 +999,7 @@ public class SsmJsonHandler {
|
||||
node.put("ScheduleExpression", assoc.getScheduleExpression());
|
||||
}
|
||||
if (assoc.getLastExecutionDate() != null) {
|
||||
node.put("LastExecutionDate", assoc.getLastExecutionDate().toEpochMilli() / 1000.0);
|
||||
node.put("LastExecutionDate", EpochSeconds.fromInstant(assoc.getLastExecutionDate()));
|
||||
}
|
||||
return node;
|
||||
}
|
||||
@@ -1049,7 +1050,7 @@ public class SsmJsonHandler {
|
||||
statusNode.put("Message", assoc.getStatus().getMessage());
|
||||
}
|
||||
if (assoc.getStatus().getDate() != null) {
|
||||
statusNode.put("Date", assoc.getStatus().getDate().toEpochMilli() / 1000.0);
|
||||
statusNode.put("Date", EpochSeconds.fromInstant(assoc.getStatus().getDate()));
|
||||
}
|
||||
if (assoc.getStatus().getAdditionalInfo() != null) {
|
||||
statusNode.put("AdditionalInfo", assoc.getStatus().getAdditionalInfo());
|
||||
@@ -1063,10 +1064,10 @@ public class SsmJsonHandler {
|
||||
desc.set("Overview", overviewNode);
|
||||
}
|
||||
if (assoc.getCreatedDate() != null) {
|
||||
desc.put("Date", assoc.getCreatedDate().toEpochMilli() / 1000.0);
|
||||
desc.put("Date", EpochSeconds.fromInstant(assoc.getCreatedDate()));
|
||||
}
|
||||
if (assoc.getLastExecutionDate() != null) {
|
||||
desc.put("LastExecutionDate", assoc.getLastExecutionDate().toEpochMilli() / 1000.0);
|
||||
desc.put("LastExecutionDate", EpochSeconds.fromInstant(assoc.getLastExecutionDate()));
|
||||
}
|
||||
if (assoc.getComplianceSeverity() != null) {
|
||||
desc.put("ComplianceSeverity", assoc.getComplianceSeverity());
|
||||
@@ -1319,7 +1320,7 @@ public class SsmJsonHandler {
|
||||
}
|
||||
node.put("Type", p.getType());
|
||||
node.put("Version", p.getVersion());
|
||||
node.put("LastModifiedDate", p.getLastModifiedDate().toEpochMilli() / 1000.0);
|
||||
node.put("LastModifiedDate", EpochSeconds.fromInstant(p.getLastModifiedDate()));
|
||||
node.put("ARN", p.getArn());
|
||||
if (p.getDataType() != null) {
|
||||
node.put("DataType", p.getDataType());
|
||||
@@ -1404,7 +1405,7 @@ public class SsmJsonHandler {
|
||||
ObjectNode node = objectMapper.createObjectNode();
|
||||
node.put("SettingId", s.getSettingId());
|
||||
node.put("SettingValue", s.getSettingValue());
|
||||
node.put("LastModifiedDate", s.getLastModifiedDate().toEpochMilli() / 1000.0);
|
||||
node.put("LastModifiedDate", EpochSeconds.fromInstant(s.getLastModifiedDate()));
|
||||
node.put("LastModifiedUser", s.getLastModifiedUser());
|
||||
node.put("ARN", s.getArn());
|
||||
node.put("Status", s.getStatus());
|
||||
@@ -1489,8 +1490,8 @@ public class SsmJsonHandler {
|
||||
node.put("DocumentName", c.getDocumentName());
|
||||
if (c.getDocumentVersion() != null) node.put("DocumentVersion", c.getDocumentVersion());
|
||||
if (c.getComment() != null) node.put("Comment", c.getComment());
|
||||
if (c.getRequestedDateTime() != null) node.put("RequestedDateTime", c.getRequestedDateTime().toEpochMilli() / 1000.0);
|
||||
if (c.getExpiresAfter() != null) node.put("ExpiresAfter", c.getExpiresAfter().toEpochMilli() / 1000.0);
|
||||
if (c.getRequestedDateTime() != null) node.put("RequestedDateTime", EpochSeconds.fromInstant(c.getRequestedDateTime()));
|
||||
if (c.getExpiresAfter() != null) node.put("ExpiresAfter", EpochSeconds.fromInstant(c.getExpiresAfter()));
|
||||
// c is the same live, shared Command object SsmCommandService's writers (updateCommandStatus,
|
||||
// cancelCommand) synchronize on before touching Status/StatusDetails together. Reading the
|
||||
// pair here without the same lock would let this read straddle a concurrent writer's update -
|
||||
@@ -1528,7 +1529,7 @@ public class SsmJsonHandler {
|
||||
if (inv.getComment() != null) node.put("Comment", inv.getComment());
|
||||
node.put("DocumentName", inv.getDocumentName());
|
||||
if (inv.getDocumentVersion() != null) node.put("DocumentVersion", inv.getDocumentVersion());
|
||||
if (inv.getRequestedDateTime() != null) node.put("RequestedDateTime", inv.getRequestedDateTime().toEpochMilli() / 1000.0);
|
||||
if (inv.getRequestedDateTime() != null) node.put("RequestedDateTime", EpochSeconds.fromInstant(inv.getRequestedDateTime()));
|
||||
// Same reasoning as commandToNode: inv is the same live, shared CommandInvocation object its
|
||||
// writers (cancelCommand, direct/agent completion, timeout sweeps) now synchronize on.
|
||||
synchronized (inv) {
|
||||
@@ -1563,8 +1564,8 @@ public class SsmJsonHandler {
|
||||
if (info.getIpAddress() != null) node.put("IPAddress", info.getIpAddress());
|
||||
if (info.getComputerName() != null) node.put("ComputerName", info.getComputerName());
|
||||
node.put("ResourceType", info.getResourceType());
|
||||
if (info.getLastPingDateTime() != null) node.put("LastPingDateTime", info.getLastPingDateTime().toEpochMilli() / 1000.0);
|
||||
if (info.getRegistrationDate() != null) node.put("RegistrationDate", info.getRegistrationDate().toEpochMilli() / 1000.0);
|
||||
if (info.getLastPingDateTime() != null) node.put("LastPingDateTime", EpochSeconds.fromInstant(info.getLastPingDateTime()));
|
||||
if (info.getRegistrationDate() != null) node.put("RegistrationDate", EpochSeconds.fromInstant(info.getRegistrationDate()));
|
||||
return node;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ import io.github.hectorvent.floci.config.EmulatorConfig;
|
||||
import io.github.hectorvent.floci.core.common.AwsArnUtils;
|
||||
import io.github.hectorvent.floci.core.common.AwsException;
|
||||
import io.github.hectorvent.floci.core.common.AwsRegions;
|
||||
import io.github.hectorvent.floci.core.common.EpochSeconds;
|
||||
import io.github.hectorvent.floci.core.common.PaginatedResult;
|
||||
import io.github.hectorvent.floci.core.common.Pagination;
|
||||
import io.github.hectorvent.floci.core.common.Resettable;
|
||||
@@ -307,7 +308,7 @@ public class SsoAdminService implements Resettable {
|
||||
}
|
||||
|
||||
public double regionAddedDateEpochSeconds(RegionMetadata region) {
|
||||
return Instant.parse(region.addedDate()).toEpochMilli() / 1000.0d;
|
||||
return EpochSeconds.fromInstant(Instant.parse(region.addedDate()));
|
||||
}
|
||||
|
||||
public synchronized TrustedTokenIssuer createTrustedTokenIssuer(JsonNode request, String callerAccountId) {
|
||||
|
||||
@@ -6,6 +6,7 @@ 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.core.common.EpochSeconds;
|
||||
import io.github.hectorvent.floci.core.common.JsonErrorResponseUtils;
|
||||
import io.github.hectorvent.floci.core.common.PaginatedResult;
|
||||
import io.github.hectorvent.floci.services.transfer.model.HomeDirectoryMapping;
|
||||
@@ -359,7 +360,7 @@ public class TransferHandler {
|
||||
kNode.put("SshPublicKeyId", k.getSshPublicKeyId());
|
||||
kNode.put("SshPublicKeyBody", k.getSshPublicKeyBody());
|
||||
if (k.getDateImported() != null) {
|
||||
kNode.put("DateImported", k.getDateImported().toEpochMilli() / 1000.0);
|
||||
kNode.put("DateImported", EpochSeconds.fromInstant(k.getDateImported()));
|
||||
}
|
||||
keys.add(kNode);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user