Interviewer - Server > Architecture > Interview Service tier > Quota web service > Quota web service > Modifying quotas > /Quota/Projects/[ProjectName]/Quotas
 
/Quota/Projects/[ProjectName]/Quotas
This URL updates all quotas in the project, either to the same values or each to different values.
For the same value
XML
<Quotas Target="10" Completed="0" />
JSON
{
"Target": "10",
"Completed": "0"
}
For different values for each quota
XML
<Quotas>
<Quota FullName="Expressions:Child" Target="10" Completed="0" />
<Quota FullName="Expressions:Adult" Target="10" Completed="2" />
<Quota FullName="UseQ:Side.(0.UseQ).(0.Brand1)" Target="5" Completed="0" />
<Quota FullName="UseQ:Side.(0.UseQ).(1.Brand2)" Target="5" Completed="1" />
<Quota FullName="UseQ:Side.(0.UseQ).(2.Brand3)" Target="5" Completed="2" />
<Quota FullName="UseQ:Side.(0.UseQ).(3.Brand4)" Target="5" Completed="0" />
<Quota FullName="UseQ:Side.(0.UseQ).(4.Brand5)" Target="5" Completed="0" />
</Quotas>
JSON
{
"Quotas": [
{
"FullName": "Expressions:Child",
"Target": "10",
"Completed": "0"
},
{
"FullName": "Expressions:Adult",
"Target": "10",
"Completed": "2"
},
{
"FullName": "UseQ:Side.(0.UseQ).(0.Brand1)",
"Target": "5",
"Completed": "0"
},
{
"FullName": "UseQ:Side.(0.UseQ).(1.Brand2)",
"Target": "5",
"Completed": "1"
},
{
"FullName": "UseQ:Side.(0.UseQ).(2.Brand3)",
"Target": "5",
"Completed": "2"
},
{
"FullName": "UseQ:Side.(0.UseQ).(3.Brand4)",
"Target": "5",
"Completed": "0"
},
{
"FullName": "UseQ:Side.(0.UseQ).(4.Brand5)",
"Target": "5",
"Completed": "0"
}
]
}
The FullName of each quota must be use. Include only the attributes which need to changed.
For example, to reset the completed count for all quotas in the project MM1WithQuota, the following XML would be sent to the URL /Quota/Projects/MM1WithQuota/Quotas as a PATCH request.
XML
<Quotas Completed="0" />
JSON
{
"Completed": "0"
}
Using expressions to adjust quota counts
In addition to specifying numeric values for the Target and Completed attributes in the XML/JSON in PATCH requests, you can use an mrEvaluate compatible expression that is evaluated for each quota. The valid identifiers in the expression are “Target”, “Completed”, and “Pending”. The new values are calculated for each count before they are updated, that is, the expressions are always based on the current counts before any updates are applied. The expressions are specified by using TargetExpression, CompletedExpression, and PendingExpression attributes to enable the Target, Completed, and Pending attributes to be retained as integers in the XML schema.
Expressions can be used to implement a rule such as “reset completes to zero and adjust the targets taking into account the number of current completes”. To achieve this for the MM1WithQuota project, the following request body would be sent as a PATCH request to the URL /Quota/Projects/MM1WithQuota/Quotas.
XML
<Quotas TargetExpression="50 + (50 – Completed)" Completed="0"/>
JSON
{
"TargetExpression": "50 + (50 – Completed)",
"Completed": 0
}
Error checking
Any syntax error in TargetExpression, CompletedExpression, or PendingExpression is returned as an error string as described in Error handling.
An error is returned if a race condition occurs during the update of multiple quotas using an expression. This can occur if another user updates the target, completed, or pending value between the web service reading the value from the database and writing the new calculated value. This is prevented by including the original target, completed, and pending values in the WHERE clause of the UPDATE statement. If zero rows are affected by the UPDATE, it is assumed the counts have been changed compared to when they were read. In the unlikely event of this occurring, an error is returned to the user who can refresh their view of the target, completed, and pending counts, and then re-run the update if necessary.
See also
Modifying quotas