-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Create API ML sample extension (#1947)
* Create and package sample extension Signed-off-by: at670475 <[email protected]> * ADD the path to the jar Signed-off-by: at670475 <[email protected]> * Fix gradle creation of jar Signed-off-by: at670475 <[email protected]> * Add doc Signed-off-by: at670475 <[email protected]> * Remove jib Signed-off-by: at670475 <[email protected]> * Clean up dependencies Signed-off-by: at670475 <[email protected]> * skip sonar scan Signed-off-by: at670475 <[email protected]> * package controller and dependencies Signed-off-by: achmelo <[email protected]> * Create and package sample extension Signed-off-by: at670475 <[email protected]> * ADD the path to the jar Signed-off-by: at670475 <[email protected]> * Fix gradle creation of jar Signed-off-by: at670475 <[email protected]> * Add doc Signed-off-by: at670475 <[email protected]> * Remove jib Signed-off-by: at670475 <[email protected]> * Clean up dependencies Signed-off-by: at670475 <[email protected]> * skip sonar scan Signed-off-by: at670475 <[email protected]> * package controller and dependencies Signed-off-by: achmelo <[email protected]> * Address requests Signed-off-by: at670475 <[email protected]> * Update doc Signed-off-by: at670475 <[email protected]> * Replace back icon to use material Signed-off-by: at670475 <[email protected]> * Revert change Signed-off-by: at670475 <[email protected]> * Fix action Signed-off-by: at670475 <[email protected]> * attempt Signed-off-by: at670475 <[email protected]> * Attempt 2 Signed-off-by: at670475 <[email protected]> * Attempt 3 Signed-off-by: at670475 <[email protected]> * Fix PR name Signed-off-by: at670475 <[email protected]> * Fix extension path Signed-off-by: at670475 <[email protected]> * Fix extension path Signed-off-by: at670475 <[email protected]> * Fix extension path Signed-off-by: at670475 <[email protected]> * Change extension package to be included in the component scan Signed-off-by: at670475 <[email protected]> * debug loader path Signed-off-by: achmelo <[email protected]> * remove debug logs Signed-off-by: achmelo <[email protected]> Co-authored-by: achmelo <[email protected]>
- Loading branch information
Showing
11 changed files
with
197 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* This program and the accompanying materials are made available under the terms of the | ||
* Eclipse Public License v2.0 which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-v20.html | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Copyright Contributors to the Zowe Project. | ||
*/ | ||
|
||
ext { | ||
artifactName = 'apiml-sample-extension-package' | ||
pullNo = project.hasProperty("pullRequest") && project.getProperty("pullRequest") != null ? "-" + project.getProperty("pullRequest") : "" | ||
} | ||
|
||
configurations { | ||
sampleExtensionJar | ||
zip | ||
} | ||
|
||
dependencies { | ||
sampleExtensionJar(project(path: ":apiml-sample-extension")) | ||
} | ||
|
||
task packageSampleExtension(type: Zip) { | ||
archiveName = artifactName + pullNo + ".zip" | ||
includeEmptyDirs = true | ||
def resourceDir = 'src/main/resources/' | ||
|
||
into('/') { | ||
from "$resourceDir/manifest.yaml" | ||
} | ||
|
||
into('bin/') { | ||
from configurations.sampleExtensionJar | ||
} | ||
} | ||
|
||
jar.dependsOn(packageSampleExtension) | ||
build.dependsOn(packageSampleExtension) | ||
|
||
artifacts { | ||
zip packageSampleExtension | ||
} | ||
|
||
publishing { | ||
publications { | ||
mavenJava(MavenPublication) { | ||
artifact("$buildDir/distributions/$artifactName" + pullNo + ".zip") | ||
} | ||
} | ||
} | ||
|
||
jar { | ||
enabled false | ||
} |
23 changes: 23 additions & 0 deletions
23
apiml-sample-extension-package/src/main/resources/manifest.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
--- | ||
name: apiml-sample-extension | ||
# Component identifier. This identifier matches artifact path in Zowe Artifactory https://zowe.jfrog.io/. | ||
id: org.zowe.apiml.sdk.apiml-sample-extension-package | ||
# Component version is defined in gradle.properties for Gradle project | ||
# Human readable component name | ||
title: A sample extension for API ML | ||
# Human readable component description | ||
description: JAR that contains a simple controller. | ||
license: EPL-2.0 | ||
repository: | ||
type: git | ||
url: https://github.com/zowe/api-layer.git | ||
build: | ||
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 ML | ||
gatewaySharedLibs: | ||
- bin/apiml-sample-extension.jar | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# API ML sample extension | ||
|
||
This is an API ML sample extension. It only contains a simple controller for testing. | ||
The extension is added to the API Gateway class path. Therefore, as a result, the controller is added in the context | ||
of the API Gateway without starting a new service. | ||
|
||
## Usage | ||
|
||
If the extension is correctly added to the API Gateway classpath, it will be possible to | ||
call the REST endpoint defined in the controller via Gateway. | ||
The extension is scanned and added to the classpath during the Zowe instance preparation, therefore | ||
once the Gateway is started, you can: | ||
|
||
1. Call the `https://<hostname>:<gatewayPort>/api/v1/greeting` endpoint though Gateway | ||
2. Verify that you get the message `Hello, I'm a sample extension!` as response |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
buildscript { | ||
repositories mavenRepositories | ||
dependencies { | ||
classpath("gradle.plugin.com.gorylenko.gradle-git-properties:gradle-git-properties:${gradleGitPropertiesVersion}") | ||
classpath ("org.eclipse.jgit:org.eclipse.jgit:5.13.0.202109080827-r") { | ||
force = true | ||
} | ||
} | ||
} | ||
|
||
normalization { | ||
runtimeClasspath { | ||
ignore("**/*git.properties*") | ||
ignore("**/*build-info.properties*") | ||
} | ||
} | ||
|
||
apply plugin: 'com.gorylenko.gradle-git-properties' | ||
|
||
gitProperties { | ||
gitPropertiesDir = new File("${project.rootDir}/${name}/build/resources/main/META-INF") | ||
} | ||
|
||
dependencies { | ||
|
||
implementation libraries.springFox | ||
implementation libraries.spring_webmvc | ||
|
||
} | ||
|
||
jar { | ||
enabled true | ||
baseName = "apiml-sample-extension" | ||
archiveName = "${baseName}.jar" | ||
} | ||
|
||
publishing { | ||
publications { | ||
mavenJavaLib(MavenPublication) { | ||
artifact jar | ||
} | ||
} | ||
} | ||
|
31 changes: 31 additions & 0 deletions
31
apiml-sample-extension/src/main/java/org/zowe/apiml/gateway/api/GreetingController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* This program and the accompanying materials are made available under the terms of the | ||
* Eclipse Public License v2.0 which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-v20.html | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Copyright Contributors to the Zowe Project. | ||
*/ | ||
package org.zowe.apiml.gateway.api; | ||
|
||
import io.swagger.annotations.Api; | ||
import org.springframework.web.bind.annotation.*; | ||
|
||
/** | ||
* Controller that returns greetings. | ||
*/ | ||
@RestController | ||
@Api(tags = {"Other Operations"}) | ||
@RequestMapping("/api/v1") | ||
public class GreetingController { | ||
private static final String GREETING = "Hello, I'm a sample extension!"; | ||
|
||
/** | ||
* Gets a greeting for anyone. | ||
*/ | ||
@GetMapping(value = "/greeting") | ||
public String greeting() { | ||
return GREETING; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters