from zope.interface import Attribute
from zope.interface import Interface


class IEvent(Interface):
    """Event type marker interface."""


class IEventRecurrence(Interface):
    """Event type marker interface for events with an RFC5545 compatible
    recurrence definition.

    """


class IOccurrence(Interface):
    """Marker interface for an occurrence item, which represents a single
    occurrence.

    """

    start = Attribute("Occurrence start date")
    end = Attribute("Occurrence end date")


class ICalendarAccessor(Interface):
    """Generic calendar accessor adapter interface.

    A calendar is a collection of calendar components, like events.

    """

    uid = Attribute("UID of the calendar. Autogenerated, read only.")
    # rw attributes
    title = Attribute("Calendar title.")
    description = Attribute("Calendar description text.")
    timezone = Attribute("Default timezone of the calendar.")

    def items(self):
        """Return a list of calendar component items, like events."""


class IEventAccessor(Interface):
    """Event type generic accessor adapter interface.

    A specific adapter implementation should be provided by the individual
    content type packages.

    """

    # ro attributes
    uid = Attribute("UID of the event. Autogenerated, read only.")
    created = Attribute("Python datetime of the event creation timestamp.")
    duration = Attribute("Duration of the event. Computed attribute.")

    # reference
    url = Attribute(
        "Canonical, unique url of the event. External events "
        "are referenced by the origin url unless explicitly set."
    )

    # rw attributes
    last_modified = Attribute("Last modified Python datetime.")
    title = Attribute("Event title.")
    description = Attribute("Event description text.")
    start = Attribute("Event start date as Python datetime.")
    end = Attribute("Event end date as Python datetime.")
    whole_day = Attribute("Event lasts whole day.")
    open_end = Attribute("Event has no defined end time.")
    timezone = Attribute("Timezone of the event. A pytz timezone identifier.")
    recurrence = Attribute("RFC5545 compatible recurrence definition.")
    location = Attribute("Location of the event.")
    attendees = Attribute("List of attendees.")
    contact_name = Attribute("Contact name.")
    contact_email = Attribute("Contact email.")
    contact_phone = Attribute("Contact phone.")
    event_url = Attribute("Website of the event.")
    subjects = Attribute("Categories.")
    text = Attribute("Body text of the event.")


class IRecurrenceSupport(Interface):
    """Event type recurrence adapter."""

    def occurrences(self, range_start, range_end):
        """Return a list of IOccurrence objects with custom attributes of the
        specific occurrence set.

        :param range_start: Search for occurrences after this date.
        :type range_start: Python datetime.

        :param range_end: Search for occurrences before this date.
        :type range_end: Python datetime.

        """


class IICalendar(Interface):
    """Adapter, which is used to construct an icalendar object."""


class IICalendarEventComponent(Interface):
    """Adapter, which is used to construct an event component object for
    icalendar.

    """


class IVEvent(Interface):
    """RFC5545 Event schema

    ; The following are REQUIRED,
    ; but MUST NOT occur more than once.
    ;
    dtstamp / uid /
    ;
    ; The following is REQUIRED if the component
    ; appears in an iCalendar object that doesn't
    ; specify the "METHOD" property; otherwise, it
    ; is OPTIONAL; in any case, it MUST NOT occur
    ; more than once.
    ;
    dtstart /
    ;
    ; The following are OPTIONAL,
    ; but MUST NOT occur more than once.
    ;
    class / created / description / geo /
    last-mod / location / organizer / priority /
    seq / status / summary / transp /
    url / recurid /
    ;
    ; The following is OPTIONAL,
    ; but SHOULD NOT occur more than once.
    ;
    rrule /
    ;
    ; Either 'dtend' or 'duration' MAY appear in
    ; a 'eventprop', but 'dtend' and 'duration'
    ; MUST NOT occur in the same 'eventprop'.
    ;
    dtend / duration /
    ;
    ; The following are OPTIONAL,
    ; and MAY occur more than once.
    ;
    attach / attendee / categories / comment /
    contact / exdate / rstatus / related /
    resources / rdate / x-prop / iana-prop

    """

    dtstart = Attribute("Start Date/Time")
    dtend = Attribute("End Date/Time")
    duration = Attribute("Duration")
    rrule = Attribute("Recurrence Rule")
    description = Attribute("Description")
    location = Attribute("Location")
    summary = Attribute("Summary")
    url = Attribute("Url")
    attendee = Attribute("Attendee")
    categories = Attribute("Categories")
    contact = Attribute("Contact")

    exdate = Attribute("Exdate")
    rdate = Attribute("Rdate")

    dtstamp = Attribute("Timestamp")
    uid = Attribute("Unique identifier")
    klass = Attribute("Class")  # class
    created = Attribute("Created")
    geo = Attribute("Geo")
    last_mod = Attribute("Last Modified")  # last-mod
    organizer = Attribute("Organizer")
    priority = Attribute("Priority")
    seq = Attribute("Seq")
    status = Attribute("Status")
    transp = Attribute("Transp")
    recurid = Attribute("Recurid")
    attach = Attribute("Attach")
    comment = Attribute("Comment")
    rstatus = Attribute("Rstatus")
    related = Attribute("Related")
    resources = Attribute("Resources")
    x_prop = Attribute("X Prop")  # x-prop
    iana_prop = Attribute("Iana Prop")  # iana-prop
