Ejemplo n.º 1
0
    def get_items_marker(self, limit=None, marker=None, fields=None):
        """
        Get the items in a folder using marker-based paging.

        :param limit:
            The maximum number of items to return per page. If not specified, then will use the server-side default.
        :type limit:
            `int` or None
        :param marker:
            The offset index to start paging from.
        :type marker:
            `str` or None
        :param fields:
            List of fields to request.
        :type fields:
            `Iterable` of `unicode`
        :returns:
            An iterator of the items in the folder.
        :rtype:
            :class:`BoxObjectCollection`
        """
        return MarkerBasedObjectCollection(
            self.session,
            self.get_url('items'),
            limit=limit,
            fields=fields,
            marker=marker,
            return_full_pages=False,
            supports_limit_offset_paging=True,
        )
Ejemplo n.º 2
0
 def _object_collection_instance(  # pylint:disable=arguments-differ
         self,
         session,
         limit,
         return_full_pages=False,
         starting_pointer=None,
         supports_limit_offset_paging=False):
     """Baseclass override."""
     return MarkerBasedObjectCollection(
         session,
         '/some/endpoint',
         limit=limit,
         return_full_pages=return_full_pages,
         marker=starting_pointer,
         supports_limit_offset_paging=supports_limit_offset_paging,
     )
Ejemplo n.º 3
0
    def get_metadata_cascade_policies(self,
                                      owner_enterprise=None,
                                      limit=None,
                                      marker=None,
                                      fields=None):
        """
        Get the metadata cascade policies current applied to the folder.

        :param owner_enterprise:
            Which enterprise's metadata templates to get cascade policies for.  This defauls to the current
            enterprise.
        :type owner_enterprise:
            :class:`Enterprise`
        :param limit:
            The maximum number of entries to return per page. If not specified, then will use the server-side default.
        :type limit:
            `int` or None
        :param marker:
            The paging marker to start paging from.
        :type marker:
            `unicode` or None
        :param fields:
            List of fields to request.
        :type fields:
            `Iterable` of `unicode`
        :returns:
            An iterator of the cascade policies attached on the folder.
        :rtype:
            :class:`BoxObjectCollection`
        """
        additional_params = {
            'folder_id': self.object_id,
        }
        if owner_enterprise is not None:
            additional_params[
                'owner_enterprise_id'] = owner_enterprise.object_id

        return MarkerBasedObjectCollection(
            url=self._session.get_url('metadata_cascade_policies'),
            session=self._session,
            additional_params=additional_params,
            limit=limit,
            marker=marker,
            fields=fields,
            return_full_pages=False,
        )
Ejemplo n.º 4
0
    def get_locks(self):
        """
        Lists all folder locks for a given folder.

        :returns:
            The collection of locks for a folder.
        :rtype:
            :class:`BoxObjectCollection`
        """
        url = self._session.get_url('folder_locks')

        additional_params = {
            'folder_id': self.object_id,
        }

        return MarkerBasedObjectCollection(
            url=url,
            session=self._session,
            additional_params=additional_params,
            return_full_pages=False,
        )
Ejemplo n.º 5
0
    def get_items(self,
                  limit=None,
                  offset=0,
                  marker=None,
                  use_marker=False,
                  sort=None,
                  direction=None,
                  fields=None):
        """
        Get the items in a folder.

        :param limit:
            The maximum number of items to return per page. If not specified, then will use the server-side default.
        :type limit:
            `int` or None
        :param offset:
            The index at which to start returning items when using offset-based pagin.
        :type offset:
            `int`
        :param use_marker:
            Whether to use marker-based paging instead of offset-based paging, defaults to False.
        :type use_marker:
            `bool`
        :param marker:
            The paging marker to start returning items from when using marker-based paging.
        :type marker:
            `unicode` or None
        :param sort:
            Item field to sort results on: 'id', 'name', or 'date'.
        :type sort':
            `unicode` or None
        :param direction:
            Sort direction for the items returned.
        :type direction:
            `unicode` or None
        :param fields:
            List of fields to request.
        :type fields:
            `Iterable` of `unicode`
        :returns:
            The collection of items in the folder.
        :rtype:
            `Iterable` of :class:`Item`
        """
        url = self.get_url('items')
        additional_params = {}
        if limit is not None:
            additional_params['limit'] = limit
        if sort:
            additional_params['sort'] = sort
        if direction:
            additional_params['direction'] = direction

        if use_marker:
            additional_params['usemarker'] = True
            return MarkerBasedObjectCollection(
                url=url,
                session=self._session,
                limit=limit,
                marker=marker,
                fields=fields,
                additional_params=additional_params,
                return_full_pages=False,
            )

        return LimitOffsetBasedObjectCollection(
            url=url,
            session=self._session,
            limit=limit,
            offset=offset,
            fields=fields,
            additional_params=additional_params,
            return_full_pages=False,
        )