Create an Extension for API ML
Create an Extension for API ML
Zowe allows extenders to define their own extension for API ML.
#
API ML Services with Class Path Extension SupportFor API ML services with extension support, extension executables can be loaded by setting the shared library path variable that corresponds to the particular service.
Service | Extension directory environment variable |
---|---|
API Gateway | ZWE_GATEWAY_SHARED_LIBS |
Discovery Service | ZWE_DISCOVERY_SHARED_LIBS |
#
API ML Services with Library Path Extension SupportThe API Gateway can load native Java libraries by setting ZWE_GATEWAY_LIBRARY_PATH
to a path pointing to the native library.
#
Example API Gateway ExtensionFollow the steps in this article to create your extension. The example in this article is for an extension of the API Gateway.
Note: The api-sample-extension-package
contains a sample manifest.yml
, and the apiml-sample-extension
JAR that contains the extension.
Follow these steps:
- Create a JAR file from your extension. See the API ML sample extension to model the format of the JAR.
- Create a
manifest.yml
with the following structure. See the samplemanifest.yml
to model the format of the yaml file.
For more information, see Packaging z/OS extensions.
Example:
```yaml---name: apiml-extension# Component identifier. This identifier matches artifact path in Zowe Artifactory https://zowe.jfrog.io/.id: org.zowe.apiml.sdk.apiml-extension-package# Component version is defined in gradle.properties for Gradle project# Human readable component nametitle: Your extension for API ML# Human readable component descriptiondescription: JAR that contains the API ML extension.license: EPL-2.0repository:type: giturl: https://github.com/zowe/api-layer.gitbuild:branch: "{{build.branch}}"number: "{{build.number}}"commitHash: "{{build.commitHash}}"timestamp: "{{build.timestamp}}"# The following block contains all the extensions directory path# (or file path) that will be included in the API MLgatewaySharedLibs: - path/to/my/lib1/ - path/to/my/lib2/```
The ZWE_GATEWAY_SHARED_LIBS
environment variable points to the
extension directory <instance>/workspace/gateway/sharedLibs/
.
The extension directory is then added to the API Gateway class path as part of the Zowe instance preparation.
Note: The paths defined under gatewaySharedLibs
can either be a path to the directory where the extensions JARs are located, or a path to the files.
Example:
gatewaySharedLibs: - path/to/my/lib1/extension1.jar - path/to/my/lib2/extension2.jar
After the JAR file and manifest.yml
are customized according to your application, the extension is extracted, scanned, and added to the extension directory during the Zowe instance preparation. When the API Gateway starts, the API Gateway consumes the sample extension.
The extension should now be correctly added to the API Gateway classpath.
#
Call the REST endpoint for validationFollow these steps to validate that you can call the REST endpoint defined in the controller via the API Gateway:
- Call the
https://<hostname>:<gatewayPort>/api/v1/greeting
endpoint though Gateway. - Verify that you receive the message,
Hello, I'm a sample extension!
as the response.