@db_api.retry_if_session_inactive()
def set_quota_usage(context, resource, tenant_id, in_use=None, delta=False):
 with db_api.autonested_transaction(context.session):
  query = db_utils.model_query(context, quota_models.QuotaUsage)
  query = query.filter_by(resource=resource).filter_by(tenant_id=tenant_id)
  usage_data = query.first()
  if (not usage_data):
   usage_data = quota_models.QuotaUsage(resource=resource, tenant_id=tenant_id)
   context.session.add(usage_data)
  if (in_use is not None):
   if delta:
    in_use = (usage_data.in_use + in_use)
   usage_data.in_use = in_use
  usage_data.dirty = False
 return QuotaUsageInfo(usage_data.resource, usage_data.tenant_id, usage_data.in_use, usage_data.dirty)

@ db_api . retry_if_session_inactive ( ) def set_quota_usage ( context , resource , tenant_id , in_use = None , delta = False ) : with db_api . autonested_transaction ( context . session ) : query = db_utils . model_query ( context , quota_models . QuotaUsage ) query = query . filter_by ( resource = resource ) . filter_by ( tenant_id = tenant_id ) usage_data = query . first ( ) if ( not usage_data ) : usage_data = quota_models . QuotaUsage ( resource = resource , tenant_id = tenant_id ) context . session . add ( usage_data ) if ( in_use is not None ) : if delta : in_use = ( usage_data . in_use + in_use ) usage_data . in_use = in_use usage_data . dirty = False return QuotaUsageInfo ( usage_data . resource , usage_data . tenant_id , usage_data . in_use , usage_data . dirty )
set resource quota usage .