def list(self, name=None, goal=None, strategy=None, limit=None, sort_key=None, sort_dir=None, detail=False, marker=None): """Retrieve a list of audit template. :param name: Name of the audit template :param limit: The maximum number of results to return per request, if: 1) limit > 0, the maximum number of audit templates to return. 2) limit == 0, return the entire list of audit_templates. 3) limit param is NOT specified (None), the number of items returned respect the maximum imposed by the Watcher API (see Watcher's api.max_limit option). :param sort_key: Optional, field used for sorting. :param sort_dir: Optional, direction of sorting, either 'asc' (the default) or 'desc'. :param detail: Optional, boolean whether to return detailed information about audit_templates. :param marker: Optional, UUID of the last audit template of the previous page. :returns: A list of audit templates. """ if limit is not None: limit = int(limit) filters = utils.common_filters(limit, sort_key, sort_dir, marker) if name is not None: filters.append('name=%s' % name) if goal is not None: filters.append("goal=%s" % goal) if strategy is not None: filters.append("strategy=%s" % strategy) path = '' if detail: path += 'detail' if filters: path += '?' + '&'.join(filters) if limit is None: return self._list(self._path(path), "audit_templates") else: return self._list_pagination(self._path(path), "audit_templates", limit=limit)
def list(self, action_plan=None, audit=None, limit=None, sort_key=None, sort_dir=None, detail=False): """Retrieve a list of action. :param action_plan: UUID of the action plan :param audit: UUID of the audit :param limit: The maximum number of results to return per request, if: 1) limit > 0, the maximum number of actions to return. 2) limit == 0, return the entire list of actions. 3) limit param is NOT specified (None), the number of items returned respect the maximum imposed by the Watcher API (see Watcher's api.max_limit option). :param sort_key: Optional, field used for sorting. :param sort_dir: Optional, direction of sorting, either 'asc' (the default) or 'desc'. :param detail: Optional, boolean whether to return detailed information about actions. :returns: A list of actions. """ if limit is not None: limit = int(limit) filters = utils.common_filters(limit, sort_key, sort_dir) if action_plan is not None: filters.append('action_plan_uuid=%s' % action_plan) if audit is not None: filters.append('audit_uuid=%s' % audit) path = '' if detail: path += 'detail' if filters: path += '?' + '&'.join(filters) if limit is None: return self._list(self._path(path), "actions") else: return self._list_pagination(self._path(path), "actions", limit=limit)
def list(self, goal=None, limit=None, sort_key=None, sort_dir=None, detail=False): """Retrieve a list of strategy. :param goal: The UUID of the goal to filter by :param limit: The maximum number of results to return per request, if: 1) limit > 0, the maximum number of audits to return. 2) limit == 0, return the entire list of audits. 3) limit param is NOT specified (None), the number of items returned respect the maximum imposed by the Watcher API (see Watcher's api.max_limit option). :param sort_key: Optional, field used for sorting. :param sort_dir: Optional, direction of sorting, either 'asc' (the default) or 'desc'. :param detail: Optional, boolean whether to return detailed information about audits. :returns: A list of audits. """ if limit is not None: limit = int(limit) filters = utils.common_filters(limit, sort_key, sort_dir) if goal: filters.append(parse.urlencode(dict(goal=goal))) path = '' if detail: path += 'detail' if filters: path += '?' + '&'.join(filters) if limit is None: return self._list(self._path(path), "strategies") else: return self._list_pagination(self._path(path), "strategies", limit=limit)
def list(self, limit=None, sort_key=None, sort_dir=None, detail=False): """Retrieve a list of services. :param limit: The maximum number of results to return per request, if: 1) limit > 0, the maximum number of services to return. 2) limit == 0, return the entire list of services. 3) limit param is NOT specified (None), the number of items returned respect the maximum imposed by the Watcher API (see Watcher's api.max_limit option). :param sort_key: Optional, field used for sorting. :param sort_dir: Optional, direction of sorting, either 'asc' (the default) or 'desc'. :param detail: Optional, boolean whether to return detailed information about services. :returns: A list of services. """ if limit is not None: limit = int(limit) filters = utils.common_filters(limit, sort_key, sort_dir) path = '' if detail: path += 'detail' if filters: path += '?' + '&'.join(filters) if limit is None: return self._list(self._path(path), "services") else: return self._list_pagination(self._path(path), "services", limit=limit)
def list(self, data_model_type='compute', audit=None): """Retrieve a list of data model. :param data_model_type: The type of data model user wants to list. Supported values: compute. Future support values: storage, baremetal. The default value is compute. :param audit: The UUID of the audit, used to filter data model by the scope in audit. :returns: A list of data model. """ path = '' filters = utils.common_filters() if audit: filters.append('audit_uuid=%s' % audit) filters.append('data_model_type=%s' % data_model_type) path += '?' + '&'.join(filters) return self._list(self._path(path))[0]
def test_other(self): for key in ('sort_key', 'sort_dir'): result = utils.common_filters(**{key: 'test'}) self.assertEqual(['%s=test' % key], result)
def test_limit_0(self): result = utils.common_filters(limit=0) self.assertEqual([], result)
def test_limit(self): result = utils.common_filters(limit=42) self.assertEqual(['limit=42'], result)