sync-collection for client
This commit is contained in:
@@ -190,3 +190,25 @@ func (c *Client) Options(path string) (classes map[string]bool, methods map[stri
|
||||
methods = parseCommaSeparatedSet(resp.Header["Allow"], true)
|
||||
return classes, methods, nil
|
||||
}
|
||||
|
||||
// SyncCollection perform a `sync-collection` REPORT operation on a resource
|
||||
func (c *Client) SyncCollection(path, syncToken string, level Depth, limit *Limit, prop *Prop) (*Multistatus, error) {
|
||||
q := SyncCollectionQuery{
|
||||
SyncToken: syncToken,
|
||||
SyncLevel: string(level),
|
||||
Limit: limit,
|
||||
Prop: prop,
|
||||
}
|
||||
|
||||
req, err := c.NewXMLRequest("REPORT", path, &q)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ms, err := c.DoMultiStatus(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return ms, nil
|
||||
}
|
||||
|
@@ -93,6 +93,7 @@ type Multistatus struct {
|
||||
XMLName xml.Name `xml:"DAV: multistatus"`
|
||||
Responses []Response `xml:"response"`
|
||||
ResponseDescription string `xml:"responsedescription,omitempty"`
|
||||
SyncToken string `xml:"sync-token,omitempty"`
|
||||
}
|
||||
|
||||
func NewMultistatus(resps ...Response) *Multistatus {
|
||||
@@ -396,3 +397,18 @@ type Set struct {
|
||||
XMLName xml.Name `xml:"DAV: set"`
|
||||
Prop Prop `xml:"prop"`
|
||||
}
|
||||
|
||||
// https://tools.ietf.org/html/rfc6578#section-6.1
|
||||
type SyncCollectionQuery struct {
|
||||
XMLName xml.Name `xml:"DAV: sync-collection"`
|
||||
SyncToken string `xml:"sync-token"`
|
||||
Limit *Limit `xml:"limit,omitempty"`
|
||||
SyncLevel string `xml:"sync-level"`
|
||||
Prop *Prop `xml:"prop"`
|
||||
}
|
||||
|
||||
// https://tools.ietf.org/html/rfc5323#section-5.17
|
||||
type Limit struct {
|
||||
XMLName xml.Name `xml:"DAV: limit"`
|
||||
NResults uint `xml:"nresults"`
|
||||
}
|
||||
|
Reference in New Issue
Block a user