Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NOISSUE - Test and Enhance Py SDK #42

Merged
merged 31 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Musilah marked this conversation as resolved.
Show resolved Hide resolved
- <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
Loading