update grafana4 module/states documentation

and update a few grafana4_org functions names
This commit is contained in:
Bruno Binet 2016-12-16 16:15:39 +01:00
parent c75b6ef50b
commit d8e3ef2043
5 changed files with 738 additions and 12 deletions

View File

@ -4,9 +4,9 @@ Module for working with the Grafana v4 API
:depends: requests :depends: requests
:configuration: This module can be used by specifying the name of a :configuration: This module requires a configuration profile to be configured
configuration profile in the minion config, minion pillar, or master in the minion config, minion pillar, or master config.
config. The module will use the 'grafana' key by default, if defined.
For example: For example:
@ -61,6 +61,19 @@ def _get_auth(profile):
def get_users(profile='grafana'): def get_users(profile='grafana'):
'''
List all users.
profile
Configuration profile used to connect to the Grafana instance.
Default is 'grafana'.
CLI Example:
.. code-block:: bash
salt '*' grafana4.get_users
'''
if isinstance(profile, string_types): if isinstance(profile, string_types):
profile = __salt__['config.option'](profile) profile = __salt__['config.option'](profile)
response = requests.get( response = requests.get(
@ -75,6 +88,22 @@ def get_users(profile='grafana'):
def get_user(login, profile='grafana'): def get_user(login, profile='grafana'):
'''
Show a single user.
login
Login of the user.
profile
Configuration profile used to connect to the Grafana instance.
Default is 'grafana'.
CLI Example:
.. code-block:: bash
salt '*' grafana4.get_user <login>
'''
data = get_users(profile) data = get_users(profile)
for user in data: for user in data:
if user['login'] == login: if user['login'] == login:
@ -83,6 +112,22 @@ def get_user(login, profile='grafana'):
def get_user_data(userid, profile='grafana'): def get_user_data(userid, profile='grafana'):
'''
Get user data.
userid
Id of the user.
profile
Configuration profile used to connect to the Grafana instance.
Default is 'grafana'.
CLI Example:
.. code-block:: bash
salt '*' grafana4.get_user_data <user_id>
'''
if isinstance(profile, string_types): if isinstance(profile, string_types):
profile = __salt__['config.option'](profile) profile = __salt__['config.option'](profile)
response = requests.get( response = requests.get(
@ -97,6 +142,31 @@ def get_user_data(userid, profile='grafana'):
def create_user(profile='grafana', **kwargs): def create_user(profile='grafana', **kwargs):
'''
Create a new user.
login
Login of the new user.
password
Password of the new user.
email
Email of the new user.
name
Optional - Full name of the new user.
profile
Configuration profile used to connect to the Grafana instance.
Default is 'grafana'.
CLI Example:
.. code-block:: bash
salt '*' grafana4.create_user login=<login> password=<password> email=<email>
'''
if isinstance(profile, string_types): if isinstance(profile, string_types):
profile = __salt__['config.option'](profile) profile = __salt__['config.option'](profile)
response = requests.post( response = requests.post(
@ -112,6 +182,31 @@ def create_user(profile='grafana', **kwargs):
def update_user(userid, profile='grafana', **kwargs): def update_user(userid, profile='grafana', **kwargs):
'''
Update an existing user.
userid
Id of the user.
login
Optional - Login of the user.
email
Optional - Email of the user.
name
Optional - Full name of the user.
profile
Configuration profile used to connect to the Grafana instance.
Default is 'grafana'.
CLI Example:
.. code-block:: bash
salt '*' grafana4.update_user <user_id> login=<login> email=<email>
'''
if isinstance(profile, string_types): if isinstance(profile, string_types):
profile = __salt__['config.option'](profile) profile = __salt__['config.option'](profile)
response = requests.put( response = requests.put(
@ -127,6 +222,25 @@ def update_user(userid, profile='grafana', **kwargs):
def update_user_password(userid, profile='grafana', **kwargs): def update_user_password(userid, profile='grafana', **kwargs):
'''
Update a user password.
userid
Id of the user.
password
New password of the user.
profile
Configuration profile used to connect to the Grafana instance.
Default is 'grafana'.
CLI Example:
.. code-block:: bash
salt '*' grafana4.update_user_password <user_id> password=<password>
'''
if isinstance(profile, string_types): if isinstance(profile, string_types):
profile = __salt__['config.option'](profile) profile = __salt__['config.option'](profile)
response = requests.put( response = requests.put(
@ -143,6 +257,25 @@ def update_user_password(userid, profile='grafana', **kwargs):
def update_user_permissions(userid, profile='grafana', **kwargs): def update_user_permissions(userid, profile='grafana', **kwargs):
'''
Update a user password.
userid
Id of the user.
isGrafanaAdmin
Wether user is a Grafana admin.
profile
Configuration profile used to connect to the Grafana instance.
Default is 'grafana'.
CLI Example:
.. code-block:: bash
salt '*' grafana4.update_user_permissions <user_id> isGrafanaAdmin=<true|false>
'''
if isinstance(profile, string_types): if isinstance(profile, string_types):
profile = __salt__['config.option'](profile) profile = __salt__['config.option'](profile)
response = requests.put( response = requests.put(
@ -159,6 +292,22 @@ def update_user_permissions(userid, profile='grafana', **kwargs):
def delete_user(userid, profile='grafana'): def delete_user(userid, profile='grafana'):
'''
Delete a user.
userid
Id of the user.
profile
Configuration profile used to connect to the Grafana instance.
Default is 'grafana'.
CLI Example:
.. code-block:: bash
salt '*' grafana4.delete_user <user_id>
'''
if isinstance(profile, string_types): if isinstance(profile, string_types):
profile = __salt__['config.option'](profile) profile = __salt__['config.option'](profile)
response = requests.delete( response = requests.delete(
@ -173,6 +322,22 @@ def delete_user(userid, profile='grafana'):
def get_user_orgs(userid, profile='grafana'): def get_user_orgs(userid, profile='grafana'):
'''
Get the list of organisations a user belong to.
userid
Id of the user.
profile
Configuration profile used to connect to the Grafana instance.
Default is 'grafana'.
CLI Example:
.. code-block:: bash
salt '*' grafana4.get_user_orgs <user_id>
'''
if isinstance(profile, string_types): if isinstance(profile, string_types):
profile = __salt__['config.option'](profile) profile = __salt__['config.option'](profile)
response = requests.get( response = requests.get(
@ -187,6 +352,25 @@ def get_user_orgs(userid, profile='grafana'):
def delete_user_org(userid, orgid, profile='grafana'): def delete_user_org(userid, orgid, profile='grafana'):
'''
Remove a user from an organization.
userid
Id of the user.
orgid
Id of the organization.
profile
Configuration profile used to connect to the Grafana instance.
Default is 'grafana'.
CLI Example:
.. code-block:: bash
salt '*' grafana4.delete_user_org <user_id> <org_id>
'''
if isinstance(profile, string_types): if isinstance(profile, string_types):
profile = __salt__['config.option'](profile) profile = __salt__['config.option'](profile)
response = requests.delete( response = requests.delete(
@ -202,6 +386,19 @@ def delete_user_org(userid, orgid, profile='grafana'):
def get_orgs(profile='grafana'): def get_orgs(profile='grafana'):
'''
List all organizations.
profile
Configuration profile used to connect to the Grafana instance.
Default is 'grafana'.
CLI Example:
.. code-block:: bash
salt '*' grafana4.get_orgs
'''
if isinstance(profile, string_types): if isinstance(profile, string_types):
profile = __salt__['config.option'](profile) profile = __salt__['config.option'](profile)
response = requests.get( response = requests.get(
@ -216,6 +413,22 @@ def get_orgs(profile='grafana'):
def get_org(name, profile='grafana'): def get_org(name, profile='grafana'):
'''
Show a single organization.
name
Name of the organization.
profile
Configuration profile used to connect to the Grafana instance.
Default is 'grafana'.
CLI Example:
.. code-block:: bash
salt '*' grafana4.get_org <name>
'''
if isinstance(profile, string_types): if isinstance(profile, string_types):
profile = __salt__['config.option'](profile) profile = __salt__['config.option'](profile)
response = requests.get( response = requests.get(
@ -230,6 +443,22 @@ def get_org(name, profile='grafana'):
def switch_org(orgname, profile='grafana'): def switch_org(orgname, profile='grafana'):
'''
Switch the current organization.
name
Name of the organization to switch to.
profile
Configuration profile used to connect to the Grafana instance.
Default is 'grafana'.
CLI Example:
.. code-block:: bash
salt '*' grafana4.switch_org <name>
'''
if isinstance(profile, string_types): if isinstance(profile, string_types):
profile = __salt__['config.option'](profile) profile = __salt__['config.option'](profile)
org = get_org(orgname, profile) org = get_org(orgname, profile)
@ -245,6 +474,22 @@ def switch_org(orgname, profile='grafana'):
def get_org_users(orgname=None, profile='grafana'): def get_org_users(orgname=None, profile='grafana'):
'''
Get the list of users that belong to the organization.
orgname
Name of the organization.
profile
Configuration profile used to connect to the Grafana instance.
Default is 'grafana'.
CLI Example:
.. code-block:: bash
salt '*' grafana4.get_org_users <orgname>
'''
if isinstance(profile, string_types): if isinstance(profile, string_types):
profile = __salt__['config.option'](profile) profile = __salt__['config.option'](profile)
if orgname: if orgname:
@ -260,7 +505,33 @@ def get_org_users(orgname=None, profile='grafana'):
return response.json() return response.json()
def create_org_users(orgname=None, profile='grafana', **kwargs): def create_org_user(orgname=None, profile='grafana', **kwargs):
'''
Add user to the organization.
loginOrEmail
Login or email of the user.
role
Role of the user for this organization. Should be one of:
- Admin
- Editor
- Read Only Editor
- Viewer
orgname
Name of the organization in which users are added.
profile
Configuration profile used to connect to the Grafana instance.
Default is 'grafana'.
CLI Example:
.. code-block:: bash
salt '*' grafana4.create_org_user <orgname> loginOrEmail=<loginOrEmail> role=<role>
'''
if isinstance(profile, string_types): if isinstance(profile, string_types):
profile = __salt__['config.option'](profile) profile = __salt__['config.option'](profile)
if orgname: if orgname:
@ -277,7 +548,36 @@ def create_org_users(orgname=None, profile='grafana', **kwargs):
return response.json() return response.json()
def update_org_users(userid, orgname=None, profile='grafana', **kwargs): def update_org_user(userid, orgname=None, profile='grafana', **kwargs):
'''
Update user role in the organization.
userid
Id of the user.
loginOrEmail
Login or email of the user.
role
Role of the user for this organization. Should be one of:
- Admin
- Editor
- Read Only Editor
- Viewer
orgname
Name of the organization in which users are updated.
profile
Configuration profile used to connect to the Grafana instance.
Default is 'grafana'.
CLI Example:
.. code-block:: bash
salt '*' grafana4.update_org_user <user_id> <orgname> loginOrEmail=<loginOrEmail> role=<role>
'''
if isinstance(profile, string_types): if isinstance(profile, string_types):
profile = __salt__['config.option'](profile) profile = __salt__['config.option'](profile)
if orgname: if orgname:
@ -294,7 +594,26 @@ def update_org_users(userid, orgname=None, profile='grafana', **kwargs):
return response.json() return response.json()
def delete_org_users(userid, orgname=None, profile='grafana'): def delete_org_user(userid, orgname=None, profile='grafana'):
'''
Remove user from the organization.
userid
Id of the user.
orgname
Name of the organization in which users are updated.
profile
Configuration profile used to connect to the Grafana instance.
Default is 'grafana'.
CLI Example:
.. code-block:: bash
salt '*' grafana4.delete_org_user <user_id> <orgname>
'''
if isinstance(profile, string_types): if isinstance(profile, string_types):
profile = __salt__['config.option'](profile) profile = __salt__['config.option'](profile)
if orgname: if orgname:
@ -311,6 +630,22 @@ def delete_org_users(userid, orgname=None, profile='grafana'):
def get_org_address(orgname=None, profile='grafana'): def get_org_address(orgname=None, profile='grafana'):
'''
Get the organization address.
orgname
Name of the organization in which users are updated.
profile
Configuration profile used to connect to the Grafana instance.
Default is 'grafana'.
CLI Example:
.. code-block:: bash
salt '*' grafana4.get_org_address <orgname>
'''
if isinstance(profile, string_types): if isinstance(profile, string_types):
profile = __salt__['config.option'](profile) profile = __salt__['config.option'](profile)
if orgname: if orgname:
@ -327,6 +662,40 @@ def get_org_address(orgname=None, profile='grafana'):
def update_org_address(orgname=None, profile='grafana', **kwargs): def update_org_address(orgname=None, profile='grafana', **kwargs):
'''
Update the organization address.
orgname
Name of the organization in which users are updated.
address1
Optional - address1 of the org.
address2
Optional - address2 of the org.
city
Optional - city of the org.
zip_code
Optional - zip_code of the org.
state
Optional - state of the org.
country
Optional - country of the org.
profile
Configuration profile used to connect to the Grafana instance.
Default is 'grafana'.
CLI Example:
.. code-block:: bash
salt '*' grafana4.update_org_address <orgname> country=<country>
'''
if isinstance(profile, string_types): if isinstance(profile, string_types):
profile = __salt__['config.option'](profile) profile = __salt__['config.option'](profile)
if orgname: if orgname:
@ -344,6 +713,22 @@ def update_org_address(orgname=None, profile='grafana', **kwargs):
def get_org_prefs(orgname=None, profile='grafana'): def get_org_prefs(orgname=None, profile='grafana'):
'''
Get the organization preferences.
orgname
Name of the organization in which users are updated.
profile
Configuration profile used to connect to the Grafana instance.
Default is 'grafana'.
CLI Example:
.. code-block:: bash
salt '*' grafana4.get_org_prefs <orgname>
'''
if isinstance(profile, string_types): if isinstance(profile, string_types):
profile = __salt__['config.option'](profile) profile = __salt__['config.option'](profile)
if orgname: if orgname:
@ -360,6 +745,31 @@ def get_org_prefs(orgname=None, profile='grafana'):
def update_org_prefs(orgname=None, profile='grafana', **kwargs): def update_org_prefs(orgname=None, profile='grafana', **kwargs):
'''
Update the organization preferences.
orgname
Name of the organization in which users are updated.
theme
Selected theme for the org.
homeDashboardId
Home dashboard for the org.
timezone
Timezone for the org (one of: "browser", "utc", or "").
profile
Configuration profile used to connect to the Grafana instance.
Default is 'grafana'.
CLI Example:
.. code-block:: bash
salt '*' grafana4.update_org_prefs <orgname> theme=<theme> timezone=<timezone>
'''
if isinstance(profile, string_types): if isinstance(profile, string_types):
profile = __salt__['config.option'](profile) profile = __salt__['config.option'](profile)
if orgname: if orgname:
@ -377,6 +787,22 @@ def update_org_prefs(orgname=None, profile='grafana', **kwargs):
def create_org(profile='grafana', **kwargs): def create_org(profile='grafana', **kwargs):
'''
Create a new organization.
name
Name of the organization.
profile
Configuration profile used to connect to the Grafana instance.
Default is 'grafana'.
CLI Example:
.. code-block:: bash
salt '*' grafana4.create_org <name>
'''
if isinstance(profile, string_types): if isinstance(profile, string_types):
profile = __salt__['config.option'](profile) profile = __salt__['config.option'](profile)
response = requests.post( response = requests.post(
@ -392,6 +818,25 @@ def create_org(profile='grafana', **kwargs):
def update_org(orgid, profile='grafana', **kwargs): def update_org(orgid, profile='grafana', **kwargs):
'''
Update an existing organization.
orgid
Id of the organization.
name
New name of the organization.
profile
Configuration profile used to connect to the Grafana instance.
Default is 'grafana'.
CLI Example:
.. code-block:: bash
salt '*' grafana4.update_org <org_id> name=<name>
'''
if isinstance(profile, string_types): if isinstance(profile, string_types):
profile = __salt__['config.option'](profile) profile = __salt__['config.option'](profile)
response = requests.put( response = requests.put(
@ -407,6 +852,22 @@ def update_org(orgid, profile='grafana', **kwargs):
def delete_org(orgid, profile='grafana'): def delete_org(orgid, profile='grafana'):
'''
Delete an organization.
orgid
Id of the organization.
profile
Configuration profile used to connect to the Grafana instance.
Default is 'grafana'.
CLI Example:
.. code-block:: bash
salt '*' grafana4.delete_org <org_id>
'''
if isinstance(profile, string_types): if isinstance(profile, string_types):
profile = __salt__['config.option'](profile) profile = __salt__['config.option'](profile)
response = requests.delete( response = requests.delete(
@ -421,6 +882,22 @@ def delete_org(orgid, profile='grafana'):
def get_datasources(orgname=None, profile='grafana'): def get_datasources(orgname=None, profile='grafana'):
'''
List all datasources in an organisation.
orgname
Name of the organization.
profile
Configuration profile used to connect to the Grafana instance.
Default is 'grafana'.
CLI Example:
.. code-block:: bash
salt '*' grafana4.get_datasources <orgname>
'''
if isinstance(profile, string_types): if isinstance(profile, string_types):
profile = __salt__['config.option'](profile) profile = __salt__['config.option'](profile)
if orgname: if orgname:
@ -437,6 +914,25 @@ def get_datasources(orgname=None, profile='grafana'):
def get_datasource(name, orgname=None, profile='grafana'): def get_datasource(name, orgname=None, profile='grafana'):
'''
Show a single datasource in an organisation.
name
Name of the datasource.
orgname
Name of the organization.
profile
Configuration profile used to connect to the Grafana instance.
Default is 'grafana'.
CLI Example:
.. code-block:: bash
salt '*' grafana4.get_datasource <name> <orgname>
'''
data = get_datasources(orgname=orgname, profile=profile) data = get_datasources(orgname=orgname, profile=profile)
for datasource in data: for datasource in data:
if datasource['name'] == name: if datasource['name'] == name:
@ -445,6 +941,61 @@ def get_datasource(name, orgname=None, profile='grafana'):
def create_datasource(orgname=None, profile='grafana', **kwargs): def create_datasource(orgname=None, profile='grafana', **kwargs):
'''
Create a new datasource in an organisation.
name
Name of the data source.
type
Type of the datasource ('graphite', 'influxdb' etc.).
access
Use proxy or direct.
url
The URL to the data source API.
user
Optional - user to authenticate with the data source.
password
Optional - password to authenticate with the data source.
database
Optional - database to use with the data source.
basicAuth
Optional - set to True to use HTTP basic auth to authenticate with the
data source.
basicAuthUser
Optional - HTTP basic auth username.
basicAuthPassword
Optional - HTTP basic auth password.
jsonData
Optional - additional json data to post (eg. "timeInterval").
isDefault
Optional - set data source as default.
withCredentials
Optional - Whether credentials such as cookies or auth headers should
be sent with cross-site requests.
typeLogoUrl
Optional - Logo to use for this datasource.
orgname
Name of the organization in which the data source should be created.
profile
Configuration profile used to connect to the Grafana instance.
Default is 'grafana'.
'''
if isinstance(profile, string_types): if isinstance(profile, string_types):
profile = __salt__['config.option'](profile) profile = __salt__['config.option'](profile)
if orgname: if orgname:
@ -462,6 +1013,61 @@ def create_datasource(orgname=None, profile='grafana', **kwargs):
def update_datasource(datasourceid, orgname=None, profile='grafana', **kwargs): def update_datasource(datasourceid, orgname=None, profile='grafana', **kwargs):
'''
Update a datasource.
datasourceid
Id of the datasource.
name
Name of the data source.
type
Type of the datasource ('graphite', 'influxdb' etc.).
access
Use proxy or direct.
url
The URL to the data source API.
user
Optional - user to authenticate with the data source.
password
Optional - password to authenticate with the data source.
database
Optional - database to use with the data source.
basicAuth
Optional - set to True to use HTTP basic auth to authenticate with the
data source.
basicAuthUser
Optional - HTTP basic auth username.
basicAuthPassword
Optional - HTTP basic auth password.
jsonData
Optional - additional json data to post (eg. "timeInterval").
isDefault
Optional - set data source as default.
withCredentials
Optional - Whether credentials such as cookies or auth headers should
be sent with cross-site requests.
typeLogoUrl
Optional - Logo to use for this datasource.
profile
Configuration profile used to connect to the Grafana instance.
Default is 'grafana'.
'''
if isinstance(profile, string_types): if isinstance(profile, string_types):
profile = __salt__['config.option'](profile) profile = __salt__['config.option'](profile)
response = requests.put( response = requests.put(
@ -479,6 +1085,22 @@ def update_datasource(datasourceid, orgname=None, profile='grafana', **kwargs):
def delete_datasource(datasourceid, orgname=None, profile='grafana'): def delete_datasource(datasourceid, orgname=None, profile='grafana'):
'''
Delete a datasource.
datasourceid
Id of the datasource.
profile
Configuration profile used to connect to the Grafana instance.
Default is 'grafana'.
CLI Example:
.. code-block:: bash
salt '*' grafana4.delete_datasource <datasource_id>
'''
if isinstance(profile, string_types): if isinstance(profile, string_types):
profile = __salt__['config.option'](profile) profile = __salt__['config.option'](profile)
response = requests.delete( response = requests.delete(
@ -493,6 +1115,25 @@ def delete_datasource(datasourceid, orgname=None, profile='grafana'):
def get_dashboard(slug, orgname=None, profile='grafana'): def get_dashboard(slug, orgname=None, profile='grafana'):
'''
Get a dashboard.
slug
Slug (name) of the dashboard.
orgname
Name of the organization.
profile
Configuration profile used to connect to the Grafana instance.
Default is 'grafana'.
CLI Example:
.. code-block:: bash
salt '*' grafana4.get_dashboard <slug>
'''
if isinstance(profile, string_types): if isinstance(profile, string_types):
profile = __salt__['config.option'](profile) profile = __salt__['config.option'](profile)
if orgname: if orgname:
@ -512,6 +1153,25 @@ def get_dashboard(slug, orgname=None, profile='grafana'):
def delete_dashboard(slug, orgname=None, profile='grafana'): def delete_dashboard(slug, orgname=None, profile='grafana'):
'''
Delete a dashboard.
slug
Slug (name) of the dashboard.
orgname
Name of the organization.
profile
Configuration profile used to connect to the Grafana instance.
Default is 'grafana'.
CLI Example:
.. code-block:: bash
salt '*' grafana4.delete_dashboard <slug>
'''
if isinstance(profile, string_types): if isinstance(profile, string_types):
profile = __salt__['config.option'](profile) profile = __salt__['config.option'](profile)
if orgname: if orgname:
@ -528,6 +1188,28 @@ def delete_dashboard(slug, orgname=None, profile='grafana'):
def create_update_dashboard(orgname=None, profile='grafana', **kwargs): def create_update_dashboard(orgname=None, profile='grafana', **kwargs):
'''
Create or update a dashboard.
dashboard
A dict that defines the dashboard to create/update.
overwrite
Wether the dashboard should be overwritten if already existing.
orgname
Name of the organization.
profile
Configuration profile used to connect to the Grafana instance.
Default is 'grafana'.
CLI Example:
.. code-block:: bash
salt '*' grafana4.create_update_dashboard dashboard=<dashboard> overwrite=True orgname=<orgname>
'''
if isinstance(profile, string_types): if isinstance(profile, string_types):
profile = __salt__['config.option'](profile) profile = __salt__['config.option'](profile)
if orgname: if orgname:

View File

@ -86,7 +86,8 @@ def present(name,
Name of the organization in which the dashboard should be present. Name of the organization in which the dashboard should be present.
profile profile
A pillar key or dict that contains grafana information Configuration profile used to connect to the Grafana instance.
Default is 'grafana'.
''' '''
ret = {'name': name, 'result': True, 'comment': '', 'changes': {}} ret = {'name': name, 'result': True, 'comment': '', 'changes': {}}
dashboard = dashboard or {} dashboard = dashboard or {}
@ -199,7 +200,8 @@ def absent(name, orgname=None, profile='grafana'):
Name of the organization in which the dashboard should be present. Name of the organization in which the dashboard should be present.
profile profile
A pillar key or dict that contains grafana information Configuration profile used to connect to the Grafana instance.
Default is 'grafana'.
''' '''
ret = {'name': name, 'result': True, 'comment': '', 'changes': {}} ret = {'name': name, 'result': True, 'comment': '', 'changes': {}}

View File

@ -71,7 +71,7 @@ def present(name,
Name of the data source. Name of the data source.
type type
Which type of data source it is ('graphite', 'influxdb' etc.). Type of the datasource ('graphite', 'influxdb' etc.).
access access
Use proxy or direct. Default: proxy Use proxy or direct. Default: proxy
@ -113,6 +113,10 @@ def present(name,
orgname orgname
Name of the organization in which the data source should be present. Name of the organization in which the data source should be present.
profile
Configuration profile used to connect to the Grafana instance.
Default is 'grafana'.
''' '''
if isinstance(profile, string_types): if isinstance(profile, string_types):
profile = __salt__['config.option'](profile) profile = __salt__['config.option'](profile)
@ -167,6 +171,10 @@ def absent(name, orgname=None, profile='grafana'):
orgname orgname
Name of the organization from which the data source should be absent. Name of the organization from which the data source should be absent.
profile
Configuration profile used to connect to the Grafana instance.
Default is 'grafana'.
''' '''
if isinstance(profile, string_types): if isinstance(profile, string_types):
profile = __salt__['config.option'](profile) profile = __salt__['config.option'](profile)

View File

@ -83,6 +83,28 @@ def present(name,
timezone timezone
Optional - Timezone for the org (one of: "browser", "utc", or ""). Optional - Timezone for the org (one of: "browser", "utc", or "").
address1
Optional - address1 of the org.
address2
Optional - address2 of the org.
city
Optional - city of the org.
zip_code
Optional - zip_code of the org.
address_state
Optional - state of the org.
country
Optional - country of the org.
profile
Configuration profile used to connect to the Grafana instance.
Default is 'grafana'.
''' '''
if isinstance(profile, string_types): if isinstance(profile, string_types):
profile = __salt__['config.option'](profile) profile = __salt__['config.option'](profile)
@ -133,14 +155,14 @@ def present(name,
for username, role in users.items(): for username, role in users.items():
if username in db_users: if username in db_users:
if role is False: if role is False:
__salt__['grafana4.delete_org_users']( __salt__['grafana4.delete_org_user'](
db_users[username]['userId'], profile=profile) db_users[username]['userId'], profile=profile)
elif role != db_users[username]['role']: elif role != db_users[username]['role']:
__salt__['grafana4.update_org_users']( __salt__['grafana4.update_org_user'](
db_users[username]['userId'], loginOrEmail=username, db_users[username]['userId'], loginOrEmail=username,
role=role, profile=profile) role=role, profile=profile)
elif role: elif role:
__salt__['grafana4.create_org_users']( __salt__['grafana4.create_org_user'](
loginOrEmail=username, role=role, profile=profile) loginOrEmail=username, role=role, profile=profile)
new_db_users = {} new_db_users = {}
@ -171,6 +193,10 @@ def absent(name, profile='grafana'):
name name
Name of the org to remove. Name of the org to remove.
profile
Configuration profile used to connect to the Grafana instance.
Default is 'grafana'.
''' '''
if isinstance(profile, string_types): if isinstance(profile, string_types):
profile = __salt__['config.option'](profile) profile = __salt__['config.option'](profile)

View File

@ -72,6 +72,10 @@ def present(name,
theme theme
Optional - Selected theme of the user. Optional - Selected theme of the user.
profile
Configuration profile used to connect to the Grafana instance.
Default is 'grafana'.
''' '''
if isinstance(profile, string_types): if isinstance(profile, string_types):
profile = __salt__['config.option'](profile) profile = __salt__['config.option'](profile)
@ -126,6 +130,10 @@ def absent(name, profile='grafana'):
name name
Name of the user to remove. Name of the user to remove.
profile
Configuration profile used to connect to the Grafana instance.
Default is 'grafana'.
''' '''
if isinstance(profile, string_types): if isinstance(profile, string_types):
profile = __salt__['config.option'](profile) profile = __salt__['config.option'](profile)