Skip to content

Commit 940ad97

Browse files
author
Chris Wiechmann
committed
Merge branch 'develop' into test-with-7.7-20200130
2 parents af7f34d + b9c5a60 commit 940ad97

172 files changed

Lines changed: 3564 additions & 1169 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.travis.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,9 @@ before_install:
3030
#- sudo apt-get install curl
3131
# All files in this folder will be cached for the next build
3232
- mkdir -p $CACHE_DIR
33-
# Login to the Docker-Registry
34-
- if [ ! -f $CACHE_FILE_APIM ]; then docker login --username $AXWAY_DOCKER_REG_USER --password $AXWAY_DOCKER_REG_PASS docker-registry.demo.axway.com; fi
3533
# Downloading the APIM-Docker-Image takes too long (Timeout 10 minutes) - Externalized to make use of travis_wait
3634
# In this script, we are either using the cached version or download a new Docker-Image
37-
- travis_wait build/pull_apim_docker_image.sh $CACHE_FILE_APIM
35+
- travis_wait build/pull_apim_docker_image.sh
3836
# Now it's time to safe the downloaded API-Management Docker-Image into the cache folder
3937
- if [ ! -f $CACHE_FILE_APIM ]; then docker save $APIM_DOCKER_IMAGE | gzip > $CACHE_FILE_APIM; fi
4038
# Pull Cassandra Image or use the cache

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,25 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
99
- Search for APIs based on configured Inbound- and Outbound-Security (See issue [#86](https://github.com/Axway-API-Management-Plus/apim-cli/issues/86))
1010
- Added support for API-Manager Config/Alerts/Remote-Hosts (See issue [#68](https://github.com/Axway-API-Management-Plus/apim-cli/issues/68))
1111
- APIs now updated without Re-Creating them if possible (See issue [#95](https://github.com/Axway-API-Management-Plus/apim-cli/issues/95))
12+
- Support to manage the full Remote-Host introduced with the API-Manager September/2020 release
13+
- Capability to filter APIs based on their organization
14+
- New command to approve one or more APIs that are in pending state (See issue [#97](https://github.com/Axway-API-Management-Plus/apim-cli/issues/97))
15+
- Script apim.sh and apim.bat now optionally use AXWAY_APIM_CLI_HOME to setup the classpath (See issue [#100](https://github.com/Axway-API-Management-Plus/apim-cli/issues/100))
16+
- Staging support for applications, users and organizations
17+
- Support for custom properties for applications, users and organizations (See issue [#93](https://github.com/Axway-API-Management-Plus/apim-cli/issues/93))
1218

1319
### Fixed
1420
- Avoid NPE during API-Export if custom-properties config is inconsistent (See issue [#90](https://github.com/Axway-API-Management-Plus/apim-cli/issues/90))
1521
- Disabled applications not created as disabled (See issue [#89](https://github.com/Axway-API-Management-Plus/apim-cli/issues/89))
1622
- Support for special characters like an accent (See issue [#88](https://github.com/Axway-API-Management-Plus/apim-cli/issues/88))
1723
- Organizations now validated based on given stage (See issue [#58](https://github.com/Axway-API-Management-Plus/apim-cli/issues/58))
1824
- API-Import is now stopped if host and backendBasepath is missing (See issue [#53](https://github.com/Axway-API-Management-Plus/apim-cli/issues/53))
25+
- Command-Line option with or without arguments can now be given interchangeable (See issue [#102](https://github.com/Axway-API-Management-Plus/apim-cli/issues/102))
26+
- apim.bat now works with or without JAVA_HOME set (See issue [#105](https://github.com/Axway-API-Management-Plus/apim-cli/issues/105))
27+
28+
### Changed
29+
- APIs no longer Re-Created if not needed (See issue [#95](https://github.com/Axway-API-Management-Plus/apim-cli/issues/95))
30+
- CLI Options parser refactored to be more flexible and support future requirements (See PR [#103](https://github.com/Axway-API-Management-Plus/apim-cli/pull/103))
1931

2032
## [1.2.3] 2020-09-24
2133
### Added

build/pull_apim_docker_image.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
#!/bin/sh
22

3-
if [ -f $CACHE_FILE_APIM ]
3+
if [ -f $CACHE_FILE_APIM -a "$SKIP_CACHE" != "true" ]
44
then
5-
echo "Loading API-Manager docker image: $APIM_DOCKER_IMAGE from $CACHE_FILE_APIM"
5+
echo "Using cached API-Manager docker image: $APIM_DOCKER_IMAGE from $CACHE_FILE_APIM"
66
gunzip -c $CACHE_FILE_APIM | docker load
77
else
88
echo "Pulling APIM docker from registry, this will take a while"
9+
docker login --username $AXWAY_DOCKER_REG_USER --password $AXWAY_DOCKER_REG_PASS docker-registry.demo.axway.com
910
docker pull $APIM_DOCKER_IMAGE
1011
fi

distribution/assembly/dist-release.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<include>com.github.axway-api-management-plus.apim-cli:apimcli-apps</include>
1818
<include>com.github.axway-api-management-plus.apim-cli:apimcli-organizations</include>
1919
<include>com.github.axway-api-management-plus.apim-cli:apimcli-users</include>
20-
<include>com.github.axway-api-management-plus.apim-cli:apimcli-setup</include>
20+
<include>com.github.axway-api-management-plus.apim-cli:apimcli-settings</include>
2121
<include>com.github.axway-api-management-plus.apim-cli:apimcli-tool</include>
2222
</includes>
2323
<binaries>

distribution/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
</dependency>
3939
<dependency>
4040
<groupId>com.github.axway-api-management-plus.apim-cli</groupId>
41-
<artifactId>apimcli-setup</artifactId>
41+
<artifactId>apimcli-settings</artifactId>
4242
</dependency>
4343
</dependencies>
4444

modules/apim-adapter/assembly/conf/env.properties.sample

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,18 @@ admin_password=changeme
6565
# want.
6666
# The following example maps the return code 10 (NO_CHANGE) and 56 (UNKNOWN_API) into a SUCCESS.
6767
# Call api-import with option: -returnCode to see all possible return codes.
68-
# returnCodeMapping=10:0, 56:0
68+
# returnCodeMapping=10:0, 56:0
69+
70+
# If a published API can be updated without the need to re-import the
71+
# backend API (e.g. changing a policy, tags, etc.), the frontend API is unpublished,
72+
# changed and then republished.
73+
# This process only takes a few seconds, but technically leads to a short downtime for consumers.
74+
# The advantage is that in this mode the API-ID and used runtime quotas of applications are preserved.
75+
# This is the default behavior since version 1.3.0.
76+
#
77+
# You can set the switch zeroDowntimeUpdate to true to update APIs with zero downtime as before.
78+
# That means that when updating a published API, the CLI always creates a completely new API,
79+
# configures it according to the old API and finally clients are switched to the new API.
80+
# This new API then has a new ID and runtime quotas are lost. The configured quotas are
81+
# transferred to the new API.
82+
# zeroDowntimeUpdate=true

modules/apim-adapter/src/main/java/com/axway/apim/adapter/APIManagerAdapter.java

Lines changed: 17 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@
88
import java.util.Collection;
99
import java.util.Date;
1010
import java.util.HashMap;
11-
import java.util.Iterator;
1211
import java.util.List;
1312
import java.util.Map;
14-
import java.util.Map.Entry;
1513

1614
import org.apache.commons.io.IOUtils;
1715
import org.apache.http.Header;
@@ -44,6 +42,8 @@
4442
import com.axway.apim.adapter.apis.APIManagerQuotaAdapter;
4543
import com.axway.apim.adapter.apis.APIManagerRemoteHostsAdapter;
4644
import com.axway.apim.adapter.clientApps.APIMgrAppsAdapter;
45+
import com.axway.apim.adapter.customProperties.APIManager762CustomPropertiesAdapter;
46+
import com.axway.apim.adapter.customProperties.APIManagerCustomPropertiesAdapter;
4747
import com.axway.apim.adapter.user.APIManagerUserAdapter;
4848
import com.axway.apim.api.model.CaCert;
4949
import com.axway.apim.api.model.Image;
@@ -60,7 +60,6 @@
6060
import com.axway.apim.lib.utils.rest.GETRequest;
6161
import com.axway.apim.lib.utils.rest.POSTRequest;
6262
import com.axway.apim.lib.utils.rest.RestAPICall;
63-
import com.fasterxml.jackson.core.JsonParser;
6463
import com.fasterxml.jackson.databind.JsonNode;
6564
import com.fasterxml.jackson.databind.ObjectMapper;
6665

@@ -99,18 +98,12 @@ public class APIManagerAdapter {
9998
public final static String TYPE_FRONT_END = "proxies";
10099
public final static String TYPE_BACK_END = "apirepo";
101100

102-
public static enum CUSTOM_PROP_TYPE {
103-
api,
104-
user,
105-
organization,
106-
application
107-
}
108-
109101
private CoreParameters cmd;
110102

111103
private static CacheManager cacheManager;
112104

113105
public APIManagerConfigAdapter configAdapter;
106+
public APIManagerCustomPropertiesAdapter customPropertiesAdapter;
114107
public APIManagerAlertsAdapter alertsAdapter;
115108
public APIManagerRemoteHostsAdapter remoteHostsAdapter;
116109
public APIManagerAPIAdapter apiAdapter;
@@ -167,7 +160,21 @@ public static synchronized void deleteInstance() throws AppException {
167160
private APIManagerAdapter() throws AppException {
168161
super();
169162
this.cmd = CoreParameters.getInstance();
163+
cmd.validateRequiredParameters();
164+
170165
this.configAdapter = new APIManagerConfigAdapter();
166+
167+
if(TestIndicator.getInstance().isTestRunning()) {
168+
this.hasAdminAccount = true; // For unit tests we have an admin account
169+
} else {
170+
// No need to login, when running unit tests
171+
loginToAPIManager(false); // Login with the provided user (might be an Org-Admin)
172+
loginToAPIManager(true); // Second, login if needed with an admin account
173+
APIManagerAdapter.apiManagerVersion = configAdapter.getConfig(false).getProductVersion();
174+
}
175+
176+
// For now this okay, may be replaced with a Factory later
177+
this.customPropertiesAdapter = (hasAPIManagerVersion("7.7")) ? new APIManagerCustomPropertiesAdapter() : new APIManager762CustomPropertiesAdapter();
171178
this.alertsAdapter = new APIManagerAlertsAdapter();
172179
this.remoteHostsAdapter = new APIManagerRemoteHostsAdapter();
173180
this.apiAdapter = new APIManagerAPIAdapter();
@@ -179,13 +186,6 @@ private APIManagerAdapter() throws AppException {
179186
this.oauthClientAdapter = new APIManagerOAuthClientProfilesAdapter();
180187
this.appAdapter = new APIMgrAppsAdapter();
181188
this.userAdapter = new APIManagerUserAdapter();
182-
if(TestIndicator.getInstance().isTestRunning()) {
183-
this.hasAdminAccount = true; // For unit tests we have an admin account
184-
return; // No need to initialize just for Unit-Tests
185-
}
186-
187-
loginToAPIManager(false); // Login with the provided user (might be an Org-Admin)
188-
loginToAPIManager(true); // Second, login if needed with an admin account
189189
}
190190

191191
public void loginToAPIManager(boolean useAdminClient) throws AppException {
@@ -546,67 +546,6 @@ public static String getApiManagerName() throws AppException {
546546
return APIManagerAdapter.apiManagerName;
547547
}
548548

549-
public static Map<String, String> getAllConfiguredCustomProperties(CUSTOM_PROP_TYPE type) {
550-
Map<String, String> allCustomProps = new HashMap<String, String>();
551-
try {
552-
JsonNode appConfig = getCustomPropertiesConfig();
553-
JsonNode apiCustomProps = appConfig.get(type.name());
554-
if(apiCustomProps==null) return null;
555-
Iterator<Entry<String, JsonNode>> it = apiCustomProps.fields();
556-
while(it.hasNext()) {
557-
Entry<String, JsonNode> entry = it.next();
558-
allCustomProps.put(entry.getKey(), null);
559-
}
560-
return allCustomProps;
561-
} catch (Exception e) {
562-
LOG.error("Error loading configured custom properties from API-Manager", e);
563-
return null;
564-
}
565-
}
566-
567-
public static JsonNode getCustomPropertiesConfig() throws AppException {
568-
569-
String appConfig = null;
570-
URI uri;
571-
HttpEntity httpResponse = null;
572-
try {
573-
uri = new URIBuilder(CoreParameters.getInstance().getAPIManagerURL()).setPath("/vordel/apiportal/app/app.config").build();
574-
RestAPICall getRequest = new GETRequest(uri);
575-
httpResponse = getRequest.execute().getEntity();
576-
appConfig = IOUtils.toString(httpResponse.getContent(), "UTF-8");
577-
return parseAppConfig(appConfig);
578-
} catch (Exception e) {
579-
throw new AppException("Can't read app.config from API-Manager: '" + appConfig + "'", ErrorCode.API_MANAGER_COMMUNICATION, e);
580-
} finally {
581-
try {
582-
if(httpResponse!=null)
583-
((CloseableHttpResponse)httpResponse).close();
584-
} catch (Exception ignore) {}
585-
}
586-
}
587-
588-
/**
589-
* Helper method to validate that configured Custom-Properties are really configured
590-
* in the API-Manager configuration.<br>
591-
* Will become obsolete sine the API-Manager REST-API provides an endpoint for that.
592-
* @param appConfig from the API-Manager (which isn't JSON)
593-
* @return JSON-Configuration with the custom-properties section
594-
* @throws AppException if the app.config can't be parsed
595-
*/
596-
public static JsonNode parseAppConfig(String appConfig) throws AppException {
597-
ObjectMapper mapper = new ObjectMapper();
598-
try {
599-
appConfig = appConfig.substring(appConfig.indexOf("customPropertiesConfig:")+23, appConfig.indexOf("wizardModels"));
600-
//appConfig = appConfig.substring(0, appConfig.length()-1); // Remove the tail comma
601-
mapper.configure(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES, true);
602-
mapper.configure(JsonParser.Feature.ALLOW_COMMENTS, true);
603-
mapper.configure(JsonParser.Feature.ALLOW_SINGLE_QUOTES, true);
604-
return mapper.readTree(appConfig);
605-
} catch (Exception e) {
606-
throw new AppException("Can't parse API-Manager app.config.", ErrorCode.API_MANAGER_COMMUNICATION, e);
607-
}
608-
}
609-
610549
/**
611550
* Helper method to fulfill the given certificates by the API-Developer into the required
612551
* format as it's needed by the API-Manager.

0 commit comments

Comments
 (0)