Agent SDK interfaces and classes

SDK interfaces and classes help to build runtime-specific agents.

Following are the list of classes that are located inside the api Jar in the SDK.

Config. The parent class - configuration file, which includes the following classes, each responsible for different aspects of federated API management and runtime configurations.

Classes Description
AuthConfig

Class for providing federated API management authentication configurations such as Basic auth, Token-based auth, Bearer token-based auth.

ControlPlaneConfig Class for providing the following federated API management configurations to which the runtime establishes connectivity - Control Plane URL, Control Plane username, and so on.
RuntimeConfig Class for providing the following runtime configurations that you want to administer from federated API management - Runtime ID, Name, Description, Type, and so on.
SdkConfig The top-level configuration class, which takes the inputs of Runtime configurations, Control Plane configurations, and asset sync intervals.
TlsConfig Class for providing the keystore and truststore configurations - keystorePath, truststorePath, keystorePassword, keyAlias, and so on.
HttpConnectionConfig Class for providing the HTTP connection-specific configurations - maxConnections, connectionTimeout, maxRetries

Interfaces

The list of interfaces that are located inside the api Jar in the SDK are as follows.

Interfaces Description
AgentSdkContextManual

Interface for implementing an agent by using manual approach. For details, see Agent implementation approaches section.

AgentSDKContextManaged

Interface for implementing an agent by using managed approach. For details, see Agent implementation approaches section.

SdkLogger Interface for customizing the logging functions. The SDK offers the following options to capture the logs.
  • DefaultAgentLogger. Agent SDK, by default offers the DefaultAgentLogger class for logging functions.
  • SdkLogger. If the developer wants to customize the logging functions provided by the SDK, the SdkLogger interface must be implemented.
SdkHttpClient Interface for customizing the HTTP client. The SDK offers the following options to implement the HTTP client.
  • DefaultHttpClient. Agent SDK, by default offers the DefaultHttpClient class to establish communication between the agent and the external entities (runtime and federated API management).
  • SdkHttpClient. If the developer wants to customize the HTTP client provided by the SDK, the SdkHttpClient interface must be implemented.

Agent SDK methods

The list of methods within classes and interfaces are as follows.

AgentSdkContextManual Interface methods

Methods Description
SdkConfig() The developer must implement this method to return federated API management specific and runtime specific configuration objects.
getLogger() The developer must implement this method to return the logger object.
getHttpClient() The developer must implement this method to return an HTTP client object, which establishes communication from the agent to the external entities (runtime and federated API management).
getHeartbeat() The developer must implement this method to return the heartbeat (health status) object.
getAPIs() The developer must implement this method to return the list of APIs object.
getMetrics() The developer must implement this method to return the list of metrics object for the transactions performed during the specified synchronization interval.
getAssetSyncActions() The developer must implement this method to return the list of asset sync action objects for the specified synchronization interval.

AgentSdkContextManaged interface methods

Methods Description
SdkConfig() The developer must implement this method to return federated API management specific and runtime specific configuration objects.
getLogger() The developer must implement this method to return the logger object.
getHttpClient() The developer must implement this method to return an HTTP client object, which establishes communication from the agent to the external entities (runtime and federated API management).
getRequestBuilders() The developer must implement this method to return the list of RequestBuilders object for fetching APIs, Heartbeats, and Metrics individually. The SDK uses these implementations to construct SdkRequests and sends it to the runtime.
getRuntimeResponseParserFactory() The developer must implement this method to return the ResponseParserFactory object for parsing the response that is received from the runtime to federated API management compatible model. The following methods build and return the parser,
  • getHeartbeatParser() - The developer must implement this method to return a HeartbeatResponseParser object, which parses the heartbeats to federated API management compatible heartbeat model.
  • getAPIParser() - The developer must implement this method to return an APIResponseParser object, which parses the APIs to federated API management compatible API model.
  • getMetricsParser() - The developer must implement this method to return a MetricsResponseParser object, which parses the metrics to federated API management compatible metrics model.

Common methods in all classes (Authconfig, TlsConfig, SdkConfig, ControlPlaneConfig, RuntimeConfig, HttpConnectionConfig)

Methods Description
Builder Creates an object with the mandatory fields that are needed for the class.
build()

Returns an object that is built from the values that are passed through the Builder class.

This method is used to create a new instance of the class with the needed information.

For example, understand the methods within the Authconfig class.

AuthConfig.Builder(agentConfiguration.controlPlaneUsername, 
agentConfiguration.controlPlanePassword) // Creates a Builder class with the following mandatory fields, controlPlaneUsername and controlPlanePassword 
.build(); // Creates an Authconfig object with controlPlaneUsername and controlPlanePassword  

SdkLogger interface methods

Methods Description
trace() The developer must implement this method to log the message at the trace level.
debug() The developer must implement this method to log the message at the debug level.
info() The developer must implement this method to log the message at the info level.
error() The developer must implement this method to log the message at the error level along with an exception object (if available).
logError(String msg, Throwable t) The developer must implement this method to log the errors without any message formatting along with an exception object (if available).

SdkHttpClient interface methods

Methods Description
execute() SDK has a default implementation for the execute() method, which facilitates the protocol specific SdkHttpRequest to external party and returns the corresponding SdkHttpResponse.
executeDelete() The developer must implement this method to execute the SdkHttpRequest for an external party by using the DELETE HTTP protocol and return the corresponding SdkHttpResponse.
executeGet() The developer must implement this method to execute the SdkHttpRequest for an external party by using the GET HTTP protocol and return the corresponding SdkHttpResponse.
executePost() The developer must implement this method to execute the SdkHttpRequest for an external party by using the POST HTTP protocol and return the corresponding SdkHttpResponse.
executePut() The developer must implement this method to execute the SdkHttpRequest for an external party by using the PUT HTTP protocol and return the corresponding SdkHttpResponse.