Skip to content

Commit 7556841

Browse files
authored
auto codegen for UHost
1 parent 1fbb887 commit 7556841

File tree

3 files changed

+341
-33
lines changed

3 files changed

+341
-33
lines changed

ucloud/services/uhost/client.py

Lines changed: 159 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,7 @@ def create_uhost_instance(
122122
- **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 <https://docs.ucloud.cn/api/summary/get_project_list>`_
123123
- **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 <https://docs.ucloud.cn/api/summary/regionlist>`_
124124
- **ImageId** (str) - (Required) 镜像ID。 请通过 `DescribeImage <https://docs.ucloud.cn/api/uhost-api/describe_image.html>`_ 获取
125-
- **LoginMode** (str) - (Required) 主机登陆模式。密码(默认选项): Password。
126-
- **Password** (str) - (Required) UHost密码。请遵照 `字段规范 <https://docs.ucloud.cn/api/uhost-api/specification>`_ 设定密码。密码需使用base64进行编码,举例如下:# echo -n Password1 | base64UGFzc3dvcmQx。
125+
- **LoginMode** (str) - (Required) 主机登陆模式。密码(默认选项): Password,密钥:KeyPair。
127126
- **Zone** (str) - (Required) 可用区。参见 `可用区列表 <https://docs.ucloud.cn/api/summary/regionlist>`_
128127
- **AlarmTemplateId** (int) - 告警模板id,如果传了告警模板id,且告警模板id正确,则绑定告警模板。绑定告警模板失败只会在后台有日志,不会影响创建主机流程,也不会在前端报错。
129128
- **AutoDataDiskInit** (str) - 数据盘是否需要自动分区挂载。当镜像支持“Cloud-init”Feature时可填写此字段。取值 >“On” 自动挂载(默认值)> “Off” 不自动挂载。
@@ -134,19 +133,19 @@ def create_uhost_instance(
134133
- **GPU** (int) - GPU卡核心数。仅GPU机型支持此字段(可选范围与MachineType+GpuType相关)
135134
- **GpuType** (str) - GPU类型,枚举值["K80", "P40", "V100", "T4", "T4S","2080Ti","2080Ti-4C","1080Ti"],MachineType为G时必填
136135
- **HotplugFeature** (bool) - 热升级特性。True为开启,False为未开启,默认False。
137-
- **HpcEnhanced** (bool) - HPC特性,主要涉及绑核操作。True为开启,False为未开启,默认False。
138136
- **IsolationGroup** (str) - 硬件隔离组id。可通过DescribeIsolationGroup获取。
137+
- **KeyPairId** (str) - KeypairId 密钥对ID,LoginMode为KeyPair时此项必须
139138
- **MachineType** (str) - 云主机机型(V2.0),在本字段和字段UHostType中,仅需要其中1个字段即可。枚举值["N", "C", "G", "O", "OS", "OPRO", "OMAX", "O.BM"]。参考 `云主机机型说明 <https://docs.ucloud.cn/api/uhost-api/uhost_type>`_ 。
140139
- **MaxCount** (int) - 本次最大创建主机数量,取值范围是[1,100],默认值为1。
141140
- **Memory** (int) - 内存大小。单位:MB。范围 :[1024, 262144],取值为1024的倍数(可选范围参考控制台)。默认值:8192
142141
- **MinimalCpuPlatform** (str) - 最低cpu平台,枚举值["Intel/Auto", "Intel/IvyBridge", "Intel/Haswell", "Intel/Broadwell", "Intel/Skylake", "Intel/Cascadelake";"Intel/CascadelakeR"; “Amd/Epyc2”,"Amd/Auto"],默认值是"Intel/Auto"。
143142
- **Name** (str) - UHost实例名称。默认:UHost。请遵照 `字段规范 <https://docs.ucloud.cn/api/uhost-api/specification>`_ 设定实例名称。
144143
- **NetCapability** (str) - 网络增强特性。枚举值:Normal(默认),不开启; Super,开启网络增强1.0; Ultra,开启网络增强2.0(仅支持部分可用区,请参考控制台)
145144
- **NetworkInterface** (list) - 见 **CreateUHostInstanceParamNetworkInterface** 模型定义
145+
- **Password** (str) - UHost密码。请遵照 `字段规范 <https://docs.ucloud.cn/api/uhost-api/specification>`_ 设定密码。密码需使用base64进行编码,举例如下:# echo -n Password1 | base64UGFzc3dvcmQx。
146146
- **PrivateIp** (list) - 【数组】创建云主机时指定内网IP。若不传值,则随机分配当前子网下的IP。调用方式举例:PrivateIp.0=x.x.x.x。当前只支持一个内网IP。
147147
- **Quantity** (int) - 购买时长。默认:值 1。按小时购买(Dynamic/Postpay)时无需此参数。 月付时,此参数传0,代表购买至月末。
148-
- **RestrictMode** (str) - 抢占式实例限制模式,仅在ChargeType为"Preemptive"生效。可选模式为PowerOff:代表关机,LowSpeed代码限速 //默认为PowerOff
149-
- **SecurityGroupId** (str) - 防火墙ID,默认:Web推荐防火墙。如何查询SecurityGroupId请参见 `DescribeFirewall <https://docs.ucloud.cn/api/unet-api/describe_firewall.html>`_ 。
148+
- **SecurityGroupId** (str) - 防火墙ID,默认:Web推荐防火墙。如何查询SecurityGroupId请参见 `DescribeFirewall <https://docs.ucloud.cn/api/uhost-api/api/unet-api/describe_firewall.html>`_ 。
150149
- **SubnetId** (str) - 子网 ID。默认为当前地域的默认子网。
151150
- **Tag** (str) - 业务组。默认:Default(Default即为未分组)。请遵照 `字段规范 <https://docs.ucloud.cn/api/uhost-api/specification>`_ 设定业务组。
152151
- **UHostType** (str) - 【建议后续不再使用】云主机机型(V1.0),在本字段和字段MachineType中,仅需要其中1个字段即可。参考 `云主机机型说明 <https://docs.ucloud.cn/api/uhost-api/uhost_type>`_ 。
@@ -196,10 +195,10 @@ def create_uhost_instance(
196195
**CreateUHostInstanceParamVirtualGpuGPUVirtualGpu**
197196
198197
199-
**CreateUHostInstanceParamVolumes**
198+
**CreateUHostInstanceParamVirtualGpu**
200199
201200
202-
**CreateUHostInstanceParamVirtualGpu**
201+
**CreateUHostInstanceParamVolumes**
203202
204203
205204
"""
@@ -217,6 +216,48 @@ def create_uhost_instance(
217216
resp = self.invoke("CreateUHostInstance", d, **kwargs)
218217
return apis.CreateUHostInstanceResponseSchema().loads(resp)
219218

219+
def create_uhost_key_pair(
220+
self, req: typing.Optional[dict] = None, **kwargs
221+
) -> dict:
222+
"""CreateUHostKeyPair - 创建主机密钥对信息
223+
224+
**Request**
225+
226+
- **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 <https://docs.ucloud.cn/api/summary/get_project_list>`_
227+
- **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 <https://docs.ucloud.cn/api/summary/regionlist>`_
228+
- **KeyPairName** (str) - (Required) 密钥对名称。 由字母,数字,符号组成,长度为1-63位。
229+
- **Zone** (str) - 可用区。参见 `可用区列表 <https://docs.ucloud.cn/api/summary/regionlist>`_
230+
231+
**Response**
232+
233+
- **KeyPair** (dict) - 见 **KeyPair** 模型定义
234+
235+
**Response Model**
236+
237+
**KeyPair**
238+
- **CreateTime** (int) - 密钥对的创建时间,格式为Unix Timestamp。
239+
- **KeyPairFingerPrint** (str) - 密钥对指纹。md5(ProjectId|KeyPairId|PublicKey)
240+
- **KeyPairId** (str) - 密钥对ID。
241+
- **KeyPairName** (str) - 密钥对名称。 长度为1~63个英文或中文字符。
242+
- **PrivateKeyBody** (str) - 密钥对的私钥内容。只有创建接口才会返回。
243+
- **ProjectId** (str) - 项目ID。
244+
245+
246+
"""
247+
# build request
248+
d = {
249+
"ProjectId": self.config.project_id,
250+
"Region": self.config.region,
251+
}
252+
req and d.update(req)
253+
d = apis.CreateUHostKeyPairRequestSchema().dumps(d)
254+
255+
# build options
256+
kwargs["max_retries"] = 0 # ignore retry when api is not idempotent
257+
258+
resp = self.invoke("CreateUHostKeyPair", d, **kwargs)
259+
return apis.CreateUHostKeyPairResponseSchema().loads(resp)
260+
220261
def delete_isolation_group(
221262
self, req: typing.Optional[dict] = None, **kwargs
222263
) -> dict:
@@ -244,6 +285,33 @@ def delete_isolation_group(
244285
resp = self.invoke("DeleteIsolationGroup", d, **kwargs)
245286
return apis.DeleteIsolationGroupResponseSchema().loads(resp)
246287

288+
def delete_uhost_key_pairs(
289+
self, req: typing.Optional[dict] = None, **kwargs
290+
) -> dict:
291+
"""DeleteUHostKeyPairs - 删除一对或者多对密钥对。
292+
293+
**Request**
294+
295+
- **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 <https://docs.ucloud.cn/api/summary/get_project_list>`_
296+
- **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 <https://docs.ucloud.cn/api/summary/regionlist>`_
297+
- **KeyPairIds** (list) - (Required) 密钥对ID,最多支持 100 对。
298+
- **Zone** (str) - 可用区。参见 `可用区列表 <https://docs.ucloud.cn/api/summary/regionlist>`_
299+
300+
**Response**
301+
302+
303+
"""
304+
# build request
305+
d = {
306+
"ProjectId": self.config.project_id,
307+
"Region": self.config.region,
308+
}
309+
req and d.update(req)
310+
d = apis.DeleteUHostKeyPairsRequestSchema().dumps(d)
311+
312+
resp = self.invoke("DeleteUHostKeyPairs", d, **kwargs)
313+
return apis.DeleteUHostKeyPairsResponseSchema().loads(resp)
314+
247315
def describe_image(
248316
self, req: typing.Optional[dict] = None, **kwargs
249317
) -> dict:
@@ -497,6 +565,48 @@ def describe_uhost_instance_snapshot(
497565
resp = self.invoke("DescribeUHostInstanceSnapshot", d, **kwargs)
498566
return apis.DescribeUHostInstanceSnapshotResponseSchema().loads(resp)
499567

568+
def describe_uhost_key_pairs(
569+
self, req: typing.Optional[dict] = None, **kwargs
570+
) -> dict:
571+
"""DescribeUHostKeyPairs - 查询一个或多个密钥对。
572+
573+
**Request**
574+
575+
- **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 <https://docs.ucloud.cn/api/summary/get_project_list>`_
576+
- **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 <https://docs.ucloud.cn/api/summary/regionlist>`_
577+
- **KeyPairFingerPrint** (str) - 密钥对的指纹。
578+
- **KeyPairName** (str) - 密钥对名称。
579+
- **Limit** (int) - 返回数据长度,默认为20,最大100
580+
- **Offset** (int) - 列表起始位置偏移量,默认为0
581+
- **Zone** (str) - 可用区。参见 `可用区列表 <https://docs.ucloud.cn/api/summary/regionlist>`_
582+
583+
**Response**
584+
585+
- **KeyPairs** (list) - 见 **KeyPairDesc** 模型定义
586+
- **TotalCount** (int) - 密钥对总数
587+
588+
**Response Model**
589+
590+
**KeyPairDesc**
591+
- **CreateTime** (int) - 密钥对的创建时间,格式为Unix Timestamp。
592+
- **KeyPairFingerPrint** (str) - 密钥对指纹。md5(ProjectId|KeyPairId|PublicKey)
593+
- **KeyPairId** (str) - 密钥对ID。
594+
- **KeyPairName** (str) - 密钥对名称。 长度为1~63个英文或中文字符。
595+
- **ProjectId** (str) - 项目ID。
596+
597+
598+
"""
599+
# build request
600+
d = {
601+
"ProjectId": self.config.project_id,
602+
"Region": self.config.region,
603+
}
604+
req and d.update(req)
605+
d = apis.DescribeUHostKeyPairsRequestSchema().dumps(d)
606+
607+
resp = self.invoke("DescribeUHostKeyPairs", d, **kwargs)
608+
return apis.DescribeUHostKeyPairsResponseSchema().loads(resp)
609+
500610
def describe_uhost_tags(
501611
self, req: typing.Optional[dict] = None, **kwargs
502612
) -> dict:
@@ -576,11 +686,11 @@ def get_uhost_instance_price(
576686
- **CPU** (int) - (Required) CPU核数。可选参数:1-64。可选范围参照控制台。默认值: 4
577687
- **Count** (int) - (Required) 购买台数,范围[1,5]
578688
- **Memory** (int) - (Required) 内存大小。单位:MB。范围 :[1024, 262144],取值为1024的倍数(可选范围参照好控制台)。默认值:8192
579-
- **ChargeType** (str) - 计费模式。枚举值为: \\ > Year,按年付费; \\ > Month,按月付费;\\ > Dynamic,按小时付费 // >Preemptive 抢占式实例 \\ 默认为月付
689+
- **ChargeType** (str) - 计费模式。枚举值为: \\ > Year,按年付费; \\ > Month,按月付费;\\ > Dynamic,按小时付费 // >Preemptive 抢占式实例 \\ 如果不传某个枚举值,默认返回年付、月付、时付的价格组合集
580690
- **CpuPlatform** (str) - 取值"Intel" "Amd",默认值“Intel”
581691
- **Disks** (list) - 见 **GetUHostInstancePriceParamDisks** 模型定义
582692
- **GPU** (int) - GPU卡核心数。仅GPU机型支持此字段。
583-
- **GpuType** (str) - GPU类型,枚举值["K80", "P40", "V100", "T4"]
693+
- **GpuType** (str) - GPU类型,枚举值["K80", "P40", "V100", "T4","T4S","2080Ti","2080Ti-4C","1080Ti"]
584694
- **ImageId** (str) - 镜像Id,可通过 `DescribeImage <https://docs.ucloud.cn/api/uhost-api/describe_image.html>`_ 获取镜像ID, 如果镜像ID不传,系统盘大小必传
585695
- **MachineType** (str) - 云主机机型(V2版本概念)。枚举值["N", "C", "G", "O", "OS", "OPRO", "OMAX", "O.BM"]。参考 `云主机机型说明 <https://docs.ucloud.cn/api/uhost-api/uhost_type>`_ 。
586696
- **NetCapability** (str) - 网络增强。枚举值:Normal,不开启; Super,开启网络增强1.0。 默认值为Normal。
@@ -604,6 +714,9 @@ def get_uhost_instance_price(
604714
**GetUHostInstancePriceParamVolumes**
605715
606716
717+
**GetUHostInstancePriceParamVirtualGpu**
718+
719+
607720
**Response Model**
608721
609722
**UHostPriceSet**
@@ -724,6 +837,40 @@ def import_custom_image(
724837
resp = self.invoke("ImportCustomImage", d, **kwargs)
725838
return apis.ImportCustomImageResponseSchema().loads(resp)
726839

840+
def import_uhost_key_pairs(
841+
self, req: typing.Optional[dict] = None, **kwargs
842+
) -> dict:
843+
"""ImportUHostKeyPairs - 导入密钥对后,仅保管公钥部分,需自行妥善保存密钥对的私钥部分。
844+
845+
**Request**
846+
847+
- **ProjectId** (str) - (Config) 项目ID。不填写为默认项目,子帐号必须填写。 请参考 `GetProjectList接口 <https://docs.ucloud.cn/api/summary/get_project_list>`_
848+
- **Region** (str) - (Config) 地域。 参见 `地域和可用区列表 <https://docs.ucloud.cn/api/summary/regionlist>`_
849+
- **KeyPairName** (str) - (Required) 密钥对名称。由字母,数字,符号组成,长度为1-63位。
850+
- **PublicKeyBody** (str) - (Required) 密钥对的公钥内容。
851+
- **Zone** (str) - 可用区。参见 `可用区列表 <https://docs.ucloud.cn/api/summary/regionlist>`_
852+
853+
**Response**
854+
855+
- **KeyPairFingerPrint** (str) - 密钥对指纹。根据RFC4716定义的公钥指纹格式,采用MD5信息摘要算法。算法处理的具体信息格式:`ProjectIdKeyPairId|PublicKeyBody`。
856+
- **KeyPairId** (str) - 密钥对标识
857+
- **KeyPairName** (str) - 密钥对名称
858+
859+
"""
860+
# build request
861+
d = {
862+
"ProjectId": self.config.project_id,
863+
"Region": self.config.region,
864+
}
865+
req and d.update(req)
866+
d = apis.ImportUHostKeyPairsRequestSchema().dumps(d)
867+
868+
# build options
869+
kwargs["max_retries"] = 0 # ignore retry when api is not idempotent
870+
871+
resp = self.invoke("ImportUHostKeyPairs", d, **kwargs)
872+
return apis.ImportUHostKeyPairsResponseSchema().loads(resp)
873+
727874
def leave_isolation_group(
728875
self, req: typing.Optional[dict] = None, **kwargs
729876
) -> dict:
@@ -941,7 +1088,9 @@ def reinstall_uhost_instance(
9411088
- **AutoDataDiskInit** (str) - 数据盘是否需要自动分区挂载。当镜像支持Cloud-init Feature时可填写此字段。取值“On”(默认值), “Off”
9421089
- **BootDiskSpace** (int) - 系统盘大小。 单位:GB, 范围[20,100], 步长:10
9431090
- **ImageId** (str) - 镜像Id,默认使用原镜像 参见 `DescribeImage <https://docs.ucloud.cn/api/uhost-api/describe_image.html>`_
944-
- **Password** (str) - 如果创建UHost实例时LoginMode为Password,则必须填写,如果LoginMode为KeyPair,不需要填写 (密码格式使用BASE64编码;LoginMode不可变更)
1091+
- **KeyPairId** (str) - KeypairId 密钥对ID,LoginMode为KeyPair时此项必须。
1092+
- **LoginMode** (str) - 主机登陆模式。密码(默认选项): Password,密钥 KeyPair。
1093+
- **Password** (str) - 如果重装UHost实例时LoginMode为Password,则必须填写,如果LoginMode为KeyPair,不需要填写 (密码格式使用BASE64编码;举例如下:# echo -n Password1 | base64UGFzc3dvcmQx。)
9451094
- **ReserveDisk** (str) - 是否保留数据盘,保留:Yes,不报留:No, 默认:Yes;如果是从Windows重装为Linux或反之,则无法保留数据盘(该参数目前仅对本地数据盘起作用)
9461095
- **UserData** (str) - cloudinit初始化使用。注意:1、总数据量大小不超多16K 2、使用base64编码
9471096
- **Zone** (str) - 可用区。参见 `可用区列表 <https://docs.ucloud.cn/api/summary/regionlist>`_

0 commit comments

Comments
 (0)