How to get email id or contacts looking at list of proxies in development environment-to clean up

Hi,

We have plenty of proxies in Development environment including all kind of tryout or helloworlds etc..

There are multiple API developers who have access to development environment.

If I have the exercise to clean up or delete the proxies not in use in development environment and want to know who is the API developer who created listed proxies by looking at proxies. Is it possible ?

I do have access to delete all proxies but would like to know who created API and if not use in future just delete them

I can look into analytics or performance information of each API but in certain decision to delte will have to indicate to creator..

Solved Solved
1 4 155
2 ACCEPTED SOLUTIONS

Hi @Abiram Radhakrishnan

Not exactly what you want, but I wrote this utility that uses the Analytics to list the proxies that has had no traffic. See if that helps and then you can use that list and delete the proxies. The tool is called ApigeeBundleReaper

View solution in original post

The information you seek is in the audit trail.

You will need to query the audit stream for your organization, and then find the API proxies in those results. The audit records are stored in time order. So the way to approach it is:

  1. query the audit stream for a period - for example, from 8 hours ago, until now
  2. for each API proxy of interest,
    1. look for a CREATE or UPDATE audit record for that proxy in the resulting list of records
    2. if found, record the username on that record, and remove that proxy from the list of interest
  3. if there are proxies in the list for which no create/update records have been found, then subtract 8 hours and return to step 1

The audit query looks like this:

curl -i -n "https://api.enterprise.apigee.com/v1/audits/organizations/$ORG?endTime=1449105607514&expand=true&startTime=1446513607514"

You need to specify the endTime and startTime in "milliseconds since epoch".

The records that cover API Proxies look like this:

CREATE (import)

{
    "operation": "CREATE",
    "request": "''ORGNAME''",
    "requestUri": "/v1/o/ORGNAME/apis/PROXYNAME/?action=import&name=PROXYNAME",
    "responseCode": "201",
    "timeStamp": 1528146834481,
    "user": "dchiesa@google.com"
}

UPDATE:

{
    "operation": "UPDATE",
    "request": "''ORGNAME''",
    "requestUri": "/v1/organizations/ORGNAME/apis/PROXYNME/revisions/1?validate=true",
    "responseCode": "200",
    "timeStamp": 1528218325640,
    "user": "dchiesa@google.com",
}

I wrote a tool that does this in nodejs. findLastEditor

example usage:

node ./findLastEditorOfProxy.js -o $ORG -v -P proxy1 -P proxy2 ...

It queries the audit trail, searching for the most recent record for each proxy according to the steps I described above. At completion, it emits the list of proxies you specified, with the most recent audit record for creation or update of that API Proxy.

Deployment or undeployment actions are stored in the Audit trail as well. This tool does not count those as a create/update events. If you want to know who last deployed the proxy, that's a different audit record. If you were interested in that, you could create a modified version of this tool to look for deployment records.

View solution in original post

4 REPLIES 4

Hi @Abiram Radhakrishnan

Not exactly what you want, but I wrote this utility that uses the Analytics to list the proxies that has had no traffic. See if that helps and then you can use that list and delete the proxies. The tool is called ApigeeBundleReaper

@Sai Saran Vaidyanathan

thanks for the tool. I had chance to go through the documentation of this tool, additionally I wanted to know email id of proxy creator.

ie in Edge UI Publish-- Developers lists the API developer name email username, but which user have created which proxies or modified any other proxies how do i know ?

I am not admin but wanted to do clean up of proxies after analyzing and also wanted to contact the proxy creator before taking decision to delete the proxies

This tool doesnt do that. You might be able to get that info by running the Mgmt API

https://api.enterprise.apigee.com/v1/organizations/{org}/apis/{proxyName}

It should give a response something like this

{
    "metaData": {
        "createdAt": 1528143738139,
        "createdBy": "abc@abc.com",
        "lastModifiedAt": 1528144612560,
        "lastModifiedBy": "abc@abc.com",
        "subType": "null"
    },
    "name": "SampleDemo",
    "revision": [
        "1"
    ]
}

The information you seek is in the audit trail.

You will need to query the audit stream for your organization, and then find the API proxies in those results. The audit records are stored in time order. So the way to approach it is:

  1. query the audit stream for a period - for example, from 8 hours ago, until now
  2. for each API proxy of interest,
    1. look for a CREATE or UPDATE audit record for that proxy in the resulting list of records
    2. if found, record the username on that record, and remove that proxy from the list of interest
  3. if there are proxies in the list for which no create/update records have been found, then subtract 8 hours and return to step 1

The audit query looks like this:

curl -i -n "https://api.enterprise.apigee.com/v1/audits/organizations/$ORG?endTime=1449105607514&expand=true&startTime=1446513607514"

You need to specify the endTime and startTime in "milliseconds since epoch".

The records that cover API Proxies look like this:

CREATE (import)

{
    "operation": "CREATE",
    "request": "''ORGNAME''",
    "requestUri": "/v1/o/ORGNAME/apis/PROXYNAME/?action=import&name=PROXYNAME",
    "responseCode": "201",
    "timeStamp": 1528146834481,
    "user": "dchiesa@google.com"
}

UPDATE:

{
    "operation": "UPDATE",
    "request": "''ORGNAME''",
    "requestUri": "/v1/organizations/ORGNAME/apis/PROXYNME/revisions/1?validate=true",
    "responseCode": "200",
    "timeStamp": 1528218325640,
    "user": "dchiesa@google.com",
}

I wrote a tool that does this in nodejs. findLastEditor

example usage:

node ./findLastEditorOfProxy.js -o $ORG -v -P proxy1 -P proxy2 ...

It queries the audit trail, searching for the most recent record for each proxy according to the steps I described above. At completion, it emits the list of proxies you specified, with the most recent audit record for creation or update of that API Proxy.

Deployment or undeployment actions are stored in the Audit trail as well. This tool does not count those as a create/update events. If you want to know who last deployed the proxy, that's a different audit record. If you were interested in that, you could create a modified version of this tool to look for deployment records.