How do I find out the name of the API Proxy using basepath? I don't see a management API for this type of search.

 
Solved Solved
2 20 7,149
1 ACCEPTED SOLUTION

Not a bug. You need to query the proxy ENDPOINT, not the proxy. Example:

curl -i -n \
 -X GET \
 'https://api.enterprise.apigee.com/v1/o/deecee/apis/weather-quota/revisions/1/proxies/default'

Response includes this:

{
  "type": "Proxy",
  "routeRuleNames": [
    "default"
  ],
  ....
  "connection": {
    "virtualHost": [
      "default"
    ],
    "connectionType": "httpConnection",
    "basePath": "/v1/weather-quota"
  }
}

Any tool would have to take a brute force approach: query each proxy endpoint and look for the matching basepath.

BTW here is a tool that takes this approach.  findProxyForBasepath.js

View solution in original post

20 REPLIES 20

I have the URI (base path + resource path) and I want to locate the API Proxy assoicated with that URI.

@prabhup1

I was going to the api call

curl -v "http://localhost:8080/v1/o/amexe1/apis/testAPI/revisions/1" -u <username>

But even this api call does not give the proxy basepath.

However, there is one way if you have access to POSTGRESS server.

Please let me know if you have access to postgress server then I can give you a query that would return the API PROXY name and associated Proxy basepath.

Hi Gaurav_bhandari,

Please let mr know the way to get it from POSTGRESS.

@gaurav_bhandari  I have access to POSTGRESS. Let me know if you have query.

Please don't ask new questions on 5-year old threads. 

Post a new question. If you like, and if it's helpful, you can refer to an existing thread from your new question. Just paste in the URL of the existing question.  It will automagically hyperlink. 

ask-a-question-2.png

When you post a new question to a 5-year old thread, it's really hard for viewers or potential answerers to find your new question among the existing traffic.  That means people who might like to answer, won't bother to try.  And in many cases (as in this one) the new question is only remotely relevant to the existing question. So it deserves a new thread anyway. 

