Skip to content

Commit d329210

Browse files
author
Chris Wiechmann
committed
Merge branch 'develop' into test-with-7.7-20200130
2 parents 2af0dc8 + 5d5cb8e commit d329210

127 files changed

Lines changed: 2378 additions & 848 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.

CHANGELOG.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,27 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
66

77
## [Unreleased]
88
### Added
9+
- Search for APIs based on configured tags (See issue [#82](https://github.com/Axway-API-Management-Plus/apim-cli/issues/82))
10+
- Error handling improved if custom properties configuration is invalid (Switch or Select without configured options)
11+
- Added support to import application scopes (See PR [#77](https://github.com/Axway-API-Management-Plus/apim-cli/pull/77))
12+
- Leverage "com.axway.apimanager.api.model.disable.confidential.fields" option (See PR [#71](https://github.com/Axway-API-Management-Plus/apim-cli/pull/71))
13+
14+
### Fixed
15+
- Changing an APIs fails due to a ClassCastException (See issue [#85](https://github.com/Axway-API-Management-Plus/apim-cli/issues/85))
16+
- NullPointerException when retrieving APIs on console with mode ultra (See issue [#80](https://github.com/Axway-API-Management-Plus/apim-cli/issues/80))
17+
- Quota- and Tag-Information always shown as false in console view, even if configured for an API (See issue [#81](https://github.com/Axway-API-Management-Plus/apim-cli/issues/81))
18+
- Handling of ExtClient configuration fixed when importing applications (See PR [#78](https://github.com/Axway-API-Management-Plus/apim-cli/pull/78))
19+
- Error when updating an organization (See issue [#73](https://github.com/Axway-API-Management-Plus/apim-cli/issues/73))
20+
- NPE when updating backendBasepath in a Swagger not having a host configured (See issue [#72](https://github.com/Axway-API-Management-Plus/apim-cli/issues/72))
21+
22+
### Changed
23+
- Internal parameter handling refactore to make it easier to integrate the CLI into other Java-Programs (See PR [#83](https://github.com/Axway-API-Management-Plus/apim-cli/pull/83))
24+
25+
## [1.2.2] 2020-09-09
26+
### Added
927
- Added new CSV-Export for applications (See issue [#70](https://github.com/Axway-API-Management-Plus/apim-cli/issues/70))
28+
- Toggle ignoreCache added to the usage (See issue [#52](https://github.com/Axway-API-Management-Plus/apim-cli/issues/52))
29+
- Added new forceUpdate flag to force re-creation (See issue [#56](https://github.com/Axway-API-Management-Plus/apim-cli/issues/56))
1030

1131
### Fixed
1232
- apim.sh now starts the CLI in the current directory (See issue [#60](https://github.com/Axway-API-Management-Plus/apim-cli/issues/60))
@@ -20,8 +40,6 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2040
- apim.sh & apim.bat script now support path with blanks. Thanks to [@cbrowet-axway](https://github.com/cbrowet-axway)
2141
- Handling NPE for Application credential search (See issue [#57](https://github.com/Axway-API-Management-Plus/apim-cli/issues/57))
2242
- If FE-Security is a Custom-Policy, the name of the Custom-Policy is now exported (See issue [#61](https://github.com/Axway-API-Management-Plus/apim-cli/issues/61))
23-
- Toggle ignoreCache added to the usage (See issue [#52](https://github.com/Axway-API-Management-Plus/apim-cli/issues/52))
24-
- Added new forceUpdate flag to force re-creation (See issue [#56](https://github.com/Axway-API-Management-Plus/apim-cli/issues/56))
2543

2644
## [1.2.1] 2020-07-22
2745
### Fixed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ The automated End-2-End test suite contains of __116__ different scenarios, whic
5151

5252
| Version | Branch | Status | Comment |
5353
| :--- | :--- | :---: | :--- |
54-
| 7.6.2 SP4 | develop | [![Build Status](https://img.shields.io/travis/Axway-API-Management-Plus/apim-cli/develop)](https://travis-ci.org/Axway-API-Management-Plus/apim-cli/branches)||
54+
| 7.6.2 SP5 | develop | [![Build Status](https://img.shields.io/travis/Axway-API-Management-Plus/apim-cli/develop)](https://travis-ci.org/Axway-API-Management-Plus/apim-cli/branches)||
5555
| 7.7.0 SP2 | test-with-7.7-SP2 | [![Build Status](https://img.shields.io/travis/Axway-API-Management-Plus/apim-cli/test-with-7.7-SP2)](https://travis-ci.org/Axway-API-Management-Plus/apim-cli/branches)||
5656
| 7.7-20200130 | test-with-7.7-20200130 | [![Build Status](https://img.shields.io/travis/Axway-API-Management-Plus/apim-cli/test-with-7.7-20200130)](https://travis-ci.org/Axway-API-Management-Plus/apim-cli/branches)||
5757
| 7.7-20200331 | test-with-7.7-20200331 | [![Build Status](https://img.shields.io/travis/Axway-API-Management-Plus/apim-cli/test-with-7.7-20200331)](https://travis-ci.org/Axway-API-Management-Plus/apim-cli/branches)||

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

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
import com.axway.apim.api.model.Image;
4848
import com.axway.apim.api.model.User;
4949
import com.axway.apim.api.model.apps.ClientApplication;
50-
import com.axway.apim.lib.CommandParameters;
50+
import com.axway.apim.lib.CoreParameters;
5151
import com.axway.apim.lib.DoNothingCacheManager;
5252
import com.axway.apim.lib.errorHandling.AppException;
5353
import com.axway.apim.lib.errorHandling.ErrorCode;
@@ -103,7 +103,7 @@ public static enum CUSTOM_PROP_TYPE {
103103
application
104104
}
105105

106-
private CommandParameters cmd;
106+
private CoreParameters cmd;
107107

108108
private static CacheManager cacheManager;
109109

@@ -134,7 +134,7 @@ public static synchronized APIManagerAdapter getInstance() throws AppException {
134134
if (APIManagerAdapter.instance == null) {
135135
APIManagerAdapter.instance = new APIManagerAdapter();
136136
if(!TestIndicator.getInstance().isTestRunning()) {
137-
LOG.info("Successfully connected to API-Manager (" + getApiManagerVersion() + ") on: " + CommandParameters.getInstance().getAPIManagerURL());
137+
LOG.info("Successfully connected to API-Manager (" + getApiManagerVersion() + ") on: " + CoreParameters.getInstance().getAPIManagerURL());
138138
} else {
139139
APIManagerAdapter.apiManagerVersion = "7.7.0";
140140
LOG.info("Successfully connected to MOCKED API-Manager (" + getApiManagerVersion() + ")");
@@ -161,7 +161,7 @@ public static synchronized void deleteInstance() throws AppException {
161161

162162
private APIManagerAdapter() throws AppException {
163163
super();
164-
this.cmd = CommandParameters.getInstance();
164+
this.cmd = CoreParameters.getInstance();
165165
this.configAdapter = new APIManagerConfigAdapter();
166166
this.apiAdapter = new APIManagerAPIAdapter();
167167
this.methodAdapter = new APIManagerAPIMethodAdapter();
@@ -183,7 +183,7 @@ private APIManagerAdapter() throws AppException {
183183

184184
public void loginToAPIManager(boolean useAdminClient) throws AppException {
185185
URI uri;
186-
if(cmd.ignoreAdminAccount() && useAdminClient) return;
186+
if(cmd.isIgnoreAdminAccount() && useAdminClient) return;
187187
if(hasAdminAccount && useAdminClient) return; // Already logged in with an Admin-Account.
188188
HttpResponse httpResponse = null;
189189
try {
@@ -268,8 +268,8 @@ public void logoutFromAPIManager(boolean orgAdmin) throws AppException {
268268
}
269269

270270
private String[] getAdminUsernamePassword() throws AppException {
271-
if(CommandParameters.getInstance().getAdminUsername()==null) return null;
272-
String[] usernamePassword = {CommandParameters.getInstance().getAdminUsername(), CommandParameters.getInstance().getAdminPassword()};
271+
if(CoreParameters.getInstance().getAdminUsername()==null) return null;
272+
String[] usernamePassword = {CoreParameters.getInstance().getAdminUsername(), CoreParameters.getInstance().getAdminPassword()};
273273
return usernamePassword;
274274
}
275275

@@ -278,7 +278,7 @@ public static User getCurrentUser(boolean useAdminClient) throws AppException {
278278
HttpResponse response = null;
279279
JsonNode jsonResponse = null;
280280
try {
281-
uri = new URIBuilder(CommandParameters.getInstance().getAPIManagerURL()).setPath(RestAPICall.API_VERSION+"/currentuser").build();
281+
uri = new URIBuilder(CoreParameters.getInstance().getAPIManagerURL()).setPath(RestAPICall.API_VERSION+"/currentuser").build();
282282
GETRequest currentUserRequest = new GETRequest(uri, useAdminClient);
283283
response = currentUserRequest.execute();
284284
getCsrfToken(response, useAdminClient); // Starting from 7.6.2 SP3 the CSRF token is returned on CurrentUser request
@@ -321,7 +321,7 @@ private static CacheManager getCacheManager() {
321321
APIManagerAdapter.cacheManager.init();
322322
return APIManagerAdapter.cacheManager;
323323
}
324-
if(CommandParameters.getInstance().ignoreCache()) {
324+
if(CoreParameters.getInstance().isIgnoreCache()) {
325325
APIManagerAdapter.cacheManager = new DoNothingCacheManager();
326326
} else {
327327
URL myUrl = APIManagerAdapter.class.getResource("/cacheConfig.xml");
@@ -335,7 +335,7 @@ private static CacheManager getCacheManager() {
335335
public static <K, V> Cache<K, V> getCache(CacheType cacheType, Class<K> key, Class<V> value) {
336336
getCacheManager();
337337
Cache<K, V> cache = APIManagerAdapter.cacheManager.getCache(cacheType.name(), key, value);
338-
if(CommandParameters.getInstance().clearCaches()!=null && CommandParameters.getInstance().clearCaches().contains(cacheType)) {
338+
if(CoreParameters.getInstance().clearCaches()!=null && CoreParameters.getInstance().clearCaches().contains(cacheType)) {
339339
cache.clear();
340340
LOG.info("Cache: " + cacheType.name() + " successfully cleared.");
341341
}
@@ -447,7 +447,7 @@ public ClientApplication getAppIdForCredential(String credential, String type) t
447447
String response = null;
448448
URI uri;
449449
try {
450-
uri = new URIBuilder(CommandParameters.getInstance().getAPIManagerURL()).setPath(RestAPICall.API_VERSION + "/applications/"+app.getId()+"/"+type+"").build();
450+
uri = new URIBuilder(CoreParameters.getInstance().getAPIManagerURL()).setPath(RestAPICall.API_VERSION + "/applications/"+app.getId()+"/"+type+"").build();
451451
LOG.debug("Loading credentials of type: '" + type + "' for application: '" + app.getName() + "' from API-Manager.");
452452
RestAPICall getRequest = new GETRequest(uri, true);
453453
httpResponse = getRequest.execute();
@@ -555,7 +555,7 @@ public static JsonNode getCustomPropertiesConfig() throws AppException {
555555
URI uri;
556556
HttpEntity httpResponse = null;
557557
try {
558-
uri = new URIBuilder(CommandParameters.getInstance().getAPIManagerURL()).setPath("/vordel/apiportal/app/app.config").build();
558+
uri = new URIBuilder(CoreParameters.getInstance().getAPIManagerURL()).setPath("/vordel/apiportal/app/app.config").build();
559559
RestAPICall getRequest = new GETRequest(uri);
560560
httpResponse = getRequest.execute().getEntity();
561561
appConfig = IOUtils.toString(httpResponse.getContent(), "UTF-8");
@@ -604,7 +604,7 @@ public static JsonNode getCertInfo(InputStream certFile, CaCert cert) throws App
604604
URI uri;
605605
HttpResponse httpResponse = null;
606606
try {
607-
uri = new URIBuilder(CommandParameters.getInstance().getAPIManagerURL()).setPath(RestAPICall.API_VERSION + "/certinfo/").build();
607+
uri = new URIBuilder(CoreParameters.getInstance().getAPIManagerURL()).setPath(RestAPICall.API_VERSION + "/certinfo/").build();
608608

609609
HttpEntity entity = MultipartEntityBuilder.create()
610610
.addBinaryBody("file", IOUtils.toByteArray(certFile), ContentType.create("application/x-x509-ca-cert"), cert.getCertFile())
@@ -643,7 +643,7 @@ public static JsonNode getFileData(byte[] certificate, String filename) throws A
643643
URI uri;
644644
HttpResponse httpResponse = null;
645645
try {
646-
uri = new URIBuilder(CommandParameters.getInstance().getAPIManagerURL()).setPath(RestAPICall.API_VERSION + "/filedata/").build();
646+
uri = new URIBuilder(CoreParameters.getInstance().getAPIManagerURL()).setPath(RestAPICall.API_VERSION + "/filedata/").build();
647647

648648
HttpEntity entity = MultipartEntityBuilder.create()
649649
.addBinaryBody("file", certificate, ContentType.create("application/x-pkcs12"), filename)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import org.slf4j.LoggerFactory;
99

1010
import com.axway.apim.api.API;
11-
import com.axway.apim.lib.CommandParameters;
11+
import com.axway.apim.lib.CoreParameters;
1212
import com.axway.apim.lib.errorHandling.AppException;
1313
import com.axway.apim.lib.errorHandling.ErrorCode;
1414
import com.axway.apim.lib.errorHandling.ErrorState;
@@ -68,7 +68,7 @@ public void update(API apiToUpdate, String desiredState) throws AppException {
6868
}
6969

7070
public void update(API apiToUpdate, String desiredState, String vhost) throws AppException {
71-
if(CommandParameters.getInstance().isForce()) {
71+
if(CoreParameters.getInstance().isForce()) {
7272
update(apiToUpdate, desiredState, vhost, true);
7373
} else {
7474
update(apiToUpdate, desiredState, vhost, false);

modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIFilter.java

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ public static enum FILTER_OP {
6969

7070
private String policyName;
7171

72+
private String tag;
73+
7274
private Map<String, String> customProperties;
7375

7476
private boolean deprecated;
@@ -169,6 +171,14 @@ public void setPolicyName(String policyName) {
169171
public String getPolicyName() {
170172
return policyName;
171173
}
174+
175+
public void setTag(String tag) {
176+
this.tag = tag;
177+
}
178+
179+
public String getTag() {
180+
return tag;
181+
}
172182

173183
public String getApiType() {
174184
if(loadBackendAPI) {
@@ -424,7 +434,7 @@ public String toString() {
424434

425435

426436
public boolean filter(API api) throws AppException {
427-
if(this.getApiPath()==null && this.getVhost()==null && this.getQueryStringVersion()==null && this.getPolicyName()==null && this.getBackendBasepath()==null) { // Nothing given to filter out.
437+
if(this.getApiPath()==null && this.getVhost()==null && this.getQueryStringVersion()==null && this.getPolicyName()==null && this.getBackendBasepath()==null && this.getTag()==null) { // Nothing given to filter out.
428438
return true;
429439
}
430440
// Before 7.7, we have to filter out APIs manually!
@@ -482,7 +492,7 @@ public boolean filter(API api) throws AppException {
482492
}
483493
if(!requestedPolicyUsed) return false;
484494
}
485-
if(this.getBackendBasepath()!=null) {
495+
if(this.getBackendBasepath()!=null) {
486496
Pattern pattern = Pattern.compile(this.getBackendBasepath().replace("*", ".*"));
487497
Matcher matcher = pattern.matcher(api.getServiceProfiles().get("_default").getBasePath());
488498
if(!matcher.matches()) {
@@ -493,6 +503,41 @@ public boolean filter(API api) throws AppException {
493503
if(this.getVhost()!=null && !this.getVhost().equals(api.getVhost())) return false;
494504
if(this.getQueryStringVersion()!=null && !this.getQueryStringVersion().equals(api.getApiRoutingKey())) return false;
495505
}
506+
if(this.getTag()!=null) {
507+
// Simple filter format tag: "tagValue*"
508+
String tagGroupFilter = this.getTag();
509+
String tagValueFilter = this.getTag();
510+
if(this.getTag().contains("=")) { // Group specific format: "tagGroup=tagValue*"
511+
tagGroupFilter = this.getTag().split("=")[0];
512+
tagValueFilter = this.getTag().split("=")[1];
513+
}
514+
Pattern groupPattern = Pattern.compile(tagGroupFilter.toLowerCase().replace("*", ".*"));
515+
Pattern valuePattern = Pattern.compile(tagValueFilter.toLowerCase().replace("*", ".*"));
516+
Iterator<String> it = api.getTags().keySet().iterator();
517+
boolean match = false;
518+
while(it.hasNext()) {
519+
String tagGroup = it.next();
520+
Matcher matcher = groupPattern.matcher(tagGroup.toLowerCase());
521+
if(!matcher.matches()) {
522+
// Search for specific group - No match - Ignore this group
523+
if(getTag().contains("=")) break;
524+
} else {
525+
// Filter match on the group
526+
if(!getTag().contains("=")) match = true;
527+
}
528+
String[] tagValues = api.getTags().get(tagGroup);
529+
for(String tagValue : tagValues) {
530+
matcher = valuePattern.matcher(tagValue.toLowerCase());
531+
if(matcher.matches()) {
532+
match=true;
533+
break;
534+
}
535+
}
536+
if(match) break;
537+
}
538+
// If none of the tags match, filter out this API
539+
if(!match) return false;
540+
}
496541
return true;
497542
}
498543

@@ -520,6 +565,7 @@ public static enum APIType {
520565
String name;
521566
String vhost;
522567
String policyName;
568+
String tag;
523569
String apiPath;
524570
String queryStringVersion;
525571
String state;
@@ -587,6 +633,7 @@ public APIFilter build() {
587633
apiFilter.setVhost(this.vhost);
588634
apiFilter.setName(this.name);
589635
apiFilter.setPolicyName(this.policyName);
636+
apiFilter.setTag(this.tag);
590637
apiFilter.setFilters(this.filters);
591638
apiFilter.setId(this.id);
592639
apiFilter.setApiId(apiId);
@@ -665,6 +712,11 @@ public Builder hasPolicyName(String policyName) {
665712
return this;
666713
}
667714

715+
public Builder hasTag(String tag) {
716+
this.tag = tag;
717+
return this;
718+
}
719+
668720
public Builder isDeprecated(boolean deprecated) {
669721
this.deprecated = deprecated;
670722
return this;

modules/apim-adapter/src/main/java/com/axway/apim/adapter/apis/APIManagerAPIAccessAdapter.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import com.axway.apim.api.model.APIAccess;
2323
import com.axway.apim.api.model.Organization;
2424
import com.axway.apim.api.model.AbstractEntity;
25-
import com.axway.apim.lib.CommandParameters;
25+
import com.axway.apim.lib.CoreParameters;
2626
import com.axway.apim.lib.errorHandling.AppException;
2727
import com.axway.apim.lib.errorHandling.ErrorCode;
2828
import com.axway.apim.lib.utils.rest.DELRequest;
@@ -76,7 +76,7 @@ private void readAPIAccessFromAPIManager(Type type, String id) throws AppExcepti
7676
URI uri;
7777
HttpResponse httpResponse = null;
7878
try {
79-
uri = new URIBuilder(CommandParameters.getInstance().getAPIManagerURL()).setPath(RestAPICall.API_VERSION + "/"+type+"/"+id+"/apis").build();
79+
uri = new URIBuilder(CoreParameters.getInstance().getAPIManagerURL()).setPath(RestAPICall.API_VERSION + "/"+type+"/"+id+"/apis").build();
8080
RestAPICall getRequest = new GETRequest(uri, APIManagerAdapter.hasAdminAccount());
8181
httpResponse = getRequest.execute();
8282
response = EntityUtils.toString(httpResponse.getEntity());
@@ -178,7 +178,7 @@ public APIAccess createAPIAccess(APIAccess apiAccess, AbstractEntity parentEntit
178178
URI uri;
179179
HttpResponse httpResponse = null;
180180
try {
181-
uri = new URIBuilder(CommandParameters.getInstance().getAPIManagerURL()).setPath(RestAPICall.API_VERSION+"/"+type+"/"+parentEntity.getId()+"/apis").build();
181+
uri = new URIBuilder(CoreParameters.getInstance().getAPIManagerURL()).setPath(RestAPICall.API_VERSION+"/"+type+"/"+parentEntity.getId()+"/apis").build();
182182
mapper.setSerializationInclusion(Include.NON_NULL);
183183
FilterProvider filter = new SimpleFilterProvider().setDefaultFilter(
184184
SimpleBeanPropertyFilter.serializeAllExcept(new String[] {"apiName"}));
@@ -233,7 +233,7 @@ public void deleteAPIAccess(APIAccess apiAccess, AbstractEntity parentEntity, Ty
233233
URI uri;
234234
HttpResponse httpResponse = null;
235235
try {
236-
uri = new URIBuilder(CommandParameters.getInstance().getAPIManagerURL()).setPath(RestAPICall.API_VERSION+"/"+type+"/"+parentEntity.getId()+"/apis/"+apiAccess.getId()).build();
236+
uri = new URIBuilder(CoreParameters.getInstance().getAPIManagerURL()).setPath(RestAPICall.API_VERSION+"/"+type+"/"+parentEntity.getId()+"/apis/"+apiAccess.getId()).build();
237237
// Use an admin account for this request
238238
RestAPICall request = new DELRequest(uri, APIManagerAdapter.hasAdminAccount());
239239
request.setContentType("application/json");

0 commit comments

Comments
 (0)