Skip to content

Commit 5838451

Browse files
authored
auto codegen for UK8S
1 parent 68c65ca commit 5838451

File tree

3 files changed

+187
-18
lines changed

3 files changed

+187
-18
lines changed

ucloud/services/uk8s/client.py

Lines changed: 80 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,15 @@ def add_uk8s_uhost_node(
104104
105105
**Request**
106106
107-
- **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 <https://docs.ucloud.cn/api/summary/get_project_list.html>`_
108-
- **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 <https://docs.ucloud.cn/api/summary/regionlist.html>`_
109-
- **CPU** (int) - (Required) 虚拟CPU核数。可选参数:2-64(具体机型与CPU的对应关系参照控制台)。默认值: 4。
107+
- **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 <https://docs.ucloud.cn/api/summary/get_project_list>`_
108+
- **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 <https://docs.ucloud.cn/api/summary/regionlist>`_
109+
- **CPU** (str) - (Required) 虚拟CPU核数。可选参数:2-64(具体机型与CPU的对应关系参照控制台)。默认值: 4。
110110
- **ChargeType** (str) - (Required) 计费模式。枚举值为: \\ > Year,按年付费; \\ > Month,按月付费;\\ > Dynamic,按小时预付费 \\ > Postpay,按小时后付费(支持关机不收费,目前仅部分可用区支持,请联系您的客户经理) \\ 默认为月付
111111
- **ClusterId** (str) - (Required) UK8S集群ID。 可从UK8S控制台获取。
112-
- **Count** (int) - (Required) 最大创建Node节点数量,取值范围是[1,10]。
113-
- **Mem** (int) - (Required) 内存大小。单位:MB。范围 :[4096, 262144],取值为1024的倍数(可选范围参考控制台)。默认值:8192
112+
- **Count** (str) - (Required) 创建Node节点数量,取值范围是[1,50]。
113+
- **Mem** (str) - (Required) 内存大小。单位:MB。范围 :[4096, 262144],取值为1024的倍数(可选范围参考控制台)。默认值:8192
114114
- **Password** (str) - (Required) Node节点密码。请遵照 `字段规范 <https://docs.ucloud.cn/api/uhost-api/specification>`_ 设定密码。密码需使用base64进行编码,如下:# echo -n Password1 | base64
115-
- **Zone** (str) - (Required) 可用区。参见 `可用区列表 <https://docs.ucloud.cn/api/summary/regionlist.html>`_
115+
- **Zone** (str) - (Required) 可用区。参见 `可用区列表 <https://docs.ucloud.cn/api/summary/regionlist>`_
116116
- **BootDiskType** (str) - 磁盘类型。请参考 `磁盘类型 <https://docs.ucloud.cn/api/uhost-api/disk_type>`_ 。默认为SSD云盘
117117
- **DataDiskSize** (str) - 数据磁盘大小,单位GB。默认0。范围 :[20, 1000]
118118
- **DataDiskType** (str) - 磁盘类型。请参考 `磁盘类型 <https://docs.ucloud.cn/api/uhost-api/disk_type>`_ 。默认为SSD云盘
@@ -132,7 +132,6 @@ def add_uk8s_uhost_node(
132132
133133
**Response**
134134
135-
- **Message** (str) - 返回错误消息,当 RetCode 非 0 时提供详细的描述信息。
136135
- **NodeIds** (list) - Node实例Id集合
137136
138137
"""
@@ -323,6 +322,75 @@ def describe_uk8s_image(
323322
resp = self.invoke("DescribeUK8SImage", d, **kwargs)
324323
return apis.DescribeUK8SImageResponseSchema().loads(resp)
325324

325+
def describe_uk8s_node(
326+
self, req: typing.Optional[dict] = None, **kwargs
327+
) -> dict:
328+
"""DescribeUK8SNode - 用于获取 UK8S 节点详情
329+
330+
**Request**
331+
332+
- **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 <https://docs.ucloud.cn/api/summary/get_project_list>`_
333+
- **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 <https://docs.ucloud.cn/api/summary/regionlist>`_
334+
- **ClusterId** (str) - (Required) UK8S 集群 Id
335+
- **Name** (str) - (Required) K8S 节点IP或者节点ID
336+
337+
**Response**
338+
339+
- **Action** (str) - 操作名称
340+
- **AllocatedPodCount** (int) - 已分配到当前节点的 Pod 数量
341+
- **Annotations** (list) - 字符串数组,每一项是类似 "node.alpha.kubernetes.io/ttl=0" 的注解
342+
- **CPUCapacity** (str) - 节点 CPU 总量
343+
- **CPULimits** (str) - 节点上已分配 Pod 的 CPU 限制值
344+
- **CPULimitsFraction** (str) - 节点上已分配 Pod 的 CPU 限制值占 CPU 总量的比例
345+
- **CPURequests** (str) - 节点上已分配 Pod 的 CPU 请求量
346+
- **CPURequestsFraction** (str) - 节点上已分配 Pod 的 CPU 请求量占 CPU 总量的比例
347+
- **Conditions** (list) - 见 **K8SNodeCondition** 模型定义
348+
- **ContainerImages** (list) - 节点上镜像名称数组
349+
- **ContainerRuntimeVersion** (str) - 容器运行时版本,如:"docker://18.9.9"
350+
- **CreationTimestamp** (int) - 时间戳,单位是 秒
351+
- **Hostname** (str) - 主机名
352+
- **InternalIP** (str) - 内部 IP 地址
353+
- **KernelVersion** (str) - 内核版本,如:"4.19.0-6.el7.ucloud.x86_64"
354+
- **KubeProxyVersion** (str) - kubeproxy 版本
355+
- **KubeletVersion** (str) - kubelet 版本
356+
- **Labels** (list) - 字符串数组,每一项是类似 "kubernetes.io/arch=amd64" 的标签
357+
- **MemoryCapacity** (str) - 节点内存总量
358+
- **MemoryLimits** (str) - 节点上已分配 Pod 的内存限制量
359+
- **MemoryLimitsFraction** (str) - 节点上已分配 Pod 的内存限制量占内存总量的比例,如返回值为 "18",则意味着限制量占总量的 18%
360+
- **MemoryRequests** (str) - 节点上已分配 Pod 的内存请求量
361+
- **MemoryRequestsFraction** (str) - 节点上已分配 Pod 的内存请求量占内存总量的比例,如返回值为 "4.5",则意味着请求量占总量的 4.5%
362+
- **Message** (str) - 操作出错时的提示信息
363+
- **Name** (str) - 节点名称
364+
- **OSImage** (str) - 操作系统类型,如:"CentOS Linux 7 (Core)"
365+
- **PodCapacity** (int) - 节点允许的可分配 Pod 最大数量
366+
- **ProviderID** (str) - 字符串,如:"UCloud://cn-sh2-02//uk8s-vsc0vgob-n-mpzxc"
367+
- **RetCode** (int) - 返回码
368+
- **Taints** (list) - 字符串数组,每一项是类似 "node-role.kubernetes.io/master:NoSchedule" 的污点
369+
- **Unschedulable** (bool) - 是否禁止调度
370+
371+
**Response Model**
372+
373+
**K8SNodeCondition**
374+
- **LastProbeTime** (str) - 最后一次上报状态的时间
375+
- **LastTransitionTime** (str) - 最后一次状态转变时间
376+
- **Message** (str) - 状态变化的描述信息
377+
- **Reason** (str) - 状态变化的原因
378+
- **Status** (str) - 状态,False、True
379+
- **Type** (str) - Condition 类型,如 MemoryPressure、DiskPressure、PIDPressure、Ready
380+
381+
382+
"""
383+
# build request
384+
d = {
385+
"ProjectId": self.config.project_id,
386+
"Region": self.config.region,
387+
}
388+
req and d.update(req)
389+
d = apis.DescribeUK8SNodeRequestSchema().dumps(d)
390+
391+
resp = self.invoke("DescribeUK8SNode", d, **kwargs)
392+
return apis.DescribeUK8SNodeResponseSchema().loads(resp)
393+
326394
def list_uk8s_cluster_node_v2(
327395
self, req: typing.Optional[dict] = None, **kwargs
328396
) -> dict:
@@ -357,7 +425,7 @@ def list_uk8s_cluster_node_v2(
357425
- **NodeId** (str) - NodeId,Node在UK8S处的唯一标示,如uk8s-reewqe5-sdasadsda
358426
- **NodeLogInfo** (str) - 加节点时判断是否没有资源,如果返回NORESOURCE则代表没有资源了
359427
- **NodeRole** (str) - node角色,枚举值为master、node
360-
- **NodeStatus** (str) - Node的状态
428+
- **NodeStatus** (str) - Node的状态:枚举值:初始化:"Initializing";启动中:"Starting";运行:"Running";停止中:"Stopping";停止:"Stopped";待删除:"ToBeDeleted";删除中:"Deleting";异常:"Error";安装失败:"Install Fail";
361429
- **OsName** (str) - Node节点的镜像名称。
362430
- **OsType** (str) - Node节点的操作系统类别,如Linux或Windows。
363431
- **Unschedulable** (bool) - 是否允许Pod调度到该节点,枚举值为true或false。
@@ -397,8 +465,8 @@ def list_uk8s_cluster_v2(
397465
398466
**Request**
399467
400-
- **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 <https://docs.ucloud.cn/api/summary/get_project_list.html>`_
401-
- **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 <https://docs.ucloud.cn/api/summary/regionlist.html>`_
468+
- **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 <https://docs.ucloud.cn/api/summary/get_project_list>`_
469+
- **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 <https://docs.ucloud.cn/api/summary/regionlist>`_
402470
- **ClusterId** (str) - UK8S集群ID
403471
- **Limit** (int) - 返回数据长度,默认为20。
404472
- **Offset** (int) - 列表起始位置偏移量,默认为0。
@@ -413,6 +481,7 @@ def list_uk8s_cluster_v2(
413481
**ClusterSet**
414482
- **ApiServer** (str) - 集群apiserver地址
415483
- **ClusterId** (str) - 集群ID
484+
- **ClusterLogInfo** (str) - 创建集群时判断如果为NORESOURCE则为没资源,否则为空
416485
- **ClusterName** (str) - 资源名字
417486
- **CreateTime** (int) - 创建时间
418487
- **ExternalApiServer** (str) - 集群外部apiserver地址
@@ -421,7 +490,7 @@ def list_uk8s_cluster_v2(
421490
- **NodeCount** (int) - Node节点数量
422491
- **PodCIDR** (str) - Pod网段
423492
- **ServiceCIDR** (str) - 服务网段
424-
- **Status** (str) - 状态
493+
- **Status** (str) - 集群状态,枚举值:初始化:"INITIALIZING";启动中:"STARTING";创建失败:"CREATEFAILED";正常运行:"RUNNING";添加节点:"ADDNODE";删除节点:"DELNODE";删除中:"DELETING";删除失败:"DELETEFAILED";错误:"ERROR";升级插件:"UPDATE_PLUGIN";更新插件信息:"UPDATE_PLUGIN_INFO";异常:"ABNORMAL";升级集群中:"UPGRADING";容器运行时切换:"CONVERTING"
425494
- **SubnetId** (str) - 所属子网
426495
- **VPCId** (str) - 所属VPC
427496

ucloud/services/uk8s/schemas/apis.py

Lines changed: 86 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ class AddUK8SUHostNodeRequestSchema(schema.RequestSchema):
9898

9999
fields = {
100100
"BootDiskType": fields.Str(required=False, dump_to="BootDiskType"),
101-
"CPU": fields.Int(required=True, dump_to="CPU"),
101+
"CPU": fields.Str(required=True, dump_to="CPU"),
102102
"ChargeType": fields.Str(required=True, dump_to="ChargeType"),
103103
"ClusterId": fields.Str(required=True, dump_to="ClusterId"),
104-
"Count": fields.Int(required=True, dump_to="Count"),
104+
"Count": fields.Str(required=True, dump_to="Count"),
105105
"DataDiskSize": fields.Str(required=False, dump_to="DataDiskSize"),
106106
"DataDiskType": fields.Str(required=False, dump_to="DataDiskType"),
107107
"DisableSchedule": fields.Bool(
@@ -115,7 +115,7 @@ class AddUK8SUHostNodeRequestSchema(schema.RequestSchema):
115115
"Labels": fields.Str(required=False, dump_to="Labels"),
116116
"MachineType": fields.Str(required=False, dump_to="MachineType"),
117117
"MaxPods": fields.Int(required=False, dump_to="MaxPods"),
118-
"Mem": fields.Int(required=True, dump_to="Mem"),
118+
"Mem": fields.Str(required=True, dump_to="Mem"),
119119
"MinmalCpuPlatform": fields.Str(
120120
required=False, dump_to="MinmalCpuPlatform"
121121
),
@@ -133,7 +133,9 @@ class AddUK8SUHostNodeResponseSchema(schema.ResponseSchema):
133133
"""AddUK8SUHostNode - 为UK8S集群添加一台Node节点,机型类型为云主机"""
134134

135135
fields = {
136-
"Message": fields.Str(required=True, load_from="Message"),
136+
"Message": fields.Str(
137+
required=True, load_from="Message"
138+
), # Deprecated, will be removed at 1.0
137139
"NodeIds": fields.List(
138140
fields.Str(), required=False, load_from="NodeIds"
139141
),
@@ -326,6 +328,86 @@ class DescribeUK8SImageResponseSchema(schema.ResponseSchema):
326328
}
327329

328330

331+
"""
332+
API: DescribeUK8SNode
333+
334+
用于获取 UK8S 节点详情
335+
"""
336+
337+
338+
class DescribeUK8SNodeRequestSchema(schema.RequestSchema):
339+
"""DescribeUK8SNode - 用于获取 UK8S 节点详情"""
340+
341+
fields = {
342+
"ClusterId": fields.Str(required=True, dump_to="ClusterId"),
343+
"Name": fields.Str(required=True, dump_to="Name"),
344+
"ProjectId": fields.Str(required=False, dump_to="ProjectId"),
345+
"Region": fields.Str(required=True, dump_to="Region"),
346+
}
347+
348+
349+
class DescribeUK8SNodeResponseSchema(schema.ResponseSchema):
350+
"""DescribeUK8SNode - 用于获取 UK8S 节点详情"""
351+
352+
fields = {
353+
"Action": fields.Str(required=True, load_from="Action"),
354+
"AllocatedPodCount": fields.Int(
355+
required=True, load_from="AllocatedPodCount"
356+
),
357+
"Annotations": fields.List(
358+
fields.Str(), required=True, load_from="Annotations"
359+
),
360+
"CPUCapacity": fields.Str(required=True, load_from="CPUCapacity"),
361+
"CPULimits": fields.Str(required=True, load_from="CPULimits"),
362+
"CPULimitsFraction": fields.Str(
363+
required=True, load_from="CPULimitsFraction"
364+
),
365+
"CPURequests": fields.Str(required=True, load_from="CPURequests"),
366+
"CPURequestsFraction": fields.Str(
367+
required=True, load_from="CPURequestsFraction"
368+
),
369+
"Conditions": fields.List(
370+
models.K8SNodeConditionSchema(),
371+
required=True,
372+
load_from="Conditions",
373+
),
374+
"ContainerImages": fields.List(
375+
fields.Str(), required=True, load_from="ContainerImages"
376+
),
377+
"ContainerRuntimeVersion": fields.Str(
378+
required=True, load_from="ContainerRuntimeVersion"
379+
),
380+
"CreationTimestamp": fields.Int(
381+
required=True, load_from="CreationTimestamp"
382+
),
383+
"Hostname": fields.Str(required=True, load_from="Hostname"),
384+
"InternalIP": fields.Str(required=True, load_from="InternalIP"),
385+
"KernelVersion": fields.Str(required=True, load_from="KernelVersion"),
386+
"KubeProxyVersion": fields.Str(
387+
required=True, load_from="KubeProxyVersion"
388+
),
389+
"KubeletVersion": fields.Str(required=True, load_from="KubeletVersion"),
390+
"Labels": fields.List(fields.Str(), required=True, load_from="Labels"),
391+
"MemoryCapacity": fields.Str(required=True, load_from="MemoryCapacity"),
392+
"MemoryLimits": fields.Str(required=True, load_from="MemoryLimits"),
393+
"MemoryLimitsFraction": fields.Str(
394+
required=True, load_from="MemoryLimitsFraction"
395+
),
396+
"MemoryRequests": fields.Str(required=True, load_from="MemoryRequests"),
397+
"MemoryRequestsFraction": fields.Str(
398+
required=True, load_from="MemoryRequestsFraction"
399+
),
400+
"Message": fields.Str(required=True, load_from="Message"),
401+
"Name": fields.Str(required=True, load_from="Name"),
402+
"OSImage": fields.Str(required=True, load_from="OSImage"),
403+
"PodCapacity": fields.Int(required=True, load_from="PodCapacity"),
404+
"ProviderID": fields.Str(required=True, load_from="ProviderID"),
405+
"RetCode": fields.Int(required=True, load_from="RetCode"),
406+
"Taints": fields.List(fields.Str(), required=False, load_from="Taints"),
407+
"Unschedulable": fields.Bool(required=True, load_from="Unschedulable"),
408+
}
409+
410+
329411
"""
330412
API: ListUK8SClusterNodeV2
331413

ucloud/services/uk8s/schemas/models.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,18 @@ class ImageInfoSchema(schema.ResponseSchema):
1414
}
1515

1616

17-
class KubeProxySchema(schema.ResponseSchema):
18-
"""KubeProxy - KubeProxy信息"""
17+
class K8SNodeConditionSchema(schema.ResponseSchema):
18+
"""K8SNodeCondition - Kubernetes Node Condition"""
1919

2020
fields = {
21-
"Mode": fields.Str(required=False, load_from="Mode"),
21+
"LastProbeTime": fields.Str(required=False, load_from="LastProbeTime"),
22+
"LastTransitionTime": fields.Str(
23+
required=False, load_from="LastTransitionTime"
24+
),
25+
"Message": fields.Str(required=False, load_from="Message"),
26+
"Reason": fields.Str(required=False, load_from="Reason"),
27+
"Status": fields.Str(required=False, load_from="Status"),
28+
"Type": fields.Str(required=False, load_from="Type"),
2229
}
2330

2431

@@ -39,6 +46,14 @@ class UHostIPSetSchema(schema.ResponseSchema):
3946
}
4047

4148

49+
class KubeProxySchema(schema.ResponseSchema):
50+
"""KubeProxy - KubeProxy信息"""
51+
52+
fields = {
53+
"Mode": fields.Str(required=False, load_from="Mode"),
54+
}
55+
56+
4257
class NodeInfoV2Schema(schema.ResponseSchema):
4358
"""NodeInfoV2 - UK8S 节点信息"""
4459

@@ -72,6 +87,9 @@ class ClusterSetSchema(schema.ResponseSchema):
7287
fields = {
7388
"ApiServer": fields.Str(required=True, load_from="ApiServer"),
7489
"ClusterId": fields.Str(required=True, load_from="ClusterId"),
90+
"ClusterLogInfo": fields.Str(
91+
required=False, load_from="ClusterLogInfo"
92+
),
7593
"ClusterName": fields.Str(required=True, load_from="ClusterName"),
7694
"CreateTime": fields.Int(required=False, load_from="CreateTime"),
7795
"ExternalApiServer": fields.Str(

0 commit comments

Comments
 (0)