Skip to content

Commit 5149d4a

Browse files
committed
Update Python Client to 3.1.6rc1
1 parent f8859b0 commit 5149d4a

File tree

71 files changed

+712
-695
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+712
-695
lines changed

CHANGELOG.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,16 @@
1717
under the License.
1818
-->
1919

20-
# v3.1.4
20+
# v3.1.6
2121

2222
## Bug Fixes:
2323

2424
- Update refresh token flow ([#55506](https://github.com/apache/airflow/pull/55506))
25-
- Patch pools should have an optional description ([#58066](https://github.com/apache/airflow/pull/58066))
25+
- Patch pools should have an optional description ([#58066](https://github.com/apache/airflow/pull/58066))(#59728)
26+
- Add task group ID filtering support to task instance query [#59511](https://github.com/apache/airflow/pull/59511)
27+
- Fix backfill run_on_latest_version defaulting to False instead of True [#59328](https://github.com/apache/airflow/pull/59328)
28+
- Update refresh token flow [#58649](https://github.com/apache/airflow/pull/58649)
29+
- Patch pools should have an optional description [#58169](https://github.com/apache/airflow/pull/58169)
2630

2731
# v3.1.3
2832

airflow_client/client/__init__.py

Lines changed: 372 additions & 184 deletions
Large diffs are not rendered by default.

airflow_client/client/api/dag_api.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
from airflow_client.client.models.dag_patch_body import DAGPatchBody
2626
from airflow_client.client.models.dag_response import DAGResponse
2727
from airflow_client.client.models.dag_tag_collection_response import DAGTagCollectionResponse
28-
from airflow_client.client.models.dag_run_state import DagRunState
2928

3029
from airflow_client.client.api_client import ApiClient, RequestSerialized
3130
from airflow_client.client.api_response import ApiResponse
@@ -1488,7 +1487,7 @@ def get_dags(
14881487
exclude_stale: Optional[StrictBool] = None,
14891488
paused: Optional[StrictBool] = None,
14901489
has_import_errors: Annotated[Optional[StrictBool], Field(description="Filter Dags by having import errors. Only Dags that have been successfully loaded before will be returned.")] = None,
1491-
last_dag_run_state: Optional[DagRunState] = None,
1490+
last_dag_run_state: Optional[Any] = None,
14921491
bundle_name: Optional[StrictStr] = None,
14931492
bundle_version: Optional[StrictStr] = None,
14941493
has_asset_schedule: Annotated[Optional[StrictBool], Field(description="Filter Dags with asset-based scheduling")] = None,
@@ -1658,7 +1657,7 @@ def get_dags_with_http_info(
16581657
exclude_stale: Optional[StrictBool] = None,
16591658
paused: Optional[StrictBool] = None,
16601659
has_import_errors: Annotated[Optional[StrictBool], Field(description="Filter Dags by having import errors. Only Dags that have been successfully loaded before will be returned.")] = None,
1661-
last_dag_run_state: Optional[DagRunState] = None,
1660+
last_dag_run_state: Optional[Any] = None,
16621661
bundle_name: Optional[StrictStr] = None,
16631662
bundle_version: Optional[StrictStr] = None,
16641663
has_asset_schedule: Annotated[Optional[StrictBool], Field(description="Filter Dags with asset-based scheduling")] = None,
@@ -1828,7 +1827,7 @@ def get_dags_without_preload_content(
18281827
exclude_stale: Optional[StrictBool] = None,
18291828
paused: Optional[StrictBool] = None,
18301829
has_import_errors: Annotated[Optional[StrictBool], Field(description="Filter Dags by having import errors. Only Dags that have been successfully loaded before will be returned.")] = None,
1831-
last_dag_run_state: Optional[DagRunState] = None,
1830+
last_dag_run_state: Optional[Any] = None,
18321831
bundle_name: Optional[StrictStr] = None,
18331832
bundle_version: Optional[StrictStr] = None,
18341833
has_asset_schedule: Annotated[Optional[StrictBool], Field(description="Filter Dags with asset-based scheduling")] = None,

airflow_client/client/api/dag_warning_api.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,9 @@
1717
from typing_extensions import Annotated
1818

1919
from pydantic import Field, StrictStr
20-
from typing import List, Optional
20+
from typing import Any, List, Optional
2121
from typing_extensions import Annotated
2222
from airflow_client.client.models.dag_warning_collection_response import DAGWarningCollectionResponse
23-
from airflow_client.client.models.dag_warning_type import DagWarningType
2423

2524
from airflow_client.client.api_client import ApiClient, RequestSerialized
2625
from airflow_client.client.api_response import ApiResponse
@@ -44,7 +43,7 @@ def __init__(self, api_client=None) -> None:
4443
def list_dag_warnings(
4544
self,
4645
dag_id: Optional[StrictStr] = None,
47-
warning_type: Optional[DagWarningType] = None,
46+
warning_type: Optional[Any] = None,
4847
limit: Optional[Annotated[int, Field(strict=True, ge=0)]] = None,
4948
offset: Optional[Annotated[int, Field(strict=True, ge=0)]] = None,
5049
order_by: Annotated[Optional[List[StrictStr]], Field(description="Attributes to order by, multi criteria sort is supported. Prefix with `-` for descending order. Supported attributes: `dag_id, warning_type, message, timestamp`")] = None,
@@ -130,7 +129,7 @@ def list_dag_warnings(
130129
def list_dag_warnings_with_http_info(
131130
self,
132131
dag_id: Optional[StrictStr] = None,
133-
warning_type: Optional[DagWarningType] = None,
132+
warning_type: Optional[Any] = None,
134133
limit: Optional[Annotated[int, Field(strict=True, ge=0)]] = None,
135134
offset: Optional[Annotated[int, Field(strict=True, ge=0)]] = None,
136135
order_by: Annotated[Optional[List[StrictStr]], Field(description="Attributes to order by, multi criteria sort is supported. Prefix with `-` for descending order. Supported attributes: `dag_id, warning_type, message, timestamp`")] = None,
@@ -216,7 +215,7 @@ def list_dag_warnings_with_http_info(
216215
def list_dag_warnings_without_preload_content(
217216
self,
218217
dag_id: Optional[StrictStr] = None,
219-
warning_type: Optional[DagWarningType] = None,
218+
warning_type: Optional[Any] = None,
220219
limit: Optional[Annotated[int, Field(strict=True, ge=0)]] = None,
221220
offset: Optional[Annotated[int, Field(strict=True, ge=0)]] = None,
222221
order_by: Annotated[Optional[List[StrictStr]], Field(description="Attributes to order by, multi criteria sort is supported. Prefix with `-` for descending order. Supported attributes: `dag_id, warning_type, message, timestamp`")] = None,

airflow_client/client/api/task_instance_api.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6357,6 +6357,7 @@ def get_task_instances(
63576357
duration_lte: Optional[Union[StrictFloat, StrictInt]] = None,
63586358
duration_lt: Optional[Union[StrictFloat, StrictInt]] = None,
63596359
task_display_name_pattern: Annotated[Optional[StrictStr], Field(description="SQL LIKE expression — use `%` / `_` wildcards (e.g. `%customer_%`). Regular expressions are **not** supported.")] = None,
6360+
task_group_id: Annotated[Optional[StrictStr], Field(description="Filter by exact task group ID. Returns all tasks within the specified task group.")] = None,
63606361
state: Optional[List[StrictStr]] = None,
63616362
pool: Optional[List[StrictStr]] = None,
63626363
queue: Optional[List[StrictStr]] = None,
@@ -6441,6 +6442,8 @@ def get_task_instances(
64416442
:type duration_lt: float
64426443
:param task_display_name_pattern: SQL LIKE expression — use `%` / `_` wildcards (e.g. `%customer_%`). Regular expressions are **not** supported.
64436444
:type task_display_name_pattern: str
6445+
:param task_group_id: Filter by exact task group ID. Returns all tasks within the specified task group.
6446+
:type task_group_id: str
64446447
:param state:
64456448
:type state: List[str]
64466449
:param pool:
@@ -6514,6 +6517,7 @@ def get_task_instances(
65146517
duration_lte=duration_lte,
65156518
duration_lt=duration_lt,
65166519
task_display_name_pattern=task_display_name_pattern,
6520+
task_group_id=task_group_id,
65176521
state=state,
65186522
pool=pool,
65196523
queue=queue,
@@ -6580,6 +6584,7 @@ def get_task_instances_with_http_info(
65806584
duration_lte: Optional[Union[StrictFloat, StrictInt]] = None,
65816585
duration_lt: Optional[Union[StrictFloat, StrictInt]] = None,
65826586
task_display_name_pattern: Annotated[Optional[StrictStr], Field(description="SQL LIKE expression — use `%` / `_` wildcards (e.g. `%customer_%`). Regular expressions are **not** supported.")] = None,
6587+
task_group_id: Annotated[Optional[StrictStr], Field(description="Filter by exact task group ID. Returns all tasks within the specified task group.")] = None,
65836588
state: Optional[List[StrictStr]] = None,
65846589
pool: Optional[List[StrictStr]] = None,
65856590
queue: Optional[List[StrictStr]] = None,
@@ -6664,6 +6669,8 @@ def get_task_instances_with_http_info(
66646669
:type duration_lt: float
66656670
:param task_display_name_pattern: SQL LIKE expression — use `%` / `_` wildcards (e.g. `%customer_%`). Regular expressions are **not** supported.
66666671
:type task_display_name_pattern: str
6672+
:param task_group_id: Filter by exact task group ID. Returns all tasks within the specified task group.
6673+
:type task_group_id: str
66676674
:param state:
66686675
:type state: List[str]
66696676
:param pool:
@@ -6737,6 +6744,7 @@ def get_task_instances_with_http_info(
67376744
duration_lte=duration_lte,
67386745
duration_lt=duration_lt,
67396746
task_display_name_pattern=task_display_name_pattern,
6747+
task_group_id=task_group_id,
67406748
state=state,
67416749
pool=pool,
67426750
queue=queue,
@@ -6803,6 +6811,7 @@ def get_task_instances_without_preload_content(
68036811
duration_lte: Optional[Union[StrictFloat, StrictInt]] = None,
68046812
duration_lt: Optional[Union[StrictFloat, StrictInt]] = None,
68056813
task_display_name_pattern: Annotated[Optional[StrictStr], Field(description="SQL LIKE expression — use `%` / `_` wildcards (e.g. `%customer_%`). Regular expressions are **not** supported.")] = None,
6814+
task_group_id: Annotated[Optional[StrictStr], Field(description="Filter by exact task group ID. Returns all tasks within the specified task group.")] = None,
68066815
state: Optional[List[StrictStr]] = None,
68076816
pool: Optional[List[StrictStr]] = None,
68086817
queue: Optional[List[StrictStr]] = None,
@@ -6887,6 +6896,8 @@ def get_task_instances_without_preload_content(
68876896
:type duration_lt: float
68886897
:param task_display_name_pattern: SQL LIKE expression — use `%` / `_` wildcards (e.g. `%customer_%`). Regular expressions are **not** supported.
68896898
:type task_display_name_pattern: str
6899+
:param task_group_id: Filter by exact task group ID. Returns all tasks within the specified task group.
6900+
:type task_group_id: str
68906901
:param state:
68916902
:type state: List[str]
68926903
:param pool:
@@ -6960,6 +6971,7 @@ def get_task_instances_without_preload_content(
69606971
duration_lte=duration_lte,
69616972
duration_lt=duration_lt,
69626973
task_display_name_pattern=task_display_name_pattern,
6974+
task_group_id=task_group_id,
69636975
state=state,
69646976
pool=pool,
69656977
queue=queue,
@@ -7021,6 +7033,7 @@ def _get_task_instances_serialize(
70217033
duration_lte,
70227034
duration_lt,
70237035
task_display_name_pattern,
7036+
task_group_id,
70247037
state,
70257038
pool,
70267039
queue,
@@ -7351,6 +7364,10 @@ def _get_task_instances_serialize(
73517364

73527365
_query_params.append(('task_display_name_pattern', task_display_name_pattern))
73537366

7367+
if task_group_id is not None:
7368+
7369+
_query_params.append(('task_group_id', task_group_id))
7370+
73547371
if state is not None:
73557372

73567373
_query_params.append(('state', state))

airflow_client/client/api_client.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import os
2222
import re
2323
import tempfile
24+
import uuid
2425

2526
from urllib.parse import quote
2627
from typing import Tuple, Optional, List, Dict, Union
@@ -90,7 +91,7 @@ def __init__(
9091
self.default_headers[header_name] = header_value
9192
self.cookie = cookie
9293
# Set default User-Agent.
93-
self.user_agent = 'OpenAPI-Generator/3.1.4/python'
94+
self.user_agent = 'OpenAPI-Generator/3.1.6/python'
9495
self.client_side_validation = configuration.client_side_validation
9596

9697
def __enter__(self):
@@ -311,7 +312,7 @@ def response_deserialize(
311312
return_data = self.__deserialize_file(response_data)
312313
elif response_type is not None:
313314
match = None
314-
content_type = response_data.getheader('content-type')
315+
content_type = response_data.headers.get('content-type')
315316
if content_type is not None:
316317
match = re.search(r"charset=([a-zA-Z\-\d]+)[\s;]?", content_type)
317318
encoding = match.group(1) if match else "utf-8"
@@ -328,7 +329,7 @@ def response_deserialize(
328329
return ApiResponse(
329330
status_code = response_data.status,
330331
data = return_data,
331-
headers = response_data.getheaders(),
332+
headers = response_data.headers,
332333
raw_data = response_data.data
333334
)
334335

@@ -356,6 +357,8 @@ def sanitize_for_serialization(self, obj):
356357
return obj.get_secret_value()
357358
elif isinstance(obj, self.PRIMITIVE_TYPES):
358359
return obj
360+
elif isinstance(obj, uuid.UUID):
361+
return str(obj)
359362
elif isinstance(obj, list):
360363
return [
361364
self.sanitize_for_serialization(sub_obj) for sub_obj in obj
@@ -382,6 +385,10 @@ def sanitize_for_serialization(self, obj):
382385
else:
383386
obj_dict = obj.__dict__
384387

388+
if isinstance(obj_dict, list):
389+
# here we handle instances that can either be a list or something else, and only became a real list by calling to_dict()
390+
return self.sanitize_for_serialization(obj_dict)
391+
385392
return {
386393
key: self.sanitize_for_serialization(val)
387394
for key, val in obj_dict.items()
@@ -404,7 +411,7 @@ def deserialize(self, response_text: str, response_type: str, content_type: Opti
404411
data = json.loads(response_text)
405412
except ValueError:
406413
data = response_text
407-
elif re.match(r'^application/(json|[\w!#$&.+-^_]+\+json)\s*(;|$)', content_type, re.IGNORECASE):
414+
elif re.match(r'^application/(json|[\w!#$&.+\-^_]+\+json)\s*(;|$)', content_type, re.IGNORECASE):
408415
if response_text == "":
409416
data = ""
410417
else:
@@ -453,13 +460,13 @@ def __deserialize(self, data, klass):
453460

454461
if klass in self.PRIMITIVE_TYPES:
455462
return self.__deserialize_primitive(data, klass)
456-
elif klass == object:
463+
elif klass is object:
457464
return self.__deserialize_object(data)
458-
elif klass == datetime.date:
465+
elif klass is datetime.date:
459466
return self.__deserialize_date(data)
460-
elif klass == datetime.datetime:
467+
elif klass is datetime.datetime:
461468
return self.__deserialize_datetime(data)
462-
elif klass == decimal.Decimal:
469+
elif klass is decimal.Decimal:
463470
return decimal.Decimal(data)
464471
elif issubclass(klass, Enum):
465472
return self.__deserialize_enum(data, klass)
@@ -694,7 +701,7 @@ def __deserialize_file(self, response):
694701
os.close(fd)
695702
os.remove(path)
696703

697-
content_disposition = response.getheader("Content-Disposition")
704+
content_disposition = response.headers.get("Content-Disposition")
698705
if content_disposition:
699706
m = re.search(
700707
r'filename=[\'"]?([^\'"\s]+)[\'"]?',

airflow_client/client/configuration.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ class Configuration:
164164
:param retries: Number of retries for API requests.
165165
:param ca_cert_data: verify the peer using concatenated CA certificate data
166166
in PEM (str) or DER (bytes) format.
167+
:param cert_file: the path to a client certificate file, for mTLS.
168+
:param key_file: the path to a client key file, for mTLS.
167169
168170
:Example:
169171
"""
@@ -186,6 +188,8 @@ def __init__(
186188
ssl_ca_cert: Optional[str]=None,
187189
retries: Optional[int] = None,
188190
ca_cert_data: Optional[Union[str, bytes]] = None,
191+
cert_file: Optional[str]=None,
192+
key_file: Optional[str]=None,
189193
*,
190194
debug: Optional[bool] = None,
191195
) -> None:
@@ -267,10 +271,10 @@ def __init__(
267271
"""Set this to verify the peer using PEM (str) or DER (bytes)
268272
certificate data.
269273
"""
270-
self.cert_file = None
274+
self.cert_file = cert_file
271275
"""client certificate file
272276
"""
273-
self.key_file = None
277+
self.key_file = key_file
274278
"""client key file
275279
"""
276280
self.assert_hostname = None
@@ -483,6 +487,7 @@ def get_basic_auth_token(self) -> Optional[str]:
483487
password = ""
484488
if self.password is not None:
485489
password = self.password
490+
486491
return urllib3.util.make_headers(
487492
basic_auth=username + ':' + password
488493
).get('authorization')
@@ -518,7 +523,7 @@ def to_debug_report(self) -> str:
518523
"OS: {env}\n"\
519524
"Python Version: {pyversion}\n"\
520525
"Version of the API: 2\n"\
521-
"SDK Package Version: 3.1.4".\
526+
"SDK Package Version: 3.1.6".\
522527
format(env=sys.platform, pyversion=sys.version)
523528

524529
def get_host_settings(self) -> List[HostSetting]:
@@ -566,6 +571,7 @@ def get_host_from_settings(
566571
variable_name, variable['default_value'])
567572

568573
if 'enum_values' in variable \
574+
and variable['enum_values'] \
569575
and used_value not in variable['enum_values']:
570576
raise ValueError(
571577
"The variable `{0}` in the host URL has invalid value "

airflow_client/client/exceptions.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ def __init__(
128128
self.body = http_resp.data.decode('utf-8')
129129
except Exception:
130130
pass
131-
self.headers = http_resp.getheaders()
131+
self.headers = http_resp.headers
132132

133133
@classmethod
134134
def from_response(
@@ -169,8 +169,11 @@ def __str__(self):
169169
error_message += "HTTP response headers: {0}\n".format(
170170
self.headers)
171171

172-
if self.data or self.body:
173-
error_message += "HTTP response body: {0}\n".format(self.data or self.body)
172+
if self.body:
173+
error_message += "HTTP response body: {0}\n".format(self.body)
174+
175+
if self.data:
176+
error_message += "HTTP response data: {0}\n".format(self.data)
174177

175178
return error_message
176179

airflow_client/client/models/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
Do not edit the class manually.
1313
""" # noqa: E501
1414

15-
1615
# import models into model package
1716
from airflow_client.client.models.app_builder_menu_item_response import AppBuilderMenuItemResponse
1817
from airflow_client.client.models.app_builder_view_response import AppBuilderViewResponse
@@ -162,3 +161,4 @@
162161
from airflow_client.client.models.x_com_response_native import XComResponseNative
163162
from airflow_client.client.models.x_com_response_string import XComResponseString
164163
from airflow_client.client.models.x_com_update_body import XComUpdateBody
164+

0 commit comments

Comments
 (0)