|
14 | 14 | TypeVar, |
15 | 15 | Union, |
16 | 16 | ) |
| 17 | +from typing_extensions import Self |
17 | 18 |
|
18 | 19 | from tableauserverclient.models.pagination_item import PaginationItem |
19 | 20 | from tableauserverclient.server.request_options import RequestOptions |
@@ -353,3 +354,41 @@ def paginate(self, **kwargs) -> QuerySet[T]: |
353 | 354 | @abc.abstractmethod |
354 | 355 | def get(self, request_options: Optional[RequestOptions] = None) -> tuple[list[T], PaginationItem]: |
355 | 356 | raise NotImplementedError(f".get has not been implemented for {self.__class__.__qualname__}") |
| 357 | + |
| 358 | + def fields(self: Self, *fields: str) -> QuerySet: |
| 359 | + """ |
| 360 | + Add fields to the request options. If no fields are provided, the |
| 361 | + default fields will be used. If fields are provided, the default fields |
| 362 | + will be used in addition to the provided fields. |
| 363 | +
|
| 364 | + Parameters |
| 365 | + ---------- |
| 366 | + fields : str |
| 367 | + The fields to include in the request options. |
| 368 | +
|
| 369 | + Returns |
| 370 | + ------- |
| 371 | + QuerySet |
| 372 | + """ |
| 373 | + queryset = QuerySet(self) |
| 374 | + queryset.request_options.fields |= set(fields) | set(("_default_",)) |
| 375 | + return queryset |
| 376 | + |
| 377 | + def only_fields(self: Self, *fields: str) -> QuerySet: |
| 378 | + """ |
| 379 | + Add fields to the request options. If no fields are provided, the |
| 380 | + default fields will be used. If fields are provided, the default fields |
| 381 | + will be replaced by the provided fields. |
| 382 | +
|
| 383 | + Parameters |
| 384 | + ---------- |
| 385 | + fields : str |
| 386 | + The fields to include in the request options. |
| 387 | +
|
| 388 | + Returns |
| 389 | + ------- |
| 390 | + QuerySet |
| 391 | + """ |
| 392 | + queryset = QuerySet(self) |
| 393 | + queryset.request_options.fields |= set(fields) |
| 394 | + return queryset |
0 commit comments