diff --git a/.github/workflows/python-testing.yml b/.github/workflows/python-testing.yml
index 30463e3..c0e1223 100644
--- a/.github/workflows/python-testing.yml
+++ b/.github/workflows/python-testing.yml
@@ -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
diff --git a/README.md b/README.md
index 05d9daa..1bfb126 100644
--- a/README.md
+++ b/README.md
@@ -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.
diff --git a/docs/README.md b/docs/README.md
index 00ece48..99543d5 100644
--- a/docs/README.md
+++ b/docs/README.md
@@ -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)
@@ -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
diff --git a/docs/boostrap.md b/docs/boostrap.md
index fa3f4a0..fc2fdcf 100644
--- a/docs/boostrap.md
+++ b/docs/boostrap.md
@@ -14,11 +14,23 @@
## class `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.
-
+**Attributes:**
+
+ - `url` (str): Mainflux Bootstrap API URL.
+ - `CONFIGS_ENDPOINT` (str): Configurations API endpoint.
+ - `BOOTSTRAP_ENDPOINT` (str): Bootstrap API endpoint.
+ - `WHITELIST_ENDPOINT` (str): Whitelist API endpoint.
+ - `BOOTSTRAP_CERTS_ENDPOINT` (str): Bootstrap certificates API endpoint.
+
+
+
+
### method `__init__`
@@ -26,16 +38,27 @@
__init__(url: str)
```
+Initializes Bootstrap with the provided URL.
+
+params: url (str): Mainflux Bootstrap API URL.
+
+**returns:**
+
+ - `Bootstrap`: Bootstrap object.
+**raises:**
+ None
+
+
---
-
+
### method `add`
@@ -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:**
+
+ - `mf_response `: response.Response.
+
+Usage:
+
+``` from mainflux import sdk```
+
+ - ` >>> mfsdk = sdk.SDK(bootstrap_url="http`: //localhost:9013")
+ >>> config = {
+
+ - ` ... "external_id"`: "123",
+
+ - ` ... "external_key"`: "456",
+
+ - ` ... "thing_id"`: "fdb1057c-2905-4f71-9a80-e0ce9191e667",
+
+ - ` ... "name"`: "thing_name"
+ ... }
+ >>> mf_resp = mfsdk.bootstrap.add(config, token)
+ >>> mf_resp
+
+
---
-
+
### method `bootstrap`
@@ -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:**
+
+ - `mf_resp `: response.Response - response object.
+
+Usage:
+
+``` from mainflux import sdk```
+
+ - ` >>> mfsdk = sdk.SDK(bootstrap_url="http`: //localhost:9013")
+ >>> external_id = "external_id"
+ >>> external_key = "external_key"
+ >>> mf_resp = mfsdk.bootstrap.bootstrap(external_id, external_key)
+ >>> mf_resp
+
+
---
-
+
### method `remove`
@@ -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:**
+
+ - `mf_response `: response.Response.
+
+Usage:
+
+``` from mainflux import sdk```
+
+ - ` >>> mfsdk = sdk.SDK(bootstrap_url="http`: //localhost:9013")
+ >>> config_id = "config_id"
+ >>> mf_resp = mfsdk.bootstrap.remove(config_id, token)
+ >>> mf_resp
+
+
---
-
+
### method `update`
@@ -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:**
+
+
+
+ - `mf_response `: response.Response.
+
+Usage:
+
+``` from mainflux import sdk```
+
+ - ` >>> mfsdk = sdk.SDK(bootstrap_url="http`: //localhost:9013")
+ >>> config = {
+
+ - ` ... "external_id"`: "123",
+
+ - ` ... "external_key"`: "456",
+
+ - ` ... "thing_id"`: "fdb1057c-2905-4f71-9a80-e0ce9191e667",
+
+ - ` ... "name"`: "thing_name"
+ ... }
+ >>> mf_resp = mfsdk.bootstrap.update(config, token)
+ >>> mf_resp
+
+
---
-
+
### method `update_certs`
@@ -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:**
+
+ - `mf_response `: response.Response.
+
+Usage:
+
+``` from mainflux import sdk```
+
+ - ` >>> mfsdk = sdk.SDK(bootstrap_url="http`: //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
+
+
---
-
+
### method `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:**
+
+ - `mf_resp `: response.Response - response object.
+
+Usage:
+
+``` from mainflux import sdk```
+
+ - ` >>> mfsdk = sdk.SDK(bootstrap_url="http`: //localhost:9013")
+ >>> thing_id = "thing_id"
+ >>> mf_resp = mfsdk.bootstrap.view(thing_id, token)
+ >>> mf_resp
+
+
---
-
+
### method `whitelist`
@@ -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:**
+
+ - `mf_response `: response.Response.
+
+Usage:
+
+``` from mainflux import sdk```
+
+ - ` >>> mfsdk = sdk.SDK(bootstrap_url="http`: //localhost:9013")
+ >>> config = {
+
+ - ` ... "external_id"`: "123",
+
+ - ` ... "external_key"`: "456",
+
+ - ` ... "thing_id"`: "fdb1057c-2905-4f71-9a80-e0ce9191e667",
+
+ - ` ... "name"`: "thing_name"
+ ... }
+ >>> mf_resp = mfsdk.bootstrap.whitelist(config, token)
+ >>> mf_resp
+
+
diff --git a/docs/certs.md b/docs/certs.md
index 73a21e1..c096cd4 100644
--- a/docs/certs.md
+++ b/docs/certs.md
@@ -14,11 +14,18 @@
## class `Certs`
+Mainflux Certificates API
+Certs is used to issue, view, and revoke certificates. It is used to issue certificates for things.
-
+**Args:**
+
+ - `url` (str): Mainflux Certificates API URL.
+ - `CERTS_ENDPOINT` (str): Certificates API endpoint.
+
+
### method `__init__`
@@ -26,30 +33,61 @@
__init__(url: str)
```
+Initializes Certs with the provided URL.
+
+
+**Args:**
+
+ - `url` (str): Mainflux Certificates API URL.
+**Returns:**
+
+ - `Certs`: Certs object.
+
---
-
+
### method `issue`
```python
-issue(thing_id: str, key_bits: int, key_type: str, valid: str, token: str)
+issue(thing_id: str, valid: str, token: str)
```
+Issues a certificate for a given thing ID.
+
+
+**Args:**
+
+ - `thing_id` (str): Thing ID.
+ - `valid` (str): Certificate validity period.
+ - `token` (str): Authorization token.
+**Returns:**
+
+ - `Response`: Mainflux response.
+
+Usage: ``` from mainflux import sdk```
+
+ - ` >>> mfsdk = sdk.SDK(certs_url="http`: //localhost:9019")
+ >>> thing_id = "thing_id"
+ >>> valid = "1h"
+ >>> mf_resp = mfsdk.certs.issue(thing_id, valid)
+ >>> mf_resp
+
+
---
-
+
### method `revoke`
@@ -57,21 +95,93 @@ issue(thing_id: str, key_bits: int, key_type: str, valid: str, token: str)
revoke(thing_id: str, token: str)
```
+Revokes a certificate for a given thing ID.
+
+Deletes a certificate for a given thing ID and valid token.
+params: thing_id (str): thing id token (str): valid authorization token used to delete the certificate
+**Returns:**
+
+ - `mf_resp `: response.Response - response object.
+
+Usage:
+
+``` from mainflux import sdk```
+
+ - ` >>> mfsdk = sdk.SDK(certs_url="http`: //localhost:9019")
+ >>> thing_id = "thing_id"
+ >>> mf_resp = mfsdk.certs.revoke(thing_id)
+ >>> mf_resp
+
+
---
-
+
-### method `view`
+### method `view_by_serial`
```python
-view(thing_id: str, token: str)
+view_by_serial(cert_id: str, token: str)
```
-Generates an access token when provided with proper credentials.
+Retrieves a certificate for a given cert ID.
+
+Provides a certificate for a given cert ID.
+
+Params:
+
+ cert_id (str): Certificate ID. token (str): Authorization token.
+
+
+
+**Returns:**
+
+ - `mf_resp `: response.Response - response object.
+
+Usage:
+
+``` from mainflux import sdk```
+
+ - ` >>> mfsdk = sdk.SDK(certs_url="http`: //localhost:9019")
+ >>> cert_id = "cert_id"
+ >>> mf_resp = mfsdk.certs.view_by_serial(cert_id)
+ >>> mf_resp
+
+
+---
+
+
+
+### method `view_by_thing`
+
+```python
+view_by_thing(thing_id: str, token: str)
+```
+
+Retrieves a list of certificates' serial IDs for a given thing ID.
+
+Provides a list of certificates' serial IDs for a given thing ID.
+
+Params: thing_id (str): Thing ID. token (str): Authorization token.
+
+
+
+**Returns:**
+
+ - `mf_resp `: response.Response - response object.
+
+Usage:
+
+``` from mainflux import sdk```
+
+ - ` >>> mfsdk = sdk.SDK(certs_url="http`: //localhost:9019")
+ >>> thing_id = "thing_id"
+ >>> mf_resp = mfsdk.certs.view_by_thing(thing_id)
+ >>> mf_resp
+
diff --git a/docs/channels.md b/docs/channels.md
index 0f30e84..85e66cf 100644
--- a/docs/channels.md
+++ b/docs/channels.md
@@ -14,11 +14,29 @@
## class `Channels`
+Channels class provides the abstraction of the Mainflux Channels API.
+Channels are used to connect things and users. They are used to send messages to things and receive messages from things. Channels API provides the following functionalities:
+ - create channel
+ - create multiple channels in a bulk
+ - get channel
+ - get all channels
+ - get all channels to which a specific thing is connected to
+ - update channel
+ - delete channel
+ - identify thing
-
+**Attributes:**
+
+ - `CHANNELS_ENDPOINT` (str): Channels API endpoint
+ - `THINGS_ENDPOINT` (str): Things API endpoint
+ - `IDENTIFY_ENDPOINT` (str): Identify API endpoint
+
+
+
+
### method `__init__`
@@ -26,16 +44,31 @@
__init__(url: str)
```
+Initializes Channels class with the provided url
+
+
+
+**Args:**
+
+ - `url` (str): Mainflux Channels API URL
+**returns:**
+
+ - `Channels`: Channels object initialized with the provided url.
+
+
+
+**raises:**
+ None
---
-
+
### method `create`
@@ -45,9 +78,32 @@ create(channel: dict, token: str)
Creates channel entity in the database
+Creates a new channel in the database when provided with a valid token.
+
+params: channel (dict): Channel entity to be created for example: { "name": "channel_name", "metadata": { "description": "channel_description" } } token (str): User's token
+
+
+
+**returns:**
+
+ - `Response`: Response object containing the response from the server
+
+Usage:
+
+``` from mainflux import sdk```
+
+ - ` >>> mfsdk = sdk.SDK(channels_url="http`: //localhost:9000")
+ >>> channel = {
+
+ - ` ... "name"`: "channel_name"
+ ... }
+ >>> mf_resp = mfsdk.channels.create(channel, token)
+ >>> mf_resp
+
+
---
-
+
### method `create_bulk`
@@ -55,23 +111,78 @@ Creates channel entity in the database
create_bulk(channels: list, token: str)
```
-Creates multiple channels in a bulk
+Creates multiple channels in bulk
+
+Creates multiple new channels when provided with channels information and a valid token.
+
+params: channels: list- Channel entities to be created for example: [ { "name": "channel_name", "metadata": { "description": "channel_description" } }, { "name": "channel_name", "metadata": { "description": "channel_description" } } ]
+
+ token (str): User's token
+
+
+
+**returns:**
+
+ - `Response`: Response object containing the response from the server
+
+Usage:
+
+``` from mainflux import sdk```
+
+ - ` >>> mfsdk = sdk.SDK(channels_url="http`: //localhost:9000")
+ >>> channels = [
+ ... {
+
+ - ` ... "name"`: "channel_name"
+ ... },
+ ... {
+
+ - ` ... "name"`: "channel_name"
+ ... }
+ ... ]
+ >>> mf_resp = mfsdk.channels.create_bulk(channels, token)
+ >>> mf_resp
+
---
-
+
-### method `delete`
+### method `disable`
```python
-delete(channel_id: str, token: str)
+disable(channel_id: str, token: str)
```
-Deletes a channel entity from database
+Deletes a channel entity from database.
+
+Deletes a channel entity from database when provided with a valid channel ID and token. The channel is not deleted from the database but is marked as disabled.
+
+params:
+
+ channel_id (str): Channel ID token (str): User's token
+
+
+
+**returns:**
+
+
+
+ - `mf_resp`: response.Response -response object
+
+Usage:
+
+``` from mainflux import sdk```
+
+ - ` >>> mfsdk = sdk.SDK(channels_url="http`: //localhost:9000")
+ >>> channel_id = "channel_id"
+ >>> mf_resp = mfsdk.channels.disable(channel_id, token)
+ >>> mf_resp
+
---
-
+
### method `get`
@@ -81,9 +192,29 @@ get(channel_id: str, token: str)
Gets a channel entity for a logged-in user
+Provides a channel entity when provided with a valid channel ID and token.
+
+params: channel_id (str): Channel ID token (str): User's token
+
+
+
+**returns:**
+
+ - `Response`: Response object
+
+Usage:
+
+``` from mainflux import sdk```
+
+ - ` >>> mfsdk = sdk.SDK(channels_url="http`: //localhost:9000")
+ >>> channel_id = "channel_id"
+ >>> mf_resp = mfsdk.channels.get(channel_id, token)
+ >>> mf_resp
+
+
---
-
+
### method `get_all`
@@ -93,9 +224,34 @@ get_all(query_params: dict, token: str)
Gets all channels from database
+Gets all channels from database when provided with a valid token..
+
+params: query_params (dict): Query parameters for example: { "offset": 0, "limit": 10 } token (str): User's token
+
+
+
+**returns:**
+
+ - `mf_resp`: response.Response -response object
+
+Usage:
+
+``` from mainflux import sdk```
+
+ - ` >>> mfsdk = sdk.SDK(channels_url="http`: //localhost:9000")
+ >>> query_params = {
+
+ - ` ... "offset"`: 0,
+
+ - ` ... "limit"`: 10
+ ... }
+ >>> mf_resp = mfsdk.channels.get_all(query_params, token)
+ >>> mf_resp
+
+
---
-
+
### method `get_by_thing`
@@ -103,11 +259,37 @@ Gets all channels from database
get_by_thing(thing_id: str, query_params: dict, token: str)
```
-Gets all channels to which a specific thing is connected to
+Gets all channels to which a specific thing is connected to.
+
+Provides a list of all the channels a thing is connected to when provided with a valid token and thing ID.
+
+params: thing_id (str): Thing ID query_params (dict): Query parameters for example: { "offset": 0, "limit": 10 } token (str): User's token
+
+
+
+**returns:**
+
+ - `mf_resp`: response.Response -response object
+
+Usage:
+
+``` from mainflux import sdk```
+
+ - ` >>> mfsdk = sdk.SDK(channels_url="http`: //localhost:9000")
+ >>> thing_id = "thing_id"
+ >>> query_params = {
+
+ - ` ... "offset"`: 0,
+
+ - ` ... "limit"`: 10
+ ... }
+ >>> mf_resp = mfsdk.channels.get_by_thing(thing_id, query_params, token)
+ >>> mf_resp
+
---
-
+
### method `identify_thing`
@@ -117,9 +299,29 @@ identify_thing(thing_key: str)
Validates thing's key and returns it's ID if key is valid
+Uses a thing_key or secret to validate a thing and provide its information.
+
+params: thing_key (str): Thing's key
+
+
+
+**returns:**
+
+ - `mf_resp`: response.Response -response object
+
+Usage:
+
+``` from mainflux import sdk ```
+
+ - ` >>> mfsdk = sdk.SDK(channels_url="http`: //localhost:9000")
+ >>> thing_key = "thing_key"
+ >>> mf_resp = mfsdk.channels.identify_thing(thing_key)
+ >>> mf_resp
+
+
---
-
+
### method `update`
@@ -129,6 +331,30 @@ update(channel_id: str, channel: dict, token: str)
Updates channel entity
+Updates a channel entity when provided with a valid channel ID, channel entity and token. The information that can be updated are channel's name and metadata.
+
+params: channel_id (str): Channel ID channel (dict): Channel entity to be updated for example: { "name": "channel_name", "metadata": { "description": "channel_description" } } token (str): User's token
+
+
+
+**returns:**
+
+ - `mf_resp`: response.Response -response object
+
+Usage:
+
+``` from mainflux import sdk```
+
+ - ` >>> mfsdk = sdk.SDK(channels_url="http`: //localhost:9000")
+ >>> channel_id = "channel_id"
+ >>> channel = {
+
+ - ` ... "name"`: "channel_name"
+ ... }
+ >>> mf_resp = mfsdk.channels.update(channel_id, channel, token)
+ >>> mf_resp
+
+
diff --git a/docs/errors.md b/docs/errors.md
index 6a1bf99..b981d57 100644
--- a/docs/errors.md
+++ b/docs/errors.md
@@ -15,7 +15,7 @@
- **channels**
- **messages**
- **groups**
-- **boostrap**
+- **bootstrap**
- **certs**
---
diff --git a/docs/groups.md b/docs/groups.md
index 7474a36..f80db33 100644
--- a/docs/groups.md
+++ b/docs/groups.md
@@ -11,14 +11,21 @@
---
-
+
## class `Groups`
+Groups class provides the abstraction of the Mainflux groups service API.
+Groups class provides the following functionality: create, get, get_all, parents, children, update, members, memberships, assign, unassign, disable.
-
+**Attributes:**
+
+ - `URL`: Mainflux groups service URL.
+ - `GROUPS_ENDPOINT`: Mainflux groups service API endpoint.
+
+
### method `__init__`
@@ -35,19 +42,34 @@ __init__(url: str)
---
-
+
### method `assign`
```python
-assign(group_id: str, members_ids, member_type: str, token: str)
+assign(group_id: str, member_id: str, member_type: list, token: str)
```
Assign
+Assigns a member to a group when provided with group_id, member_id, member_type which is their action and a token.
+
+params: group_id: str - group id member_id: str - member id member_type: list - actions the member can perform for example: [ "m_read", "m_write", "m_admin" ] token: str - token used to assign a member to a group.
+
+
+
+**returns:**
+
+ - `mf_resp`: "Policy created"
+
+Usage:
+```
+
+ >>> from mainflux import sdk >>> mfsdk = sdk.SDK(users_url="http://localhost:9002") >>> group_id = "group_id" >>> member_id = "member_id" >>> member_type = [ ... "m_read", "m_write", "m_admin" ... ] >>> mf_resp = mfsdk.groups.assign(group_id, member_id, member_type) >>> mf_resp
+
---
-
+
### method `children`
@@ -57,9 +79,24 @@ children(group_id: str, query_params: dict, token: str)
Gets children for a specific group from database
+Provides information about children for a specific group from database when provided with group_id, query_params and token.
+
+params: group_id: str - group id of the parent group in question. query_params: dict - query parameters for example: { "offset": 0, "limit": 10, } where offset is the number of items to skip before starting to collect the result set and limit is the numbers of items to return. token: str - token used to get children for a specific group.
+
+
+
+**returns:**
+
+ - `mf_resp`: response.Response - response object
+
+Usage:
+```
+
+ >>> from mainflux import sdk >>> mfsdk = sdk.SDK(users_url="http://localhost:9002") >>> group_id = "group_id" >>> query_params = { ... "offset": 0, ... "limit": 10, ... } >>> mf_resp = mfsdk.groups.children(group_id, query_params) >>> mf_resp
+
---
-
+
### method `create`
@@ -67,23 +104,51 @@ Gets children for a specific group from database
create(group: dict, token: str)
```
-Creates group entity in the database
+Creates a group entity in the database.
+
+Creates a group entity in the database using the provided group object and token.
+
+params: group: dict - group information for example: { "name": "groupName", } token: str - token used to create a new group.
+
+
+
+**returns:**
+
+ - `mf_resp`: response.Response - response object
+
+Usage:
+```
+
+ >>> from mainflux import sdk >>> mfsdk = sdk.SDK(users_url="http://localhost:9002") >>> group = { ... "name": "groupName", ... } >>> mf_resp = mfsdk.groups.create(group) >>> mf_resp
---
-
+
-### method `delete`
+### method `disable`
```python
-delete(group_id: str, token: str)
+disable(group_id: str, user_token: str)
```
-Deletes a group entity from database
+Disables a group entity from database
+
+Deletes a group from the database when provided with group_id and user_token.
+
+params: group_id: str - group id user_token: str - token used to delete a group.
+
+
+
+**returns:**
+
+ - `mf_resp`: response.Response - response object
+
+Usage:
+``` >>> from mainflux import sdk >>> mfsdk = sdk.SDK(users_url="http://localhost:9002") >>> group_id = "group_id" >>> mf_resp = mfsdk.groups.disable(group_id) >>> mf_resp
---
-
+
### method `get`
@@ -93,9 +158,24 @@ get(group_id: str, token: str)
Gets a group entity
+Provides information about a group entity using the provided group_id and a token.
+
+params: group_id: str - group id token: str - token used to get a group.
+
+
+
+**returns:**
+
+ - `mf_resp`: response.Response - response object
+
+Usage:
+```
+
+ >>> from mainflux import sdk >>> mfsdk = sdk.SDK(users_url="http://localhost:9002") >>> group_id = "group_id" >>> mf_resp = mfsdk.groups.get(group_id) >>> mf_resp
+
---
-
+
### method `get_all`
@@ -105,9 +185,24 @@ get_all(query_params: dict, token: str)
Gets all groups from database
+Gets all groups from database using the provided query_params and token.
+
+params: query_params: dict - query parameters for example: { "offset": 0, "limit": 10, } where offset is the number of items to skip before starting to collect the result set and limit is the numbers of items to return. token: str - token used to get all groups.
+
+
+
+**returns:**
+
+ - `mf_resp`: response.Response - response object
+
+Usage:
+```
+
+ >>> from mainflux import sdk >>> mfsdk = sdk.SDK(users_url="http://localhost:9002") >>> query_params = { ... "offset": 0, ... "limit": 10, ... } >>> mf_resp = mfsdk.groups.get_all(query_params) >>> mf_resp
+
---
-
+
### method `members`
@@ -115,11 +210,26 @@ Gets all groups from database
members(group_id: str, query_params: dict, token: str)
```
-Get list of members ID's from group
+Gets members associated with the group specified by id
+
+Provides information about members associated with the group specified by id when provided with group_id, query_params and token.
+
+params: group_id: str - group id query_params: dict - query parameters for example: { "offset": 0, "limit": 10, } where offset is the number of items to skip before starting to collect the result set and limit is the numbers of items to return. token: str - token used to get members associated with the group specified by id.
+
+
+
+**returns:**
+
+ - `mf_resp`: response.Response - response object
+
+Usage:
+```
+
+ >>> from mainflux import sdk >>> mfsdk = sdk.SDK(users_url="http://localhost:9002") >>> group_id = "group_id" >>> query_params = { ... "offset": 0, ... "limit": 10, ... } >>> mf_resp = mfsdk.groups.members(group_id, query_params) >>> mf_resp
---
-
+
### method `memberships`
@@ -127,11 +237,24 @@ Get list of members ID's from group
memberships(member_id: str, query_params: dict, token: str)
```
-Get list of members ID's from group
+Retrieves a list of groups the user is connected to
+
+Retrieves a list of groups the user is connected to when provided with the users id, query_params and token.
+
+params: member_id: str - user id query_params: dict - query parameters for example: { "offset": 0, "limit": 10, } where offset is the number of items to skip before starting to collect the result set and limit is the numbers of items to return. token: str - token used to retrieve a list of groups the user is connected to.
+
+
+
+**returns:**
+
+ - `mf_resp`: response.Response - response object
+
+Usage:
+``` >>> from mainflux import sdk >>> mfsdk = sdk.SDK(users_url="http://localhost:9002") >>> member_id = "member_id" >>> query_params = { ... "offset": 0, ... "limit": 10, ... } >>> mf_resp = mfsdk.groups.memberships(member_id, query_params) >>> mf_resp
---
-
+
### method `parents`
@@ -141,21 +264,24 @@ parents(group_id: str, query_params: dict, token: str)
Gets parents for a specific group from database
----
+Provides information about parents for a specific group from database when provided with group_id, query_params and token.
-
+params: group_id: str - group id of the child group in question. query_params: dict - query parameters for example: { "offset": 0, "limit": 10, } where offset is the number of items to skip before starting to collect the result set and limit is the numbers of items to return. token: str - token used to get parents for a specific group.
-### method `share_groups`
-```python
-share_groups(token: str, user_group_id: str, thing_group_id: str)
-```
-Adds access rights on thing groups to the user group
+**returns:**
+
+ - `mf_resp`: response.Response - response object
+
+Usage:
+```
+
+ >>> from mainflux import sdk >>> mfsdk = sdk.SDK(users_url="http://localhost:9002") >>> group_id = "group_id" >>> query_params = { ... "offset": 0, ... "limit": 10, ... } >>> mf_resp = mfsdk.groups.parents(group_id, query_params) >>> mf_resp
---
-
+
### method `unassign`
@@ -163,11 +289,24 @@ Adds access rights on thing groups to the user group
unassign(group_id: str, token: str, members_ids)
```
-Assign
+Unassign
+
+Deletes a user's policy from over a group when provided with group_id, token and members_ids.
+
+params: group_id: str - group id token: str - token used to delete a user's policy from over a group. members_ids: str - member id
+
+
+
+**returns:**
+
+ - `mf_resp`: response.Response - response object
+
+Usage:
+``` >>> from mainflux import sdk >>> mfsdk = sdk.SDK(users_url="http://localhost:9002") >>> group_id = "group_id" >>> members_ids = "members_ids" >>> mf_resp = mfsdk.groups.unassign(group_id, members_ids) >>> mf_resp
---
-
+
### method `update`
@@ -177,6 +316,21 @@ update(group_id: str, group: dict, token: str)
Updates group entity
+Updates a group entity in the database using the provided group_id, group object and token. It updates the group name and metadata.
+
+params: group_id: str - group id group: dict - group information for example: { "name": "groupName", } token: str - token used to update a group.
+
+
+
+**returns:**
+
+
+
+ - `mf_resp`: response.Response - response object
+
+Usage:
+``` >>> from mainflux import sdk >>> mfsdk = sdk.SDK(users_url="http://localhost:9002") >>> group_id = "group_id" >>> group = { ... "name": "groupName", ... } >>> mf_resp = mfsdk.groups.update(group_id, group) >>> mf_resp
+
diff --git a/docs/keys.md b/docs/keys.md
deleted file mode 100644
index 666e350..0000000
--- a/docs/keys.md
+++ /dev/null
@@ -1,77 +0,0 @@
-
-
-
-
-# module `keys`
-
-
-
-
-
-
----
-
-
-
-## class `Keys`
-
-
-
-
-
-
-### method `__init__`
-
-```python
-__init__(url: str)
-```
-
-
-
-
-
-
-
-
----
-
-
-
-### method `get_key_details`
-
-```python
-get_key_details(key_id: str, token: str)
-```
-
-Gets API key details for the given key
-
----
-
-
-
-### method `issue`
-
-```python
-issue(duration: str, token: str)
-```
-
-Generates a new API key
-
----
-
-
-
-### method `revoke`
-
-```python
-revoke(key_id: str, token: str)
-```
-
-Revoke API key identified by the given ID.
-
-
-
-
----
-
-_This file was automatically generated via [lazydocs](https://github.com/ml-tooling/lazydocs)._
diff --git a/docs/messages.md b/docs/messages.md
index 607309f..b6403e8 100644
--- a/docs/messages.md
+++ b/docs/messages.md
@@ -14,11 +14,18 @@
## class `Messages`
+Messages API client
+Messages API client enables interaction with Mainflux Messages API. It provides methods for sending and reading messages.
-
+**Attributes:**
+
+ - `adapter_url`: URL of the Mainflux Messages adapter
+ - `reader_url`: URL of the Mainflux Messages reader
+
+
### method `__init__`
@@ -35,7 +42,7 @@ __init__(adapter_url: str, reader_url: str)
---
-
+
### method `read`
@@ -45,18 +52,61 @@ read(channel_id: str, token: str)
Reads messages from database for a given channel
+Reads message from a given channel via HTTP protocol. Message is read through a reader add-on such as timescale.
+
+params: channel_id: ID of the channel to read message from token: token of the user reading the message
+
+
+
+**returns:**
+
+ - `mf_resp`: response object
+
+usage:
+
+``` from mainflux import sdk```
+
+ - ` >>> mfsdk = sdk.Sdk("http`: //localhost:9011")
+ >>> channel_id = "2b86beba-83dd-4b39-8165-4dda4e6eb4ad"
+ >>> mf_resp = mfsdk.messages.read(channel_id, token)
+ >>> mf_resp
+
+
---
-
+
### method `send`
```python
-send(channel_id: str, msg: dict, thing_key: str)
+send(channel_id: str, msg: str, thing_key: str)
```
Sends message via HTTP protocol
+Sends message to a given channel via HTTP protocol. Message is sent through a writer add-on such as timescale. Message is sent to a http port specific to the writer add-on. The thing and channel must be created before sending the message and connected.
+
+params: channel_id: ID of the channel to send message to msg: message to send to the channel that should be in encoded into bytes format for example: [{"bn":"demo", "bu":"V", "n":"voltage", "u":"V", "v":5}] thing_key: secret of the thing sending the message
+
+
+
+**returns:**
+
+ - `mf_resp`: response object
+
+usage:
+
+``` from mainflux import sdk```
+
+ - ` >>> mfsdk = sdk.Sdk("http`: //localhost:9011")
+ >>> channel_id = "2b86beba-83dd-4b39-8165-4dda4e6eb4ad"
+
+ - ` >>> msg = '[{"bn"`: "demo", "bu":"V", "n":"voltage", "u":"V", "v":5}]'
+ >>> thing_key = "fc68b31b-d7fd-4879-b3a7-0baf4580c5b1"
+ >>> mf_resp = mfsdk.messages.send(channel_id, msg, thing_key)
+ >>> mf_resp
+
+
diff --git a/docs/sdk.md b/docs/sdk.md
index 04e26c7..6f3182f 100644
--- a/docs/sdk.md
+++ b/docs/sdk.md
@@ -14,14 +14,14 @@
---
-
+
## class `SDK`
-
+
### method `__init__`
@@ -33,7 +33,7 @@ __init__(
http_adapter_url='http://localhost',
certs_url='http://localhost',
bootstrap_url='http://localhost',
- auth_url='http://localhost'
+ groups_url='http://localhost'
)
```
@@ -46,7 +46,7 @@ __init__(
---
-
+
### method `version`
diff --git a/docs/things.md b/docs/things.md
index 2c2e712..0af7178 100644
--- a/docs/things.md
+++ b/docs/things.md
@@ -11,14 +11,21 @@
---
-
+
## class `Things`
+Things API client.
+Things API is used for creating and managing things. It is used for creating new things, creating multiple things getting thing information, updating thing information, disabling and enabling things ,and connecting and disconnecting things.
-
+**Attributes:**
+
+ - `URL`: str - URL of the Things API
+ - `THINGS_ENDPOINT`: str - Things API endpoint
+
+
### method `__init__`
@@ -35,31 +42,90 @@ __init__(url: str)
---
-
+
+
+### method `authorise_thing`
+
+```python
+authorise_thing(access_request: dict, token: str)
+```
+
+Authorises thing.
+
+Creates policies for a thing as a subject over a channel which is the object. It authorizes the thing to perform some actions over the channel.
+
+params:
+
+ access_request: dict - access request information for example: { "subject": "fd4f7da5-b7bf-49b7-bf2f-99995e78afd9", "object": "567f7da5-b7bf-49b7-bf2f-99995e78afd9", "actions": "m_write" "entity_type": "group" } token: str - token used for authorising thing
+
+
+
+**returns:**
+
+ - `mf_resp`: "True"
+
+Usage:
+```
+
+ >>> from mainflux import sdk >>> mfsdk = sdk.SDK(things_url="http://localhost:9000") >>> access_request = { ... "subject": "fd4f7da5-b7bf-49b7-bf2f-99995e78afd9", ... "object": "567f7da5-b7bf-49b7-bf2f-99995e78afd9", ... "actions": "m_write" ... "entity_type": "group" ... } >>> mf_resp = mfsdk.things.authorise_thing(access_request) >>> mf_resp
+
+---
+
+
### method `connect`
```python
-connect(thing_id: str, channel_id: str, token: str)
+connect(thing_id: str, channel_id: str, action: str, token: str)
```
-Connects thing and channel
+Connects thing and channel.
+
+Connects a thing and channel with provided thing ID as the subject, channel ID as the object, action that the thing can partake in and a valid token.
+
+params: thing_id: str - ID of the thing channel_id: str - ID of the channel action: str - action for example: "m_write" token: str - token used for connecting thing and channel
+
+
+
+**returns:**
+
+ - `mf_resp`: "connected"
+
+Usage:
+```
+
+ >>> from mainflux import sdk >>> mfsdk = sdk.SDK(things_url="http://localhost:9000") >>> thing_id = "fd4f7da5-b7bf-49b7-bf2f-99995e78afd9" >>> channel_id = "567f7da5-b7bf-49b7-bf2f-99995e78afd9" >>> action = "m_write" >>> mf_resp = mfsdk.things.connect(thing_id, channel_id, action) >>> mf_resp
---
-
+
### method `connects`
```python
-connects(thing_ids: list, channel_ids: list, token: str)
+connects(thing_ids: list, channel_ids: list, actions: list, token: str)
```
-Connects thing and channel
+Connects things and channels.
+
+Connects multiple things and channels with provided thing IDs as the subjects, channel IDs as the objects, actions that the thing can partake in and a valid token.
+
+params: thing_ids: list - list of thing IDs channel_ids: list - list of channel IDs actions: list - list of actions for example: ["m_write", "m_read"] token: str - token used for connecting things and channels
+
+
+
+**returns:**
+
+ - `mf_resp`: response.Response - response object.
+
+Usage:
+```
+
+ >>> from mainflux import sdk >>> mfsdk = sdk.SDK(things_url="http://localhost:9000") >>> thing_ids = ["fd4f7da5-b7bf-49b7-bf2f-99995e78afd9"] >>> channel_ids = ["567f7da5-b7bf-49b7-bf2f-99995e78afd9"] >>> actions = ["m_write", "m_read"] >>> mf_resp = mfsdk.things.connects(thing_ids, channel_ids, actions) >>> mf_resp
---
-
+
### method `create`
@@ -67,11 +133,24 @@ Connects thing and channel
create(thing: dict, token: str)
```
-Creates thing entity in the database
+Creates thing entity in the database.
+
+Creates a new thing with provided thing information. If token is provided, it will be used to create a new thing
+
+params: thing: dict - thing information for example: { "name": "thing1" } token: str - token used for creating a new thing
+
+
+
+**returns:**
+
+ - `mf_resp`: response.Response - response object
+
+Usage:
+``` >>> from mainflux import sdk >>> mfsdk = sdk.SDK(things_url="http://localhost:9000") >>> thing = { ... "name": "thing1", ... } >>> mf_resp = mfsdk.things.create(thing) >>> mf_resp
---
-
+
### method `create_bulk`
@@ -79,23 +158,49 @@ Creates thing entity in the database
create_bulk(things: list, token: str)
```
-Creates multiple things in a bulk
+Creates multiple things in bulk.
+
+Creates multiple new things with provided things information. If a token is provided, it will be used to create the new things.
+
+params: things: list - a list of things with theri information for example: [ {"name": "thing2"}, {"name": "thing3"}, {"name": "thing4"} ] token: str - token used for creating the new things.
+
+
+
+**returns:**
+
+ - `mf_resp`: response.Response - response object
+
+Usage:
+``` >>> from mainflux import sdk >>> mfsdk = sdk.SDK(things_url="http://localhost:9000") >>> things = [ ... {"name": "thing2"}, ... {"name": "thing3"}, ... {"name": "thing4"} ... ] >>> mf_resp = mfsdk.things.create_bulk(things) >>> mf_resp
---
-
+
-### method `delete`
+### method `disable`
```python
-delete(thing_id: str, token: str)
+disable(thing_id: str, token: str)
```
-Deletes a thing entity from database
+Deletes a thing entity from the database.
+
+Deletes a thing with provided thing ID and valid token.
+
+params: thing_id: str - ID of the thing token: str - token used for deleting thing
+
+
+
+**returns:**
+
+ - `mf_resp`: response.Response - response object.
+
+Usage:
+``` >>> from mainflux import sdk >>> mfsdk = sdk.SDK(things_url="http://localhost:9000") >>> thing_id = "fd4f7da5-b7bf-49b7-bf2f-99995e78afd9" >>> mf_resp = mfsdk.things.disable(thing_id) >>> mf_resp
---
-
+
### method `disconnect`
@@ -103,11 +208,26 @@ Deletes a thing entity from database
disconnect(thing_id: str, channel_id: str, token: str)
```
-Disconnect thing and channel
+Disconnects thing and channel.
+
+Disconnects a thing and channel with provided thing ID as the subject, channel ID as the object and a valid token.
+
+params: thing_id: str - ID of the thing channel_id: str - ID of the channel token: str - token used for disconnecting thing and channel
+
+
+
+**returns:**
+
+ - `mf_resp`: response.Response - response object.
+
+Usage:
+```
+
+ >>> from mainflux import sdk >>> mfsdk = sdk.SDK(things_url="http://localhost:9000") >>> thing_id = "fd4f7da5-b7bf-49b7-bf2f-99995e78afd9" >>> channel_id = "567f7da5-b7bf-49b7-bf2f-99995e78afd9" >>> mf_resp = mfsdk.things.disconnect(thing_id, channel_id) >>> mf_resp
---
-
+
### method `disconnects`
@@ -115,11 +235,26 @@ Disconnect thing and channel
disconnects(thing_ids: list, channel_ids: list, token: str)
```
-Disconnect thing and channel
+Disconnect things and channels.
+
+Disconnects multiple things and channels with provided thing IDs as the subjects, channel IDs as the objects and a valid token.
+
+params: thing_ids: list - list of thing IDs channel_ids: list - list of channel IDs token: str - token used for disconnecting things and channels
+
+
+
+**returns:**
+
+ - `mf_resp`: response.Response - response object.
+
+Usage:
+```
+
+ >>> from mainflux import sdk >>> mfsdk = sdk.SDK(things_url="http://localhost:9000") >>> thing_ids = ["fd4f7da5-b7bf-49b7-bf2f-99995e78afd9"] >>> channel_ids = ["567f7da5-b7bf-49b7-bf2f-99995e78afd9"] >>> mf_resp = mfsdk.things.disconnects(thing_ids, channel_ids) >>> mf_resp
---
-
+
### method `get`
@@ -127,11 +262,24 @@ Disconnect thing and channel
get(thing_id: str, token: str)
```
-Gets a thing entity for a logged-in user
+Gets a thing entity.
+
+Provides information about a thing with provided thing ID and token. Information about a thing is provided in a JSON format and includes the name its owner, secret,tags and status.
+
+params: thing_id: str - ID of the thing token: str - token used for getting thing information
+
+
+
+**returns:**
+
+ - `mf_resp`: response.Response - response object.
+
+Usage:
+``` >>> from mainflux import sdk >>> mfsdk = sdk.SDK(things_url="http://localhost:9000") >>> thing_id = "fd4f7da5-b7bf-49b7-bf2f-99995e78afd9" >>> mf_resp = mfsdk.things.get(thing_id) >>> mf_resp
---
-
+
### method `get_all`
@@ -139,11 +287,24 @@ Gets a thing entity for a logged-in user
get_all(query_params: dict, token: str)
```
-Gets all things from database
+Gets all things from database.
+
+Provides information about all things in a JSON format. It is controlled by a set of query parameters and a valid token.
+
+params: query_params: dict - query parameters for example: { "offset": 0, "limit": 10 } where offset is the number of things to skip and limit is the maximum token: str - token used for getting all things information
+
+
+
+**returns:**
+
+ - `mf_resp`: response.Response - response object.
+
+Usage:
+``` >>> from mainflux import sdk >>> mfsdk = sdk.SDK(things_url="http://localhost:9000") >>> query_params = { ... "offset": 0, ... "limit": 10 ... } >>> mf_resp = mfsdk.things.get_all(query_params) >>> mf_resp
---
-
+
### method `get_by_channel`
@@ -151,11 +312,47 @@ Gets all things from database
get_by_channel(channel_id: str, query_params: dict, token: str)
```
-Gets all things to which a specific thing is connected to
+Gets all things to which a specific thing is connected to.
+
+Provides a list of all things that are connected to a specific channel when given a channel ID and valid token.
+
+params: channel_id: str - ID of the channel query_params: dict - query parameters for example: { "offset": 0, "limit": 10 } where offset is the number of things to skip and limit is the maximum token: str - token used for getting all things information
+
+returns: mf_resp: response.Response - response object.
+
+Usage:
+``` >>> from mainflux import sdk >>> mfsdk = sdk.SDK(things_url="http://localhost:9000") >>> channel_id = "567f7da5-b7bf-49b7-bf2f-99995e78afd9" >>> query_params = { ... "offset": 0, ... "limit": 10 ... } >>> mf_resp = mfsdk.things.get_by_channel(channel_id, query_params) >>> mf_resp
+
+---
+
+
+
+### method `share_thing`
+
+```python
+share_thing(user_id: str, channel_id: str, actions: list, token: str)
+```
+
+Shares thing.
+
+Allows a logged in user to create new policies for a thing over a channel provided with a user ID, channel ID, actions that the thing can partake in and a valid token.
+
+params: user_id: str - ID of the user channel_id: str - ID of the channel actions: list - list of actions for example: ["m_write", "m_read"] token: str - token used for sharing thing
+
+
+
+**returns:**
+
+ - `mf_resp`: "OK"
+
+Usage:
+```
+
+ >>> from mainflux import sdk >>> mfsdk = sdk.SDK(things_url="http://localhost:9000") >>> user_id = "fd4f7da5-b7bf-49b7-bf2f-99995e78afd9" >>> channel_id = "567f7da5-b7bf-49b7-bf2f-99995e78afd9" >>> actions = ["m_write", "m_read"] >>> mf_resp = mfsdk.things.share_thing(user_id, channel_id, actions) >>> mf_resp
---
-
+
### method `update`
@@ -163,7 +360,101 @@ Gets all things to which a specific thing is connected to
update(thing_id: str, thing: dict, token: str)
```
-Updates thing entity
+Updates thing entity.
+
+Allows a logged in user to make changes and update a thing's information with provided thing ID and valid token. Information such as the metadata and name can be updated.
+
+params: thing_id: str - ID of the thing thing: dict - thing information for example: { "name": "thing1" } token: str - token used for updating thing information
+
+
+
+**returns:**
+
+ - `mf_resp`: response.Response - response object.
+
+Usage:
+``` >>> from mainflux import sdk >>> mfsdk = sdk.SDK(things_url="http://localhost:9000") >>> thing_id = "fd4f7da5-b7bf-49b7-bf2f-99995e78afd9" >>> thing = { ... "name": "thing2", ... } >>> mf_resp = mfsdk.things.update(thing_id, thing) >>> mf_resp
+
+---
+
+
+
+### method `update_thing_owner`
+
+```python
+update_thing_owner(thing_id: str, thing: dict, token: str)
+```
+
+Updates thing owner.
+
+Allows a logged in user to make changes and update a thing's information with provided thing ID and valid token. The thing owner can be updated.
+
+params: thing_id: str - ID of the thing thing: dict - thing information for example: { "owner": "user1" } token: str - token used for updating thing information
+
+
+
+**returns:**
+
+ - `mf_resp`: response.Response - response object.
+
+Usage:
+```
+
+ >>> from mainflux import sdk >>> mfsdk = sdk.SDK(things_url="http://localhost:9000") >>> thing_id = "fd4f7da5-b7bf-49b7-bf2f-99995e78afd9" >>> thing = { ... "owner": "user1" ... } >>> mf_resp = mfsdk.things.update_thing_owner(thing_id, thing) >>> mf_resp
+
+---
+
+
+
+### method `update_thing_secret`
+
+```python
+update_thing_secret(thing_id: str, thing: dict, token: str)
+```
+
+Updates thing secret.
+
+Allows a logged in user to make changes and update a thing's information with provided thing ID and valid token. The thing's secret can be updated.
+
+params: thing_id: str - ID of the thing thing: dict - thing information for example: { "key": "thing1" } token: str - token used for updating thing information
+
+
+
+**returns:**
+
+ - `mf_resp`: response.Response - response object.
+
+Usage:
+```
+
+ >>> from mainflux import sdk >>> mfsdk = sdk.SDK(things_url="http://localhost:9000") >>> thing_id = "fd4f7da5-b7bf-49b7-bf2f-99995e78afd9" >>> thing = { ... "key": "thing2", ... } >>> mf_resp = mfsdk.things.update_thing_secret(thing_id, thing) >>> mf_resp
+
+---
+
+
+
+### method `update_thing_tags`
+
+```python
+update_thing_tags(thing_id: str, thing: dict, token: str)
+```
+
+Updates thing tags.
+
+Allows a logged in user to make changes and update a thing's information with provided thing ID and valid token. The thing's tags can be updated.
+
+params: thing_id: str - ID of the thing thing: dict - thing information for example: { "tags": ["tag1", "tag2"] } token: str - token used for updating thing information
+
+
+
+**returns:**
+
+ - `mf_resp`: response.Response - response object.
+
+Usage:
+```
+
+ >>> from mainflux import sdk >>> mfsdk = sdk.SDK(things_url="http://localhost:9000") >>> thing_id = "fd4f7da5-b7bf-49b7-bf2f-99995e78afd9" >>> thing = { ... "tags": ["tag1", "tag2"] ... } >>> mf_resp = mfsdk.things.update_thing_tags(thing_id, thing) >>> mf_resp
diff --git a/docs/users.md b/docs/users.md
index 622c303..837aacd 100644
--- a/docs/users.md
+++ b/docs/users.md
@@ -14,11 +14,18 @@
## class `Users`
+Users API client.
+Users API is used for creating and managing users. It is used for creating new users, logging in, refreshing tokens, getting user information, updating user information, disabling and enabling users.
-
+**Attributes:**
+
+ - `URL`: str - URL of the Users API
+ - `USERS_ENDPOINT`: str - Users API endpoint
+
+
### method `__init__`
@@ -35,43 +42,105 @@ __init__(url: str)
---
-
+
+
+### method `authorise_user`
+
+```python
+authorise_user(access_request: dict, token: str)
+```
+
+Authorises user
+
+Creates policies for a user as a subject over a group which is the object. It authorizes the User to perform some actions over the group.
+
+params: access_request = { "subject": "", "object": "", "action": "", "entity_type": "" } token: strOnly admin can use this endpoint. Therefore, you need an authentication token for the admin. Also, only policies defined on the system are allowed to add.
+
+
+
+**returns:**
+
+ - `mf_resp`: "True"
+
+Usage:
+``` >>> from mainflux import sdk >>> mfsdk = sdk.SDK(users_url="http://localhost:9002") >>> access_request = { ... "subject": "", ... "object": "", ... "action": "", ... "entity_type": "" ... } >>> mf_resp = mfsdk.users.authorise_user(access_request, token) >>> mf_resp
+
+---
+
+
### method `create`
```python
-create(user: dict)
+create(user: dict, token: str = '')
```
-Registers new user account given email and password. New account will be uniquely identified by its email address.
+Creates a new user.
+
+Creates a new user with provided user information. If token is provided, it will be used to create a new user.
+
+params: user: dict - user information for example: { "name": "example", "credentials": { "identity": "example@main.com", "secret": "12345678" } } token: str - token used for creating a new user
+
+
+
+**returns:**
+
+ - `mf_resp`: response.Response - response object
+
+Usage:
+``` >>> from mainflux import sdk >>> mfsdk = sdk.SDK(users_url="http://localhost:9002") >>> user = { ... "name": "example", ... "credentials": { ... "identity": "example@mail.com", ... "secret": "12345678" ... } ... } >>> mf_resp = mfsdk.users.create(user) >>> mf_resp
---
-
+
### method `disable`
```python
-disable(user_id: str, admin_token: str)
+disable(user_id: str, user_token: str)
```
-Disables an enabled user account for a given user ID.
+Disables an enabled user account for a given user ID.
+
+params: user_id: str - the user's given ID. token: str - token used for enabling a user
+
+
+
+**returns:**
+
+ - `mf_resp`: response.Response - response object
+
+Usage:
+``` >>> from mainflux import sdk >>> mfsdk = sdk.SDK(users_url="http://localhost:9002") >>> user_id= "886b4266-77d1-4258-abae-2931fb4f16de" >>> mf_resp = mfsdk.users.disable(user_id, user_token) >>> mf_resp
---
-
+
### method `enable`
```python
-enable(user_id: str, admin_token: str)
+enable(user_id: str, user_token: str)
```
-Enables a disabled user account for a given user ID.
+Enables a disabled user account for a given user ID.
+
+Takes in the disabled User's ID and a valid token and enables the user.
+
+params: user_id: str - the user's given ID. token: str - token used for enabling a user
+
+
+
+**returns:**
+
+ - `mf_resp`: response.Response - response object
+
+Usage:
+``` >>> from mainflux import sdk >>> mfsdk = sdk.SDK(users_url="http://localhost:9002") >>> user_id= "886b4266-77d1-4258-abae-2931fb4f16de" >>> mf_resp = mfsdk.users.enable(user_id, user_token) >>> mf_resp
---
-
+
### method `get`
@@ -79,23 +148,51 @@ Enables a disabled user account for a given user ID.
get(user_id: str, token: str)
```
-Gets a user information
+Gets a user information.
+
+Gets info on currently logged in user. Info is obtained using authorization token and the user id.
+
+params: user_id: str - user information eg "886b4266-77d1-4258-abae-2931fb4f16de", token: str - token used for creating a new user
+
+
+
+**returns:**
+
+ - `mf_resp`: response.Response - response object
+
+Usage:
+``` >>> from mainflux import sdk >>> mfsdk = sdk.SDK(users_url="http://localhost:9002") >>> user_id = "886b4266-77d1-4258-abae-2931fb4f16de" >>> token = "" >>> mf_resp = mfsdk.users.get(user_id, token) >>> mf_resp
---
-
+
### method `get_all`
```python
-get_all(query_params: dict, admin_token: str)
+get_all(query_params: dict, user_token: str)
```
-Retrieves a list of users
+Retrieves a list of users.
+
+Gets a list of users from the database when provided with a user token and some parameters.
+
+params: user_token: str - token used for creating a new user query_params: dict - has a limit(int) which is the size of the subset to be expected and offset which is the number of items to skip during retrieval. For example: { "offset" : 0, "limit" : 10 }
+
+
+
+**returns:**
+
+ - `mf_resp`: response.Response - response object
+
+Usage:
+```
+
+ >>> from mainflux import sdk >>> mfsdk = sdk.SDK(users_url="http://localhost:9002") >>> query_params = { ... "offset" : 0, "limit" : 10 ... } >>> mf_resp = mfsdk.users.get(query_params, user_token) >>> mf_resp
---
-
+
### method `login`
@@ -105,9 +202,99 @@ login(user: dict)
Generates an access token when provided with proper credentials.
+Issues a new access and refresh token for a user for authenticating into the system.
+
+params: user: a dict with the user information and password for example: {"credentials":{ "identity": "user@mainflux.com", "secret": "12345678" } }
+
+**returns:**
+
+ - `mf_resp`: response.Response - response object
+
+Usage:
+```
+
+ >>> from mainflux import sdk >>> mfsdk = sdk.SDK(users_url="http://localhost:9002") >>> credentials= { ... "identity": "user@mainflux.com", ... "secret": "12345678" ... } >>> mf_resp = mfsdk.users.login(credentials) >>> mf_resp
+
+---
+
+
+
+### method `refresh_token`
+
+```python
+refresh_token(refresh_token: str)
+```
+
+Refreshes Access and Refresh Token used for authenticating into the system.
+
+Creates a new access token and refresh token for a user when provided with a valid refresh token.
+
+params: refresh_token: str - token used to refresh access.
+
+
+
+**returns:**
+
+ - `mf_resp`: response.Response - response object
+
+Usage:
+```
+
+ >>> from mainflux import sdk >>> mfsdk = sdk.SDK(users_url="http://localhost:9002") >>> mf_resp = mfsdk.users.refresh_token(refresh_token) >>> mf_resp
+
+---
+
+
+
+### method `reset_password`
+
+```python
+reset_password(password: str, confirm_password: str, token: str)
+```
+
+Changes user password with the reset_request token
+
+When user gets reset token, after he submitted email to /password/reset-request, posting a new password along to this endpoint will change password.
+
+params: passwor: str - the user's new password. confirm_password: str - a recurrence of the password to ensure it is the same. token: str - the reset token recieved from the reset_request email.
+
+
+
+**returns:**
+
+ - `mf_resp`: "OK"
+
+Usage:
+``` >>> from mainflux import sdk >>> mfsdk = sdk.SDK(users_url="http://localhost:9002") ... password = 234567 ... confirm_password = 234567 >>> mf_resp = mfsdk.users.reset_password(password, confirm_password, token) >>> mf_resp
+
---
-
+
+
+### method `reset_password_request`
+
+```python
+reset_password_request(email: str, url: str)
+```
+
+User Password reset request.
+
+Generates a reset token and sends an email to the user with link for resetting password.
+
+params: referrer email: str - this is the host being sent by the browser. The email must be valid preferably gmail and ensure that the email is already linked to a user as their identity in the database. The email is part of the header. url: str - http://localhost/reset-request
+
+
+
+**returns:**
+
+ - `mf_resp`: response.Response - response object
+
+Usage:
+``` >>> from mainflux import sdk >>> mfsdk = sdk.SDK(users_url="http://localhost:9002") ... email = admin@example.com ... url = stp@gmail.com >>> mf_resp = mfsdk.users.reset_password_request(email, url) >>> mf_resp
+
+---
+
+
### method `update`
@@ -115,19 +302,126 @@ Generates an access token when provided with proper credentials.
update(user: dict, user_token: str)
```
-Updates info on currently logged in user. Info is updated using authorization user_token
+Updates information on currently logged in user.
+
+Information such as name and metadata is updated using authorization user_token
+
+params: user: dict - user information for example: { "name": "example", "id": "886b4266-77d1-4258-abae-2931fb4f16de" "credentials": { "identity": "example@main.com", "secret": "12345678" }, "metadata": { "foo": "bar" } } token: str - token used for creating a new user
+
+
+
+**returns:**
+
+ - `mf_resp`: response.Response - response object
+
+Usage:
+``` >>> from mainflux import sdk >>> mfsdk = sdk.SDK(users_url="http://localhost:9002") >>> user = { ... "name": "example", ... "id": "886b4266-77d1-4258-abae-2931fb4f16de" ... "metadata": { ... "foo": "bar" ... } ... } >>> mf_resp = mfsdk.users.update(user, token) >>> mf_resp
---
-
+
### method `update_password`
```python
-update_password(old_password: str, password: str, user_token: str)
+update_password(old_secret: str, new_secret: str, user_token: str)
+```
+
+Changes user password.
+
+Updates secret of currently logged in user. Secret is updated using authorization token and the new received info.
+
+params: old_secret: str - the logged in user's current secret. new_secret: str - the user's new secret. token: str - token used for creating a new user
+
+
+
+**returns:**
+
+ - `mf_resp`: response.Response - response object
+
+Usage:
+``` >>> from mainflux import sdk >>> mfsdk = sdk.SDK(users_url="http://localhost:9002") ... old_secret = 12345678 ... new_secret = 87654321 >>> mf_resp = mfsdk.users.update(old_secret, new_secret, user_token) >>> mf_resp
+
+---
+
+
+
+### method `update_user_identity`
+
+```python
+update_user_identity(user: dict, user_token: str)
```
-Changes user password
+Updates identity information on currently logged in user.
+
+The user Identity is updated using authorization user_token
+
+params: user: dict - user information for example:
+
+ { "name": "example", "id": "886b4266-77d1-4258-abae-2931fb4f16de" "credentials": { "identity": "example@main.com", "secret": "12345678" }, "metadata": { "foo": "bar" } } token: str - token used for creating a new user
+
+
+
+**returns:**
+
+ - `mf_resp`: response.Response - response object
+
+Usage:
+``` >>> from mainflux import sdk >>> mfsdk = sdk.SDK(users_url="http://localhost:9002") >>> user = { ... "name": "example", ... "id": "886b4266-77d1-4258-abae-2931fb4f16de" ... "credentials": { ... "identity": "example@main.com", ... "secret": "12345678" ... }, ... "metadata": { ... "foo": "bar" ... } ... } >>> mf_resp = mfsdk.users.update_user_identity(user, user_token) >>> mf_resp
+
+---
+
+
+
+### method `update_user_owner`
+
+```python
+update_user_owner(user: dict, user_token: str)
+```
+
+Updates owner on currently logged in user.
+
+Updates owner for the user with provided ID. Owner is updated using authorization token and a new owner identifier received in request.
+
+params: user: dict - user information for example:
+
+ { "name": "example", "id": "886b4266-77d1-4258-abae-2931fb4f16de" "owner": "c52d-3b0d-43b9-8c3e-275c087d875af" } token: str - token used for creating a new user
+
+
+
+**returns:**
+
+ - `mf_resp`: response.Response - response object
+
+Usage:
+``` >>> from mainflux import sdk >>> mfsdk = sdk.SDK(users_url="http://localhost:9002") >>> user = { ... "name": "example", ... "id": "886b4266-77d1-4258-abae-2931fb4f16de", ... "owner": "c52d-3b0d-43b9-8c3e-275c087d875af" ... } >>> mf_resp = mfsdk.users.update_user_owner(user, user_token) >>> mf_resp
+
+---
+
+
+
+### method `update_user_tags`
+
+```python
+update_user_tags(user: dict, user_token: str)
+```
+
+Updates tags on currently logged in user.
+
+Updates tags of the user with provided ID. Tags is updated using authorization token and the new tags received in request.
+
+params: user: dict - user information for example:
+
+ { "name": "example", "id": "886b4266-77d1-4258-abae-2931fb4f16de" "tags": [ "back", "end" ] "metadata": { "foo": "bar" } } token: str - token used for creating a new user
+
+
+
+**returns:**
+
+ - `mf_resp`: response.Response - response object
+
+Usage:
+``` >>> from mainflux import sdk >>> mfsdk = sdk.SDK(users_url="http://localhost:9002") >>> user = { ... "name": "example", ... "id": "886b4266-77d1-4258-abae-2931fb4f16de" ... "tags": [ ... "back", ... "end" ... ] ... } >>> mf_resp = mfsdk.users.update_user_tags(user, user_token) >>> mf_resp
diff --git a/examples/examples.py b/examples/examples.py
index 19f2f24..f01e0d0 100644
--- a/examples/examples.py
+++ b/examples/examples.py
@@ -1,21 +1,35 @@
from mainflux import sdk
+import json
default_url = "http://localhost"
mfsdk = sdk.SDK(
users_url=default_url,
- things_url=default_url,
- reader_url=default_url + ":9204",
+ things_url=default_url + ":9000",
+ reader_url=default_url + ":9011",
http_adapter_url=default_url,
- certs_url=default_url + ":8204",
- bootstrap_url=default_url + ":8202",
- auth_url=default_url,
+ certs_url=default_url + ":9019",
+ bootstrap_url=default_url + ":9013"
)
+"""Repetitive values that can be easily fed into the example code"""
+
+email = "",
+password = "",
+user_id = "",
+token = "",
+refresh_token = "",
+thing_id = "",
+thing_id2 = "",
+channel_id = "",
+channel_id2 = "",
+group_id = "",
+
"""To start working with the Mainflux system,
you need to create a user account"""
mf_resp = mfsdk.users.create(
- user={"email": "", "password": ""}
+ user={"credentials": {"identity": "", "secret": password}},
+ token= token,
)
if mf_resp.error.status == 0:
print(mf_resp.value)
@@ -24,7 +38,17 @@
"""To log in to the Mainflux system, you need to create a user token"""
mf_resp = mfsdk.users.login(
- user={"email": "", "password": ""}
+ user={ "identity" : "", "secret": password}
+)
+if mf_resp.error.status == 0:
+ print(mf_resp.value)
+else:
+ print(mf_resp.error.message)
+
+"""Refreshes Access and Refresh Token used for authenticating into the system."""
+
+mf_resp = mfsdk.users.refresh_token(
+ refresh_token= refresh_token
)
if mf_resp.error.status == 0:
print(mf_resp.value)
@@ -33,57 +57,146 @@
"""You can always check the user entity that is logged in
by entering the user ID and token"""
-mf_resp = mfsdk.users.get(id="", token="")
+mf_resp = mfsdk.users.get(user_id= user_id, token= token)
if mf_resp.error.status == 0:
print(mf_resp.value)
else:
print(mf_resp.error.message)
-"""Updating user entities in the database"""
-mf_resp = mfsdk.users.update(
- user_token="", user={"metadata": {"foo": "bar"}}
-)
+"""Updates user entities in the database"""
+user = {
+ "id": user_id,
+ "name": "",
+ "metadata": {
+ "foo": "bar"
+ }
+}
+mf_resp = mfsdk.users.update(user_token= token, user=user)
if mf_resp.error.status == 0:
print(mf_resp.value)
else:
print(mf_resp.error.message)
-"""You can get all users in the database by calling the get_all () function"""
-mf_resp = mfsdk.users.get_all(
- query_params={"offset": 1, "limit": 5}, admin_token=""
-)
+"""Updates user identity in the database"""
+user = {
+ "credentials": {
+ "identity": "",
+ },
+ "id": user_id
+}
+mf_resp = mfsdk.users.update_user_identity(user_token= token, user=user)
if mf_resp.error.status == 0:
print(mf_resp.value)
else:
print(mf_resp.error.message)
-mf_resp = mfsdk.users.disable(user_id="", admin_token="")
+"""Updates user tags in the database"""
+user = {
+ "id": user_id,
+ "name": "",
+ "tags": [
+ "yellow",
+ "orange"
+ ]
+}
+mf_resp = mfsdk.users.update_user_tags(user_token= token, user=user)
if mf_resp.error.status == 0:
print(mf_resp.value)
else:
print(mf_resp.error.message)
+"""Updates user owner in the database"""
+user = {
+ "credentials": {
+ "identity": "",
+ "secret": password,
+ },
+ "id": user_id,
+ "owner": ""
+}
+mf_resp = mfsdk.users.update_user_owner(user_token= token, user=user)
+if mf_resp.error.status == 0:
+ print(mf_resp.value)
+else:
+ print(mf_resp.error.message)
+
+"""User Password reset request"""
+mf_resp = mfsdk.users.reset_password_request(email= email, url= "http://localhost/reset-request")
+if mf_resp.error.status == 0:
+ print(mf_resp.value)
+else:
+ print(mf_resp.error.message)
-mf_resp = mfsdk.users.enable(user_id="", admin_token="")
+"""User Password reset with the reset_request token"""
+mf_resp = mfsdk.users.reset_password(password="", confirm_password="", token= token)
+if mf_resp.error.status == 0:
+ print(mf_resp.value)
+else:
+ print(mf_resp.error.message)
+
+"""You can get all users in the database by calling the get_all () function"""
+mf_resp = mfsdk.users.get_all(
+ query_params={"offset": 0, "limit": 5},
+ user_token= token
+)
+if mf_resp.error.status == 0:
+ print(mf_resp.value)
+else:
+ print(mf_resp.error.message)
+
+"""Disables user"""
+mf_resp = mfsdk.users.disable(user_id= user_id, user_token= token)
+if mf_resp.error.status == 0:
+ print(mf_resp.value)
+else:
+ print(mf_resp.error.message)
+
+"""Enables user"""
+mf_resp = mfsdk.users.enable(user_id= user_id, user_token= token)
if mf_resp.error.status == 0:
print(mf_resp.value)
else:
print(mf_resp.error.message)
-"""Changing the user password can be done by calling
-the update password function"""
+"""Changing the user password can be done by calling the update password function"""
mf_resp = mfsdk.users.update_password(
- old_password="", password="",
- user_token=""
+ old_secret="", new_secret="",
+ user_token= token
)
if mf_resp.error.status == 0:
print(mf_resp.value)
else:
print(mf_resp.error.message)
+"""Authorising a User"""
+access_request = {
+ "subject": user_id,
+ "object": group_id,
+ "action": "",
+ "entity_type": ""
+}
+mf_resp = mfsdk.users.authorise_user(access_request=access_request, token= token)
+if mf_resp.error.status == 0:
+ print(mf_resp.value)
+else:
+ print(mf_resp.error.message)
+
+"""Authorising a Thing"""
+access_request = {
+ "subject": thing_id,
+ "object": channel_id,
+ "action": "",
+ "entity_type": ""
+}
+mf_resp = mfsdk.things.authorise_thing(access_request=access_request, token= token)
+if mf_resp.error.status == 0:
+ print(mf_resp.value)
+else:
+ print(mf_resp.error.message)
+
"""To create a thing, you need the thing name and a user token"""
mf_resp = mfsdk.things.create(
- thing={"name": ""}, token="")
+ thing={"name": ""}, token= token)
if mf_resp.error.status == 0:
print(mf_resp.value)
else:
@@ -92,8 +205,8 @@
"""You can create multiple things at once
by entering a series of things structures and a user token"""
mf_resp = mfsdk.things.create_bulk(
- things=[{"name": ""}, {"name": ""}],
- token="",
+ things=[{"name": ""}, {"name": ""}, {"name": ""}],
+ token= token,
)
if mf_resp.error.status == 0:
print(mf_resp.value)
@@ -101,7 +214,7 @@
print(mf_resp.error.message)
"""You can get thing information by entering the thing ID and user token"""
-mf_resp = mfsdk.things.get(token="", thing_id="")
+mf_resp = mfsdk.things.get(thing_id= thing_id, token= token)
if mf_resp.error.status == 0:
print(mf_resp.value)
else:
@@ -109,36 +222,74 @@
"""You can get all things in the database by calling the get_all () function"""
mf_resp = mfsdk.things.get_all(
- query_params={"offset": 1, "limit": 5}, token=""
+ query_params={"offset": 0, "limit": 5}, token= token
)
if mf_resp.error.status == 0:
print(mf_resp.value)
else:
print(mf_resp.error.message)
-"""Updating a thing entity in a database"""
+"""Updates a thing entity in a database"""
mf_resp = mfsdk.things.update(
- thing_id="", token="", thing={"name": ""}
+ thing_id=thing_id, token= token, thing={"name": ""}
)
if mf_resp.error.status == 0:
print(mf_resp.value)
else:
print(mf_resp.error.message)
+"""Updates a thing secret in a database"""
+mf_resp = mfsdk.things.update_thing_secret(
+ thing_id=thing_id, token= token, thing={"secret": password}
+)
+if mf_resp.error.status == 0:
+ print(mf_resp.value)
+else:
+ print(mf_resp.error.message)
-"You can get all thing connected to channel"
+"""Updates a thing's tags in a database"""
+thing= {
+ "id": thing_id,
+ "name": "",
+ "tags": [
+ "dev","back"
+ ]
+ }
+mf_resp = mfsdk.things.update_thing_tags(
+ thing_id=thing_id, token= token, thing=thing
+)
+if mf_resp.error.status == 0:
+ print(mf_resp.value)
+else:
+ print(mf_resp.error.message)
+
+"""Updates a thing's owner"""
+thing= {
+ "id": thing_id,
+ "name": "",
+ "owner": "",
+}
+mf_resp = mfsdk.things.update_thing_owner(
+ thing_id=thing_id, token= token, thing=thing
+)
+if mf_resp.error.status == 0:
+ print(mf_resp.value)
+else:
+ print(mf_resp.error.message)
+
+"""You can get all thing connected to channel"""
mf_resp = mfsdk.things.get_by_channel(
- channel_id="",
+ channel_id=channel_id,
query_params={"offset": 1, "limit": 5},
- token="",
+ token=token,
)
if mf_resp.error.status == 0:
print(mf_resp.value)
else:
print(mf_resp.error.message)
-"""To delete a thing you need a thing ID and a user token"""
-mf_resp = mfsdk.things.delete(thing_id="", token="")
+"""To disable a thing you need a thing ID and a user token"""
+mf_resp = mfsdk.things.disable(thing_id=thing_id, token= token)
if mf_resp.error.status == 0:
print(mf_resp.value)
else:
@@ -146,7 +297,7 @@
"""Connect thing to channel"""
mf_resp = mfsdk.things.connect(
- channel_id="", thing_id="", token=""
+ channel_id=channel_id, thing_id=thing_id, action="", token= token
)
if mf_resp.error.status == 0:
print(mf_resp.value)
@@ -155,7 +306,7 @@
"""Disconnect thing from channel"""
mf_resp = mfsdk.things.disconnect(
- channel_id="", thing_id="", token=""
+ channel_id=channel_id, thing_id=thing_id, token= token
)
if mf_resp.error.status == 0:
print(mf_resp.value)
@@ -164,10 +315,12 @@
"""Connect things to channels"""
mf_resp = mfsdk.things.connects(
- channel_ids=["", ""],
- thing_ids=["", ""],
- token="",
+ thing_ids=[thing_id, thing_id2],
+ channel_ids=[channel_id, channel_id2],
+ actions="",
+ token= token,
)
+
if mf_resp.error.status == 0:
print(mf_resp.value)
else:
@@ -175,18 +328,30 @@
"""Disconnect things from channels"""
mf_resp = mfsdk.things.disconnects(
- channel_ids=["", ""],
- thing_ids=["", ""],
- token="",
+ thing_ids=[thing_id, thing_id2],
+ channel_ids=[channel_id, channel_id2],
+ token=token,
)
if mf_resp.error.status == 0:
print(mf_resp.value)
else:
print(mf_resp.error.message)
+"""Share thing"""
+mf_resp = mfsdk.things.share_thing(
+ channel_id= channel_id,
+ user_id= user_id,
+ actions= [""],
+ token= token,
+)
+if mf_resp.error.status == 0:
+ print(mf_resp.value)
+else:
+ print(mf_resp.error.message)
+
"""To create a channel, you need a channel and a token"""
mf_resp = mfsdk.channels.create(
- channel={"name": "channel_name"}, token="")
+ channel={"name": ""}, token= token)
if mf_resp.error.status == 0:
print(mf_resp.value)
else:
@@ -194,19 +359,19 @@
"""As with things, you can create multiple channels at once"""
mf_resp = mfsdk.channels.create_bulk(
- channels=[{"name": ""}, {"name": ""}],
- token="",
+ channels=[{"name": ""}, {"name": ""}],
+ token= token,
)
if mf_resp.error.status == 0:
print(mf_resp.value)
else:
print(mf_resp.error.message)
-
+
"""Update channel entities in the database"""
mf_resp = mfsdk.channels.update(
- channel_id="",
- token="",
- channel={"name": ""},
+ channel_id=channel_id,
+ token= token,
+ channel={"name": ""},
)
if mf_resp.error.status == 0:
print(mf_resp.value)
@@ -214,7 +379,7 @@
print(mf_resp.error.message)
"""You can get channel information by entering the channel ID and user token"""
-mf_resp = mfsdk.channels.get(token="", channel_id="")
+mf_resp = mfsdk.channels.get(token= token, channel_id=channel_id)
if mf_resp.error.status == 0:
print(mf_resp.value)
else:
@@ -223,7 +388,7 @@
"""You can get all channels in the database by calling the get_all ()
function"""
mf_resp = mfsdk.channels.get_all(
- query_params={"offset": 1, "limit": 5}, token=""
+ query_params={"offset": 0, "limit": 5}, token= token
)
if mf_resp.error.status == 0:
print(mf_resp.value)
@@ -232,8 +397,8 @@
"""A list of all the channels to which a given thing is connected"""
mf_resp = mfsdk.channels.get_by_thing(
- thing_id="", query_params={"offset": 1, "limit": 5},
- token=""
+ thing_id=thing_id, query_params={"offset": 0, "limit": 5},
+ token= token
)
if mf_resp.error.status == 0:
print(mf_resp.value)
@@ -241,15 +406,15 @@
print(mf_resp.error.message)
"""Identifies thing when given thing key"""
-mf_resp = mfsdk.channels.identify_thing(thing_key="")
+mf_resp = mfsdk.channels.identify_thing(thing_key="")
if mf_resp.error.status == 0:
print(mf_resp.value)
else:
print(mf_resp.error.message)
"""Delete channels from the database"""
-mf_resp = mfsdk.channels.delete(
- channel_id="", token="")
+mf_resp = mfsdk.channels.disable(
+ channel_id=channel_id, token= token)
if mf_resp.error.status == 0:
print(mf_resp.value)
else:
@@ -257,22 +422,29 @@
"""To create a group, you need the group name and a user token"""
mf_resp = mfsdk.groups.create(
- group={"name": "group_name"}, token="")
+ group={"name": "group_name"}, token= token)
if mf_resp.error.status == 0:
print(mf_resp.value)
else:
print(mf_resp.error.message)
"""You can get group information by entering the group ID and token"""
-mf_resp = mfsdk.groups.get(group_id="", token="")
+mf_resp = mfsdk.groups.get(group_id= group_id, token= token)
if mf_resp.error.status == 0:
print(mf_resp.value)
else:
print(mf_resp.error.message)
"""Group update"""
+group={
+ "id": group_id,
+ "name": "",
+ "metdata": {
+ "foo": "bar"
+ }
+ }
mf_resp = mfsdk.groups.update(
- group_id="", token="", group={""}
+ token= token, group= group, group_id="group_id"
)
if mf_resp.error.status == 0:
print(mf_resp.value)
@@ -281,19 +453,19 @@
"""You can get groups in the database by calling the get_all () function"""
mf_resp = mfsdk.groups.get_all(
- token="", query_params={"offset": 1, "limit": 5}
+ token= token, query_params={"offset": 0, "limit": 5}
)
if mf_resp.error.status == 0:
print(mf_resp.value)
else:
print(mf_resp.error.message)
-"""Assign user, thing or channel to a group"""
+"""Assign user to a group"""
mf_resp = mfsdk.groups.assign(
- group_id="",
- token="",
- members_ids=["" | "" | ""],
- member_type='<"users" | "things" | "channels">',
+ group_id=group_id,
+ token= token,
+ member_id="",
+ member_type=[""],
)
if mf_resp.error.status == 0:
print(mf_resp.value)
@@ -302,9 +474,9 @@
"""Unassign"""
mf_resp = mfsdk.groups.unassign(
- group_id="",
- token="",
- members_ids=["" | "" | ""],
+ group_id="