updating API Proxy with Management API

Not applicable

I've found documentation here

http://apigee.com/docs/management/apis/put/organizations/%7Borg_name%7D/apis/%7Bapi_name%7D/revision...

But it doesn't have any specific details about the accepted element:value pairs that can be used for proxy configuration. Suppose I want to change the base path, or endpoint url, or change virtual hosts, or add policy, or something else. How am I supposed to know how to do this with the API?

0 3 654
3 REPLIES 3

Former Community Member
Not applicable

Hi @Elliot Korte, I agree the documentation could have been better. You can reference the API Proxy Configuration options which gives you the element names of different attributes/settings that you can change in the proxy using the management API. You only have to provide the element:new_value of the attribute/setting that you need to change. Hope this helps.

Not applicable

Hi @Elliot Korte, good question. You can certainly leverage the Management API to apply these changes on API Proxy. However, you will need to will need to run a few steps manually, such as import and override new revision, un-deploy the current revision (without seamless deployment), and deploy last one with changes. As you can tell, there are a few steps required to make changes to APIs getting live traffic. Luckily, there are a few tools to manage the API Lifecycle that will ease the pain of going through each of these steps manually. Apigee Deploy Grunt and Maven plugins are two of them. You should give them a try and let us know your thoughts on them. Cheers!

adas
New Member

Hi @Elliot Korte

The update API for apiproxy works more like a "find and replace" of the entire apiproxy entity. That's the reason, we do not have the option to update specific entities of the apiproxy. Even if you want to do that, you would have to post the entire xml or json. For example:

Let's say my initial apiproxy looks like this:

<ProxyEndpoint name="MyProxy">
    <Description></Description>
    <HTTPProxyConnection>
        <BasePath>/test</BasePath>
        <VirtualHost>default</VirtualHost>
    </HTTPProxyConnection>
</ProxyEndpoint>

Now you want to add an VerifyAPIKey policy to this, so first you add the policy using the management api (or if its already there, you need to use the same policy)

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<VerifyAPIKey enabled="true" continueOnError="false" async="false" name="verifyApiKey">
    <DisplayName>verifyApiKey</DisplayName>
    <FaultRules/>
    <Properties/>
    <APIKey ref="request.queryparam.apikey"></APIKey>
</VerifyAPIKey>

Then, you can add this policy and additionally if you want to change the basepath to /verify in the MyProxy by making the PUT call:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ProxyEndpoint proxyType="httpConnection" name="MyProxy">
    <Description></Description>
    <FaultRules/>
    <Flows/>
    <PostFlow name="PostFlow">
        <Request/>
        <Response/>
    </PostFlow>
    <PreFlow name="PreFlow">
        <Request>
            <Step>
                <FaultRules/>
                <Name>verifyApiKey</Name>
            </Step>
        </Request>
        <Response/>
    </PreFlow>
    <HTTPProxyConnection>
        <BasePath>/verify</BasePath>
        <Properties/>
        <VirtualHost>default</VirtualHost>
    </HTTPProxyConnection>
    <RouteRule name="MyProxyRule">
        <TargetEndpoint>MyTarget</TargetEndpoint>
    </RouteRule>
</ProxyEndpoint>

Note that this would require an undeploy and deploy call like @dzuluaga already mentioned. Also if this is an apiproxy which is already serving live traffic you need to be mindful of downtime and traffic disruption, so you might want to create a new revision first and then update that revision. Once you have the new revision ready, you can use the seamless deployment option to update the proxy definition, which would ensure there's no downtime. For details about the seamless deployment refer to: http://apigee.com/docs/api-services/content/deploy-api-proxies-using-management-api