@azure-rest/agrifood-farming 1.0.0-alpha.20230127.1 → 1.0.0-alpha.20230224.1
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 +33 -45
- package/dist/index.js +312 -10
- 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 +3 -0
- 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.map +1 -1
- package/dist-esm/src/parameters.js.map +1 -1
- package/dist-esm/src/pollingHelper.js +10 -6
- package/dist-esm/src/pollingHelper.js.map +1 -1
- 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 +7 -5
- package/types/agrifood-farming-rest.d.ts +9284 -2622
package/README.md
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
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
|
+
|
|
14
15
|
- [Source code][source_code]
|
|
15
16
|
- [Package (NPM)][npm]
|
|
16
17
|
- [API reference documentation][ref_docs]
|
|
@@ -25,17 +26,17 @@ Key links:
|
|
|
25
26
|
### Prerequisites
|
|
26
27
|
|
|
27
28
|
- You must have an [Azure subscription][azure_subscription].
|
|
28
|
-
-
|
|
29
|
+
- Microsoft Azure Data Manager for Agriculture resource - [Microsoft Azure Data Manager for Agriculture][install_farmbeats]
|
|
29
30
|
|
|
30
31
|
### Install the `@azure-rest/agrifood-farming` package
|
|
31
32
|
|
|
32
|
-
Install the
|
|
33
|
+
Install the Data Manager for Agriculture rest client library for JavaScript with `npm`:
|
|
33
34
|
|
|
34
35
|
```bash
|
|
35
36
|
npm install @azure-rest/agrifood-farming
|
|
36
37
|
```
|
|
37
38
|
|
|
38
|
-
### Create and authenticate a `
|
|
39
|
+
### Create and authenticate a `Microsoft Azure Data Manager for Agriculture` REST Client
|
|
39
40
|
|
|
40
41
|
To use an [Azure Active Directory (AAD) token credential][authenticate_with_token],
|
|
41
42
|
provide an instance of the desired credential type obtained from the
|
|
@@ -72,12 +73,12 @@ This client is one of our REST clients. We highly recommend you read how to use
|
|
|
72
73
|
|
|
73
74
|
Farm hierarchy is a collection of below entities.
|
|
74
75
|
|
|
75
|
-
-
|
|
76
|
+
- Party - is the custodian of all the agronomic data.
|
|
76
77
|
- Farm - is a logical collection of fields and/or seasonal fields. They do not have any area associated with them.
|
|
77
78
|
- Field - is a multi-polygon area. This is expected to be stable across seasons.
|
|
78
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.
|
|
79
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.
|
|
80
|
-
- 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.
|
|
81
82
|
|
|
82
83
|
### [Scenes][scenes]
|
|
83
84
|
|
|
@@ -89,13 +90,13 @@ Fam operations includes details pertaining to tilling, planting, application of
|
|
|
89
90
|
|
|
90
91
|
## Examples
|
|
91
92
|
|
|
92
|
-
### Create a
|
|
93
|
+
### Create a Party
|
|
93
94
|
|
|
94
95
|
Once you have authenticated and created the client object as shown in the [Authenticate the client](#create-and-authenticate-a-farmbeats-rest-client)
|
|
95
|
-
section, you can create a
|
|
96
|
+
section, you can create a party within the Data Manager for Agriculture resource like this:
|
|
96
97
|
|
|
97
98
|
```typescript
|
|
98
|
-
import FarmBeats from "@azure-rest/agrifood-farming";
|
|
99
|
+
import FarmBeats, { isUnexpected } from "@azure-rest/agrifood-farming";
|
|
99
100
|
import { DefaultAzureCredential } from "@azure/identity";
|
|
100
101
|
|
|
101
102
|
const client = FarmBeats(
|
|
@@ -103,29 +104,30 @@ const client = FarmBeats(
|
|
|
103
104
|
new DefaultAzureCredential()
|
|
104
105
|
);
|
|
105
106
|
|
|
106
|
-
const
|
|
107
|
-
const result = await
|
|
107
|
+
const partyId = "test_party";
|
|
108
|
+
const result = await farmbeatsClient.path("/parties/{partyId}", partyId).patch({
|
|
108
109
|
body: {
|
|
109
|
-
name: "Contoso
|
|
110
|
-
description: "Your custom
|
|
110
|
+
name: "Contoso Party",
|
|
111
|
+
description: "Your custom party description here",
|
|
111
112
|
status: "Active",
|
|
112
|
-
properties: { foo: "bar", "numeric one": 1, "1": "numeric key" }
|
|
113
|
+
properties: { foo: "bar", "numeric one": 1, "1": "numeric key" },
|
|
113
114
|
},
|
|
114
115
|
// Set the content-type of the request
|
|
115
|
-
contentType: "application/merge-patch+json"
|
|
116
|
+
contentType: "application/merge-patch+json",
|
|
116
117
|
});
|
|
117
118
|
|
|
118
|
-
if (result
|
|
119
|
+
if (isUnexpected(result)) {
|
|
119
120
|
throw result.body.error;
|
|
120
121
|
}
|
|
121
122
|
|
|
122
|
-
|
|
123
|
+
const party = result.body;
|
|
124
|
+
console.log(`Created Party: ${party.name}`);
|
|
123
125
|
```
|
|
124
126
|
|
|
125
|
-
### List
|
|
127
|
+
### List Parties
|
|
126
128
|
|
|
127
129
|
```typescript
|
|
128
|
-
import FarmBeats from "@azure-rest/agrifood-farming";
|
|
130
|
+
import FarmBeats, { isUnexpected } from "@azure-rest/agrifood-farming";
|
|
129
131
|
import { DefaultAzureCredential } from "@azure/identity";
|
|
130
132
|
|
|
131
133
|
const client = FarmBeats(
|
|
@@ -133,33 +135,19 @@ const client = FarmBeats(
|
|
|
133
135
|
new DefaultAzureCredential()
|
|
134
136
|
);
|
|
135
137
|
|
|
136
|
-
const
|
|
138
|
+
const response = await farmbeatsClient.path("/parties").get();
|
|
137
139
|
|
|
138
|
-
if (
|
|
139
|
-
throw
|
|
140
|
+
if (isUnexpected(response)) {
|
|
141
|
+
throw response.body.error;
|
|
140
142
|
}
|
|
141
143
|
|
|
142
|
-
|
|
143
|
-
let skipToken = result.body.skipToken;
|
|
144
|
-
|
|
145
|
-
// Farmer results may be paginated. In case there are more than one page of farmers
|
|
146
|
-
// the service would return a skipToken that can be used for subsequent request to get
|
|
147
|
-
// the next page of farmers. Here we'll keep calling until the service stops returning a
|
|
148
|
-
// skip token which means that there are no more pages.
|
|
149
|
-
while (skipToken) {
|
|
150
|
-
const page = await client.path("/farmers").get({ queryParameters: { $skipToken: skipToken } });
|
|
151
|
-
if (page.status !== "200") {
|
|
152
|
-
throw page.body.error;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
farmers.concat(page.body.value ?? []);
|
|
156
|
-
skipToken = page.body.skipToken;
|
|
157
|
-
}
|
|
144
|
+
const parties = paginate(farmbeatsClient, response);
|
|
158
145
|
|
|
159
|
-
//
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
146
|
+
// Log each party id
|
|
147
|
+
for await (const party of parties) {
|
|
148
|
+
const partyOutput = party;
|
|
149
|
+
console.log(partyOutput.id);
|
|
150
|
+
}
|
|
163
151
|
```
|
|
164
152
|
|
|
165
153
|
### Additional Samples
|
package/dist/index.js
CHANGED
|
@@ -7,14 +7,297 @@ var corePaging = require('@azure/core-paging');
|
|
|
7
7
|
var coreLro = require('@azure/core-lro');
|
|
8
8
|
|
|
9
9
|
// Copyright (c) Microsoft Corporation.
|
|
10
|
-
|
|
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 = {}) {
|
|
11
17
|
var _a, _b;
|
|
12
|
-
const baseUrl = (_a = options.baseUrl) !== null && _a !== void 0 ? _a : `${
|
|
13
|
-
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";
|
|
14
20
|
options = Object.assign(Object.assign({}, options), { credentials: {
|
|
15
21
|
scopes: ["https://farmbeats.azure.net/.default"],
|
|
16
22
|
} });
|
|
17
|
-
|
|
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);
|
|
18
301
|
}
|
|
19
302
|
|
|
20
303
|
// Copyright (c) Microsoft Corporation.
|
|
@@ -92,7 +375,8 @@ function checkPagingRequest(response) {
|
|
|
92
375
|
* @param options - Options to set a resume state or custom polling interval.
|
|
93
376
|
* @returns - A poller object to poll for operation state updates and eventually get the final response.
|
|
94
377
|
*/
|
|
95
|
-
function getLongRunningPoller(client, initialResponse, options = {}) {
|
|
378
|
+
async function getLongRunningPoller(client, initialResponse, options = {}) {
|
|
379
|
+
var _a;
|
|
96
380
|
const poller = {
|
|
97
381
|
requestMethod: initialResponse.request.method,
|
|
98
382
|
requestPath: initialResponse.request.url,
|
|
@@ -108,15 +392,18 @@ function getLongRunningPoller(client, initialResponse, options = {}) {
|
|
|
108
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
|
|
109
393
|
// depending on the lro pattern that the service implements. If non is provided we default to the initial path.
|
|
110
394
|
const response = await client.pathUnchecked(path !== null && path !== void 0 ? path : initialResponse.request.url).get();
|
|
111
|
-
|
|
395
|
+
const lroResponse = getLroResponse(response);
|
|
396
|
+
lroResponse.rawResponse.headers["x-ms-original-url"] = initialResponse.request.url;
|
|
397
|
+
return lroResponse;
|
|
112
398
|
},
|
|
113
399
|
};
|
|
114
|
-
|
|
400
|
+
options.resolveOnUnsuccessful = (_a = options.resolveOnUnsuccessful) !== null && _a !== void 0 ? _a : true;
|
|
401
|
+
return coreLro.createHttpPoller(poller, options);
|
|
115
402
|
}
|
|
116
403
|
/**
|
|
117
|
-
* Converts a Rest Client response to a response that the LRO
|
|
404
|
+
* Converts a Rest Client response to a response that the LRO implementation understands
|
|
118
405
|
* @param response - a rest client http response
|
|
119
|
-
* @returns - An LRO response that the LRO
|
|
406
|
+
* @returns - An LRO response that the LRO implementation understands
|
|
120
407
|
*/
|
|
121
408
|
function getLroResponse(response) {
|
|
122
409
|
if (Number.isNaN(response.status)) {
|
|
@@ -128,9 +415,24 @@ function getLroResponse(response) {
|
|
|
128
415
|
};
|
|
129
416
|
}
|
|
130
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("&");
|
|
429
|
+
}
|
|
430
|
+
|
|
131
431
|
// Copyright (c) Microsoft Corporation.
|
|
132
432
|
|
|
133
|
-
exports
|
|
433
|
+
exports.buildMultiCollection = buildMultiCollection;
|
|
434
|
+
exports["default"] = createClient;
|
|
134
435
|
exports.getLongRunningPoller = getLongRunningPoller;
|
|
436
|
+
exports.isUnexpected = isUnexpected;
|
|
135
437
|
exports.paginate = paginate;
|
|
136
438
|
//# sourceMappingURL=index.js.map
|