PyPushover group docs

groups - Group Management for the Pushover API

This module defines functions and classes used for handling groups on the Pushover servers. Users can be added, removed, activated, or deactivated from a group. Information can also be queried about the group.

Group Information and Renaming:

## Using the GroupManager class:

>>> import pypushover as py_po
>>> gm = py_po.groups.GroupManager('app_token', 'group_key')
>>> print(gm.info())

You can also use the group property to query information on the group. This is dynamically updated with every call to the group:

>>> print(gm.group.name)
>>> print(len(gm.group.users))
>>> print(gm.group.users[0].device)
## Using the function call
>>> print(py_po.groups.info('app_token', 'group_key'))

## Renaming the group

Using the GroupManager class
>>> gm.rename('group name')
>>> print(gm.group.name)
Using the function calls
>>> py_po.groups.rename('app_token', 'group_key', 'group name')
>>> print(py_po.groups.info('app_token', 'group_key')['name'])

User Management for a Group:

## Adding a user:

>>> gm.add_user('user_key')
>>> py_po.groups.add_user('app_token', 'group_key', 'user_key')

You can also add specifying information for the user:

>>> gm.add_user('user_key',
>>>     device='android',
>>>     memo='Users android device')  # adds only device 'android' for user to group.  Attach a memo to the addition

## Removing a user:

Using the Class method:

>>> gm.remove_user('user_key')

You can also use the dynamic group property to select a user

>>> gm.remove_user(gm.group.users[0].user_key)

Using the function call

>>> py_po.groups.remove_user('app_token', 'group_key', 'user_key')

## Disable a user Disabling a user doesn’t remove them from the group, but disables any alerts sent to the group to be sent to them

Using the Class method call
>>> gm.disable_user('user_key')
You can also use the dynamic group property
>>> gm.disable_user(gm.group.users[0].user_key)
Using the function call
>>> py_po.groups.disable_user('app_token', 'group_key', 'user_key')

## Enable a user Enabling a user does the exact opposite of the disable user. An enabled user will receive messages sent to the group.

Using the Class method:

>>> gm.enable_user('user_key')

You can also use the dynamic group property:

>>> gm.enable_user(gm.group.users[0].user_key)

Using the function call:

>>> py_po.groups.enable_user('app_token', 'group_key', 'user_key')
class groups.GroupManager(app_token, group_key)[source]

Manages the calls the groups API for Pushover, without having to supply and app token and group key everytime.

Also enables to user to query current status of the group using the group property:

>>> gm = GroupManager('app_token', 'group_key')
>>> print(gm.group.name)  # prints the name of the group associated with 'group_key'
>>> gm.rename('new name')
>>> print(gm.group.name)  # prints 'new name'
add_user(user, device=None, memo=None)[source]

Adds the selected user to the group

Parameters:
  • user (str) – the user id of the user to add
  • device (str) – the associated device name (optional)
  • memo (str) – memo (optional)
Returns:

A dictionary representing the json response.

disable_user(user)[source]

Disables the user from receiving notifications sent to the group :param str user: the user id of the user to disable :return: A dictionary representing the json response.

enable_user(user)[source]

Enables the user to receive notifications sent to the group :param str user: the user id of the user to enable :return: A dictionary representing the json response.

info()[source]

Fetches the group name and a list of users subscribed to the group.

Returns:A dictionary representing the json response.
remove_user(user)[source]

Removes the selected user from the group :param str user: the user id of the user to deleted :return: A dictionary representing the json response.

rename(name)[source]

Renames the group :param str name: the name of the group to change to :return: A dictionary representing the json response.

groups.add_user(app_token, group, user, device=None, memo=None)[source]

Adds the selected user to the group

Parameters:
  • app_token (str) – your applications token
  • group (str) – the group id
  • user (str) – the user id of the user to add
  • device (str) – the associated device name (optional)
  • memo (str) – memo (optional)
Returns:

A dictionary representing the json response.

groups.disable_user(app_token, group, user)[source]

Disables the user from receiving notifications sent to the group :param str app_token: your applications token :param str group: the group id :param str user: the user id of the user to disable :return: A dictionary representing the json response.

groups.enable_user(app_token, group, user)[source]

Enables the user to receive notifications sent to the group :param str app_token: your applications token :param str group: the group id :param str user: the user id of the user to enable :return: A dictionary representing the json response.

groups.info(app_token, group)[source]

Fetches the group name and a list of users subscribed to the group.

Parameters:
  • app_token (str) – your applications token
  • group (str) – the group id to return info on
Returns:

A dictionary representing the json response.

groups.remove_user(app_token, group, user)[source]

Removes the selected user from the group :param str app_token: your applications token :param str group: the group id :param str user: the user id of the user to deleted :return: A dictionary representing the json response.

groups.rename(app_token, group, name)[source]

Renames the group :param str app_token: your applications token :param str group: the group id :param str name: the name of the group to change to :return: A dictionary representing the json response.