Loading…
Loading…
Manage individual API operations, including their REST endpoints, execution modes, schemas, and runtime route synchronization. For platform engineers.
The Operation Repository is a data access component responsible for managing individual API operations. An operation is a single function within an API service version, defined by its SOAP and REST characteristics, execution behavior, and data schemas. This component provides the low-level interface for creating, retrieving, and updating operations in the s2r_operation database table.
This repository is a critical part of the administration service. It is called by higher-level services to persist changes to an operation's configuration. Its primary responsibilities include:
s2r_runtime_route table, which makes the REST endpoint live and routable by the gateway.Every database query is automatically scoped to the current tenant, ensuring that modifications for one tenant cannot affect another.
The repository uses direct SQL queries via JdbcTemplate to interact with the database. The core logic revolves around updating an operation's record and then synchronizing that change to the runtime routing layer.
When an operation is updated via the update method, the system performs the following sequence:
OperationRecord from the database.draft state and not active. Active service versions are immutable. If the version is not editable, the update is rejected with an IllegalStateException.restMethod, timeoutMs) is validated against business rules. For example, timeout_ms must be between 1 and 60,000, and rest_method must be one of the allowed HTTP methods.UPDATE statement for the s2r_operation table. If an update parameter is not provided (is null), the existing value is preserved.syncRuntimeRoute method is called to reflect the changes in the runtime environment.The syncRuntimeRoute method is a critical process that makes an operation's REST endpoint available to API consumers.
flowchart TD
subgraph syncRuntimeRoute Flow
A[Start] --> B(Fetch operation, version, and service data);
B -- Not found --> B_end(End);
B -- Found --> C(Delete any existing route for this operation);
C --> D{Should publish route?<br/>(Operation enabled AND<br/>Version active AND<br/>Service not disabled)};
D -- No --> D_end(End);
D -- Yes --> E(Check for route collision with other services);
E -- Collision found --> F(Fail with error);
E -- No collision --> G(Calculate route hash);
G --> H(Upsert route into runtime routing table);
H --> H_end(End);
endThis flow ensures that:
rest_method or rest_path are correctly reflected in the routing table.direction, environment, rest_method, rest_path) is already in use by a different service. If a collision is detected, the operation update fails.route_hash (SHA-256) is generated for the route to uniquely identify it.s2r_runtime_route table is updated atomically using an INSERT ... ON CONFLICT DO UPDATE (upsert) statement, which claims the route for the current operation.The repository includes specific logic for configuring asynchronous operations (execution_mode = 'async_callback').
callback_auth_mode determines how the platform authenticates incoming callback requests. It defaults to shared_secret for security. To accept unauthenticated callbacks, it must be explicitly set to none.callback_auth_mode is shared_secret, a callback_secret_ref is required. To prevent accidental deletion, the callback_secret_ref is write-only. If an update request provides a blank or null value for the secret, the previously stored secret is retained. A new value must be explicitly provided to change it.execution_mode is changed from async_callback to sync, all callback-related fields (callback_path, callback_secret_ref) are automatically cleared (nullified).The backfillGeneratedGetOperations method provides a mechanism to correct misconfigured operations. It identifies all operations that were generated as GET requests and, based on heuristics from WsdlRestRouteHeuristics, determines if they should have been POST requests (e.g., if they have a request body schema).
When executed, it performs the following steps for each candidate operation:
GET operations within the current tenant.POST using WsdlRestRouteHeuristics.shouldForcePost.rest_method to POST.syncRuntimeRoute to update the corresponding runtime route, effectively changing the live endpoint from GET to POST.The repository exposes the following methods for managing operations.
updateUpdates the configuration of a single operation.
OperationRecord update(UUID operationId,
String restMethod,
String restPath,
Integer timeoutMs,
Integer retryCount,
String executionMode,
String callbackPath,
String callbackAuthMode,
String callbackSecretRef,
Integer asyncAckHttpStatus,
String actor)
IMPORTANT
This method can only be called on operations belonging to a service version in draft status. Attempting to update an operation in an active version will result in an IllegalStateException.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
operationId | UUID | Yes | The unique identifier of the operation to update. |
restMethod | String | No | The new REST HTTP method. If null, the current value is kept. Allowed values: GET, POST, PUT, PATCH, DELETE. |
restPath | String | No | The new REST URL path. If null, the current value is kept. Must start with /. |
timeoutMs | Integer | No | The request timeout in milliseconds. If null, the current value is kept. Must be between 1 and 60000. |
retryCount | Integer | No | The number of retries on failure. If null, the current value is kept. Must be between 0 and 10. |
executionMode | String | No | The execution mode. If null, defaults to sync. Allowed values: sync, async_callback. |
callbackPath | String | No | The callback URL path for async_callback mode. If null, the current value is kept. Cleared if executionMode is not async_callback. |
callbackAuthMode | String | No | The authentication mode for callbacks. If null, defaults to shared_secret. Allowed values: none, shared_secret. |
callbackSecretRef | String | No | A reference to the secret for shared_secret callback authentication (e.g., inline:<secret>). A null or blank value preserves the existing secret. |
asyncAckHttpStatus | Integer | No | The HTTP status code to return for an accepted async_callback request. If null, the current value is kept. Must be a 2xx status code. |
actor | String | No | The identifier of the user or system performing the update. If null or blank, defaults to system. |
Returns
An OperationRecord object representing the updated state of the operation.
updateSchemasUpdates the JSON request and response schemas for a single operation.
OperationContractRecord updateSchemas(UUID operationId,
Map<String, Object> requestSchema,
Map<String, Object> responseSchema,
String actor)
IMPORTANT
This method can only be called on operations belonging to a service version in draft status. Attempting to update an operation in an active version will result in an IllegalStateException.
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
operationId | UUID | Yes | The unique identifier of the operation to update. |
requestSchema | Map<String, Object> | No | The JSON request schema. If null, an empty schema ({}) is stored. |
responseSchema | Map<String, Object> | No | The JSON response schema. If null, an empty schema ({}) is stored. |
actor | String | No | The identifier of the user or system performing the update. If null or blank, defaults to system. |
Returns
An OperationContractRecord object representing the updated state of the operation's schemas.
| Method | Description |
|---|---|
List<OperationRecord> findByServiceVersion(UUID serviceId, UUID versionId) | Finds all operations associated with a specific service version, ordered by operation_key. |
Optional<OperationRecord> findById(UUID operationId) | Finds a single operation by its unique ID. |
Optional<OperationContractRecord> findContractById(UUID operationId) | Finds a single operation's data contract (including schemas) by its unique ID. |
OperationRecordRepresents the full configuration of an operation.
| Field | Type | Description |
|---|---|---|
id | UUID | The unique identifier of the operation. |
service_version_id | UUID | The ID of the parent service version. |
operation_key | String | A unique key for the operation within the service. |
soap_operation_name | String | The name of the original SOAP operation. |
soap_action | String | The SOAPAction header value from the WSDL. |
rest_method | String | The HTTP method for the REST endpoint. |
rest_path | String | The URL path for the REST endpoint. |
enabled | boolean | Whether the operation is enabled. |
timeout_ms | int | Request timeout in milliseconds. |
retry_count | int | Number of retries on failure. |
debug_enabled | boolean | Whether debug logging is enabled for this operation. |
execution_mode | String | sync or async_callback. |
callback_path | String | The path for asynchronous callbacks. |
callback_auth_mode | String | none or shared_secret. |
callback_secret_ref | String | Reference to the callback authentication secret. |
async_ack_http_status | int | The HTTP status returned for accepted async requests. |
created_at | OffsetDateTime | Timestamp of creation. |
updated_at | OffsetDateTime | Timestamp of the last update. |
OperationContractRecordRepresents the data contract of an operation, focusing on its schemas.
| Field | Type | Description |
|---|---|---|
id | UUID | The unique identifier of the operation. |
service_version_id | UUID | The ID of the parent service version. |
operation_key | String | A unique key for the operation within the service. |
soap_operation_name | String | The name of the original SOAP operation. |
request_schema | Map<String, Object> | The JSON request schema. |
response_schema | Map<String, Object> | The JSON response schema. |
| Error Condition | Trigger | Meaning |
|---|---|---|
IllegalArgumentException: operation not found | The provided operationId does not exist in the database for the current tenant. | The caller has specified an invalid operation ID. |
IllegalStateException: operation version is immutable | An attempt was made to update or updateSchemas for an operation in an active service version. | Operations can only be modified when their parent service version is in a draft state. |
IllegalArgumentException: unsupported rest method | The restMethod parameter is not one of GET, POST, PUT, PATCH, or DELETE. | The provided HTTP method is invalid. |
IllegalArgumentException: timeout_ms must be between 1 and 60000 | The timeoutMs parameter is outside the allowed range. | The timeout value is invalid. |
IllegalArgumentException: retry_count must be between 0 and 10 | The retryCount parameter is outside the allowed range. | The retry count is invalid. |
IllegalArgumentException: execution_mode must be... | The executionMode is not sync or async_callback. | The execution mode is invalid. |
IllegalArgumentException: callback_secret_ref is required... | callback_auth_mode is shared_secret but callback_secret_ref is not provided. | An async operation with shared secret auth must have a secret configured. |
RouteCollisionException (internal) | The syncRuntimeRoute process detects that the operation's REST endpoint conflicts with an existing route owned by a different service. | The update is rejected to prevent one service from hijacking another's endpoint. Change the rest_method or rest_path to resolve. |