def search(self, *, filter: dict = None, limit: int = None, page: int = None, sort: dict = None, return_total: bool = False, **kwargs) -> Union[ResourcesWithTotal, List[Resource]]: """Search users. Args: filter: Search filter (refer to ``/search-users`` definition in the User and company management API for a detailed description of supported operators). limit: Optional Maximum number of results to extract. page: Optional Page number (starting at page 1). sort: Optional. Sort the results on the specified attributes (``1`` is sorting in ascending order, ``-1`` is sorting in descending order). return_total: Optional. Change the type of return: If ``False`` (default), the method will return a limited list of resources (limited by ``limit`` value). If ``True``, the method will return a namedtuple with the total number of all results, and the limited list of resources. **kwargs: Optional keyword arguments. Those arguments are passed as is to the API provider. Returns: Resources: A list of resources OR a namedtuple with total number of results and list of resources. """ return search(self, url='search-users', filter=filter, limit=limit, page=page, sort=sort, return_total=return_total, **kwargs)
def search(self, *, filter: dict = None, limit: int = None, page: int = None, return_total: bool = False, **kwargs) -> Union[ResourcesWithTotal, List[Resource]]: """Search share tokens. Share token search is restricted to users with admin profile or a manager role on their company. Args: filter: Search filter (refer to ``/search-share-tokens`` definition in the Authentication API specification for a detailed description of supported operators). limit: Optional Maximum number of results to extract. page: Optional Page number (starting at page 1). return_total: Optional. Change the type of return: If ``False`` (default), the method will return a limited list of resources (limited by ``limit`` value). If ``True``, the method will return a namedtuple with the total number of all results, and the limited list of resources. Returns: List of share token resources (with ``token``, ``expiration_date`` and ``scope`` keys) or a namedtuple with total number of results and the list of resources. """ # sort is not supported yet if kwargs.get('sort') is not None: kwargs.pop('sort') return search(self, url='search-share-tokens', filter=filter, limit=limit, page=page, return_total=return_total, **kwargs)
def search(self, *, filter: dict = None, limit: int = None, page: int = None, sort: dict = None, return_total: bool = False, **kwargs) -> Union[ResourcesWithTotal, List[Resource]]: """Search collection tasks. Args: filter: Search filter dictionary. limit: Optional Maximum number of results to extract. page: Optional Page number (starting at page 0). sort: Optional Sort the results on the specified attributes (``1`` is sorting in ascending order, ``-1`` is sorting in descending order). return_total: Optional. Change the type of return: If ``False`` (default), the method will return a limited list of resources (limited by ``limit`` value). If ``True``, the method will return a namedtuple with the total number of all results, and the limited list of resources. **kwargs: Optional keyword arguments. Those arguments are passed as is to the API provider. Returns: Resources: A list of collection task resources. """ return search(self, url='search-tasks', filter=filter, limit=limit, page=page, sort=sort, return_total=return_total, **kwargs)
def search(self, *, filter: dict = None, fields: dict = None, limit: int = 100, page: int = None, sort: dict = None, return_total: bool = False, **kwargs) -> Union[ResourcesWithTotal, List[Resource]]: """Search flights. Args: filter: Optional Search filter (refer to ``/search-flights`` definition in the Project management API for a detailed description of supported operators). fields: Optional Field names to include or exclude from the response. ``{"include: ["name", "creation_date"]}`` ``{"exclude: ["name", "creation_date"]}`` Do not use both `include` and `exclude`. limit: Optional Maximum number of results to extract (default is ``100``). page: Optional Page number (starting at page 1). sort: Optional. Sort the results on the specified attributes (``1`` is sorting in ascending order, ``-1`` is sorting in descending order). return_total: Optional. Change the type of return: If ``False`` (default), the method will return a limited list of resources (limited by ``limit`` value). If ``True``, the method will return a namedtuple with the total number of all results, and the limited list of resources. **kwargs: Optional keyword arguments. Those arguments are passed as is to the API provider. Resources: A list of resources OR a namedtuple with total number of results and list of resources. Examples: >>> # search flights by IDs (should use flights.describe() instead) >>> sdk.flights.search(filter={'_id': {'$eq': '5d6e0dcc965a0f56891f3865'}}) [Resource(_id='5d6e0dcc965a0f56891f3865'), ...] >>> # search flights of a wanted project (could use '$in' with an array of IDs) >>> sdk.flights.search(filter={'project': {'$eq': '41b9b3c7e6cd160006586688'}}) [Resource(_id='5d6e0dcc965a0f56891f3865'), ...] >>> # search flights of wanted missions >>> sdk.flights.search(filter={ ... 'mission': {'$in': ['5d6e0dcc965a0f56891f3861', '60924899669e6e0007f8d262'} ... }) [Resource(_id='5d6e0dcc965a0f56891f3865'), ...] >>> # search flights updated after December 15th 2021 >>> sdk.flights.search(filter={'modification_date': {'$gt': '2021-12-15T00:00:00'}}) [Resource(_id='5d6e0dcc965a0f56891f3865'), ...] >>> # search flights having 1000+ photos >>> sdk.flights.search(filter={'number_of_photos': {'$gte': 1000}}) [Resource(_id='5d6e0dcc965a0f56891f3865'), ...] >>> # search uncompleted flights of wanted mission (prefer describe_uploads_status()) >>> sdk.flights.search(filter={ ... 'status.name': {'$ne': 'completed'}, ... 'mission': {'eq': '5d6e0dcc965a0f56891f3861'}, ... }) [Resource(_id='5d6e0dcc965a0f56891f3865'), ...] >>> # get second page of the same search >>> sdk.flights.search(filter={...}, page=2) [Resource(_id='60924899669e6e0007f8d266'), ...] >>> # search 400 last created flights, in 2 calls (prefer search_generator() to get all) >>> sdk.flights.search(sort={'creation_date': -1}, limit=200) [Resource(_id='5d6e0dcc965a0f56891f3865'), ...] >>> sdk.flights.search(sort={'creation_date': -1}, limit=200, page=2) [Resource(_id='60924899669e6e0007f8d266'), ...] >>> # search flights and also get the total results >>> sdk.flights.search(filter={...}, return_total=True) ResourcesWithTotal(total=612, results=[Resource(_id='5d6e0dcc965a0f56891f3865'), ...]) """ if kwargs.get('project'): raise QueryError('"project" keyword not exists anymore in flights.search()') if kwargs.get('mission'): raise QueryError('"mission" keyword not exists anymore in flights.search()') return search( self, url='search-flights', filter=filter, fields=fields, limit=limit, page=page, sort=sort, return_total=return_total, **kwargs )
def search(self, *, filter: dict = None, fields: dict = None, limit: int = 100, page: int = None, sort: dict = None, return_total: bool = False, **kwargs) -> Union[ResourcesWithTotal, List[Resource]]: """Search projects. Args: filter: Optional Search filter (refer to ``/search-projects`` definition in the Project management API for a detailed description of supported operators). fields: Optional Field names to include or exclude from the response. ``{"include: ["name", "creation_date"]}`` ``{"exclude: ["name", "creation_date"]}`` Do not use both `include` and `exclude`. limit: Optional Maximum number of results to extract (default is ``100``). page: Optional Page number (starting at page 1). sort: Optional Sort the results on the specified attributes (``1`` is sorting in ascending order, ``-1`` is sorting in descending order). return_total: Optional. Change the type of return: If ``False`` (default), the method will return a limited list of resources (limited by ``limit`` value). If ``True``, the method will return a namedtuple with the total number of all results, and the limited list of resources. **kwargs: Optional keyword arguments. Those arguments are passed as is to the API provider. Resources: A list of resources OR a namedtuple with total number of results and list of resources. Examples: >>> # search projects with name exacty equals to 'my project' >>> sdk.projects.search(filter={'name': {'$eq': 'my project'}}) [Resource(_id='5d6e0dcc965a0f56891f3860'), ...] >>> # search projects having 'my' in their name (case-insensitive) >>> sdk.projects.search(filter={'name': {'$match': 'my'}}) [Resource(_id='5d6e0dcc965a0f56891f3860'), ...] >>> # search projects having 'my' in their name or place name or tags (case-insensitive) >>> sdk.projects.search(filter={'search': {'$match': 'my'}}) [Resource(_id='5d6e0dcc965a0f56891f3860'), ...] >>> # search projects by IDs (should use projects.describe() instead) >>> sdk.projects.search(filter={'_id': {'$eq': '5d6e0dcc965a0f56891f3860'}}) [Resource(_id='5d6e0dcc965a0f56891f3860'), ...] >>> # search projects of a wanted company (could use '$in' with an array of IDs) >>> sdk.projects.search(filter={'company': {'$eq': '41b9b3c7e6cd160006586688'}}) [Resource(_id='5d6e0dcc965a0f56891f3860'), ...] >>> # search projects updated after December 15th 2021 >>> sdk.projects.search(filter={'modification_date': {'$gt': '2021-12-15T00:00:00'}}) [Resource(_id='5d6e0dcc965a0f56891f3860'), ...] >>> # get second page of the same search >>> sdk.projects.search(filter={...}, page=2) [Resource(_id='60924899669e6e0007f8d261'), ...] >>> # search 400 first projects sorted by name ascending, in 2 calls >>> sdk.projects.search(sort={'name': 1}, limit=200) [Resource(_id='5d6e0dcc965a0f56891f3860'), ...] >>> sdk.projects.search(sort={'name': 1}, limit=200, page=2) [Resource(_id='60924899669e6e0007f8d261'), ...] >>> # search projects and also get the total results >>> sdk.projects.search(filter={...}, return_total=True) ResourcesWithTotal(total=940, results=[Resource(_id='5d6e0dcc965a0f56891f3860'), ...]) """ if kwargs.get('name'): raise QueryError( '"name" keyword not exists anymore in projects.search()') if kwargs.get('deleted'): raise QueryError( '"deleted" keyword not exists anymore in projects.search()') return search(self, url='search-projects', filter=filter, fields=fields, limit=limit, page=page, sort=sort, return_total=return_total, **kwargs)