Exemple #1
0
    def files(self, query, offset=None, count=None, folder=None, modified_after=None, modified_before=None):
        """
        Search for files.
        Parameters:

        * query The search string you want to find. * is supported as a postfix wildcard, AND and OR as bool operations and double quotes for phrase search.
        * offset The 0-based index of the initial record being requested (Integer >= 0).
        * count The number of entries per page (min 1, max 100)
        * folder Limit the result set to only items contained in the specified folder.
        * modified_before Limit to results before the specified ISO-8601 timestamp (datetime.date object or string).
        * modified_after Limit to results after the specified ISO-8601 timestamp (datetime.date object or string).

        Returns list of SearchMatch objects, with additional attributes total_count and offset.
        """
        url = self._client.get_url(self._url_template)
        params = base.filter_none_values(dict(
            query=query,
            offset=offset,
            count=count,
            folder=folder,
            modified_after=base.date_format(modified_after),
            modified_before=base.date_format(modified_before))
        )
        json = exc.default.check_json_response(self._client.GET(url, params=params))
        return base.ResultList((SearchMatch(self._client, **d) for d in json.get('results', ())), json['total_count'], json['offset'])
Exemple #2
0
    def files(self,
              query,
              offset=None,
              count=None,
              folder=None,
              modified_after=None,
              modified_before=None):
        """
        Search for files.
        Parameters:

        * query The search string you want to find. * is supported as a postfix wildcard, AND and OR as bool operations and double quotes for phrase search.
        * offset The 0-based index of the initial record being requested (Integer >= 0).
        * count The number of entries per page (min 1, max 100)
        * folder Limit the result set to only items contained in the specified folder.
        * modified_before Limit to results before the specified ISO-8601 timestamp (datetime.date object or string).
        * modified_after Limit to results after the specified ISO-8601 timestamp (datetime.date object or string).

        Returns list of SearchMatch objects, with additional attributes total_count and offset.
        """
        url = self._client.get_url(self._url_template)
        params = base.filter_none_values(
            dict(query=query,
                 offset=offset,
                 count=count,
                 folder=folder,
                 modified_after=base.date_format(modified_after),
                 modified_before=base.date_format(modified_before)))
        json = exc.default.check_json_response(
            self._client.GET(url, params=params))
        return base.ResultList(
            (SearchMatch(self._client, **d) for d in json.get('results', ())),
            json['total_count'], json['offset'])
Exemple #3
0
    def permissions(self, format, date_start, date_end, folders, assigners,
                    assignee_users, assignee_groups):
        """
        Generate permissions report.
        Parameters:

        * format: 'csv' or 'json'
        * date_start: string in 'YYYY-MM-DD' format or datetime.date - first day report should cover
        * date_end: string in 'YYYY-MM-DD' format or datetime.date - last day report should cover

        Returns an AuditReport object.
        """
        json = dict(format=format,
                    date_start=base.date_format(date_start),
                    date_end=base.date_format(date_end),
                    folders=list(folders),
                    assigners=list(assigners),
                    assignee_users=list(assignee_users),
                    assignee_groups=list(assignee_groups))
        url = self._client.get_url(self._url_template, type="permissions")
        r = self._client.POST(url, json)
        return AuditReport(self._client,
                           id=self._job_id(r),
                           format=format,
                           type='permissions')
Exemple #4
0
    def files(self, format, date_start, date_end, folders=None, file=None, users=None, transaction_type=None):
        """
        Generate files report.
        Parameters:

        * format: 'csv' or 'json'
        * date_start: string in 'YYYY-MM-DD' format or datetime.date - first day report should cover
        * date_end: string in 'YYYY-MM-DD' format or datetime.date - last day report should cover

        Returns an AuditReport object.
        """
        json = dict(format=format,
                    date_start=base.date_format(date_start),
                    date_end=base.date_format(date_end))
        if folders:
            json['folders'] = list(folders)
        if file:
            json['file'] = file
        if users:
            json['users'] = list(users)
        if transaction_type:
            json['transaction_type'] = list(transaction_type)
        url = self._client.get_url(self._url_template, type="files")
        r = self._client.POST(url, json)
        return AuditReport(self._client, id=self._job_id(r), format=format, type='files')
