mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-04-06 00:23:53 -04:00
* add Groupware APIs for creating and deleting addressbooks * add Groupware APIs for creating and deleting calendars * add JMAP APIs for creating and deleting addressbooks, calendars * add JMAP APIs to retrieve Principals * fix API tagging * move addressbook JMAP APIs into its own file * move addressbook Groupware APIs into its own file
38 lines
1.2 KiB
Go
38 lines
1.2 KiB
Go
package jmap
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/opencloud-eu/opencloud/pkg/log"
|
|
)
|
|
|
|
var NS_PRINCIPALS = ns(JmapPrincipals)
|
|
|
|
type PrincipalsResponse struct {
|
|
Principals []Principal `json:"principals"`
|
|
NotFound []string `json:"notFound,omitempty"`
|
|
}
|
|
|
|
func (j *Client) GetPrincipals(accountId string, session *Session, ctx context.Context, logger *log.Logger, acceptLanguage string, ids []string) (PrincipalsResponse, SessionState, State, Language, Error) {
|
|
logger = j.logger("GetPrincipals", session, logger)
|
|
|
|
cmd, err := j.request(session, logger, NS_PRINCIPALS,
|
|
invocation(CommandPrincipalGet, PrincipalGetCommand{AccountId: accountId, Ids: ids}, "0"),
|
|
)
|
|
if err != nil {
|
|
return PrincipalsResponse{}, "", "", "", err
|
|
}
|
|
|
|
return command(j.api, logger, ctx, session, j.onSessionOutdated, cmd, acceptLanguage, func(body *Response) (PrincipalsResponse, State, Error) {
|
|
var response PrincipalGetResponse
|
|
err = retrieveResponseMatchParameters(logger, body, CommandPrincipalGet, "0", &response)
|
|
if err != nil {
|
|
return PrincipalsResponse{}, response.State, err
|
|
}
|
|
return PrincipalsResponse{
|
|
Principals: response.List,
|
|
NotFound: response.NotFound,
|
|
}, response.State, nil
|
|
})
|
|
}
|