CommunitySubscriptionsMixin

class squirro_client.topic.CommunitySubscriptionsMixin

Bases: object

Methods Summary

delete_community_subscription(project_id, …)

Deletes a community subscription

get_community_subscriptions(project_id[, …])

Returns all community subscriptions for a project and a user.

new_community_subscriptions(project_id, …)

Creates a new community subscription for a project given the community_id

Methods Documentation

delete_community_subscription(project_id, subscription_id)

Deletes a community subscription

Parameters
  • project_id – Project Identifier

  • subscription_id – Community subscription Identifier

Example:

>>> client.delete_community_subscription(
    'Xh9CeyQtTYe2cv5F11e6nQ',
    'mNDkc6q9QvuL8EVMWA3cgg')
{}
get_community_subscriptions(project_id, include_count_of_items=False, start=None, count=- 1)

Returns all community subscriptions for a project and a user.

Parameters
  • project_id – Project Identifier

  • include_count_of_items – Boolean argument to include the count of items belonging to the subscribed communities of the user. Defaults to False.

  • start – Integer. Used for pagination of objects. If set, the objects starting with offset start are returned. Defaults to None.

  • count – Integer. Used for pagination of objects. If set, count number of communities are returned. To return all communities, set to -1. Defaults to -1.

Example:

>>> client.get_community_subscriptions('Xh9CeyQtTYe2cv5F11e6nQ')
[
    {
    "id": "D0nEBlUmTLqxq6lwZj4rTw",
    "user_id": "-XNqd1bARxuA0L1jh3OeeQ",
    "community_id": "OSACPQKbRz2dadBM4nSseA",
    "created_at": "2020-09-14T09:12:21"
    },
    {
    "id": "QmykmwR3Tb6ZEHI6DJQzUg",
    "user_id": "-XNqd1bARxuA0L1jh3OeeQ",
    "community_id": "mNDkc6q9QvuL8EVMWA3cgg",
    "created_at": "2020-09-14T09:17:15"
    }

]

TODO: allow for specifying user id

new_community_subscriptions(project_id, community_ids, remove_existing_subscriptions=False, user_id=None)

Creates a new community subscription for a project given the community_id

Parameters
  • project_id – Project Identifier

  • community_ids – Ids of the communities to subscribe to

  • remove_existing_subscriptions – Boolean flag to remove existing subscriptions

  • user_id – Id of the user subscribing to the community ids

Example:

>>> client.new_community_subscription(
        'Xh9CeyQtTYe2cv5F11e6nQ',
        ['mNDkc6q9QvuL8EVMWA3cgg','otCTwaF9Qs-66MFGLCtyKQ']
        remove_existing_subscriptions = True
    )
{
    "id": "QmykmwR3Tb6ZEHI6DJQzUg",
    "user_id": "-XNqd1bARxuA0L1jh3OeeQ",
    "community_id": "mNDkc6q9QvuL8EVMWA3cgg",
    "created_at": "2020-09-14T09:17:15"
}