Skip to content

Commit 1ff65e9

Browse files
author
GH Action
committed
auto README.md generation
1 parent 3604e52 commit 1ff65e9

File tree

1 file changed

+47
-79
lines changed

1 file changed

+47
-79
lines changed

README.md

Lines changed: 47 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ Version](https://img.shields.io/pypi/pyversions/python-glinet)](https://pypi.org
77
[![Code
88
Cov](https://codecov.io/gh/tomtana/python-glinet/branch/main/graph/badge.svg?token=976L8ESH8K)](https://codecov.io/gh/tomtana/python-glinet)
99

10-
# python-glinet - A Python3 Client for GL.Inet Router
10+
python-glinet - A Python3 Client for GL.Inet Router
11+
===================================================
1112

1213
- **Python3 client providing full access to the GL.Inet Luci API.**
1314
- **Supported firmware versions: 4.0 onwards**
@@ -20,10 +21,7 @@ Cov](https://codecov.io/gh/tomtana/python-glinet/branch/main/graph/badge.svg?tok
2021

2122
![image](https://github.com/tomtana/python-glinet/raw/main/ressources/python_glinet_demo.gif)
2223

23-
::: note
24-
::: title
25-
Note
26-
:::
24+
**Note:**
2725

2826
- GL.Inet changed the api mechanism from REST to JSON-RPC with the
2927
introduction of the firmware 4.0. Therefore, older versions are not
@@ -35,19 +33,19 @@ Note
3533
updated.
3634
- The best way to navigate and explore the api is within an ipython
3735
shell. A wrapper for ipython and terminal is on the roadmap.
38-
:::
3936

40-
## Installation
37+
Installation
38+
------------
4139

4240
### PIP
4341

44-
``` sh
42+
``` {.sourceCode .sh}
4543
pip install python-glinet
4644
```
4745

4846
### From Repo
4947

50-
``` sh
48+
``` {.sourceCode .sh}
5149
#clone repository
5250
git clone https://github.com/tomtana/python-glinet.git
5351
cd python-glinet
@@ -59,13 +57,14 @@ virtual environment (see
5957
The pip parameter `-e` is optional, and gives you the possibility to
6058
edit the `python-glinet` module in the cloned folder.
6159

62-
``` sh
60+
``` {.sourceCode .sh}
6361
python3 -m venv venv
6462
source venv/bin/activate
6563
pip install -e .
6664
```
6765

68-
## Getting Started
66+
Getting Started
67+
---------------
6968

7069
The heart piece of `python-glinet` is the `GlInet` class. It is manages
7170
authentication, session and communication with the api. In case you
@@ -74,66 +73,54 @@ need to pass them as parameter (see the documentation of the
7473
[GlInet](https://tomtana.github.io/python-glinet/glinet.html) class for
7574
more details).
7675

77-
For browsing the api using the dynamically created api_client, it is
76+
For browsing the api using the dynamically created api\_client, it is
7877
assumed that the commands are executed in an ipython shell.
7978

80-
::: warning
81-
::: title
82-
Warning
83-
:::
79+
**Warning:**
8480

8581
Even though possible, it is strongly discouraged to pass the password as
8682
a parameter.
87-
:::
8883

89-
::: note
90-
::: title
91-
Note
92-
:::
84+
**Note:**
9385

9486
- The constructor is checking if a api description is already in the
9587
cache and will load it from the gl.inet online documentation if not.
9688
- Make sure you check and understand the default settings
97-
:::
9889

99-
``` python
90+
``` {.sourceCode .python}
10091
from pyglinet import GlInet
10192
glinet = GlInet()
10293
```
10394

10495
### Login
10596

106-
``` python
97+
``` {.sourceCode .python}
10798
glinet.login()
10899
```
109100

110-
::: note
111-
::: title
112-
Note
113-
:::
101+
**Note:**
114102

115103
- if no password is passed as parameter in the constructor, `login()`
116104
will try to load login data from persistence
117105
- if no success ask via prompt and persist settings
118106
- start background thread to keep connection alive
119-
:::
120107

121108
### API Access Via Dynamically Created Client
122109

123110
Make sure you are in an ipython shell and logged in. Then, generate the
124111
`api_client`.
125112

126-
``` python
113+
``` {.sourceCode .python}
127114
api_client = glinet.get_api_client()
128115
```
129116

130117
#### General
131118

132119
- The api structure is as follow:
133-
**client.\<functionial_group\>.\<method\>**
120+
**client.\<functionial\_group\>.\<method\>**
134121
- Due to python naming rules for variables, all \"-\" are replaced
135122
with \"\_\" for the api method construction. **e.g. wg-client
136-
becomes wg_client.**
123+
becomes wg\_client.**
137124
- Use code completion and docstring to intuitively navigate the api
138125

139126
#### Functional Groups
@@ -142,10 +129,7 @@ Just call your client to see all available api function groups.
142129

143130
api_client
144131

145-
::: collapse
146-
Output
147-
148-
``` bash
132+
``` {.sourceCode .bash}
149133
Out[11]:
150134
Function
151135
------------------
@@ -193,21 +177,17 @@ wifi
193177
cloud
194178
cloud_batch_manage
195179
```
196-
:::
197180

198181
#### Methods
199182

200183
To explore the methods of a function group, just select it and hit
201184
enter.
202185

203-
``` python
186+
``` {.sourceCode .python}
204187
api_client.wg_client
205188
```
206189

207-
::: collapse
208-
Output
209-
210-
``` bash
190+
``` {.sourceCode .bash}
211191
Out[6]:
212192
Function
213193
--------------------
@@ -234,22 +214,18 @@ set_route
234214
get_route_list
235215
remove_route
236216
```
237-
:::
238217

239218
#### Parameters
240219

241220
Select your method and press enter. A list for all possible parameters
242221
are printed. If a parameter is prepended with `?`, it means it is
243222
optional.
244223

245-
``` python
224+
``` {.sourceCode .python}
246225
api_client.wg_client.set_config
247226
```
248227

249-
::: collapse
250-
Output
251-
252-
``` bash
228+
``` {.sourceCode .bash}
253229
Out[8]:
254230
Parameter Type Description
255231
--------------------- ------ ------------------
@@ -270,21 +246,17 @@ peer_id number 配置ID
270246
?persistent_keepalive number 节点保活
271247
?mtu number 节点的mtu
272248
```
273-
:::
274249

275250
#### Docstring
276251

277252
You can also show the docstring by appending a `?` to the method. It
278253
will show all the parameter and usage examples.
279254

280-
``` text
255+
``` {.sourceCode .text}
281256
api_client.wg_client.set_config?
282257
```
283258

284-
::: collapse
285-
Output
286-
287-
``` text
259+
``` {.sourceCode .text}
288260
Signature: api.wg_client.set_config(params=None)
289261
Type: GlInetApiCall
290262
File: ~/.local/lib/python3.10/site-packages/pyglinet/api_helper.py
@@ -315,7 +287,6 @@ Example request:
315287
Example response:
316288
{\"jsonrpc\": \"2.0\", \"id\": 1, \"result\": {}}
317289
```
318-
:::
319290

320291
#### Method call
321292

@@ -324,7 +295,7 @@ how parameters need to be passed.
324295

325296
api_client.wg_client.get_all_config_list()
326297

327-
``` bash
298+
``` {.sourceCode .bash}
328299
Out[12]: {'name': 'wg_client__get_all_config_list', 'config_list': [{'name': 'wg_client__get_all_config_list', 'username': '', 'group_name': 'AzireVPN', 'peers': [], 'password': '', 'auth_type': 1, 'group_id': 9690}]}
329300
```
330301

@@ -336,55 +307,52 @@ data.
336307

337308
### API Access Via Direct Request
338309

339-
Instead of using the dynamically created api_client, it is also possible
340-
to use the `GlInet` instance to make api requests. In fact, the
341-
api_client uses the `GlInet` session under the hood.
310+
Instead of using the dynamically created api\_client, it is also
311+
possible to use the `GlInet` instance to make api requests. In fact, the
312+
api\_client uses the `GlInet` session under the hood.
342313

343314
Once logged in, you simply can use the `glinet.request(method, params)`
344315
method to access or retrieve data from the api. Information about the
345316
method and the parameters can either be found in the
346317
[documentation](https://dev.gl-inet.cn/docs/api_docs_page) or via the
347-
api_client.
318+
api\_client.
348319

349320
e.g.
350321

351322
glinet.request("call", ["adguardhome", "get_config"])
352323

353-
``` bash
324+
``` {.sourceCode .bash}
354325
Out[12]: {'name': 'adguardhome__get_config', 'id': 13, 'jsonrpc': '2.0', 'result': {'name': 'adguardhome__get_config', 'enabled': False}}
355326
```
356327

357328
is equivalent to
358329

359330
api_client.adguardhome.get_config()
360331

361-
``` bash
332+
``` {.sourceCode .bash}
362333
Out[13]: {'name': 'adguardhome__get_config', 'enabled': False}
363334
```
364335

365-
::: note
366-
::: title
367-
Note
368-
:::
336+
**Note:**
369337

370338
The output of the `request` method returns the whole response body
371-
whereas the api_client just returns the result dict.
372-
:::
339+
whereas the api\_client just returns the result dict.
373340

374-
## Roadmap
341+
Roadmap
342+
-------
375343

376344
### V1.0.0
377345

378-
- [x] Add dynamically docstring for API calls
379-
- [x] Create pip compliant package
380-
- [x] Publish pip package
381-
- [x] Add tests
382-
- [x] Improve documentation
383-
- [x] Increase test coverage
384-
- [ ] replace crypt dependency to allow also Windows execution
385-
- [ ] Add wrapper for execution via terminal
346+
- Add dynamically docstring for API calls
347+
- Create pip compliant package
348+
- Publish pip package
349+
- Add tests
350+
- Improve documentation
351+
- Increase test coverage
352+
- replace crypt dependency to allow also Windows execution
353+
- Add wrapper for execution via terminal
386354

387355
### V2.0.0
388356

389-
- [ ] Add asyncio support
390-
- [ ] \...
357+
- Add asyncio support
358+
- \...

0 commit comments

Comments
 (0)