@azure-rest/agrifood-farming 1.0.0-beta.1 → 1.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +42 -50
- package/dist/index.js +424 -5
- package/dist/index.js.map +1 -1
- package/dist-esm/src/clientDefinitions.js +4 -0
- package/dist-esm/src/clientDefinitions.js.map +1 -0
- package/dist-esm/src/farmBeats.js +18 -4
- package/dist-esm/src/farmBeats.js.map +1 -1
- package/dist-esm/src/index.js +7 -1
- package/dist-esm/src/index.js.map +1 -1
- package/dist-esm/src/isUnexpected.js +269 -0
- package/dist-esm/src/isUnexpected.js.map +1 -0
- package/dist-esm/src/models.js.map +1 -1
- package/dist-esm/src/outputModels.js +4 -0
- package/dist-esm/src/outputModels.js.map +1 -0
- package/dist-esm/src/paginateHelper.js +70 -0
- package/dist-esm/src/paginateHelper.js.map +1 -0
- package/dist-esm/src/parameters.js.map +1 -1
- package/dist-esm/src/pollingHelper.js +50 -0
- package/dist-esm/src/pollingHelper.js.map +1 -0
- package/dist-esm/src/responses.js.map +1 -1
- package/dist-esm/src/serializeHelper.js +13 -0
- package/dist-esm/src/serializeHelper.js.map +1 -0
- package/package.json +30 -29
- package/types/agrifood-farming-rest.d.ts +10281 -2670
- package/CHANGELOG.md +0 -5
package/README.md
CHANGED
|
@@ -1,16 +1,21 @@
|
|
|
1
|
-
# Azure
|
|
1
|
+
# Microsoft Azure Data Manager for Agriculture REST client library for JavaScript
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Microsoft Azure Data Manager for Agriculture is a B2B PaaS offering from Microsoft that makes it easy for AgriFood companies to build intelligent digital agriculture solutions on Azure.Data Manager for Agriculture acquire, aggregate, and process agricultural data from various sources (farm equipment, weather, satellite) without the need to invest in deep data engineering resources. Customers can build SaaS solutions on top of Data Manager for Agriculture and leverage first class support for model building to generate insights at scale.
|
|
4
4
|
|
|
5
|
-
Use
|
|
5
|
+
Use Data Manager for Agriculture client library for JavaScript to do the following.
|
|
6
6
|
|
|
7
|
-
- Create & update
|
|
7
|
+
- Create & update parties, farms, fields, seasonal fields and boundaries.
|
|
8
8
|
- Ingest satellite and weather data for areas of interest.
|
|
9
9
|
- Ingest farm operations data covering tilling, planting, harvesting and application of farm inputs.
|
|
10
10
|
|
|
11
11
|
**Please rely heavily on the [service's documentation][product_documentation] and our [REST client docs][rest_client] to use this library**
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
Key links:
|
|
14
|
+
|
|
15
|
+
- [Source code][source_code]
|
|
16
|
+
- [Package (NPM)][npm]
|
|
17
|
+
- [API reference documentation][ref_docs]
|
|
18
|
+
- [Product documentation][product_documentation]
|
|
14
19
|
|
|
15
20
|
## Getting started
|
|
16
21
|
|
|
@@ -21,17 +26,17 @@ Use FarmBeats client library for JavaScript to do the following.
|
|
|
21
26
|
### Prerequisites
|
|
22
27
|
|
|
23
28
|
- You must have an [Azure subscription][azure_subscription].
|
|
24
|
-
-
|
|
29
|
+
- Microsoft Azure Data Manager for Agriculture resource - [Microsoft Azure Data Manager for Agriculture][install_farmbeats]
|
|
25
30
|
|
|
26
31
|
### Install the `@azure-rest/agrifood-farming` package
|
|
27
32
|
|
|
28
|
-
Install the
|
|
33
|
+
Install the Data Manager for Agriculture rest client library for JavaScript with `npm`:
|
|
29
34
|
|
|
30
35
|
```bash
|
|
31
36
|
npm install @azure-rest/agrifood-farming
|
|
32
37
|
```
|
|
33
38
|
|
|
34
|
-
### Create and authenticate a `
|
|
39
|
+
### Create and authenticate a `Microsoft Azure Data Manager for Agriculture` REST Client
|
|
35
40
|
|
|
36
41
|
To use an [Azure Active Directory (AAD) token credential][authenticate_with_token],
|
|
37
42
|
provide an instance of the desired credential type obtained from the
|
|
@@ -68,12 +73,12 @@ This client is one of our REST clients. We highly recommend you read how to use
|
|
|
68
73
|
|
|
69
74
|
Farm hierarchy is a collection of below entities.
|
|
70
75
|
|
|
71
|
-
-
|
|
76
|
+
- Party - is the custodian of all the agronomic data.
|
|
72
77
|
- Farm - is a logical collection of fields and/or seasonal fields. They do not have any area associated with them.
|
|
73
78
|
- Field - is a multi-polygon area. This is expected to be stable across seasons.
|
|
74
79
|
- Seasonal field - is a multi-polygon area. To define a seasonal boundary we need the details of area (boundary), time (season) and crop. New seasonal fields are expected to be created for every growing season.
|
|
75
80
|
- Boundary - is the actual multi-polygon area expressed as a geometry (in geojson). It is normally associated with a field or a seasonal field. Satellite, weather and farm operations data is linked to a boundary.
|
|
76
|
-
- Cascade delete - Agronomic data is stored hierarchically with
|
|
81
|
+
- Cascade delete - Agronomic data is stored hierarchically with party as the root. The hierarchy includes Party -> Farms -> Fields -> Seasonal Fields -> Boundaries -> Associated data (satellite, weather, farm operations). Cascade delete refers to the process of deleting any node and its subtree.
|
|
77
82
|
|
|
78
83
|
### [Scenes][scenes]
|
|
79
84
|
|
|
@@ -85,13 +90,13 @@ Fam operations includes details pertaining to tilling, planting, application of
|
|
|
85
90
|
|
|
86
91
|
## Examples
|
|
87
92
|
|
|
88
|
-
### Create a
|
|
93
|
+
### Create a Party
|
|
89
94
|
|
|
90
95
|
Once you have authenticated and created the client object as shown in the [Authenticate the client](#create-and-authenticate-a-farmbeats-rest-client)
|
|
91
|
-
section, you can create a
|
|
96
|
+
section, you can create a party within the Data Manager for Agriculture resource like this:
|
|
92
97
|
|
|
93
98
|
```typescript
|
|
94
|
-
import FarmBeats from "@azure-rest/agrifood-farming";
|
|
99
|
+
import FarmBeats, { isUnexpected } from "@azure-rest/agrifood-farming";
|
|
95
100
|
import { DefaultAzureCredential } from "@azure/identity";
|
|
96
101
|
|
|
97
102
|
const client = FarmBeats(
|
|
@@ -99,11 +104,11 @@ const client = FarmBeats(
|
|
|
99
104
|
new DefaultAzureCredential()
|
|
100
105
|
);
|
|
101
106
|
|
|
102
|
-
const
|
|
103
|
-
const result = await
|
|
107
|
+
const partyId = "test_party";
|
|
108
|
+
const result = await farmbeatsClient.path("/parties/{partyId}", partyId).patch({
|
|
104
109
|
body: {
|
|
105
|
-
name: "Contoso
|
|
106
|
-
description: "Your custom
|
|
110
|
+
name: "Contoso Party",
|
|
111
|
+
description: "Your custom party description here",
|
|
107
112
|
status: "Active",
|
|
108
113
|
properties: { foo: "bar", "numeric one": 1, "1": "numeric key" },
|
|
109
114
|
},
|
|
@@ -111,17 +116,18 @@ const result = await client.path("/farmers/{farmerId}", farmerId).patch({
|
|
|
111
116
|
contentType: "application/merge-patch+json",
|
|
112
117
|
});
|
|
113
118
|
|
|
114
|
-
if (result
|
|
119
|
+
if (isUnexpected(result)) {
|
|
115
120
|
throw result.body.error;
|
|
116
121
|
}
|
|
117
122
|
|
|
118
|
-
|
|
123
|
+
const party = result.body;
|
|
124
|
+
console.log(`Created Party: ${party.name}`);
|
|
119
125
|
```
|
|
120
126
|
|
|
121
|
-
### List
|
|
127
|
+
### List Parties
|
|
122
128
|
|
|
123
129
|
```typescript
|
|
124
|
-
import FarmBeats from "@azure-rest/agrifood-farming";
|
|
130
|
+
import FarmBeats, { isUnexpected } from "@azure-rest/agrifood-farming";
|
|
125
131
|
import { DefaultAzureCredential } from "@azure/identity";
|
|
126
132
|
|
|
127
133
|
const client = FarmBeats(
|
|
@@ -129,33 +135,19 @@ const client = FarmBeats(
|
|
|
129
135
|
new DefaultAzureCredential()
|
|
130
136
|
);
|
|
131
137
|
|
|
132
|
-
const
|
|
138
|
+
const response = await farmbeatsClient.path("/parties").get();
|
|
133
139
|
|
|
134
|
-
if (
|
|
135
|
-
throw
|
|
140
|
+
if (isUnexpected(response)) {
|
|
141
|
+
throw response.body.error;
|
|
136
142
|
}
|
|
137
143
|
|
|
138
|
-
|
|
139
|
-
let skipToken = result.body.skipToken;
|
|
140
|
-
|
|
141
|
-
// Farmer results may be paginated. In case there are more than one page of farmers
|
|
142
|
-
// the service would return a skipToken that can be used for subsequent request to get
|
|
143
|
-
// the next page of farmers. Here we'll keep calling until the service stops returning a
|
|
144
|
-
// skip token which means that there are no more pages.
|
|
145
|
-
while (skipToken) {
|
|
146
|
-
const page = await client.path("/farmers").get({ queryParameters: { $skipToken: skipToken } });
|
|
147
|
-
if (page.status !== "200") {
|
|
148
|
-
throw page.body.error;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
farmers.concat(page.body.value ?? []);
|
|
152
|
-
skipToken = page.body.skipToken;
|
|
153
|
-
}
|
|
144
|
+
const parties = paginate(farmbeatsClient, response);
|
|
154
145
|
|
|
155
|
-
//
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
146
|
+
// Log each party id
|
|
147
|
+
for await (const party of parties) {
|
|
148
|
+
const partyOutput = party;
|
|
149
|
+
console.log(partyOutput.id);
|
|
150
|
+
}
|
|
159
151
|
```
|
|
160
152
|
|
|
161
153
|
### Additional Samples
|
|
@@ -174,7 +166,7 @@ import { setLogLevel } from "@azure/logger";
|
|
|
174
166
|
setLogLevel("info");
|
|
175
167
|
```
|
|
176
168
|
|
|
177
|
-
For more detailed instructions on how to enable logs, you can look at the [@azure/logger package docs](https://github.com/Azure/azure-sdk-for-js/tree/
|
|
169
|
+
For more detailed instructions on how to enable logs, you can look at the [@azure/logger package docs](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/logger).
|
|
178
170
|
|
|
179
171
|
## Next steps
|
|
180
172
|
|
|
@@ -184,7 +176,7 @@ For more extensive documentation on the FarmBeats, see the [FarmBeats documentat
|
|
|
184
176
|
|
|
185
177
|
## Contributing
|
|
186
178
|
|
|
187
|
-
If you'd like to contribute to this library, please read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/
|
|
179
|
+
If you'd like to contribute to this library, please read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md) to learn more about how to build and test the code.
|
|
188
180
|
|
|
189
181
|
## Related projects
|
|
190
182
|
|
|
@@ -193,16 +185,16 @@ If you'd like to contribute to this library, please read the [contributing guide
|
|
|
193
185
|

|
|
194
186
|
|
|
195
187
|
[product_documentation]: https://docs.microsoft.com/azure/industry/agriculture/overview-azure-farmbeats
|
|
196
|
-
[rest_client]: https://github.com/Azure/azure-sdk-for-js/blob/
|
|
197
|
-
[source_code]: https://github.com/Azure/azure-sdk-for-js/tree/
|
|
188
|
+
[rest_client]: https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/rest-clients.md
|
|
189
|
+
[source_code]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/agrifood/agrifood-farming-rest
|
|
198
190
|
[npm]: https://www.npmjs.com/org/azure-rest
|
|
199
191
|
[ref_docs]: https://azure.github.io/azure-sdk-for-js
|
|
200
192
|
[azure_subscription]: https://azure.microsoft.com/free/
|
|
201
193
|
[farmbeats_resource]: https://docs.microsoft.com/azure/industry/agriculture/install-azure-farmbeats
|
|
202
194
|
[authenticate_with_token]: https://docs.microsoft.com/azure/cognitive-services/authentication?tabs=powershell#authenticate-with-an-authentication-token
|
|
203
|
-
[azure_identity_credentials]: https://github.com/Azure/azure-sdk-for-js/tree/
|
|
195
|
+
[azure_identity_credentials]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#credentials
|
|
204
196
|
[azure_identity_npm]: https://www.npmjs.com/package/@azure/identity
|
|
205
|
-
[default_azure_credential]: https://github.com/Azure/azure-sdk-for-js/tree/
|
|
197
|
+
[default_azure_credential]: https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/identity/identity#defaultazurecredential
|
|
206
198
|
[install_farmbeats]: https://aka.ms/FarmBeatsInstallDocumentationPaaS
|
|
207
199
|
[farm_hierarchy]: https://aka.ms/FarmBeatsFarmHierarchyDocs
|
|
208
200
|
[scenes]: https://aka.ms/FarmBeatsSatellitePaaSDocumentation
|
package/dist/index.js
CHANGED
|
@@ -1,19 +1,438 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
3
5
|
var coreClient = require('@azure-rest/core-client');
|
|
6
|
+
var corePaging = require('@azure/core-paging');
|
|
7
|
+
var coreLro = require('@azure/core-lro');
|
|
4
8
|
|
|
5
9
|
// Copyright (c) Microsoft Corporation.
|
|
6
|
-
|
|
10
|
+
/**
|
|
11
|
+
* Initialize a new instance of `FarmBeatsClient`
|
|
12
|
+
* @param $host type: string, server parameter
|
|
13
|
+
* @param credentials type: TokenCredential, uniquely identify client credential
|
|
14
|
+
* @param options type: ClientOptions, the parameter for all optional parameters
|
|
15
|
+
*/
|
|
16
|
+
function createClient($host, credentials, options = {}) {
|
|
7
17
|
var _a, _b;
|
|
8
|
-
const baseUrl = (_a = options.baseUrl) !== null && _a !== void 0 ? _a : `${
|
|
9
|
-
options.apiVersion = (_b = options.apiVersion) !== null && _b !== void 0 ? _b : "
|
|
18
|
+
const baseUrl = (_a = options.baseUrl) !== null && _a !== void 0 ? _a : `${$host}`;
|
|
19
|
+
options.apiVersion = (_b = options.apiVersion) !== null && _b !== void 0 ? _b : "2022-11-01-preview";
|
|
10
20
|
options = Object.assign(Object.assign({}, options), { credentials: {
|
|
11
21
|
scopes: ["https://farmbeats.azure.net/.default"],
|
|
12
22
|
} });
|
|
13
|
-
|
|
23
|
+
const userAgentInfo = `azsdk-js-agrifood-farming-rest/1.0.0-beta.2`;
|
|
24
|
+
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
25
|
+
? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
|
|
26
|
+
: `${userAgentInfo}`;
|
|
27
|
+
options = Object.assign(Object.assign({}, options), { userAgentOptions: {
|
|
28
|
+
userAgentPrefix,
|
|
29
|
+
} });
|
|
30
|
+
const client = coreClient.getClient(baseUrl, credentials, options);
|
|
31
|
+
return client;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Copyright (c) Microsoft Corporation.
|
|
35
|
+
// Licensed under the MIT license.
|
|
36
|
+
const responseMap = {
|
|
37
|
+
"GET /application-data": ["200"],
|
|
38
|
+
"PUT /application-data/cascade-delete/{jobId}": ["202"],
|
|
39
|
+
"GET /application-data/cascade-delete/{jobId}": ["200"],
|
|
40
|
+
"GET /parties/{partyId}/application-data": ["200"],
|
|
41
|
+
"GET /parties/{partyId}/application-data/{applicationDataId}": ["200"],
|
|
42
|
+
"PATCH /parties/{partyId}/application-data/{applicationDataId}": ["200", "201"],
|
|
43
|
+
"DELETE /parties/{partyId}/application-data/{applicationDataId}": ["204"],
|
|
44
|
+
"GET /parties/{partyId}/attachments": ["200"],
|
|
45
|
+
"GET /parties/{partyId}/attachments/{attachmentId}": ["200"],
|
|
46
|
+
"PATCH /parties/{partyId}/attachments/{attachmentId}": ["200", "201"],
|
|
47
|
+
"DELETE /parties/{partyId}/attachments/{attachmentId}": ["204"],
|
|
48
|
+
"GET /parties/{partyId}/attachments/{attachmentId}/file": ["200"],
|
|
49
|
+
"GET /boundaries": ["200"],
|
|
50
|
+
"POST /boundaries": ["200"],
|
|
51
|
+
"PUT /boundaries/cascade-delete/{jobId}": ["202"],
|
|
52
|
+
"GET /boundaries/cascade-delete/{jobId}": ["200"],
|
|
53
|
+
"GET /parties/{partyId}/boundaries": ["200"],
|
|
54
|
+
"POST /parties/{partyId}/boundaries": ["200"],
|
|
55
|
+
"PATCH /parties/{partyId}/boundaries/{boundaryId}": ["200", "201"],
|
|
56
|
+
"GET /parties/{partyId}/boundaries/{boundaryId}": ["200"],
|
|
57
|
+
"DELETE /parties/{partyId}/boundaries/{boundaryId}": ["204"],
|
|
58
|
+
"GET /parties/{partyId}/boundaries/{boundaryId}/overlap": ["200"],
|
|
59
|
+
"GET /crop-products": ["200"],
|
|
60
|
+
"GET /crop-products/{cropProductId}": ["200"],
|
|
61
|
+
"PATCH /crop-products/{cropProductId}": ["200", "201"],
|
|
62
|
+
"DELETE /crop-products/{cropProductId}": ["204"],
|
|
63
|
+
"GET /crops": ["200"],
|
|
64
|
+
"GET /crops/{cropId}": ["200"],
|
|
65
|
+
"PATCH /crops/{cropId}": ["200", "201"],
|
|
66
|
+
"DELETE /crops/{cropId}": ["204"],
|
|
67
|
+
"GET /sensor-partners/{sensorPartnerId}/device-data-models": ["200"],
|
|
68
|
+
"PATCH /sensor-partners/{sensorPartnerId}/device-data-models/{deviceDataModelId}": ["200", "201"],
|
|
69
|
+
"GET /sensor-partners/{sensorPartnerId}/device-data-models/{deviceDataModelId}": ["200"],
|
|
70
|
+
"DELETE /sensor-partners/{sensorPartnerId}/device-data-models/{deviceDataModelId}": ["204"],
|
|
71
|
+
"GET /sensor-partners/{sensorPartnerId}/devices": ["200"],
|
|
72
|
+
"PATCH /sensor-partners/{sensorPartnerId}/devices/{deviceId}": ["200", "201"],
|
|
73
|
+
"GET /sensor-partners/{sensorPartnerId}/devices/{deviceId}": ["200"],
|
|
74
|
+
"DELETE /sensor-partners/{sensorPartnerId}/devices/{deviceId}": ["204"],
|
|
75
|
+
"PUT /farm-operations/ingest-data/{jobId}": ["202"],
|
|
76
|
+
"GET /farm-operations/ingest-data/{jobId}": ["200"],
|
|
77
|
+
"GET /farms": ["200"],
|
|
78
|
+
"PUT /farms/cascade-delete/{jobId}": ["202"],
|
|
79
|
+
"GET /farms/cascade-delete/{jobId}": ["200"],
|
|
80
|
+
"GET /parties/{partyId}/farms": ["200"],
|
|
81
|
+
"GET /parties/{partyId}/farms/{farmId}": ["200"],
|
|
82
|
+
"PATCH /parties/{partyId}/farms/{farmId}": ["200", "201"],
|
|
83
|
+
"DELETE /parties/{partyId}/farms/{farmId}": ["204"],
|
|
84
|
+
"GET /fields": ["200"],
|
|
85
|
+
"GET /fields/cascade-delete/{jobId}": ["200"],
|
|
86
|
+
"PUT /fields/cascade-delete/{jobId}": ["202"],
|
|
87
|
+
"GET /parties/{partyId}/fields": ["200"],
|
|
88
|
+
"GET /parties/{partyId}/fields/{fieldId}": ["200"],
|
|
89
|
+
"PATCH /parties/{partyId}/fields/{fieldId}": ["200", "201"],
|
|
90
|
+
"DELETE /parties/{partyId}/fields/{fieldId}": ["204"],
|
|
91
|
+
"GET /harvest-data": ["200"],
|
|
92
|
+
"PUT /harvest-data/cascade-delete/{jobId}": ["202"],
|
|
93
|
+
"GET /harvest-data/cascade-delete/{jobId}": ["200"],
|
|
94
|
+
"GET /parties/{partyId}/harvest-data": ["200"],
|
|
95
|
+
"GET /parties/{partyId}/harvest-data/{harvestDataId}": ["200"],
|
|
96
|
+
"PATCH /parties/{partyId}/harvest-data/{harvestDataId}": ["200", "201"],
|
|
97
|
+
"DELETE /parties/{partyId}/harvest-data/{harvestDataId}": ["204"],
|
|
98
|
+
"PUT /image-processing/rasterize/{jobId}": ["202"],
|
|
99
|
+
"GET /image-processing/rasterize/{jobId}": ["200"],
|
|
100
|
+
"GET /parties/{partyId}/models/{modelId}/resource-types/{resourceType}/resources/{resourceId}/insight-attachments": ["200"],
|
|
101
|
+
"PATCH /parties/{partyId}/models/{modelId}/resource-types/{resourceType}/resources/{resourceId}/insight-attachments/{insightAttachmentId}": ["200", "201"],
|
|
102
|
+
"GET /parties/{partyId}/models/{modelId}/resource-types/{resourceType}/resources/{resourceId}/insight-attachments/{insightAttachmentId}": ["200"],
|
|
103
|
+
"DELETE /parties/{partyId}/models/{modelId}/resource-types/{resourceType}/resources/{resourceId}/insight-attachments/{insightAttachmentId}": ["204"],
|
|
104
|
+
"GET /parties/{partyId}/models/{modelId}/resource-types/{resourceType}/resources/{resourceId}/insight-attachments/{insightAttachmentId}/file": ["200"],
|
|
105
|
+
"PUT /insights/cascade-delete/{jobId}": ["202"],
|
|
106
|
+
"GET /insights/cascade-delete/{jobId}": ["200"],
|
|
107
|
+
"GET /parties/{partyId}/models/{modelId}/resource-types/{resourceType}/resources/{resourceId}/insights": ["200"],
|
|
108
|
+
"PATCH /parties/{partyId}/models/{modelId}/resource-types/{resourceType}/resources/{resourceId}/insights/{insightId}": ["200", "201"],
|
|
109
|
+
"GET /parties/{partyId}/models/{modelId}/resource-types/{resourceType}/resources/{resourceId}/insights/{insightId}": ["200"],
|
|
110
|
+
"DELETE /parties/{partyId}/models/{modelId}/resource-types/{resourceType}/resources/{resourceId}/insights/{insightId}": ["204"],
|
|
111
|
+
"GET /management-zones": ["200"],
|
|
112
|
+
"GET /management-zones/cascade-delete/{jobId}": ["200"],
|
|
113
|
+
"PUT /management-zones/cascade-delete/{jobId}": ["202"],
|
|
114
|
+
"GET /parties/{partyId}/management-zones": ["200"],
|
|
115
|
+
"GET /parties/{partyId}/management-zones/{managementZoneId}": ["200"],
|
|
116
|
+
"PATCH /parties/{partyId}/management-zones/{managementZoneId}": ["200", "201"],
|
|
117
|
+
"DELETE /parties/{partyId}/management-zones/{managementZoneId}": ["204"],
|
|
118
|
+
"PUT /model-inference/models/microsoft-biomass/infer-data/{jobId}": ["202"],
|
|
119
|
+
"GET /model-inference/models/microsoft-biomass/infer-data/{jobId}": ["200"],
|
|
120
|
+
"PUT /model-inference/models/microsoft-sensor-placement/infer-data/{jobId}": ["202"],
|
|
121
|
+
"GET /model-inference/models/microsoft-sensor-placement/infer-data/{jobId}": ["200"],
|
|
122
|
+
"PUT /model-inference/models/microsoft-soil-moisture/infer-data/{jobId}": ["202"],
|
|
123
|
+
"GET /model-inference/models/microsoft-soil-moisture/infer-data/{jobId}": ["200"],
|
|
124
|
+
"GET /nutrient-analyses": ["200"],
|
|
125
|
+
"GET /parties/{partyId}/nutrient-analyses": ["200"],
|
|
126
|
+
"GET /parties/{partyId}/nutrient-analyses/{nutrientAnalysisId}": ["200"],
|
|
127
|
+
"PATCH /parties/{partyId}/nutrient-analyses/{nutrientAnalysisId}": ["200", "201"],
|
|
128
|
+
"DELETE /parties/{partyId}/nutrient-analyses/{nutrientAnalysisId}": ["204"],
|
|
129
|
+
"GET /oauth/providers": ["200"],
|
|
130
|
+
"GET /oauth/providers/{oauthProviderId}": ["200"],
|
|
131
|
+
"PATCH /oauth/providers/{oauthProviderId}": ["200", "201"],
|
|
132
|
+
"DELETE /oauth/providers/{oauthProviderId}": ["204"],
|
|
133
|
+
"GET /oauth/providers/cascade-delete/{jobId}": ["200"],
|
|
134
|
+
"PUT /oauth/providers/cascade-delete/{jobId}": ["202"],
|
|
135
|
+
"GET /oauth/tokens": ["200"],
|
|
136
|
+
"POST /oauth/tokens/:connect": ["200"],
|
|
137
|
+
"GET /oauth/tokens/remove/{jobId}": ["200"],
|
|
138
|
+
"PUT /oauth/tokens/remove/{jobId}": ["202"],
|
|
139
|
+
"GET /parties": ["200"],
|
|
140
|
+
"GET /parties/{partyId}": ["200"],
|
|
141
|
+
"PATCH /parties/{partyId}": ["200", "201"],
|
|
142
|
+
"DELETE /parties/{partyId}": ["204"],
|
|
143
|
+
"GET /parties/cascade-delete/{jobId}": ["200"],
|
|
144
|
+
"PUT /parties/cascade-delete/{jobId}": ["202"],
|
|
145
|
+
"GET /parties/{partyId}/planting-data": ["200"],
|
|
146
|
+
"GET /parties/{partyId}/planting-data/{plantingDataId}": ["200"],
|
|
147
|
+
"PATCH /parties/{partyId}/planting-data/{plantingDataId}": ["200", "201"],
|
|
148
|
+
"DELETE /parties/{partyId}/planting-data/{plantingDataId}": ["204"],
|
|
149
|
+
"GET /planting-data": ["200"],
|
|
150
|
+
"PUT /planting-data/cascade-delete/{jobId}": ["202"],
|
|
151
|
+
"GET /planting-data/cascade-delete/{jobId}": ["200"],
|
|
152
|
+
"GET /parties/{partyId}/plant-tissue-analyses": ["200"],
|
|
153
|
+
"GET /parties/{partyId}/plant-tissue-analyses/{plantTissueAnalysisId}": ["200"],
|
|
154
|
+
"PATCH /parties/{partyId}/plant-tissue-analyses/{plantTissueAnalysisId}": ["200", "201"],
|
|
155
|
+
"DELETE /parties/{partyId}/plant-tissue-analyses/{plantTissueAnalysisId}": ["204"],
|
|
156
|
+
"GET /plant-tissue-analyses": ["200"],
|
|
157
|
+
"PUT /plant-tissue-analyses/cascade-delete/{jobId}": ["202"],
|
|
158
|
+
"GET /plant-tissue-analyses/cascade-delete/{jobId}": ["200"],
|
|
159
|
+
"GET /parties/{partyId}/prescription-maps": ["200"],
|
|
160
|
+
"GET /parties/{partyId}/prescription-maps/{prescriptionMapId}": ["200"],
|
|
161
|
+
"PATCH /parties/{partyId}/prescription-maps/{prescriptionMapId}": ["200", "201"],
|
|
162
|
+
"DELETE /parties/{partyId}/prescription-maps/{prescriptionMapId}": ["204"],
|
|
163
|
+
"GET /prescription-maps": ["200"],
|
|
164
|
+
"GET /prescription-maps/cascade-delete/{jobId}": ["200"],
|
|
165
|
+
"PUT /prescription-maps/cascade-delete/{jobId}": ["202"],
|
|
166
|
+
"GET /parties/{partyId}/prescriptions": ["200"],
|
|
167
|
+
"GET /parties/{partyId}/prescriptions/{prescriptionId}": ["200"],
|
|
168
|
+
"PATCH /parties/{partyId}/prescriptions/{prescriptionId}": ["200", "201"],
|
|
169
|
+
"DELETE /parties/{partyId}/prescriptions/{prescriptionId}": ["204"],
|
|
170
|
+
"GET /prescriptions": ["200"],
|
|
171
|
+
"GET /prescriptions/cascade-delete/{jobId}": ["200"],
|
|
172
|
+
"PUT /prescriptions/cascade-delete/{jobId}": ["202"],
|
|
173
|
+
"GET /scenes": ["200"],
|
|
174
|
+
"GET /scenes/downloadFiles": ["200"],
|
|
175
|
+
"PUT /scenes/satellite/ingest-data/{jobId}": ["202"],
|
|
176
|
+
"GET /scenes/satellite/ingest-data/{jobId}": ["200"],
|
|
177
|
+
"POST /scenes/stac-collections/{collectionId}:search": ["200"],
|
|
178
|
+
"GET /scenes/stac-collections/{collectionId}/features/{featureId}": ["200"],
|
|
179
|
+
"GET /parties/{partyId}/seasonal-fields": ["200"],
|
|
180
|
+
"GET /parties/{partyId}/seasonal-fields/{seasonalFieldId}": ["200"],
|
|
181
|
+
"PATCH /parties/{partyId}/seasonal-fields/{seasonalFieldId}": ["200", "201"],
|
|
182
|
+
"DELETE /parties/{partyId}/seasonal-fields/{seasonalFieldId}": ["204"],
|
|
183
|
+
"GET /seasonal-fields": ["200"],
|
|
184
|
+
"GET /seasonal-fields/cascade-delete/{jobId}": ["200"],
|
|
185
|
+
"PUT /seasonal-fields/cascade-delete/{jobId}": ["202"],
|
|
186
|
+
"GET /seasons": ["200"],
|
|
187
|
+
"GET /seasons/{seasonId}": ["200"],
|
|
188
|
+
"PATCH /seasons/{seasonId}": ["200", "201"],
|
|
189
|
+
"DELETE /seasons/{seasonId}": ["204"],
|
|
190
|
+
"GET /sensor-partners/{sensorPartnerId}/sensor-data-models": ["200"],
|
|
191
|
+
"PATCH /sensor-partners/{sensorPartnerId}/sensor-data-models/{sensorDataModelId}": ["200", "201"],
|
|
192
|
+
"GET /sensor-partners/{sensorPartnerId}/sensor-data-models/{sensorDataModelId}": ["200"],
|
|
193
|
+
"DELETE /sensor-partners/{sensorPartnerId}/sensor-data-models/{sensorDataModelId}": ["204"],
|
|
194
|
+
"GET /sensor-events": ["200"],
|
|
195
|
+
"GET /sensor-mappings": ["200"],
|
|
196
|
+
"PATCH /sensor-mappings/{sensorMappingId}": ["200", "201"],
|
|
197
|
+
"GET /sensor-mappings/{sensorMappingId}": ["200"],
|
|
198
|
+
"DELETE /sensor-mappings/{sensorMappingId}": ["204"],
|
|
199
|
+
"GET /sensor-partners/{sensorPartnerId}/integrations": ["200"],
|
|
200
|
+
"PATCH /sensor-partners/{sensorPartnerId}/integrations/{integrationId}": ["200", "201"],
|
|
201
|
+
"GET /sensor-partners/{sensorPartnerId}/integrations/{integrationId}": ["200"],
|
|
202
|
+
"DELETE /sensor-partners/{sensorPartnerId}/integrations/{integrationId}": ["204"],
|
|
203
|
+
"POST /sensor-partners/{sensorPartnerId}/integrations/{integrationId}/:check-consent": ["200"],
|
|
204
|
+
"POST /sensor-partners/{sensorPartnerId}/integrations/{integrationId}/:generate-consent-link": [
|
|
205
|
+
"200",
|
|
206
|
+
],
|
|
207
|
+
"GET /sensor-partners/{sensorPartnerId}/sensors": ["200"],
|
|
208
|
+
"PATCH /sensor-partners/{sensorPartnerId}/sensors/{sensorId}": ["200", "201"],
|
|
209
|
+
"GET /sensor-partners/{sensorPartnerId}/sensors/{sensorId}": ["200"],
|
|
210
|
+
"DELETE /sensor-partners/{sensorPartnerId}/sensors/{sensorId}": ["204"],
|
|
211
|
+
"GET /sensor-partners/{sensorPartnerId}/sensors/{sensorId}/connection-strings": ["200"],
|
|
212
|
+
"POST /sensor-partners/{sensorPartnerId}/sensors/{sensorId}/connection-strings/:renew": ["200"],
|
|
213
|
+
"POST /solutions/{solutionId}:cancel": ["200"],
|
|
214
|
+
"POST /solutions/{solutionId}:create": ["202"],
|
|
215
|
+
"GET /solutions/{solutionId}:create": ["202"],
|
|
216
|
+
"POST /solutions/{solutionId}:fetch": ["200"],
|
|
217
|
+
"GET /parties/{partyId}/tillage-data": ["200"],
|
|
218
|
+
"GET /parties/{partyId}/tillage-data/{tillageDataId}": ["200"],
|
|
219
|
+
"PATCH /parties/{partyId}/tillage-data/{tillageDataId}": ["200", "201"],
|
|
220
|
+
"DELETE /parties/{partyId}/tillage-data/{tillageDataId}": ["204"],
|
|
221
|
+
"GET /tillage-data": ["200"],
|
|
222
|
+
"PUT /tillage-data/cascade-delete/{jobId}": ["202"],
|
|
223
|
+
"GET /tillage-data/cascade-delete/{jobId}": ["200"],
|
|
224
|
+
"GET /weather": ["200"],
|
|
225
|
+
"GET /weather/delete-data/{jobId}": ["200"],
|
|
226
|
+
"PUT /weather/delete-data/{jobId}": ["202"],
|
|
227
|
+
"GET /weather/ingest-data/{jobId}": ["200"],
|
|
228
|
+
"PUT /weather/ingest-data/{jobId}": ["202"],
|
|
229
|
+
"POST /weather-data/:fetch": ["200"],
|
|
230
|
+
"GET /parties/{partyId}/zones": ["200"],
|
|
231
|
+
"GET /parties/{partyId}/zones/{zoneId}": ["200"],
|
|
232
|
+
"PATCH /parties/{partyId}/zones/{zoneId}": ["200", "201"],
|
|
233
|
+
"DELETE /parties/{partyId}/zones/{zoneId}": ["204"],
|
|
234
|
+
"GET /zones": ["200"],
|
|
235
|
+
"GET /zones/cascade-delete/{jobId}": ["200"],
|
|
236
|
+
"PUT /zones/cascade-delete/{jobId}": ["202"],
|
|
237
|
+
};
|
|
238
|
+
function isUnexpected(response) {
|
|
239
|
+
const lroOriginal = response.headers["x-ms-original-url"];
|
|
240
|
+
const url = new URL(lroOriginal !== null && lroOriginal !== void 0 ? lroOriginal : response.request.url);
|
|
241
|
+
const method = response.request.method;
|
|
242
|
+
let pathDetails = responseMap[`${method} ${url.pathname}`];
|
|
243
|
+
if (!pathDetails) {
|
|
244
|
+
pathDetails = getParametrizedPathSuccess(method, url.pathname);
|
|
245
|
+
}
|
|
246
|
+
return !pathDetails.includes(response.status);
|
|
247
|
+
}
|
|
248
|
+
function getParametrizedPathSuccess(method, path) {
|
|
249
|
+
var _a, _b, _c, _d;
|
|
250
|
+
const pathParts = path.split("/");
|
|
251
|
+
// Traverse list to match the longest candidate
|
|
252
|
+
// matchedLen: the length of candidate path
|
|
253
|
+
// matchedValue: the matched status code array
|
|
254
|
+
let matchedLen = -1, matchedValue = [];
|
|
255
|
+
// Iterate the responseMap to find a match
|
|
256
|
+
for (const [key, value] of Object.entries(responseMap)) {
|
|
257
|
+
// Extracting the path from the map key which is in format
|
|
258
|
+
// GET /path/foo
|
|
259
|
+
if (!key.startsWith(method)) {
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
262
|
+
const candidatePath = getPathFromMapKey(key);
|
|
263
|
+
// Get each part of the url path
|
|
264
|
+
const candidateParts = candidatePath.split("/");
|
|
265
|
+
// track if we have found a match to return the values found.
|
|
266
|
+
let found = true;
|
|
267
|
+
for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) {
|
|
268
|
+
if (((_a = candidateParts[i]) === null || _a === void 0 ? void 0 : _a.startsWith("{")) && ((_b = candidateParts[i]) === null || _b === void 0 ? void 0 : _b.indexOf("}")) !== -1) {
|
|
269
|
+
const start = candidateParts[i].indexOf("}") + 1, end = (_c = candidateParts[i]) === null || _c === void 0 ? void 0 : _c.length;
|
|
270
|
+
// If the current part of the candidate is a "template" part
|
|
271
|
+
// Try to use the suffix of pattern to match the path
|
|
272
|
+
// {guid} ==> $
|
|
273
|
+
// {guid}:export ==> :export$
|
|
274
|
+
const isMatched = new RegExp(`${(_d = candidateParts[i]) === null || _d === void 0 ? void 0 : _d.slice(start, end)}`).test(pathParts[j] || "");
|
|
275
|
+
if (!isMatched) {
|
|
276
|
+
found = false;
|
|
277
|
+
break;
|
|
278
|
+
}
|
|
279
|
+
continue;
|
|
280
|
+
}
|
|
281
|
+
// If the candidate part is not a template and
|
|
282
|
+
// the parts don't match mark the candidate as not found
|
|
283
|
+
// to move on with the next candidate path.
|
|
284
|
+
if (candidateParts[i] !== pathParts[j]) {
|
|
285
|
+
found = false;
|
|
286
|
+
break;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
// We finished evaluating the current candidate parts
|
|
290
|
+
// Update the matched value if and only if we found the longer pattern
|
|
291
|
+
if (found && candidatePath.length > matchedLen) {
|
|
292
|
+
matchedLen = candidatePath.length;
|
|
293
|
+
matchedValue = value;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
return matchedValue;
|
|
297
|
+
}
|
|
298
|
+
function getPathFromMapKey(mapKey) {
|
|
299
|
+
const pathStart = mapKey.indexOf("/");
|
|
300
|
+
return mapKey.slice(pathStart);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// Copyright (c) Microsoft Corporation.
|
|
304
|
+
/**
|
|
305
|
+
* Helper to paginate results from an initial response that follows the specification of Autorest `x-ms-pageable` extension
|
|
306
|
+
* @param client - Client to use for sending the next page requests
|
|
307
|
+
* @param initialResponse - Initial response containing the nextLink and current page of elements
|
|
308
|
+
* @param customGetPage - Optional - Function to define how to extract the page and next link to be used to paginate the results
|
|
309
|
+
* @returns - PagedAsyncIterableIterator to iterate the elements
|
|
310
|
+
*/
|
|
311
|
+
function paginate(client, initialResponse, options = {}) {
|
|
312
|
+
let firstRun = true;
|
|
313
|
+
const itemName = "value";
|
|
314
|
+
const nextLinkName = "nextLink";
|
|
315
|
+
const { customGetPage } = options;
|
|
316
|
+
const pagedResult = {
|
|
317
|
+
firstPageLink: "",
|
|
318
|
+
getPage: typeof customGetPage === "function"
|
|
319
|
+
? customGetPage
|
|
320
|
+
: async (pageLink) => {
|
|
321
|
+
const result = firstRun ? initialResponse : await client.pathUnchecked(pageLink).get();
|
|
322
|
+
firstRun = false;
|
|
323
|
+
checkPagingRequest(result);
|
|
324
|
+
const nextLink = getNextLink(result.body, nextLinkName);
|
|
325
|
+
const values = getElements(result.body, itemName);
|
|
326
|
+
return {
|
|
327
|
+
page: values,
|
|
328
|
+
nextPageLink: nextLink,
|
|
329
|
+
};
|
|
330
|
+
},
|
|
331
|
+
};
|
|
332
|
+
return corePaging.getPagedAsyncIterator(pagedResult);
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Gets for the value of nextLink in the body
|
|
336
|
+
*/
|
|
337
|
+
function getNextLink(body, nextLinkName) {
|
|
338
|
+
if (!nextLinkName) {
|
|
339
|
+
return undefined;
|
|
340
|
+
}
|
|
341
|
+
const nextLink = body[nextLinkName];
|
|
342
|
+
if (typeof nextLink !== "string" && typeof nextLink !== "undefined") {
|
|
343
|
+
throw new Error(`Body Property ${nextLinkName} should be a string or undefined`);
|
|
344
|
+
}
|
|
345
|
+
return nextLink;
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* Gets the elements of the current request in the body.
|
|
349
|
+
*/
|
|
350
|
+
function getElements(body, itemName) {
|
|
351
|
+
const value = body[itemName];
|
|
352
|
+
// value has to be an array according to the x-ms-pageable extension.
|
|
353
|
+
// The fact that this must be an array is used above to calculate the
|
|
354
|
+
// type of elements in the page in PaginateReturn
|
|
355
|
+
if (!Array.isArray(value)) {
|
|
356
|
+
throw new Error(`Couldn't paginate response\n Body doesn't contain an array property with name: ${itemName}`);
|
|
357
|
+
}
|
|
358
|
+
return value !== null && value !== void 0 ? value : [];
|
|
359
|
+
}
|
|
360
|
+
/**
|
|
361
|
+
* Checks if a request failed
|
|
362
|
+
*/
|
|
363
|
+
function checkPagingRequest(response) {
|
|
364
|
+
const Http2xxStatusCodes = ["200", "201", "202", "203", "204", "205", "206", "207", "208", "226"];
|
|
365
|
+
if (!Http2xxStatusCodes.includes(response.status)) {
|
|
366
|
+
throw coreClient.createRestError(`Pagination failed with unexpected statusCode ${response.status}`, response);
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
// Copyright (c) Microsoft Corporation.
|
|
371
|
+
/**
|
|
372
|
+
* Helper function that builds a Poller object to help polling a long running operation.
|
|
373
|
+
* @param client - Client to use for sending the request to get additional pages.
|
|
374
|
+
* @param initialResponse - The initial response.
|
|
375
|
+
* @param options - Options to set a resume state or custom polling interval.
|
|
376
|
+
* @returns - A poller object to poll for operation state updates and eventually get the final response.
|
|
377
|
+
*/
|
|
378
|
+
async function getLongRunningPoller(client, initialResponse, options = {}) {
|
|
379
|
+
var _a;
|
|
380
|
+
const poller = {
|
|
381
|
+
requestMethod: initialResponse.request.method,
|
|
382
|
+
requestPath: initialResponse.request.url,
|
|
383
|
+
sendInitialRequest: async () => {
|
|
384
|
+
// In the case of Rest Clients we are building the LRO poller object from a response that's the reason
|
|
385
|
+
// we are not triggering the initial request here, just extracting the information from the
|
|
386
|
+
// response we were provided.
|
|
387
|
+
return getLroResponse(initialResponse);
|
|
388
|
+
},
|
|
389
|
+
sendPollRequest: async (path) => {
|
|
390
|
+
// This is the callback that is going to be called to poll the service
|
|
391
|
+
// to get the latest status. We use the client provided and the polling path
|
|
392
|
+
// which is an opaque URL provided by caller, the service sends this in one of the following headers: operation-location, azure-asyncoperation or location
|
|
393
|
+
// depending on the lro pattern that the service implements. If non is provided we default to the initial path.
|
|
394
|
+
const response = await client.pathUnchecked(path !== null && path !== void 0 ? path : initialResponse.request.url).get();
|
|
395
|
+
const lroResponse = getLroResponse(response);
|
|
396
|
+
lroResponse.rawResponse.headers["x-ms-original-url"] = initialResponse.request.url;
|
|
397
|
+
return lroResponse;
|
|
398
|
+
},
|
|
399
|
+
};
|
|
400
|
+
options.resolveOnUnsuccessful = (_a = options.resolveOnUnsuccessful) !== null && _a !== void 0 ? _a : true;
|
|
401
|
+
return coreLro.createHttpPoller(poller, options);
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Converts a Rest Client response to a response that the LRO implementation understands
|
|
405
|
+
* @param response - a rest client http response
|
|
406
|
+
* @returns - An LRO response that the LRO implementation understands
|
|
407
|
+
*/
|
|
408
|
+
function getLroResponse(response) {
|
|
409
|
+
if (Number.isNaN(response.status)) {
|
|
410
|
+
throw new TypeError(`Status code of the response is not a number. Value: ${response.status}`);
|
|
411
|
+
}
|
|
412
|
+
return {
|
|
413
|
+
flatResponse: response,
|
|
414
|
+
rawResponse: Object.assign(Object.assign({}, response), { statusCode: Number.parseInt(response.status), body: response.body }),
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
// Copyright (c) Microsoft Corporation.
|
|
419
|
+
// Licensed under the MIT license.
|
|
420
|
+
function buildMultiCollection(queryParameters, parameterName) {
|
|
421
|
+
return queryParameters
|
|
422
|
+
.map((item, index) => {
|
|
423
|
+
if (index === 0) {
|
|
424
|
+
return item;
|
|
425
|
+
}
|
|
426
|
+
return `${parameterName}=${item}`;
|
|
427
|
+
})
|
|
428
|
+
.join("&");
|
|
14
429
|
}
|
|
15
430
|
|
|
16
431
|
// Copyright (c) Microsoft Corporation.
|
|
17
432
|
|
|
18
|
-
|
|
433
|
+
exports.buildMultiCollection = buildMultiCollection;
|
|
434
|
+
exports["default"] = createClient;
|
|
435
|
+
exports.getLongRunningPoller = getLongRunningPoller;
|
|
436
|
+
exports.isUnexpected = isUnexpected;
|
|
437
|
+
exports.paginate = paginate;
|
|
19
438
|
//# sourceMappingURL=index.js.map
|