Table of Contents
organisation
Organisation Objects
class Organisation()
The class includes all necessary methods to access the Grafana organisation API endpoint
Arguments:
grafana_api_model
APIModel - Inject a Grafana API model object that includes all necessary values and information
Attributes:
grafana_api_model
APIModel - This is where we store the grafana_api_model
get_current_organization
def get_current_organization() -> dict
The method includes a functionality to get the current organization
Required Permissions: Action: orgs:read Scope: N/A
Raises:
Exception
- Unspecified error by executing the API call
Returns:
api_call
dict - Returns the current organization
get_all_users_by_the_current_organization
def get_all_users_by_the_current_organization() -> list
The method includes a functionality to get all users from the current organization
Required Permissions: Action: org.users:read Scope: users:*
Raises:
Exception
- Unspecified error by executing the API call
Returns:
api_call
list - Returns the users of the current organization
get_all_users_by_the_current_organization_lookup
def get_all_users_by_the_current_organization_lookup() -> list
The method includes a functionality to get the lookup information of all users from the current organization
Required Permissions: Action: org.users:read Scope: users:*
Raises:
Exception
- Unspecified error by executing the API call
Returns:
api_call
list - Returns the users of the current organization
update_organization_user_role_by_user_id
def update_organization_user_role_by_user_id(user_id: int, role: str)
The method includes a functionality to update the current organization user by the user id
Arguments:
user_id
int - Specify the id of the userrole
str - Specify the role of the user
Required Permissions:
- Action
- org.users.role:update
- Scope
- users:*
Raises:
ValueError
- Missed specifying a necessary valueException
- Unspecified error by executing the API call
Returns:
None
delete_organization_user_by_user_id
def delete_organization_user_by_user_id(user_id: int)
The method includes a functionality to delete the current organization user by the user id
Arguments:
user_id
int - Specify the id of the user
Required Permissions:
- Action
- org.users:remove
- Scope
- users:*
Raises:
ValueError
- Missed specifying a necessary valueException
- Unspecified error by executing the API call
Returns:
None
update_current_organization
def update_current_organization(name: str)
The method includes a functionality to update the current organization
Arguments:
name
str - Specify the new name of the current organization
Required Permissions:
- Action
- orgs:write
- Scope
- N/A
Raises
- ValueError
- Missed specifying a necessary value
- Exception
- Unspecified error by executing the API call
Returns:
None
add_new_user_to_current_organization
def add_new_user_to_current_organization(login_or_email: str,
role: str) -> int
The method includes a functionality to add a new user to the current organization
Arguments:
login_or_email
str - Specify the added userrole
str - Specify the added role for the user
Required Permissions:
- Action
- org.users:add
- Scope
- users:*
Raises:
ValueError
- Missed specifying a necessary valueException
- Unspecified error by executing the API call
Returns:
user_id
int - Returns the id of the created user
OrganisationAdmin Objects
class OrganisationAdmin()
The class includes all necessary methods to access the Grafana organisation Admin API endpoint. Be aware that all functionalities inside the class only working with basic authentication (username and password)
Arguments:
grafana_api_model
APIModel - Inject a Grafana API model object that includes all necessary values and information
Attributes:
grafana_api_model
APIModel - This is where we store the grafana_api_model
get_organization_by_id
def get_organization_by_id(org_id: int) -> dict
The method includes a functionality to get an organization by the id
Arguments:
org_id
int - Specify the organization id
Required Permissions:
- Action
- orgs:read
- Scope
- N/A
Raises:
ValueError
- Missed specifying a necessary valueException
- Unspecified error by executing the API call
Returns:
api_call
dict - Returns the organization as dict
get_organization_by_name
def get_organization_by_name(name: str) -> dict
The method includes a functionality to get an organization by the name
Arguments:
name
str - Specify the organization name
Required Permissions:
- Action
- orgs:read
- Scope
- N/A
- Note
- Needs to be assigned globally.
Raises:
ValueError
- Missed specifying a necessary valueException
- Unspecified error by executing the API call
Returns:
api_call
dict - Returns the organization as dict
get_organizations
def get_organizations() -> list
The method includes a functionality to get all organizations
Required Permissions: Action: orgs:read Scope: N/A Note: Needs to be assigned globally.
Raises:
Exception
- Unspecified error by executing the API call
Returns:
api_call
list - Returns all organizations as list
create_organization
def create_organization(name: str) -> int
The method includes a functionality to create an organization
Arguments:
name
str - Specify the organization name
Required Permissions:
- Action
- orgs:create
- Scope
- N/A
- Note
- Needs to be assigned globally.
Raises:
ValueError
- Missed specifying a necessary valueException
- Unspecified error by executing the API call
Returns:
org_id
int - Returns the id of the created organization
update_organization
def update_organization(org_id: int, name: str)
The method includes a functionality to update an organization
Arguments:
org_id
int - Specify the organization idname
str - Specify the organization name
Required Permissions:
- Action
- orgs:write
- Scope
- N/A
Raises:
ValueError
- Missed specifying a necessary valueException
- Unspecified error by executing the API call
Returns:
None
delete_organization
def delete_organization(org_id: int)
The method includes a functionality to delete an organization
Arguments:
org_id
int - Specify the organization id
Required Permissions:
- Action
- orgs:delete
- Scope
- N/A
Raises:
ValueError
- Missed specifying a necessary valueException
- Unspecified error by executing the API call
Returns:
None
get_organization_users
def get_organization_users(org_id: int) -> list
The method includes a functionality to get all organization users specified by the organization id
Arguments:
org_id
int - Specify the organization id
Required Permissions:
- Action
- org.users:read
- Scope
- users:*
Raises:
ValueError
- Missed specifying a necessary valueException
- Unspecified error by executing the API call
Returns:
api_call
list - Returns all organization users as list
add_organization_user
def add_organization_user(org_id: int, login_or_email: str, role: str) -> int
The method includes a functionality to add a user to an organization
Arguments:
org_id
int - Specify the organization idlogin_or_email
str - Specify the added userrole
str - Specify the added role for the user
Required Permissions:
- Action
- org.users:add
- Scope
- users:*
Raises:
ValueError
- Missed specifying a necessary valueException
- Unspecified error by executing the API call
Returns:
user_id
int - Returns the added user id
update_organization_user
def update_organization_user(org_id: int, user_id: int, role: str)
The method includes a functionality to update organization user specified by the organization id, the user_id and the role
Arguments:
org_id
int - Specify the organization iduser_id
int - Specify the user idrole
str - Specify the added role for the user
Required Permissions:
- Action
- org.users.role:update
- Scope
- users:*
Raises:
ValueError
- Missed specifying a necessary valueException
- Unspecified error by executing the API call
Returns:
None
delete_organization_user
def delete_organization_user(org_id: int, user_id: int)
The method includes a functionality to remove an organization users specified by the organization id and the user id
Arguments:
org_id
int - Specify the organization iduser_id
int - Specify the user id
Required Permissions:
- Action
- org.users:remove
- Scope
- users:*
Raises:
ValueError
- Missed specifying a necessary valueException
- Unspecified error by executing the API call
Returns:
None