platypush/plugins/google/drive/__init__.py
def files(self,
              filter: Optional[str] = None,
              folder_id: Optional[str] = None,
              limit: Optional[int] = 100,
              drive_id: Optional[str] = None,
              spaces: Optional[Union[str, List[str]]] = None,
              order_by: Optional[Union[str, List[str]]] = None) -> Union[GoogleDriveFile, List[GoogleDriveFile]]:
        """
        Get the list of files.

        :param filter: Optional filter (default: None). See
            `Google Drive API docs <https://developers.google.com/drive/api/v3/search-files>`_ for
            the supported syntax.

        :param folder_id: Drive folder ID to search (default: get all files).
        :param limit: Maximum number of entries to be retrieves (default: 100).
        :param drive_id: Shared drive ID to search (default: None).
        :param spaces: Drive spaces to search. Supported values:

            - ``drive``
            - ``appDataFolder``
            - ``photos``

        :param order_by: Order the results by a specific attribute or list
            of attributes (default: None). Supported attributes:

                - ``createdTime``
                - ``folder``
                - ``modifiedByMeTime``
                - ``modifiedTime``
                - ``name``
                - ``name_natural``
                - ``quotaBytesUsed``
                - ``recency``
                - ``sharedWithMeTime``
                - ``starred``
                - ``viewedByMeTime``

            Attributes will be sorted in ascending order by default. You can change that by
            by appending "``desc``" separated by a space to the attribute you want in descending
            order - e.g. ``["folder", "createdTime desc", "modifiedTime desc"]``.
        """

        service = self.get_service()
        page_token = None
        files = []

        if isinstance(order_by, list):
            order_by = ','.join(order_by)
        if isinstance(spaces, list):
            spaces = ','.join(spaces)
        if folder_id:
            if not filter:
                filter = ''
            else:
                filter += ' '

            filter += "'{}' in parents".format(folder_id)

        while True:
            results = service.files().list(
                q=filter,
                driveId=drive_id,
                pageSize=limit,
                orderBy=order_by,
                fields="nextPageToken, files(id, name, kind, mimeType)",
                pageToken=page_token,
                spaces=spaces,
            ).execute()

            page_token = results.get('nextPageToken')
            files.extend([
                GoogleDriveFile(
                    id=f.get('id'),
                    name=f.get('name'),
                    type=f.get('kind').split('#')[1],
                    mime_type=f.get('mimeType'),
                ) for f in results.get('files', [])
            ])

            if not page_token or (limit and len(files) >= limit):
                break

        return files

        Get the list of files.

        :param filter: Optional filter (default: None). See
            `Google Drive API docs <https://developers.google.com/drive/api/v3/search-files>`_ for
            the supported syntax.

        :param folder_id: Drive folder ID to search (default: get all files).
        :param limit: Maximum number of entries to be retrieves (default: 100).
        :param drive_id: Shared drive ID to search (default: None).
        :param spaces: Drive spaces to search. Supported values:

            - ``drive``
            - ``appDataFolder``
            - ``photos``

        :param order_by: Order the results by a specific attribute or list
            of attributes (default: None). Supported attributes:

                - ``createdTime``
                - ``folder``
                - ``modifiedByMeTime``
                - ``modifiedTime``
                - ``name``
                - ``name_natural``
                - ``quotaBytesUsed``
                - ``recency``
                - ``sharedWithMeTime``
                - ``starred``
                - ``viewedByMeTime``

            Attributes will be sorted in ascending order by default. You can change that by
            by appending "``desc``" separated by a space to the attribute you want in descending
            order - e.g. ``["folder", "createdTime desc", "modifiedTime desc"]``.
        
Get the list of files.
Get the list of files .
def files(self,
              filter: Optional[str] = None,
              folder_id: Optional[str] = None,
              limit: Optional[int] = 100,
              drive_id: Optional[str] = None,
              spaces: Optional[Union[str, List[str]]] = None,
              order_by: Optional[Union[str, List[str]]] = None) -> Union[GoogleDriveFile, List[GoogleDriveFile]]:
        service = self.get_service()
        page_token = None
        files = []
        if isinstance(order_by, list):
            order_by = ','.join(order_by)
        if isinstance(spaces, list):
            spaces = ','.join(spaces)
        if folder_id:
            if not filter:
                filter = ''
            else:
                filter += ' '
            filter += "'{}' in parents".format(folder_id)
        while True:
            results = service.files().list(
                q=filter,
                driveId=drive_id,
                pageSize=limit,
                orderBy=order_by,
                fields="nextPageToken, files(id, name, kind, mimeType)",
                pageToken=page_token,
                spaces=spaces,
            ).execute()
            page_token = results.get('nextPageToken')
            files.extend([
                GoogleDriveFile(
                    id=f.get('id'),
                    name=f.get('name'),
                    type=f.get('kind').split('#')[1],
                    mime_type=f.get('mimeType'),
                ) for f in results.get('files', [])
            ])
            if not page_token or (limit and len(files) >= limit):
                break
        return files
