Skip to content

Commit 69eaf23

Browse files
committed
Move usage to docs/index.
1 parent 909f56b commit 69eaf23

File tree

2 files changed

+93
-66
lines changed

2 files changed

+93
-66
lines changed

README.md

+5-66
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,10 @@
66
[![Twitter](https://img.shields.io/twitter/follow/farmOSorg.svg?label=%40farmOSorg&style=flat)](https://twitter.com/farmOSorg)
77
[![Chat](https://img.shields.io/matrix/farmOS:matrix.org.svg)](https://riot.im/app/#/room/#farmOS:matrix.org)
88

9-
farmOS.py is a Python library for interacting with [farmOS](https://farmOS.org)
10-
over API.
9+
farmOS.py is a Python library for interacting with farmOS servers over API.
1110

1211
For more information on farmOS, visit [farmOS.org](https://farmOS.org).
1312

14-
- [Installation](#installation)
15-
- [Usage](#usage)
16-
- [Server Info](#server-info)
17-
- [Client methods](#client-methods)
18-
- [farmOS 1.x](docs/client_1x.md)
19-
- [farmOS 2.x](docs/client_2x.md)
20-
21-
2213
## Installation
2314

2415
To install using `pip`:
@@ -29,65 +20,13 @@ $ pip install farmOS~=1.0.0b
2920

3021
To install using `conda` see [conda-forge/farmos-feedstock](https://github.com/conda-forge/farmos-feedstock#installing-farmos)
3122

32-
## Usage
33-
34-
### Server Info
35-
36-
```python
37-
38-
info = farm_client.info()
39-
40-
{
41-
"jsonapi": {
42-
"version": "1.0",
43-
"meta": {
44-
"links": {
45-
"self": {
46-
"href": "http://jsonapi.org/format/1.0/"
47-
}
48-
}
49-
}
50-
},
51-
"data": [],
52-
"meta": {
53-
"links": {
54-
"me": {
55-
"meta": {
56-
"id": "163c6e73-46fb-4283-b26b-153b598151ce"
57-
},
58-
"href": "http://localhost/api/user/user/163c6e73-46fb-4283-b26b-153b598151ce"
59-
}
60-
},
61-
"farm": {
62-
"name": "Drush Site-Install",
63-
"url": "http://localhost",
64-
"version": "2.x",
65-
"system_of_measurement": "metric"
66-
}
67-
},
68-
"links": {
69-
"asset--animal": {
70-
"href": "http://localhost/api/asset/animal"
71-
},
72-
"asset--equipment": {
73-
"href": "http://localhost/api/asset/equipment"
74-
},
75-
...
76-
}
77-
}
78-
```
79-
80-
81-
### Client methods
23+
## Documentation
8224

8325
farmOS.py can connect to farmOS servers running version ^1.6 or 2.x. The version should be specified when instantiating
84-
the farmOS client, see [Authentication](#authentication).
85-
86-
Because of [API changes](https://2x.farmos.org/development/api/changes/) in farmOS 2.x, the client provides different
87-
methods depending on the server version:
26+
the farmOS client.
8827

89-
- [1.x methods](docs/client_1x.md)
90-
- [2.x methods](docs/client_2x.md)
28+
- [1.x documentation](docs/client_1x.md)
29+
- [2.x documentation](docs/index.md)
9130

9231
## MAINTAINERS
9332

docs/index.md

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Introduction
2+
3+
## Motivation
4+
5+
farmOS.py is a Python library for interacting with farmOS servers over API.
6+
7+
This library was developed to support more custom use cases that interact
8+
with the farmOS server from a Python scripting environment. It can be used
9+
to build custom importers and exporters that interface with CSV, IoT and
10+
other APIs. farmOS.py also helps integrate with existing scientific and GIS
11+
tools that exist in the Python ecosystem.
12+
13+
The [farmOS Aggregator](https://github.com/farmOS/farmOS-aggregator)
14+
also uses farmOS.py to communicate with farmOS servers.
15+
16+
## Quick start
17+
18+
Learn farmOS.py by example.
19+
20+
### 1. Install
21+
22+
To install using `pip`:
23+
24+
```bash
25+
$ pip install farmOS~=1.0.0b
26+
```
27+
28+
To install using `conda` see [conda-forge/farmos-feedstock](https://github.com/conda-forge/farmos-feedstock#installing-farmos)
29+
30+
### 2. Create a farm client instance
31+
32+
```python
33+
from farmOS import farmOS
34+
35+
farm_client = farmOS(
36+
hostname= "https://farm.example.com",
37+
client_id = "farm",
38+
scope = "farm_manager",
39+
)
40+
```
41+
42+
### 3. Authorize with farmOS server
43+
44+
```python
45+
token = farm_client.authorize()
46+
# Complete username and password prompts.
47+
```
48+
49+
### 4. Get farmOS server info
50+
51+
```python
52+
info = farm_client.info()
53+
```
54+
55+
### 5. CRUD Operations with a farmOS log
56+
57+
```python
58+
59+
# Create observation log
60+
observation_log = {
61+
"attributes": {
62+
"name": "My Great Observation",
63+
"status": "pending",
64+
"notes": "Some notes"
65+
}
66+
}
67+
log = farm_client.log.send('observation', observation_log)
68+
log_id = log["data"]["id"]
69+
70+
# Update the log status to "done".
71+
done = {
72+
'id': log_id,
73+
"attributes": {
74+
"status": "done",
75+
}
76+
}
77+
updated_log = farm_client.log.send('observation', done)
78+
79+
# Delete the log.
80+
farm_client.log.delete('observation', log_id)
81+
```
82+
83+
## Next steps
84+
85+
Now that you know the basics, dive deeper into following topics:
86+
87+
- [Authorizing with farmOS server](authorization.md)
88+
- [Working with farmOS resources](client_2x.md)

0 commit comments

Comments
 (0)