Exemple #5
0
    def files(self,
              format,
              date_start,
              date_end,
              folders=None,
              file=None,
              users=None,
              transaction_type=None):
        """
        Generate files report.
        Parameters:

        * format: 'csv' or 'json'
        * date_start: string in 'YYYY-MM-DD' format or datetime.date - first day report should cover
        * date_end: string in 'YYYY-MM-DD' format or datetime.date - last day report should cover

        Returns an AuditReport object.
        """
        json = dict(format=format,
                    date_start=base.date_format(date_start),
                    date_end=base.date_format(date_end))
        if folders:
            json['folders'] = list(folders)
        if file:
            json['file'] = file
        if users:
            json['users'] = list(users)
        if transaction_type:
            json['transaction_type'] = list(transaction_type)
        url = self._client.get_url(self._url_template, type="files")
        r = self._client.POST(url, json)
        return AuditReport(self._client,
                           id=self._job_id(r),
                           format=format,
                           type='files')
Exemple #6
0
    def logins(self,
               format,
               date_start,
               date_end,
               events,
               access_points=None,
               users=None):
        """
        Generate login report.
        Parameters:

        * format: 'csv' or 'json'
        * date_start: string in 'YYYY-MM-DD' format or datetime.date - first day report should cover
        * date_end: string in 'YYYY-MM-DD' format or datetime.date - last day report should cover
        * events: list of events to report on, at least one must be specified, allowed values: logins, logouts, account_lockouts, password_resets, failed_attempts

        Returns an AuditReport object.
        """
        json = dict(format=format,
                    date_start=base.date_format(date_start),
                    date_end=base.date_format(date_end),
                    events=list(events))
        if access_points:
            json['access_points'] = list(access_points)
        if users:
            json['users'] = list(users)
        url = self._client.get_url(self._url_template, type="logins")
        r = self._client.POST(url, json)
        return AuditReport(self._client,
                           id=self._job_id(r),
                           format=format,
                           type='logins')
Exemple #7
0
    def logins(self,
               format,
               date_start,
               date_end,
               events,
               access_points=None,
               users=None):
        """
        Generate login report.
        Parameters:

        * format: 'csv' or 'json'
        * date_start: string in 'YYYY-MM-DD' format or datetime.date - first day report should cover
        * date_end: string in 'YYYY-MM-DD' format or datetime.date - last day report should cover

        Returns an AuditReport object.
        """
        json = dict(format=format,
                    date_start=base.date_format(date_start),
                    date_end=base.date_format(date_end),
                    events=list(events))
        if access_points:
            json['access_points'] = list(access_points)
        if users:
            json['users'] = list(users)
        url = self._client.get_url(self._url_template, type="logins")
        r = self._client.POST(url, json)
        return AuditReport(self._client,
                           id=self._job_id(r),
                           format=format,
                           type='logins')
Exemple #8
0
    def list(self, file=None, folder=None, start_time=None, end_time=None):
        """
        List existing notes.
        Optional filtering parameters:

        * start_time: Get notes created after start_time (datetime.date or string in 'YYYY-MM-DD' format)
        * file: Get only notes attached to a specific file (path).
        * folder: Get only notes atatched to files in specific folder (path).
        * end_time: Get notes created before end_time (datetime.date or string in 'YYYY-MM-DD' format)

        Returns list of Note objects, with additional attributes total_count and offset.
        """
        url = self._client.get_url(self._url_template)
        params = base.filter_none_values(dict(file=file, folder=folder, start_time=base.date_format(start_time),
                                              end_time=base.date_format(end_time)))
        json = exc.default.check_json_response(self._client.GET(url, params=params))
        return base.ResultList((Note(self._client, **d) for d in json.pop('notes', ())), json['total_results'], json['offset'])
Exemple #9
0
    def list(self, file=None, folder=None, start_time=None, end_time=None):
        """
        List existing notes.
        Optional filtering parameters:

        * start_time: Get notes created after start_time (datetime.date or string in 'YYYY-MM-DD' format)
        * file: Get only notes attached to a specific file (path).
        * folder: Get only notes atatched to files in specific folder (path).
        * end_time: Get notes created before end_time (datetime.date or string in 'YYYY-MM-DD' format)

        Returns list of Note objects, with additional attributes total_count and offset.
        """
        url = self._client.get_url(self._url_template)
        params = base.filter_none_values(dict(file=file, folder=folder, start_time=base.date_format(start_time),
                                              end_time=base.date_format(end_time)))
        json = exc.default.check_json_response(self._client.GET(url, params=params))
        return base.ResultList((Note(self._client, **d) for d in json.pop('notes', ())), json['total_results'], json['offset'])
