internal

package
v0.4.26 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 8, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const Namespace = "DAV:"

Variables

View Source
var (
	ResourceTypeName     = xml.Name{Namespace, "resourcetype"}
	DisplayNameName      = xml.Name{Namespace, "displayname"}
	GetContentLengthName = xml.Name{Namespace, "getcontentlength"}
	GetContentTypeName   = xml.Name{Namespace, "getcontenttype"}
	GetLastModifiedName  = xml.Name{Namespace, "getlastmodified"}
	GetETagName          = xml.Name{Namespace, "getetag"}

	CurrentUserPrincipalName = xml.Name{Namespace, "current-user-principal"}
)
View Source
var CollectionName = xml.Name{Namespace, "collection"}

Functions

func DiscoverContextURL

func DiscoverContextURL(ctx context.Context, service, domain string) (string, error)

DiscoverContextURL performs a DNS-based CardDAV/CalDAV service discovery as described in RFC 6352 section 11. It returns the URL to the CardDAV server.

func FormatOverwrite

func FormatOverwrite(overwrite bool) string

FormatOverwrite formats an Overwrite header.

func IsNotFound

func IsNotFound(err error) bool

func ParseOverwrite

func ParseOverwrite(s string) (bool, error)

ParseOverwrite parses an Overwrite header.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func NewClient

func NewClient(c HTTPClient, endpoint string) (*Client, error)

func (*Client) Do

func (c *Client) Do(req *http.Request) (*http.Response, error)

func (*Client) DoMultiStatus

func (c *Client) DoMultiStatus(req *http.Request) (*MultiStatus, error)

func (*Client) NewRequest

func (c *Client) NewRequest(method string, path string, body io.Reader) (*http.Request, error)

func (*Client) NewXMLRequest

func (c *Client) NewXMLRequest(method string, path string, v interface{}) (*http.Request, error)

func (*Client) Options

func (c *Client) Options(ctx context.Context, path string) (classes map[string]bool, methods map[string]bool, err error)

func (*Client) PropFind

func (c *Client) PropFind(ctx context.Context, path string, depth Depth, propfind *PropFind) (*MultiStatus, error)

func (*Client) PropFindFlat

func (c *Client) PropFindFlat(ctx context.Context, path string, propfind *PropFind) (*Response, error)

PropfindFlat performs a PROPFIND request with a zero depth.

func (*Client) PropUpdate

func (c *Client) PropUpdate(ctx context.Context, path string, propupd *PropertyUpdate) (*MultiStatus, error)

func (*Client) ResolveHref

func (c *Client) ResolveHref(p string) *url.URL

func (*Client) SyncCollection

func (c *Client) SyncCollection(ctx context.Context, path, syncToken string, level Depth, limit *Limit, prop *Prop) (*MultiStatus, error)

SyncCollection perform a `sync-collection` REPORT operation on a resource

func (*Client) Touch

func (c *Client) Touch(ctx context.Context, path string, mtime time.Time) (*MultiStatus, error)

type CurrentUserPrincipal

type CurrentUserPrincipal struct {
	XMLName         xml.Name  `xml:"DAV: current-user-principal"`
	Href            Href      `xml:"href,omitempty"`
	Unauthenticated *struct{} `xml:"unauthenticated,omitempty"`
}

https://tools.ietf.org/html/rfc5397#section-3

type Depth

type Depth int

Depth indicates whether a request applies to the resource's members. It's defined in RFC 4918 section 10.2.

const (
	// DepthZero indicates that the request applies only to the resource.
	DepthZero Depth = 0
	// DepthOne indicates that the request applies to the resource and its
	// internal members only.
	DepthOne Depth = 1
	// DepthInfinity indicates that the request applies to the resource and all
	// of its members.
	DepthInfinity Depth = -1
)

func ParseDepth

func ParseDepth(s string) (Depth, error)

ParseDepth parses a Depth header.

func (Depth) String

func (d Depth) String() string

String formats the depth.

type DisplayName

type DisplayName struct {
	XMLName xml.Name `xml:"DAV: displayname"`
	Name    string   `xml:",chardata"`
}

https://tools.ietf.org/html/rfc4918#section-15.2

type ETag

type ETag string

func (ETag) MarshalText

func (etag ETag) MarshalText() ([]byte, error)

