You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/data-manager-for-agri/how-to-write-weather-extension.md
+27-27Lines changed: 27 additions & 27 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,7 @@ ms.custom: template-how-to
11
11
12
12
# How to write a weather extension
13
13
14
-
In this section you'll see a step-by-step guide to write your own weather extension.
14
+
In this section, you see a step-by-step guide to write your own weather extension.
15
15
16
16
## What is a weather extension
17
17
@@ -26,7 +26,7 @@ At a high-level the extension file is a JSON consisting of two things:
26
26
27
27
### Provider metadata
28
28
29
-
It's a json object providing the details on the below fields that are necessary to uniquely identify an extension and its versioning information. The details provided in this section of the extension will be shown to external customers in Data Manager for Agriculture marketplace. Therefore `extensionId` & `extensionName` (for easy identification) and `description` (for value-proposition) needs to be customer focused.
29
+
It's a json object providing the details on the below fields that are necessary to uniquely identify an extension and its versioning information. The details provided in this section of the extension are shown to external customers in Data Manager for Agriculture marketplace. Therefore `extensionId` & `extensionName` (for easy identification) and `description` (for value-proposition) needs to be customer focused.
30
30
31
31
#### Sample provider metadata
32
32
@@ -47,18 +47,18 @@ It's a json object providing the details on the below fields that are necessary
47
47
48
48
|Name | Type | Description|
49
49
|:-----:|:----:|----|
50
-
| extensionId | string | The ID provided in the fashion of organization name (ABC) and service (weather) Ex: `org.service`. extensionId is the unique identifier of the extension and the one which users will be using on the Data Manager for Agriculture platform to interact with the extension APIs|
50
+
| extensionId | string | The ID provided in the fashion of organization name (Contoso) and service (weather) Ex: `org.service`. extensionId is the unique identifier of the extension and the one which users are using on the Data Manager for Agriculture platform to interact with the extension APIs|
51
51
| extensionName | string | Name of the extension as to be used in Data Manager for Agriculture extension marketplace.|
52
52
| description | string | Description stating the capabilities and services offered by the extension.|
53
-
| dataCategory | string | For weather extensions use `weather`.|
54
-
| farmBeatsSchemaVersion | string | The version of the manifest file on the Data Manager for Agriculture side. Any updates to the existing manifest file will lead to a new version update to this field.|
55
-
| extensionVersion | string | The version of extension file. Starting with `1.0`. As there are updates to your extension file increment this version number according to the convention of major & minor updates.|
53
+
| dataCategory | string | For weather extensions, use `weather`.|
54
+
| farmBeatsSchemaVersion | string | The version of the manifest file on the Data Manager for Agriculture side. Any updates to the existing manifest file lead to a new version update to this field.|
55
+
| extensionVersion | string | The version of extension file. Starting with `1.0`. Updates to your extension file increment this version number according to the convention of major & minor updates.|
56
56
| supportUrl | string | Website link to raise support queries & FAQs|
57
57
| supportEmail | string | Email to send in the support queries.|
58
58
59
59
### API information
60
60
61
-
The API Information JSON array (`apiInfos`) can be further broken into the following structural elements
61
+
The API Information JSON array (`apiInfos`) can be further broken into the following structural elements.
62
62
63
63
* API metadata
64
64
* Authentication parameters
@@ -71,7 +71,7 @@ The API Information JSON array (`apiInfos`) can be further broken into the follo
71
71
72
72
#### API metadata
73
73
74
-
This section consists of basic information regarding the API. It's used by Data Manager for Agriculture to identify the `apiName` (called by users explicitly) and redirect the api request to the right `endpoint` based on the appropriate `requestType`.
74
+
This section consists of basic information regarding the APIused by Data Manager for Agriculture to identify the `apiName` (called by users explicitly) and redirect the API request to the right `endpoint` based on the appropriate `requestType`.
75
75
76
76
##### Sample API metadata
77
77
@@ -95,20 +95,20 @@ This section consists of basic information regarding the API. It's used by Data
95
95
|Name | Type | Description|
96
96
|:-----:|:----:|----|
97
97
| apiInfos | array | The JSON array of objects, where each API is an object within `apiInfos` array.|
98
-
| apiName | string | The API Name as supported by the extension, this is the exact name using which the users would be calling into the extension APIs. Kindly follow the same naming convention as mentioned in your API documentation.|
98
+
| apiName | string | The API Name as supported by the extension, it's the exact name using which the users would be calling into the extension APIs. Kindly follow the same naming convention as mentioned in your API documentation.|
99
99
| description | string | API description|
100
100
| endpoint | string | API endpoint for Data Manager for Agriculture to call into the `apiName`.|
101
101
| requestType | string |`GET` or `POST` or `PUT` request type as supported by the `apiName`.|
102
-
| isLoadAPI | boolean | If the `apiName` is a pass-through API like current weather data, make this key as `false`. For all the load APIs (historical & forecast) keep this field as `true`. When the `isLoadAPI` key is `false`, the API response would be directly sent to the user and wouldn't be stored in the Data Manager for Agriculture storage service.|
102
+
| isLoadAPI | boolean | If the `apiName` is a pass-through API like current weather data, make this key as `false`. For all the load APIs (historical & forecast), keep this field as `true`. When the `isLoadAPI` key is `false`, the API response would be directly sent to the user and wouldn't be stored in the Data Manager for Agriculture storage service.|
103
103
| typeOfData | string | Currently supported values are `Historical` and `Forecast`.|
104
104
| granularity | string | Currently supported values are `Daily` and `Hourly`.|
105
105
| defaultUnitSystem | string | Provide the name of the default units system supported by the `apiName`.|
106
106
107
107
#### Authentication parameters
108
108
109
-
This section takes in the authentication related parameters as supported by the `apiName`. As Data Manager for Agriculture supports two types of auth-related keys (`x-ms-farmBeats-data-provider-id` & `x-ms-farmBeats-data-provider-key`) in the api header section, the extension file needs to explicitly provide the key name of its respective authentication keys as required by the `apiName`.
109
+
This section takes in the authentication related parameters as supported by the `apiName`. As Data Manager for Agriculture supports two types of auth-related keys (`x-ms-farmBeats-data-provider-id` & `x-ms-farmBeats-data-provider-key`) in the API header section, the extension file needs to explicitly provide the key name of its respective authentication keys as required by the `apiName`.
110
110
111
-
As Data Manager for Agriculture collects the authentication information via the api header (in the [Create Weather Job API](/rest/api/data-manager-for-agri/dataplane-version2022-11-01-preview/weather/create-data-delete-job)). Authentication parameter mapping is done to ensure that Data Manager for Agriculture can pass the key accordingly to the extension as required.
111
+
As Data Manager for Agriculture collects the authentication information via the API header (in the [Create Weather Job API](/rest/api/data-manager-for-agri/dataplane-version2022-11-01-preview/weather/create-data-delete-job)). Authentication parameter mapping is done to ensure that Data Manager for Agriculture can pass the key accordingly to the extension as required.
112
112
113
113
##### Sample authentication parameters
114
114
@@ -142,7 +142,7 @@ As Data Manager for Agriculture collects the authentication information via the
142
142
| authInputParameters | array | JSON array of authentication parameters, where each object signifies a type of authentication supported. Use the key based on the authentication type supported by your extension.|
143
143
| farmBeatsAuthMapping | string | Currently two types of authentication related keys are supported. For API Key based authentication, use only `x-ms-farmBeats-data-provider-key` object, whereas for APP ID and APP Key based authentication use both `x-ms-farmBeats-data-provider-id` &`x-ms-farmBeats-data-provider-key` objects.|
144
144
| name | string | Name of the authentication key as supported by the `apiName`.|
145
-
| isRequired | boolean | Is this name a required parameter to the apiName. Provide true or false values.|
145
+
| isRequired | boolean | Is this name a required parameter to the apiName? Provide true or false values.|
146
146
| providerDataType | string | Provide the datatype of the `name` parameter.|
147
147
| description | string | Data Manager for Agriculture description of what each of the `farmBeatsAuthMapping` means within each object.|
148
148
| location | string | Where in the API should the `name` parameter be sent. Currently supported values are `apiQuery` & `apiHeader`.|
@@ -194,14 +194,14 @@ This section provides the details about the API signature (input parameters) to
194
194
|:-----:|:----:|----|
195
195
| apiInputParameters | array | JSON array of API input parameters, where each object signifies an input parameter supported by the `apiName`.|
196
196
| name | string | Name of the input parameter as supported by the `apiName`.|
197
-
| isRequired | boolean | Is this name a required parameter to the apiName. Provide true or false values.|
197
+
| isRequired | boolean | Is this name a required parameter to the apiName? Provide true or false values.|
198
198
| providerDataType | string | Provide the datatype of the `name` parameter.|
199
199
| description | string | Provide a description of what `name` parameter means.|
200
200
| location | string | Where in the API should the `name` parameter be sent. Currently supported values are `apiQuery` & `apiHeader`.|
201
201
202
202
#### Extracted API input parameters
203
203
204
-
This section is for dedicated for Data Manager for Agriculture to extract certain set of input parameters passed during the API request for computation and storage purpose. In this example Data Manager for Agriculture would be extracting the location information (latitude and longitude) from the API Input request and store them as part of each weather output in Data Manager for Agriculture.
204
+
This section is for Data Manager to extract input parameters passed in the API request for computation and storage. In this example Data Manager for Agriculture would be extracting the location information (latitude and longitude) from the API Input request and store them as part of each weather output in Data Manager for Agriculture.
205
205
206
206
Hence the extension needs to provide a [**HandleBars template**](https://handlebarsjs.com/examples/simple-expressions.html) on how to extract location information. The below example suggests that the extension API collects location information as `"lat"` for `"latitude"` and `"lon"` for `"longitude"`.
207
207
@@ -220,15 +220,15 @@ Hence the extension needs to provide a [**HandleBars template**](https://handleb
220
220
221
221
|Name | Type | Description|
222
222
|:-----:|:----:|----|
223
-
| extractedApiInputParameters | array | JSON array of extraction functionalities, where each object signifies what information needs to be extracted by Data Manager for Agriculture. Currently `location` is one such extraction.|
224
-
| name | string | Name of the extraction, currently the supported value will be`location` .|
223
+
| extractedApiInputParameters | array | JSON array of extraction functionalities, where each object signifies what information needs to be extracted. Currently `location` is one such extraction.|
224
+
| name | string | Name of the extraction, currently the supported value is`location` .|
225
225
| template | string | HandleBars template depicting how is latitude and longitude information collected in the API input parameters.|
226
226
227
227
#### Functional parameters
228
228
229
-
This section is dedicated for the functionalities/capabilities built by Data Manager for Agriculture. In the case of weather extension, centroid calculation is one such functionality.
229
+
This section is dedicated for the functionalities/capabilities built by Data Manager for Agriculture. For weather extension, centroid calculation is one such functionality.
230
230
231
-
When users don't provide the latitude/longitude coordinates, Data Manager for Agriculture will be using the primary geometry of the field (ID passed by user) to compute the centroid. The computed centroid coordinates will be passed as the latitude and longitude to the extension (data provider). Hence for Data Manager for Agriculture to be able to understand the usage of location coordinates the functional parameters section is used.
231
+
When users don't provide the latitude/longitude coordinates, Data Manager for Agriculture uses the primary geometry of the field (ID passed by user) to compute the centroid. The computed centroid coordinates are passed as the latitude and longitude to the extension (data provider). Hence for Data Manager for Agriculture to be able to understand the usage of location coordinates the functional parameters section is used.
232
232
233
233
For Data Manager for Agriculture to understand the usage of latitude and longitude in the `apiName` input parameters, the extension is expected to provide the `name` of key used for collecting location information followed by a **handlebar template** to imply how the latitude and longitude values need to be passed.
234
234
@@ -260,7 +260,7 @@ For Data Manager for Agriculture to understand the usage of latitude and longitu
260
260
|Name | Type | Description|
261
261
|:-----:|:----:|----|
262
262
| functionalParameters | array | JSON array of functionalities, where each object signifies a functionality supported by Data Manager for Agriculture. Currently `CentroidCalculation` is one such functionality.|
263
-
| name | string | Name of the functionality, currently the supported value will be`CentroidCalculation` .|
263
+
| name | string | Name of the functionality, currently the supported value is`CentroidCalculation` .|
264
264
| description | string | Data Manager for Agriculture description of functionality.|
265
265
| functionalParameterEntities | array | JSON array of objects, where each object is specific to the latitude & longitude.|
266
266
@@ -293,7 +293,7 @@ This section is used by Data Manager for Agriculture to understand the various t
293
293
294
294
#### Platform & custom parameters
295
295
296
-
In each weather API response, the weather measures which are sent as part of the output (ex: temperature, dewpoint etc.) are called as parameters.
296
+
In each weather API response, the weather measures, which are sent as part of the output (ex: temperature, dewpoint etc.) are called as parameters.
297
297
298
298
Hence, when it comes to parameters, Data Manager for Agriculture internally supports the following set of parameters and treats them as `Platform parameters`.
299
299
@@ -314,9 +314,9 @@ Hence, when it comes to parameters, Data Manager for Agriculture internally supp
314
314
* windGust
315
315
* windSpeed
316
316
317
-
Therefore, any extension sending weather parameters which do not fall under the platform parameters, will be sending them as part of `Custom parameters`. The key difference between platform & customer parameters is that, the users using Data Manager for Agriculture weather APIs will be able to query and filter on the platform parameters (Ex: temperature > 30) and not on custom parameters. However, custom parameters will be sent as part of the weather query output.
317
+
Therefore, any extension sending weather parameters, which don't fall under the platform parameters, is sending them as part of `Custom parameters`. The key difference between platform & customer parameters is that, the users using Data Manager for Agriculture weather APIs are able to query and filter on the platform parameters (Ex: temperature > 30) and not on custom parameters. However, custom parameters are sent as part of the weather query output.
318
318
319
-
In this section, the extension provides the units information for each of the parameters for every units system that is supported. This is done to ensure that Data Manager for Agriculture will know what is the underlying measurement unit for each weather parameter based on the information provided in this section of the extension.
319
+
In this section, the extension provides the units information for each of the parameters for every units system that is supported. Using this Data Manager for Agriculture knows what is the underlying measurement unit for each weather parameter based on the information provided in this section of the extension.
320
320
321
321
> [!NOTE]
322
322
>
@@ -432,14 +432,14 @@ In this section, the extension provides the units information for each of the pa
432
432
433
433
#### Platform & custom template
434
434
435
-
Template is the mapping information provided by the extension to convert the extension API output (JSON response) to the format which Data Manager for Agriculture expects. This is done to ensure that various weather data providers having different API output formats can now be uniformly mapped/converted to one single format.
435
+
Template is the mapping information provided by the extension to convert the extension API output (JSON response) to the format which Data Manager for Agriculture expects. Using this different API output formats can now be uniformly mapped/converted to one single format.
436
436
437
437
Template solution is found to be one of the most effective ways to parse the JSON output provided by the extension. In the case of weather extension, **Data Manager for Agriculture expects the extension to be written using [HandleBars](https://handlebarsjs.com/guide/#what-is-handlebars) template**. HandleBars is an open source templating language with simple to use expressions.
438
438
439
439
> [!NOTE]
440
440
> It is highly recommended to try-out the [HandleBars template](https://handlebarsjs.com/examples/simple-expressions.html) with the examples provided and learn how to make use of the helper functions to build your own parsing logic if it is not already provided by Data Manager for Agriculture.
441
441
442
-
On a high-level this is how templates will work, by taking the API response as the input and generating the output in the format expected by Data Manager for Agriculture.
442
+
On a high-level this is how templates work, by taking the API response as the input and generating the output in the format expected by Data Manager for Agriculture.
443
443
444
444
>:::image type="content" source="./media/template-flow.png" alt-text="Screen Shot of template flow.":::
445
445
@@ -606,7 +606,7 @@ As shown in the above figure, validate your template against the respective API
606
606
607
607
#### Helper functions
608
608
609
-
Helper functions are used by the templates to perform specific transformation on the data which isn't supported natively. Below are few helper functions that are supported by Data Manager for Agriculture.
609
+
Helper functions are used by the templates to perform specific transformation on the data, which isn't supported natively. Here are helper functions supported by Data Manager for Agriculture.
610
610
611
611
##### Sample helper functions
612
612
@@ -629,7 +629,7 @@ What action these helper functions do?
629
629
***ConvertDateInFormatToDateTime(object dateObject, string format)** - This function is used to parse a date in given format (Ex: 2016-12-15) to DateTime string.
630
630
***ConvertUnixTimeToDateTime(object unixTimeStamp)** - This function is used to convert unix timestamp (Ex: 1392267600) to datetime string.
631
631
***GetObjectFromListWithKeyValuePair(Array listOfObjects, string key, string value)** - Given a list of objects it fetches the object based on key (`type`) value (`RAIN`) pair.
632
-
In the below example, to pick the precipitation of `"type": "RAIN"` this function will be used.
632
+
In the below example, to pick the precipitation of `"type": "RAIN"` this function is used.
0 commit comments