Exemple #10
0
    def create(
        self,
        path,
        type,
        accessibility,
        recipients=None,
        send_email=None,
        message=None,
        copy_me=None,
        notify=None,
        link_to_current=None,
        expiry_date=None,
        expiry_clicks=None,
        add_filename=None,
    ):
        """
        Create links.

        * path:  The absolute path of the destination file or folder.
        * type:  This determines what type of link will be created ('File' or 'Folder')
        * accessibility: Determines who a link is accessible by ('Anyone', 'Password', 'Domain', 'Recipients')
        * send_email: If True, the link will be sent via email by Egnyte.
        * recipients: List email addresses of recipients of the link. Only required if send_email is True (List of valid email addresses)
        * message: Personal message to be sent in link email. Only applies if send_email is True (plain text)
        * copy_me: If True, a copy of the link message will be sent to the link creator. Only applies if send_email is True.
        * notify: If True, link creator will be notified via email when link is accessed.
        * link_to_current: If True, link will always refer to current version of file. Only applicable for file links.
        * expiry_date: The expiry date for the link. If expiry_date is specified, expiry_clicks cannot be set (future date as datetime.date or string in YYYY-MM-DD format)
        * expiry_clicks: The number of clicks the link is valid for. If expiry_clicks is specified, expiry_date cannot be set (value must be between 1 - 10, inclusive)
        * add_filename: If True then the filename will be appended to the end of the link. Only applies to file links, not folder links.

        Will return a sequence of created Links, one for each recipient.
        """
        url = self._client.get_url(self._url_template)
        data = base.filter_none_values(
            dict(path=path,
                 type=type,
                 accessibility=accessibility,
                 send_email=send_email,
                 copy_me=copy_me,
                 notify=notify,
                 add_filename=add_filename,
                 link_to_current=link_to_current,
                 expiry_clicks=expiry_clicks,
                 expiry_date=base.date_format(expiry_date),
                 recipients=recipients,
                 message=message))
        response = exc.default.check_json_response(self._client.POST(
            url, data))
        # This response has weird structure
        links = response.pop('links')
        result = []
        for l in links:
            l.update(response)
            result.append(Link(self._client, **l))
        return result
Exemple #11
0
    def permissions(self, format, date_start, date_end, folders, assigners, assignee_users, assignee_groups):
        """
        Generate permissions report.
        Parameters:

        * format: 'csv' or 'json'
        * date_start: string in 'YYYY-MM-DD' format or datetime.date - first day report should cover
        * date_end: string in 'YYYY-MM-DD' format or datetime.date - last day report should cover

        Returns an AuditReport object.
        """
        json = dict(format=format,
                    date_start=base.date_format(date_start),
                    date_end=base.date_format(date_end),
                    folders=list(folders),
                    assigners=list(assigners),
                    assignee_users=list(assignee_users),
                    assignee_groups=list(assignee_groups))
        url = self._client.get_url(self._url_template, type="permissions")
        r = self._client.POST(url, json)
        return AuditReport(self._client, id=self._job_id(r), format=format, type='permissions')
Exemple #12
0
    def list(self,
             path=None,
             username=None,
             created_before=None,
             created_after=None,
             type=None,
             accessibility=None,
             offset=None,
             count=None):
        """
        Search links that match following optional conditions:

        * path: List links to this file or folder (Full absolute path of destination file or folder)
        * username: List links created by this user (Any username from your Egnyte account)
        * created_before: List links created before this date (datetime.date, or string in YYYY-MM-DD format)
        * created_after: List links created after this date (datetime.date, or string in YYYY-MM-DD format)
        * type: Links of selected type will be shown ('File' or 'Folder')
        * accessibility: Links of selected accessibility will be shown ('Anyone', 'Password', 'Domain', or 'Recipients')
        * offset: Start at this link, where offset=0 means start with first link.
        * count: Send this number of links. If not specified, all links will be sent.

        Returns a list of Link objects, with additional total_count and offset attributes.
        """
        url = self._client.get_url(self._url_template)
        params = base.filter_none_values(
            dict(path=path,
                 username=username,
                 created_before=base.date_format(created_before),
                 created_after=base.date_format(created_after),
                 type=type,
                 accessibility=accessibility,
                 offset=offset,
                 count=count))
        json = exc.default.check_json_response(
            self._client.GET(url, params=params))
        return base.ResultList(
            (Link(self._client, id=id) for id in json.get('ids', ())),
            json['total_count'], json['offset'])
