Search code examples
pythonapigee

Get environment name as flow variable


I have two environments which point to the same target endpoint (this is out of my control so please omit from suggesting that I change this).

I have a python script which runs at the response phase of the flow and re-writes the content of the response.

I need to re-write a different var value within that response, depending on the apigee URL corresponding to each environment, i.e:

  1. Environment 1: https://myCompany-env1.apigee.net/myservice/
  2. Environment 2: https://myCompany-env2.apigee.net/myservice/

This is because the output from my endpoint otherwise exposes the target endpoint URL to the public (this is also outside of my control so please omit from suggesting that I make a change at the target endpoint rather than within apigee).

There seem to be plenty of flow variables to access the target endpoint URL, but what is the correct flow variable in order to access the name of the environment? or in other words the name of the apigee URL which was used to hit my endpoint? It does not seem to be listed here.

There is also no HTTP Host header which I can use to query the value either.


Solution

  • Are you asking for the variable that refers to the name of the environment (environment.name) like you asked first or the url used to access the proxy (proxy.url)?

    proxy.url Gets the complete URL associated with the proxy request received by the ProxyEndpoint

    environment.name : Name of the environment

    Both of these are in the link you mentioned.