exchangelib.services.move_folder API documentation

# Module `exchangelib.services.move_folder`

Expand source code

    from ..errors import InvalidTypeError
    from ..folders import BaseFolder
    from ..properties import FolderId
    from ..util import MNS, create_element
    from .common import EWSAccountService, folder_ids_element

    class MoveFolder(EWSAccountService):
        """MSDN: https://docs.microsoft.com/en-us/exchange/client-developer/web-service-reference/movefolder-operation"""

        SERVICE_NAME = "MoveFolder"
        element_container_name = f"{{{MNS}}}Folders"

        def call(self, folders, to_folder):
            if not isinstance(to_folder, (BaseFolder, FolderId)):
                raise InvalidTypeError("to_folder", to_folder, (BaseFolder, FolderId))
            return self._elems_to_objs(self._chunked_get_elements(self.get_payload, items=folders, to_folder=to_folder))

        def _elem_to_obj(self, elem):
            return FolderId.from_xml(elem=elem.find(FolderId.response_tag()), account=self.account)

        def get_payload(self, folders, to_folder):
            # Takes a list of folders and returns their new folder IDs
            payload = create_element(f"m:{self.SERVICE_NAME}")
            payload.append(folder_ids_element(folders=[to_folder], version=self.account.version, tag="m:ToFolderId"))
            payload.append(folder_ids_element(folders=folders, version=self.account.version))
            return payload

## Classes

`class MoveFolder (*args, **kwargs)`

  MSDN: https://docs.microsoft.com/en-us/exchange/client-developer/web-service-reference/movefolder-operation

  Expand source code

      class MoveFolder(EWSAccountService):
          """MSDN: https://docs.microsoft.com/en-us/exchange/client-developer/web-service-reference/movefolder-operation"""

          SERVICE_NAME = "MoveFolder"
          element_container_name = f"{{{MNS}}}Folders"

          def call(self, folders, to_folder):
              if not isinstance(to_folder, (BaseFolder, FolderId)):
                  raise InvalidTypeError("to_folder", to_folder, (BaseFolder, FolderId))
              return self._elems_to_objs(self._chunked_get_elements(self.get_payload, items=folders, to_folder=to_folder))

          def _elem_to_obj(self, elem):
              return FolderId.from_xml(elem=elem.find(FolderId.response_tag()), account=self.account)

          def get_payload(self, folders, to_folder):
              # Takes a list of folders and returns their new folder IDs
              payload = create_element(f"m:{self.SERVICE_NAME}")
              payload.append(folder_ids_element(folders=[to_folder], version=self.account.version, tag="m:ToFolderId"))
              payload.append(folder_ids_element(folders=folders, version=self.account.version))
              return payload

  ### Ancestors

  - EWSAccountService
  - EWSService
  - SupportedVersionClassMixIn

  ### Class variables

  `var SERVICE_NAME`
  `var element_container_name`

  ### Methods

  `def call(self, folders, to_folder)`
    Expand source code

        def call(self, folders, to_folder):
            if not isinstance(to_folder, (BaseFolder, FolderId)):
                raise InvalidTypeError("to_folder", to_folder, (BaseFolder, FolderId))
            return self._elems_to_objs(self._chunked_get_elements(self.get_payload, items=folders, to_folder=to_folder))

  `def get_payload(self, folders, to_folder)`
    Expand source code

        def get_payload(self, folders, to_folder):
            # Takes a list of folders and returns their new folder IDs
            payload = create_element(f"m:{self.SERVICE_NAME}")
            payload.append(folder_ids_element(folders=[to_folder], version=self.account.version, tag="m:ToFolderId"))
            payload.append(folder_ids_element(folders=folders, version=self.account.version))
            return payload

  ### Inherited members

  - `EWSAccountService`:
    - `NO_VALID_SERVER_VERSIONS`
    - `WARNINGS_TO_CATCH_IN_RESPONSE`
    - `get`
    - `parse`
    - `supported_api_versions`
    - `wrap`