Skip to content

Commit

Permalink
NOISSUE - Test and Enhance Py SDK (#42)
Browse files Browse the repository at this point in the history
* Fix sdk-py

Signed-off-by: Musilah <[email protected]>

* Test user service

Signed-off-by: Musilah <[email protected]>

* Fix things, channels and groups

Signed-off-by: Musilah <[email protected]>

* Support latest OS version and 2 python versions

Signed-off-by: Musilah <[email protected]>

* Fix Tests

Signed-off-by: Musilah <[email protected]>

* Add Docs

Signed-off-by: Musilah <[email protected]>

* Fix Certs

Signed-off-by: Musilah <[email protected]>

* Add Certs Docs

Signed-off-by: Musilah <[email protected]>

* Update Bootstrap

Signed-off-by: Musilah <[email protected]>

* Update users and things

Signed-off-by: Musilah <[email protected]>

* Fix and Update examples.py

Signed-off-by: Musilah <[email protected]>

* Fix users and comment resolution

Signed-off-by: Musilah <[email protected]>

* Update docs

Signed-off-by: Musilah <[email protected]>

* Add tests for Groups and Comment Resolution

Signed-off-by: Musilah <[email protected]>

* Fixing failing Tests in Test_groups.py

Signed-off-by: Musilah <[email protected]>

* Comment resolution

Signed-off-by: Musilah <[email protected]>

* resolve comment

Signed-off-by: Musilah <[email protected]>

* update docstrings on users.py file

Signed-off-by: Musilah <[email protected]>

* add docstrings to things.py file

Signed-off-by: Musilah <[email protected]>

* fix things.py file

Signed-off-by: Musilah <[email protected]>

* remove auth_url

Signed-off-by: Musilah <[email protected]>

* fix users.py file and add groups.py docstrings

Signed-off-by: Musilah <[email protected]>

* update docstrings

Signed-off-by: Musilah <[email protected]>

* fix messages.py file

Signed-off-by: Musilah <[email protected]>

* comment resolution

Signed-off-by: Musilah <[email protected]>

* fix groups.md docs

Signed-off-by: Musilah <[email protected]>

* simplify examples

Signed-off-by: Musilah <[email protected]>

* add a few more variables

Signed-off-by: Musilah <[email protected]>

* fix examples.py

Signed-off-by: Musilah <[email protected]>

* attempt to fix Markdown

Signed-off-by: Musilah <[email protected]>

* regenerate docs

Signed-off-by: Musilah <[email protected]>

---------

Signed-off-by: Musilah <[email protected]>
Co-authored-by: Musilah <[email protected]>
  • Loading branch information
Musilah and Musilah authored Oct 27, 2023
1 parent 0902c1b commit 7c17220
Show file tree
Hide file tree
Showing 32 changed files with 4,690 additions and 846 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/python-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: [3.5, 3.6, 3.7, 3.8]
os: [windows-2022, windows-2019, ubuntu-18.04, ubuntu-20.04, macos-10.15, macos-11]
python-version: [3.7, 3.9]
os: [windows-2022, ubuntu-22.04, macos-11]
steps:
- name: Checkout code
uses: actions/checkout@v2
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ Official documentation for the SDK is hosted at [here](https://github.com/mainfl
```sh
pip install lazydocs requests
python3 setup.py install
lazydocs --src-base-url="https://github.com/mainflux/sdk-py/blob/main/" --overview-file="README.md" lib
lazydocs --src-base-url="https://github.com/mainflux/sdk-py/blob/main/" --overview-file="README.md" mainflux
```

Please note that lazydocs requires Python version 3.5 or higher.
Expand Down
16 changes: 7 additions & 9 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
- [`channels`](./channels.md#module-channels)
- [`errors`](./errors.md#module-errors)
- [`groups`](./groups.md#module-groups)
- [`keys`](./keys.md#module-keys)
- [`messages`](./messages.md#module-messages)
- [`response`](./response.md#module-response)
- [`sdk`](./sdk.md#module-sdk)
Expand All @@ -19,17 +18,16 @@

## Classes

- [`boostrap.Bootstrap`](./boostrap.md#class-bootstrap)
- [`certs.Certs`](./certs.md#class-certs)
- [`channels.Channels`](./channels.md#class-channels)
- [`groups.Groups`](./groups.md#class-groups)
- [`keys.Keys`](./keys.md#class-keys)
- [`messages.Messages`](./messages.md#class-messages)
- [`boostrap.Bootstrap`](./boostrap.md#class-bootstrap): Bootstrap service API client.
- [`certs.Certs`](./certs.md#class-certs): Mainflux Certificates API
- [`channels.Channels`](./channels.md#class-channels): Channels class provides the abstraction of the Mainflux Channels API.
- [`groups.Groups`](./groups.md#class-groups): Groups class provides the abstraction of the Mainflux groups service API.
- [`messages.Messages`](./messages.md#class-messages): Messages API client
- [`response.Error`](./response.md#class-error)
- [`response.Response`](./response.md#class-response)
- [`sdk.SDK`](./sdk.md#class-sdk)
- [`things.Things`](./things.md#class-things)
- [`users.Users`](./users.md#class-users)
- [`things.Things`](./things.md#class-things): Things API client.
- [`users.Users`](./users.md#class-users): Users API client.

## Functions

Expand Down
204 changes: 195 additions & 9 deletions docs/boostrap.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,28 +14,51 @@
<a href="https://github.com/mainflux/sdk-py/blob/main/mainflux/boostrap.py#L8"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

## <kbd>class</kbd> `Bootstrap`
Bootstrap service API client.

Bootstrap service is used to manage configurations for Mainflux Things. It provides services such as updating, viewing, removing and adding new configurations.



<a href="https://github.com/mainflux/sdk-py/blob/main/mainflux/boostrap.py#L14"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
**Attributes:**

- <b>`url`</b> (str): Mainflux Bootstrap API URL.
- <b>`CONFIGS_ENDPOINT`</b> (str): Configurations API endpoint.
- <b>`BOOTSTRAP_ENDPOINT`</b> (str): Bootstrap API endpoint.
- <b>`WHITELIST_ENDPOINT`</b> (str): Whitelist API endpoint.
- <b>`BOOTSTRAP_CERTS_ENDPOINT`</b> (str): Bootstrap certificates API endpoint.



<a href="https://github.com/mainflux/sdk-py/blob/main/mainflux/boostrap.py#L27"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `__init__`

```python
__init__(url: str)
```

Initializes Bootstrap with the provided URL.

params: url (str): Mainflux Bootstrap API URL.



**returns:**

- <b>`Bootstrap`</b>: Bootstrap object.



**raises:**
None




---

<a href="https://github.com/mainflux/sdk-py/blob/main/mainflux/boostrap.py#L17"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="https://github.com/mainflux/sdk-py/blob/main/mainflux/boostrap.py#L41"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `add`

Expand All @@ -45,9 +68,38 @@ add(config: dict, token: str)

Adds new config to the list of config owned by user identified using the provided access token.

Some of the key data needed include the external_key and external_id which must be specific to the thing provided with the thing_id. Mind that every configuration must have a specific thing_id.

params: config (dict): Configuration data for example: { "external_id": "123", "external_key": "456", "thing_id": "fdb1057c-2905-4f71-9a80-e0ce9191e667", "name": "thing_name" } token (str): Authorization token.



**returns:**

- <b>`mf_response `</b>: response.Response.

Usage:

``` from mainflux import sdk```

- <b>` >>> mfsdk = sdk.SDK(bootstrap_url="http`</b>: //localhost:9013")
>>> config = {
- <b>` ... "external_id"`</b>: "123",

- <b>` ... "external_key"`</b>: "456",

- <b>` ... "thing_id"`</b>: "fdb1057c-2905-4f71-9a80-e0ce9191e667",

- <b>` ... "name"`</b>: "thing_name"
... }
>>> mf_resp = mfsdk.bootstrap.add(config, token)
>>> mf_resp

---

<a href="https://github.com/mainflux/sdk-py/blob/main/mainflux/boostrap.py#L130"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="https://github.com/mainflux/sdk-py/blob/main/mainflux/boostrap.py#L300"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `bootstrap`

Expand All @@ -57,9 +109,28 @@ bootstrap(external_id: str, external_key: str)

Retrieves a configuration with given external ID and external key.

params: external_id (str): External ID. external_key (str): External key.



**returns:**

- <b>`mf_resp `</b>: response.Response - response object.

Usage:

``` from mainflux import sdk```

- <b>` >>> mfsdk = sdk.SDK(bootstrap_url="http`</b>: //localhost:9013")
>>> external_id = "external_id"
>>> external_key = "external_key"
>>> mf_resp = mfsdk.bootstrap.bootstrap(external_id, external_key)
>>> mf_resp

---

<a href="https://github.com/mainflux/sdk-py/blob/main/mainflux/boostrap.py#L114"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="https://github.com/mainflux/sdk-py/blob/main/mainflux/boostrap.py#L266"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `remove`

Expand All @@ -69,9 +140,27 @@ remove(config_id: str, token: str)

Removes a Config. In case of successful removal the service will ensure that the removed config is disconnected from all the Mainflux channels.

params: config_id (str): Configuration ID. token (str): Authorization token.



**returns:**

- <b>`mf_response `</b>: response.Response.

Usage:

``` from mainflux import sdk```

- <b>` >>> mfsdk = sdk.SDK(bootstrap_url="http`</b>: //localhost:9013")
>>> config_id = "config_id"
>>> mf_resp = mfsdk.bootstrap.remove(config_id, token)
>>> mf_resp

---

<a href="https://github.com/mainflux/sdk-py/blob/main/mainflux/boostrap.py#L72"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="https://github.com/mainflux/sdk-py/blob/main/mainflux/boostrap.py#L173"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `update`

Expand All @@ -81,9 +170,38 @@ update(config: dict, token: str)

Update is performed by replacing the current resource data with values provided in a request payload. Note that the owner, ID, external ID, external key, Mainflux Thing ID and key cannot be changed.

params: config (dict): Configuration data for example: { "external_id": "123", "external_key": "456", "thing_id": "fdb1057c-2905-4f71-9a80-e0ce9191e667", "name": "thing_name" } token (str): Authorization token.



**returns:**



- <b>`mf_response `</b>: response.Response.

Usage:

``` from mainflux import sdk```

- <b>` >>> mfsdk = sdk.SDK(bootstrap_url="http`</b>: //localhost:9013")
>>> config = {
- <b>` ... "external_id"`</b>: "123",

- <b>` ... "external_key"`</b>: "456",

- <b>` ... "thing_id"`</b>: "fdb1057c-2905-4f71-9a80-e0ce9191e667",

- <b>` ... "name"`</b>: "thing_name"
... }
>>> mf_resp = mfsdk.bootstrap.update(config, token)
>>> mf_resp

---

<a href="https://github.com/mainflux/sdk-py/blob/main/mainflux/boostrap.py#L93"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="https://github.com/mainflux/sdk-py/blob/main/mainflux/boostrap.py#L224"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `update_certs`

Expand All @@ -99,21 +217,62 @@ update_certs(

Update is performed by replacing the current certificate data with values provided in a request payload.

params: config_id (str): Configuration ID. client_cert (str): Client certificate. client_key (str): Client key. ca (str): CA certificate. token (str): Authorization token.



**returns:**

- <b>`mf_response `</b>: response.Response.

Usage:

``` from mainflux import sdk```

- <b>` >>> mfsdk = sdk.SDK(bootstrap_url="http`</b>: //localhost:9013")
>>> config_id = "config_id"
>>> client_cert = "client_cert"
>>> client_key = "client_key"
>>> ca = "ca"
>>> mf_resp = mfsdk.bootstrap.update_certs(config_id, client_cert, client_key, ca, token)
>>> mf_resp

---

<a href="https://github.com/mainflux/sdk-py/blob/main/mainflux/boostrap.py#L56"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="https://github.com/mainflux/sdk-py/blob/main/mainflux/boostrap.py#L139"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `view`

```python
view(config_id: str, token: str)
view(thing_id: str, token: str)
```

Retrieves a configuration with given config id

Provides a configuration with given config id.

params: thing_id (str): Thing ID. token (str): Authorization token.



**returns:**

- <b>`mf_resp `</b>: response.Response - response object.

Usage:

``` from mainflux import sdk```

- <b>` >>> mfsdk = sdk.SDK(bootstrap_url="http`</b>: //localhost:9013")
>>> thing_id = "thing_id"
>>> mf_resp = mfsdk.bootstrap.view(thing_id, token)
>>> mf_resp

---

<a href="https://github.com/mainflux/sdk-py/blob/main/mainflux/boostrap.py#L36"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>
<a href="https://github.com/mainflux/sdk-py/blob/main/mainflux/boostrap.py#L90"><img align="right" style="float:right;" src="https://img.shields.io/badge/-source-cccccc?style=flat-square"></a>

### <kbd>method</kbd> `whitelist`

Expand All @@ -123,6 +282,33 @@ whitelist(config: dict, token: str)

Updating state represents enabling/disabling Config, i.e.connecting and disconnecting corresponding Mainflux Thing to the list of Channels.

params: config (dict): Configuration data for example: { "external_id": "123", "external_key": "456", "thing_id": "fdb1057c-2905-4f71-9a80-e0ce9191e667", "name": "thing_name" } token (str): Authorization token.



**returns:**

- <b>`mf_response `</b>: response.Response.

Usage:

``` from mainflux import sdk```

- <b>` >>> mfsdk = sdk.SDK(bootstrap_url="http`</b>: //localhost:9013")
>>> config = {
- <b>` ... "external_id"`</b>: "123",

- <b>` ... "external_key"`</b>: "456",

- <b>` ... "thing_id"`</b>: "fdb1057c-2905-4f71-9a80-e0ce9191e667",

- <b>` ... "name"`</b>: "thing_name"
... }
>>> mf_resp = mfsdk.bootstrap.whitelist(config, token)
>>> mf_resp




Expand Down
Loading

0 comments on commit 7c17220

Please sign in to comment.