diff --git a/README.md b/README.md
index 66ff7d24c7..eb3506c9c8 100644
--- a/README.md
+++ b/README.md
@@ -239,7 +239,7 @@ Floci supports local emulation for application services, data services, eventing
| Databases and caching | RDS, RDS Data API, Neptune, DocumentDB, MemoryDB, ElastiCache |
| Messaging and transfer | SES, Kinesis, MSK, Amazon MQ, Transfer Family, DataSync, IoT Core, Amazon Connect, Amazon AppIntegrations |
| Security and governance | AWS Network Firewall, AWS RAM, Service Quotas, WAF v2, GuardDuty, Amazon Inspector, CloudTrail, CloudFront, Resource Groups Tagging API, Resource Explorer 2, CloudHSM v2, Organizations, AWS Account Management, IAM Access Analyzer, IAM Identity Center (SSO Admin, OIDC, Access Portal, SCIM), Identity Store, Amazon Macie, Amazon Detective, Security Hub, Amazon Verified Permissions, Control Catalog, Control Tower, Service Catalog, AWS Marketplace |
-| Cost and billing | AWS Budgets, Pricing, Cost Explorer, Cost and Usage Reports, BCM Data Exports |
+| Cost and billing | AWS Budgets, Pricing, Cost Explorer, Cost and Usage Reports, BCM Pricing Calculator, BCM Data Exports |
| Resilience, backup, and config | AWS FIS, AWS Backup, AWS Config, AppConfig, AppConfigData, CloudFormation, Cloud Control API |
For operation-level compatibility, see the [Services Overview](https://floci.io/floci/services/).
@@ -328,6 +328,7 @@ For operation-level compatibility, see the [Services Overview](https://floci.io/
| Pricing | In-process with static snapshot | Product discovery, attributes, price list files, pagination |
| Cost Explorer | In-process | Cost synthesized from Floci resource state and pricing snapshots |
| Cost and Usage Reports | In-process with floci-duck sidecar | CUR 2.0 and FOCUS 1.2 columns, account-scoped storage, Parquet emission |
+| BCM Pricing Calculator | In-process | Workload estimate create, usage pricing, read, and delete lifecycle |
| BCM Data Exports | In-process | Export lifecycle, executions, update and delete operations |
diff --git a/compatibility-tests/sdk-test-java/pom.xml b/compatibility-tests/sdk-test-java/pom.xml
index 3f0d2288fb..46e275ec65 100644
--- a/compatibility-tests/sdk-test-java/pom.xml
+++ b/compatibility-tests/sdk-test-java/pom.xml
@@ -517,6 +517,11 @@
software.amazon.awssdk
oam
+
+
+ software.amazon.awssdk
+ bcmpricingcalculator
+
software.amazon.awssdk
diff --git a/compatibility-tests/sdk-test-java/src/main/java/com/floci/test/TestFixtures.java b/compatibility-tests/sdk-test-java/src/main/java/com/floci/test/TestFixtures.java
index baa8938f2f..0d892fcae2 100644
--- a/compatibility-tests/sdk-test-java/src/main/java/com/floci/test/TestFixtures.java
+++ b/compatibility-tests/sdk-test-java/src/main/java/com/floci/test/TestFixtures.java
@@ -39,6 +39,7 @@ import software.amazon.awssdk.services.ssoadmin.SsoAdminClient;
import software.amazon.awssdk.services.ssooidc.SsoOidcClient;
import software.amazon.awssdk.services.identitystore.IdentitystoreClient;
import software.amazon.awssdk.services.budgets.BudgetsClient;
+import software.amazon.awssdk.services.bcmpricingcalculator.BcmPricingCalculatorClient;
import software.amazon.awssdk.services.macie2.Macie2Client;
import software.amazon.awssdk.services.controlcatalog.ControlCatalogClient;
import software.amazon.awssdk.services.marketplacecatalog.MarketplaceCatalogClient;
@@ -1303,6 +1304,14 @@ public final class TestFixtures {
.build();
}
+ public static BcmPricingCalculatorClient bcmPricingCalculatorClient() {
+ return BcmPricingCalculatorClient.builder()
+ .endpointOverride(ENDPOINT)
+ .region(REGION)
+ .credentialsProvider(CREDENTIALS)
+ .build();
+ }
+
public static ResourceExplorer2Client resourceExplorer2Client() {
return resourceExplorer2Client(REGION);
}
diff --git a/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/BcmPricingCalculatorTest.java b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/BcmPricingCalculatorTest.java
new file mode 100644
index 0000000000..0e013f4e18
--- /dev/null
+++ b/compatibility-tests/sdk-test-java/src/test/java/com/floci/test/BcmPricingCalculatorTest.java
@@ -0,0 +1,53 @@
+package com.floci.test;
+
+import org.junit.jupiter.api.Test;
+import software.amazon.awssdk.services.bcmpricingcalculator.BcmPricingCalculatorClient;
+import software.amazon.awssdk.services.bcmpricingcalculator.model.BatchCreateWorkloadEstimateUsageEntry;
+import software.amazon.awssdk.services.bcmpricingcalculator.model.BatchCreateWorkloadEstimateUsageRequest;
+import software.amazon.awssdk.services.bcmpricingcalculator.model.CreateWorkloadEstimateRequest;
+import software.amazon.awssdk.services.bcmpricingcalculator.model.DeleteWorkloadEstimateRequest;
+import software.amazon.awssdk.services.bcmpricingcalculator.model.GetWorkloadEstimateRequest;
+import software.amazon.awssdk.services.bcmpricingcalculator.model.WorkloadEstimateRateType;
+import software.amazon.awssdk.services.bcmpricingcalculator.model.WorkloadEstimateStatus;
+
+import java.util.List;
+
+import static org.junit.jupiter.api.Assertions.*;
+
+class BcmPricingCalculatorTest {
+ @Test
+ void workloadEstimateLifecycle() {
+ try (BcmPricingCalculatorClient client = TestFixtures.bcmPricingCalculatorClient()) {
+ var created = client.createWorkloadEstimate(CreateWorkloadEstimateRequest.builder()
+ .name("sdk-estimate")
+ .clientToken("sdk-estimate-token")
+ .rateType(WorkloadEstimateRateType.BEFORE_DISCOUNTS)
+ .build());
+ assertNotNull(created.id());
+
+ var batch = client.batchCreateWorkloadEstimateUsage(BatchCreateWorkloadEstimateUsageRequest.builder()
+ .workloadEstimateId(created.id())
+ .clientToken("sdk-usage-token")
+ .usage(List.of(BatchCreateWorkloadEstimateUsageEntry.builder()
+ .serviceCode("AmazonEC2")
+ .usageType("BoxUsage:t3.micro")
+ .operation("")
+ .key("sdk1")
+ .usageAccountId("000000000000")
+ .group("compute")
+ .amount(730d)
+ .build()))
+ .build());
+ assertTrue(batch.errors().isEmpty());
+ assertEquals(1, batch.items().size());
+
+ var estimate = client.getWorkloadEstimate(GetWorkloadEstimateRequest.builder()
+ .identifier(created.id()).build());
+ assertEquals(WorkloadEstimateStatus.VALID, estimate.status());
+ assertEquals(7.592d, estimate.totalCost(), 0.000001d);
+
+ client.deleteWorkloadEstimate(DeleteWorkloadEstimateRequest.builder()
+ .identifier(created.id()).build());
+ }
+ }
+}
diff --git a/docs/services/bcm-pricing-calculator.md b/docs/services/bcm-pricing-calculator.md
new file mode 100644
index 0000000000..3e5134bf68
--- /dev/null
+++ b/docs/services/bcm-pricing-calculator.md
@@ -0,0 +1,62 @@
+# BCM Pricing Calculator (`bcm-pricing-calculator:*`)
+
+**Protocol:** AWS JSON 1.0
+**Header:** `X-Amz-Target: AWSBCMPricingCalculator.`
+**Endpoint prefix:** `bcm-pricing-calculator`
+
+Floci emulates the workload-estimate path of the in-console AWS Pricing Calculator. Usage lines are priced from Floci's bundled AWS Pricing snapshots, so estimates stay deterministic and require no external network access.
+
+## Supported operations
+
+| Operation | Notes |
+|---|---|
+| `CreateWorkloadEstimate` | Creates an account-scoped workload estimate and honors `clientToken` idempotency |
+| `BatchCreateWorkloadEstimateUsage` | Adds 1 to 25 usage lines and recalculates the estimate total |
+| `GetWorkloadEstimate` | Returns the estimate status, rate metadata, currency, and total cost |
+| `DeleteWorkloadEstimate` | Idempotent; also removes the estimate's usage lines |
+
+## Pricing behavior
+
+`BatchCreateWorkloadEstimateUsage` resolves each usage line by `serviceCode`, `usageType`, and, when supplied, `operation`. The matching On-Demand price dimension from the Pricing service snapshot determines the unit and USD rate. The usage amount is multiplied by that rate and the estimate total is recalculated synchronously.
+
+Floci currently models `BEFORE_DISCOUNTS` with the bundled public On-Demand rates. The AWS API also accepts `AFTER_DISCOUNTS` and `AFTER_DISCOUNTS_AND_COMMITMENTS`; these values are preserved on the estimate, but Floci does not have account-specific negotiated rates or purchase commitments to alter the calculated amount.
+
+## Validation and lifecycle
+
+- Workload estimate names use AWS's `[a-zA-Z0-9-]+` shape and are limited to 64 characters.
+- Estimate identifiers use the AWS 36-character lowercase UUID shape.
+- `clientToken` supports AWS idempotency semantics. Reusing a token with conflicting create parameters returns `ConflictException`.
+- Batch requests accept 1 to 25 entries.
+- Usage keys are at most 10 alphanumeric characters and `usageAccountId` is exactly 12 digits.
+- A successful local calculation is stored as `VALID`; Floci performs the calculation synchronously rather than exposing a temporary `UPDATING` state.
+- Currency is `USD`.
+- Deleting an already-absent valid identifier succeeds, matching the idempotent delete contract.
+
+## Configuration
+
+| Variable | Default | Description |
+|---|---|---|
+| `FLOCI_SERVICES_BCM_PRICING_CALCULATOR_ENABLED` | `true` | Enable or disable the service |
+
+## Example
+
+```bash
+export AWS_ENDPOINT_URL=http://localhost:4566
+export AWS_DEFAULT_REGION=us-east-1
+export AWS_ACCESS_KEY_ID=test
+export AWS_SECRET_ACCESS_KEY=test
+
+estimate_id=$(aws bcm-pricing-calculator create-workload-estimate \
+ --name example-estimate \
+ --rate-type BEFORE_DISCOUNTS \
+ --client-token example-create \
+ --query id --output text)
+
+aws bcm-pricing-calculator batch-create-workload-estimate-usage \
+ --workload-estimate-id "$estimate_id" \
+ --client-token example-usage \
+ --usage '[{"serviceCode":"AmazonEC2","usageType":"BoxUsage:t3.micro","operation":"","key":"ec2a","usageAccountId":"000000000000","amount":730}]'
+
+aws bcm-pricing-calculator get-workload-estimate --identifier "$estimate_id"
+aws bcm-pricing-calculator delete-workload-estimate --identifier "$estimate_id"
+```
diff --git a/docs/services/index.md b/docs/services/index.md
index 7d0986233b..17891bf351 100644
--- a/docs/services/index.md
+++ b/docs/services/index.md
@@ -131,6 +131,7 @@ Operation counts are exact. For dispatch-table services (Query and JSON 1.1) eac
| [Pricing](pricing.md) | `POST /` + `X-Amz-Target: AWSPriceListService.*` | JSON 1.1 | 5 |
| [Cost Explorer](ce.md) | `POST /` + `X-Amz-Target: AWSInsightsIndexService.*` | JSON 1.1 | 9 |
| [Cost and Usage Reports](cur.md) | `POST /` + `X-Amz-Target: AWSOrigamiServiceGatewayService.*` | JSON 1.1 | 6 |
+| [BCM Pricing Calculator](bcm-pricing-calculator.md) | `POST /` + `X-Amz-Target: AWSBCMPricingCalculator.*` | JSON 1.0 | 4 |
| [BCM Data Exports](bcm-data-exports.md) | `POST /` + `X-Amz-Target: AWSBillingAndCostManagementDataExports.*` | JSON 1.1 | 7 |
| [Transfer Family](transfer.md) | `POST /` + `X-Amz-Target: TransferService.*` | JSON 1.1 | 17 |
| [DataSync](datasync.md) | `POST /` + `X-Amz-Target: FmrsService.*` | JSON 1.1 | 48 |
diff --git a/mkdocs.yml b/mkdocs.yml
index b45cca9cf7..a98cd39aad 100644
--- a/mkdocs.yml
+++ b/mkdocs.yml
@@ -210,6 +210,7 @@ nav:
- Pricing: services/pricing.md
- Cost Explorer: services/ce.md
- Cost and Usage Reports: services/cur.md
+ - BCM Pricing Calculator: services/bcm-pricing-calculator.md
- BCM Data Exports: services/bcm-data-exports.md
- Testcontainers:
- Overview: testcontainers/index.md
diff --git a/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java b/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java
index 0aa7eb9e72..2363c6ea03 100644
--- a/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java
+++ b/src/main/java/io/github/hectorvent/floci/config/EmulatorConfig.java
@@ -704,6 +704,7 @@ public interface EmulatorConfig {
CurServiceConfig cur();
BcmDataExportsServiceConfig bcmDataExports();
OamServiceConfig oam();
+ BcmPricingCalculatorServiceConfig bcmPricingCalculator();
ConfigServiceConfig configservice();
CloudTrailServiceConfig cloudtrail();
CloudControlServiceConfig cloudcontrol();
@@ -1928,6 +1929,11 @@ public interface EmulatorConfig {
boolean enabled();
}
+ interface BcmPricingCalculatorServiceConfig {
+ @WithDefault("true")
+ boolean enabled();
+ }
+
interface BcmDataExportsServiceConfig {
@WithDefault("true")
boolean enabled();
diff --git a/src/main/java/io/github/hectorvent/floci/core/common/AwsJsonController.java b/src/main/java/io/github/hectorvent/floci/core/common/AwsJsonController.java
index 5c48f6ca7a..a858986302 100644
--- a/src/main/java/io/github/hectorvent/floci/core/common/AwsJsonController.java
+++ b/src/main/java/io/github/hectorvent/floci/core/common/AwsJsonController.java
@@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectReader;
import io.github.hectorvent.floci.services.cloudcontrol.CloudControlJsonHandler;
+import io.github.hectorvent.floci.services.bcmpricingcalculator.BcmPricingCalculatorJsonHandler;
import io.github.hectorvent.floci.services.cloudwatch.metrics.CloudWatchMetricsJsonHandler;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbJsonHandler;
import io.github.hectorvent.floci.services.dynamodb.DynamoDbResponses;
@@ -53,6 +54,7 @@ public class AwsJsonController {
private final NetworkFirewallJsonHandler networkFirewallJsonHandler;
private final MarketplaceJsonHandler marketplaceJsonHandler;
private final VerifiedPermissionsJsonHandler verifiedPermissionsJsonHandler;
+ private final BcmPricingCalculatorJsonHandler bcmPricingCalculatorJsonHandler;
@Inject
public AwsJsonController(ObjectMapper objectMapper, ResolvedServiceCatalog catalog,
@@ -66,7 +68,8 @@ public class AwsJsonController {
SwfJsonHandler swfJsonHandler,
NetworkFirewallJsonHandler networkFirewallJsonHandler,
MarketplaceJsonHandler marketplaceJsonHandler,
- VerifiedPermissionsJsonHandler verifiedPermissionsJsonHandler) {
+ VerifiedPermissionsJsonHandler verifiedPermissionsJsonHandler,
+ BcmPricingCalculatorJsonHandler bcmPricingCalculatorJsonHandler) {
this.objectMapper = objectMapper;
this.strictBodyReader = objectMapper.reader().with(DeserializationFeature.FAIL_ON_TRAILING_TOKENS);
this.catalog = catalog;
@@ -82,6 +85,7 @@ public class AwsJsonController {
this.networkFirewallJsonHandler = networkFirewallJsonHandler;
this.marketplaceJsonHandler = marketplaceJsonHandler;
this.verifiedPermissionsJsonHandler = verifiedPermissionsJsonHandler;
+ this.bcmPricingCalculatorJsonHandler = bcmPricingCalculatorJsonHandler;
}
@POST
@@ -134,6 +138,7 @@ public class AwsJsonController {
action, request, region, regionResolver.getAccountId());
case "marketplace" -> marketplaceJsonHandler.handle(action, request, region);
case "verifiedpermissions" -> verifiedPermissionsJsonHandler.handle(action, request, region);
+ case "bcm-pricing-calculator" -> bcmPricingCalculatorJsonHandler.handle(action, request, region);
default -> null;
};
// catalog.matchTarget is protocol-agnostic: a JSON 1.1 target
diff --git a/src/main/java/io/github/hectorvent/floci/core/common/ResolvedServiceCatalog.java b/src/main/java/io/github/hectorvent/floci/core/common/ResolvedServiceCatalog.java
index bb70d135b9..b45fa57570 100644
--- a/src/main/java/io/github/hectorvent/floci/core/common/ResolvedServiceCatalog.java
+++ b/src/main/java/io/github/hectorvent/floci/core/common/ResolvedServiceCatalog.java
@@ -555,6 +555,11 @@ public class ResolvedServiceCatalog {
"cur", config.storage().mode(), 5000L, null, ServiceProtocol.JSON,
protocols(ServiceProtocol.JSON),
Set.of("AWSOrigamiServiceGatewayService."), Set.of("cur"), Set.of(), Set.of()),
+ descriptor("bcm-pricing-calculator", "bcmpricingcalculator",
+ config.services().bcmPricingCalculator().enabled(), true,
+ "bcmpricingcalculator", config.storage().mode(), 5000L, null, ServiceProtocol.JSON,
+ protocols(ServiceProtocol.JSON),
+ Set.of("AWSBCMPricingCalculator."), Set.of("bcm-pricing-calculator"), Set.of(), Set.of()),
descriptor("bcm-data-exports", "bcmdataexports", config.services().bcmDataExports().enabled(), true,
"bcmdataexports", config.storage().mode(), 5000L, null, ServiceProtocol.JSON,
protocols(ServiceProtocol.JSON),
diff --git a/src/main/java/io/github/hectorvent/floci/services/bcmpricingcalculator/BcmPricingCalculatorJsonHandler.java b/src/main/java/io/github/hectorvent/floci/services/bcmpricingcalculator/BcmPricingCalculatorJsonHandler.java
new file mode 100644
index 0000000000..5f04c65a0e
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/bcmpricingcalculator/BcmPricingCalculatorJsonHandler.java
@@ -0,0 +1,135 @@
+package io.github.hectorvent.floci.services.bcmpricingcalculator;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import io.github.hectorvent.floci.core.common.AwsErrorResponse;
+import io.github.hectorvent.floci.core.common.AwsException;
+import io.github.hectorvent.floci.services.bcmpricingcalculator.model.WorkloadEstimate;
+import io.github.hectorvent.floci.services.bcmpricingcalculator.model.WorkloadEstimateUsage;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.inject.Inject;
+import jakarta.ws.rs.core.Response;
+
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+@ApplicationScoped
+public class BcmPricingCalculatorJsonHandler {
+ private final BcmPricingCalculatorService service;
+ private final ObjectMapper objectMapper;
+
+ @Inject
+ public BcmPricingCalculatorJsonHandler(BcmPricingCalculatorService service, ObjectMapper objectMapper) {
+ this.service = service;
+ this.objectMapper = objectMapper;
+ }
+
+ public Response handle(String action, JsonNode request, String region) {
+ try {
+ return switch (action) {
+ case "CreateWorkloadEstimate" -> create(request);
+ case "BatchCreateWorkloadEstimateUsage" -> batchCreateUsage(request);
+ case "GetWorkloadEstimate" -> get(request);
+ case "DeleteWorkloadEstimate" -> delete(request);
+ default -> Response.status(400).entity(new AwsErrorResponse(
+ "UnknownOperationException", "Unknown operation: AWSBCMPricingCalculator." + action)).build();
+ };
+ } catch (AwsException e) {
+ throw e;
+ }
+ }
+
+ private Response create(JsonNode request) {
+ WorkloadEstimate estimate = service.create(text(request, "name"), text(request, "clientToken"),
+ text(request, "rateType"), stringMap(request.path("tags")));
+ return Response.ok(estimateNode(estimate)).build();
+ }
+
+ private Response batchCreateUsage(JsonNode request) {
+ List entries = new ArrayList<>();
+ JsonNode usage = request.path("usage");
+ if (usage.isArray()) {
+ for (JsonNode item : usage) {
+ entries.add(new BcmPricingCalculatorService.UsageInput(
+ text(item, "serviceCode"), text(item, "usageType"), text(item, "operation"),
+ text(item, "key"), text(item, "usageAccountId"), text(item, "group"),
+ item.path("amount").isNumber() ? item.path("amount").asDouble() : Double.NaN));
+ }
+ }
+ BcmPricingCalculatorService.UsageBatchResult result = service.batchCreateUsage(
+ text(request, "workloadEstimateId"), entries, text(request, "clientToken"));
+ ObjectNode out = objectMapper.createObjectNode();
+ ArrayNode items = out.putArray("items");
+ result.items().forEach(item -> items.add(usageNode(item)));
+ ArrayNode errors = out.putArray("errors");
+ result.errors().forEach(error -> {
+ ObjectNode node = errors.addObject();
+ if (error.key() != null) node.put("key", error.key());
+ node.put("errorCode", error.errorCode());
+ node.put("errorMessage", error.errorMessage());
+ });
+ return Response.ok(out).build();
+ }
+
+ private Response get(JsonNode request) {
+ return Response.ok(estimateNode(service.get(text(request, "identifier")))).build();
+ }
+
+ private Response delete(JsonNode request) {
+ service.delete(text(request, "identifier"));
+ return Response.ok(objectMapper.createObjectNode()).build();
+ }
+
+ private ObjectNode estimateNode(WorkloadEstimate e) {
+ ObjectNode out = objectMapper.createObjectNode();
+ out.put("id", e.getId());
+ out.put("name", e.getName());
+ out.put("createdAt", epochSeconds(e.getCreatedAt()));
+ out.put("expiresAt", epochSeconds(e.getExpiresAt()));
+ out.put("rateType", e.getRateType());
+ out.put("rateTimestamp", epochSeconds(e.getRateTimestamp()));
+ out.put("status", e.getStatus());
+ out.put("totalCost", e.getTotalCost());
+ out.put("costCurrency", e.getCostCurrency());
+ return out;
+ }
+
+ private ObjectNode usageNode(WorkloadEstimateUsage u) {
+ ObjectNode out = objectMapper.createObjectNode();
+ out.put("serviceCode", u.getServiceCode());
+ out.put("usageType", u.getUsageType());
+ out.put("operation", u.getOperation());
+ if (u.getLocation() != null) out.put("location", u.getLocation());
+ out.put("id", u.getId());
+ out.put("usageAccountId", u.getUsageAccountId());
+ if (u.getGroup() != null) out.put("group", u.getGroup());
+ ObjectNode quantity = out.putObject("quantity");
+ quantity.put("unit", u.getUnit());
+ quantity.put("amount", u.getAmount());
+ out.put("cost", u.getCost());
+ out.put("currency", u.getCurrency());
+ out.put("status", u.getStatus());
+ out.put("key", u.getKey());
+ return out;
+ }
+
+ private static double epochSeconds(java.time.Instant instant) {
+ return instant.getEpochSecond() + instant.getNano() / 1_000_000_000.0;
+ }
+
+ private static String text(JsonNode node, String field) {
+ JsonNode value = node == null ? null : node.get(field);
+ return value == null || value.isNull() ? null : value.asText();
+ }
+
+ private static Map stringMap(JsonNode node) {
+ if (node == null || !node.isObject()) return null;
+ Map out = new LinkedHashMap<>();
+ node.fields().forEachRemaining(entry -> out.put(entry.getKey(), entry.getValue().asText()));
+ return out;
+ }
+}
diff --git a/src/main/java/io/github/hectorvent/floci/services/bcmpricingcalculator/BcmPricingCalculatorService.java b/src/main/java/io/github/hectorvent/floci/services/bcmpricingcalculator/BcmPricingCalculatorService.java
new file mode 100644
index 0000000000..887072168d
--- /dev/null
+++ b/src/main/java/io/github/hectorvent/floci/services/bcmpricingcalculator/BcmPricingCalculatorService.java
@@ -0,0 +1,228 @@
+package io.github.hectorvent.floci.services.bcmpricingcalculator;
+
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import io.github.hectorvent.floci.core.common.AwsException;
+import io.github.hectorvent.floci.core.common.RegionResolver;
+import io.github.hectorvent.floci.core.storage.StorageBackend;
+import io.github.hectorvent.floci.core.storage.StorageFactory;
+import io.github.hectorvent.floci.services.bcmpricingcalculator.model.WorkloadEstimate;
+import io.github.hectorvent.floci.services.bcmpricingcalculator.model.WorkloadEstimateUsage;
+import io.github.hectorvent.floci.services.pricing.PricingService;
+import jakarta.enterprise.context.ApplicationScoped;
+import jakarta.inject.Inject;
+
+import java.time.Instant;
+import java.time.temporal.ChronoUnit;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+import java.util.regex.Pattern;
+
+@ApplicationScoped
+public class BcmPricingCalculatorService {
+ private static final Pattern NAME = Pattern.compile("[a-zA-Z0-9-]+");
+ private static final Pattern ACCOUNT = Pattern.compile("\\d{12}");
+ private static final List RATE_TYPES = List.of(
+ "BEFORE_DISCOUNTS", "AFTER_DISCOUNTS", "AFTER_DISCOUNTS_AND_COMMITMENTS");
+
+ public record UsageInput(String serviceCode, String usageType, String operation, String key,
+ String usageAccountId, String group, double amount) {}
+ public record UsageError(String key, String errorCode, String errorMessage) {}
+ public record UsageBatchResult(List items, List errors) {}
+
+ private final StorageBackend estimates;
+ private final StorageBackend usages;
+ private final RegionResolver regionResolver;
+ private final PricingService pricingService;
+ private final ObjectMapper objectMapper;
+
+ @Inject
+ public BcmPricingCalculatorService(StorageFactory storageFactory, RegionResolver regionResolver,
+ PricingService pricingService, ObjectMapper objectMapper) {
+ this(storageFactory.create("bcmpricingcalculator", "workload-estimates.json",
+ new TypeReference