<?xml version="1.0" encoding="utf-8"?>
<!-- name="GENERATOR" content="github.com/mmarkdown/mmark Mmark Markdown Processor - mmark.miek.nl" -->
<rfc version="3" ipr="trust200902" docName="draft-ietf-jmap-quotas-08" submissionType="IETF" category="std" xml:lang="en" xmlns:xi="http://www.w3.org/2001/XInclude" indexInclude="true" consensus="true">

<front>
<title abbrev="JMAP Quotas">JMAP for Quotas</title><seriesInfo value="draft-ietf-jmap-quotas-08" stream="IETF" status="standard" name="Internet-Draft"></seriesInfo>
<author role="editor" initials="R.C." surname="Cordier" fullname="René Cordier"><organization>Linagora Vietnam</organization><address><postal><street>5 Dien Bien Phu</street>
<city>Hanoi</city>
<code>10000</code>
<country>Vietnam</country>
</postal><email>rcordier@linagora.com</email>
<uri>https://linagora.vn</uri>
</address></author><date year="2022" month="November" day="18"></date>
<area>Applications</area>
<workgroup>JMAP</workgroup>
<keyword>JMAP</keyword>
<keyword>JSON</keyword>
<keyword>email</keyword>
<keyword>quotas</keyword>

<abstract>
<t>This document specifies a data model for handling quotas on accounts with a server using JMAP.</t>
</abstract>

</front>

<middle>

<section anchor="introduction"><name>Introduction</name>
<t>JMAP (<xref target="RFC8620"></xref> – JSON Meta Application Protocol) is a generic protocol for synchronising data, such as mails,
calendars or contacts, between a client and a server. It is optimised for mobile and web environments, and aims
to provide a consistent interface to different data types.</t>
<t>This specification defines a data model for handling quotas over JMAP, allowing a user to obtain details about a certain quota.</t>
<t>This specification does not address quota administration, which should be handled by other means.</t>

<section anchor="notational-conventions"><name>Notational conventions</name>
<t>The key words &quot;MUST&quot;, &quot;MUST NOT&quot;, &quot;REQUIRED&quot;, &quot;SHALL&quot;, &quot;SHALL NOT&quot;,
&quot;SHOULD&quot;, &quot;SHOULD NOT&quot;, &quot;RECOMMENDED&quot;, &quot;NOT RECOMMENDED&quot;, &quot;MAY&quot;, and
&quot;OPTIONAL&quot; in this document are to be interpreted as described in BCP
14 <xref target="RFC2119"></xref> <xref target="RFC8174"></xref> when, and only when, they appear in all
capitals, as shown here.</t>
<t>Type signatures, examples and property descriptions in this document follow the conventions established in section 1.1
of <xref target="RFC8620"></xref>. Data types defined in the core specification are also used in this document.</t>
<t>Servers that support the new data types defined in this document MUST support all the properties specified for these data types.</t>
</section>

<section anchor="terminology"><name>Terminology</name>
<t>This document reuses the terminology from the core JMAP specification.</t>
<t>The term Quota (with that specific capitalization) is used to refer to the data type defined in this document and instance of that data type.</t>
</section>

<section anchor="addition-to-the-capabilities-object"><name>Addition to the capabilities object</name>
<t>The capabilities object is returned as part of the JMAP Session object; see <xref target="RFC8620"></xref>, section 2.</t>
<t>This document defines one additional capability URI.</t>

<section anchor="urn-ietf-params-jmap-quota"><name>urn:ietf:params:jmap:quota</name>
<t>This represents support for the Quota data type and associated API methods. Servers supporting this specification MUST add a property called urn:ietf:params:jmap:quota to the capabilities object.</t>
<t>The value of this property is an empty object in both the JMAP session capabilities property and an account’s accountCapabilities property.</t>
</section>
</section>

<section anchor="data-types"><name>Data types</name>
<t>In addition to the standard JMAP data types, a couple of additional data types are common to the definition of Quota objects and properties.</t>

<section anchor="scope"><name>Scope</name>
<t>The <strong>Scope</strong> data type is used to represent the entities the Quota applies to. It is defined as a &quot;String&quot; with values from the following set:</t>

