Groups

Retrieving group objects

class GroupMixin

This class defines all functions related to BlueConic groups.

delete_group(group_id, group_type_id)

Delete a group with a specific group ID of a specific group type.

Parameters:
  • group_id (str) – The group ID

  • group_type_id (str) – The group type ID

get_group(group_id, group_type_id)

Retrieves the group with a specific group ID within a specific group type. The group type also needs to be passed, as a group with the same ID might also exist for other group types.

Parameters:
  • group_id (str) – The group ID

  • group_type_id (str) – The group type ID

Raises:

HTTPError: Request fails

Returns:

The group

Return type:

Group

get_group_properties(group_type_id)

Retrieve all group properties of a group type and returns them in a generator with all BlueConic profile properties.

Parameters:

group_type_id (str) – The group type ID

Returns:

Iterator with group properties

Return type:

Iterator[ProfileProperty]

get_group_property(property_id)

Retrieve the group property with the group property ID and returns it as a BlueConic profile property.

Parameters:

property_id (str) – The property ID

Returns:

The group property

Return type:

Optional[ProfileProperty]

get_groups(group_type_id, start=None, count=1000000, properties=None, progress_bar=True, filters=None)

Retrieve all groups from the same group type.

Parameters:
  • group_type_id (str) – The group type ID

  • start (int, optional) – The group to start from. Defaults to 0. Deprecated, doesn’t work anymore in R89.

  • count (int, optional) – The number of groups to retrieve. To get all groups, use count=0. Defaults to 1000000.

  • properties ([str], optional) – The group properties that should be retrieved. Leave empty to retrieve all group properties. Defaults to None.

  • progress_bar (bool, optional) – Enables the view of the progress bar, which shows the progress of the group retrieval. Defaults to True.

  • filters (Union[FilterConfig, Sequence[FilterConfig]], optional) – Property filters to limit the returned groups. See filtering groups for details.

Raises:

ValueError – If group type id properties are used in the filters.

Returns:

Iterator with groups

Return type:

Iterator[Group]

get_nr_of_groups(group_type_id, filters=None)

Gets the number of groups.

Parameters:
  • group_type_id (str) – The group type ID

  • filters (Union[FilterConfig, Sequence[FilterConfig]], optional) – Property filters to limit the groups included in the count

Raises:

ValueError – If group type id properties are used in the filters.

Returns:

The number of groups using the given filters

Return type:

int

Usage:
>>> import blueconic
>>> bc = blueconic.Client()
>>> myfilter = blueconic.get_filter("example_property_id").is_empty()
>>> print(bc.get_nr_of_groups('example_group_type_id', myfilter))
1337

Using group objects

class Group
add_value(property_id, property_value)

Adds one value to the property. Keeps existing values intact.

Parameters:
get_value(property_id)

Gets the first value of a property.

Parameters:

property_id (str) – The ID of the property to retrieve the value from

Raises:

KeyError – If the ID does not refer to an existing property

Returns:

The first value of the property

Return type:

str

get_values(property_id)

Gets all values of a property.

Parameters:

property_id (str) – The ID of the property to retrieve the values from

Raises:

KeyError – If the ID does not refer to an existing property

Returns:

All the values of the property

Return type:

[str]

set_value(property_id, property_value, set_if_empty=False)

Sets one value for this property. Removes all values that were already present.

Parameters:
  • property_id (str) – The ID of the property

  • property_value (int or str or bool or float or datetime.datetime) – The value to set. All values are cast to a string

  • set_if_empty (bool, optional) – When set to False, the existing value will always be replaced with the new value. Set this parameter to True to set the new value only when there was no value yet present in the property. Defaults to False.

Raises:

KeyError – If the ID does not refer to an existing property

set_values(property_id, property_values, set_if_empty=False)

Sets multiple values for this property. Remove all values that were already present.

Parameters:
  • property_id (str) – The ID of the property

  • property_values ([int or str or bool or float or datetime.datetime]) – A list of values. All values are cast to a string

  • set_if_empty (bool) – When set to False, the existing values will always be replaced with the new values. Set this parameter to True to set the new values only when there were no values yet present in the property. Defaults to False.

property group_type_id

Returns the ID of the group type.

property id

Returns the ID of this group.

property identifier

Returns the external identifier for this group.

property properties

Returns the properties of this object.

property property_ids

Returns the property IDs of this object.