In general, here's what I humbly suggest: Don't post new questions as replies to others' threads, especially if the existing threads are older than 3 weeks or so. When you have a question, please just post a new question. Posting a new question will result in a better experience for you (you'll get better, more focused answers), and for others (they'll more easily be able to understand and benefit from the discussion).  If you have an answer to someone else's question, post a reply.  Don't post new questions as replies to others' threads.

@gbhandari

Hello, my company does not have a POSTGRESS server.

There is no direct way to arrive at the api proxy from the basepath. This has to be arrived at using multiple management api calls which includes calls for deployments, env and org.

@AMAR DEVEGOWDA - Do we have a script to do this ?

@Venkataraghavan , BasePath information is not available in deployment APIs, I have verified it. It always show basePath as "/" in deployments api list call. It might be a bug. I did some research on this yesterday & didn't find any Management API which has basePath information.

@anilsagar : You are right, There is no deployment api for retrieving basepath. But the basepath to api proxy computation should be possible by using multiple management apis including the deployment management api. We are checking to see if we have any internal scripts that do this orchestration and fetch the api proxy.

@AMAR DEVEGOWDA, @Anil Sagar, @Venkataraghavan

Awesome. Thanks for looking into this guys. I will take a look at the Python script. I hope a future release of Apigee includes a management API that does this.

There is a management API that queries the basepath, though there is no Mgmt API that does the "search" on the server side. In other words, you have to exhaustively query each proxy (really each endpoint on each proxy) for the basepath and look for your result. Querying the proxy endpoint looks like this:

curl -i -n \
 -X GET \
 'https://api.enterprise.apigee.com/v1/o/ORGNAME/apis/PROXYNAME/revisions/REVISION/proxies/default'

Replace all the CAPITALIZED terms with whatever is appropriate in your case.

Dear @prabhup1,

As @Venkataraghavan said there is no single management API to retrieve the API Proxy name for a given basepath. We have to run multiple management api calls to get this information. We have a python script that determines the API proxy name if you specify the basepath. I have attached the zip file (searchbasepath.zip) containing the script and a README file which has instructions how to use this script.

Note: This is a script that we have developed for internal use and it is not supported. It hasn't been tested thoroughly for all scenarios. Request you to use at your discretion.

Regards,

Amar

searchbasepath.zip

@AMAR DEVEGOWDA

I was going through the script. One of the scenario will not work when more than one revision if the same API PROXY is deployed.

apilistresponse = xmlapilist.findall("APIProxy")
apilistrevision = xmlapilist.findall("./APIProxy/Revision")

totalapis= len(apilistresponse)
totalapilistrevision= len(apilistrevision)

The length of array apilistresponse and apilistrevision will be different in case more than one revision of API PROXY is deployed.

Not a bug. You need to query the proxy ENDPOINT, not the proxy. Example:

curl -i -n \
 -X GET \
 'https://api.enterprise.apigee.com/v1/o/deecee/apis/weather-quota/revisions/1/proxies/default'

Response includes this:

{
  "type": "Proxy",
  "routeRuleNames": [
    "default"
  ],
  ....
  "connection": {
    "virtualHost": [
      "default"
    ],
    "connectionType": "httpConnection",
    "basePath": "/v1/weather-quota"
  }
}

Any tool would have to take a brute force approach: query each proxy endpoint and look for the matching basepath.

BTW here is a tool that takes this approach.  findProxyForBasepath.js

Thank you @Dino , Above API is not available in the Apigee Docs here. Am i missing something ? Regarding , Deployment API list, It always shows basePath as "/"

2249-screen-shot-2016-03-25-at-85832-pm.png

@Anil Sagar -

I don't know if you are missing something!

The basepath for a proxy is specified in the proxy endpoint, so you can query it there.

I think the value of the "basepath" property in the deployment response is somewhat misleading. It is appended to the basepath of the proxy endpoint. Usually it is a slash, which means all proxy endpoints will be available on their respective basepaths. If the deployment basepath is /foo, and the proxy endpoint basepath is /bar then the proxy will be available at /foo/bar .

I think that the doc around this could be improved.

My opinion.

Thank you @Dino , @docs , We need to add above API information to Management APIs list. Thank you 🙂

If you export all your proxy zip files, and store them -exploded- under a single directory [ call it "/apis" ], you can use the following:

1. cd into "/apis"

2. execute this command:

> find . -name "*.xml" -exec grep -i /basepath {} \; -ls

3. it will give you an output that shows something like

<BasePath>/PolicyActivity.svc</BasePath>
1434582 8 -rw------- 1 user staff 3346 Oct 14 2015 ./apis/apiproxy/proxies/BLIAR-STARSServices2.xml
<BasePath>/aus-services/api/v1</BasePath>
1435206 16 -rw------- 1 user staff 4313 Oct 14 2015 ./apis/apiproxy/proxies/BLIAUS-WebServices-v1.xml
<BasePath>/AUS-Services</BasePath>
1438160 8 -rw------- 1 user staff 3240 Oct 14 2015 ./apis/apiproxy/proxies/BLIAUS-WebServices.xml
<BasePath>/ClientPolicySvc</BasePath>
1434748 8 -rw------- 1 user staff 3476 Oct 14 2015 ./apis/apiproxy/proxies/BLIDI-ClientPolicyService.xml

where the basepath is listed followed by the name of the proxy's xml file.

Note: it does not tell you if the proxy is deployed or not.

Hello,

I am not sure how significant this solution would be but you can achieve this using Custom Reports in Analytics. - i see you don't have Analytics now 😞 but for other users if this helps.

Create a new custom report,

add Metrics, Dimensions [should be proxy name] , filter [choose the "proxy basepath" condition]

Done.

Check this out - https://github.com/ssvaidyanathan/BasePathNode

Wrote this util to search for proxy with base path