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)
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'])
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)
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'])
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)
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'])
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'])