carddav

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: MIT Imports: 14 Imported by: 16

Documentation

Overview

Package carddav provides a client and server CardDAV implementation.

CardDAV is defined in RFC 6352.

Index

Constants

This section is empty.

Variables

View Source
var CapabilityAddressBook = webdav.Capability("addressbook")

Functions

func DiscoverContextURL added in v0.5.0

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

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

func Match added in v0.4.0

func Match(query *AddressBookQuery, ao *AddressObject) (matched bool, err error)

Match reports whether the provided AddressObject matches the query.

func NewAddressBookHomeSet added in v0.4.0

func NewAddressBookHomeSet(path string) webdav.BackendSuppliedHomeSet

func NewPreconditionError added in v0.4.0

func NewPreconditionError(err PreconditionType) error

Types

type AddressBook

type AddressBook struct {
	Path                 string
	Name                 string
	Description          string
	MaxResourceSize      int64
	SupportedAddressData []AddressDataType
}

func (*AddressBook) SupportsAddressData added in v0.3.0

func (ab *AddressBook) SupportsAddressData(contentType, version string) bool

type AddressBookMultiGet added in v0.2.0

type AddressBookMultiGet struct {
	Paths       []string
	DataRequest AddressDataRequest
}

type AddressBookQuery added in v0.2.0

type AddressBookQuery struct {
	DataRequest AddressDataRequest

	PropFilters []PropFilter
	FilterTest  FilterTest // defaults to FilterAnyOf

	Limit int // <= 0 means unlimited
}

type AddressDataRequest added in v0.2.0

type AddressDataRequest struct {
	Props   []string
	AllProp bool
}

type AddressDataType added in v0.3.0

type AddressDataType struct {
	ContentType string
	Version     string
}

type AddressObject

type AddressObject struct {
	Path          string
	ModTime       time.Time
	ContentLength int64
	ETag          string
	Card          vcard.Card
}

func Filter added in v0.4.0

func Filter(query *AddressBookQuery, aos []AddressObject) ([]AddressObject, error)

Filter returns the filtered list of address objects matching the provided query. A nil query will return the full list of address objects.

type Backend added in v0.2.0

type Backend interface {
	AddressbookHomeSetPath(ctx context.Context) (string, error)
	AddressBook(ctx context.Context) (*AddressBook, error)
	GetAddressObject(ctx context.Context, path string, req *AddressDataRequest) (*AddressObject, error)
	ListAddressObjects(ctx context.Context, req *AddressDataRequest) ([]AddressObject, error)
	QueryAddressObjects(ctx context.Context, query *AddressBookQuery) ([]AddressObject, error)
	PutAddressObject(ctx context.Context, path string, card vcard.Card, opts *PutAddressObjectOptions) (loc string, err error)
	DeleteAddressObject(ctx context.Context, path string) error

	webdav.UserPrincipalBackend
}

Backend is a CardDAV server backend.

type Client added in v0.2.0

type Client struct {
	*webdav.Client
	// contains filtered or unexported fields
}

Client provides access to a remote CardDAV server.

func NewClient added in v0.2.0

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

func (*Client) FindAddressBookHomeSet added in v0.2.0

func (c *Client) FindAddressBookHomeSet(ctx context.Context, principal string) (string, error)

func (*Client) FindAddressBooks added in v0.2.0

func (c *Client) FindAddressBooks(ctx context.Context, addressBookHomeSet string) ([]AddressBook, error)

func (*Client) GetAddressObject added in v0.3.0

func (c *Client) GetAddressObject(ctx context.Context, path string) (*AddressObject, error)

func (*Client) HasSupport added in v0.3.0

func (c *Client) HasSupport(ctx context.Context) error

func (*Client) MultiGetAddressBook added in v0.2.0

func (c *Client) MultiGetAddressBook(ctx context.Context, path string, multiGet *AddressBookMultiGet) ([]AddressObject, error)

func (*Client) PutAddressObject added in v0.3.0

func (c *Client) PutAddressObject(ctx context.Context, path string, card vcard.Card) (*AddressObject, error)

func (*Client) QueryAddressBook added in v0.2.0

func (c *Client) QueryAddressBook(ctx context.Context, addressBook string, query *AddressBookQuery) ([]AddressObject, error)

func (*Client) SyncCollection added in v0.3.1

func (c *Client) SyncCollection(ctx context.Context, path string, query *SyncQuery) (*SyncResponse, error)

SyncCollection performs a collection synchronization operation on the specified resource, as defined in RFC 6578.

type FilterTest added in v0.2.0

type FilterTest string
const (
	FilterAnyOf FilterTest = "anyof"
	FilterAllOf FilterTest = "allof"
)

type Handler

type Handler struct {
	Backend Backend
	Prefix  string
}

Handler handles CardDAV HTTP requests. It can be used to create a CardDAV server.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP implements http.Handler.

type MatchType added in v0.2.0

type MatchType string
const (
	MatchEquals     MatchType = "equals"
	MatchContains   MatchType = "contains"
	MatchStartsWith MatchType = "starts-with"
	MatchEndsWith   MatchType = "ends-with"
)

type ParamFilter added in v0.2.0

type ParamFilter struct {
	Name string

	// if IsNotDefined is set, TextMatch needs to be unset
	IsNotDefined bool
	TextMatch    *TextMatch
}

type PreconditionType added in v0.4.0

type PreconditionType string

https://tools.ietf.org/rfcmarkup?doc=6352#section-6.3.2.1

const (
	PreconditionNoUIDConflict        PreconditionType = "no-uid-conflict"
	PreconditionSupportedAddressData PreconditionType = "supported-address-data"
	PreconditionValidAddressData     PreconditionType = "valid-address-data"
	PreconditionMaxResourceSize      PreconditionType = "max-resource-size"
)

type PropFilter added in v0.2.0

type PropFilter struct {
	Name string
	Test FilterTest // defaults to FilterAnyOf

	// if IsNotDefined is set, TextMatches and Params need to be unset
	IsNotDefined bool
	TextMatches  []TextMatch
	Params       []ParamFilter
}

type PutAddressObjectOptions added in v0.4.0

type PutAddressObjectOptions struct {
	// IfNoneMatch indicates that the client does not want to overwrite
	// an existing resource.
	IfNoneMatch webdav.ConditionalMatch
	// IfMatch provides the ETag of the resource that the client intends
	// to overwrite, can be ""
	IfMatch webdav.ConditionalMatch
}

type SyncQuery added in v0.3.1

type SyncQuery struct {
	DataRequest AddressDataRequest
	SyncToken   string
	Limit       int // <= 0 means unlimited
}

SyncQuery is the query struct represents a sync-collection request

type SyncResponse added in v0.3.1

type SyncResponse struct {
	SyncToken string
	Updated   []AddressObject
	Deleted   []string
}

SyncResponse contains the returned sync-token for next time

type TextMatch added in v0.2.0

type TextMatch struct {
	Text            string
	NegateCondition bool
	MatchType       MatchType // defaults to MatchContains
}

Jump to

Keyboard shortcuts

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