<ul spacing="compact">
<li>account: The Quota information applies to this account</li>
<li>domain: The Quota information applies to all accounts sharing this domain</li>
<li>global: The Quota information applies to all accounts belonging to the server</li>
</ul>
</section>

<section anchor="resourcetype"><name>ResourceType</name>
<t>The <strong>ResourceType</strong> data type is used to act as an unit of measure for the quota usage. It is defined as a &quot;String&quot; with values from the following set:</t>

<ul spacing="compact">
<li>count: The quota is measured in number of data type objects. For example, a quota can have a limit of 50 &quot;Mail&quot; objects.</li>
<li>octets: The quota is measured in size (in &quot;octets&quot;). For example, a quota can have a limit of 25000 &quot;octets&quot;.</li>
</ul>
</section>
</section>

<section anchor="push"><name>Push</name>
<t>Servers MUST support the JMAP push mechanisms, as specified in <xref target="RFC8620"></xref> Section 7, to receive notifications when
the state changes for the Quota type defined in this specification.</t>
</section>
</section>

<section anchor="quota"><name>Quota</name>
<t>The quota is an object that displays the limit set to an account usage as well as the current usage in regard to that limit.</t>
<t>The quota object MUST contain the following fields:</t>

<ul spacing="compact">
<li>id: &quot;Id&quot;</li>
</ul>
<ul empty="true"><li>The unique identifier for this object.</li></ul>

<ul spacing="compact">
<li>resourceType: &quot;ResourceType&quot;</li>
</ul>
<ul empty="true"><li>The resource type of the quota.</li></ul>

<ul spacing="compact">
<li>used: &quot;UnsignedInt&quot;</li>
</ul>
<ul empty="true"><li>The current usage of the defined quota, using the &quot;resourceType&quot; defined as unit of measure.
Computation of this value is handled by the server.</li></ul>

<ul spacing="compact">
<li>limit: &quot;UnsignedInt&quot;</li>
</ul>
<ul empty="true"><li>The hard limit set by this quota, using the &quot;resourceType&quot; defined as unit of measure. Objects
in scope may not be created or updated if this limit is reached.</li></ul>

<ul spacing="compact">
<li>scope: &quot;Scope&quot;</li>
</ul>
<ul empty="true"><li>The &quot;Scope&quot; of this quota.</li></ul>

<ul spacing="compact">
<li>name: &quot;String&quot;</li>
</ul>
<ul empty="true"><li>The name of the quota object. Useful for managing quotas and using queries for searching.</li></ul>

<ul spacing="compact">
<li>dataTypes: &quot;String[]&quot;</li>
</ul>
<ul empty="true"><li>A list of all the type names (e.g., Email, Calendar, etc.) to which this quota applies.
This allows to assign quotas to distinct or shared data types. This MAY include data types the client does not recognise.
Clients MUST ignore any unknown data type in the list.</li></ul>
<t>The quota object MAY contain the following fields:</t>

<ul spacing="compact">
<li>warnLimit: &quot;UnsignedInt|null&quot;</li>
</ul>
<ul empty="true"><li>The warn limit set by this quota object, using the &quot;resourceType&quot; defined as unit of measure.
It can be used to send a warning to an entity about to reach the hard limit soon, but with no action taken yet. If set, it
should be lower than the &quot;softLimit&quot; and the &quot;limit&quot;.</li></ul>

<ul spacing="compact">
<li>softLimit: &quot;UnsignedInt|null&quot;</li>
</ul>
<ul empty="true"><li>The soft limit set by this quota object, using the &quot;resourceType&quot; defined as unit of measure.
It can be used to still allow some operations, but refuse some others. What is allowed or not is up to the server. For example, it
could be used for blocking outgoing events of an entity (sending emails, creating calendar events, ...) while still receiving
incoming events (receiving emails, receiving calendars events, ...). If set, it should be higher than the &quot;warnLimit&quot; but lower
than the &quot;limit&quot;.</li></ul>

