Is there a more effective way of configuring API's for CA API Gateway

1.2k Views Asked by At

I am trying to configure some API's through CA-API Gateway.

However the CA product seem to be heavily based on UI interaction JSP. I have seen that they also provide REST interface.

Has anyone set up a complete API using something else than the JAVA based UI?

Ideally I would like to have my complete configurations as code.

The REST api for the API Gateway seems to provide a lot of get and post functionality, but I have not been able to get it working:

Executing a get template towards my CA APIGW instance (https://localhost:9443/restman/1.0/services/template) yields:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<l7:Item xmlns:l7="http://ns.l7tech.com/2010/04/gateway-management">
<l7:Name>SERVICE Template</l7:Name>
<l7:Type>SERVICE</l7:Type>
<l7:TimeStamp>2017-06-13T07:30:22.487Z</l7:TimeStamp>
<l7:Link rel="self" uri="https://d7a66e5db02e:9443/restman/1.0/services/template"/>
<l7:Link rel="list" uri="https://d7a66e5db02e:9443/restman/1.0/services"/>
<l7:Resource>
<l7:Service>
<l7:ServiceDetail folderId="FolderID">
<l7:Name>My New Service</l7:Name>
<l7:Enabled>false</l7:Enabled>
</l7:ServiceDetail>
<l7:Resources>
<l7:ResourceSet tag="policy">
<l7:Resource type="policy">Policy XML</l7:Resource>
</l7:ResourceSet>
</l7:Resources>
</l7:Service>
</l7:Resource>
</l7:Item>

From reading the template I expect to be able to create a new published service using post and the following body:

<l7:Service>
<l7:ServiceDetail folderId="0000000000000000ffffffffffffec76">
<l7:Name>MyNewService</l7:Name>
<l7:Enabled>false</l7:Enabled>
</l7:ServiceDetail>
<l7:Resources>
<l7:ResourceSet tag="policy">
<l7:Resource type="policy">Policy XML</l7:Resource>
</l7:ResourceSet>
</l7:Resources>
</l7:Service>

The POST to https://localhost:9443/restman/1.0/services however yields:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>400 Bad Request</title>
</head>
<body>
<h1>Bad Request</h1>
<h3>The request sent by the client was syntactically incorrect.</h3>
</body>
</html>

And there is no apparent way for me to debug what actually fails. I would expect to be able to trace the error in a log somewhere but can not find any documentation or examples of this.

2

There are 2 best solutions below

0
On

The following worked for me:

  • Query the object type you'd like to create, e.g. GET /restman/1.0/services/{ID} or use GET /restman/1.0/services?name={service-name}
  • To create a new instance, find the right sub-element of the XML response, e.g. for services //Item/Resource/Service
  • Use this sub-element in your RESTMAN POST request

If you'd like to oupdate an existing service:

  • Query the existing version number (and ID)
  • PUT /restman/1.0/services/{ID} with version in the version attribute

If the version does not match, the update will fail.

1
On

There is no good alternative to native CA Policy manager application, but you can use REST management API's to make updates and move policy code between different environments. All policies are written in XML so you can export them to a file and manage them in your normal version control system. You can use deployment tools like Jenkins https://jenkins.io where you can configure custom plugin to integrate it with API deployments, but you will still have to rely on RESTMAN API's.

Hope that helps!