I donāt know that much about the apigee-templater project, but ⦠I understand that it can be used as a generator tool, to build API proxy bundles from the command line, based on input you provide.
From the README, I understand that there is a fixed set of template options the tool offers. For example, you can choose one of 3 different target types: generic HTTP Urls, BigQuery Queries, or BigQuery Tables. And there are options for APIKey or token validation, and you can include or exclude quotas and spike arrest policies. That all seems like a pretty cool set of features. But I guess most people would want a little more control and flexibility. And for that the rEADME says thereās an extensibility model.
I looked briefly into that, and ⦠it seems like you need to learn a novel plugin framework, a new mental model, to extend the tool to allow it to build from a different template. It seems like youād need to explore that and learn how to do that. Iām sorry I donāt have any experience with that framework and Iām not clear on whether flowcallouts and the like would be easy to include in the thing. Seems like youād need to write some Typescript and so on to make that happen, but I donāt know for sure.
Facing the same challenge, I built an alternative tool, called apigee-proxy-generator, which uses a different approach for extensibility. Rather than defining a new JS or Typescript programming model for the proxy templates, I just used the filesystem. Basically you define your template in terms of an existing API proxy, with placeholders in it. So if you want a FlowCallout, you just insert that FlowCallout into the ProxyEndpoint or TargetEndpoint, and itās there. Itās just like authoring an API proxy, except that you have the opportunity to insert placeholders that get filled in with data at the time you run the generator. This seems like a more approachable way to define templates for your proxies, because you can include whatever you like in the template, and thereās no need to learn a new model, or build a thing like āFlowCalloutPlugin()ā or whatever, in Typescript.
This latter generator tool is not āinteractiveā - it doesnāt have an execution mode in which it asks a bunch of questions interactively, and then does itās generation work. Instead you need to provide all of the input data to the tool in a file. But it seems to me this latter generator tool is more flexible, with the templates as well as the data that you combine with the templates. You can define an arbitrary number of conditional flows. You can have arbitrary policies including FlowCallouts, ExternalCallout, Dialogflow, etc⦠You can include resources like properties files or OASpec files into your generated proxy. You can supply arbitrary custom data to embed into the generated API proxy.
The trickiest thing with this latter tool is⦠the template itself is a lodash template. lodash is a nodejs module that is pretty broad and wide, but ONE of the things it offers is a template engine. Using a template like "Hello {{= name}}" , you combine it with a dataset like { "name" : "Raghu" } and get an output like āHello Raghuā. Obviously it gets more involved than that simple example, but thatās the basic idea. And because Apigee proxy definitions are just text files, applying this template approach to a proxy bundle is easy. The trick is, when authoring new proxy templates, for example, for a proxy that invokes a FlowCallout and so on, you probably need to know the lodash template syntax. You need to know how to specify {{= flow.name}} in the template to provide the name for a conditional flow. And so on. There are examples you can follow, and to ME itās not too difficult, but for other people who donāt know lodash, it might be an obstacle. Can you decipher this:?
<Flows>
<!-- there is one flow for each item in the config -->
{{
flows.forEach( (flow,ix) => {
let amPolicyName = 'AM-PreparedQuery-' + (ix+1);
let d = path.dirname(sourceFilename),
fqAssignMessagePolicyFileName = path.resolve(d, '..', 'policies', amPolicyName + '.xml');
let avContent1 =
" <AssignVariable>\n"+
" <Name>bq_query</Name>\n" +
` <Template>${flow.query}</Template>\n`+
" </AssignVariable>\n";
let avContent2 = ''; /* will optionally hold another AssignVariable */
}}
<Flow name="{{= flow.name}}">
<Request>
<Step>
<Name>VerifyAPIKey-1</Name>
</Step>
{{
let pathPattern = '';
// the query may have named perameters. Extract them. No possibility for SQL injection here.
let re = new RegExp('{[_a-zA-Z][_a-zA-Z0-9]+}','g');
let m = flow.path.match(re);
if (m) {
....
Bottom line, between the apigee-templater project and this latter generator tool, you have some options.