func (ETag) String

func (etag ETag) String() string

func (*ETag) UnmarshalText

func (etag *ETag) UnmarshalText(b []byte) error

type Error

type Error struct {
	XMLName xml.Name      `xml:"DAV: error"`
	Raw     []RawXMLValue `xml:",any"`
}

https://tools.ietf.org/html/rfc4918#section-14.5

func (*Error) Error

func (err *Error) Error() string

type GetContentLength

type GetContentLength struct {
	XMLName xml.Name `xml:"DAV: getcontentlength"`
	Length  int64    `xml:",chardata"`
}

https://tools.ietf.org/html/rfc4918#section-15.4

type GetContentType

type GetContentType struct {
	XMLName xml.Name `xml:"DAV: getcontenttype"`
	Type    string   `xml:",chardata"`
}

https://tools.ietf.org/html/rfc4918#section-15.5

type GetETag

type GetETag struct {
	XMLName xml.Name `xml:"DAV: getetag"`
	ETag    ETag     `xml:",chardata"`
}

https://tools.ietf.org/html/rfc4918#section-15.6

type GetLastModified

type GetLastModified struct {
	XMLName      xml.Name `xml:"DAV: getlastmodified"`
	LastModified Time     `xml:",chardata"`
}

https://tools.ietf.org/html/rfc4918#section-15.7

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient performs HTTP requests. It's implemented by *http.Client.

type HTTPError

type HTTPError struct {
	Code int
	Err  error
}

func HTTPErrorFromError

func HTTPErrorFromError(err error) *HTTPError

func HTTPErrorf

func HTTPErrorf(code int, format string, a ...interface{}) *HTTPError

func (*HTTPError) Error

func (err *HTTPError) Error() string

func (*HTTPError) Unwrap

func (err *HTTPError) Unwrap() error

type Href

type Href url.URL

func (*Href) MarshalText

func (h *Href) MarshalText() ([]byte, error)

func (*Href) String

func (h *Href) String() string

func (*Href) UnmarshalText

func (h *Href) UnmarshalText(b []byte) error

type Include

type Include struct {
	XMLName xml.Name      `xml:"DAV: include"`
	Raw     []RawXMLValue `xml:",any"`
}

https://tools.ietf.org/html/rfc4918#section-14.8

type Limit

type Limit struct {
	XMLName  xml.Name `xml:"DAV: limit"`
	NResults uint     `xml:"nresults"`
}

https://tools.ietf.org/html/rfc5323#section-5.17

type Location

type Location struct {
	XMLName xml.Name `xml:"DAV: location"`
	Href    Href     `xml:"href"`
}

https://tools.ietf.org/html/rfc4918#section-14.9

type MultiStatus

type MultiStatus struct {
	XMLName             xml.Name   `xml:"DAV: multistatus"`
	Responses           []Response `xml:"response"`
	ResponseDescription string     `xml:"responsedescription,omitempty"`
	SyncToken           string     `xml:"sync-token,omitempty"`
}

https://tools.ietf.org/html/rfc4918#section-14.16

func NewMultiStatus

func NewMultiStatus(resps ...Response) *MultiStatus

type Prop

type Prop struct {
	XMLName xml.Name      `xml:"DAV: prop"`
	Raw     []RawXMLValue `xml:",any"`
}

https://tools.ietf.org/html/rfc4918#section-14.18

func EncodeProp

func EncodeProp(values ...interface{}) (*Prop, error)

func (*Prop) Decode

func (p *Prop) Decode(v interface{}) error

func (*Prop) Get

func (p *Prop) Get(name xml.Name) *RawXMLValue

type PropFind

type PropFind struct {
	XMLName  xml.Name  `xml:"DAV: propfind"`
	Prop     *Prop     `xml:"prop,omitempty"`
	AllProp  *struct{} `xml:"allprop,omitempty"`
	Include  *Include  `xml:"include,omitempty"`
	PropName *struct{} `xml:"propname,omitempty"`
}

https://tools.ietf.org/html/rfc4918#section-14.20

func NewPropNamePropFind

func NewPropNamePropFind(names ...xml.Name) *PropFind

type PropStat

