Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,53 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

# [1.14.17] In progress

### Fixed
- Updating the quota of an API corrupted restrictions that use the same method, e.g. a `throttle` and a `throttlemb` restriction for `*`
([#592](https://github.com/Axway-API-Management-Plus/apim-cli/issues/592)). Restrictions were matched by method only, which turned
one restriction into the other. They are now identified by method, type, period and per. Restrictions of the same type and method with a different
period (e.g. 100 messages per second and 10000 messages per day) are kept apart. Changing the limit updates the restriction, changing
the type, period or per replaces it.
- Application quota restrictions of different APIs, which are given by `apiPath`, were all applied to the first API. The API lookup reused
the cached response of a previous lookup by another API path, as the cache key of the API filter ignored the API path
([#567](https://github.com/Axway-API-Management-Plus/apim-cli/issues/567)). The same applies to any other lookup of APIs by `apiPath`,
`state`, `deprecated`, `retired` or `createdOn` within one execution.
- Updating an API failed with "No operation found with name: '<id>'" if an inbound or outbound profile exists for a specific operation and the API
is updated more than once during an import, for example when the backendBasepath is changed together with other properties
([#581](https://github.com/Axway-API-Management-Plus/apim-cli/issues/581)).
- OpenAPI 3.1 specifications with `resolve_openapi_ref=true` failed silently on import ([#582](https://github.com/Axway-API-Management-Plus/apim-cli/issues/582)):
- The resolved specification was ignored, as the original specification was used after resolving the references.
- The resolved OpenAPI 3.1 model was serialized with a plain Jackson mapper instead of the one of swagger-core, which fails for
boolean schemas like `additionalProperties: false`. Mixed up swagger library versions (`NoSuchMethodError` for `booleanSchemaValue`)
were fixed by aligning swagger-models and swagger-core.
- Errors while resolving the references now fail the import with a message. References are only resolved for OpenAPI 3.x specifications.
- Errors thrown by a command, which are no longer lost silently, are now logged by the CLI.

### Changed
- Improved the performance of commands loading remote hosts, like `api get`, `api import` and the settings export. The users (createdBy) and organizations
of remote hosts are only loaded for the requested remote hosts, instead of one by one (`/users/{id}`) for all remote hosts on every
lookup ([#462](https://github.com/Axway-API-Management-Plus/apim-cli/issues/462)).
- Upgraded dependencies:
- swagger-parser 2.1.19 to 2.1.48
- swagger-models 2.2.0 to 2.2.55 (swagger-core 2.2.55 is now managed as well). The 3.x line of swagger-models requires
Jackson 3 and is not supported by swagger-parser yet, so it is not used.
- Ehcache 3.10.8 to 3.12.0, now using its `jakarta` build together with `jaxb-runtime` 4.0.9 (jakarta.xml.bind) instead of
the javax based `jaxb-runtime` 2.3.9 to read `cacheConfig.xml`. A customized `conf/cacheConfig.xml` keeps working.

### Removed
- **OData support was removed.** Passing an OData `$metadata` / EDMX document (OData V2, V3 and V4) as the API
definition of `api import` is no longer supported and fails with a message pointing to the replacement.
The conversion was built on [Apache Olingo](https://olingo.apache.org/), which is no longer maintained. It moved to
the separate project `apim-cli-odata`, which converts OData V2/V4 metadata into an OpenAPI 3 specification:
```
apim-odata convert -m <metadata file or URL> -b <backend of the OData service> -o openapi.json
```
Convert the metadata first, then import the resulting OpenAPI file with the CLI as usual. Everything else about
importing such an API stays the same. The OData-Routing policy is still required for these APIs. API-Specification
filters can still be applied, as they now work on the converted OpenAPI file.
- Removed the OData example configurations from `examples/basic` and the Apache Olingo dependencies.

# [1.14.16] 2026-11-12

### Fixed
Expand Down
39 changes: 0 additions & 39 deletions examples/basic/odata-v2-northwind-api-filtered.json

This file was deleted.

15 changes: 0 additions & 15 deletions examples/basic/odata-v2-northwind-api.json

This file was deleted.

27 changes: 0 additions & 27 deletions examples/basic/odata-v4-trippin-api-filtered.json

This file was deleted.

10 changes: 0 additions & 10 deletions examples/basic/odata-v4-trippin-api.json

This file was deleted.

23 changes: 4 additions & 19 deletions modules/apim-adapter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,32 +53,17 @@
<artifactId>jackson-dataformat-xml</artifactId>
</dependency>
<dependency>
<groupId>org.apache.olingo</groupId>
<artifactId>olingo-odata2-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.olingo</groupId>
<artifactId>olingo-odata2-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.olingo</groupId>
<artifactId>odata-commons-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.olingo</groupId>
<artifactId>odata-commons-core</artifactId>
</dependency>
<dependency>
<groupId>org.apache.olingo</groupId>
<artifactId>odata-client-core</artifactId>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-models</artifactId>
</dependency>
<dependency>
<groupId>io.swagger.core.v3</groupId>
<artifactId>swagger-models</artifactId>
<artifactId>swagger-core</artifactId>
</dependency>
<dependency>
<groupId>org.ehcache</groupId>
<artifactId>ehcache</artifactId>
<classifier>jakarta</classifier>
</dependency>
<dependency>
<groupId>org.glassfish.jaxb</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,13 @@ public void setFailOnError(boolean failOnError) {
this.failOnError = failOnError;
}

/**
* The responses of the API-Manager are cached per filter. Therefore, two filters are equal if they result in the same request to the
* API-Manager, which is defined by the type of the API (front-end/back-end), the ID and the filters sent to the API-Manager (e.g.
* name, API path, state). Everything else is applied on the response and doesn't change the request.
* It is important to include all of them. Otherwise, the lookup of an API returns the API of a previous lookup, for instance
* when APIs are looked up by different API paths (issue #567).
*/
@Override
public boolean equals(Object obj) {
if (obj == null) return false;
Expand All @@ -395,16 +402,15 @@ public boolean equals(Object obj) {
return (
StringUtils.equals(other.getId(), this.getId()) &&
StringUtils.equals(other.getName(), this.getName()) &&
StringUtils.equals(other.getApiId(), this.getApiId())
StringUtils.equals(other.getApiId(), this.getApiId()) &&
StringUtils.equals(other.getApiType(), this.getApiType()) &&
Objects.equals(other.getFilters(), this.getFilters())
);
}

@Override
public int hashCode() {
int hashCode = 0;
hashCode += (this.id != null) ? this.id.hashCode() : 0;
hashCode += (this.name != null) ? this.name.hashCode() : 0;
return hashCode;
return Objects.hash(id, name, apiId, getApiType(), filters);
}

public boolean isIncludeMethods() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,13 +363,26 @@ public void updateAPIImage(API api, Image image) throws AppException {
}
}

private boolean isTranslated(String key, METHOD_TRANSLATION mode, List<String> apiIds) throws AppException {
// When translated as ID the key is an operation ID, and the other way around an operation name
boolean translatedKeyIsId = mode != METHOD_TRANSLATION.AS_NAME;
for (String apiId : apiIds) {
if (APIManagerAdapter.getInstance().getMethodAdapter().hasMethod(apiId, key, translatedKeyIsId))
return true;
}
return false;
}

private <T> void translateMethodIds(Map<String, T> profiles, METHOD_TRANSLATION mode, List<String> apiIds) throws AppException {
Map<String, T> updatedEntries = new HashMap<>();
if (profiles != null) {
Iterator<String> keys = profiles.keySet().iterator();
while (keys.hasNext()) {
String key = keys.next();
if (key.equals("_default")) continue;
// The profiles are translated in place. If the same API is handled more than once (e.g. a proxy update
// followed by a backendBasepath update), the key is already translated and must be kept (issue #581)
if (isTranslated(key, mode, apiIds)) continue;
APIMethod method = null;
for (String apiId : apiIds) {
if (mode == METHOD_TRANSLATION.AS_NAME) {
Expand Down Expand Up @@ -617,7 +630,7 @@ public API updateAPIProxy(API api) throws AppException {
*/
public static final String QUERY_STRING_PASS_THROUGH_MIN_VERSION = "7.7.20220530";

public String[] getSerializeAllExcept() throws AppException {
public String[] getSerializeAllExcept() {
String[] serializeAllExcept;
if (APIManagerAdapter.hasAPIManagerVersion(QUERY_STRING_PASS_THROUGH_MIN_VERSION)) {
serializeAllExcept = new String[]{"apiDefinition", "certFile", "useForInbound", "useForOutbound", "organization", "applications", "image", "clientOrganizations", "applicationQuota", "systemQuota", "backendBasepath", "remoteHost"};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,21 @@ public APIMethod getMethodForName(String apiId, String methodName) throws AppExc
throw new AppException("No operation found with name: '" + methodName + "'", ErrorCode.API_OPERATION_NOT_FOUND);
}

/**
* @param apiId the API the operations are loaded for
* @param methodKey the ID or the name of an operation
* @param byId true to check if methodKey is the ID of an operation, otherwise it is checked against the names
* @return true, if the API has an operation with the given ID or name
* @throws AppException if the operations cannot be loaded
*/
public boolean hasMethod(String apiId, String methodKey, boolean byId) throws AppException {
for (APIMethod method : getAllMethodsForAPI(apiId)) {
String value = byId ? method.getId() : method.getName();
if (methodKey.equals(value)) return true;
}
return false;
}

private void logMessage(String apiId) {
LOG.warn("No operations found for API with id: {}", apiId);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
package com.axway.apim.adapter.apis;

import com.axway.apim.adapter.APIManagerAdapter;
import com.axway.apim.adapter.jackson.OrganizationDeserializer;
import com.axway.apim.adapter.jackson.OrganizationSerializerModifier;
import com.axway.apim.adapter.jackson.UserDeserializer;
import com.axway.apim.adapter.jackson.UserSerializerModifier;
import com.axway.apim.api.model.Organization;
import com.axway.apim.api.model.RemoteHost;
import com.axway.apim.api.model.User;
import com.axway.apim.lib.CoreParameters;
import com.axway.apim.lib.error.AppException;
import com.axway.apim.lib.error.ErrorCode;
Expand All @@ -13,6 +18,7 @@
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectReader;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.databind.ser.FilterProvider;
import com.fasterxml.jackson.databind.ser.impl.SimpleBeanPropertyFilter;
Expand Down Expand Up @@ -68,10 +74,18 @@ private void readRemoteHostsFromAPIManager(RemoteHostFilter filter) throws AppEx
public Map<String, RemoteHost> getRemoteHosts(RemoteHostFilter filter) throws AppException {
readRemoteHostsFromAPIManager(filter);
try {
List<RemoteHost> remoteHostsList = mapper.readValue(apiManagerResponse.get(filter), new TypeReference<>() {});
// The users and organizations are only resolved for the remote hosts, which are requested. Otherwise, they are loaded
// one by one for all remote hosts, even if only one is requested (issue #462).
// If the remote hosts are filtered by organization, the organization is required to filter.
boolean organizationRequiredToFilter = filter.getOrganization() != null;
ObjectReader reader = mapper.readerFor(new TypeReference<List<RemoteHost>>() {})
.withAttribute(UserDeserializer.Params.SKIP_LOOKUP, true)
.withAttribute(OrganizationDeserializer.Params.SKIP_LOOKUP, !organizationRequiredToFilter);
List<RemoteHost> remoteHostsList = reader.readValue(apiManagerResponse.get(filter));
remoteHostsList.removeIf(filter::filter);
Map<String, RemoteHost> remoteHosts = new HashMap<>();
for (RemoteHost remoteHost : remoteHostsList) {
resolveReferences(remoteHost, !organizationRequiredToFilter);
remoteHosts.put(remoteHost.getName(), remoteHost);
}
return remoteHosts;
Expand All @@ -80,6 +94,30 @@ public Map<String, RemoteHost> getRemoteHosts(RemoteHostFilter filter) throws Ap
}
}

/**
* Loads the details of the user and the organization, which are only given by their ID.
*/
private void resolveReferences(RemoteHost remoteHost, boolean resolveOrganization) throws AppException {
User createdBy = remoteHost.getCreatedBy();
if (createdBy != null && createdBy.getId() != null) {
User user = null;
try {
user = APIManagerAdapter.getInstance().getUserAdapter().getUserForId(createdBy.getId());
} catch (AppException e) {
LOG.error("Error reading user with ID: {} from API-Manager.", createdBy.getId());
}
if (user != null) {
remoteHost.setCreatedBy(user);
} else {
LOG.error("User with ID: {} not found.", createdBy.getId());
}
}
Organization organization = remoteHost.getOrganization();
if (resolveOrganization && organization != null && organization.getId() != null) {
remoteHost.setOrganization(APIManagerAdapter.getInstance().getOrgAdapter().getOrgForId(organization.getId()));
}
}

public RemoteHost getRemoteHost(String name, Integer port) throws AppException {
RemoteHostFilter remoteHostFilter = new RemoteHostFilter.Builder().hasName(name).hasPort(port).build();
Map<String, RemoteHost> remoteHosts = getRemoteHosts(remoteHostFilter);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ public class OrganizationDeserializer extends StdDeserializer<Organization> {

private static final long serialVersionUID = 1L;

public enum Params {
/**
* Don't load the organization from the API-Manager, only the organization ID is set. Used if the organization is not required
* for all entities, which are deserialized. The organization can be loaded afterwards with APIManagerOrganizationAdapter.getOrgForId.
* Only applies to the organizationId given by the API-Manager.
*/
SKIP_LOOKUP
}

public OrganizationDeserializer() {
this(null);
}
Expand All @@ -33,6 +42,11 @@ public Organization deserialize(JsonParser jp, DeserializationContext context)
// Deserialization depends on the direction
if ("organizationId".equals(jp.currentName())) {
// organizationId is given by API-Manager
if (Boolean.TRUE.equals(context.getAttribute(Params.SKIP_LOOKUP))) {
Organization organization = new Organization();
organization.setId(node.asText());
return organization;
}
return organizationAdapter.getOrgForId(node.asText());
} else {
// Otherwise make sure the organization exists and try to load it
Expand Down
Loading
Loading