io.apiman.gateway.engine.beans.Api类的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(10.1k)|赞(0)|评价(0)|浏览(220)

本文整理了Java中io.apiman.gateway.engine.beans.Api类的一些代码示例,展示了Api类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Api类的具体详情如下:
包路径:io.apiman.gateway.engine.beans.Api
类名称:Api

Api介绍

[英]Models an API published to the API Management runtime.
[中]为发布到API管理运行时的API建模。

代码示例

代码示例来源:origin: io.apiman/apiman-gateway-engine-es

  1. /**
  2. * Generates a valid document ID for a api, used to index the api in ES.
  3. * @param api an api
  4. * @return a api key
  5. */
  6. private String getApiId(Api api) {
  7. return getApiId(api.getOrganizationId(), api.getApiId(), api.getVersion());
  8. }

代码示例来源:origin: apiman/apiman

  1. @Override
  2. public void retire(String organizationId, String apiId, String version, AsyncResponse response)
  3. throws RegistrationException, NotAuthorizedException {
  4. Api api = new Api();
  5. api.setOrganizationId(organizationId);
  6. api.setApiId(apiId);
  7. api.setVersion(version);
  8. registry.retireApi(api, handlerWithEmptyResult(response));
  9. }

代码示例来源:origin: apiman/apiman

  1. /**
  2. * Response API property replacements
  3. */
  4. protected void resolvePropertyReplacements(Api api) {
  5. if (api == null) {
  6. return;
  7. }
  8. String endpoint = api.getEndpoint();
  9. endpoint = resolveProperties(endpoint);
  10. api.setEndpoint(endpoint);
  11. Map<String, String> properties = api.getEndpointProperties();
  12. for (Entry<String, String> entry : properties.entrySet()) {
  13. String value = entry.getValue();
  14. value = resolveProperties(value);
  15. entry.setValue(value);
  16. }
  17. resolvePropertyReplacements(api.getApiPolicies());
  18. }

代码示例来源:origin: apiman/apiman

  1. /**
  2. * @see io.apiman.gateway.engine.IRegistry#publishApi(io.apiman.gateway.engine.beans.Api, io.apiman.gateway.engine.async.IAsyncResultHandler)
  3. */
  4. @Override
  5. public void publishApi(Api api, IAsyncResultHandler<Void> handler) {
  6. List<Policy> policies = api.getApiPolicies();
  7. encryptPolicies(api.getOrganizationId(), api.getApiId(), api.getVersion(), EntityType.Api, policies);
  8. encryptEndpointProperties(api.getOrganizationId(), api.getApiId(), api.getVersion(), EntityType.Api, api.getEndpointProperties());
  9. delegate.publishApi(api, handler);
  10. decryptPolicies(api.getOrganizationId(), api.getApiId(), api.getVersion(), EntityType.Api, policies);
  11. decryptEndpointProperties(api.getOrganizationId(), api.getApiId(), api.getVersion(), EntityType.Api, api.getEndpointProperties());
  12. }

代码示例来源:origin: apiman/apiman

  1. private void processData() {
  2. if (configs.size() == 0) {
  3. log.warn("File loaded into registry was empty. No entities created.");
  4. return;
  5. }
  6. try {
  7. // Naive version initially.
  8. for (Auth3ScaleBean bean : configs) {
  9. // Reflects the remote data structure.
  10. BackendConfiguration config = bean.getThreescaleConfig().getProxyConfig().getBackendConfig();
  11. Api api = new Api();
  12. api.setApiId(config.getSystemName());
  13. api.setOrganizationId(defaultOrgName);
  14. api.setEndpoint(config.getProxy().getApiBackend());
  15. api.setEndpointContentType("text/json"); // don't think there is an equivalent of this in 3scale
  16. api.setEndpointType("rest"); //don't think there is an equivalent of this in 3scale
  17. api.setParsePayload(false); // can let user override this?
  18. api.setPublicAPI(true); // is there an equivalent of this?
  19. api.setVersion(defaultVersion); // don't think this is relevant anymore
  20. setPolicies(api, bean);
  21. log.debug("Processing: {0}", config);
  22. log.debug("Creating API: {0}", api);
  23. apis.add(api);
  24. }
  25. dataProcessed = true;
  26. checkQueue();
  27. } catch (DecodeException e) {
  28. failAll(e);
  29. }
  30. }

