Skip to content

Commit

Permalink
Update GH Pages - 7d3e1d8
Browse files Browse the repository at this point in the history
  • Loading branch information
DevRel GH Pages Publish Action committed Mar 28, 2024
1 parent be692c3 commit 60f4305
Show file tree
Hide file tree
Showing 16 changed files with 204 additions and 235 deletions.
2 changes: 1 addition & 1 deletion labs/bdd-proxy-development/codelab.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"format": "html",
"prefix": "https://storage.googleapis.com",
"mainga": "UA-49880327-14",
"updated": "2024-03-28T09:30:24Z",
"updated": "2024-03-28T09:35:57Z",
"id": "bdd-proxy-development",
"duration": 62,
"title": "Behaviour-Driven Proxy Development with Apigee",
Expand Down
76 changes: 39 additions & 37 deletions labs/bdd-proxy-development/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<title>Behaviour-Driven Proxy Development with Apigee</title>
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Source+Code+Pro:400|Roboto:400,300,400italic,500,700|Roboto+Mono">
<link rel="stylesheet" href="//fonts.googleapis.com/icon?family=Material+Icons">
<link rel="stylesheet" href="https://storage.googleapis.com/codelab-elements/codelab-elements.css">
<link rel="stylesheet" href="https://storage.googleapis.com/claat-public/codelab-elements.css">
<style>
.success {
color: #1e8e3e;
Expand All @@ -20,28 +20,29 @@
</style>
</head>
<body>
<google-codelab-analytics gaid="UA-49880327-14"></google-codelab-analytics>
<google-codelab-analytics gaid="UA-49880327-14" ga4id=""></google-codelab-analytics>
<google-codelab codelab-gaid=""
codelab-ga4id=""
id="bdd-proxy-development"
title="Behaviour-Driven Proxy Development with Apigee"
environment="web"
feedback-link="">

<google-codelab-step label="Overview" duration="2">
<p>This lab walks through the process of generating, deploying and testing a mock<br>proxy on Apigee.<br>The lab focuses on leveraging useful tools and best practices, with some<br>practical examples. Over the course of the lab you will step through<br>the process shown below. An Open API specification and test suite have already<br>been provided for the lab. You can use these as a reference<br>to leverage this same process in your own API development work.</p>
<p>This lab walks through the process of generating, deploying and testing a mock proxy on Apigee. The lab focuses on leveraging useful tools and best practices, with some practical examples. Over the course of the lab you will step through the process shown below. An Open API specification and test suite have already been provided for the lab. You can use these as a reference to leverage this same process in your own API development work.</p>
<p class="image-container"><img alt="Overview" src="img/173d98dadc3450b8.png"></p>
<p>We assume basic knowledge of the Apigee platform and you will get the most<br>from this lab if you already possess this knowledge.</p>
<p>Ideally you will have completed the Apigee courses on<br><a href="https://www.coursera.org/learn/api-design-apigee-gcp" target="_blank">Design</a>,<br><a href="https://www.coursera.org/learn/api-development-apigee-gcp" target="_blank">Development</a> and<br><a href="https://www.coursera.org/learn/api-security-apigee-gcp" target="_blank">Security</a> Courses.<br>These are available through Coursera, Pluralsight or Qwiklabs.</p>
<p>Alternatively, completing the Apigee<br><a href="https://github.com/apigee/apijam" target="_blank">API Jam</a> will cover the same topics in<br>less depth.</p>
<p>We assume basic knowledge of the Apigee platform and you will get the most from this lab if you already possess this knowledge.</p>
<p>Ideally you will have completed the Apigee courses on <a href="https://www.coursera.org/learn/api-design-apigee-gcp" target="_blank">Design</a>, <a href="https://www.coursera.org/learn/api-development-apigee-gcp" target="_blank">Development</a> and <a href="https://www.coursera.org/learn/api-security-apigee-gcp" target="_blank">Security</a> Courses. These are available through Coursera, Pluralsight or Qwiklabs.</p>
<p>Alternatively, completing the Apigee <a href="https://github.com/apigee/apijam" target="_blank">API Jam</a> will cover the same topics in less depth.</p>
<p>Lets get started!</p>


</google-codelab-step>

<google-codelab-step label="Prerequisites" duration="30">
<p>An Apigee organisation (X or Hybrid) configured for external exposure is<br>required to complete this lab. See<br><a href="https://github.com/apigee/devrel/tree/main/tools/apigee-x-trial-provision" target="_blank">here</a><br>for details on provisioning an Apigee X evaluation organisation.</p>
<p>An Apigee organisation (X or Hybrid) configured for external exposure is required to complete this lab. See <a href="https://github.com/apigee/devrel/tree/main/tools/apigee-x-trial-provision" target="_blank">here</a> for details on provisioning an Apigee X evaluation organisation.</p>
<h2 is-upgraded>Tools</h2>
<p>You will need to have the following dependencies configured in you local<br>environment in order to complete the lab tasks:</p>
<p>You will need to have the following dependencies configured in you local environment in order to complete the lab tasks:</p>
<ul>
<li>Bash (Unix shell)</li>
<li><a href="https://nodejs.org/en/" target="_blank">NodeJS</a> LTS version or above.</li>
Expand All @@ -52,14 +53,14 @@ <h2 is-upgraded>Tools</h2>
<li><a href="https://stedolan.github.io/jq/" target="_blank">jq</a></li>
</ul>
<h2 is-upgraded>Environment Variables</h2>
<p>Commands used during the lab will require the following environment variables<br>to be configured.</p>
<pre><code>export TOKEN=$(gcloud auth application-default print-access-token)
<p>Commands used during the lab will require the following environment variables to be configured.</p>
<pre><code language="language-bash" class="language-bash">export TOKEN=$(gcloud auth application-default print-access-token)
export APIGEE_ENV=&lt;apigee-environment-name&gt;
export APIGEE_ORG=&lt;gcp-project-name&gt;
</code></pre>
<h2 is-upgraded>oas-apigee-mock</h2>
<p>Clone the Apigee DevRel repo and install the dependencies for the<br>oas-apigee-mock tool.</p>
<pre><code>git clone https://github.com/apigee/devrel.git
<p>Clone the Apigee DevRel repo and install the dependencies for the oas-apigee-mock tool.</p>
<pre><code language="language-bash" class="language-bash">git clone https://github.com/apigee/devrel.git
cd devrel/tools/oas-apigee-mock/
export LAB_HOME=$PWD
npm install
Expand All @@ -70,57 +71,57 @@ <h2 is-upgraded>oas-apigee-mock</h2>

<google-codelab-step label="Generate the proxy bundle and prepare tests" duration="10">
<h2 is-upgraded>Generate an Apigee proxy from an Open API Specification</h2>
<p>Use the <code>orders-apikey-header.yaml</code> Open API specification included<br>in the <code>$LAB_HOME/test/oas</code> folder to generate a proxy bundle.</p>
<pre><code>node $LAB_HOME/bin/oas-apigee-mock generateApi web-orders-proxy-v1 \
<p>Use the <code>orders-apikey-header.yaml</code> Open API specification included in the <code>$LAB_HOME/test/oas</code> folder to generate a proxy bundle.</p>
<pre><code language="language-bash" class="language-bash">node $LAB_HOME/bin/oas-apigee-mock generateApi web-orders-proxy-v1 \
-s $LAB_HOME/test/oas/orders-apikey-header.yaml \
-o
</code></pre>
<h2 is-upgraded>Update the apickli configuration to use your Environment Group&#39;s Hostname</h2>
<p>Update the <code>before(function ()</code> block in<br><code>$LAB_HOME/test/features/step_definitions/init.js</code> with a hostname from the<br>environment group you will deploying to. For example:</p>
<pre><code>before(function () {
<p>Update the <code>before(function ()</code> block in <code>$LAB_HOME/test/features/step_definitions/init.js</code> with a hostname from the environment group you will deploying to. For example:</p>
<pre><code language="language-javascript" class="language-javascript">before(function () {
this.apickli = new apickli.Apickli(
&#34;https&#34;,process.env.RUNTIME_HOST_ALIAS
);
</code></pre>
<p>If you followed the<br><a href="https://github.com/apigee/devrel/tree/main/tools/apigee-x-trial-provision" target="_blank">Apigee X Trial Provisioning</a><br>script, a hostname will have been stored in the <code>RUNTIME_HOST_ALIAS</code><br>environment variable associated with the <code>eval-group</code> environment group.</p>
<p>You can also retrieve environment group information from you Apigee organisation<br>using <code>apigeecli</code>.</p>
<pre><code>apigeecli envgroups list -t &#34;$TOKEN&#34; -o &#34;$APIGEE_ORG&#34;
<p>If you followed the <a href="https://github.com/apigee/devrel/tree/main/tools/apigee-x-trial-provision" target="_blank">Apigee X Trial Provisioning</a> script, a hostname will have been stored in the <code>RUNTIME_HOST_ALIAS</code> environment variable associated with the <code>eval-group</code> environment group.</p>
<p>You can also retrieve environment group information from you Apigee organisation using <code>apigeecli</code>.</p>
<pre><code language="language-bash" class="language-bash">apigeecli envgroups list -t &#34;$TOKEN&#34; -o &#34;$APIGEE_ORG&#34;
</code></pre>
<p>Using <code>jq</code> we can retrieve a hostname of an environment group and store it in the<br><code>RUNTIME_HOST_ALIAS</code> variable.</p>
<pre><code>apigeecli envgroups list -t &#34;$TOKEN&#34; -o &#34;$APIGEE_ORG&#34; &gt; environment-groups.json
<p>Using <code>jq</code> we can retrieve a hostname of an environment group and store it in the <code>RUNTIME_HOST_ALIAS</code> variable.</p>
<pre><code language="language-bash" class="language-bash">apigeecli envgroups list -t &#34;$TOKEN&#34; -o &#34;$APIGEE_ORG&#34; &gt; environment-groups.json
RUNTIME_HOST_ALIAS=$(jq &#39;.environmentGroups[0].hostnames[0]&#39; -r &lt; environment-groups.json )
export RUNTIME_HOST_ALIAS
echo &#34;RUNTIME_HOST_ALIAS is $RUNTIME_HOST_ALIAS&#34;
</code></pre>
<h2 is-upgraded>Update the test suite proxy reference</h2>
<p>Update the test suite <code>$LAB_HOME/test/features/orders-apikey-header.feature</code><br>with the basepath for your proxy.<code>web-orders-proxy-v1</code> was used in the generate<br>proxy step earlier in this lab.</p>
<p>Update the test suite <code>$LAB_HOME/test/features/orders-apikey-header.feature</code> with the basepath for your proxy.<code>web-orders-proxy-v1</code> was used in the generate proxy step earlier in this lab.</p>


</google-codelab-step>

<google-codelab-step label="Deploy and Test the Proxy" duration="10">
<h2 is-upgraded>Test the Proxy</h2>
<p>Lets start by running the test suite.</p>
<pre><code>cd $LAB_HOME
<pre><code language="language-bash" class="language-bash">cd $LAB_HOME
./node_modules/.bin/cucumber-js test/features/orders-apikey-header.feature --format json:test/test_report.json --publish-quiet
</code></pre>
<p>The test should fail as we have yet to deploy the proxy we generated<br>previously.</p>
<p>The test should fail as we have yet to deploy the proxy we generated previously.</p>
<h2 is-upgraded>Deploy the generated proxy to your Apigee Organisation</h2>
<pre><code>sackmesser deploy -d &#34;$LAB_HOME/api_bundles/web-orders-proxy-v1&#34; --googleapi -t &#34;$TOKEN&#34; -o &#34;$APIGEE_ORG&#34; -e &#34;$APIGEE_ENV&#34;
<pre><code language="language-bash" class="language-bash">sackmesser deploy -d &#34;$LAB_HOME/api_bundles/web-orders-proxy-v1&#34; --googleapi -t &#34;$TOKEN&#34; -o &#34;$APIGEE_ORG&#34; -e &#34;$APIGEE_ENV&#34;
</code></pre>
<h2 is-upgraded>Start debugging</h2>
<p>Turn on <a href="https://cloud.google.com/apigee/docs/api-platform/debug/trace" target="_blank">debug</a><br>and run the test suite again.</p>
<pre><code>cd $LAB_HOME
<p>Turn on <a href="https://cloud.google.com/apigee/docs/api-platform/debug/trace" target="_blank">debug</a> and run the test suite again.</p>
<pre><code language="language-bash" class="language-bash">cd $LAB_HOME
./node_modules/.bin/cucumber-js test/features/orders-apikey-header.feature --format json:test/test_report.json --publish-quiet
</code></pre>
<p>Once again the tests should fail but for a different reason. Use the Apigee<br>debug tool to investigate the cause.</p>
<p>Once again the tests should fail but for a different reason. Use the Apigee debug tool to investigate the cause.</p>


</google-codelab-step>

<google-codelab-step label="Create an API Product, Developer and App" duration="10">
<p>The generated proxy is protected by a Verify API Key policy (as specified<br>in the Open API Specification used), a valid API Key is needed in order to<br>successfully make API calls to the proxy. To obtain an API Key we need to<br>create an API product which includes our proxy and register a developer and<br>application which will use that API Product.</p>
<pre><code>apigeecli products create -t &#34;$TOKEN&#34; -o &#34;$APIGEE_ORG&#34; --name &#34;web-orders&#34; --proxies &#34;web-orders-proxy-v1&#34; --envs &#34;$APIGEE_ENV&#34; --approval &#34;auto&#34;
<p>The generated proxy is protected by a Verify API Key policy (as specified in the Open API Specification used), a valid API Key is needed in order to successfully make API calls to the proxy. To obtain an API Key we need to create an API product which includes our proxy and register a developer and application which will use that API Product.</p>
<pre><code language="language-bash" class="language-bash">apigeecli products create -t &#34;$TOKEN&#34; -o &#34;$APIGEE_ORG&#34; --name &#34;web-orders&#34; --proxies &#34;web-orders-proxy-v1&#34; --envs &#34;$APIGEE_ENV&#34; --approval &#34;auto&#34;
apigeecli devs create -t &#34;$TOKEN&#34; -o &#34;$APIGEE_ORG&#34; --email &#34;[email protected]&#34; --user &#34;[email protected]&#34; --first &#34;Web&#34; --last &#34;Developer&#34;
apigeecli apps create -t &#34;$TOKEN&#34; -o &#34;$APIGEE_ORG&#34; --email &#34;[email protected]&#34; --prods &#34;web-orders&#34; --name &#34;web-orders-app&#34; &gt; app.json

Expand All @@ -129,27 +130,28 @@ <h2 is-upgraded>Start debugging</h2>
echo &#34;APIKEY is $APIKEY&#34;
</code></pre>
<h2 is-upgraded>Retest the Proxy</h2>
<p>A valid API Key is now available as an environment variable and can now be<br>used by the test suite.<br>Turn on <a href="https://cloud.google.com/apigee/docs/api-platform/debug/trace" target="_blank">debug</a><br>again, run the test suite and verify the tests are now passing.</p>
<pre><code>cd $LAB_HOME
<p>A valid API Key is now available as an environment variable and can now be used by the test suite. Turn on <a href="https://cloud.google.com/apigee/docs/api-platform/debug/trace" target="_blank">debug</a> again, run the test suite and verify the tests are now passing.</p>
<pre><code language="language-bash" class="language-bash">cd $LAB_HOME
./node_modules/.bin/cucumber-js test/features/orders-apikey-header.feature --format json:test/test_report.json --publish-quiet
</code></pre>


</google-codelab-step>

<google-codelab-step label="Summary" duration="0">
<p>You have generated, deployed and tested a mock API<br>proxy on Apigee using a behavior-driven development approach.</p>
<p>You have generated, deployed and tested a mock API proxy on Apigee using a behavior-driven development approach.</p>
<p class="image-container"><img alt="Overview" src="img/173d98dadc3450b8.png"></p>


</google-codelab-step>

</google-codelab>

<script src="https://storage.googleapis.com/codelab-elements/native-shim.js"></script>
<script src="https://storage.googleapis.com/codelab-elements/custom-elements.min.js"></script>
<script src="https://storage.googleapis.com/codelab-elements/prettify.js"></script>
<script src="https://storage.googleapis.com/codelab-elements/codelab-elements.js"></script>
<script src="https://storage.googleapis.com/claat-public/native-shim.js"></script>
<script src="https://storage.googleapis.com/claat-public/custom-elements.min.js"></script>
<script src="https://storage.googleapis.com/claat-public/prettify.js"></script>
<script src="https://storage.googleapis.com/claat-public/codelab-elements.js"></script>
<script src="//support.google.com/inapp/api.js"></script>

</body>
</html>
2 changes: 1 addition & 1 deletion labs/best-practices-hackathon/codelab.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"format": "html",
"prefix": "https://storage.googleapis.com",
"mainga": "UA-49880327-14",
"updated": "2024-03-28T09:30:24Z",
"updated": "2024-03-28T09:35:57Z",
"id": "best-practices-hackathon",
"duration": 0,
"title": "Apigee Best Practices Hackathon",
Expand Down
Loading

0 comments on commit 60f4305

Please sign in to comment.