Loading…
Loading…
Manage API operations, including REST endpoints, schemas, and asynchronous behavior. This reference details methods for finding, updating, and
The OperationRepository is a data access component responsible for creating, reading, and updating API operations in the platform's database. It serves as the canonical source for an individual operation's configuration, including its REST endpoint mapping, backend SOAP details, runtime behaviors like timeouts and retries, and asynchronous processing settings.
This component solves the problem of persisting and managing the detailed configuration for each operation within a service version. It is primarily used by the administrative services of the platform. When an operation is updated, OperationRepository performs the database write and also triggers a critical side effect: synchronizing the operation's state with the s2r_runtime_route table. This ensures that changes made in the admin plane are correctly reflected in the runtime routing layer that handles live traffic.
The OperationRepository manages records in the s2r_operation database table. Each record represents a single API operation and contains all its configuration. The primary mechanism for modification is the update method, which orchestrates a series of validation, persistence, and synchronization steps.
When an operation is updated, the following sequence occurs:
draft and it is not the active version). Attempts to modify an operation belonging to an active or non-draft version will fail.rest_method is converted to uppercase, rest_path is prefixed with a / if missing, and numeric values like timeout_ms are checked to be within allowed ranges.execution_mode. If the mode is not async_callback, any callback-related fields are cleared. If the callback authentication mode is shared_secret, a callback_secret_ref is required.s2r_operation table is updated with the new configuration values.syncRuntimeRoute method is called to reflect the changes in the runtime routing table (s2r_runtime_route).The following diagram illustrates the data flow for an operation update:
sequenceDiagram
participant Admin Service
participant Operation Repository
participant Platform Database
Admin Service->>Operation Repository: update(operationId, ...)
Operation Repository->>Platform Database: Find operation by ID
Operation Repository->>Platform Database: Check if service version is editable
alt Not an editable draft version
Operation Repository->>Admin Service: Throw IllegalStateException
end
Operation Repository->>Operation Repository: Validate and normalize parameters
Operation Repository->>Platform Database: UPDATE s2r_operation table
Operation Repository->>Operation Repository: syncRuntimeRoute(operationId)
Note over Operation Repository,Platform Database: Synchronize with runtime routing table
Operation Repository->>Platform Database: SELECT data for runtime route
alt Route should be published
Operation Repository->>Platform Database: Check for route collisions
Operation Repository->>Platform Database: UPSERT into s2r_runtime_route table
else Route should not be published
Operation Repository->>Platform Database: DELETE from s2r_runtime_route table
end
Operation Repository->>Platform Database: Find updated operation by ID
Operation Repository->>Admin Service: Return updated OperationRecordThe syncRuntimeRoute method ensures the runtime gateway has the correct routing information.
s2r_runtime_route table only if the operation is enabled, its parent service version is active, and the parent service's status is not disabled. If these conditions are not met, any existing entry for the operation is deleted from the runtime route table.direction, environment, rest_method, and rest_path. This check prevents two services from unintentionally claiming the same endpoint.INSERT ... ON CONFLICT DO UPDATE (upsert) operation. This creates a new route if one doesn't exist or updates the existing one if the route path is already claimed by the same service. The conflict is detected on the unique key (direction, environment, rest_method, rest_path).route_hash) is computed from the route's key components (direction, environment, method, path) to uniquely identify the route configuration.The primary interface for modification is the update method within the OperationRepository class. The source does not provide an HTTP endpoint example, but illustrates the programmatic call signature.
// This is a Java method signature, not a direct API endpoint.
public OperationRecord update(UUID operationId,
String restMethod,
String restPath,
Integer timeoutMs,
Integer retryCount,
String executionMode,
String callbackPath,
String callbackAuthMode,
String callbackSecretRef,
Integer asyncAckHttpStatus,
String actor)
Usage: To modify an operation, a caller would invoke this method with the operationId and a set of new configuration values. Any parameter provided as null will be ignored, and the existing value for that field will be retained. Upon successful execution, the method returns the complete, updated OperationRecord.
The following parameters can be provided to the update method to configure an operation.
| Name | Type | Description |
|---|---|---|
operationId | UUID | Required. The unique identifier of the operation to update. |
restMethod | String | The HTTP method for the REST endpoint. Supported values: GET, POST, PUT, PATCH, DELETE. The value is case-insensitive and trimmed. |
restPath | String | The path for the REST endpoint. Cannot be empty. If it does not start with /, one will be prepended. |
timeoutMs | Integer | The downstream request timeout in milliseconds. Must be between 1 and 60000. |
retryCount | Integer | The number of times to retry a failed downstream request. Must be between 0 and 10. |
executionMode | String | The processing mode. Supported values: sync, async_callback. Defaults to sync if null or blank. |
callbackPath | String | The path for the callback endpoint in async_callback mode. If it does not start with /, one will be prepended. This field is ignored and set to null if executionMode is not async_callback. |
callbackAuthMode | String | The authentication mode for the callback. Supported values: none, shared_secret. Defaults to none. This field is ignored if executionMode is not async_callback. |
callbackSecretRef | String | A reference to the secret used for shared_secret callback authentication. Required when callbackAuthMode is shared_secret. This field is ignored if executionMode is not async_callback. |
asyncAckHttpStatus | Integer | The HTTP status code to return as an acknowledgement in async_callback mode. Must be a 2xx status code (200-299). Defaults to 202. This field is ignored if executionMode is not async_callback. |
actor | String | An identifier for the user or system performing the update. Defaults to system if null or blank. |
The OperationRecord represents the full configuration of an operation stored in the database.
| Field | Type | Description |
|---|---|---|
id | UUID | The unique identifier for the operation. |
service_version_id | UUID | The ID of the service version this operation belongs to. |
operation_key | String | A system-generated key for the operation. |
soap_operation_name | String | The name of the corresponding SOAP operation in the WSDL. |
soap_action | String | The SOAPAction header value for the backend SOAP request. |
rest_method | String | The HTTP method of the exposed REST endpoint. |
rest_path | String | The path of the exposed REST endpoint. |
enabled | boolean | Whether this operation is enabled for runtime routing. |
timeout_ms | int | The backend request timeout in milliseconds. |
retry_count | int | The number of retries for failed backend requests. |
debug_enabled | boolean | A flag to enable debug logging for this operation. |
execution_mode | String | The execution mode (sync or async_callback). |
callback_path | String | The callback path for asynchronous operations. |
callback_auth_mode | String | The authentication mode for asynchronous callbacks. |
callback_secret_ref | String | The secret reference for shared_secret callback authentication. |
async_ack_http_status | int | The HTTP status code for asynchronous acknowledgements. |
created_at | OffsetDateTime | Timestamp of when the operation was created. |
updated_at | OffsetDateTime | Timestamp of when the operation was last updated. |
The OperationRepository class exposes the following public methods for managing operations.
| Method | Description |
|---|---|
List<OperationRecord> findByServiceVersion(UUID serviceId, UUID versionId) | Finds all operations belonging to a specific service version. |
Optional<OperationRecord> findById(UUID operationId) | Finds a single operation by its unique ID. Returns an empty optional if not found. |
Optional<OperationContractRecord> findContractById(UUID operationId) | Finds an operation's contract (ID, key, and JSON schemas) by its ID. |
OperationRecord update(...) | Updates an operation's configuration. See the Configuration Parameters table for details. |
OperationContractRecord updateSchemas(UUID operationId, Map<String, Object> requestSchema, Map<String, Object> responseSchema, String actor) | Updates the request and response JSON schemas for an operation. |
int backfillGeneratedGetOperations() | A system maintenance method that iterates through GET operations and changes them to POST based on heuristics defined in WsdlRestRouteHeuristics. |
When interacting with the OperationRepository, you may encounter the following exceptions:
| Exception | Trigger | Meaning |
|---|---|---|
IllegalArgumentException | An input parameter fails validation. | The request contains invalid data. The exception message will specify the error, such as "operation not found", "unsupported rest method", "timeout_ms must be between 1 and 60000", or "callback_secret_ref is required when callback_auth_mode=shared_secret". |
IllegalStateException | The operation's service version is not in a mutable state (e.g., it is active or not a draft). | The operation cannot be modified because it is part of a locked or active service version. You must create a new draft version to make changes. |
| Route Collision | An attempt is made to publish a route (method and path) that is already in use by a different service in the same environment. | This is detected by the RouteCollisionGuard and will cause the update transaction to fail. The route path must be unique per environment and direction. |
EmptyResultDataAccessException | An operation is not found during the syncRuntimeRoute process. | This can happen if the operation is deleted between the initial update and the sync step. The exception is caught and ignored, effectively treating it as a "not found" condition. |
RouteCollisionGuard: A component responsible for preventing route conflicts between different services.WsdlRestRouteHeuristics: A component providing logic to determine if a generated GET operation should be converted to a POST.gov.specaria.service.ServiceDirection: A shared component for normalizing service direction values (e.g., PUBLISH, CONSUME).