def files ( self , filter : Optional [ str ] = None , folder_id : Optional [ str ] = None , limit : Optional [ int ] = 100 , drive_id : Optional [ str ] = None , spaces : Optional [ Union [ str , List [ str ] ] ] = None , order_by : Optional [ Union [ str , List [ str ] ] ] = None ) -> Union [ GoogleDriveFile , List [ GoogleDriveFile ] ] : service = self . get_service ( ) page_token = None files = [ ] if isinstance ( order_by , list ) : order_by = ',' . join ( order_by ) if isinstance ( spaces , list ) : spaces = ',' . join ( spaces ) if folder_id : if not filter : filter = '' else : filter += ' ' filter += "'{}' in parents" . format ( folder_id ) while True : results = service . files ( ) . list ( q = filter , driveId = drive_id , pageSize = limit , orderBy = order_by , fields = "nextPageToken, files(id, name, kind, mimeType)" , pageToken = page_token , spaces = spaces , ) . execute ( ) page_token = results . get ( 'nextPageToken' ) files . extend ( [ GoogleDriveFile ( id = f . get ( 'id' ) , name = f . get ( 'name' ) , type = f . get ( 'kind' ) . split ( '#' ) [ 1 ] , mime_type = f . get ( 'mimeType' ) , ) for f in results . get ( 'files' , [ ] ) ] ) if not page_token or ( limit and len ( files ) >= limit ) : break return files
Get the list of files.
Get the list of files .
"""
        Get the list of files.

        :param filter: Optional filter (default: None). See
            `Google Drive API docs <https://developers.google.com/drive/api/v3/search-files>`_ for
            the supported syntax.

        :param folder_id: Drive folder ID to search (default: get all files).
        :param limit: Maximum number of entries to be retrieves (default: 100).
        :param drive_id: Shared drive ID to search (default: None).
        :param spaces: Drive spaces to search. Supported values:

            - ``drive``
            - ``appDataFolder``
            - ``photos``

        :param order_by: Order the results by a specific attribute or list
            of attributes (default: None). Supported attributes:

                - ``createdTime``
                - ``folder``
                - ``modifiedByMeTime``
                - ``modifiedTime``
                - ``name``
                - ``name_natural``
                - ``quotaBytesUsed``
                - ``recency``
                - ``sharedWithMeTime``
                - ``starred``
                - ``viewedByMeTime``

            Attributes will be sorted in ascending order by default. You can change that by
            by appending "``desc``" separated by a space to the attribute you want in descending
            order - e.g. ``["folder", "createdTime desc", "modifiedTime desc"]``.
        """
self
filter
Optional[str]
Optional filter (default: None). See
`Google Drive API docs `_ for
the supported syntax.
Optional filter ( default : None ) . See ` Google Drive API docs ` _ for the supported syntax .
folder_id
Optional[str]
Drive folder ID to search (default: get all files).
Drive folder ID to search ( default : get all files ) .
limit
Optional[int]
Maximum number of entries to be retrieves (default: 100).
Maximum number of entries to be retrieves ( default : 100 ) .
drive_id
Optional[str]
Shared drive ID to search (default: None).
Shared drive ID to search ( default : None ) .
spaces
Optional[Union[str, List[str]]]
Drive spaces to search. Supported values:
``drive``
``appDataFolder``
``photos``
Drive spaces to search . Supported values : ` ` drive ` ` ` ` appDataFolder ` ` ` ` photos ` `
order_by
Optional[Union[str, List[str]]]
Order the results by a specific attribute or list
of attributes (default: None). Supported attributes.

``createdTime``
``folder``
``modifiedByMeTime``
``modifiedTime``
``name``
``name_natural``
``quotaBytesUsed``
``recency``
``sharedWithMeTime``
``starred``
``viewedByMeTime``

Attributes will be sorted in ascending order by default. You can change that by
by appending "``desc``" separated by a space to the attribute you want in descending
order - e.g. ``["folder", "createdTime desc", "modifiedTime desc"]``.
Order the results by a specific attribute or list of attributes ( default : None ) . Supported attributes . ` ` createdTime ` ` ` ` folder ` ` ` ` modifiedByMeTime ` ` ` ` modifiedTime ` ` ` ` name ` ` ` ` name_natural ` ` ` ` quotaBytesUsed ` ` ` ` recency ` ` ` ` sharedWithMeTime ` ` ` ` starred ` ` ` ` viewedByMeTime ` ` Attributes will be sorted in ascending order by default . You can change that by by appending " ` ` desc ` ` " separated by a space to the attribute you want in descending order - e . g . ` ` [ " folder " " createdTime desc " " modifiedTime desc " ] ` ` .