How to use the exchangelib.folders.base.Folder function in exchangelib

To help you get started, we’ve selected a few exchangelib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ecederstrand / exchangelib / exchangelib / folders / known_folders.py View on Github external
LOCALIZED_NAMES = {
        'da_DK': (u'Opgaver',),
        'de_DE': (u'Aufgaben',),
        'en_US': (u'Tasks',),
        'es_ES': (u'Tareas',),
        'fr_CA': (u'Tâches',),
        'nl_NL': (u'Taken',),
        'ru_RU': (u'Задачи',),
        'sv_SE': (u'Uppgifter',),
        'zh_CN': (u'任务',),
    }
    __slots__ = tuple()


class Contacts(Folder):
    DISTINGUISHED_FOLDER_ID = 'contacts'
    CONTAINER_CLASS = 'IPF.Contact'
    supported_item_models = (Contact, DistributionList)

    LOCALIZED_NAMES = {
        'da_DK': (u'Kontaktpersoner',),
        'de_DE': (u'Kontakte',),
        'en_US': (u'Contacts',),
        'es_ES': (u'Contactos',),
        'fr_CA': (u'Contacts',),
        'nl_NL': (u'Contactpersonen',),
        'ru_RU': (u'Контакты',),
        'sv_SE': (u'Kontakter',),
        'zh_CN': (u'联系人',),
    }
    __slots__ = tuple()
github ecederstrand / exchangelib / exchangelib / folders / known_folders.py View on Github external
class DeferredAction(NonDeleteableFolderMixin, Folder):
    LOCALIZED_NAMES = {
        None: (u'Deferred Action',),
    }
    __slots__ = tuple()


class ExchangeSyncData(NonDeleteableFolderMixin, Folder):
    LOCALIZED_NAMES = {
        None: (u'ExchangeSyncData',),
    }
    __slots__ = tuple()


class Files(NonDeleteableFolderMixin, Folder):
    CONTAINER_CLASS = 'IPF.Files'

    LOCALIZED_NAMES = {
        'da_DK': (u'Filer',),
    }
    __slots__ = tuple()


class FreebusyData(NonDeleteableFolderMixin, Folder):
    LOCALIZED_NAMES = {
        None: (u'Freebusy Data',),
    }
    __slots__ = tuple()


class Friends(NonDeleteableFolderMixin, Contacts):
github ecederstrand / exchangelib / exchangelib / folders / queryset.py View on Github external
def only(self, *args):
        """Restrict the fields returned. 'name' and 'folder_class' are always returned.
        """
        from .base import Folder
        # Subfolders will always be of class Folder
        all_fields = self.folder_collection.get_folder_fields(target_cls=Folder, is_complex=None)
        only_fields = []
        for arg in args:
            for field_path in all_fields:
                if field_path.field.name == arg:
                    only_fields.append(field_path)
                    break
            else:
                raise InvalidField("Unknown field %r on folders %s" % (arg, self.folder_collection.folders))
        new_qs = self._copy_self()
        new_qs.only_fields = only_fields
        return new_qs
github ecederstrand / exchangelib / exchangelib / folders / known_folders.py View on Github external
LOCALIZED_NAMES = {
        'da_DK': (u'Kontaktpersoner',),
        'de_DE': (u'Kontakte',),
        'en_US': (u'Contacts',),
        'es_ES': (u'Contactos',),
        'fr_CA': (u'Contacts',),
        'nl_NL': (u'Contactpersonen',),
        'ru_RU': (u'Контакты',),
        'sv_SE': (u'Kontakter',),
        'zh_CN': (u'联系人',),
    }
    __slots__ = tuple()


class WellknownFolder(Folder):
    """A base class to use until we have a more specific folder implementation for this folder"""
    supported_item_models = ITEM_CLASSES
    __slots__ = tuple()


class AdminAuditLogs(WellknownFolder):
    DISTINGUISHED_FOLDER_ID = 'adminauditlogs'
    supported_from = EXCHANGE_2013
    get_folder_allowed = False
    __slots__ = tuple()


class ArchiveDeletedItems(WellknownFolder):
    DISTINGUISHED_FOLDER_ID = 'archivedeleteditems'
    supported_from = EXCHANGE_2010_SP1
    __slots__ = tuple()
github ecederstrand / exchangelib / exchangelib / folders / known_folders.py View on Github external
class GraphAnalytics(NonDeleteableFolderMixin, Folder):
    CONTAINER_CLASS = 'IPF.StoreItem.GraphAnalytics'
    LOCALIZED_NAMES = {
        None: (u'GraphAnalytics',),
    }
    __slots__ = tuple()


class Location(NonDeleteableFolderMixin, Folder):
    LOCALIZED_NAMES = {
        None: (u'Location',),
    }
    __slots__ = tuple()


class MailboxAssociations(NonDeleteableFolderMixin, Folder):
    LOCALIZED_NAMES = {
        None: (u'MailboxAssociations',),
    }
    __slots__ = tuple()


class MyContactsExtended(NonDeleteableFolderMixin, Contacts):
    CONTAINER_CLASS = 'IPF.Note'
    LOCALIZED_NAMES = {
        None: (u'MyContactsExtended',),
    }
    __slots__ = tuple()


