:param exclude_fields: A list of object fields to exclude. :type exclude_fields: ``list``
(
self,
exclude_fields=None,
include_fields=None,
advanced_filters=None,
sort=None,
offset=0,
limit=None,
query_options=None,
from_model_kwargs=None,
raw_filters=None,
requester_user=None,
)
| 129 | return cfg.CONF.api.max_page_size |
| 130 | |
| 131 | def _get_all( |
| 132 | self, |
| 133 | exclude_fields=None, |
| 134 | include_fields=None, |
| 135 | advanced_filters=None, |
| 136 | sort=None, |
| 137 | offset=0, |
| 138 | limit=None, |
| 139 | query_options=None, |
| 140 | from_model_kwargs=None, |
| 141 | raw_filters=None, |
| 142 | requester_user=None, |
| 143 | ): |
| 144 | """ |
| 145 | :param exclude_fields: A list of object fields to exclude. |
| 146 | :type exclude_fields: ``list`` |
| 147 | """ |
| 148 | raw_filters = copy.deepcopy(raw_filters) or {} |
| 149 | |
| 150 | exclude_fields = exclude_fields or [] |
| 151 | include_fields = include_fields or [] |
| 152 | query_options = query_options if query_options else self.query_options |
| 153 | |
| 154 | if exclude_fields and include_fields: |
| 155 | msg = ( |
| 156 | "exclude_fields and include_fields arguments are mutually exclusive. " |
| 157 | "You need to provide either one or another, but not both." |
| 158 | ) |
| 159 | raise ValueError(msg) |
| 160 | |
| 161 | exclude_fields = self._validate_exclude_fields(exclude_fields=exclude_fields) |
| 162 | include_fields = self._validate_include_fields(include_fields=include_fields) |
| 163 | |
| 164 | # TODO: Why do we use comma delimited string, user can just specify |
| 165 | # multiple values using ?sort=foo&sort=bar and we get a list back |
| 166 | sort = sort.split(",") if sort else [] |
| 167 | |
| 168 | db_sort_values = [] |
| 169 | for sort_key in sort: |
| 170 | if sort_key.startswith("-"): |
| 171 | direction = "-" |
| 172 | sort_key = sort_key[1:] |
| 173 | elif sort_key.startswith("+"): |
| 174 | direction = "+" |
| 175 | sort_key = sort_key[1:] |
| 176 | else: |
| 177 | direction = "" |
| 178 | |
| 179 | if sort_key not in self.supported_filters: |
| 180 | # Skip unsupported sort key |
| 181 | continue |
| 182 | |
| 183 | sort_value = direction + self.supported_filters[sort_key] |
| 184 | db_sort_values.append(sort_value) |
| 185 | |
| 186 | default_sort_values = copy.copy(query_options.get("sort")) |
| 187 | raw_filters["sort"] = db_sort_values if db_sort_values else default_sort_values |
| 188 |
no test coverage detected