mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-02-11 14:39:09 -06:00
* add example generator infrastructure, with some examples for pkg/jmap and pkg/groupware, with more needing to be done * alter the apidoc Makefile to stop using go-swagger but, instead, use the openapi.yml file that must be dropped into that directory using groupware-apidocs (will improve the integration there later) * add Makefile target to generate examples * bump redocly from 2.4.0 to 2.14.5 * introduce Request.PathParam() and .PathParamDoc() to improve API documentation, as well as future-proofing * improve X-Request-ID and Trace-Id header handling in the middleware by logging it safely when an error occurs in the middleware
36 lines
1.3 KiB
Go
36 lines
1.3 KiB
Go
package jmap
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/opencloud-eu/opencloud/pkg/log"
|
|
"github.com/opencloud-eu/opencloud/pkg/structs"
|
|
)
|
|
|
|
func (j *Client) GetQuotas(accountIds []string, session *Session, ctx context.Context, logger *log.Logger, acceptLanguage string) (map[string]QuotaGetResponse, SessionState, State, Language, Error) {
|
|
logger = j.logger("GetQuotas", session, logger)
|
|
|
|
uniqueAccountIds := structs.Uniq(accountIds)
|
|
|
|
invocations := make([]Invocation, len(uniqueAccountIds))
|
|
for i, accountId := range uniqueAccountIds {
|
|
invocations[i] = invocation(CommandQuotaGet, QuotaGetCommand{AccountId: accountId}, mcid(accountId, "0"))
|
|
}
|
|
cmd, err := j.request(session, logger, invocations...)
|
|
if err != nil {
|
|
return nil, "", "", "", err
|
|
}
|
|
return command(j.api, logger, ctx, session, j.onSessionOutdated, cmd, acceptLanguage, func(body *Response) (map[string]QuotaGetResponse, State, Error) {
|
|
result := map[string]QuotaGetResponse{}
|
|
for _, accountId := range uniqueAccountIds {
|
|
var response QuotaGetResponse
|
|
err = retrieveResponseMatchParameters(logger, body, CommandQuotaGet, mcid(accountId, "0"), &response)
|
|
if err != nil {
|
|
return nil, "", err
|
|
}
|
|
result[accountId] = response
|
|
}
|
|
return result, squashStateFunc(result, func(q QuotaGetResponse) State { return q.State }), nil
|
|
})
|
|
}
|