class ParkedMessages(NonDeleteableFolderMixin, Folder):
    CONTAINER_CLASS = None
github ecederstrand / exchangelib / exchangelib / folders / collections.py View on Github external
if not self.account:
            raise ValueError('Folder must have an account')
        if q is None or q.is_empty():
            restriction = None
        else:
            restriction = Restriction(q, folders=self.folders, applies_to=Restriction.FOLDERS)
        if shape not in SHAPE_CHOICES:
            raise ValueError("'shape' %s must be one of %s" % (shape, SHAPE_CHOICES))
        if depth not in FOLDER_TRAVERSAL_CHOICES:
            raise ValueError("'depth' %s must be one of %s" % (depth, FOLDER_TRAVERSAL_CHOICES))
        if not self.folders:
            log.debug('Folder list is empty')
            return
        if additional_fields is None:
            # Default to all non-complex properties. Subfolders will always be of class Folder
            additional_fields = self.get_folder_fields(target_cls=Folder, is_complex=False)
        else:
            for f in additional_fields:
                if f.field.is_complex:
                    raise ValueError("find_folders() does not support field '%s'. Use get_folders()." % f.field.name)

        # Add required fields
        additional_fields.update(
            (FieldPath(field=BaseFolder.get_field_by_fieldname(f)) for f in self.REQUIRED_FOLDER_FIELDS)
        )

        for f in FindFolder(account=self.account, folders=self.folders, chunk_size=page_size).call(
                additional_fields=additional_fields,
                restriction=restriction,
                shape=shape,
                depth=depth,
                max_items=max_items,
github ecederstrand / exchangelib / exchangelib / folders / known_folders.py View on Github external
LOCALIZED_NAMES = {
        None: (u'ExchangeSyncData',),
    }
    __slots__ = tuple()


class Files(NonDeleteableFolderMixin, Folder):
    CONTAINER_CLASS = 'IPF.Files'

    LOCALIZED_NAMES = {
        'da_DK': (u'Filer',),
    }
    __slots__ = tuple()


class FreebusyData(NonDeleteableFolderMixin, Folder):
    LOCALIZED_NAMES = {
        None: (u'Freebusy Data',),
    }
    __slots__ = tuple()


class Friends(NonDeleteableFolderMixin, Contacts):
    CONTAINER_CLASS = 'IPF.Note'

    LOCALIZED_NAMES = {
        'de_DE': (u'Bekannte',),
    }
    __slots__ = tuple()


class GALContacts(NonDeleteableFolderMixin, Contacts):
github ecederstrand / exchangelib / exchangelib / folders / collections.py View on Github external
# We may have root folders that don't support the same set of fields as normal folders. If there is a mix of
        # both folder types in self.folders, raise an error so we don't risk losing some fields in the query.
        from .base import Folder
        from .roots import RootOfHierarchy
        has_roots = False
        has_non_roots = False
        for f in self.folders:
            if isinstance(f, RootOfHierarchy):
                if has_non_roots:
                    raise ValueError('Cannot call GetFolder on a mix of folder types: {}'.format(self.folders))
                has_roots = True
            else:
                if has_roots:
                    raise ValueError('Cannot call GetFolder on a mix of folder types: {}'.format(self.folders))
                has_non_roots = True
        return RootOfHierarchy if has_roots else Folder
github ecederstrand / exchangelib / exchangelib / folders / known_folders.py View on Github external
class MailboxAssociations(NonDeleteableFolderMixin, Folder):
    LOCALIZED_NAMES = {
        None: (u'MailboxAssociations',),
    }
    __slots__ = tuple()


class MyContactsExtended(NonDeleteableFolderMixin, Contacts):
    CONTAINER_CLASS = 'IPF.Note'
    LOCALIZED_NAMES = {
        None: (u'MyContactsExtended',),
    }
    __slots__ = tuple()


class ParkedMessages(NonDeleteableFolderMixin, Folder):
    CONTAINER_CLASS = None
    LOCALIZED_NAMES = {
        None: (u'ParkedMessages',),
    }
    __slots__ = tuple()


class PassThroughSearchResults(NonDeleteableFolderMixin, Folder):
    CONTAINER_CLASS = 'IPF.StoreItem.PassThroughSearchResults'
    LOCALIZED_NAMES = {
        None: (u'Pass-Through Search Results',),
    }
    __slots__ = tuple()


class PdpProfileV2Secured(NonDeleteableFolderMixin, Folder):
github ecederstrand / exchangelib / exchangelib / folders / base.py View on Github external
def __init__(self, **kwargs):
        self._root = kwargs.pop('root', None)  # This is a pointer to the root of the folder hierarchy
        parent = kwargs.pop('parent', None)
        if parent:
            if self.root:
                if parent.root != self.root:
                    raise ValueError("'parent.root' must match 'root'")
            else:
                self.root = parent.root
            if 'parent_folder_id' in kwargs:
                if parent.id != kwargs['parent_folder_id']:
                    raise ValueError("'parent_folder_id' must match 'parent' ID")
            kwargs['parent_folder_id'] = ParentFolderId(id=parent.id, changekey=parent.changekey)
        super(Folder, self).__init__(**kwargs)