mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-07-13 09:02:09 -04:00
* refactor APIs in JMAP and Groupware in order to implement pagination across multiple accountIds and multiple suppliers (currently implemented using a mock supplier for contacts) * requires go 1.26 due to use of self-reflecting generics type constraints * still missing: query criteria and sorting parameters * still missing: multi-accountId support for emails * errors are now all just 'error' in the APIs, instead of the specialized implementations, and are interpreted dynamically where necessary in order to transform them into HTTP responses * remove position, anchor, anchorOffset as individual query parameters as we now only support a 'next=...' token for subsequent pages (except in emails for now), and use jmap.QueryParams instead; those tokens have a header character for the format, followed by a JSON encoded QueryParams map, all wrapped into base62 to make it clearer that it is meant to be an opaque token, and not a parameter clients should tinker with or construct themselves * introduce QueryParamsSupplier as an interface to provide QueryParams for various scenarios (single supplier, multiple supplier, ...) per accountId * implement multi-supplier template methods slist and squery
97 lines
2.9 KiB
Go
97 lines
2.9 KiB
Go
package jmap
|
|
|
|
var NS_QUOTA = ns(JmapQuota)
|
|
|
|
func (j *Client) GetQuotas(accountIds []string, ctx Context) (Result[map[string]QuotaGetResponse], error) {
|
|
return getN(j, "GetQuotas", QuotaType,
|
|
func(accountId string, ids []string) QuotaGetCommand {
|
|
return QuotaGetCommand{AccountId: accountId}
|
|
},
|
|
QuotaGetResponse{},
|
|
identity1,
|
|
identity1,
|
|
accountIds, []string{},
|
|
ctx,
|
|
)
|
|
}
|
|
|
|
type QuotaChanges ChangesTemplate[Quota]
|
|
|
|
var _ Changes[Quota] = QuotaChanges{}
|
|
|
|
func (c QuotaChanges) GetHasMoreChanges() bool { return c.HasMoreChanges }
|
|
func (c QuotaChanges) GetOldState() State { return c.OldState }
|
|
func (c QuotaChanges) GetNewState() State { return c.NewState }
|
|
func (c QuotaChanges) GetCreated() []Quota { return c.Created }
|
|
func (c QuotaChanges) GetUpdated() []Quota { return c.Updated }
|
|
func (c QuotaChanges) GetDestroyed() []string { return c.Destroyed }
|
|
|
|
// Retrieve the changes in Quotas since a given State.
|
|
// @api:tags quota,changes
|
|
func (j *Client) GetQuotaChanges(accountId string, sinceState State, maxChanges uint,
|
|
ctx Context) (Result[QuotaChanges], error) {
|
|
return changesA(j, "GetQuotaChanges", QuotaType,
|
|
func() QuotaChangesCommand {
|
|
return QuotaChangesCommand{AccountId: accountId, SinceState: sinceState, MaxChanges: uintPtr(maxChanges)}
|
|
},
|
|
QuotaChangesResponse{},
|
|
QuotaGetResponse{},
|
|
func(path string, rof string) QuotaGetRefCommand {
|
|
return QuotaGetRefCommand{
|
|
AccountId: accountId,
|
|
IdsRef: &ResultReference{
|
|
Name: CommandQuotaChanges,
|
|
Path: path,
|
|
ResultOf: rof,
|
|
},
|
|
}
|
|
},
|
|
func(oldState, newState State, hasMoreChanges bool, created, updated []Quota, destroyed []string) QuotaChanges {
|
|
return QuotaChanges{
|
|
OldState: oldState,
|
|
NewState: newState,
|
|
HasMoreChanges: hasMoreChanges,
|
|
Created: created,
|
|
Updated: updated,
|
|
Destroyed: destroyed,
|
|
}
|
|
},
|
|
ctx,
|
|
)
|
|
}
|
|
|
|
func (j *Client) GetQuotaUsageChanges(accountId string, sinceState State, maxChanges uint,
|
|
ctx Context) (Result[QuotaChanges], error) {
|
|
return updates(j, "GetQuotaUsageChanges", QuotaType,
|
|
func() QuotaChangesCommand {
|
|
return QuotaChangesCommand{AccountId: accountId, SinceState: sinceState, MaxChanges: uintPtr(maxChanges)}
|
|
},
|
|
QuotaChangesResponse{},
|
|
func(path string, rof string) QuotaGetRefCommand {
|
|
return QuotaGetRefCommand{
|
|
AccountId: accountId,
|
|
IdsRef: &ResultReference{
|
|
Name: CommandQuotaChanges,
|
|
Path: path,
|
|
ResultOf: rof,
|
|
},
|
|
PropertiesRef: &ResultReference{
|
|
Name: CommandQuotaChanges,
|
|
Path: "/updatedProperties",
|
|
ResultOf: rof,
|
|
},
|
|
}
|
|
},
|
|
func(resp QuotaGetResponse) []Quota { return resp.List },
|
|
func(oldState, newState State, hasMoreChanges bool, updated []Quota) QuotaChanges {
|
|
return QuotaChanges{
|
|
OldState: oldState,
|
|
NewState: newState,
|
|
HasMoreChanges: hasMoreChanges,
|
|
Updated: updated,
|
|
}
|
|
},
|
|
ctx,
|
|
)
|
|
}
|