quota

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package quota implements JMAP Quotas (RFC 9425).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register()

Register registers the Quota capability and all Quota methods. Must be called before using these types.

Types

type Capability

type Capability struct{}

Capability represents the urn:ietf:params:jmap:quota capability (RFC 9425). It has no configuration fields.

func (*Capability) New

func (c *Capability) New() jmap.Capability

New implements jmap.Capability.

func (*Capability) URI

func (c *Capability) URI() jmap.URI

URI implements jmap.Capability.

type Changes

type Changes struct {
	// AccountID is the account to query.
	AccountID jmap.ID `json:"accountId"`

	// SinceState is the state string from a previous response.
	SinceState string `json:"sinceState"`

	// MaxChanges is the maximum number of changed IDs to return.
	MaxChanges *uint64 `json:"maxChanges,omitempty"`
}

Changes is the Quota/changes method (RFC 9425 Section 2.2).

func (*Changes) Name

func (m *Changes) Name() string

Name implements jmap.Method.

func (*Changes) Requires

func (m *Changes) Requires() []jmap.URI

Requires implements jmap.Method.

type ChangesResponse

type ChangesResponse struct {
	// AccountID is the account this response is for.
	AccountID jmap.ID `json:"accountId"`

	// OldState is the state string supplied by the client.
	OldState string `json:"oldState"`

	// NewState is the current state string after the changes.
	NewState string `json:"newState"`

	// HasMoreChanges indicates if there are more changes to fetch.
	HasMoreChanges bool `json:"hasMoreChanges"`

	// Created contains IDs of quotas created since the old state.
	Created []jmap.ID `json:"created"`

	// Updated contains IDs of quotas updated since the old state.
	Updated []jmap.ID `json:"updated"`

	// Destroyed contains IDs of quotas destroyed since the old state.
	Destroyed []jmap.ID `json:"destroyed"`
}

ChangesResponse is the response to Quota/changes.

func (*ChangesResponse) Name

func (r *ChangesResponse) Name() string

Name implements jmap.MethodResponse.

type Filter

type Filter struct {
	// Name filters by quota name (substring match).
	Name *string `json:"name,omitempty"`

	// Scope filters by scope value.
	Scope *string `json:"scope,omitempty"`

	// ResourceType filters by resource type.
	ResourceType *string `json:"resourceType,omitempty"`
}

Filter is a filter for Quota/query (RFC 9425 Section 3).

type Get

type Get struct {
	// AccountID is the account to query.
	AccountID jmap.ID `json:"accountId"`

	// IDs is the list of Quota IDs to retrieve. If nil, all are returned.
	IDs []jmap.ID `json:"ids,omitempty"`

	// Properties lists the properties to include. If nil, all are returned.
	Properties []string `json:"properties,omitempty"`
}

Get is the Quota/get method (RFC 9425 Section 2.1).

func (*Get) Name

func (m *Get) Name() string

Name implements jmap.Method.

func (*Get) Requires

func (m *Get) Requires() []jmap.URI

Requires implements jmap.Method.

type GetResponse

type GetResponse struct {
	// AccountID is the account this response is for.
	AccountID jmap.ID `json:"accountId"`

	// State is the current state string for this data type.
	State string `json:"state"`

	// List contains the requested Quota objects.
	List []*Quota `json:"list"`

	// NotFound contains IDs that were not found.
	NotFound []jmap.ID `json:"notFound"`
}

GetResponse is the response to Quota/get.

func (*GetResponse) Name

func (r *GetResponse) Name() string

Name implements jmap.MethodResponse.

type Query

type Query struct {
	// AccountID is the account to query.
	AccountID jmap.ID `json:"accountId"`

	// Filter specifies conditions for the query.
	Filter *Filter `json:"filter,omitempty"`

	// Sort specifies the sort order for results.
	Sort []*Sort `json:"sort,omitempty"`

	// Position is the zero-based index of the first result to return.
	Position int64 `json:"position,omitempty"`

	// Anchor is the ID of an item to use as the position reference.
	Anchor *jmap.ID `json:"anchor,omitempty"`

	// AnchorOffset is the offset from the anchor to the first result.
	AnchorOffset int64 `json:"anchorOffset,omitempty"`

	// Limit is the maximum number of results to return.
	Limit *uint64 `json:"limit,omitempty"`

	// CalculateTotal requests the server include a total count.
	CalculateTotal bool `json:"calculateTotal,omitempty"`
}

Query is the Quota/query method (RFC 9425 Section 2.3).

