Convert JSON or Dict to client objects
維護者通常 1 天內回覆
評估
這個 Issue 還沒有評估資料。
描述
See also https://github.com/kubernetes-client/python/issues/340#issuecomment-526249075 (was closed for inactivity, NOT resolved)
See also #63
Motivation
It is sometimes useful to be able to load Python objects from JSON, for example to read it from a config file. It should be possible to get Python objects from JSON, to pass around the code in a type-safe manner, for modification and ultimately sending through the client.
Feature request
There should be functions to convert JSON to objects and objects to JSON. This code already exists (it's required to talk to the API server), it should be exposed.
Workaround?
Right now, you can put this raw JSON into Python objects' fields, and the API client will apparently accept this, however if you use such mixed objects your code will probably break since their attribute names are different (API uses PascalCase, Python objects use snake_case). Even if taking care to handle that, you will reach the point where you have to handle things coming from the API client (Python objects using snake_case) differently from what you load from config files (JSON using PascalCase). Really messy.
Right now I am left considering dropping this lib altogether and issuing requests directly, since the point of the wrapper is to expose safe typed Python classes instead of the raw JSON, but this doesn't work if you use any kind of config file.
Current status
It is somewhat possible to convert from a Python object to JSON using client.api_client.sanitize_for_serialization(), however converting from JSON to Python is completely impossible; the deserialize() method that exists expects a requests.Response, not JSON. Calling client.api_client._ApiClient__deserialize() works, but that is a private method, and you need to pass it the kind read from the JSON yourself.
Apologies for duplicating #340 but I cannot re-open it myself.
- 主要語言
- Python
- 星號
- 7.7k
- 分支
- 3.5k
- 平均合併
- 1 天 5 小時
- 30 天內合併 PR
- 23
環境準備
- 沒有 Dockerfile 或 Docker Compose 檔案
- 有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
kubernetes-client/python 的其他 Issue
-
getheaders is deprecated in urllib3 >= 2.0.0可能重新可做 關聯的 PR 已關閉且未合併。 未關閉kind/bug
難度 1/5 1 小時以內 新手友好度 68/100
kubernetes-client/python#2280 · 18 則留言 · 9 個 reaction ·
維護者通常 1 天內回覆
-
kind/feature
難度 2/5 1-3 小時 新手友好度 55/100
kubernetes-client/python#2739 · 1 則留言 ·
維護者通常 1 天內回覆
-
help wanted
難度 5/5 一週以上 新手友好度 35/100
kubernetes-client/python#2677 · 15 則留言 · 1 個 reaction ·
維護者通常 1 天內回覆
-
Add option to disable strict x509 verifcation in sync client可能已有人在做 @Vishwa0223 於 58 天前認領。 未關閉help wanted kind/feature
kubernetes-client/python#2602 · 6 則留言 · 已指派 1 人 ·
維護者通常 1 天內回覆
-
v36.0.0 regression fetching container logs可能重新可做 @yliaog 於 97 天前認領,目前沒有進行中的 PR。 未關閉kind/bug
kubernetes-client/python#2596 · 19 則留言 · 2 個 reaction · 已指派 1 人 ·
維護者通常 1 天內回覆
查看 kubernetes-client/python 的全部 Issue
相似的 Issue
-
難度 2/5 1-3 小時 新手友好度 66/100
-
[Bug]: Queen's own Ollama model loses num_ctx when a running session switches to it可能已有人在做 @anasamin26 今天認領。 未關閉bug enhancement
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
llm translation
難度 2/5 1-3 小時 新手友好度 78/100
BerriAI/litellm#47884 · 1 則留言 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 78/100
維護者通常 1 天內回覆
-
bug 🐛
難度 2/5 1-3 小時 新手友好度 72/100
netalertx/NetAlertX#1856 · 1 個 reaction ·
維護者通常 1 天內回覆