Skip to content

Commit b3769c4

Browse files
committed
1 parent 8c1a954 commit b3769c4

17 files changed

Lines changed: 471 additions & 0 deletions

kubernetes_asyncio/__init__.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Copyright 2026 The Kubernetes Authors.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
__project__ = "kubernetes_asyncio"
16+
# The version is auto-updated. Please do not edit.
17+
__version__ = "35.0.0+snapshot"
18+
19+
import kubernetes_asyncio.client as client
20+
21+
__all__ = ["client"]

requirements-asyncio.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
certifi>=14.05.14 # MPL
2+
six>=1.9.0 # MIT
3+
python-dateutil>=2.5.3 # BSD
4+
pyyaml>=5.4.1 # MIT
5+
urllib3>=1.24.2,!=2.6.0 # MIT
6+
aiohttp>=3.9.0,<4.0.0 # Apache-2.0
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
diff --git a/kubernetes_asyncio/client/api_client.py b/kubernetes_asyncio/client/api_client.py
2+
index 81c12e00..02c9d0f2 100644
3+
--- a/kubernetes_asyncio/client/api_client.py
4+
+++ b/kubernetes_asyncio/client/api_client.py
5+
@@ -165,7 +165,7 @@ class ApiClient(object):
6+
post_params.extend(self.files_parameters(files))
7+
8+
# auth setting
9+
- self.update_params_for_auth(
10+
+ await self.update_params_for_auth(
11+
header_params, query_params, auth_settings,
12+
request_auth=_request_auth)
13+
14+
@@ -548,7 +548,7 @@ class ApiClient(object):
15+
else:
16+
return content_types[0]
17+
18+
- def update_params_for_auth(self, headers, queries, auth_settings,
19+
+ async def update_params_for_auth(self, headers, queries, auth_settings,
20+
request_auth=None):
21+
"""Updates header and query params based on authentication setting.
22+
23+
@@ -566,6 +566,6 @@ class ApiClient(object):
24+
return
25+
26+
for auth in auth_settings:
27+
- auth_setting = self.configuration.auth_settings().get(auth)
28+
+ auth_setting = (await self.configuration.auth_settings()).get(auth)
29+
if auth_setting:
30+
self._apply_auth_params(headers, queries, auth_setting)
31+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
diff --git a/kubernetes_asyncio/client/api_client.py b/kubernetes_asyncio/client/api_client.py
2+
index 0d543478..2791a9cd 100644
3+
--- a/kubernetes_asyncio/client/api_client.py
4+
+++ b/kubernetes_asyncio/client/api_client.py
5+
@@ -198,7 +198,9 @@ class ApiClient(object):
6+
if not _preload_content:
7+
return return_data
8+
9+
- response_type = response_types_map.get(response_data.status, None)
10+
+ response_type = None
11+
+ if response_types_map:
12+
+ response_type = response_types_map.get(response_data.status, None)
13+
14+
if six.PY3 and response_type not in ["file", "bytes"]:
15+
match = None
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--- /tmp/api_client.py 2024-02-25 20:40:28.143350042 +0100
2+
+++ kubernetes_asyncio/client/api_client.py 2024-02-25 20:40:32.954201652 +0100
3+
@@ -535,10 +535,13 @@
4+
5+
content_types = [x.lower() for x in content_types]
6+
7+
- if (method == 'PATCH' and
8+
- 'application/json-patch+json' in content_types and
9+
- isinstance(body, list)):
10+
- return 'application/json-patch+json'
11+
+ if method == 'PATCH':
12+
+ if ('application/json-patch+json' in content_types and
13+
+ isinstance(body, list)):
14+
+ return 'application/json-patch+json'
15+
+ if ('application/strategic-merge-patch+json' in content_types and
16+
+ (isinstance(body, dict) or hasattr(body, "to_dict"))):
17+
+ return 'application/strategic-merge-patch+json'
18+
19+
if 'application/json' in content_types or '*/*' in content_types:
20+
return 'application/json'
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
diff --git a/kubernetes_asyncio/client/configuration.py b/kubernetes_asyncio/client/configuration.py
2+
index 720bb81f..b2522c23 100644
3+
--- a/kubernetes_asyncio/client/configuration.py
4+
+++ b/kubernetes_asyncio/client/configuration.py
5+
@@ -12,6 +12,7 @@
6+
7+
from __future__ import absolute_import
8+
9+
+import asyncio
10+
import copy
11+
import logging
12+
import sys
13+
@@ -370,7 +371,7 @@ conf = client.Configuration(
14+
self.__logger_format = value
15+
self.logger_formatter = logging.Formatter(self.__logger_format)
16+
17+
- def get_api_key_with_prefix(self, identifier, alias=None):
18+
+ async def get_api_key_with_prefix(self, identifier, alias=None):
19+
"""Gets API key (with prefix if set).
20+
21+
:param identifier: The identifier of apiKey.
22+
@@ -378,7 +379,9 @@ conf = client.Configuration(
23+
:return: The token for api key authentication.
24+
"""
25+
if self.refresh_api_key_hook is not None:
26+
- self.refresh_api_key_hook(self)
27+
+ result = self.refresh_api_key_hook(self)
28+
+ if asyncio.iscoroutine(result):
29+
+ await result
30+
key = self.api_key.get(identifier, self.api_key.get(alias) if alias is not None else None)
31+
if key:
32+
prefix = self.api_key_prefix.get(identifier)
33+
@@ -402,7 +405,7 @@ conf = client.Configuration(
34+
basic_auth=username + ':' + password
35+
).get('authorization')
36+
37+
- def auth_settings(self):
38+
+ async def auth_settings(self):
39+
"""Gets Auth Settings dict for api client.
40+
41+
:return: The Auth Settings information dict.
42+
@@ -413,7 +416,7 @@ conf = client.Configuration(
43+
'type': 'api_key',
44+
'in': 'header',
45+
'key': 'authorization',
46+
- 'value': self.get_api_key_with_prefix(
47+
+ 'value': await self.get_api_key_with_prefix(
48+
'BearerToken',
49+
),
50+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
diff --git a/kubernetes_asyncio/client/configuration.py b/kubernetes_asyncio/client/configuration.py
2+
index d0dd9f9e..facc9173 100644
3+
--- a/kubernetes_asyncio/client/configuration.py
4+
+++ b/kubernetes_asyncio/client/configuration.py
5+
@@ -177,6 +177,14 @@ conf = client.Configuration(
6+
Set this to false to skip verifying SSL certificate when calling API
7+
from https server.
8+
"""
9+
+ self.disable_strict_ssl_verification = False
10+
+ """Set to true, to accept certificates violate X509 strict certificate
11+
+ verification requirements, like missing the following extensions:
12+
+ - X509v3 Subject Key Identifier
13+
+ - X509v3 Authority Key Identifier
14+
+ - X509v3 Subject Alternative Name
15+
+ (It is implemented by removing ssl.VERIFY_X509_STRICT from SSLContext.verify_flags)
16+
+ """
17+
self.ssl_ca_cert = ssl_ca_cert
18+
"""Set this to customize the certificate file to verify the peer.
19+
"""
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--- kubernetes_asyncio/client/configuration.py 2024-01-28 00:09:56.593954742 +0100
2+
+++ /tmp/configuration.py 2024-01-28 00:00:42.583447266 +0100
3+
@@ -254,6 +254,16 @@
4+
cls._default = copy.deepcopy(default)
5+
6+
@classmethod
7+
+ def get_default(cls):
8+
+ """Get default instance of configuration.
9+
+
10+
+ :return: The Configuration object.
11+
+ """
12+
+ if cls._default is None:
13+
+ cls.set_default(Configuration())
14+
+ return cls._default
15+
+
16+
+ @classmethod
17+
def get_default_copy(cls):
18+
"""Return new instance of configuration.
19+
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--- /tmp/configuration.py 2024-01-15 23:55:23.361535239 +0100
2+
+++ kubernetes_asyncio/client/configuration.py 2024-01-15 23:55:30.793395231 +0100
3+
@@ -189,6 +189,10 @@
4+
self.assert_hostname = None
5+
"""Set this to True/False to enable/disable SSL hostname verification.
6+
"""
7+
+ self.tls_server_name = None
8+
+ """SSL/TLS Server Name Indication (SNI)
9+
+ Set this to the SNI value expected by Kubernetes API.
10+
+ """
11+
12+
self.connection_pool_maxsize = 100
13+
"""This value is passed to the aiohttp to limit simultaneous connections.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
diff --git a/kubernetes_asyncio/client/rest.py b/kubernetes_asyncio/client/rest.py
2+
--- a/kubernetes_asyncio/client/rest.py
3+
+++ b/kubernetes_asyncio/client/rest.py
4+
@@ -142,7 +142,10 @@
5+
6+
# For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE`
7+
if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']:
8+
- if re.search('json', headers['Content-Type'], re.IGNORECASE):
9+
+ if (
10+
+ re.search('json', headers['Content-Type'], re.IGNORECASE)
11+
+ or headers['Content-Type'] in ["application/apply-patch+yaml"]
12+
+ ):
13+
if body is not None:
14+
body = json.dumps(body)
15+
args["data"] = body

0 commit comments

Comments
 (0)