caldav

package
v0.0.0-...-eb6ca6c Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2024 License: MIT Imports: 14 Imported by: 1

Documentation

Overview

Package caldav provides a client and server CalDAV implementation.

CalDAV is defined in RFC 4791.

Index

Constants

This section is empty.

Variables

View Source
var CapabilityCalendar = webdav.Capability("calendar-access")

Functions

func DiscoverContextURL

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

func Match(query CompFilter, co *CalendarObject) (matched bool, err error)

Match reports whether the provided CalendarObject matches the query.

func NewCalendarHomeSet

func NewCalendarHomeSet(path string) webdav.BackendSuppliedHomeSet

func NewPreconditionError

func NewPreconditionError(err PreconditionType) error

func ValidateCalendarObject

func ValidateCalendarObject(cal *ical.Calendar) (eventType string, uid string, err error)

ValidateCalendarObject checks the validity of a calendar object according to the contraints layed out in RFC 4791 section 4.1 and returns the only event type and UID occuring in this calendar, or an error if the calendar could not be validated.

Types

type Backend

type Backend interface {
	CalendarHomeSetPath(ctx context.Context) (string, error)

	CreateCalendar(ctx context.Context, calendar *Calendar) error
	ListCalendars(ctx context.Context) ([]Calendar, error)
	GetCalendar(ctx context.Context, path string) (*Calendar, error)

	GetCalendarObject(ctx context.Context, path string, req *CalendarCompRequest) (*CalendarObject, error)
	ListCalendarObjects(ctx context.Context, path string, req *CalendarCompRequest) ([]CalendarObject, error)
	QueryCalendarObjects(ctx context.Context, path string, query *CalendarQuery) ([]CalendarObject, error)
	PutCalendarObject(ctx context.Context, path string, calendar *ical.Calendar, opts *PutCalendarObjectOptions) (*CalendarObject, error)
	DeleteCalendarObject(ctx context.Context, path string) error
	GetPrivileges(ctx context.Context) []string
	GetCalendarPrivileges(ctx context.Context, calendar *Calendar) []string
	webdav.UserPrincipalBackend
}

Backend is a CalDAV server backend.

type Calendar

type Calendar struct {
	Path                  string
	Name                  string
	Description           string
	MaxResourceSize       int64
	SupportedComponentSet []string
}

type CalendarCompRequest

type CalendarCompRequest struct {
	Name string

	AllProps bool
	Props    []string

	AllComps bool
	Comps    []CalendarCompRequest
}

type CalendarMultiGet

type CalendarMultiGet struct {
	Paths       []string
	CompRequest CalendarCompRequest
}

type CalendarObject

type CalendarObject struct {
	Path          string
	ModTime       time.Time
	ContentLength int64
	ETag          string
	Data          *ical.Calendar
}

func Filter

func Filter(query *CalendarQuery, cos []CalendarObject) ([]CalendarObject, error)

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

type CalendarQuery

type CalendarQuery struct {
	CompRequest CalendarCompRequest
	CompFilter  CompFilter
}

type Client

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

Client provides access to a remote CardDAV server.

func NewClient

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

func (*Client) FindCalendarHomeSet

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

func (*Client) FindCalendars

func (c *Client) FindCalendars(ctx context.Context, calendarHomeSet string) ([]Calendar, error)

func (*Client) GetCalendarObject

func (c *Client) GetCalendarObject(ctx context.Context, path string) (*CalendarObject, error)

func (*Client) MultiGetCalendar

func (c *Client) MultiGetCalendar(ctx context.Context, path string, multiGet *CalendarMultiGet) ([]CalendarObject, error)

func (*Client) PutCalendarObject

func (c *Client) PutCalendarObject(ctx context.Context, path string, cal *ical.Calendar) (*CalendarObject, error)

func (*Client) QueryCalendar

func (c *Client) QueryCalendar(ctx context.Context, calendar string, query *CalendarQuery) ([]CalendarObject, error)

type CompFilter

type CompFilter struct {
	Name         string
	IsNotDefined bool
	Start, End   time.Time
	Props        []PropFilter
	Comps        []CompFilter
}

type Handler

type Handler struct {
	Backend Backend
	Prefix  string
}

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

func (*Handler) ServeHTTP

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

ServeHTTP implements http.Handler.

type ParamFilter

type ParamFilter struct {
	Name         string
	IsNotDefined bool
	TextMatch    *TextMatch
}

type PreconditionType

type PreconditionType string

https://datatracker.ietf.org/doc/html/rfc4791#section-5.3.2.1

const (
	PreconditionNoUIDConflict                PreconditionType = "no-uid-conflict"
	PreconditionSupportedCalendarData        PreconditionType = "supported-calendar-data"
	PreconditionSupportedCalendarComponent   PreconditionType = "supported-calendar-component"
	PreconditionValidCalendarData            PreconditionType = "valid-calendar-data"
	PreconditionValidCalendarObjectResource  PreconditionType = "valid-calendar-object-resource"
	PreconditionCalendarCollectionLocationOk PreconditionType = "calendar-collection-location-ok"
	PreconditionMaxResourceSize              PreconditionType = "max-resource-size"
	PreconditionMinDateTime                  PreconditionType = "min-date-time"
	PreconditionMaxDateTime                  PreconditionType = "max-date-time"
	PreconditionMaxInstances                 PreconditionType = "max-instances"
	PreconditionMaxAttendeesPerInstance      PreconditionType = "max-attendees-per-instance"
)

type PropFilter

type PropFilter struct {
	Name         string
	IsNotDefined bool
	Start, End   time.Time
	TextMatch    *TextMatch
	ParamFilter  []ParamFilter
}

type PutCalendarObjectOptions

type PutCalendarObjectOptions 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
}

TODO if nothing more Caldav-specific needs to be added this should be merged with carddav.PutAddressObjectOptions

type TextMatch

type TextMatch struct {
	Text            string
	NegateCondition bool
}

Jump to

Keyboard shortcuts

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