本文整理了Java中io.apiman.gateway.engine.beans.Api
类的一些代码示例,展示了Api
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Api
类的具体详情如下:
包路径:io.apiman.gateway.engine.beans.Api
类名称:Api
[英]Models an API published to the API Management runtime.
[中]为发布到API管理运行时的API建模。
代码示例来源:origin: io.apiman/apiman-gateway-engine-es
/**
* Generates a valid document ID for a api, used to index the api in ES.
* @param api an api
* @return a api key
*/
private String getApiId(Api api) {
return getApiId(api.getOrganizationId(), api.getApiId(), api.getVersion());
}
代码示例来源:origin: apiman/apiman
@Override
public void retire(String organizationId, String apiId, String version, AsyncResponse response)
throws RegistrationException, NotAuthorizedException {
Api api = new Api();
api.setOrganizationId(organizationId);
api.setApiId(apiId);
api.setVersion(version);
registry.retireApi(api, handlerWithEmptyResult(response));
}
代码示例来源:origin: apiman/apiman
/**
* Response API property replacements
*/
protected void resolvePropertyReplacements(Api api) {
if (api == null) {
return;
}
String endpoint = api.getEndpoint();
endpoint = resolveProperties(endpoint);
api.setEndpoint(endpoint);
Map<String, String> properties = api.getEndpointProperties();
for (Entry<String, String> entry : properties.entrySet()) {
String value = entry.getValue();
value = resolveProperties(value);
entry.setValue(value);
}
resolvePropertyReplacements(api.getApiPolicies());
}
代码示例来源:origin: apiman/apiman
/**
* @see io.apiman.gateway.engine.IRegistry#publishApi(io.apiman.gateway.engine.beans.Api, io.apiman.gateway.engine.async.IAsyncResultHandler)
*/
@Override
public void publishApi(Api api, IAsyncResultHandler<Void> handler) {
List<Policy> policies = api.getApiPolicies();
encryptPolicies(api.getOrganizationId(), api.getApiId(), api.getVersion(), EntityType.Api, policies);
encryptEndpointProperties(api.getOrganizationId(), api.getApiId(), api.getVersion(), EntityType.Api, api.getEndpointProperties());
delegate.publishApi(api, handler);
decryptPolicies(api.getOrganizationId(), api.getApiId(), api.getVersion(), EntityType.Api, policies);
decryptEndpointProperties(api.getOrganizationId(), api.getApiId(), api.getVersion(), EntityType.Api, api.getEndpointProperties());
}
代码示例来源:origin: apiman/apiman
private void processData() {
if (configs.size() == 0) {
log.warn("File loaded into registry was empty. No entities created.");
return;
}
try {
// Naive version initially.
for (Auth3ScaleBean bean : configs) {
// Reflects the remote data structure.
BackendConfiguration config = bean.getThreescaleConfig().getProxyConfig().getBackendConfig();
Api api = new Api();
api.setApiId(config.getSystemName());
api.setOrganizationId(defaultOrgName);
api.setEndpoint(config.getProxy().getApiBackend());
api.setEndpointContentType("text/json"); // don't think there is an equivalent of this in 3scale
api.setEndpointType("rest"); //don't think there is an equivalent of this in 3scale
api.setParsePayload(false); // can let user override this?
api.setPublicAPI(true); // is there an equivalent of this?
api.setVersion(defaultVersion); // don't think this is relevant anymore
setPolicies(api, bean);
log.debug("Processing: {0}", config);
log.debug("Creating API: {0}", api);
apis.add(api);
}
dataProcessed = true;
checkQueue();
} catch (DecodeException e) {
failAll(e);
}
}
代码示例来源:origin: apiman/apiman
} else {
Exception error = new NoContractFoundException(Messages.i18n.format("InMemoryRegistry.NoContractFound", //$NON-NLS-1$
client.getClientId(), api.getApiId()));
handler.handle(AsyncResultImpl.create(error, ApiContract.class));
代码示例来源:origin: apiman/apiman
@Override
public void listApis(String organizationId, int page, int pageSize, IAsyncResultHandler<List<String>> handler) {
// For now, ignore paging, but it's there for future. Would need to ensure stable ordering.
List<String> res = map.entrySet().stream()
.map(Map.Entry::getValue)
.filter(entity -> entity instanceof Api)
.map(entity -> (Api) entity)
.filter(api -> api.getOrganizationId().equals(organizationId))
.map(api -> api.getApiId())
.distinct()
.collect(Collectors.toList());
handler.handle(AsyncResultImpl.create(res));
}
代码示例来源:origin: io.apiman/apiman-gateway-engine-3scale
private void setPolicies(Api api, Auth3ScaleBean config) { // FIXME optimise
// Add 3scale policy
Policy pol = new Policy();
pol.setPolicyImpl(determinePolicyImpl()); // TODO get version? Hmm! Env?
pol.setPolicyJsonConfig(Json.encode(config));
api.getApiPolicies().add(pol);
// Add any policies user specified in remote config.
policyConfigApis.stream()
.filter(skeleton -> skeleton.getApiId().equals(api.getApiId()))
// Apply policies from skeleton to 3scale API.
.forEach(skeleton -> api.getApiPolicies().addAll(skeleton.getApiPolicies()));
}
代码示例来源:origin: apiman/apiman
String endpoint = ApimanPathUtils.join(api.getEndpoint(), request.getDestination());
BasicAuthOptions options = new BasicAuthOptions(api.getEndpointProperties());
if (options.getUsername() != null && options.getPassword() != null) {
if (options.isRequireSSL() && !isSsl) {
代码示例来源:origin: apiman/apiman
private URI parseApiEndpoint(Api api) {
try {
return new URI(api.getEndpoint());
} catch (URISyntaxException e) {
throw new RuntimeException(e);
}
}
代码示例来源:origin: io.apiman/apiman-gateway-engine-core
@Override
public void listOrgs(IAsyncResultHandler<List<String>> handler) {
// TODO: We should track set of OrgId -> AtomicCounter if this API has meaningfully high usage.
List<String> res = map.entrySet().stream()
.map(Map.Entry::getValue)
.map(elem -> {
if (elem instanceof Api) {
return ((Api) elem).getOrganizationId();
} else {
return ((Client) elem).getOrganizationId();
}
})
.distinct()
.collect(Collectors.toList());
handler.handle(AsyncResultImpl.create(res));
}
代码示例来源:origin: io.apiman/apiman-gateway-engine-3scale
private void processData() {
if (configs.size() == 0) {
log.warn("File loaded into registry was empty. No entities created.");
return;
}
try {
// Naive version initially.
for (Auth3ScaleBean bean : configs) {
// Reflects the remote data structure.
BackendConfiguration config = bean.getThreescaleConfig().getProxyConfig().getBackendConfig();
Api api = new Api();
api.setApiId(config.getSystemName());
api.setOrganizationId(defaultOrgName);
api.setEndpoint(config.getProxy().getApiBackend());
api.setEndpointContentType("text/json"); // don't think there is an equivalent of this in 3scale
api.setEndpointType("rest"); //don't think there is an equivalent of this in 3scale
api.setParsePayload(false); // can let user override this?
api.setPublicAPI(true); // is there an equivalent of this?
api.setVersion(defaultVersion); // don't think this is relevant anymore
setPolicies(api, bean);
log.debug("Processing: {0}", config);
log.debug("Creating API: {0}", api);
apis.add(api);
}
dataProcessed = true;
checkQueue();
} catch (DecodeException e) {
failAll(e);
}
}
代码示例来源:origin: io.apiman/apiman-gateway-engine-core
/**
* @see io.apiman.gateway.engine.IRegistry#publishApi(io.apiman.gateway.engine.beans.Api, io.apiman.gateway.engine.async.IAsyncResultHandler)
*/
@Override
public void publishApi(Api api, IAsyncResultHandler<Void> handler) {
List<Policy> policies = api.getApiPolicies();
encryptPolicies(api.getOrganizationId(), api.getApiId(), api.getVersion(), EntityType.Api, policies);
encryptEndpointProperties(api.getOrganizationId(), api.getApiId(), api.getVersion(), EntityType.Api, api.getEndpointProperties());
delegate.publishApi(api, handler);
decryptPolicies(api.getOrganizationId(), api.getApiId(), api.getVersion(), EntityType.Api, policies);
decryptEndpointProperties(api.getOrganizationId(), api.getApiId(), api.getVersion(), EntityType.Api, api.getEndpointProperties());
}
代码示例来源:origin: io.apiman/apiman-gateway-engine-vertx-shareddata
} else {
Exception error = new NoContractFoundException(Messages.i18n.format("InMemoryRegistry.NoContractFound", //$NON-NLS-1$
client.getClientId(), api.getApiId()));
handler.handle(AsyncResultImpl.create(error, ApiContract.class));
代码示例来源:origin: io.apiman/apiman-gateway-engine-core
@Override
public void listApis(String organizationId, int page, int pageSize, IAsyncResultHandler<List<String>> handler) {
// For now, ignore paging, but it's there for future. Would need to ensure stable ordering.
List<String> res = map.entrySet().stream()
.map(Map.Entry::getValue)
.filter(entity -> entity instanceof Api)
.map(entity -> (Api) entity)
.filter(api -> api.getOrganizationId().equals(organizationId))
.map(api -> api.getApiId())
.distinct()
.collect(Collectors.toList());
handler.handle(AsyncResultImpl.create(res));
}
代码示例来源:origin: apiman/apiman
private void setPolicies(Api api, Auth3ScaleBean config) { // FIXME optimise
// Add 3scale policy
Policy pol = new Policy();
pol.setPolicyImpl(determinePolicyImpl()); // TODO get version? Hmm! Env?
pol.setPolicyJsonConfig(Json.encode(config));
api.getApiPolicies().add(pol);
// Add any policies user specified in remote config.
policyConfigApis.stream()
.filter(skeleton -> skeleton.getApiId().equals(api.getApiId()))
// Apply policies from skeleton to 3scale API.
.forEach(skeleton -> api.getApiPolicies().addAll(skeleton.getApiPolicies()));
}
代码示例来源:origin: io.apiman/apiman-gateway-platforms-servlet
String endpoint = ApimanPathUtils.join(api.getEndpoint(), request.getDestination());
BasicAuthOptions options = new BasicAuthOptions(api.getEndpointProperties());
if (options.getUsername() != null && options.getPassword() != null) {
if (options.isRequireSSL() && !isSsl) {
代码示例来源:origin: apiman/apiman
/**
* Constructor.
* @param api
* @param request
* @param handler
*/
public PolicyTesterApiConnection(Api api, ApiRequest request,
IAsyncResultHandler<IApiConnectionResponse> handler) {
this.request = request;
this.handler = handler;
this.output = null;
this.backEndApi = createBackEndApi(api.getEndpoint());
}
代码示例来源:origin: apiman/apiman
@Override
public void listOrgs(IAsyncResultHandler<List<String>> handler) {
// TODO: We should track set of OrgId -> AtomicCounter if this API has meaningfully high usage.
List<String> res = map.entrySet().stream()
.map(Map.Entry::getValue)
.map(elem -> {
if (elem instanceof Api) {
return ((Api) elem).getOrganizationId();
} else {
return ((Client) elem).getOrganizationId();
}
})
.distinct()
.collect(Collectors.toList());
handler.handle(AsyncResultImpl.create(res));
}
代码示例来源:origin: apiman/apiman
policy.setPolicyJsonConfig(getPolicyConfiguration(config));
Api api = new Api();
api.setEndpoint(backEndApi.getName());
api.setEndpointType("TEST");
api.setOrganizationId(orgId);
api.setApiId(apiId);
api.setVersion(String.valueOf(version));
api.setPublicAPI(true);
api.setApiPolicies(Collections.singletonList(policy));
内容来源于网络,如有侵权,请联系作者删除!