def iterate(self, filter: Union[List[dict], dict], limit: int, skip: int, sort: str, order: int, user: UserModel = None, permission: AccessControlPermission = None, *args, **kwargs) \ -> IterationResult[ObjectLinkModel]: """ Iterate over a collection where the public id exists. """ try: query: Pipeline = self.query_builder.build(filter=filter, limit=limit, skip=skip, sort=sort, order=order) count_query: Pipeline = self.query_builder.count( filter=filter, user=user, permission=permission) aggregation_result = list(self._aggregate(self.collection, query)) total_cursor = self._aggregate(self.collection, count_query) total = 0 while total_cursor.alive: total = next(total_cursor)['total'] except ManagerGetError as err: raise ManagerIterationError(err=err) iteration_result: IterationResult[ObjectLinkModel] = IterationResult( aggregation_result, total) iteration_result.convert_to(ObjectLinkModel) return iteration_result
def iterate(self, filter: dict, limit: int, skip: int, sort: str, order: int, *args, **kwargs) \ -> IterationResult[ExportdJob]: """ Iterate over a collection of exportd jobs resources. Args: filter: match requirements of field values limit: max number of elements to return skip: number of elements to skip first sort: sort field order: sort order Returns: IterationResult: Instance of IterationResult with generic ExportdJob. """ try: query: Query = self.builder.build(filter=filter, limit=limit, skip=skip, sort=sort, order=order) aggregation_result = next(self._aggregate(self.collection, query)) except ManagerGetError as err: raise ManagerIterationError(err=err) iteration_result: IterationResult[ ExportdJob] = IterationResult.from_aggregation(aggregation_result) iteration_result.convert_to(ExportdJob) return iteration_result
def iterate(self, filter: dict, limit: int, skip: int, sort: str, order: int, *args, **kwargs) \ -> IterationResult[CategoryModel]: """ Iterate over a collection of type resources. Args: filter: match requirements of field values limit: max number of elements to return skip: number of elements to skip first sort: sort field order: sort order Returns: IterationResult: Instance of IterationResult with generic CategoryModel. """ try: query: Pipeline = self.builder.build(filter=filter, limit=limit, skip=skip, sort=sort, order=order) count_query: Pipeline = self.builder.count(filter=filter) aggregation_result = list(self._aggregate(self.collection, query)) total_cursor = self._aggregate(self.collection, count_query) total = 0 while total_cursor.alive: total = next(total_cursor)['total'] except ManagerGetError as err: raise ManagerIterationError(err=err) iteration_result: IterationResult[CategoryModel] = IterationResult( aggregation_result, total) iteration_result.convert_to(CategoryModel) return iteration_result
def iterate(self, filter: dict, limit: int, skip: int, sort: str, order: int, *args, **kwargs) \ -> IterationResult[CmdbObject]: try: query: Query = self.object_builder.build(filter=filter, limit=limit, skip=skip, sort=sort, order=order) aggregation_result = next(self._aggregate(self.collection, query)) except ManagerGetError as err: raise ManagerIterationError(err=err) iteration_result: IterationResult[CmdbObject] = IterationResult.from_aggregation(aggregation_result) iteration_result.convert_to(CmdbObject) return iteration_result
def get_templates(self, filter: dict, limit: int, skip: int, sort: str, order: int, *args, **kwargs) -> IterationResult[DocapiTemplate]: try: query: Pipeline = self.builder.build(filter=filter, limit=limit, skip=skip, sort=sort, order=order) count_query: Pipeline = self.builder.count(filter=filter) aggregation_result = list(self._aggregate(self.collection, query)) total_cursor = self._aggregate(self.collection, count_query) total = 0 while total_cursor.alive: total = next(total_cursor)['total'] except ManagerGetError as err: raise ManagerIterationError(err=err) iteration_result: IterationResult[DocapiTemplate] = IterationResult(aggregation_result, total) iteration_result.convert_to(DocapiTemplate) return iteration_result
def iterate(self, filter: dict, limit: int, skip: int, sort: str, order: int, user: UserModel = None, permission: AccessControlPermission = None, *args, **kwargs): """ Iterate over a collection of object logs resources. Args: filter: match requirements of field values limit: max number of elements to return skip: number of elements to skip first sort: sort field order: sort order Returns: IterationResult: Instance of IterationResult with generic CmdbObjectLog. """ try: query: Query = self.log_builder.build(filter=filter, limit=limit, skip=skip, sort=sort, order=order, user=user, permission=permission) count_query: Pipeline = self.log_builder.count( filter=filter, user=user, permission=permission) aggregation_result = list(self._aggregate(self.collection, query)) total_cursor = self._aggregate(self.collection, count_query) total = 0 while total_cursor.alive: total = next(total_cursor)['total'] except ManagerGetError as err: raise ManagerIterationError(err=err) try: iteration_result: IterationResult[CmdbMetaLog] = IterationResult( aggregation_result, total) iteration_result.convert_to(CmdbObjectLog) except ManagerGetError as err: raise ManagerGetError(err) return iteration_result
def iterate(self, filter: Union[List[dict], dict], limit: int, skip: int, sort: str, order: int, user: UserModel = None, permission: AccessControlPermission = None, *args, **kwargs) \ -> IterationResult[ObjectLinkModel]: """ Iterate over a collection where the public id exists. """ try: query: Query = self.query_builder.build(filter=filter, limit=limit, skip=skip, sort=sort, order=order, user=user, permission=permission) aggregation_result = next(self._aggregate(self.collection, query)) except ManagerGetError as err: raise ManagerIterationError(err=err) iteration_result: IterationResult[ObjectLinkModel] = IterationResult.from_aggregation(aggregation_result) iteration_result.convert_to(ObjectLinkModel) return iteration_result