<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Brendon Stephens on Medium]]></title>
        <description><![CDATA[Stories by Brendon Stephens on Medium]]></description>
        <link>https://medium.com/@brendon-stephens?source=rss-61c5035480a0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*rWTcvRCIuAPE3IGE.jpg</url>
            <title>Stories by Brendon Stephens on Medium</title>
            <link>https://medium.com/@brendon-stephens?source=rss-61c5035480a0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 07:48:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@brendon-stephens/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Managing IBM DataPower Configuration as XML on OpenShift and Kubernetes]]></title>
            <link>https://medium.com/@brendon-stephens/managing-ibm-datapower-configuration-as-xml-on-openshift-and-kubernetes-260796a2a963?source=rss-61c5035480a0------2</link>
            <guid isPermaLink="false">https://medium.com/p/260796a2a963</guid>
            <category><![CDATA[datapower]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[ibm-datapower]]></category>
            <category><![CDATA[ibm-api-connect]]></category>
            <category><![CDATA[openshift]]></category>
            <dc:creator><![CDATA[Brendon Stephens]]></dc:creator>
            <pubDate>Fri, 20 Nov 2026 00:45:08 GMT</pubDate>
            <atom:updated>2026-11-20T00:47:16.707Z</atom:updated>
            <content:encoded><![CDATA[<p>The DataPower Operator for OpenShift and Kubernetes requires domain configuration to be supplied as .cfgfiles in ConfigMaps referenced from the DataPowerServicecustom resource.</p><p>Every guide and example online follows this pattern. There does not appear to be any documented examples of supplying XML-based configuration through the same path.</p><p>This article proposes one way to manage configuration as XML instead. XML is the the format many teams have long used for configuration management on IBM DataPower appliances via the XML Management Interface (SOMA) and domain imports. Using XML has several practical advantages over using CFG/CLI commands.</p><h3>The issue with CFG configuration</h3><p>From a practical standpoint defining DataPower object configuration as CFG/CLI commands creates several ongoing issues:</p><ul><li><strong>It’s hard to read.</strong> Some commands can take 10+ positional arguments with no labels. For example, a single aaa-policy definition is like reading a long opaque string. Without labels or structure, it is difficult to read, update and template.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wAVlq3vhdt1CFn0ZJ1wcvg.png" /><figcaption>Example AAA Policy defined in .cfg</figcaption></figure><ul><li><strong>You can’t validate it before deployment.</strong> There is no schema or structural check you can run against a CFG file. Syntax errors, missing dependencies, or incorrect object references only surface when the file is applied on the container. That makes the development experience slow and increases the chance of broken domain config on startup.</li><li><strong>Updating it is a delicate process.</strong> Because the file is an ordered sequence of commands, the safest way to change anything is usually through a fresh export. CFG files are fragile, and manually editing them can risk breaking the ordering or syntax of the CFG. If your CFG is templated, it can make even the smallest of updates cumbersome.</li><li><strong>It’s difficult to migrate.</strong> Teams coming from traditional deployments (physical appliances or VMware) often already manage configuration as XML. Moving to the DataPower Operator can force a rewrite or conversion of that XML into CFG, as is suggested in the <a href="https://www.ibm.com/docs/en/cloud-paks/cp-integration/16.1.3?topic=pak-datapower-gateway-transformation-guide">official migration guide.</a></li></ul><h3>A cleaner approach is to keep the source of truth as XML</h3><p>DataPower appliances allow for full configuration of the appliance through schema-validated requests (using the SOMA) and domain imports (export.xml).</p><p>Practical benefits of using xml:</p><ul><li><strong>It’s structured and human-readable.</strong> Every property has a label. Instead of a long positional command with a dozen unnamed arguments, you see explicit elements such as &lt;LocalAddress&gt;, &lt;LocalPort&gt;, &lt;SSLServerProfile&gt;, etc. The configuration is much easier to read and understand.</li><li><strong>You can validate it before deployment.</strong> The XML can be checked against schemas published on the DataPower. This can be done in a pipeline before anything is applied, <strong>or even in the IDE with schema-aware editing</strong>.</li><li><strong>Incremental updates are easier.</strong> Because the structure is explicit and order is less brittle than a CLI script, targeted edits are safer. You are less likely to break object dependencies when you change a single service or policy.</li><li><strong>It’s transformable with XSLT.</strong> Environment-specific values (hostnames, ports, remote endpoints, logging targets, etc.) can be injected or overridden with standard XSLT transforms.</li><li><strong>It aligns with existing practices.</strong> Teams that already manage configuration via the XML Management Interface or export.xml on physical or VMware appliances can continue to use that format instead of rewriting everything into CFG.</li></ul><h3>Implementation</h3><p>Note: There does not appear to be direct support for managing configuration as XML, and the solution proposed below may be considered a hack.</p><p>The DataPower Operator will still require you to define a ConfigMap containing.cfg in the dpApp.config , but you can keep the real configuration as XML and use the Operator’s extraExe and initCmds hooks to load it.</p><p>The pattern is:</p><ol><li>Store the configuration as XML artefacts. Keep the domain’s export.xml (or a cleaned subset of object definitions) as the source of truth. Environment-specific values can be injected using a templating engine like Helm, Jinja2 or something like XSLT in the pipeline before the ConfigMap is created.</li><li>Create a ConfigMap containing the export.xml file(s). Reference that ConfigMap under spec.extraExe (or additionalExtraExe on an IBM API Connect GatewayCluster resource). This mounts the XML into the pod at /usr/local/extra/ before DataPower starts.</li><li>Mount an init script via another extraExe ConfigMap. Reference the script in spec.initCmds (or additionalInitCmds). The script copies the mounted export.xml into the domain’s filesystem so it is available for import.</li><li>Create a small, stable .cfg that only does the import. Reference this .cfg as a normal dpApp.config ConfigMap. The CFG simply points to the XML file that the init script copied to the local directory and runs the import. Because the bulk of the configuration lives in the XML, this CFG never needs to change.</li><li>The Operator still reconciles and rolls out the pods as usual. The only difference is that the meaningful configuration is the XML, and the CFG is reduced to a thin import trigger. This lets you keep the structured, validatable XML as the source of truth while staying inside the mechanisms the DataPower Operator already supports.</li></ol><p>Here is how it looks in practice:</p><pre>---<br># .cfg script that will import default domain config<br>apiVersion: v1<br>kind: ConfigMap<br>metadata:<br>  name: import-default-xml-cfg<br>data:<br>  import.cfg: |<br>    top; config;<br>    import-package default-cfg<br>      source-url &quot;local:///export.xml&quot;<br>      import-format XML<br>      overwrite-files on<br>      overwrite-objects on<br>      auto-execute on<br>    exit<br>    import-execute default-cfg<br>    write mem<br><br>---<br># .cfg script that will import application dmoain config<br>apiVersion: v1<br>kind: ConfigMap<br>metadata:<br>  name: import-services-xml-cfg<br>data:<br>  import.cfg: |<br>    import-package services-cfg<br>      source-url &quot;local:///services/export.xml&quot;<br>      import-format XML<br>      overwrite-files on<br>      overwrite-objects on<br>      auto-execute on<br>    exit<br>    import-execute services-cfg<br>    write mem<br><br>---<br># ConfigMap that is mounted to the container using the extraExe property.<br># Contains the copy script and the export xml.<br>apiVersion: v1<br>kind: ConfigMap<br>metadata:<br>  name: idg-export-xml<br>data:<br>  copy-export-xml.sh:<br>    #!/bin/bash<br>    echo &quot;Running $(basename $0)...&quot;<br> <br>    MOUNT_DIR=&quot;/usr/local/extra&quot;<br>    LOCAL_DIR=&quot;/opt/ibm/datapower/drouter/local&quot;<br><br>    mkdir -p &quot;$LOCAL_DIR/services&quot;<br><br>    cp &quot;$MOUNT_DIR/default-export.xml&quot; &quot;$LOCAL_DIR/export.xml&quot;<br>    cp &quot;$MOUNT_DIR/services-export.xml&quot; &quot;$LOCAL_DIR/services/export.xml&quot;<br><br>    echo &quot;Finished $(basename $0)&quot;<br><br>  default-export.xml:<br>    &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br>    &lt;datapower-configuration version=&quot;3&quot;&gt;<br>      &lt;configuration domain=&quot;default&quot;&gt;<br>        &lt;!-- default domain config goes here --&gt;<br>      &lt;/configuration&gt;<br>    &lt;/datapower-configuration&gt;<br><br>  services-export.xml:<br>    &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br>    &lt;datapower-configuration version=&quot;3&quot;&gt;<br>      &lt;configuration domain=&quot;services&quot;&gt;<br>        &lt;!-- services domain config goes here --&gt;<br>      &lt;/configuration&gt;<br>    &lt;/datapower-configuration&gt;<br><br>---<br># Example DataPowerService illustrating how to mount and import the config<br>apiVersion: datapower.ibm.com/v1beta3<br>kind: DataPowerService<br>metadata:<br>  name: idg-sandbox<br>spec:<br>...<br>  domains:<br>    - name: default<br>      dpApp:<br>        config:<br>          - import-default-xml-cfg # runs cli to import default-export.xml<br>    - name: services<br>      dpApp:<br>        config:<br>          - import-services-xml-cfg # runs cli to import servicex-export.xml<br>  extraExe:<br>    - idg-export-xml # mounts export.xml and copy script<br>  initCmds:<br>    - /usr/local/extra/copy-export-xml.sh # invokes copy script on init<br>...</pre><p>From here you have your basepoint and can expand on it with additional domains, introduce templating like Helm/Jinja2 and then migrate it into your GitOps solution like ArgoCD.</p><h3>Validating your config at deploy time</h3><p>The big win with this is that you can validate your config before you deploy. To do this you can pull the store:///xml-mgmt.xsd and other related schemas down and use them in your pipelines.</p><p>The xml-mgmt schema will contain all of the base types. You may need to do some minor tweaking of the schema depending on what your configuration management strategy looks like.</p><p>In my case, I store the configuration using the &lt;configuration&gt; element as the base element, so I needed to add a top level element to the schema</p><pre>&lt;xsd:element name=&quot;configuration&quot; type=&quot;tns:AnyConfigElement&quot;/&gt;</pre><p>I also need to add theelementFormDefault=”qualified” to the root xsd:schema element</p><pre>&lt;xsd:schema targetNamespace=&quot;http://www.datapower/schemas/management&quot;<br>  xmlns:tns=&quot;http://www.datapower.com/schemas/management&quot;<br>  xmlns:xsd=&quot;http://www.w3.org/2001/XMLSchema&quot; elementFormDefault=&quot;qualified&quot;&gt;</pre><h3>Bonus: Schema-aware editing in the IDE</h3><p>Now that you have the schemas, you can use these in an IDE like vscode for schema-aware editing. It will provide you instant feedback if your changes are valid, and provides some guidance on what elements are available to add.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*grsvFP2o5dD9KQpCZX7AKQ.png" /><figcaption>Instant feedback of invalid config</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/831/1*R14Fp7C9cu6fmPI7jduENg.png" /><figcaption>Element and enumeration hints</figcaption></figure><h3>Summary</h3><p>This config management pattern keeps the source of truth as structured XML while still working inside the confines of the DataPower Operator interface. Working with XML provides a better developer experience by making the config more readable, validatable, and easier to update.</p><p>I’m always looking to expand my knowledge of API Connect and DataPower. If you have implemented a different solution, I’d be interested to know. Please share in the comments or on LinkedIn.</p><p><a href="https://www.linkedin.com/in/brendon-stephens/">https://www.linkedin.com/in/brendon-stephens/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=260796a2a963" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[IBM API Connect on OCP - Injecting pod-specific properties into DataPower config objects]]></title>
            <link>https://medium.com/@brendon-stephens/ibm-api-connect-on-ocp-injecting-pod-specific-properties-into-datapower-config-objects-3a6422ffc8e4?source=rss-61c5035480a0------2</link>
            <guid isPermaLink="false">https://medium.com/p/3a6422ffc8e4</guid>
            <category><![CDATA[ibm-api-connect]]></category>
            <category><![CDATA[apiconnect]]></category>
            <category><![CDATA[ibm-datapower]]></category>
            <category><![CDATA[openshift]]></category>
            <category><![CDATA[datapower]]></category>
            <dc:creator><![CDATA[Brendon Stephens]]></dc:creator>
            <pubDate>Fri, 17 Apr 2026 03:12:34 GMT</pubDate>
            <atom:updated>2026-04-19T03:26:23.759Z</atom:updated>
            <content:encoded><![CDATA[<h3>IBM API Connect on OCP — Injecting pod-specific properties into DataPower config objects</h3><p><em>I’m currently working a project to migrate IBM API Connect and DataPower to OpenShift. We’re going with a full GitOps “everything as code” approach to infrastructure deployment using ArgoCD.</em></p><p><em>To share what I’m learning, I’m writing some short articles focused on practical tips and tricks that I discover along the way. If you’re working with the same technologies, I am interested to hear feedback or any alternative ways that you have approached the same problems.</em></p><h4><strong>Log Targets and the local identifier property in DataPower</strong></h4><p>The <strong>Log Target</strong> config object defines where DataPower sends its log and audit messages. <strong>Syslog </strong>is a type of Log Target that forwards those messages to a centralised syslog server (using UDP or TCP).</p><p>One of the mandatory config properties for the syslog target is the <strong>Local Identifier</strong> (local-ident) property. This string is prepended to every syslog message, allowing your central logging platform to identify which DataPower instance (appliance, VM, or Kubernetes pod) generated the message.</p><p>A syslog message looks like this:</p><p><em>&lt;11&gt;Apr 16 02:56:06 </em><strong><em>dev-gwv6-default-ext-0</em></strong><em> [0x88c00002][apigw][error] source-https(apiconnect_https_9443): trans(117824)[172.24.2.2]: The request URL ‘</em><a href="https://api.dev-gwv6-default-ext.apps.example.org/"><em>https://api.dev-gwv6-default-ext.apps.example.org/</em></a><em>&#39; is not routed to any API collection.</em></p><p>Here you can see that <strong>dev-gwv6-default-ext-0 </strong>is the unique local identifier.</p><h4><strong>The problem in containerised deployments</strong></h4><p>In traditional VM or physical appliances, you would usually set the identifier once at deploy time, and it would never change. The config gets persisted onto the filesystem.</p><p>In the Kubernetes/OpenShift world, pod hostnames are dynamic and assigned at runtime (eg. dev-gwv6-default-ext-0, etc). Because DataPower configuration files are static (usually mounted from ConfigMaps), you cannot inject the pod name at build time.</p><h4><strong>Solution — making use of the initCmds hook</strong></h4><p>The <strong>DataPowerService</strong> custom resource exposes two properties called <em>extraExe</em> and <em>initCmds </em>(on the <strong>GatewayCluster </strong>resource these are called <em>additionalExtraExe </em>and <em>additionalInitCmds</em>)</p><p>These properties allow you run scripts after the container starts, but before DataPower imports its configuration.</p><p>Using these, you can put a placeholder in the config and replace it with the pod hostname after the container starts up. This is a similar mechanism that IBM use to implement the Gateway Peering configuration.</p><h4>Implementation</h4><p>First, create the ConfigMap resource containing the hook script that will replace the placeholder variables.</p><pre>apiVersion: v1<br>kind: ConfigMap<br>metadata:<br>  name: init-pod-vars-sh<br>data:<br>  init-pod-vars.sh: |<br>    #!/bin/base<br><br>    echo &quot;Running $(basename $0)...&quot;<br><br>    HOSTNAME=$(hostname)<br><br>    echo &quot;Injecting &#39;\$LOCAL_IDENT&#39; with &#39;$HOSTNAME&#39;&quot;<br>    find /opt/ibm/datapower/drouter/config -type f -name &quot;*.cfg&quot; -exec \<br>        sed -i &quot;s|\$LOCAL_IDENT|$HOSTNAME|g&quot; {} \;<br><br>    echo &quot;$(basename $0) completed.&quot;</pre><p>Next, create the ConfigMap containing the DataPower config</p><pre>apiVersion: v1<br>kind: ConfigMap<br>metadata:<br>  name: apiconnect-logging-cfg<br>data:<br>  cfg: |<br>    logging target &quot;apic-pre-processing&quot;<br>      summary &quot;Captures useful pre-processing events that are not captured by our internal runtime framework&quot;<br>      type syslog<br>      ... <br>      local-ident &quot;$LOCAL_IDENT&quot;<br>      remote-address &quot;syslog-server.example.com&quot; &quot;12000&quot;<br>      ...<br>    exit</pre><p>Lastly, configure these ConfigMaps in your <strong>GatewayCluster </strong>or <strong>DataPowerService </strong>resources. The script will then be mounted into the <em>/usr/local/extra</em> directory and executed before the DataPower config is imported.</p><pre>apiVersion: gateway.apiconnect.ibm.com/v1beta1<br>kind: GatewayCluster<br>metadata:<br>  annotations:<br>    apiconnect-operator/cp4i: &quot;false&quot;<br>  labels:<br>    app.kubernetes.io/instance: dev-apic-sandpit-dev-apic-sandpit<br>    app.kubernetes.io/managed-by: ibm-apiconnect<br>    app.kubernetes.io/name: dev-gwv6-default-ext<br>  name: dev-gwv6-default-ext<br>spec:<br>  additionalDomainConfig:<br>  - dpApp:<br>      config:<br>      # mount the datapower config to the container<br>      - apiconnect-logging-cfg <br>    name: apiconnect<br>  additionalExtraExe:<br>  # mount the script to the container<br>  - init-pod-vars-sh <br>  additionalInitCmds:<br>  # execute the script<br>  - /usr/local/extra/init-pod-vars.sh <br>... </pre><p>or</p><pre>apiVersion: datapower.ibm.com/v1beta3<br>kind: DataPowerService<br>metadata:<br>  name: dev-gwv6-default-ext<br>spec:<br>  domains:<br>    dpApp:<br>      config:<br>      # mount the datapower config to the container<br>      - apiconnect-logging-cfg<br>    name: apiconnect<br>  extraExe:<br>  # mount the script to the container<br>  - init-pod-vars-sh<br>  initCmds:<br>  # execute the script<br>  - /usr/local/extra/init-pod-vars.sh<br>...</pre><h4><strong>Other use cases?</strong></h4><p>The pattern is very flexible. In theory you can inject any pod or cluster-specific value (namespace, node name, labels, etc.) and even create JSON/XML artefacts on the local filesystem for use in processing policies. This could be useful for enriching your analytics events with cluster information.</p><p>I’m interested to see how others are using this.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3a6422ffc8e4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Grep DataPower Logs from the CLI]]></title>
            <link>https://medium.com/@brendon-stephens/grep-datapower-logs-from-the-cli-ac860f5ddce3?source=rss-61c5035480a0------2</link>
            <guid isPermaLink="false">https://medium.com/p/ac860f5ddce3</guid>
            <category><![CDATA[apiconnect]]></category>
            <category><![CDATA[apics]]></category>
            <category><![CDATA[cli]]></category>
            <category><![CDATA[datapower]]></category>
            <category><![CDATA[ibm]]></category>
            <dc:creator><![CDATA[Brendon Stephens]]></dc:creator>
            <pubDate>Wed, 18 Jun 2025 10:45:09 GMT</pubDate>
            <atom:updated>2025-06-18T11:25:27.772Z</atom:updated>
            <content:encoded><![CDATA[<h4>Lightweight CLI tool for fetching and filtering logs from IBM DataPower.</h4><p>Working with IBM DataPower usually means jumping through hoops to access logs. Debugging often requires logging into multiple hosts, navigating a slow WebGUI, or using the SSH-based CLI that doesn’t support filtering or search. As a result, you often have to rely on log shipping, which may be delayed or unavailable during outages or under periods of heavy load.</p><p>To make this easier, I wrote dplogs.sh - a lightweight Bash script that pulls logs directly from DataPower over the SOMA interface. It decodes the response and outputs plain, readable logs to the terminal. You can filter with regex, follow logs in real time, highlight key events, and pipe the output into tools like grep or less. It requires <strong>no external dependencies</strong> beyond standard Unix tools and works on Linux, macOS and Windows via Git Bash or WSL.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yafQMwICkeC08-Ab-f4VHg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gOzZoZeWpmgxulZclupwlw.gif" /><figcaption>dplogs.sh works on Windows, Linux and MacOS and only requires basic Unix dependencies</figcaption></figure><h3>How It Works</h3><p>dplogs.sh uses the DataPower SOAP Management Interface (SOMA) to retrieve log files. Under the hood, it builds a simple XML request, sends it via curl, and extracts the base64-encoded log content from the SOAP response.</p><p>The log data is then decoded, optionally filtered, highlighted, and printed to standard output. If follow mode is enabled, it polls the appliance at regular intervals and prints new log entries as they appear, similar to howtail -f works.</p><p>Because the output is plain text, you can pipe it directly into other tools like grep, less, awk, or custom scripts, making it much easier to search, filter, and navigate logs during debugging.</p><h3>Installation</h3><p>Download the script directly and update the executable permissions:</p><pre>curl -O https://raw.githubusercontent.com/brendon-stephens/apic-snippets/refs/heads/master/scripts/dplogs.sh<br>chmod +x dplogs.sh</pre><p>Move it somewhere on your PATH if you want to use it globally:</p><pre>mv dplogs.sh /usr/local/bin/</pre><h3>Usage Examples</h3><pre>Usage: dplogs.sh &lt;host&gt; --user &lt;username&gt; [options]<br><br>Required:<br>  &lt;host&gt;                  Datapower hostname to query<br>  --user &lt;username&lt;&gt;      HTTP basic auth username<br><br>Options:<br>  -f                      Follow mode (like tail -f)<br>  -p &lt;pattern&gt;            Regex pattern to filter on<br>  --lines &lt;N&gt;             Show only last N lines<br>  --file &lt;path&gt;           File to fetch from logtemp:/ dir (default: defaultlog)<br>  --domain &lt;name&gt;         Datapower domain to query (default: default)<br>  -u, --user &lt;username&gt;   HTTP basic auth username<br>  --password &lt;password&gt;   HTTP basic auth password (will prompt if not set)<br>  -h, --help              Show this help message</pre><p>Show the last 100 lines from the defaultlogin the default domain:</p><pre>dplogs.sh dp01 -u admin</pre><p>Follow the log output in near-real time (works like tail -f):</p><pre>dplogs.sh dp01 -u admin -f</pre><p>Pattern match the term TransactionOverviewfrom the overview.log and show the last 10 matching lines.</p><pre>dplogs.sh dp01 -u admin -p &quot;TransactionOverview&quot; --file &quot;overview.log&quot; --lines 10</pre><p>Show lines matching failure-related keywords</p><pre>dplogs.sh dp01 -u admin -p &#39;fail|error|denied&#39;</pre><p>Show GatewayScript runtime errors and exception traces</p><pre>dplogs.sh dp01 -u admin -p &#39;GatewayScript.*(Exception|Error|throw)&#39;</pre><p>It works well as a standalone script, but it also <strong>plays nicely in pipes and toolchains.</strong></p><p>Grep expired lines and pipe to less:</p><pre>dplogs.sh dp01 -p &#39;cache&#39; | grep -v expired | less</pre><p>Count the number of cache expired error lines:</p><pre>dplogs.sh dp01 -p &#39;cache&#39; | grep -v expired | wc -l</pre><h3>Integration with Wrapper Scripts</h3><p>In many environments, credentials and endpoint details are centrally managed via vaults or local config files on a management server. To support that, dplogs.sh is designed to work cleanly behind wrapper scripts that can inject credentials, domains, or other options at runtime.</p><p>The script accepts --user, --password, --domain, and other arguments explicitly, so wrapper layers can populate them dynamically without modifying the core logic.</p><p>You can build interactive wrappers that pull from an inventory or prompt for host selection, then pass through the remaining args untouched, preserving the ability to grep, tail, or filter just like normal.</p><pre>brendon@BRENDONXPS15:/# ./wrapper.sh -f -p GatewayScript<br><br>Select the cluster:<br>1) ClusterA<br>2) ClusterB<br>3) ClusterC<br>#? 2<br><br>Select the environment:<br>1) dev<br>2) test<br>3) stage<br>4) prod<br>#? 2<br><br>Select the host:<br>1) test01.clusterb.com<br>2) test02.clusterb.com<br>3) test03.clusterb.com<br>#? 2<br><br>Select the domain:<br>1) DomainA<br>2) DomainB<br>3) DomainC<br>#? 2<br><br>Running dplogs.sh with args:<br>  Host         : test02.clusterb.com<br>  Domain       : DomainB<br>  Username     : admin<br>  Log File     : logtemp:/default-log<br><br>20250618T085747.900Z [0x85800007][gatewayscript][error] mpgw(temp): tid(1320181)[request][172.18.0.1] gtid(568c24b068527f8b001424f5): GatewayScript processing Error &#39;ReferenceError: hello is not defined<br>In file &#39;local:///testing.js&#39; line:8, stack:ReferenceError: hello is not defined<br>    at Object.&lt;anonymous&gt; (local:///testing.js:4:18)<br>    at Script.execute (gatewayscript:///datapower.js:158:24)<br>    at Object.&lt;anonymous&gt; (gatewayscript:///datapower.js:585:55)&#39;</pre><h3>Conclusion</h3><p>dplogs.sh is intended for admins, support teams, and engineers who want quick and structured access to DataPower logs without relying on the GUI or custom tooling. It’s small, dependency-light, and integrates well with existing Bash-based toolchains.</p><p>It doesn’t replace centralized logging or SIEM, it just makes raw log access faster and more readable when you need it.</p><h4><strong>Source Code</strong></h4><p>You can find the script on GitHub:</p><p><a href="https://github.com/brendon-stephens/apic-snippets/blob/master/scripts/dplogs.sh">apic-snippets/scripts/dplogs.sh at master · brendon-stephens/apic-snippets</a></p><p><a href="https://github.com/brendon-stephens/apic-snippets/blob/master/scripts/wrapper.sh">apic-snippets/scripts/wrapper.sh at master · brendon-stephens/apic-snippets</a></p><p>Feedback and improvements welcome.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ac860f5ddce3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Solution for role-based access to API Connect v2018 portals]]></title>
            <link>https://medium.com/@brendon-stephens/solution-for-role-based-access-to-api-connect-v2018-portals-11d8d1c25043?source=rss-61c5035480a0------2</link>
            <guid isPermaLink="false">https://medium.com/p/11d8d1c25043</guid>
            <category><![CDATA[ibm-api-connect]]></category>
            <category><![CDATA[datapower]]></category>
            <category><![CDATA[apiconnect]]></category>
            <category><![CDATA[ibm-datapower]]></category>
            <category><![CDATA[apiconnect-2018]]></category>
            <dc:creator><![CDATA[Brendon Stephens]]></dc:creator>
            <pubDate>Thu, 02 Jul 2020 09:22:43 GMT</pubDate>
            <atom:updated>2020-07-02T09:53:31.570Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>There is no out of the box solution for role-based access into API Connect v2018 portals. This article presents one potential solution to this problem by utilising a proxy service to intercept /token responses from a third-party OIDC provider (OP). By intercepting these responses, we have a logic point post-authentication that allows us to perform a corporate LDAP lookup and provision the applicable API Connect user resources using the REST management interface.</p><h3>High-level Overview</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/750/1*EyFwvrqzYOHKnp7ZubUxIA.png" /></figure><ol><li>The user logs onto the API Connect portal. (Note this has only been tested on the cloud admin and manager portals, but the idea should be easily transferable to the developer portal).</li><li>Using a configured third-party OIDC user registry, the portal makes a standard OAuth 2.0 /authorize call to the OIDC Provider (OP).</li><li>The OP performs the standard OAuth 2.0 authorization ‘dance’ with the API Connect portal.</li><li>API Connect uses the granted authorization code to retrieve an OAuth 2.0 token for the authenticated user.</li><li>Rather than route directly to the OP, we route the /token request through a DataPower XML Firewall service. The service proxies the request to the OP and the OP returns an OAuth 2.0 token.</li><li>Using the token, the DataPower service performs a lookup to the corporate LDAP. The LDAP returns a list of relevant groups to API Connect and their associated members. (Note: this could also be coded to return a list of groups associated with the authenticated user).</li><li>Using the LDAP results, the DataPower service provisions access in API Connect by interacting with the REST management interface.</li><li>The DataPower proxies back the OAuth 2.0 token response to the portal.</li></ol><h3>DataPower Token Proxy Service</h3><p>A full copy of the code is available on GitHub</p><p><a href="https://github.com/brendon-stephens/apic_v2018_snippits/tree/master/portal_rbm">https://github.com/brendon-stephens/apic_v2018_snippits/tree/master/portal_rbm</a></p><p>The token proxy service was implemented using an XML Firewall. This equally could have been done on a Multi-Protocol Gateway Service (MPGW).</p><p>I tried to keep the proxy policy as simple as possible — the less that can go wrong the better. In hindsight I would include an error catch to ensure we always return OAuth 2.0 compliant responses.</p><p>In this example there is just one response match which has a single GatewayScript processing action. This GatewayScript action will decode the token, perform the corporate LDAP lookup, and orchestrate the relevant API Connect REST management interface calls.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qEbhCdIUalVrn3njVfRUjQ.png" /></figure><h4>Overview of GatewayScript Code</h4><p>Full code available at: <a href="https://github.com/brendon-stephens/apic_v2018_snippits/blob/master/portal_rbm/local/authorize-user.js">https://github.com/brendon-stephens/apic_v2018_snippits/blob/master/portal_rbm/local/authorize-user.js</a></p><p>At a high level the script will….</p><ol><li>Decode the id_token returned by the OP.</li><li>Retrieve an access token required for interactions with the API Connect REST interface.</li><li>Query and attempt to find an associated “user” resource in the user registry. If it doesn’t exist, it will create a new one using details from the id_token.</li><li>Query the LDAP server to get a list groups related to API Connect, and a list of their associated members.</li><li>Retrieve all the API Connect organisation roles and map these to their associated LDAP groups.</li><li>Query and attempt to find an associated “member” resource. If found it will update the existing resource with the matched roles (if any), otherwise it will create a new one.</li></ol><p>As the API Connect REST calls are quite similar, they’re all invoked through a common function to ensure consistentcy in response processing and error handling.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/17d873586d787b82abd45e81cdb598a8/href">https://medium.com/media/17d873586d787b82abd45e81cdb598a8/href</a></iframe><h4>Querying LDAP in GatewayScript</h4><p>The LDAP search is done using dp:ldap-search functionality, which is only available as an XSLT extension. As such we need to write a wrapper stylesheet to perform the lookup. The wrapper stylesheet is called using the transform module provided in GatewayScript.</p><p>After the LDAP query is complete a second stylesheet is run to transform the LDAP XML response into JSON (via JSONX). This allows us to process the LDAP response as native JS object rather than using XML DOM.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0a3bc95f521e70b05dc9dc9342648cb9/href">https://medium.com/media/0a3bc95f521e70b05dc9dc9342648cb9/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/218cd3ebda0783d48480de631560a94e/href">https://medium.com/media/218cd3ebda0783d48480de631560a94e/href</a></iframe><h3>Conclusion</h3><p>Role-based access can be achieved for API Connect. The solution is not ideal and of course will introduce a maintenance burden, but may be useful for those larger organisations who don’t want to wear the security risk of manually managing user accounts in API Connect.</p><p>Feel free to get in touch on Linkdin:</p><p><a href="https://www.linkedin.com/in/brendon-stephens/">https://www.linkedin.com/in/brendon-stephens/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=11d8d1c25043" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>