示例#1
0
    def list(self,
             email=None,
             externalId=None,
             userName=None,
             startIndex=None,
             count=None):
        """
        Search users. Optional search parameters are 'email', 'externalId' and 'userName'.
        startIndex (starts with 1) and count may be used for pagination

        Returns a list of User objects, with additional total_count and offset attributes.
        """
        url = self._client.get_url(self._url_template)
        filters = base.filter_none_values(
            dict(email=email, externalId=externalId, userName=userName))
        params = base.filter_none_values(
            dict(startIndex=startIndex, count=count))
        params['filter'] = [
            u'%s eq "%s"' % (k, v) for (k, v) in filters.items()
        ]
        json = exc.default.check_json_response(
            self._client.GET(url, params=params))
        return base.ResultList(
            (User(self._client, **d) for d in json.get('resources', ())),
            json['totalResults'], json['startIndex'] - 1)
示例#2
0
    def list(self, email=None, externalId=None, userName=None, startIndex=None, count=None):
        """
        Search users. Optional search parameters are 'email', 'externalId' and 'userName'.
        startIndex (starts with 1) and count may be used for pagination

        Returns a list of User objects, with additional total_count and offset attributes.
        """
        url = self._client.get_url(self._url_template)
        filters = base.filter_none_values(dict(email=email, externalId=externalId, userName=userName))
        params = base.filter_none_values(dict(startIndex=startIndex, count=count))
        params['filter'] = [u'%s eq "%s"' % (k, v) for (k, v) in filters.items()]
        json = exc.default.check_json_response(self._client.GET(url, params=params))
        return base.ResultList((User(self._client, **d) for d in json.get('resources', ())), json['totalResults'], json['startIndex'] - 1)
示例#3
0
    def create(self, userName, externalId, email, familyName, givenName, active=True, sendInvite=True, authType='egnyte',
               userType='power', role=None, idpUserId=None, userPrincipalName=None):
        """
        Create a new user account. Parameters:

        * userName: The Egnyte username for the user. Username must start with a letter or digit. Special characters are not supported (with the exception of periods, hyphens, and underscores).
        * externalId: This is an immutable unique identifier provided by the API consumer. Any plain text (e.g. S-1-5-21-3623811015-3361044348-30300820-1013)
        * email: The email address of the user. Any valid email address (e.g. [email protected])
        * familyName: The last name of the user. Any plain text (e.g. John)
        * givenName: The first name of the user. Any plain text (e.g. Smith)
        * active: Whether the user is active or inactive. True or False
        * sendInvite: If set to true when creating a user, an invitation email will be sent (if the user is created in active state). True or False
        * authType: The authentication type for the user. 'ad' (AD), 'sso' (SAML SSO), 'egnyte' (Internal Egnyte)
        * userType: The type of the user. 'admin' (Administrator), 'power' (Power User), 'standard' (Standard User)
        * role: The role assigned to the user. Only applicable for Power Users. Default or custom role name
        * idpUserId: Only required if the user is SSO authenticated and not using default user mapping. Do not specify if user is not SSO authenticated. This is the way the user is identified within the SAML Response from an SSO Identity Provider, i.e. the SAML Subject (e.g. jsmith)
        * userPrincipalName: Do not specify if user is not AD authenticated. Used to bind child authentication policies to a user when using Active Directory authentication in a multi-domain setup (e.g. [email protected])

        Returns created User object.
        """
        url = self._client.get_url(self._url_template)
        data = base.filter_none_values(dict(userName=userName, externalId=externalId, email=email,
                                            name=dict(familyName=familyName, givenName=givenName), active=active, sendInvite=sendInvite, authType=authType,
                                            userType=userType, role=role, idpUserId=idpUserId, userPrincipalName=userPrincipalName))
        json = exc.created.check_json_response(self._client.POST(url, data))
        return User(self._client, **json)
示例#4
0
 def set_permissions(self, permission, users=None, groups=None):
     """
     Set permission level for some users and/or groups for this folder.
     """
     url = self._client.get_url(self._url_template_permissions, path=self.path)
     data = base.filter_none_values(dict(permission=permission, users=users, groups=groups))
     exc.default.check_response(self._client.POST(url, data))
