Reusable flows

Hi, 

I want to create the below flow. I know how to use each individual policy but the flow definition language seems lacking the ability of splitting the flow into 2. Please, what are my options to define this branch mechanism which might become more complex in the future?

AD_key_exchange.png

 

Regards,

 

Solved Solved
1 4 212
1 ACCEPTED SOLUTION

I understand what you're saying. 

In the Apigee Domain-specific language for flows, Condition elements apply to Step elements. 

Aside from the "Shared flow" concept, There is no way to define a Sequence of Steps, and wrap them all with a Condition.  There is no way to define a callable "local sequence".

I like the idea of doing something like this: 

    <Flow name="myflow">
      <Request>
        <Step>
          <Name>Cache-Lookup-1</Name>
        </Step>
        <If>
          <Condition>cached_variable != null</Condition>
          <Then>
            <Step>
              <Name>AM-AssignB</Name>
            </Step>
          </Then>
          <Else>
            <Step>
              <Name>JavaCallout-1</Name>
            </Step>
            <Step>
              <Name>Cache-Populate-1</Name>
            </Step>
            <Step>
              <Name>AM-AssignB</Name>
            </Step>
          </Else>
        </If>
      </Request>
      <Response>
        <Step>
          <Name>AM-Response</Name>
        </Step>
      </Response>
      <Condition>(proxy.pathsuffix MatchesPath "/t1") and (request.verb = "GET")</Condition>
    </Flow>

...but there is nothing in the Apigee flow language to support this kind of control.  Currently you need to copy/paste the Condition statement in each step that should be in the THEN clause, and apply the opposite of the Condition statement for each step in the Else clause. 

 

View solution in original post

4 REPLIES 4

Hi @mhany 

Have you already checked Shared Flows in Apigee?

thanks, 

regards,

Hi @optimism 

 

Yes, it seems more suitable for flows that will be shared amon multiple proxies however, I think it is an overkill to create a share flow each time I want to reuse a flow in the same proxy.

 

Regards'

Hany

I understand what you're saying. 

In the Apigee Domain-specific language for flows, Condition elements apply to Step elements. 

Aside from the "Shared flow" concept, There is no way to define a Sequence of Steps, and wrap them all with a Condition.  There is no way to define a callable "local sequence".

I like the idea of doing something like this: 

    <Flow name="myflow">
      <Request>
        <Step>
          <Name>Cache-Lookup-1</Name>
        </Step>
        <If>
          <Condition>cached_variable != null</Condition>
          <Then>
            <Step>
              <Name>AM-AssignB</Name>
            </Step>
          </Then>
          <Else>
            <Step>
              <Name>JavaCallout-1</Name>
            </Step>
            <Step>
              <Name>Cache-Populate-1</Name>
            </Step>
            <Step>
              <Name>AM-AssignB</Name>
            </Step>
          </Else>
        </If>
      </Request>
      <Response>
        <Step>
          <Name>AM-Response</Name>
        </Step>
      </Response>
      <Condition>(proxy.pathsuffix MatchesPath "/t1") and (request.verb = "GET")</Condition>
    </Flow>

...but there is nothing in the Apigee flow language to support this kind of control.  Currently you need to copy/paste the Condition statement in each step that should be in the THEN clause, and apply the opposite of the Condition statement for each step in the Else clause.