<ul spacing="compact">
<li>description: &quot;String|null&quot;</li>
</ul>
<ul empty="true"><li>Arbitrary free, human readable, description of this quota. Might be used to explain
where the limit comes from and explain the entities and data types this quota applies to. The description is presumed to be given
in the US-ASCII character set.</li></ul>

<section anchor="quota-get"><name>Quota/get</name>
<t>Standard “/get” method as described in <xref target="RFC8620"></xref> section 5.1. The <em>ids</em> argument may be &quot;null&quot; to fetch all at once.</t>
</section>

<section anchor="quota-changes"><name>Quota/changes</name>
<t>Standard “/changes” method as described in <xref target="RFC8620"></xref> section 5.2 but with one extra argument to the response:</t>

<ul spacing="compact">
<li>updatedProperties: &quot;String[]|null&quot;</li>
</ul>
<ul empty="true"><li>If only the “used” Quota properties has changed since the old state, this
will be a list containing only that property. If the server is unable to tell if only &quot;used&quot; has changed, it
MUST just be null.</li></ul>
<t>Since &quot;used&quot; frequently changes but other properties are generally only changed rarely, the server can help the client
optimise data transfer by keeping track of changes to Quota usage separate from other state changes. The
updatedProperties array may be used directly via a back-reference in a subsequent Quota/get call in the same request,
so only these properties are returned if nothing else has changed.</t>
<t>Servers MAY decide to add other properties to the list that they judge changing frequently.</t>
</section>

<section anchor="quota-query"><name>Quota/query</name>
<t>This is a standard “/query” method as described in <xref target="RFC8620"></xref>, Section 5.5.</t>
<t>A <strong>FilterCondition</strong> object has the following properties, any of which may be omitted:</t>

<ul spacing="compact">
<li>name: &quot;String&quot;</li>
</ul>
<ul empty="true"><li>The Quota <em>name</em> property contains the given string.</li></ul>

<ul spacing="compact">
<li>scopes: &quot;Scope[]&quot;</li>
</ul>
<ul empty="true"><li>The Quota <em>scope</em> property must be in this list to match the condition.</li></ul>

<ul spacing="compact">
<li>resourceTypes: &quot;ResourceType[]&quot;</li>
</ul>
<ul empty="true"><li>The Quota <em>resourceType</em> property must be in this list to match the condition.</li></ul>

<ul spacing="compact">
<li>dataTypes: &quot;String[]&quot;</li>
</ul>
<ul empty="true"><li>The Quota <em>dataTypes</em> property must contain the elements in this list to match the condition.</li></ul>
<t>A Quota object matches the FilterCondition if and only if all of the given conditions match. If zero properties are
specified, it is automatically true for all objects.</t>
<t>The following Quota properties MUST be supported for sorting:</t>

<ul spacing="compact">
<li>name</li>
<li>used</li>
</ul>
</section>

<section anchor="quota-querychanges"><name>Quota/queryChanges</name>
<t>This is a standard “/queryChanges” method as described in <xref target="RFC8620"></xref>, Section 5.6.</t>
</section>

<section anchor="examples"><name>Examples</name>

<section anchor="fetching-quotas"><name>Fetching quotas</name>
<t>Request fetching all quotas related to an account :</t>

<artwork>[[ &quot;Quota/get&quot;, {
  &quot;accountId&quot;: &quot;u33084183&quot;,
  &quot;ids&quot;: null
}, &quot;0&quot; ]]
</artwork>
<t>With response :</t>

<artwork>[[ &quot;Quota/get&quot;, {
  &quot;accountId&quot;: &quot;u33084183&quot;,
  &quot;state&quot;: &quot;78540&quot;,
  &quot;list&quot;: [{
    &quot;id&quot;: &quot;2a06df0d-9865-4e74-a92f-74dcc814270e&quot;,
    &quot;resourceType&quot;: &quot;count&quot;,
    &quot;used&quot;: 1056,
    &quot;warnLimit&quot;: 1600,
    &quot;softLimit&quot;: 1800,
    &quot;limit&quot;: 2000,
    &quot;scope&quot;: &quot;account&quot;,
    &quot;name&quot;: &quot;bob@example.com&quot;,
    &quot;description&quot;: &quot;Personal account usage&quot;,
    &quot;dataTypes&quot; : [ &quot;Mail&quot;, &quot;Calendar&quot;, &quot;Contact&quot; ]
  }, {
    &quot;id&quot;: &quot;3b06df0e-3761-4s74-a92f-74dcc963501x&quot;,
    &quot;resourceType&quot;: &quot;octets&quot;,
    ...
  }, ...],
  &quot;notFound&quot;: []
}, &quot;0&quot; ]]
</artwork>
</section>

