Account¶
In order to modify information in the account, dashboard, bucket, device and any other settings, it is necessary to use the device functions.
To setup an account object, you need a token that you need to get in our admin website. Make sure to use tokens with the correct write/read previlegies for the current function that you want to use. For example, a token with only read previlegies can’t create, modify or delete anything from an account.
.info¶
Get all account information
import tago
my_account = tago.Account('MY_ACCOUNT_TOKEN')
account_info = my_account.info()
print(account_info)
.tokenList¶
Get all tokens from the account
import tago
my_account = tago.Account('MY_ACCOUNT_TOKEN')
result = my_account.profiles.tokenList('PROFILE ID HERE')
print(result)
.tokenCreate¶
Generate and retrieve a new token for the account
import tago
my_account = tago.Account('MY_ACCOUNT_TOKEN')
new_token = { 'name': 'My First Token',
'profile_id': 'PROFILE ID HERE',
'email': 'ACCOUNT EMAIL HERE',
'password': 'ACCOUNT PASSWORD HERE',
'expire_time': '1 day' }
result = my_account.tokenCreate(new_token)
print(result)
.tokenDelete¶
Delete current token of the account
import tago
my_account = tago.Account('MY_ACCOUNT_TOKEN')
result = my_account.profiles.tokenDelete('PROFILE ID HERE', 'PROFILE TOKEN HERE')
print(result)
Devices¶
Across the account function, it is possible to manage all your devices. Make sure that you use an account token with “write” permission when using functions to create, edit and delete. The Device method is completly different from the class Device, since this one can only manage devices, and can’t do anything with data related to the device.
.list¶
Retrieve a list with all devices from account
import tago
my_account = tago.Account('MY_ACCOUNT_TOKEN')
my_devices = my_account.devices.list()
print(my_devices)
.create¶
Generate and retrieve a new device for the account
import tago
my_account = tago.Account('MY_ACCOUNT_TOKEN')
new_device = {
'name': 'My First Device',
'description' : 'Creating my first device',
'active': True,
'visible': True,
'tags': [
{'key': 'Client', 'value': 'John'}
],
'configuration_params': [
{'sent': False, 'key': 'check_rate', 'value': 600},
{'sent': False, 'key': 'measure_time', 'value': 0}
]
}
result = my_account.devices.create(new_device)
print(result)
.edit¶
Modify any property of the device.
import tago
my_account = tago.Account('MY_ACCOUNT_TOKEN')
data = {
'name': 'New name for my device',
'description' : 'In this way I can change the description too',
'active': False,
'visible': True,
'tags': [
{'key': 'Client', 'value': 'Mark'}
]
}
result = my_account.devices.edit('DEVICE_ID', data)
print(result)
.info¶
Get information about the device
import tago
my_account = tago.Account('MY_ACCOUNT_TOKEN')
device_info = my_account.devices.info('DEVICE_ID')
print(device_info)
.delete¶
Delete device for the account
import tago
my_account = tago.Account('MY_ACCOUNT_TOKEN')
device_info = my_account.devices.delete('DEVICE_ID')
print(device_info)
.tokenList¶
Retrieve a list of all tokens of the device
import tago
my_account = tago.Account('MY_ACCOUNT_TOKEN')
device_token_list = my_account.devices.tokenList('DEVICE_ID')
print(device_token_list)
.tokenCreate¶
Generate and retrieve a new token for the device
import tago
my_account = tago.Account('MY_ACCOUNT_TOKEN')
new_token_data = {
'name': 'My First Token',
'expire_time': 'never',
'permission': 'full'
}
result = my_account.devices.tokenCreate('DEVICE_ID', new_token_data)
print(result)
.tokenDelete¶
Delete an token of the Device
import tago
my_account = tago.Account('MY_ACCOUNT_TOKEN')
result = my_account.devices.tokenDelete('TOKEN')
print(result)
Buckets¶
Across the account function, it is possible to manage all your buckets. Be sure to use an account token with “write” permissions when using functions like create, edit and delete.
.list¶
Retrieve a list with all buckets from account
import tago
my_account = tago.Account('MY_ACCOUNT_TOKEN')
my_buckets = my_account.buckets.list()
print(my_buckets)
.create¶
Generate and retrieve a new bucket for the account
import tago
my_account = tago.Account('MY_ACCOUNT_TOKEN')
new_bucket_data = {
'name':'My first bucket',
'description':'Creating my first bucket',
'visible': True,
'tags': [
{'key': 'client', 'value': 'Francisco'}
]
}
result = my_account.buckets.create(new_bucket_data)
print(result)
.edit¶
Modify any property of the bucket.
import tago
my_account = tago.Account('MY_ACCOUNT_TOKEN')
data = {
'name':'New name for my bucket',
'description':'This way I can change the description too',
'visible': True,
'tags': [
{'key': 'client', 'value': 'Leonard'}
]
}
result = my_account.buckets.edit('BUCKET_ID_HERE', data)
print(result)
.info¶
Get information about the bucket
import tago
my_account = tago.Account('MY_ACCOUNT_TOKEN')
result = my_account.buckets.info('BUCKET_ID_HERE')
print(result)
.delete¶
Delete bucket for the account
import tago
my_account = tago.Account('MY_ACCOUNT_TOKEN')
result = my_account.buckets.delete('BUCKET_ID_HERE')
print(result)
Actions¶
Across the account function, it is possible to manage all your actions. Be sure to use an account token with “write” permissions when using functions like create, edit and delete.
.list¶
Retrieve a list with all actions from account
import tago
my_account = tago.Account('MY_ACCOUNT_TOKEN')
my_actions = my_account.actions.list()
print(my_actions)
.create¶
Generate and retrieve a new action for the account
import tago
my_account = tago.Account('MY_ACCOUNT_TOKEN')
new_action_data = {
'name': 'a simple action',
'description': 'trigger when the variable test is higher than 2, and reset it when is less than 2',
'when_reset_bucket': '571920982c452fa00c6af660',
'when_reset_origin': '571920a5cc7d43a00c642ca1',
'when_reset_variable': 'test',
'when_reset_condition': '<',
'when_reset_value': '2',
'when_set_bucket': '571920982c452fa00c6af660',
'when_set_origin': '571920a5cc7d43a00c642ca1',
'when_set_variable': 'test',
'when_set_condition': '>',
'when_set_value': '2',
'type': 'script',
'script': '577d4c457ee399ef1a6e6cf6',
'lock': False,
'active': True,
'tags': [
{'key':'Trigger', 'value':'2'}
]
}
result = my_account.actions.create(new_action_data)
print(result)
.edit¶
Modify any property of the action.
import tago
my_account = tago.Account('MY_ACCOUNT_TOKEN')
data = {
'name':'New name for my action',
'description':'In this way I can change the description too',
'visible': True,
'tags': [
{'key': 'client', 'value': 'Mark'}
]
}
result = my_account.actions.edit('ACTION_ID_HERE', data)
print(result)
.info¶
Get information about the action
import tago
my_account = tago.Account('MY_ACCOUNT_TOKEN')
action_info = my_account.actions.info('ACTION_ID_HERE')
print(action_info)
.delete¶
Delete action for the account
import tago
my_account = tago.Account('MY_ACCOUNT_TOKEN')
result = my_account.actions.delete('ACTION_ID_HERE')
print(result)
Analysis¶
Across the account function, it is possible to manage all your analysis. Be sure to use an account token with “write” permissions when using functions like create, edit and delete. The analysis method is completly different from the class analysis, since it only manages the analysis information and not the code that it runs.
.list¶
Retrieve a list with all analysis from account
import tago
my_account = tago.Account('MY_ACCOUNT_TOKEN')
my_analysis = my_account.analysis.list()
print(my_analysis)
.create¶
Generate and retrieve a new analysis for the account
import tago
my_account = tago.Account('MY_ACCOUNT_TOKEN')
new_analysis_data = {
'name':'My first analysis',
'description':'Creating my first analysis',
'active': True,
'interval': '1 minute',
'variables': [
{'key': 'max_battery', 'value': '3100'}
],
'tags': [
{'key': 'client', 'value': 'Mark'}
]
}
result = my_account.analysis.create(new_analysis_data)
print(result)
.edit¶
Modify any property of the analysis.
import tago
my_account = tago.Account('MY_ACCOUNT_TOKEN')
data = {
'name':'New name for my analysis',
'description':'In this way I can change the description too',
'active':False,
'interval': '2 minutes',
'variables': [
{'key': 'max_battery', 'value': '3000'}
],
'tags': [
{'key': 'client', 'value': 'Mark'}
]
}
result = my_account.analysis.create(data)
print(result)
.info¶
Get information about the analysis
import tago
my_account = tago.Account('MY_ACCOUNT_TOKEN')
analysis_info = my_account.analysis.info('ANALYSIS_ID_HERE')
print(analysis_info)
.delete¶
Delete analysis for the account
import tago
my_account = tago.Account('MY_ACCOUNT_TOKEN')
result = my_account.analysis.delete('ANALYSIS_ID_HERE')
print(result)
.run¶
Force Analysis to run immediately
import tago
my_account = tago.Account('MY_ACCOUNT_TOKEN')
# Your scope can be an array with several objects
scope = [
{
'variable': 'alarm',
'value:' 'On'
}
]
result = my_account.analysis.run('ANALYSIS_ID_HERE', scope)
print(result)
Dashboards¶
Across the account function, it is possible to manage all your dashboards. Be sure to use an account token with “write” permissions when using functions like create, edit and delete.
.list¶
Retrieve a list with all dashboards from account
import tago
my_account = tago.Account('MY_ACCOUNT_TOKEN')
my_dashboards = my_account.dashboards.list()
print(my_dashboards)
.create¶
Generate and retrieve a new dashboard for the account
import tago
my_account = tago.Account('MY_ACCOUNT_TOKEN')
new_dashboard_data = {
'label':'My first dashboard',
'arrangement': [
{'widget_id': 'WIDGET_ID_HERE', 'x': 0, 'y': 0, 'width': 2, 'height': 3}
],
'tags': [
{'key': 'client', 'value': 'Mark'}
]
}
result = my_account.dashboards.create(new_dashboard_data)
print(result)
.edit¶
Modify any property of the dashboards.
import tago
my_account = tago.Account('MY_ACCOUNT_TOKEN')
data = {
'label':'New name for my dashboard',
}
result = my_account.dashboards.edit('DASHBOARD_ID_HERE', data)
print(result)
.info¶
Get information about the dashboards
import tago
my_account = tago.Account('MY_ACCOUNT_TOKEN')
dashboard_info = my_account.dashboards.info('DASHBOARD_ID_HERE')
print(dashboard_info)
.delete¶
Delete dashboards for the account
import tago
my_account = tago.Account('MY_ACCOUNT_TOKEN')
result = my_account.dashboards.delete('DASHBOARD_ID_HERE')
print(result)
Widgets¶
Inside dashboards, you need widgets to show and control information inside buckets. Every widget have their data slighty different from each other, to know how do they work
.create¶
Generate and retrieve a new widget for the dashboard
import tago
my_account = tago.Account('54d83222-6837-4e9e-8f2e-67de8fce5a8b')
new_widget = {
'label': 'My first widget',
'type': 'step_button',
'data': [{
'bucket': '5d02be12cac6da0026398ed2',
'origin': '5d02be12cac6da0026398ed1',
'timezone': 'America/Sao_Paulo',
'query': 'last_value',
'variables': ['humidity']
}]
}
result = my_account.dashboards.widgets.create('DASHBOARD_ID_HERE', new_widget)
print(result)
.edit¶
Modify any property of the widget.
import tago
account_dashboards = tago.Account('MY_ACCOUNT_TOKEN').dashboards
data = {
'label':'New name for my widget',
}
result = account_dashboards.widgets.edit('DASHBOARD_ID_HERE', 'WIDGET_ID_HERE', data)
print(result)
.info¶
Get information about the widget
import tago
account_dashboards = tago.Account('MY_ACCOUNT_TOKEN').dashboards
widget_info = account_dashboards.widgets.info('DASHBOARD_ID_HERE', 'WIDGET_ID_HERE')
print(widget_info)
.delete¶
Delete access widget for the dashboard
import tago
account_dashboards = tago.Account('MY_ACCOUNT_TOKEN').dashboards
result = account_dashboards.widgets.delete('DASHBOARD_ID_HERE', 'WIDGET_ID_HERE')
print(result)
notifications to myself¶
All accounts have an notification system, where you can see alerts of account limit and accept/refuse share of dashboards, profiles.
.list¶
Retrieve a list with all notifications from account
import tago
my_account = tago.Account('MY_ACCOUNT_TOKEN')
# Empty object as params retrive all notifications from account
params = {}
my_notifications = my_account.notifications.list(params)
print(my_notifications)
.markAsRead¶
Mark a notification as read/ignored.
import tago
my_account = tago.Account('54d83222-6837-4e9e-8f2e-67de8fce5a8b')
# Array of notifications ids, this array can have several notifications ids
notifications_ids_list = ['NOTIFICATION_ID_HERE', 'ANOTHER_NOTIFICATION_ID_HERE']
result = my_account.notifications.markAsRead(notifications_ids_list)
print(result)
.accept¶
Accept the notification if it has a condition.
import tago
my_account = tago.Account('54d83222-6837-4e9e-8f2e-67de8fce5a8b')
result = my_account.notifications.accept('NOTIFICATION_ID_HERE')
print(result)
.refuse¶
Refuse the notification if it has a condition.
import tago
my_account = tago.Account('54d83222-6837-4e9e-8f2e-67de8fce5a8b')
result = my_account.notifications.accept('NOTIFICATION_ID_HERE')
print(result)
TagoRun Users¶
You can manage your TagoRun and Run Users. In order to modify, add, delete or do anything else with the data inside Run. See more about Tago Run here.
To setup an device object, you need a account-token (that you need to get in our website). Be sure to use tokens with the correct write/read previlegies for the current function that you want to use. For example, a token with only read previlegies can’t create, modify or delete anything from a Run.
.info¶
Get all information from the run
import tago
my_account = tago.Account('54d83222-6837-4e9e-8f2e-67de8fce5a8b')
tago_run_info = my_account.run.info()
print(tago_run_info)
.listUsers¶
Retrieve a list with all users from Run
import tago
my_account = tago.Account('54d83222-6837-4e9e-8f2e-67de8fce5a8b')
tago_run_users = my_account.run.listUsers()
print(tago_run_users)
.getUserInfo¶
Get run user information
import tago
my_account = tago.Account('54d83222-6837-4e9e-8f2e-67de8fce5a8b')
run_user_info = my_account.run.getUserInfo('RUN_USER_ID_HERE')
print(run_user_info)
.userEdit¶
Modify any property of the Run User.
import tago
my_account = tago.Account('54d83222-6837-4e9e-8f2e-67de8fce5a8b')
data = {
'name':'New name for my Run User',
'tags': [
{'key': 'client', 'value': 'Mark'}
]
}
result = my_account.run.userEdit('RUN_USER_ID_HERE', data)
print(result)
.createUser¶
Create a new Run User.
import tago
my_account = tago.Account('54d83222-6837-4e9e-8f2e-67de8fce5a8b')
new_user = {
'name':'John Doe',
'email': 'jhon@doe.com',
'password': '123abc',
'tags': [
{'key': 'employee', 'value': 'Manager'}
],
'timezone': 'America/Sao_Paulo'
}
result = my_account.run.createUser(new_user)
print(result)
.deleteUser¶
Delete run user
import tago
my_account = tago.Account('54d83222-6837-4e9e-8f2e-67de8fce5a8b')
result = my_account.run.deleteUser('5d7adfb1f03154001bbd9d78')
print(result)
Notification to users¶
You can push notification messages directly to the users registered in your Run. See more about notification for users here.
.notificationList¶
Retrieve a list with all notifications for the Run user
import tago
my_account = tago.Account('54d83222-6837-4e9e-8f2e-67de8fce5a8b')
run_user_notifications_list = my_account.run.notificationList('RUN_USER_ID_HERE')
print(run_user_notifications_list)
.notificationEdit¶
Modify any property of the user push notification.
import tago
my_account = tago.Account('54d83222-6837-4e9e-8f2e-67de8fce5a8b')
data = {
'title': 'Temperature Alert',
'message': 'The temperature is too high'
'buttons': [{
'label': 'Go to device dashboard',
'url': 'https://admin.tago.io/dashboard/info/5d9c6e7945f7ab001b0a32c2',
'color': 'red',
# 'analysis': '5d9c6e7945f7ab001b0a32c2',
}],
}
result = my_account.run.notificationEdit('NOTIFICATION_ID_HERE', data)
print(result)
.notificationCreate¶
Create a new push notification for the user.
import tago
my_account = tago.Account('54d83222-6837-4e9e-8f2e-67de8fce5a8b')
data = {
'title': 'Temperature Alert',
'message': 'The temperature is too high',
'buttons': [{
'label': 'Go to device dashboard',
'url': 'https://admin.tago.io/dashboard/info/5d9c6e7945f7ab001b0a32c2',
'color': 'red',
# 'analysis': '5d9c6e7945f7ab001b0a32c2',
}],
}
result = my_account.run.notificationCreate('RUN_USER_ID_HERE', data)
print(result)
.notificationDelete¶
Delete push notifcation for the run user
import tago
my_account = tago.Account('54d83222-6837-4e9e-8f2e-67de8fce5a8b')
result = my_account.run.notificationDelete('NOTIFICATION_ID_HERE')
print(result)
Access Management¶
Access Management (AM) is a module that helps you securely grant access to certain resources in your account. You create Targets (users or things) and determine which type of Permissions for the resources they will have. See more about Access Management here.
.list¶
Retrieve a list with all access management from account.
import tago
my_account = tago.Account('54d83222-6837-4e9e-8f2e-67de8fce5a8b')
access_management_list = my_account.accessManagement.list()
print(access_management_list)
.create¶
Generate and retrieve a new access management for the account.
import tago
my_account = tago.Account('54d83222-6837-4e9e-8f2e-67de8fce5a8b')
user = {
'id': '576dc932415f403531fd2cf6',
'name': 'John Doe',
}
new_access_management = {
'name': 'Dashboards for the user {}'.format(user['id']),
'tags': [{ 'key': 'client_id', 'value': user['id'] }],
'targets': [
[
'run_user',
'id',
user['id'],
],
],
'permissions': [
{
'effect': 'allow',
'action': [
'access',
],
'resource': [
'dashboard',
'tag.key',
'client_id',
'tag.value',
user['id'],
],
},
],
}
result = my_account.accessManagement.create(new_access_management)
print(result)
.edit¶
Modify any property of the access management.
import tago
my_account = tago.Account('54d83222-6837-4e9e-8f2e-67de8fce5a8b')
data = {
'name': 'my new name of access management',
}
result = my_account.accessManagement.edit('ACCESS_MANAGEMENT_ID', data)
print(result)
.info¶
Get information about the access management
import tago
my_account = tago.Account('54d83222-6837-4e9e-8f2e-67de8fce5a8b')
access_management_info = my_account.accessManagement.info('5dc0b9ab9955dd0026247ce6')
print(access_management_info)
.delete¶
Delete access management for the account
import tago
my_account = tago.Account('54d83222-6837-4e9e-8f2e-67de8fce5a8b')
result = my_account.accessManagement.delete('5dc0b9ab9955dd0026247ce6')
print(result)