Loading…
Loading…
Discovers and synchronizes APIs and services from a Perforce Akana API Platform instance. Explains the discovery workflow, data mapping, and configuration.
The Akana Discovery Service automates the discovery of APIs and services from a Perforce Akana API Platform instance. It connects to the Akana Platform Management REST API, fetches all consumer-facing APIs and backend business services, and synchronizes them with the platform's service catalog.
This service is designed for API publishers who use Akana as an API gateway and need to maintain an up-to-date inventory of their services within this platform. The service runs as a discovery pass for a specific, pre-configured Akana instance.
Its primary inputs are the credentials for an Akana instance, identified by a gatewayType of akana and a unique instanceName. Its main output is the creation and updating of records in the s2r_discovered_service database table. It also deactivates records for services that are no longer present in the Akana instance.
The discovery process executes a series of steps to query the Akana API, process the results, and persist them to the local database.
flowchart TD
subgraph "Initialization"
A[Start runDiscovery] --> B{Load Credentials};
B --> C[Instantiate Akana API Client];
end
subgraph "Data Fetching"
C --> D[GET /api/apis];
C --> E[GET /api/services];
D --> F[For each API];
F --> G[GET /api/apis/:id];
E --> H[For each Service];
H --> I[GET /api/services/:id];
end
subgraph "Data Processing & Persistence"
G --> J[Map API to Discovered Entry];
I --> K[Map Service to Discovered Entry];
J --> L[Collect All Entries];
K --> L;
L --> M[Upsert into s2r_discovered_service];
M --> N[Mark Stale Services Inactive];
end
subgraph "Completion"
N --> O[Return DiscoveryResult];
O --> P[End];
endThe service follows this sequence of operations:
runDiscovery method is invoked with a gatewayType and instanceName. It retrieves the decrypted credentials (host, port, username, password) for the specified Akana instance from the s2r_lb_connector_credentials table via the LbConnectorCredentialService.AkanaPlatformClient is created to communicate with the Akana Platform Management REST API. If a port is not specified in the credentials, it defaults to 9900./api/apis endpoint to get a list of all consumer-facing APIs. For each API in the list, it sends a follow-up request to /api/apis/{id} to fetch its detailed configuration./api/services endpoint to get a list of all business services (backend mappings). For each service, it sends a follow-up request to /api/services/{id} for its details.vendor_service_id is created with the format api:<id> for APIs and service:<id> for services.displayName is constructed from the service's name and version fields (e.g., PaymentService v2.0).endpointUrl field.raw_metadata field for auditing and troubleshooting.s2r_discovered_service table.
vendor_service_id already exists, its record is updated with the latest information, and its is_active flag is set to true.is_active flag to false.DiscoveryResult object containing statistics for the run, including the number of services discovered, added, updated, and marked inactive, along with a list of any errors encountered.NOTE
The field names used to extract data from the Akana API responses (e.g., id, ApiID, name, version, endpointUrl) are based on public documentation. The service attempts to use several common variants for each field, as these may differ across Akana firmware versions. The complete response is stored in the raw_metadata field for manual validation if needed.
The service maps data from the Akana API to fields in the s2r_discovered_service table as follows:
s2r_discovered_service Field | Source Akana Concept / Logic |
|---|---|
vendor_service_id | A string identifier prefixed with api: or service:, followed by the Akana entity's ID. Example: api:12345. |
display_name | Constructed as name + " v" + version. If version is absent, it is just the name. |
frontend_host | The host parsed from the Akana endpointUrl. Falls back to the host from the connector credentials if parsing fails. |
frontend_port | The port parsed from the endpointUrl. |
frontend_protocol | The scheme (e.g., http, https) parsed from the endpointUrl. Defaults to https if not present. |
backend_pool_name | Always null. Akana APIs are mapped to a single backend implementation service, not a pool. |
backend_members | A JSON array containing a single object representing the backend. The uri, host, port, and protocol are derived from the Akana endpointUrl. |
raw_metadata | The full JSON object returned from the Akana detail endpoint (/api/apis/{id} or /api/services/{id}), excluding internal fields like _rawBody. |
is_active | Set to true if the service was found in the latest discovery run, false otherwise. |
The service exposes a single public method to initiate a discovery pass.
runDiscoveryTriggers a full discovery pass for a configured Akana instance.
DiscoveryResult runDiscovery(String gatewayType, String instanceName)
Parameters:
| Name | Type | Description |
|---|---|---|
gatewayType | String | The type of the gateway. Must be akana. |
instanceName | String | The unique name of the Akana instance to discover, as configured in the connector credentials. |
Returns:
A DiscoveryResult object containing the outcome of the discovery pass. The structure includes:
| Field | Type | Description |
|---|---|---|
totalDiscovered | long | The total number of APIs and services found in the Akana instance. |
newlyAdded | long | The number of new services inserted into the database. |
updated | long | The number of existing services updated in the database. |
markedInactive | long | The number of stale services marked as inactive. |
durationMs | long | The total time taken for the discovery pass, in milliseconds. |
errors | List<String> | A list of error messages generated during the run. |
Exceptions:
LbConnectorCredentialService.NotFoundException: Thrown if credentials for the specified gatewayType and instanceName are not found in the system.To use the Akana Discovery Service, you must first configure the connection credentials for the target Akana instance. This is managed by the LbConnectorCredentialService.
The following credential fields are required for an akana connector instance:
| Field | Type | Required | Default | Description |
|---|---|---|---|---|
host | String | Yes | — | The hostname or IP address of the Akana Platform Management API. |
port | Integer | No | 9900 | The port for the Akana Platform Management API. |
username | String | Yes | — | The username for authenticating to the Akana API. |
password | String | Yes | — | The password for the specified username. |
verifyTls | Boolean | No | — | Whether to verify the TLS certificate of the Akana host. The source does not define a default. |
When a discovery run fails or encounters issues, it records errors in the DiscoveryResult object. The following error codes and messages may appear:
| Error Code | Message | Cause |
|---|---|---|
S2R-LBC-0502 | failed to build Akana client: <message> | An error occurred while initializing the AkanaPlatformClient. This could be due to invalid configuration or an internal issue. |
S2R-LBC-0401 | Akana auth failed listing APIs: <message> | Authentication failed when trying to list all APIs (GET /api/apis). Check the username and password in the connector credentials. |
S2R-LBC-0401 | Akana auth failed listing services: <message> | Authentication failed when trying to list all services (GET /api/services). Check the username and password. |
S2R-LBC-0401 | Akana auth failed for API <id>: <message> | Authentication failed when fetching details for a specific API. This may indicate a permissions issue with the provided credentials. |
S2R-LBC-0401 | Akana auth failed for service <id>: <message> | Authentication failed when fetching details for a specific business service. |
S2R-LBC-0502 | Akana listApis failed: <message> | A non-authentication error occurred while listing APIs. This could be a network issue or an error from the Akana platform. |
S2R-LBC-0502 | Akana listServices failed: <message> | A non-authentication error occurred while listing business services. |
S2R-LBC-0502 | error fetching API <id>: <message> | A non-authentication error occurred while fetching details for a specific API. |
S2R-LBC-0502 | error fetching service <id>: <message> | A non-authentication error occurred while fetching details for a specific business service. |
S2R-LBC-0502 | DB persist error: <message> | An exception occurred during the database transaction to upsert discovered services. This indicates a problem with the database connection or schema. |
If runDiscovery throws an LbConnectorCredentialService.NotFoundException, it means no credentials have been configured for the provided gatewayType: 'akana' and instanceName.