{"info":{"_postman_id":"ce8cdaaf-e082-4860-854a-2d66a3854e51","name":"FIWARE Context Providers","description":"<html><head></head><body><p>This tutorial builds on the <strong>Store</strong> entity created in the previous <a href=\"https://github.com/Fiware/tutorials.CRUD-Operations/\">stock management example</a> and enables a user to \nretrieve data about a store which is not held directly within the Orion Context Broker.</p>\n<p>The <code>docker-compose</code> file for this tutorial can be found on GitHub: </p>\n<p><img src=\"https://fiware.github.io/tutorials.Context-Providers/icon/GitHub-Mark-32px.png\" alt=\"GitHub\"> <a href=\"https://github.com/Fiware/tutorials.Context-Providers\">FIWARE 104: Registering Context Providers</a></p>\n<h1 id=\"context-providers\">Context Providers</h1>\n<blockquote>\n<p>\"Knowledge is of two kinds. We know a subject ourselves, or we know where we can find information about it.\"</p>\n<p>— Samuel Johnson (Boswell's Life of Johnson)</p>\n</blockquote>\n<p>Within the FIWARE platform, an entity represents the state of a physical or conceptural object which exists in the real world. \nFor example, a <strong>Store</strong> is a real world bricks and mortar building.</p>\n<p>The context data of that entity defines the state of that real-world object at a given moment in time. </p>\n<p>In all of the tutorials so far, we are holding all of the context data for our <strong>Store</strong> entities directly within the Orion \nContext Broker, for example stores would have attributes such as:</p>\n<ul>\n<li>A unique identifier for the store e.g. <code>urn:ngsi-ld:Store:002</code></li>\n<li>The name of the store e.g. \"Checkpoint Markt\"</li>\n<li>The address \"Friedrichstraße 44, 10969 Kreuzberg, Berlin\"</li>\n<li>A physical location  e.g. <em>52.5075 N, 13.3903 E</em></li>\n</ul>\n<p>As you can see, most of these attributes are completely static (such as the location) and the others are unlikely to be\nchanged on a regular basis - though a street could be renamed, or the store name could be rebranded.</p>\n<p>There is however another class of context data about the <strong>Store</strong> entity which is much more dynamic, information such as:</p>\n<ul>\n<li>The current temperature at the store location</li>\n<li>The current relative humidity at the store location</li>\n<li>Recent social media tweets regarding the store</li>\n</ul>\n<p>This information is always changing, and if it were held in a database, the data would always be out-of-date. To keep the context\ndata fresh, and to be able to retrieve the current state of the system on demand, new values for these dynamic data attributes will \nneed to be retrieved whenever the entity context is requested.</p>\n<p>Smart solutions are designed to react on the current state of the real-world. They are \"aware\" since they rely on dynamic data readings from \nexternal sources (such social media, IoT sensors, user inputs). The FIWARE platform makes the gathering and presentation of real-time \ncontext data transparent, since whenever an <a href=\"https://swagger.lab.fiware.org/?url=https://raw.githubusercontent.com/Fiware/specifications/master/OpenAPI/ngsiv2/ngsiv2-openapi.json\">NGSI</a> request is made to the Orion Context\nBroker it will always return the latest context by combining the data held within its database along with real-time data readings from \nany registered external context providers.</p>\n<p>In order to be able to fulfil these requests, the Orion Context Broker, must first be supplied with two types of information:</p>\n<ul>\n<li>The static context data held within Orion itself  (<em>Entities that Orion \"knows\" about</em>) </li>\n<li>Registered external context providers associated with existing entities (<em>Entities that Orion can \"find information\" about</em>)</li>\n</ul>\n<h2 id=\"entities-within-a-stock-management-system\">Entities within a stock management system</h2>\n<p>Within our simple stock management system, our <strong>Store</strong> entity currently returns <code>id</code>, <code>name</code>,  <code>address</code> and <code>location</code> attributes. \nWe will augment this with additional real-time context data from the following free publicly available data sources:</p>\n<ul>\n<li>The temperature and relative humidity from the <a href=\"https://www.wunderground.com/weather/api/d/docs?MR=1\">Weather Underground API</a></li>\n<li>Recent social media tweets regarding the store from the <a href=\"https://developer.twitter.com/%5D(https://developer.twitter.com/\">Twitter API</a></li>\n</ul>\n<p>The relationship between our entities is defined as shown:</p>\n<p><img src=\"https://fiware.github.io/tutorials.Context-Providers/img/entities.png\" alt=\"\"></p>\n<h1 id=\"architecture\">Architecture</h1>\n<p>This application will only make use of one FIWARE component - the <a href=\"https://catalogue.fiware.org/enablers/publishsubscribe-context-broker-orion-context-broker\">Orion Context Broker</a>. Usage of the Orion Context Broker is sufficient for an application to qualify as <em>“Powered by FIWARE”</em>.</p>\n<p>Currently, the Orion Context Broker relies on open source <a href=\"https://www.mongodb.com/\">MongoDB</a> technology to keep persistence of the context data it holds. \nTo request context data from external sources, we will now need to add a simple Context Provider NGSI proxy.</p>\n<p>Therefore, the architecture will consist of three elements:</p>\n<ul>\n<li>The Orion Context Broker server which will receive requests using <a href=\"https://swagger.lab.fiware.org/?url=https://raw.githubusercontent.com/Fiware/specifications/master/OpenAPI/ngsiv2/ngsiv2-openapi.json\">NGSI</a></li>\n<li>The underlying MongoDB database associated to the Orion Context Broker server</li>\n<li>The Context Provider NGSI proxy which will will:<ul>\n<li>receive requests using <a href=\"https://swagger.lab.fiware.org/?url=https://raw.githubusercontent.com/Fiware/specifications/master/OpenAPI/ngsiv2/ngsiv2-openapi.json\">NGSI</a></li>\n<li>makes requests to publicly available data sources using their own APIs in a proprietory format </li>\n<li>returns context data back to the Orion Context Broker in <a href=\"https://swagger.lab.fiware.org/?url=https://raw.githubusercontent.com/Fiware/specifications/master/OpenAPI/ngsiv2/ngsiv2-openapi.json\">NGSI</a> format.</li>\n</ul>\n</li>\n</ul>\n<p>Since all interactions between the elements are initiated by HTTP requests, the entities can be containerized and run from exposed ports. </p>\n<p><img src=\"https://fiware.github.io/tutorials.Context-Providers/img/architecture.png\" alt=\"\"></p>\n<p>The necessary configuration information for the <strong>Context Provider NGSI proxy</strong> can be seen in the services section the of the associated <code>docker-compose.yml</code>  file:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-yaml\">  context-provider:\n    image: fiware/cp-web-app:latest\n    hostname: context-provider\n    container_name: context-provider\n    networks:\n        - default\n    expose:\n        - \"3000\"\n    ports:\n        - \"3000:3000\"\n    environment:\n        - \"DEBUG=proxy:*\"\n        - \"PORT=3000\" \n        - \"CONTEXT_BROKER=http://orion:1026/v2\" \n        - \"WUNDERGROUND_KEY_ID=&lt;ADD_YOUR_KEY_ID&gt;\"\n        - \"TWITTER_CONSUMER_KEY=&lt;ADD_YOUR_CONSUMER_KEY&gt;\"\n        - \"TWITTER_CONSUMER_SECRET=&lt;ADD_YOUR_CONSUMER_SECRET&gt;\"\n</code></pre>\n<p>The <code>context-provider</code> container is driven by environment variables as shown:</p>\n<div class=\"click-to-expand-wrapper is-table-wrapper\"><table>\n<thead>\n<tr>\n<th>Key</th>\n<th>Value</th>\n<th>Description</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td>DEBUG</td>\n<td><code>proxy:*</code></td>\n<td>Debug flag used for logging</td>\n</tr>\n<tr>\n<td>PORT</td>\n<td><code>3000</code></td>\n<td>Port used by the content provider proxy and web-app for viewing data</td>\n</tr>\n<tr>\n<td>CONTEXT_BROKER</td>\n<td><code>http://orion:1026/v2</code></td>\n<td>URL of the context broker to  connect to update context</td>\n</tr>\n<tr>\n<td>WUNDERGROUND_KEY_ID</td>\n<td><code>&lt;ADD_YOUR_KEY_ID&gt;</code></td>\n<td>A consumer key used to obtain access to the Weather Underground API</td>\n</tr>\n<tr>\n<td>TWITTER_CONSUMER_KEY</td>\n<td><code>&lt;ADD_YOUR_CONSUMER_KEY&gt;</code></td>\n<td>A consumer key used to obtain access to the Twitter API</td>\n</tr>\n<tr>\n<td>TWITTER_CONSUMER_SECRET</td>\n<td><code>&lt;ADD_YOUR_CONSUMER_SECRET&gt;</code></td>\n<td>A user key used to obtain access to the Twitter API</td>\n</tr>\n</tbody>\n</table>\n</div><p>The other <code>context-provider</code> container configuration values described in the YAML file are not used in this tutorial.</p>\n<p>The configuration information for MongoDB and the Orion Context Broker\nhas been described in a <a href=\"https://github.com/Fiware/tutorials.Entity-Relationships/\">previous tutorial</a></p>\n<h1 id=\"prerequisites\">Prerequisites</h1>\n<h2 id=\"docker\">Docker</h2>\n<p>To keep things simple both components will be run using <a href=\"https://www.docker.com\">Docker</a>. <strong>Docker</strong> is a container technology which allows to different components isolated into their respective environments. </p>\n<ul>\n<li>To install Docker on Windows follow the instructions <a href=\"https://docs.docker.com/docker-for-windows/\">here</a></li>\n<li>To install Docker on Mac follow the instructions <a href=\"https://docs.docker.com/docker-for-mac/\">here</a></li>\n<li>To install Docker on Linux follow the instructions <a href=\"https://docs.docker.com/install/\">here</a></li>\n</ul>\n<p><strong>Docker Compose</strong> is a tool for defining and running multi-container Docker applications. A <a href=\"https://raw.githubusercontent.com/Fiware/tutorials.Entity-Relationships/master/docker-compose.yml\">YAML file</a> is used configure the required\nservices for the application. This means all container sevices can be brought up in a single commmand. Docker Compose is installed by default as part of Docker for Windows and  Docker for Mac, however Linux users will need to follow the instructions found <a href=\"https://docs.docker.com/compose/install/\">here</a></p>\n<h2 id=\"cygwin\">Cygwin</h2>\n<p>We will start up our services using a simple bash script. Windows users should download <a href=\"www.cygwin.com\">cygwin</a> to provide a command line functionality similar to a Linux distribution on Windows. </p>\n<h2 id=\"context-provider-ngsi-proxy\">Context Provider NGSI proxy</h2>\n<p>A simple <a href=\"https://nodejs.org/\">nodejs</a> <a href=\"https://expressjs.com/\">Express</a> application has been bundled as part of the repository. The application offers an NGSI v1 interface for four different context providers - the Weather Underground API, the Twitter Search API and two dummy data context providers - a static data provider (which always returns the same data) and a random data context provider (which will change every time it is invoked). </p>\n<p>More information about the proxy endpoints can be found <a href=\"https://github.com/Fiware/tutorials.Context-Providers/blob/master/proxy/README.md\">here</a></p>\n<ul>\n<li>In order to access the Weather Underground API, you will need to sign up for a key at <a href=\"https://www.wunderground.com/weather/api/\">https://www.wunderground.com/weather/api/</a> </li>\n<li>In order to access the Twitter Search API, you will have to create an app in Twitter via  <a href=\"https://apps.twitter.com/app/new\">https://apps.twitter.com/app/new</a> to obtain a \nConsumer Key &amp; Consumer Secret.</li>\n</ul>\n<p>Replace the placeholders in <code>docker-compose.yml</code> in the root of the repository with the values you obtain for your application:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-yaml\">    environment:\n        - \"DEBUG=proxy:*\"\n        - \"WUNDERGROUND_KEY_ID=&lt;ADD_YOUR_KEY_ID&gt;\"\n        - \"TWITTER_CONSUMER_KEY=&lt;ADD_YOUR_CONSUMER_KEY&gt;\"\n        - \"TWITTER_CONSUMER_SECRET=&lt;ADD_YOUR_CONSUMER_SECRET&gt;\"\n</code></pre>\n<p>If you do not wish to sign-up for an API key, you can use data from the random data context provider instead.</p>\n<h1 id=\"start-up\">Start Up</h1>\n<p>All services can be initialised from the command line by running the bash script provided within the repository:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-console\">./services create; ./services start;\n</code></pre>\n<p>This command will also import seed data from the previous <a href=\"https://github.com/Fiware/tutorials.CRUD-Operations\">Stock Management example</a> on startup.</p>\n</body></html>","schema":"https://schema.getpostman.com/json/collection/v2.0.0/collection.json","toc":[{"content":"Context Providers","slug":"context-providers"},{"content":"Architecture","slug":"architecture"},{"content":"Prerequisites","slug":"prerequisites"},{"content":"Start Up","slug":"start-up"}],"owner":"513743","collectionId":"ce8cdaaf-e082-4860-854a-2d66a3854e51","publishedId":"RW1XLMKz","public":true,"customColor":{"top-bar":"FFFFFF","right-sidebar":"4C4C4C","highlight":"233C68"},"publishDate":"2020-01-02T11:02:46.000Z"},"item":[{"name":"Health Checks","item":[{"name":"Static Data Context Provider (Health Check)","id":"17ee9d41-b78f-4b6c-8d49-fdf7637f95e2","request":{"method":"GET","header":[],"body":{"mode":"formdata","formdata":[]},"url":"http://localhost:3000/health/static","description":"<p>This example returns the health of the Static Data Context Provider endpoint.</p>\n<p>A non-error response shows that an NGSI proxy is available on the network and returning values.\nEach Request will return the same data.</p>\n","urlObject":{"protocol":"http","path":["health","static"],"host":["localhost:3000"],"query":[],"variable":[]}},"response":[],"_postman_id":"17ee9d41-b78f-4b6c-8d49-fdf7637f95e2"},{"name":"Random Data Context Provider (Health Check)","id":"b07bf5df-c6fb-40ac-9c45-1109246bc2ea","request":{"method":"GET","header":[],"body":{"mode":"formdata","formdata":[]},"url":"http://localhost:3000/health/random","description":"<p>This example returns the health of the Random Data Generator Context Provider endpoint.</p>\n<p>A non-error response shows that an NGSI proxy is available on the network and returning values.\nEach Request will return some random dummy data.</p>\n","urlObject":{"protocol":"http","path":["health","random"],"host":["localhost:3000"],"query":[],"variable":[]}},"response":[],"_postman_id":"b07bf5df-c6fb-40ac-9c45-1109246bc2ea"},{"name":"Twitter API Context Provider (Health Check)","id":"00037fd1-6505-4b56-82b6-d63861eca32a","request":{"method":"GET","header":[],"body":{"mode":"formdata","formdata":[]},"url":"http://localhost:3000/health/twitter","description":"<p>This example returns the health of the Twitter API Context Provider endpoint.</p>\n<p>A non-error response shows that an NGSI proxy for the Twitter API is available on the network and returning values.</p>\n<p>If the proxy is correctly configured to connect to the Twitter API, a series of Tweets will be\nreturned.</p>\n<p>The Twitter API uses OAuth2: </p>\n<ul>\n<li>To get Consumer Key &amp; Consumer Secret for the Twitter API, you have to create an app in Twitter via <a href=\"https://apps.twitter.com/app/new\">https://apps.twitter.com/app/new</a>. Then you'll be taken to a page containing Consumer Key &amp; Consumer Secret.</li>\n<li>For more information see: <a href=\"https://developer.twitter.com/\">https://developer.twitter.com/</a></li>\n</ul>\n","urlObject":{"protocol":"http","path":["health","twitter"],"host":["localhost:3000"],"query":[],"variable":[]}},"response":[],"_postman_id":"00037fd1-6505-4b56-82b6-d63861eca32a"},{"name":"Weather API Context Provider (Health Check)","id":"67313dfc-c530-4a06-88d2-37d1276990a5","request":{"method":"GET","header":[],"body":{"mode":"formdata","formdata":[]},"url":"http://localhost:3000/health/weather","description":"<p>This example returns the health of the Weather API Context Provider endpoint.</p>\n<p>A non-error response shows that an NGSI proxy for the Weather API is available on the network and returning values.</p>\n<p>If the proxy is correctly configured to connect to the Weather Underground API, the current weather in Berlin will be returned.</p>\n<p>Most of the Weather API features require an API key. </p>\n<ul>\n<li><p>Sign up for a key at <a href=\"https://www.wunderground.com/weather/api/\">https://www.wunderground.com/weather/api/</a></p>\n</li>\n<li><p>For more information see: <a href=\"https://www.wunderground.com/weather/api/d/docs?MR=1\">https://www.wunderground.com/weather/api/d/docs?MR=1</a></p>\n</li>\n</ul>\n","urlObject":{"protocol":"http","path":["health","weather"],"host":["localhost:3000"],"query":[],"variable":[]}},"response":[],"_postman_id":"67313dfc-c530-4a06-88d2-37d1276990a5"},{"name":"Cat Facts API Context Provider (Health Check)","id":"b51782ce-4ae8-467c-8f10-591743c4962e","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[],"url":"http://localhost:3000/health/catfacts","description":"<p>This example returns the health of the Cat Facts API Context Provider endpoint.</p>\n<p>A non-error response shows that an NGSI proxy for the Cat Facts API is available on the network and returning values.</p>\n<p>If the proxy is correctly configured to connect to the Cat Facts API, a series of facts about cats will be returned.</p>\n","urlObject":{"protocol":"http","path":["health","catfacts"],"host":["localhost:3000"],"query":[],"variable":[]}},"response":[],"_postman_id":"b51782ce-4ae8-467c-8f10-591743c4962e"}],"id":"6bdafbe5-78b1-4ab7-911e-ac8d360cb21a","description":"<p>The nodejs proxy application offers a <code>health</code> endpoint for each of the four context providers. Making a request to the appropriate endpoint will check that the provider is running and external data can be received. The application runs on port <code>3000</code>.</p>\n","event":[{"listen":"prerequest","script":{"id":"2964a74c-f2c6-46ac-9c71-f929208fb5a0","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"4820111c-c261-4e96-8089-0fc8e5065867","type":"text/javascript","exec":[""]}}],"_postman_id":"6bdafbe5-78b1-4ab7-911e-ac8d360cb21a"},{"name":"Accessing the NGSI v2 QueryContext Endpoint","item":[{"name":"Retrieving a Single Attribute Value","id":"4215ed36-053e-4c6f-9c19-33c4d0a52372","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[{"key":"Content-Type","value":"application/json"}],"body":{"mode":"raw","raw":"{\n    \"entities\": [\n        {\n            \"type\": \"Store\",\n            \"isPattern\": \"false\",\n            \"id\": \"urn:ngsi-ld:Store:001\"\n        }\n    ],\n    \"attrs\": [\n        \"temperature\"\n    ]\n} "},"url":"http://localhost:3000/static/temperature/op/query","description":"<p>This example uses the NGSI v2 <code>op/query</code> endpoint to request a <code>temperature</code> reading from the  Static Data Generator Context Provider.</p>\n<p>The response will return a object of <code>type:Number</code> and <code>value:42</code></p>\n<p>The Orion Context Broker will make similar requests to this <code>op/query</code> endpoint once a context provider has been registered.</p>\n","urlObject":{"protocol":"http","path":["static","temperature","op","query"],"host":["localhost:3000"],"query":[],"variable":[]}},"response":[],"_postman_id":"4215ed36-053e-4c6f-9c19-33c4d0a52372"},{"name":"Retrieving Multiple Attribute Values","id":"556347e5-8271-4435-a34f-b7ed38a19a85","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[{"key":"Content-Type","value":"application/json"}],"body":{"mode":"raw","raw":"{\n    \"entities\": [\n        {\n            \"type\": \"Store\",\n            \"isPattern\": \"false\",\n            \"id\": \"urn:ngsi-ld:Store:001\"\n        }\n    ],\n    \"attrs\": [\n        \"temperature\",\n        \"relativeHumidity\"\n    ]\n} "},"url":"http://localhost:3000/random/weatherConditions/op/query","description":"<p>It is possible for the Orion Context Broker to make a request for multiple data values. This example uses the NGSI NGSI v2 <code>op/query</code>  endpoint to request  <code>temperature</code> and <code>relativeHumidity</code> readings from the Random Data Generator Context Provider. The requested attributes are found within the <code>attributes</code> array of the POST body.</p>\n<p>The response will return a object with values for both <code>temperature</code> and <code>relativeHumidity</code></p>\n<p>The Orion Context Broker will make similar requests to this <code>op/query</code> endpoint once a context provider has been registered.</p>\n","urlObject":{"protocol":"http","path":["random","weatherConditions","op","query"],"host":["localhost:3000"],"query":[],"variable":[]}},"response":[],"_postman_id":"556347e5-8271-4435-a34f-b7ed38a19a85"},{"name":"Retrieving Live Weather Values","id":"28d10b6e-8ae6-4e71-81b1-798ada33e80b","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[{"key":"Content-Type","value":"application/json"}],"body":{"mode":"raw","raw":"{\n    \"entities\": [\n        {\n            \"type\": \"Store\",\n            \"isPattern\": \"false\",\n            \"id\": \"urn:ngsi-ld:Store:001\"\n        }\n    ],\n    \"attrs\": [\n        \"temperature\",\n        \"relativeHumidity\"\n    ]\n} "},"url":"http://localhost:3000/random/weatherConditions/op/query","description":"<p>This example uses the NGSI v2 <code>op/query</code>  endpoint to request temperature and relativeHumidity readings from the Weather API Context Provider. The requested attributes are found within the attributes array of the POST body.</p>\n<p>The Orion Context Broker will make similar requests to this <code>op/query</code> endpoint once a context provider has been registered.</p>\n","urlObject":{"protocol":"http","path":["random","weatherConditions","op","query"],"host":["localhost:3000"],"query":[],"variable":[]}},"response":[],"_postman_id":"28d10b6e-8ae6-4e71-81b1-798ada33e80b"},{"name":"Retrieving Live Tweets","id":"e8de9d27-d5f8-48c1-ab25-c4f0905c5651","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[{"key":"Content-Type","value":"application/json"}],"body":{"mode":"raw","raw":"{\n    \"entities\": [\n        {\n            \"type\": \"Store\",\n            \"isPattern\": \"false\",\n            \"id\": \"urn:ngsi-ld:Store:001\"\n        }\n    ],\n    \"attrs\": [\n        \"tweets\"\n    ]\n} "},"url":"http://localhost:3000/twitter/tweets/op/query","description":"<p>This example uses the NGSI v2 <code>op/query</code>  endpoint to request tweets from the Twitter API Context Provider. The requested attributes are found within the attributes array of the POST body.</p>\n<p>The Orion Context Broker will make similar requests to this queryContext <code>op/query</code>  once a context provider has been registered.</p>\n","urlObject":{"protocol":"http","path":["twitter","tweets","op","query"],"host":["localhost:3000"],"query":[],"variable":[]}},"response":[],"_postman_id":"e8de9d27-d5f8-48c1-ab25-c4f0905c5651"},{"name":"Retrieving Live Cat Facts","id":"029dee89-c5da-4e5c-841f-67e5c4dac761","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[{"key":"Content-Type","value":"application/json"}],"body":{"mode":"raw","raw":"{\n    \"entities\": [\n        {\n            \"type\": \"Store\",\n            \"isPattern\": \"false\",\n            \"id\": \"urn:ngsi-ld:Store:001\"\n        }\n    ],\n    \"attrs\": [\n        \"tweets\"\n    ]\n} "},"url":"http://localhost:3000/catfacts/tweets/op/query","description":"<p>This example uses the NGSI v2 <code>op/query</code>  endpoint to request tweets from the Twitter API Context Provider. The requested attributes are found within the attributes array of the POST body.</p>\n<p>The Orion Context Broker will make similar requests to this <code>op/query</code>  endpoint once a context provider has been registered.</p>\n","urlObject":{"protocol":"http","path":["catfacts","tweets","op","query"],"host":["localhost:3000"],"query":[],"variable":[]}},"response":[],"_postman_id":"029dee89-c5da-4e5c-841f-67e5c4dac761"}],"id":"48b313c2-9bb3-467f-ac01-ad749b6b6592","description":"<p>Because the <code>3000</code> port of the Context Provider has been exposed outside of the Docker container, it is possible for curl to make requests directly to the Context Provider - this simulates the requests that would have been made by the Orion Context Broker. You can also simulate making the requests as part of the docker container network by running the <code>appropriate/curl</code> Docker image.</p>\n<p>Firstly obtain the name of the network used within the Docker containers by running</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-console\">docker network ls\n</code></pre>\n<p>Then run the following curl command including the <code>--network</code> parameter:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-console\">docker run --network fiware_default --rm appropriate/curl -X GET http://context-provider:3000/random/health\n</code></pre>\n<p>As you can see, within the network, the host name of the Context Provider is <code>context-provider</code>.</p>\n","event":[{"listen":"prerequest","script":{"id":"6c72a7b6-107b-4d17-98b8-41fa833c675a","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"d4f0cf7e-297b-4674-bc92-bcbe91c53b76","type":"text/javascript","exec":[""]}}],"_postman_id":"48b313c2-9bb3-467f-ac01-ad749b6b6592"},{"name":"Context Provider Registration Actions","item":[{"name":"Register a Context Provider - Weather","id":"601852dd-2a33-4bbc-a458-644a604c983f","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[{"key":"Content-Type","value":"application/json"}],"body":{"mode":"raw","raw":"{\n   \"description\": \"Get Weather data for Store 1\",\n   \"dataProvided\": {\n     \"entities\": [\n       {\n         \"id\" : \"urn:ngsi-ld:Store:001\",\n         \"type\": \"Store\"\n       }\n     ],\n     \"attrs\": [\n      \"temperature\", \"relativeHumidity\"\n    ]\n   },\n   \"provider\": {\n     \"http\": {\n       \"url\": \"http://context-provider:3000/random/weatherConditions\"\n     },\n     \"legacyForwarding\": false\n   },\n   \"status\": \"active\"\n}"},"url":"http://localhost:1026/v2/registrations","description":"<p>This example registers the Random Data Context Provider with the Orion Context Broker.</p>\n<p>The body of the request states that: <em>\"The URL</em> <code>http://context-provider:3000/proxy/v1/random/weatherConditions</code> <em>is capable of providing</em> <code>relativeHumidity</code>  and <code>temperature</code> <em>data for the entity called</em> <code>id=urn:ngsi-ld:Store:001</code>.<em>\"</em></p>\n<p>The values are <strong>never</strong> held within Orion, it is always requested on demand from the registered context provider. Orion merely holds the registration information about which context providers can offer context data.</p>\n<p>This request will return with a <strong>201 - Created</strong> response code. The <code>Location</code> Header of the response contains a path to the registration record held in Orion.</p>\n<blockquote>\n<p><em>Note:</em> if you have registered with the Weather API, you can retrieve live values for <code>temperature</code> and <code>relativeHumidity</code> in Berlin by placing the following <code>url</code> in the <code>provider</code>:</p>\n<ul>\n<li><code>http://context-provider:3000/proxy/v1/weather/weatherConditions</code></li>\n</ul>\n</blockquote>\n","urlObject":{"protocol":"http","path":["v2","registrations"],"host":["localhost:1026"],"query":[{"disabled":true,"description":{"content":"<p>Entity type, to avoid ambiguity in case there are several entities with the same entity id</p>\n","type":"text/plain"},"key":"type","value":"Store"},{"disabled":true,"description":{"content":"<p>Ordered list of attribute names to display</p>\n","type":"text/plain"},"key":"attrs","value":"name"}],"variable":[]}},"response":[],"_postman_id":"601852dd-2a33-4bbc-a458-644a604c983f"},{"name":"Register a Context Provider - Tweets","id":"a4f4d07f-aa8f-4d54-a55d-397dd829447d","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[{"key":"Content-Type","value":"application/json"}],"body":{"mode":"raw","raw":"{\n   \"description\": \"Get Tweets for Store 1\",\n   \"dataProvided\": {\n     \"entities\": [\n       {\n         \"id\" : \"urn:ngsi-ld:Store:001\",\n         \"type\": \"Store\"\n       }\n     ],\n     \"attrs\": [\n      \"tweets\"\n    ]\n   },\n   \"provider\": {\n     \"http\": {\n       \"url\": \"http://context-provider:3000/catfacts/tweets\"\n     },\n     \"legacyForwarding\": false\n   },\n   \"status\": \"active\"\n}"},"url":"http://localhost:1026/v2/registrations","description":"<p>This example registers the Cat Facts API Context Provider with the Orion Context Broker.</p>\n<p>The body of the request states that: <em>\"The URL</em> <code>http://context-provider:3000/proxy/v1/catfacts/tweets</code> <em>is capable of providing</em> <code>tweets</code> <em>data for the entity called</em> <code>id=urn:ngsi-ld:Store:001</code>.<em>\"</em></p>\n<p>The values are <strong>never</strong> held within Orion, it is always requested on demand from the registered context provider. Orion merely holds the registration information about which context providers can offer context data.</p>\n<p>This request will return with a <strong>201 - Created</strong> response code. The <code>Location</code> Header of the response contains a path to the registration record held in Orion.</p>\n<blockquote>\n<p><em>Note:</em> if you have registered with the Twitter API, you can retrieve live values for <code>tweets</code> in Berlin by placing the following <code>url</code> in the <code>provider</code>:</p>\n<ul>\n<li><code>http://context-provider:3000/proxy/v1/twitter/tweets</code></li>\n</ul>\n</blockquote>\n","urlObject":{"protocol":"http","path":["v2","registrations"],"host":["localhost:1026"],"query":[{"disabled":true,"description":{"content":"<p>Entity type, to avoid ambiguity in case there are several entities with the same entity id</p>\n","type":"text/plain"},"key":"type","value":"Store"},{"disabled":true,"description":{"content":"<p>Ordered list of attribute names to display</p>\n","type":"text/plain"},"key":"attrs","value":"name"}],"variable":[]}},"response":[],"_postman_id":"a4f4d07f-aa8f-4d54-a55d-397dd829447d"},{"name":"Read a registered content provider","id":"e730ed8e-2138-4ef8-b130-824326486760","request":{"method":"GET","header":[],"body":{"mode":"formdata","formdata":[]},"url":"http://localhost:1026/v2/registrations/5addeffd93e53f86d8264521","description":"<p>This example reads  the registration data with the id <code>5addeffd93e53f86d8264521</code> from the context.</p>\n<p>Registration data can be obtained by making a GET request to the <code>/v2/registrations/&lt;entity&gt;</code> endpoint.</p>\n","urlObject":{"protocol":"http","path":["v2","registrations","5addeffd93e53f86d8264521"],"host":["localhost:1026"],"query":[{"disabled":true,"description":{"content":"<p>Entity type, to avoid ambiguity in case there are several entities with the same entity id</p>\n","type":"text/plain"},"key":"type","value":"Store"},{"disabled":true,"description":{"content":"<p>Ordered list of attribute names to display</p>\n","type":"text/plain"},"key":"attrs","value":"name"}],"variable":[]}},"response":[],"_postman_id":"e730ed8e-2138-4ef8-b130-824326486760"},{"name":"List all registered content providers","id":"7a587072-8e4d-429d-b164-72ec06b514ca","request":{"method":"GET","header":[],"body":{"mode":"formdata","formdata":[]},"url":"http://localhost:1026/v2/registrations","description":"<p>This example lists all registered context providers</p>\n<p>Full context data  for a specified entity type can be retrieved by making a GET request to the <code>/v2/registrations/</code> endpoint.</p>\n","urlObject":{"protocol":"http","path":["v2","registrations"],"host":["localhost:1026"],"query":[{"disabled":true,"description":{"content":"<p>Entity type, to avoid ambiguity in case there are several entities with the same entity id</p>\n","type":"text/plain"},"key":"type","value":"Store"}],"variable":[]}},"response":[],"_postman_id":"7a587072-8e4d-429d-b164-72ec06b514ca"},{"name":"Remove a registered content provider","id":"9ec487c1-2d08-415f-bc5b-c8d2655b77d8","request":{"method":"DELETE","header":[],"body":{"mode":"formdata","formdata":[]},"url":"http://localhost:1026/v2/registrations/5ad5b9435c28633f0ae90671","description":"<p>This example removes the registration with the id <code>5ad5b9435c28633f0ae90671</code> from the context.</p>\n<p>Registrations can be deleted by making a DELETE request to the <code>/v2/registrations/&lt;entity&gt;</code> endpoint.</p>\n<hr />\n<p>Subsequent requests using the same <code>id</code> will result in an error response since the entity no longer exists</p>\n","urlObject":{"protocol":"http","path":["v2","registrations","5ad5b9435c28633f0ae90671"],"host":["localhost:1026"],"query":[{"disabled":true,"description":{"content":"<p>Entity type, to avoid ambiguity in case there are several entities with the same entity id</p>\n","type":"text/plain"},"key":"type","value":"Store"},{"disabled":true,"description":{"content":"<p>Ordered list of attribute names to display</p>\n","type":"text/plain"},"key":"attrs","value":"name"}],"variable":[]}},"response":[],"_postman_id":"9ec487c1-2d08-415f-bc5b-c8d2655b77d8"}],"id":"5d610d41-4779-4b65-91b1-31256c4e0eae","description":"<p>All Context Provider Registration actions take place on the <code>v2/registrations</code> endpoint. The standatd CRUD mappings apply:</p>\n<ul>\n<li>Creation is mapped to the HTTP POST</li>\n<li>Reading/Listing registrations to HTTP GET verb</li>\n<li>Deletion is mapped to HTTP DELETE</li>\n</ul>\n","event":[{"listen":"prerequest","script":{"id":"ecb1fe44-a6ca-45f0-b04f-8fd08c24e916","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"fe5b4d0c-f893-45bc-b2ce-b128e18491f3","type":"text/javascript","exec":[""]}}],"_postman_id":"5d610d41-4779-4b65-91b1-31256c4e0eae"},{"name":"Reading Context Data","item":[{"name":"Obtain Store Information","id":"1706c713-90fc-4d3f-a53a-80713b9be2f1","request":{"method":"GET","header":[],"body":{"mode":"formdata","formdata":[]},"url":"http://localhost:1026/v2/entities/urn:ngsi-ld:Store:001","description":"<p>This example reads the full context from the <strong>Store</strong> entity with the <code>id=urn:ngsi-ld:Store:001</code>.</p>\n<p>The <code>relativeHumidity</code> attribute is returned as part of the context for the entity because a context provider has been registered to provide that data.</p>\n","urlObject":{"protocol":"http","path":["v2","entities","urn:ngsi-ld:Store:001"],"host":["localhost:1026"],"query":[],"variable":[]}},"response":[],"_postman_id":"1706c713-90fc-4d3f-a53a-80713b9be2f1"},{"name":"Obtain Store Humidity","id":"b65ff3ae-0e19-44c6-adb7-78c64bac5973","request":{"method":"GET","header":[],"body":{"mode":"formdata","formdata":[]},"url":"http://localhost:1026/v2/entities/urn:ngsi-ld:Store:001/attrs/relativeHumidity/value","description":"<p>This example reads the value of the <code>relativeHumidity</code> attribute from the <strong>Store</strong> entity with the <code>id=urn:ngsi-ld:Store:001</code>.</p>\n<p>Data is returned in the context because a context provider has been registered to provide that data.</p>\n","urlObject":{"protocol":"http","path":["v2","entities","urn:ngsi-ld:Store:001","attrs","relativeHumidity","value"],"host":["localhost:1026"],"query":[],"variable":[]}},"response":[],"_postman_id":"b65ff3ae-0e19-44c6-adb7-78c64bac5973"}],"id":"1d9c46bf-7028-4a8c-aa6a-9e36bb9f06af","description":"<p>Once a Context Provider has been registered, the new context data will be included in the response if the context of the associated entity is requested.</p>\n","event":[{"listen":"prerequest","script":{"id":"c43b57f2-84cc-4d57-8c6d-5b4260399699","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"cc26f7d9-301c-48e2-891f-3c336c18fe96","type":"text/javascript","exec":[""]}}],"_postman_id":"1d9c46bf-7028-4a8c-aa6a-9e36bb9f06af"}],"event":[{"listen":"prerequest","script":{"id":"343e1af9-161c-4ec3-ba3a-a63bf0296b92","type":"text/javascript","exec":[""]}},{"listen":"test","script":{"id":"dc4dca7c-b13f-475e-888f-046dafbba038","type":"text/javascript","exec":[""]}}],"variable":[{"key":"orion","value":"localhost:1026","type":"string"},{"key":"context-provider","value":"localhost:3000","type":"string"}]}