Database context¶
- class luna_handlers.db.context.DBContext(logger)[source]¶
Handlers DB context.
- checkVerifier(verifierId, accountId=None)[source]¶
Check verifier existence :param verifierId: verifier id :param accountId: account id
- Returns
True - if verifier exists, otherwise False
- Return type
bool
- createHandler(policies, accountId, description='', isDynamic=False)[source]¶
Create new handler.
- Parameters
policies – set handler policies
accountId – account id
description – user handler description
isDynamic – dynamic handler flag
- Returns
handler id
- Return type
str
- createVerifier(policies, accountId, description='')[source]¶
Create new verifier.
- Parameters
policies – verifier policies
accountId – account id
description – user verifier description
- Returns
verifier id
- Return type
str
- deleteHandler(handlerId, accountId=None)[source]¶
Delete handler by id
- Parameters
handlerId – handler id
accountId – account id of the handler
- Returns
True if handler exist otherwise false
- Return type
bool
- deleteVerifier(verifierId, accountId=None)[source]¶
Delete verifier by id
- Parameters
verifierId – verifier id
accountId – account id
- Returns
True if verifier deleted, otherwise False
- Return type
bool
- doesHandlerExist(handlerId, accountId=None)[source]¶
Check a account handler with id=handlerId existence :param handlerId: handler id :param accountId: handler account id
- Returns
true - if handler is exist otherwise false
- Return type
bool
- getAbsentHandlersIds(handlerIds)[source]¶
Given list of handlerIds, return those handlerIds that were removed from database.
Used for removal of items from cache by cache invalidator.
- Parameters
handlerIds – handler ids
- Returns
List with handlersIds that were removed.
- Return type
List
[str
]
- getHandler(handlerId, targets=(<HandlerTarget.handlerId: 'handler_id'>, <HandlerTarget.accountId: 'account_id'>, <HandlerTarget.createTime: 'create_time'>, <HandlerTarget.lastUpdateTime: 'last_update_time'>, <HandlerTarget.description: 'description'>, <HandlerTarget.policies: 'policies'>, <HandlerTarget.isDynamic: 'is_dynamic'>), accountId=None)[source]¶
Get handler by id :param handlerId: handler id :param accountId: handler account id :param targets: handler targets
- Returns
deserialize dict with handler
- Raises
VLException(Error.HandlerNotFound.format(handlerId), 404, isCriticalError=False) – if handler not found
- Return type
dict
- getHandlerCount(accountId=None, description=None, isDynamic=None)[source]¶
Get handler count
- Parameters
accountId – handler account id
description – handler description
isDynamic – whether to get only dynamic (non-dynamic) handlers
- Returns
handler count
- getHandlers(accountId=None, description=None, isDynamic=None, page=1, pageSize=100)[source]¶
Get handlers by filters
- Parameters
accountId – handler account id
description – handler description
isDynamic – whether to get only dynamic (non-dynamic) handlers
page – page
pageSize – page size
- Returns
list of deserialize handlers
- Return type
List
[dict
]
- getUpdatedHandlers(handlerIds, lastUpdateTimeGte, targets=None)[source]¶
Get updated handlers by ids. Used for cache invalidation.
- Parameters
handlerIds – handler ids
lastUpdateTimeGte – lower bound of handler update time
targets – handler targets
- Returns
List with handlers
- Return type
List
[Dict
]
- getVerifier(verifierId, accountId=None)[source]¶
Get verifier by id :param verifierId: verifier id :param accountId: verifier account id
- Returns
deserialized dict with verifier
- Raises
VLException(Error.VerifierNotFound.format(verifierId), 404, isCriticalError=False) – if verifier not found
- Return type
Dict
- getVerifierCount(accountId=None, description=None)[source]¶
Get verifier count
- Parameters
accountId – account id
description – verifier description
- Returns
verifier count
- getVerifiers(accountId=None, description=None, page=1, pageSize=100)[source]¶
Get verifiers by filters
- Parameters
accountId – account id
description – verifier description
page – page
pageSize – page size
- Returns
list of verifiers
- Return type
List
[dict
]
- loadHandlerFromRow(handlerRow, selectColumns)[source]¶
Load handler as dict from raw row.
- Parameters
handlerRow – full row from db
selectColumns – columns from sql query
- Returns
handler as dict
- Return type
dict
[str
,Any
]
- loadVerifierFromRow(verifierRow)[source]¶
Load verifier as dict from raw row.
- Parameters
verifierRow – full row from db
- Returns
verifier as dict
- Return type
Dict
[str
,Any
]
- putHandler(handlerId, policies, accountId, description='', isDynamic=False)[source]¶
Put handler instead old handler.
- Parameters
handlerId – handler
policies – set handler policies
accountId – account id
description – user handler description
isDynamic – dynamic handler flag
Warning
function does not create handler!
- Returns
True if handler exist otherwise false
- Return type
bool
- putVerifier(verifierId, policies, accountId, description='')[source]¶
Replace verifier by id.
- Parameters
verifierId – verifier id
policies – verifier policies
accountId – account id
description – user verifier description
Warning
function does not create verifier!
- Returns
verifier current version if verifier replaced
- Return type
Optional
[int
]