<section anchor="requesting-latest-quota-changes"><name>Requesting latest quota changes</name>
<t>Request fetching the changes for a specific quota:</t>

<artwork>[[ &quot;Quota/changes&quot;, {
  &quot;accountId&quot;: &quot;u33084183&quot;,
  &quot;sinceState&quot;: &quot;10824&quot;,
  &quot;maxChanges&quot;: 20,
  &quot;updatedProperties&quot;: [&quot;used&quot;]
}, &quot;0&quot; ],
[ &quot;Quota/get&quot;, {
  &quot;accountId&quot;: &quot;u33084183&quot;,
  &quot;#ids&quot;: {
    &quot;resultOf&quot;: &quot;0&quot;,
    &quot;name&quot;: &quot;Quota/changes&quot;,
    &quot;path&quot;: &quot;/updated&quot;
  },
  &quot;#properties&quot;: {
    &quot;resultOf&quot;: &quot;0&quot;,
    &quot;name&quot;: &quot;Quota/changes&quot;,
    &quot;path&quot;: &quot;/updatedProperties&quot;
  }
}, &quot;1&quot; ]]
</artwork>
<t>With response:</t>

<artwork>[[ &quot;Quota/changes&quot;, {
  &quot;accountId&quot;: &quot;u33084183&quot;,
  &quot;oldState&quot;: &quot;10824&quot;,
  &quot;newState&quot;: &quot;10826&quot;,
  &quot;hasMoreChanges&quot;: false,
  &quot;created&quot;: [],
  &quot;updated&quot;: [&quot;2a06df0d-9865-4e74-a92f-74dcc814270e&quot;],
  &quot;destroyed&quot;: []
}, &quot;0&quot; ],
[ &quot;Quota/get&quot;, {
  &quot;accountId&quot;: &quot;u33084183&quot;,
  &quot;state&quot;: &quot;10826&quot;,
  &quot;list&quot;: [{
    &quot;id&quot;: &quot;2a06df0d-9865-4e74-a92f-74dcc814270e&quot;,
    &quot;used&quot;: 1246
  }],
  &quot;notFound&quot;: []
}, &quot;1&quot; ]]
</artwork>
</section>
</section>
</section>

<section anchor="security-considerations"><name>Security considerations</name>
<t>All security considerations of JMAP (<xref target="RFC8620"></xref>) apply to this specification.</t>
<t>Implementors should be careful to make sure the implementation of that extension does not violate the site's security policy.
The resource usage of other users is likely to be considered confidential information and should not be divulged to
unauthorized persons.</t>
<t>As for any resource shared across users (for example, a quota with the &quot;domain&quot; or &quot;global&quot; scope), a user that can consume
the resource can affect the resources available to the other users. For example, a user could spam himself with events and
make the shared resource hit the limit and unusable for others (implementors could mitigate that with some rate limiting
implementation on the server).</t>
</section>

<section anchor="iana-considerations"><name>IANA Considerations</name>

<section anchor="jmap-capability-registration-for-quota"><name>JMAP Capability Registration for &quot;quota&quot;</name>
<t>IANA will register the &quot;quota&quot; JMAP Capability as follows:</t>
<t>Capability Name: &quot;urn:ietf:params:jmap:quota&quot;</t>
<t>Specification document: this document</t>
<t>Intended use: common</t>
<t>Change Controller: IETF</t>
<t>Security and privacy considerations: this document, section 3.</t>
</section>
</section>

</middle>

<back>
<references><name>Normative References</name>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.2119.xml"/>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8174.xml"/>
<xi:include href="https://xml2rfc.ietf.org/public/rfc/bibxml/reference.RFC.8620.xml"/>
</references>

</back>

</rfc>