type PropStat struct {
	XMLName             xml.Name `xml:"DAV: propstat"`
	Prop                Prop     `xml:"prop"`
	Status              Status   `xml:"status"`
	ResponseDescription string   `xml:"responsedescription,omitempty"`
	Error               *Error   `xml:"error,omitempty"`
}

https://tools.ietf.org/html/rfc4918#section-14.22

type PropertyUpdate

type PropertyUpdate struct {
	XMLName xml.Name `xml:"DAV: propertyupdate"`
	Remove  []Remove `xml:"remove"`
	Set     []Set    `xml:"set"`
}

https://tools.ietf.org/html/rfc4918#section-14.19

type RawXMLValue

type RawXMLValue struct {
	// contains filtered or unexported fields
}

RawXMLValue is a raw XML value. It implements xml.Unmarshaler and xml.Marshaler and can be used to delay XML decoding or precompute an XML encoding.

func EncodeRawXMLElement

func EncodeRawXMLElement(v interface{}) (*RawXMLValue, error)

EncodeRawXMLElement encodes a value into a new RawXMLValue. The XML value can only be used for marshalling.

func NewRawXMLElement

func NewRawXMLElement(name xml.Name, attr []xml.Attr, children []RawXMLValue) *RawXMLValue

NewRawXMLElement creates a new RawXMLValue for an element.

func (*RawXMLValue) Decode

func (val *RawXMLValue) Decode(v interface{}) error

func (*RawXMLValue) MarshalXML

func (val *RawXMLValue) MarshalXML(e *xml.Encoder, start xml.StartElement) error

MarshalXML implements xml.Marshaler.

func (*RawXMLValue) TokenReader

func (val *RawXMLValue) TokenReader() xml.TokenReader

TokenReader returns a stream of tokens for the XML value.

func (*RawXMLValue) UnmarshalXML

func (val *RawXMLValue) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error

UnmarshalXML implements xml.Unmarshaler.

func (*RawXMLValue) XMLName

func (val *RawXMLValue) XMLName() (name xml.Name, ok bool)

type Remove

type Remove struct {
	XMLName xml.Name `xml:"DAV: remove"`
	Prop    Prop     `xml:"prop"`
}

https://tools.ietf.org/html/rfc4918#section-14.23

type ResourceType

type ResourceType struct {
	XMLName xml.Name      `xml:"DAV: resourcetype"`
	Raw     []RawXMLValue `xml:",any"`
}

https://tools.ietf.org/html/rfc4918#section-15.9

func NewResourceType

func NewResourceType(names ...xml.Name) *ResourceType

func (*ResourceType) Is

func (t *ResourceType) Is(name xml.Name) bool

type Response

type Response struct {
	XMLName             xml.Name   `xml:"DAV: response"`
	Hrefs               []Href     `xml:"href"`
	PropStats           []PropStat `xml:"propstat,omitempty"`
	ResponseDescription string     `xml:"responsedescription,omitempty"`
	Status              *Status    `xml:"status,omitempty"`
	Error               *Error     `xml:"error,omitempty"`
	Location            *Location  `xml:"location,omitempty"`
}

https://tools.ietf.org/html/rfc4918#section-14.24

func NewErrorResponse

func NewErrorResponse(path string, err error) *Response

func NewOKResponse

func NewOKResponse(path string) *Response

func (*Response) DecodeProp

func (resp *Response) DecodeProp(values ...interface{}) error

func (*Response) EncodeProp

func (resp *Response) EncodeProp(code int, v interface{}) error

func (*Response) Err

func (resp *Response) Err() error

func (*Response) Path

func (resp *Response) Path() (string, error)

type Set

type Set struct {
	XMLName xml.Name `xml:"DAV: set"`
	Prop    Prop     `xml:"prop"`
}

https://tools.ietf.org/html/rfc4918#section-14.26

type Status

type Status struct {
	Code int
	Text string
}

func (*Status) Err

func (s *Status) Err() error

func (*Status) MarshalText

func (s *Status) MarshalText() ([]byte, error)

func (*Status) UnmarshalText

func (s *Status) UnmarshalText(b []byte) error

type SyncCollectionQuery

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/rfc6578#section-6.1

type Time

type Time time.Time

func (*Time) MarshalText

func (t *Time) MarshalText() ([]byte, error)

func (*Time) UnmarshalText

func (t *Time) UnmarshalText(b []byte) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL