Skip to content

Commit ed88036

Browse files
committed
Update client_2x Subrequest docs to include a plant_type term.
1 parent 9cc0549 commit ed88036

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88

99
### Fixed
1010
- Do not include the endpoint property in the serialized subrequest.
11+
- Update client_2x Subrequests docs to include a plant_type when creating the plant asset.
1112

1213
## [1.0.0-beta.3] -- 2021-07-26
1314
### Fixed

docs/client_2x.md

+25-8
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,18 @@ from farmOS import farmOS
280280
from farmOS.subrequests import Action, Subrequest, SubrequestsBlueprint, Format
281281

282282
client = farmOS("http://localhost", scope="farm_manager", version=2)
283-
client.authorize(username, password)
283+
client.authorize('username', 'password')
284+
285+
plant_type = {
286+
"data": {
287+
"type": "taxonomy_term--plant_type",
288+
"attributes": {
289+
"name": "New plant type"
290+
}
291+
}
292+
}
293+
294+
new_plant_type = Subrequest(action=Action.create, requestId="create-plant-type", endpoint="api/taxonomy_term/plant_type", body=plant_type)
284295

285296
plant = {
286297
"data": {
@@ -289,9 +300,19 @@ plant = {
289300
"name": "My new plant",
290301
"description": "Created in the first request.",
291302
},
303+
"relationships": {
304+
"plant_type": {
305+
"data": [
306+
{
307+
"type": "taxonomy_term--plant_type",
308+
"id": "{{create-plant-type.body@$.data.id}}"
309+
}
310+
]
311+
}
312+
}
292313
}
293314
}
294-
new_asset = Subrequest(action=Action.create, requestId="create-asset", endpoint="api/asset/plant", body=plant)
315+
new_asset = Subrequest(action=Action.create, requestId="create-asset", waitFor=["create-plant-type"], endpoint="api/asset/plant", body=plant)
295316

296317
log = {
297318
"data": {
@@ -315,15 +336,11 @@ log = {
315336
new_log = Subrequest(action=Action.create, requestId="create-log", waitFor=["create-asset"], endpoint="api/log/seeding", body=log)
316337

317338
# Create a blueprint object
318-
blueprint = SubrequestsBlueprint.parse_obj([new_asset, new_log])
339+
blueprint = SubrequestsBlueprint.parse_obj([new_plant_type, new_asset, new_log])
319340

320341
# OR provide a list of Subrequest objects.
321-
blueprint = [new_asset, new_log]
342+
blueprint = [new_plant_type, new_asset, new_log]
322343

323344
# Send the blueprint.
324345
response = client.subrequests.send(blueprint, format=Format.json)
325-
326-
# New resource ids.
327-
print(response['create-asset']['data']['id'])
328-
print(response['create-log']['data']['id'])
329346
```

0 commit comments

Comments
 (0)