Documentation
¶
Overview ¶
Package sharing implements the JMAP Sharing protocol (RFC 9670), providing Principal and ShareNotification data types and methods.
Index ¶
- func Register()
- type Capability
- type Principal
- type PrincipalAccountAccess
- type PrincipalChanges
- type PrincipalChangesResponse
- type PrincipalFilter
- type PrincipalGet
- type PrincipalGetResponse
- type PrincipalQuery
- type PrincipalQueryChanges
- type PrincipalQueryChangesResponse
- type PrincipalQueryResponse
- type PrincipalSet
- type PrincipalSetResponse
- type PrincipalSort
- type ShareNotification
- type ShareNotificationCapability
- type ShareNotificationChanges
- type ShareNotificationChangesResponse
- type ShareNotificationGet
- type ShareNotificationGetResponse
- type ShareNotificationSender
- type ShareNotificationSet
- type ShareNotificationSetResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Capability ¶
type Capability struct{}
Capability represents the urn:ietf:params:jmap:principals capability (RFC 9670 Section 2).
type Principal ¶
type Principal struct {
// ID is the server-assigned identifier.
ID jmap.ID `json:"id"`
// Type is the kind of principal: "individual", "group", "resource",
// "location", or "other".
Type string `json:"type"`
// Name is the display name of the principal.
Name string `json:"name"`
// Description is a longer description of the principal.
Description *string `json:"description,omitempty"`
// Email is the email address of the principal.
Email *string `json:"email,omitempty"`
// TimeZone is the IANA time zone identifier for the principal.
TimeZone *string `json:"timeZone,omitempty"`
// Capabilities maps capability URIs to capability-specific data.
Capabilities map[jmap.URI]any `json:"capabilities,omitempty"`
// Accounts maps account IDs to their access details.
Accounts map[jmap.ID]*PrincipalAccountAccess `json:"accounts,omitempty"`
}
Principal represents a JMAP Principal object (RFC 9670 Section 3). A Principal represents an individual, group, resource, location, or other entity in a collaborative system.
type PrincipalAccountAccess ¶
type PrincipalAccountAccess struct {
// AccountID is the ID of the account.
AccountID jmap.ID `json:"accountId"`
// IsPersonal indicates whether this is the principal's own account.
IsPersonal bool `json:"isPersonal"`
// IsReadOnly indicates whether the principal has read-only access.
IsReadOnly bool `json:"isReadOnly"`
}
PrincipalAccountAccess describes a principal's access to an account.
type PrincipalChanges ¶
type PrincipalChanges struct {
// AccountID is the account to query.
AccountID jmap.ID `json:"accountId"`
// SinceState is the state to compare against.
SinceState string `json:"sinceState"`
// MaxChanges is the maximum number of changes to return.
MaxChanges *uint64 `json:"maxChanges,omitempty"`
}
PrincipalChanges retrieves changes to Principals since a given state (RFC 9670 Section 3).
func (*PrincipalChanges) Name ¶
func (m *PrincipalChanges) Name() string
Name implements jmap.Method.
func (*PrincipalChanges) Requires ¶
func (m *PrincipalChanges) Requires() []jmap.URI
Requires implements jmap.Method.
type PrincipalChangesResponse ¶
type PrincipalChangesResponse struct {
// OldState is the state before the changes.
OldState string `json:"oldState"`
// NewState is the state after the changes.
NewState string `json:"newState"`
// HasMoreChanges indicates whether there are more changes available.
HasMoreChanges bool `json:"hasMoreChanges"`
// Created contains IDs of Principals that were created.
Created []jmap.ID `json:"created,omitempty"`
// Updated contains IDs of Principals that were updated.
Updated []jmap.ID `json:"updated,omitempty"`
// Destroyed contains IDs of Principals that were destroyed.
Destroyed []jmap.ID `json:"destroyed,omitempty"`
}
PrincipalChangesResponse is the response to Principal/changes.
func (*PrincipalChangesResponse) Name ¶
func (r *PrincipalChangesResponse) Name() string
Name implements jmap.MethodResponse.
type PrincipalFilter ¶
type PrincipalFilter struct {
// Email filters by the principal's email address.
Email *string `json:"email,omitempty"`
// Name filters by the principal's name.
Name *string `json:"name,omitempty"`
// Type filters by the principal type.
Type *string `json:"type,omitempty"`
// TimeZone filters by the principal's time zone.
TimeZone *string `json:"timeZone,omitempty"`
}
PrincipalFilter is the filter criteria for Principal/query.
type PrincipalGet ¶
type PrincipalGet struct {
// AccountID is the account to query.
AccountID jmap.ID `json:"accountId"`
// IDs is the list of Principal IDs to retrieve. If nil, all are returned.
IDs []jmap.ID `json:"ids,omitempty"`
// Properties lists the properties to return. If nil, all are returned.
Properties []string `json:"properties,omitempty"`
}
PrincipalGet retrieves Principal objects (RFC 9670 Section 3).
func (*PrincipalGet) Requires ¶
func (m *PrincipalGet) Requires() []jmap.URI
Requires implements jmap.Method.
type PrincipalGetResponse ¶
type PrincipalGetResponse struct {
// State is the current state string for this type.
State string `json:"state"`
// List contains the requested Principal objects.
List []*Principal `json:"list,omitempty"`
// NotFound contains IDs that were not found.
NotFound []jmap.ID `json:"notFound,omitempty"`
}
PrincipalGetResponse is the response to Principal/get.
func (*PrincipalGetResponse) Name ¶
func (r *PrincipalGetResponse) Name() string
Name implements jmap.MethodResponse.
type PrincipalQuery ¶
type PrincipalQuery struct {
// AccountID is the account to query.
AccountID jmap.ID `json:"accountId"`
// Filter specifies the criteria to filter by.
Filter *PrincipalFilter `json:"filter,omitempty"`
// Sort specifies the sort order.
Sort []*PrincipalSort `json:"sort,omitempty"`
// Position is the zero-based index of the first result to return.
Position *int64 `json:"position,omitempty"`
// Anchor is an ID to use as the position reference.
Anchor *jmap.ID `json:"anchor,omitempty"`
// AnchorOffset is the offset from the anchor position.
AnchorOffset *int64 `json:"anchorOffset,omitempty"`
// Limit is the maximum number of results to return.
Limit *uint64 `json:"limit,omitempty"`
// CalculateTotal requests the server to calculate the total count.
CalculateTotal *bool `json:"calculateTotal,omitempty"`
}
PrincipalQuery searches for Principal IDs matching criteria (RFC 9670 Section 3).
func (*PrincipalQuery) Requires ¶
func (m *PrincipalQuery) Requires() []jmap.URI
Requires implements jmap.Method.
type PrincipalQueryChanges ¶
type PrincipalQueryChanges struct {
// AccountID is the account to query.
AccountID jmap.ID `json:"accountId"`
// Filter specifies the criteria used in the original query.
Filter *PrincipalFilter `json:"filter,omitempty"`
// Sort specifies the sort order used in the original query.
Sort []*PrincipalSort `json:"sort,omitempty"`
// SinceQueryState is the query state to compare against.
SinceQueryState string `json:"sinceQueryState"`
// MaxChanges is the maximum number of changes to return.
MaxChanges *uint64 `json:"maxChanges,omitempty"`
// UpToID limits results to changes up to this ID.
UpToID *jmap.ID `json:"upToId,omitempty"`
// CalculateTotal requests the server to calculate the total count.
CalculateTotal *bool `json:"calculateTotal,omitempty"`
}
PrincipalQueryChanges retrieves changes to a previous Principal/query result (RFC 9670 Section 3).
func (*PrincipalQueryChanges) Name ¶
func (m *PrincipalQueryChanges) Name() string
Name implements jmap.Method.
func (*PrincipalQueryChanges) Requires ¶
func (m *PrincipalQueryChanges) Requires() []jmap.URI
Requires implements jmap.Method.
type PrincipalQueryChangesResponse ¶
type PrincipalQueryChangesResponse struct {
// OldQueryState is the previous query state.
OldQueryState string `json:"oldQueryState"`
// NewQueryState is the new query state.
NewQueryState string `json:"newQueryState"`
// Removed contains IDs removed from the query results.
Removed []jmap.ID `json:"removed,omitempty"`
// Added contains items added to the query results.
Added []jmap.AddedItem `json:"added,omitempty"`
// Total is the total number of results, if calculated.
Total *uint64 `json:"total,omitempty"`
}
PrincipalQueryChangesResponse is the response to Principal/queryChanges.
func (*PrincipalQueryChangesResponse) Name ¶
func (r *PrincipalQueryChangesResponse) Name() string
Name implements jmap.MethodResponse.
type PrincipalQueryResponse ¶
type PrincipalQueryResponse struct {
// QueryState is the current query state.
QueryState string `json:"queryState"`
// CanCalculateChanges indicates whether the server supports
// Principal/queryChanges for this query.
CanCalculateChanges bool `json:"canCalculateChanges"`
// Position is the zero-based index of the first result.
Position uint64 `json:"position"`
// IDs contains the matching Principal IDs.
IDs []jmap.ID `json:"ids,omitempty"`
// Total is the total number of matching results, if calculated.
Total *uint64 `json:"total,omitempty"`
// Limit is the limit applied to the query.
Limit *uint64 `json:"limit,omitempty"`
}
PrincipalQueryResponse is the response to Principal/query.
func (*PrincipalQueryResponse) Name ¶
func (r *PrincipalQueryResponse) Name() string
Name implements jmap.MethodResponse.
type PrincipalSet ¶
type PrincipalSet struct {
// AccountID is the account to modify.
AccountID jmap.ID `json:"accountId"`
// IfInState only applies changes if the current state matches.
IfInState *string `json:"ifInState,omitempty"`
// Create maps creation IDs to Principal objects to create.
Create map[jmap.ID]*Principal `json:"create,omitempty"`
// Update maps Principal IDs to patch objects.
Update map[jmap.ID]*jmap.Patch `json:"update,omitempty"`
// Destroy is a list of Principal IDs to destroy.
Destroy []jmap.ID `json:"destroy,omitempty"`
}
PrincipalSet creates, updates, or destroys Principals (RFC 9670 Section 3).
func (*PrincipalSet) Requires ¶
func (m *PrincipalSet) Requires() []jmap.URI
Requires implements jmap.Method.
type PrincipalSetResponse ¶
type PrincipalSetResponse struct {
// OldState is the state before the changes.
OldState string `json:"oldState"`
// NewState is the state after the changes.
NewState string `json:"newState"`
// Created maps creation IDs to created Principal objects.
Created map[jmap.ID]*Principal `json:"created,omitempty"`
// Updated maps Principal IDs to updated Principal objects.
Updated map[jmap.ID]*Principal `json:"updated,omitempty"`
// Destroyed contains IDs of destroyed Principals.
Destroyed []jmap.ID `json:"destroyed,omitempty"`
// NotCreated maps creation IDs to errors.
NotCreated map[jmap.ID]*jmap.SetError `json:"notCreated,omitempty"`
// NotUpdated maps Principal IDs to errors.
NotUpdated map[jmap.ID]*jmap.SetError `json:"notUpdated,omitempty"`
// NotDestroyed maps Principal IDs to errors.
NotDestroyed map[jmap.ID]*jmap.SetError `json:"notDestroyed,omitempty"`
}
PrincipalSetResponse is the response to Principal/set.
func (*PrincipalSetResponse) Name ¶
func (r *PrincipalSetResponse) Name() string
Name implements jmap.MethodResponse.
type PrincipalSort ¶
type PrincipalSort struct {
// Property is the property name to sort by.
Property string `json:"property"`
// IsAscending determines the sort direction. Default is true.
IsAscending *bool `json:"isAscending,omitempty"`
}
PrincipalSort defines the sort criteria for Principal/query.
type ShareNotification ¶
type ShareNotification struct {
ID jmap.ID `json:"id"`
Type string `json:"@type"`
Created string `json:"created"`
ChangedBy *ShareNotificationSender `json:"changedBy,omitempty"`
ObjectType string `json:"objectType"`
ObjectAccountID jmap.ID `json:"objectAccountId"`
ObjectID jmap.ID `json:"objectId"`
Name string `json:"name"`
OldRights map[string]bool `json:"oldRights,omitempty"`
NewRights map[string]bool `json:"newRights,omitempty"`
}
ShareNotification represents a notification about a sharing change (RFC 9670 Section 4).
type ShareNotificationCapability ¶
type ShareNotificationCapability struct{}
ShareNotificationCapability represents the urn:ietf:params:jmap:principals:owner capability (RFC 9670 Section 2).
func (*ShareNotificationCapability) New ¶
func (c *ShareNotificationCapability) New() jmap.Capability
New implements jmap.Capability.
func (*ShareNotificationCapability) URI ¶
func (c *ShareNotificationCapability) URI() jmap.URI
URI implements jmap.Capability.
type ShareNotificationChanges ¶
type ShareNotificationChanges struct {
AccountID jmap.ID `json:"accountId"`
SinceState string `json:"sinceState"`
MaxChanges *uint64 `json:"maxChanges,omitempty"`
}
ShareNotificationChanges retrieves changes to ShareNotifications since a given state (RFC 9670 Section 4).
func (*ShareNotificationChanges) Name ¶
func (m *ShareNotificationChanges) Name() string
Name implements jmap.Method.
func (*ShareNotificationChanges) Requires ¶
func (m *ShareNotificationChanges) Requires() []jmap.URI
Requires implements jmap.Method.
type ShareNotificationChangesResponse ¶
type ShareNotificationChangesResponse struct {
OldState string `json:"oldState"`
NewState string `json:"newState"`
HasMoreChanges bool `json:"hasMoreChanges"`
Created []jmap.ID `json:"created,omitempty"`
Updated []jmap.ID `json:"updated,omitempty"`
Destroyed []jmap.ID `json:"destroyed,omitempty"`
}
ShareNotificationChangesResponse is the response to ShareNotification/changes.
func (*ShareNotificationChangesResponse) Name ¶
func (r *ShareNotificationChangesResponse) Name() string
Name implements jmap.MethodResponse.
type ShareNotificationGet ¶
type ShareNotificationGet struct {
AccountID jmap.ID `json:"accountId"`
// If nil, all are returned.
IDs []jmap.ID `json:"ids,omitempty"`
Properties []string `json:"properties,omitempty"`
}
ShareNotificationGet retrieves ShareNotification objects (RFC 9670 Section 4).
func (*ShareNotificationGet) Name ¶
func (m *ShareNotificationGet) Name() string
Name implements jmap.Method.
func (*ShareNotificationGet) Requires ¶
func (m *ShareNotificationGet) Requires() []jmap.URI
Requires implements jmap.Method.
type ShareNotificationGetResponse ¶
type ShareNotificationGetResponse struct {
State string `json:"state"`
List []*ShareNotification `json:"list,omitempty"`
NotFound []jmap.ID `json:"notFound,omitempty"`
}
ShareNotificationGetResponse is the response to ShareNotification/get.
func (*ShareNotificationGetResponse) Name ¶
func (r *ShareNotificationGetResponse) Name() string
Name implements jmap.MethodResponse.
type ShareNotificationSender ¶
type ShareNotificationSender struct {
Name string `json:"name"`
Email *string `json:"email,omitempty"`
PrincipalID *jmap.ID `json:"principalId,omitempty"`
}
ShareNotificationSender identifies who made a sharing change.
type ShareNotificationSet ¶
type ShareNotificationSet struct {
AccountID jmap.ID `json:"accountId"`
IfInState *string `json:"ifInState,omitempty"`
Destroy []jmap.ID `json:"destroy,omitempty"`
}
ShareNotificationSet destroys ShareNotification objects (RFC 9670 Section 4). ShareNotifications can only be destroyed, not created or updated by clients.
func (*ShareNotificationSet) Name ¶
func (m *ShareNotificationSet) Name() string
Name implements jmap.Method.
func (*ShareNotificationSet) Requires ¶
func (m *ShareNotificationSet) Requires() []jmap.URI
Requires implements jmap.Method.
type ShareNotificationSetResponse ¶
type ShareNotificationSetResponse struct {
OldState string `json:"oldState"`
NewState string `json:"newState"`
Destroyed []jmap.ID `json:"destroyed,omitempty"`
NotDestroyed map[jmap.ID]*jmap.SetError `json:"notDestroyed,omitempty"`
}
ShareNotificationSetResponse is the response to ShareNotification/set.
func (*ShareNotificationSetResponse) Name ¶
func (r *ShareNotificationSetResponse) Name() string
Name implements jmap.MethodResponse.