代码示例来源:origin: apiman/apiman

  1. } else {
  2. Exception error = new NoContractFoundException(Messages.i18n.format("InMemoryRegistry.NoContractFound", //$NON-NLS-1$
  3. client.getClientId(), api.getApiId()));
  4. handler.handle(AsyncResultImpl.create(error, ApiContract.class));

代码示例来源:origin: apiman/apiman

  1. @Override
  2. public void listApis(String organizationId, int page, int pageSize, IAsyncResultHandler<List<String>> handler) {
  3. // For now, ignore paging, but it's there for future. Would need to ensure stable ordering.
  4. List<String> res = map.entrySet().stream()
  5. .map(Map.Entry::getValue)
  6. .filter(entity -> entity instanceof Api)
  7. .map(entity -> (Api) entity)
  8. .filter(api -> api.getOrganizationId().equals(organizationId))
  9. .map(api -> api.getApiId())
  10. .distinct()
  11. .collect(Collectors.toList());
  12. handler.handle(AsyncResultImpl.create(res));
  13. }

代码示例来源:origin: io.apiman/apiman-gateway-engine-3scale

  1. private void setPolicies(Api api, Auth3ScaleBean config) { // FIXME optimise
  2. // Add 3scale policy
  3. Policy pol = new Policy();
  4. pol.setPolicyImpl(determinePolicyImpl()); // TODO get version? Hmm! Env?
  5. pol.setPolicyJsonConfig(Json.encode(config));
  6. api.getApiPolicies().add(pol);
  7. // Add any policies user specified in remote config.
  8. policyConfigApis.stream()
  9. .filter(skeleton -> skeleton.getApiId().equals(api.getApiId()))
  10. // Apply policies from skeleton to 3scale API.
  11. .forEach(skeleton -> api.getApiPolicies().addAll(skeleton.getApiPolicies()));
  12. }

代码示例来源:origin: apiman/apiman

  1. String endpoint = ApimanPathUtils.join(api.getEndpoint(), request.getDestination());
  2. BasicAuthOptions options = new BasicAuthOptions(api.getEndpointProperties());
  3. if (options.getUsername() != null && options.getPassword() != null) {
  4. if (options.isRequireSSL() && !isSsl) {

代码示例来源:origin: apiman/apiman

  1. private URI parseApiEndpoint(Api api) {
  2. try {
  3. return new URI(api.getEndpoint());
  4. } catch (URISyntaxException e) {
  5. throw new RuntimeException(e);
  6. }
  7. }

代码示例来源:origin: io.apiman/apiman-gateway-engine-core

  1. @Override
  2. public void listOrgs(IAsyncResultHandler<List<String>> handler) {
  3. // TODO: We should track set of OrgId -> AtomicCounter if this API has meaningfully high usage.
  4. List<String> res = map.entrySet().stream()
  5. .map(Map.Entry::getValue)
  6. .map(elem -> {
  7. if (elem instanceof Api) {
  8. return ((Api) elem).getOrganizationId();
  9. } else {
  10. return ((Client) elem).getOrganizationId();
  11. }
  12. })
  13. .distinct()
  14. .collect(Collectors.toList());
  15. handler.handle(AsyncResultImpl.create(res));
  16. }

代码示例来源:origin: io.apiman/apiman-gateway-engine-3scale

  1. private void processData() {
  2. if (configs.size() == 0) {
  3. log.warn("File loaded into registry was empty. No entities created.");
  4. return;
  5. }
  6. try {
  7. // Naive version initially.
  8. for (Auth3ScaleBean bean : configs) {
  9. // Reflects the remote data structure.
  10. BackendConfiguration config = bean.getThreescaleConfig().getProxyConfig().getBackendConfig();
  11. Api api = new Api();
  12. api.setApiId(config.getSystemName());
  13. api.setOrganizationId(defaultOrgName);
  14. api.setEndpoint(config.getProxy().getApiBackend());
  15. api.setEndpointContentType("text/json"); // don't think there is an equivalent of this in 3scale
  16. api.setEndpointType("rest"); //don't think there is an equivalent of this in 3scale
  17. api.setParsePayload(false); // can let user override this?
  18. api.setPublicAPI(true); // is there an equivalent of this?
  19. api.setVersion(defaultVersion); // don't think this is relevant anymore
  20. setPolicies(api, bean);
  21. log.debug("Processing: {0}", config);
  22. log.debug("Creating API: {0}", api);
  23. apis.add(api);
  24. }
  25. dataProcessed = true;
  26. checkQueue();
  27. } catch (DecodeException e) {
  28. failAll(e);
  29. }
  30. }

代码示例来源:origin: io.apiman/apiman-gateway-engine-core

  1. /**
  2. * @see io.apiman.gateway.engine.IRegistry#publishApi(io.apiman.gateway.engine.beans.Api, io.apiman.gateway.engine.async.IAsyncResultHandler)
  3. */
  4. @Override
  5. public void publishApi(Api api, IAsyncResultHandler<Void> handler) {
  6. List<Policy> policies = api.getApiPolicies();
  7. encryptPolicies(api.getOrganizationId(), api.getApiId(), api.getVersion(), EntityType.Api, policies);
  8. encryptEndpointProperties(api.getOrganizationId(), api.getApiId(), api.getVersion(), EntityType.Api, api.getEndpointProperties());
  9. delegate.publishApi(api, handler);
  10. decryptPolicies(api.getOrganizationId(), api.getApiId(), api.getVersion(), EntityType.Api, policies);
  11. decryptEndpointProperties(api.getOrganizationId(), api.getApiId(), api.getVersion(), EntityType.Api, api.getEndpointProperties());
  12. }

代码示例来源:origin: io.apiman/apiman-gateway-engine-vertx-shareddata

  1. } else {
  2. Exception error = new NoContractFoundException(Messages.i18n.format("InMemoryRegistry.NoContractFound", //$NON-NLS-1$
  3. client.getClientId(), api.getApiId()));
  4. handler.handle(AsyncResultImpl.create(error, ApiContract.class));

代码示例来源:origin: io.apiman/apiman-gateway-engine-core

  1. @Override
  2. public void listApis(String organizationId, int page, int pageSize, IAsyncResultHandler<List<String>> handler) {
  3. // For now, ignore paging, but it's there for future. Would need to ensure stable ordering.
  4. List<String> res = map.entrySet().stream()
  5. .map(Map.Entry::getValue)
  6. .filter(entity -> entity instanceof Api)
  7. .map(entity -> (Api) entity)
  8. .filter(api -> api.getOrganizationId().equals(organizationId))
  9. .map(api -> api.getApiId())
  10. .distinct()
  11. .collect(Collectors.toList());
  12. handler.handle(AsyncResultImpl.create(res));
  13. }

代码示例来源:origin: apiman/apiman

  1. private void setPolicies(Api api, Auth3ScaleBean config) { // FIXME optimise
  2. // Add 3scale policy
  3. Policy pol = new Policy();
  4. pol.setPolicyImpl(determinePolicyImpl()); // TODO get version? Hmm! Env?
  5. pol.setPolicyJsonConfig(Json.encode(config));
  6. api.getApiPolicies().add(pol);
  7. // Add any policies user specified in remote config.
  8. policyConfigApis.stream()
  9. .filter(skeleton -> skeleton.getApiId().equals(api.getApiId()))
  10. // Apply policies from skeleton to 3scale API.
  11. .forEach(skeleton -> api.getApiPolicies().addAll(skeleton.getApiPolicies()));
  12. }

代码示例来源:origin: io.apiman/apiman-gateway-platforms-servlet

  1. String endpoint = ApimanPathUtils.join(api.getEndpoint(), request.getDestination());
  2. BasicAuthOptions options = new BasicAuthOptions(api.getEndpointProperties());
  3. if (options.getUsername() != null && options.getPassword() != null) {
  4. if (options.isRequireSSL() && !isSsl) {

代码示例来源:origin: apiman/apiman

  1. /**
  2. * Constructor.
  3. * @param api
  4. * @param request
  5. * @param handler
  6. */
  7. public PolicyTesterApiConnection(Api api, ApiRequest request,
  8. IAsyncResultHandler<IApiConnectionResponse> handler) {
  9. this.request = request;
  10. this.handler = handler;
  11. this.output = null;
  12. this.backEndApi = createBackEndApi(api.getEndpoint());
  13. }

代码示例来源:origin: apiman/apiman

  1. @Override
  2. public void listOrgs(IAsyncResultHandler<List<String>> handler) {
  3. // TODO: We should track set of OrgId -> AtomicCounter if this API has meaningfully high usage.
  4. List<String> res = map.entrySet().stream()
  5. .map(Map.Entry::getValue)
  6. .map(elem -> {
  7. if (elem instanceof Api) {
  8. return ((Api) elem).getOrganizationId();
  9. } else {
  10. return ((Client) elem).getOrganizationId();
  11. }
  12. })
  13. .distinct()
  14. .collect(Collectors.toList());
  15. handler.handle(AsyncResultImpl.create(res));
  16. }

代码示例来源:origin: apiman/apiman

  1. policy.setPolicyJsonConfig(getPolicyConfiguration(config));
  2. Api api = new Api();
  3. api.setEndpoint(backEndApi.getName());
  4. api.setEndpointType("TEST");
  5. api.setOrganizationId(orgId);
  6. api.setApiId(apiId);
  7. api.setVersion(String.valueOf(version));
  8. api.setPublicAPI(true);
  9. api.setApiPolicies(Collections.singletonList(policy));

相关文章