Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactored this sample to use mocktarget
- Loading branch information
Showing
14 changed files
with
146 additions
and
205 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
sample-proxies/variables/apiproxy/policies/parse-json-response.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<ExtractVariables name="parse-json-response"> | ||
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> | ||
<VariablePrefix>mock</VariablePrefix> | ||
<JSONPayload> | ||
<Variable name="firstName"> | ||
<JSONPath>$.root.firstName</JSONPath> | ||
</Variable> | ||
<Variable name="lastName"> | ||
<JSONPath>$.root.lastName</JSONPath> | ||
</Variable> | ||
</JSONPayload> | ||
</ExtractVariables> |
15 changes: 15 additions & 0 deletions
15
sample-proxies/variables/apiproxy/policies/parse-xml-response.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<ExtractVariables name="parse-xml-response"> | ||
<!-- Parse the XML response using XPath. --> | ||
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> | ||
<VariablePrefix>mock</VariablePrefix> | ||
<XMLPayload stopPayloadProcessing="false"> | ||
<Namespaces/> | ||
<Variable name="city" type="string"> | ||
<XPath>//city</XPath> | ||
</Variable> | ||
<Variable name="state" type="string"> | ||
<XPath>//state</XPath> | ||
</Variable> | ||
</XMLPayload> | ||
</ExtractVariables> |
23 changes: 0 additions & 23 deletions
23
sample-proxies/variables/apiproxy/policies/parseforecast.xml
This file was deleted.
Oops, something went wrong.
124 changes: 0 additions & 124 deletions
124
sample-proxies/variables/apiproxy/policies/parsejsonforecast.xml
This file was deleted.
Oops, something went wrong.
6 changes: 6 additions & 0 deletions
6
sample-proxies/variables/apiproxy/policies/read-variables.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<Javascript async="false" continueOnError="false" enabled="true" timeLimit="200" name="read-variables"> | ||
<DisplayName>read-variables</DisplayName> | ||
<Properties/> | ||
<ResourceURL>jsc://read-variables.js</ResourceURL> | ||
</Javascript> |
72 changes: 36 additions & 36 deletions
72
sample-proxies/variables/apiproxy/policies/variables.xml
100644 → 100755
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,38 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<AssignMessage name="variables"> | ||
<AssignTo createNew="false" type="response"></AssignTo> | ||
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> | ||
<Set> | ||
<Headers> | ||
<Header name="system.timestamp">{system.timestamp}</Header> | ||
<Header name="system.time">{system.time}</Header> | ||
<Header name="organization.name">{organization.name}</Header> | ||
<Header name="apiproxy.name">{apiproxy.name}</Header> | ||
<Header name="apiproxy.revision">{apiproxy.revision}</Header> | ||
<Header name="proxy.basepath">{proxy.basepath}</Header> | ||
<Header name="proxy.name">{apiproxy.name}</Header> | ||
<Header name="proxy.pathsuffix">{proxy.pathsuffix}</Header> | ||
<Header name="message.headers.count">{message.headers.count}</Header> | ||
<Header name="message.headers.names">{message.headers.names}</Header> | ||
<Header name="client.ip">{client.ip}</Header> | ||
<Header name="request.uri">{request.uri}</Header> | ||
<Header name="request.headers.names">{request.headers.names}</Header> | ||
<Header name="request.header.user-agent.values">{request.header.user-agent.values}</Header> | ||
<Header name="request.path">{request.path}</Header> | ||
<Header name="request.querystring">{request.querystring}</Header> | ||
<Header name="request.queryparams.names">{request.queryparams.names}</Header> | ||
<Header name="request.queryparam.w">{request.queryparam.w}</Header> | ||
<Header name="request.verb">{request.verb}</Header> | ||
<Header name="target.url">{target.url}</Header> | ||
<Header name="target.host">{target.host}</Header> | ||
<Header name="target.ip">{target.ip}</Header> | ||
<!-- Variables populated by parsing XML response with an ExtractVariables policy --> | ||
<Header name="weather.location">{weather.location}</Header> | ||
<Header name="weather.condition">{weather.condition}</Header> | ||
<Header name="weather.forecast_today">{weather.forecast_today}</Header> | ||
<Header name="weather.forecast_tomorrow">{weather.forecast_tomorrow}</Header> | ||
<!-- Variables populated by parsing JSON response with an ExtractVariables policy --> | ||
<Header name="weather.description">{weather.description}</Header> | ||
<Header name="weather.humidity">{weather.humidity}</Header> | ||
</Headers> | ||
</Set> | ||
<AssignTo createNew="false" type="response"/> | ||
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables> | ||
<Set> | ||
<Headers> | ||
<!--Edge flow variables--> | ||
<Header name="system.timestamp">{system.timestamp}</Header> | ||
<Header name="system.time">{system.time}</Header> | ||
<Header name="organization.name">{organization.name}</Header> | ||
<Header name="apiproxy.name">{apiproxy.name}</Header> | ||
<Header name="apiproxy.revision">{apiproxy.revision}</Header> | ||
<Header name="proxy.basepath">{proxy.basepath}</Header> | ||
<Header name="proxy.name">{apiproxy.name}</Header> | ||
<Header name="proxy.pathsuffix">{proxy.pathsuffix}</Header> | ||
<Header name="message.headers.count">{message.headers.count}</Header> | ||
<Header name="message.headers.names">{message.headers.names}</Header> | ||
<Header name="client.ip">{client.ip}</Header> | ||
<Header name="request.uri">{request.uri}</Header> | ||
<Header name="request.headers.names">{request.headers.names}</Header> | ||
<Header name="request.header.user-agent.values">{request.header.user-agent.values}</Header> | ||
<Header name="request.path">{request.path}</Header> | ||
<Header name="request.querystring">{request.querystring}</Header> | ||
<Header name="request.queryparams.names">{request.queryparams.names}</Header> | ||
<Header name="request.queryparam.w">{request.queryparam.w}</Header> | ||
<Header name="request.verb">{request.verb}</Header> | ||
<Header name="target.url">{target.url}</Header> | ||
<Header name="target.host">{target.host}</Header> | ||
<Header name="target.ip">{target.ip}</Header> | ||
<!-- Variables populated by parsing XML response with an ExtractVariables policy --> | ||
<Header name="mock.city">{mock.city}</Header> | ||
<Header name="mock.state">{mock.state}</Header> | ||
<!-- Variables populated by parsing JSON response with an ExtractVariables policy --> | ||
<Header name="mock.firstName">{mock.firstName}</Header> | ||
<Header name="mock.lastName">{mock.lastName}</Header> | ||
</Headers> | ||
</Set> | ||
</AssignMessage> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,36 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<ProxyEndpoint name="default"> | ||
<Flows> | ||
<Flow name="default"> | ||
<Response> | ||
<Step><Name>parseforecast</Name></Step> | ||
<Step><Name>xmltojson</Name></Step> | ||
<Step><Name>parsejsonforecast</Name></Step> | ||
<Step><Name>variables</Name></Step> | ||
</Response> | ||
</Flow> | ||
</Flows> | ||
<HTTPProxyConnection> | ||
<BasePath>/variables</BasePath> | ||
<VirtualHost>default</VirtualHost> | ||
</HTTPProxyConnection> | ||
<RouteRule name="Route"> | ||
<TargetEndpoint>default</TargetEndpoint> | ||
</RouteRule> | ||
<Flows> | ||
<Flow name="default"> | ||
<Response> | ||
<Step> | ||
<Name>parse-xml-response</Name> | ||
</Step> | ||
<Step> | ||
<Name>read-variables</Name> | ||
</Step> | ||
<Step> | ||
<Name>xmltojson</Name> | ||
</Step> | ||
<Step> | ||
<Name>parse-json-response</Name> | ||
</Step> | ||
<Step> | ||
<Name>read-variables</Name> | ||
</Step> | ||
<Step> | ||
<Name>variables</Name> | ||
</Step> | ||
</Response> | ||
<Request> | ||
</Request> | ||
</Flow> | ||
</Flows> | ||
<HTTPProxyConnection> | ||
<BasePath>/variables</BasePath> | ||
<VirtualHost>default</VirtualHost> | ||
</HTTPProxyConnection> | ||
<RouteRule name="Route"> | ||
<TargetEndpoint>default</TargetEndpoint> | ||
</RouteRule> | ||
</ProxyEndpoint> |
11 changes: 11 additions & 0 deletions
11
sample-proxies/variables/apiproxy/resources/jsc/read-variables.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
var a = context.getVariable("mock.city"); | ||
print(a); | ||
|
||
var b = context.getVariable("mock.state"); | ||
print(b); | ||
|
||
var c = context.getVariable("mock.firstName"); | ||
print(c); | ||
|
||
var d = context.getVariable("mock.lastName"); | ||
print(d); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<TargetEndpoint name="default"> | ||
<HTTPTargetConnection> | ||
<URL>http://weather.yahooapis.com</URL> | ||
</HTTPTargetConnection> | ||
<HTTPTargetConnection> | ||
<URL>http://mocktarget.apigee.net</URL> | ||
</HTTPTargetConnection> | ||
</TargetEndpoint> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,27 @@ | ||
<APIProxy name="variables"> | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | ||
<APIProxy revision="1" name="variables"> | ||
<ConfigurationVersion majorVersion="4" minorVersion="0"/> | ||
<CreatedAt>1462938270155</CreatedAt> | ||
<CreatedBy>wwitman@apigee.com</CreatedBy> | ||
<DisplayName>variables</DisplayName> | ||
<LastModifiedAt>1462938323904</LastModifiedAt> | ||
<LastModifiedBy>wwitman@apigee.com</LastModifiedBy> | ||
<Policies> | ||
<Policy>parse-json-response</Policy> | ||
<Policy>parse-xml-response</Policy> | ||
<Policy>read-variables</Policy> | ||
<Policy>variables</Policy> | ||
<Policy>xmltojson</Policy> | ||
</Policies> | ||
<ProxyEndpoints> | ||
<ProxyEndpoint>default</ProxyEndpoint> | ||
</ProxyEndpoints> | ||
<Resources> | ||
<Resource>jsc://read-variables.js</Resource> | ||
</Resources> | ||
<TargetServers/> | ||
<TargetEndpoints> | ||
<TargetEndpoint>default</TargetEndpoint> | ||
</TargetEndpoints> | ||
<validate>false</validate> | ||
</APIProxy> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.