Exemple #13
0
    def logins(self, format, date_start, date_end, events, access_points=None, users=None):
        """
        Generate login report.
        Parameters:

        * format: 'csv' or 'json'
        * date_start: string in 'YYYY-MM-DD' format or datetime.date - first day report should cover
        * date_end: string in 'YYYY-MM-DD' format or datetime.date - last day report should cover
        * events: list of events to report on, at least one must be specified, allowed values: logins, logouts, account_lockouts, password_resets, failed_attempts

        Returns an AuditReport object.
        """
        json = dict(format=format,
                    date_start=base.date_format(date_start),
                    date_end=base.date_format(date_end),
                    events=list(events))
        if access_points:
            json['access_points'] = list(access_points)
        if users:
            json['users'] = list(users)
        url = self._client.get_url(self._url_template, type="logins")
        r = self._client.POST(url, json)
        return AuditReport(self._client, id=self._job_id(r), format=format, type='logins')
Exemple #14
0
    def list(self, path=None, username=None, created_before=None, created_after=None, type=None, accessibility=None,
             offset=None, count=None):
        """
        Search links that match following optional conditions:

        * path: List links to this file or folder (Full absolute path of destination file or folder)
        * username: List links created by this user (Any username from your Egnyte account)
        * created_before: List links created before this date (datetime.date, or string in YYYY-MM-DD format)
        * created_after: List links created after this date (datetime.date, or string in YYYY-MM-DD format)
        * type: Links of selected type will be shown ('File' or 'Folder')
        * accessibility: Links of selected accessibility will be shown ('Anyone', 'Password', 'Domain', or 'Recipients')
        * offset: Start at this link, where offset=0 means start with first link.
        * count: Send this number of links. If not specified, all links will be sent.

        Returns a list of Link objects, with additional total_count and offset attributes.
        """
        url = self._client.get_url(self._url_template)
        params = base.filter_none_values(dict(path=path, username=username, created_before=base.date_format(created_before),
                                              created_after=base.date_format(created_after), type=type, accessibility=accessibility,
                                              offset=offset, count=count))
        json = exc.default.check_json_response(self._client.GET(url, params=params))
        return base.ResultList((Link(self._client, id=id) for id in json.get('ids', ())), json['total_count'], json['offset'])
Exemple #15
0
    def create(self, path, type, accessibility,
               recipients=None, send_email=None, message=None,
               copy_me=None, notify=None, link_to_current=None,
               expiry_date=None, expiry_clicks=None, add_filename=None,
               ):
        """
        Create links.

        * path:  The absolute path of the destination file or folder.
        * type:  This determines what type of link will be created ('File' or 'Folder')
        * accessibility: Determines who a link is accessible by ('Anyone', 'Password', 'Domain', 'Recipients')
        * send_email: If True, the link will be sent via email by Egnyte.
        * recipients: List email addresses of recipients of the link. Only required if send_email is True (List of valid email addresses)
        * message: Personal message to be sent in link email. Only applies if send_email is True (plain text)
        * copy_me: If True, a copy of the link message will be sent to the link creator. Only applies if send_email is True.
        * notify: If True, link creator will be notified via email when link is accessed.
        * link_to_current: If True, link will always refer to current version of file. Only applicable for file links.
        * expiry_date: The expiry date for the link. If expiry_date is specified, expiry_clicks cannot be set (future date as datetime.date or string in YYYY-MM-DD format)
        * expiry_clicks: The number of clicks the link is valid for. If expiry_clicks is specified, expiry_date cannot be set (value must be between 1 - 10, inclusive)
        * add_filename: If True then the filename will be appended to the end of the link. Only applies to file links, not folder links.

        Will return a sequence of created Links, one for each recipient.
        """
        url = self._client.get_url(self._url_template)
        data = base.filter_none_values(dict(path=path, type=type, accessibility=accessibility, send_email=send_email,
                                            copy_me=copy_me, notify=notify, add_filename=add_filename, link_to_current=link_to_current,
                                            expiry_clicks=expiry_clicks, expiry_date=base.date_format(expiry_date),
                                            recipients=recipients, message=message))
        response = exc.default.check_json_response(self._client.POST(url, data))
        # This response has weird structure
        links = response.pop('links')
        result = []
        for l in links:
            l.update(response)
            result.append(Link(self._client, **l))
        return result