def get_group_by_id(group_id=None): """Gets a Group instance. Args: Returns: A Group instance if found, None otherwise. """ if not group_id: return None try: g = actions.db_get(collection=Collection.Groups, primary_id=group_id) if g: group = Group(g[GroupKey.GroupName], g[GroupKey.CustomerId], g[GroupKey.Permissions], g[GroupKey.Id]) return group except Exception as e: logger.error('Could not get group by id `%s`' % group_id) logger.exception(e) return None
def get_customer_property(customer_name=None, property_name=None): if (not customer_name and not property_name): return None try: properties = actions.db_get(collection=Collection.Customers, primary_id=customer_name, pluck=CustomerKey.Properties) properties = properties[CustomerKey.Properties] return properties.get(property_name) except Exception as e: logger.error("Unable to retrieve property `%s`." % property_name) logger.exception(e) return None