PolicyData
- enum q2_sdk.hq.db.policy_data.Entity(value)[source]
Bases:
EnumValid values are as follows:
- User = <Entity.User: 'U'>
- Customer = <Entity.Customer: 'C'>
- Group = <Entity.Group: 'G'>
- UserRole = <Entity.UserRole: 'R'>
- Company = <Entity.Company: 'O'>
- SSOIdentifier = <Entity.SSOIdentifier: 'S'>
- class q2_sdk.hq.db.policy_data.PolicyDataValues(entity, entity_id, policy_data=None)[source]
Bases:
objectPolicyDataValues(entity: q2_sdk.hq.db.policy_data.Entity, entity_id: int, policy_data: list[q2_sdk.hq.models.policy_data.GeneratedTransactionRights | q2_sdk.hq.models.policy_data.Subsidiaries | q2_sdk.hq.models.policy_data.Account | q2_sdk.hq.models.policy_data.Features | q2_sdk.hq.models.policy_data.Data] = None)
-
entity_id:
int
-
policy_data:
list[GeneratedTransactionRights|Subsidiaries|Account|Features|Data] = None
-
entity_id:
- class q2_sdk.hq.db.policy_data.PolicyData(logger, hq_credentials=None, ret_table_obj=None)[source]
Bases:
DbObjectProgrammatic access to the Q2 database. Not as flexible as a true ORM, but takes the guesswork out of database schemas and ensures safety in the transactions.
- Parameters:
logger – Reference to calling request’s logger (self.logger in your extension)
hq_credentials (
Optional[HqCredentials]) – HQ Connectivity Information (Defaults to settings file)ret_table_obj (
Optional[bool]) – Flag to return list of LXML elements ifFalseor TableRow objects from DB calls ifTrue(Defaults to settings file)
- async get(entity, entity_id, include_parent_policy_data=False)[source]
A helper function for getting policy data for an entity. Example function calls:
await self.db.policy_data.get(Entity.User, self.online_user.user_id) await self.db.policy_data.get(Entity.Customer, self.online_user.customer_id) await self.db.policy_data.get(Entity.Group, self.online_user.group_id) await self.db.policy_data.get(Entity.UserRole, user[0].UserRoleID, include_parent_policy_data=True) await self.db.policy_data.get(Entity.SSOIdentifier, sso_user_logon[0].SSOUserLogonID, include_parent_policy_data=True)
- Parameters:
entity (
Entity) – Either User, Customer, Group, UserRole, Company of the Entity enumentity_id (
int) – The id of the entity. If user, provide the user id. If group, provide the group idinclude_parent_policy_data (
bool) – If true, then all policies in the user hierarchy will also be provided
- Return type:
- Returns:
PolicyData object
- async set(policy_data)[source]
Set policy data for an entity.
This method expects the full policy payload. First call
getto retrieve the current policy, apply your updates to that object, and then pass the complete result back viapolicy_data. Ifpolicy_data.entityisEntity.SSOIdentifier, the method resolves the concrete user entity and normalizesentity_idbefore submitting.- Return type:
str- Returns:
Success or failure message based on hq response
PolicyData return object definition