示例#5
0
 def set_permissions(self, permission, users=None, groups=None):
     """
     Set permission level for some users and/or groups for this folder.
     """
     url = self._client.get_url(self._url_template_permissions, path=self.path)
     data = base.filter_none_values(dict(permission=permission, users=users, groups=groups))
     exc.default.check_response(self._client.POST(url, data))
示例#6
0
    def files(self, 
              query = None, 
              offset = None, 
              count = None, 
              folder = None, 
              modified_after = None, 
              modified_before = None,
              namespaces = None,
              custom_metadata = None,
              sort_by = None,
              sort_direction = 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 datetime (datetime.date object or ISO 8601 format datetime string {YYYY-MM-DDTHH:MM:SS}).
        * modified_after Limit to results after the specified datetime timestamp (datetime.date or ISO 8601 format datetime string {YYYY-MM-DDTHH:MM:SS}).
        * namespaces List of strings containing the name of the namespaces requested. Namespace will only return if there is a value in any of the fields.
        * custom_metadata Either this or query is required. List of JSON containing values to search - See https://developers.egnyte.com/docs/read/Search_API#Search%20v2
        * sort_by Returns sorted search results. Valid values are one of {"last_modified", "size", "score", "name"}.
        * sort_direction Sort results in ascending or descending order.

        Returns list of SearchMatch objects, with additional attributes offset, total_count and has_more.
        """
        
        if not query and not custom_metadata:
            raise exc.InvalidParameters(
                "query and custom_metadata both can't be None at the same time. "
                "Either pass the query or custom_metadata or both to search."
            )
         
        if sort_by and sort_by not in self._sort_by:
            raise exc.InvalidParameters(
                "Invalid sort_by, it must be one of %s" % self._sort_by
            )
        
        if sort_direction and sort_direction not in self._sort_dir:
            raise exc.InvalidParameters(
                "Invalid sort_direction, it must be one of %s" % self._sort_dir
            )
        
        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_in_ms(modified_after),
            modified_before=base.date_in_ms(modified_before),
            custom_metadata=custom_metadata,
            namespaces=namespaces,
            sort_by=sort_by,
            sort_direction=sort_direction)
        )
        json = exc.default.check_json_response(self._client.POST(url, json=params))
        return base.ResultList((SearchMatch(self._client, **d) for d in json.get('results', ())), json['total_count'], json['offset'], json['hasMore'])
示例#7
0
    def list(self, displayName=None, startIndex=None, count=None):
        """
        List existing groups.
        Optional filtering parameters:
        
        * displayName: Filter by name of the group. This may contain '*' wildcards at beginning for prefix search or both at beginning and end for contains search.

        Returns list of Group objects, with additional attributes total_result and offset
        """
        params = base.filter_none_values(
            dict(startIndex=startIndex, count=count))
        if displayName:
            if displayName.startswith('*'):
                op = 'co' if displayName.endswith('*') else 'sw'
            else:
                op = 'eq'
            params['filter'] = [
                u'displayName %s "%s"' % (op, displayName.strip('*'))
            ]
        url = self._client.get_url(self._url_template)
        json = exc.default.check_json_response(
            self._client.GET(url, params=params))
        return base.ResultList(
            (Group(self._client, **d) for d in json.pop('resources', ())),
            json['totalResults'], json['startIndex'] - 1)
示例#8
0
    def create(self, userName, externalId, email, familyName, givenName, active=True, sendInvite=True, authType='egnyte',
               userType='power', role=None, idpUserId=None, userPrincipalName=None):
        """
        Create a new user account. Parameters:

        * userName: The Egnyte username for the user. Username must start with a letter or digit. Special characters are not supported (with the exception of periods, hyphens, and underscores).
        * externalId: This is an immutable unique identifier provided by the API consumer. Any plain text (e.g. S-1-5-21-3623811015-3361044348-30300820-1013)
        * email: The email address of the user. Any valid email address (e.g. [email protected])
        * familyName: The last name of the user. Any plain text (e.g. John)
        * givenName: The first name of the user. Any plain text (e.g. Smith)
        * active: Whether the user is active or inactive. True or False
        * sendInvite: If set to true when creating a user, an invitation email will be sent (if the user is created in active state). True or False
        * authType: The authentication type for the user. 'ad' (AD), 'sso' (SAML SSO), 'egnyte' (Internal Egnyte)
        * userType: The type of the user. 'admin' (Administrator), 'power' (Power User), 'standard' (Standard User)
        * role: The role assigned to the user. Only applicable for Power Users. Default or custom role name
        * idpUserId: Only required if the user is SSO authenticated and not using default user mapping. Do not specify if user is not SSO authenticated. This is the way the user is identified within the SAML Response from an SSO Identity Provider, i.e. the SAML Subject (e.g. jsmith)
        * userPrincipalName: Do not specify if user is not AD authenticated. Used to bind child authentication policies to a user when using Active Directory authentication in a multi-domain setup (e.g. [email protected])

        Returns created User object.
        """
        url = self._client.get_url(self._url_template)
        data = base.filter_none_values(dict(userName=userName, externalId=externalId, email=email,
                                            name=dict(familyName=familyName, givenName=givenName), active=active, sendInvite=sendInvite, authType=authType,
                                            userType=userType, role=role, idpUserId=idpUserId, userPrincipalName=userPrincipalName))
        json = exc.created.check_json_response(self._client.POST(url, data))
        return User(self._client, **json)
示例#9
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'])
示例#10
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'])
示例#11
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
示例#12
0
    def update(self, email=None, familyName=None, givenName=None, active=None, sendInvite=None, authType=None,
               userType=None, idpUserId=None, userPrincipalName=None):
        """
        Modify this user account.
        Optional parameters (no change if value is None):

        * email: The email address of the user. Any valid email address (e.g. [email protected])
        * familyName: The last name of the user. Any plain text (e.g. John)
        * givenName: The first name of the user. Any plain text (e.g. Smith)
        * active: Whether the user is active or inactive. True or False
        * sendInvite: If set to true when creating a user, an invitation email will be sent (if the user is created in active state). True or False
        * authType: The authentication type for the user. 'ad' (AD), 'sso' (SAML SSO), 'egnyte' (Internal Egnyte)
        * userType: The Egnyte role of the user. 'admin' (Administrator), 'power' (Power User), 'standard' (Standard User)
        * idpUserId: Only required if the user is SSO authenticated and not using default user mapping. Do not specify if user is not SSO authenticated. This is the way the user is identified within the SAML Response from an SSO Identity Provider, i.e. the SAML Subject (e.g. jsmith)
        * userPrincipalName: Do not specify if user is not AD authenticated. Used to bind child authentication policies to a user when using Active Directory authentication in a multi-domain setup (e.g. [email protected])
        """
        url = self._client.get_url(self._url_template, id=self.id)
        name = base.filter_none_values(dict(familyName=familyName, givenName=givenName)) or None
        data = base.filter_none_values(dict(email=email, active=active, name=name, sendInvite=sendInvite, authType=authType, idpUserId=idpUserId, userPrincipalName=userPrincipalName))
        json = exc.default.check_json_response(self._client.PATCH(url, data))
        self._update_attributes(json)
示例#13
0
    def update(self, email=None, familyName=None, givenName=None, active=None, sendInvite=None, authType=None,
               userType=None, idpUserId=None, userPrincipalName=None):
        """
        Modify this user account.
        Optional parameters (no change if value is None):

        * email: The email address of the user. Any valid email address (e.g. [email protected])
        * familyName: The last name of the user. Any plain text (e.g. John)
        * givenName: The first name of the user. Any plain text (e.g. Smith)
        * active: Whether the user is active or inactive. True or False
        * sendInvite: If set to true when creating a user, an invitation email will be sent (if the user is created in active state). True or False
        * authType: The authentication type for the user. 'ad' (AD), 'sso' (SAML SSO), 'egnyte' (Internal Egnyte)
        * userType: The Egnyte role of the user. 'admin' (Administrator), 'power' (Power User), 'standard' (Standard User)
        * idpUserId: Only required if the user is SSO authenticated and not using default user mapping. Do not specify if user is not SSO authenticated. This is the way the user is identified within the SAML Response from an SSO Identity Provider, i.e. the SAML Subject (e.g. jsmith)
        * userPrincipalName: Do not specify if user is not AD authenticated. Used to bind child authentication policies to a user when using Active Directory authentication in a multi-domain setup (e.g. [email protected])
        """
        url = self._client.get_url(self._url_template, id=self.id)
        name = base.filter_none_values(dict(familyName=familyName, givenName=givenName)) or None
        data = base.filter_none_values(dict(email=email, active=active, name=name, sendInvite=sendInvite, authType=authType, idpUserId=idpUserId, userPrincipalName=userPrincipalName))
        json = exc.default.check_json_response(self._client.PATCH(url, data))
        self._update_attributes(json)
示例#14
0
 def list(self, start_id, count=None):
     """
     Get detailed data about up to 'count' events 'start_id'.
     """
     if start_id is None:
         start_id = self.start_id
     params = base.filter_none_values(dict(id=start_id, suppress=self.suppress, type=self.types, count=count))
     url = self._client.get_url(self._url_template_list)
     json = exc.no_content_ok.check_json_response(self._client.GET(url, params=params))
     if json is None:
         return ()
     else:
         return base.ResultList((Event(self._client, **d) for d in json.get('events', ())), json['latest_id'], start_id)
示例#15
0
 def list(self, start_id, count=None):
     """
     Get detailed data about up to 'count' events 'start_id'.
     """
     if start_id is None:
         start_id = self.start_id
     params = base.filter_none_values(dict(id=start_id, suppress=self.suppress, type=self.types, count=count, folder=self.folder))
     url = self._client.get_url(self._url_template_list)
     json = exc.no_content_ok.check_json_response(self._client.GET(url, params=params))
     if json is None:
         return ()
     else:
         return base.ResultList((Event(self._client, **d) for d in json.get('events', ())), json['latest_id'], start_id)
示例#16
0
    def filter(self, start_id=None, suppress=None, folder=None, types=None):
        """
        Returns a filtered view of the events,

        Parameters:
        * start_id - return all events occurred after id from the previous request (the events shouldn't overlap between calls). defaults to latest_event_id
        * folder (optional) - return events occurred only for this folders and all its content (subfolders, files and notes).
        * suppress (optional) - filter out events from requesting client or filter out events from requesting client done by requesting user. Allowed values: app, user or none (defaults to no filter)
        * types (optional) - return only events of given types.

        """
        if types is not None:
            types = '|'.join(types)
        d = self.__dict__.copy()
        d.update(base.filter_none_values(dict(start_id=start_id, suppress=suppress, type=types)))
        return self.__class__(**d)
示例#17
0
    def filter(self, start_id=None, suppress=None, folder=None, types=None):
        """
        Returns a filtered view of the events,

        Parameters:
        * start_id - return all events occurred after id from the previous request (the events shouldn't overlap between calls). defaults to latest_event_id
        * folder (optional) - return events occurred only for this folders and all its content (subfolders, files and notes).
        * suppress (optional) - filter out events from requesting client or filter out events from requesting client done by requesting user. Allowed values: app, user or none (defaults to no filter)
        * types (optional) - return only events of given types.

        """
        if types is not None:
            types = '|'.join(types)
        d = self.__dict__.copy()
        d.update(base.filter_none_values(dict(start_id=start_id, suppress=suppress, folder=folder, type=types)))
        return self.__class__(**d)
示例#18
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'])
示例#19
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'])
示例#20
0
    def list(self, displayName=None, startIndex=None, count=None):
        """
        List existing groups.
        Optional filtering parameters:
        
        * displayName: Filter by name of the group. This may contain '*' wildcards at beginning for prefix search or both at beginning and end for contains search.

        Returns list of Group objects, with additional attributes total_result and offset
        """
        params = base.filter_none_values(dict(startIndex=startIndex, count=count))
        if displayName:
            if displayName.startswith('*'):
                op = 'co' if displayName.endswith('*') else 'sw'
            else:
                op = 'eq'
            params['filter'] = [u'displayName %s "%s"' % (op, displayName.strip('*'))]
        url = self._client.get_url(self._url_template)
        json = exc.default.check_json_response(self._client.GET(url, params=params))
        return base.ResultList((Group(self._client, **d) for d in json.pop('resources', ())), json['totalResults'], json['startIndex'] - 1)
示例#21
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'])
示例#22
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'])
示例#23
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