func (*Query) Name

func (m *Query) Name() string

Name implements jmap.Method.

func (*Query) Requires

func (m *Query) Requires() []jmap.URI

Requires implements jmap.Method.

type QueryChanges

type QueryChanges struct {
	// AccountID is the account to query.
	AccountID jmap.ID `json:"accountId"`

	// Filter specifies conditions for the query.
	Filter *Filter `json:"filter,omitempty"`

	// Sort specifies the sort order for results.
	Sort []*Sort `json:"sort,omitempty"`

	// SinceQueryState is the query state from a previous Quota/query response.
	SinceQueryState string `json:"sinceQueryState"`

	// MaxChanges is the maximum number of changes to return.
	MaxChanges *uint64 `json:"maxChanges,omitempty"`

	// UpToID limits changes to those up to and including this ID.
	UpToID *jmap.ID `json:"upToId,omitempty"`

	// CalculateTotal requests the server include a total count.
	CalculateTotal bool `json:"calculateTotal,omitempty"`
}

QueryChanges is the Quota/queryChanges method (RFC 9425 Section 2.4).

func (*QueryChanges) Name

func (m *QueryChanges) Name() string

Name implements jmap.Method.

func (*QueryChanges) Requires

func (m *QueryChanges) Requires() []jmap.URI

Requires implements jmap.Method.

type QueryChangesResponse

type QueryChangesResponse struct {
	// AccountID is the account this response is for.
	AccountID jmap.ID `json:"accountId"`

	// OldQueryState is the query state supplied by the client.
	OldQueryState string `json:"oldQueryState"`

	// NewQueryState is the current query state.
	NewQueryState string `json:"newQueryState"`

	// Removed contains IDs removed from the query results.
	Removed []jmap.ID `json:"removed"`

	// Added contains items added to the query results with their positions.
	Added []jmap.AddedItem `json:"added"`

	// Total is the total number of matching results, if requested.
	Total *uint64 `json:"total,omitempty"`
}

QueryChangesResponse is the response to Quota/queryChanges.

func (*QueryChangesResponse) Name

func (r *QueryChangesResponse) Name() string

Name implements jmap.MethodResponse.

type QueryResponse

type QueryResponse struct {
	// AccountID is the account this response is for.
	AccountID jmap.ID `json:"accountId"`

	// QueryState is the current state of the query.
	QueryState string `json:"queryState"`

	// CanCalculateChanges indicates if the server supports queryChanges.
	CanCalculateChanges bool `json:"canCalculateChanges"`

	// Position is the zero-based index of the first result returned.
	Position uint64 `json:"position"`

	// IDs contains the IDs of the matching Quota objects.
	IDs []jmap.ID `json:"ids"`

	// Total is the total number of matching results, if requested.
	Total *uint64 `json:"total,omitempty"`

	// Limit is the limit that was applied to the query.
	Limit *uint64 `json:"limit,omitempty"`
}

QueryResponse is the response to Quota/query.

func (*QueryResponse) Name

func (r *QueryResponse) Name() string

Name implements jmap.MethodResponse.

type Quota

type Quota struct {
	// ID is the server-assigned identifier for this quota.
	ID jmap.ID `json:"id"`

	// ResourceType is the resource being limited: "count" or "octets".
	ResourceType string `json:"resourceType"`

	// Used is the current usage of the resource.
	Used uint64 `json:"used"`

	// HardLimit is the absolute maximum usage allowed.
	HardLimit uint64 `json:"hardLimit"`

	// Scope is "account" or "global".
	Scope string `json:"scope"`

	// Name is a human-readable description of the quota.
	Name string `json:"name"`

	// Description is an optional longer description of the quota.
	Description *string `json:"description,omitempty"`

	// Types lists the data types this quota applies to, e.g. ["Mail", "Calendar"].
	Types []string `json:"types,omitempty"`

	// WarnLimit is the usage level at which a warning should be issued.
	WarnLimit *uint64 `json:"warnLimit,omitempty"`

	// SoftLimit is the usage level at which the server may start rejecting.
	SoftLimit *uint64 `json:"softLimit,omitempty"`
}

Quota represents a JMAP Quota object (RFC 9425 Section 2).

type Sort

type Sort struct {
	// Property is the Quota property to sort by.
	Property string `json:"property"`

	// IsAscending controls sort direction. Default is true.
	IsAscending *bool `json:"isAscending,omitempty"`
}

Sort defines the sort order for Quota/query results.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL