Skip to content

Commit cf462c4

Browse files
committed
acrolinx quality improvement
1 parent 5d1169c commit cf462c4

File tree

1 file changed

+27
-27
lines changed

1 file changed

+27
-27
lines changed

articles/data-manager-for-agri/how-to-write-weather-extension.md

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ ms.custom: template-how-to
1111

1212
# How to write a weather extension
1313

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.
1515

1616
## What is a weather extension
1717

@@ -26,7 +26,7 @@ At a high-level the extension file is a JSON consisting of two things:
2626

2727
### Provider metadata
2828

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.
3030

3131
#### Sample provider metadata
3232

@@ -47,18 +47,18 @@ It's a json object providing the details on the below fields that are necessary
4747

4848
|Name | Type | Description|
4949
|:-----:|:----:|----|
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|
5151
| extensionName | string | Name of the extension as to be used in Data Manager for Agriculture extension marketplace.|
5252
| 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.|
5656
| supportUrl | string | Website link to raise support queries & FAQs|
5757
| supportEmail | string | Email to send in the support queries.|
5858

5959
### API information
6060

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.
6262

6363
* API metadata
6464
* Authentication parameters
@@ -71,7 +71,7 @@ The API Information JSON array (`apiInfos`) can be further broken into the follo
7171

7272
#### API metadata
7373

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 API 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`.
7575

7676
##### Sample API metadata
7777

@@ -95,20 +95,20 @@ This section consists of basic information regarding the API. It's used by Data
9595
|Name | Type | Description|
9696
|:-----:|:----:|----|
9797
| 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.|
9999
| description | string | API description|
100100
| endpoint | string | API endpoint for Data Manager for Agriculture to call into the `apiName`.|
101101
| 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.|
103103
| typeOfData | string | Currently supported values are `Historical` and `Forecast`.|
104104
| granularity | string | Currently supported values are `Daily` and `Hourly`.|
105105
| defaultUnitSystem | string | Provide the name of the default units system supported by the `apiName`.|
106106

107107
#### Authentication parameters
108108

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`.
110110

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.
112112

113113
##### Sample authentication parameters
114114

@@ -142,7 +142,7 @@ As Data Manager for Agriculture collects the authentication information via the
142142
| 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.|
143143
| 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.|
144144
| 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.|
146146
| providerDataType | string | Provide the datatype of the `name` parameter.|
147147
| description | string | Data Manager for Agriculture description of what each of the `farmBeatsAuthMapping` means within each object.|
148148
| 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
194194
|:-----:|:----:|----|
195195
| apiInputParameters | array | JSON array of API input parameters, where each object signifies an input parameter supported by the `apiName`.|
196196
| 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.|
198198
| providerDataType | string | Provide the datatype of the `name` parameter.|
199199
| description | string | Provide a description of what `name` parameter means.|
200200
| location | string | Where in the API should the `name` parameter be sent. Currently supported values are `apiQuery` & `apiHeader`.|
201201

202202
#### Extracted API input parameters
203203

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.
205205

206206
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"`.
207207

@@ -220,15 +220,15 @@ Hence the extension needs to provide a [**HandleBars template**](https://handleb
220220

221221
|Name | Type | Description|
222222
|:-----:|:----:|----|
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` .|
225225
| template | string | HandleBars template depicting how is latitude and longitude information collected in the API input parameters.|
226226

227227
#### Functional parameters
228228

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.
230230

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.
232232

233233
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.
234234

@@ -260,7 +260,7 @@ For Data Manager for Agriculture to understand the usage of latitude and longitu
260260
|Name | Type | Description|
261261
|:-----:|:----:|----|
262262
| 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` .|
264264
| description | string | Data Manager for Agriculture description of functionality.|
265265
| functionalParameterEntities | array | JSON array of objects, where each object is specific to the latitude & longitude.|
266266

@@ -293,7 +293,7 @@ This section is used by Data Manager for Agriculture to understand the various t
293293

294294
#### Platform & custom parameters
295295

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.
297297

298298
Hence, when it comes to parameters, Data Manager for Agriculture internally supports the following set of parameters and treats them as `Platform parameters`.
299299

@@ -314,9 +314,9 @@ Hence, when it comes to parameters, Data Manager for Agriculture internally supp
314314
* windGust
315315
* windSpeed
316316

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.
318318

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.
320320

321321
> [!NOTE]
322322
>
@@ -432,14 +432,14 @@ In this section, the extension provides the units information for each of the pa
432432

433433
#### Platform & custom template
434434

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.
436436

437437
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.
438438

439439
> [!NOTE]
440440
> 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.
441441
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.
443443

444444
>:::image type="content" source="./media/template-flow.png" alt-text="Screen Shot of template flow.":::
445445
@@ -606,7 +606,7 @@ As shown in the above figure, validate your template against the respective API
606606
607607
#### Helper functions
608608

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.
610610

611611
##### Sample helper functions
612612

@@ -629,7 +629,7 @@ What action these helper functions do?
629629
* **ConvertDateInFormatToDateTime(object dateObject, string format)** - This function is used to parse a date in given format (Ex: 2016-12-15) to DateTime string.
630630
* **ConvertUnixTimeToDateTime(object unixTimeStamp)** - This function is used to convert unix timestamp (Ex: 1392267600) to datetime string.
631631
* **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.
633633

634634
```json
635635
{

0 commit comments

Comments
 (0)