Skip to content

Commit

Permalink
Revert "auto codegen for UNet" (#136)
Browse files Browse the repository at this point in the history
  • Loading branch information
shawnmssu authored May 8, 2021
1 parent 774e0d1 commit a985b7b
Show file tree
Hide file tree
Showing 3 changed files with 258 additions and 16 deletions.
120 changes: 120 additions & 0 deletions ucloud/services/unet/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,51 @@ def allocate_share_bandwidth(
resp = self.invoke("AllocateShareBandwidth", d, **kwargs)
return apis.AllocateShareBandwidthResponseSchema().loads(resp)

def allocate_vip(self, req: typing.Optional[dict] = None, **kwargs) -> dict:
"""AllocateVIP -
**Request**
- **ProjectId** (str) - (Config)
- **Region** (str) - (Config)
- **SubnetId** (str) - (Required)
- **VPCId** (str) - (Required)
- **BusinessId** (str) -
- **Count** (int) -
- **Ip** (str) -
- **Name** (str) -
- **Remark** (str) -
- **Tag** (str) -
- **Zone** (str) -
**Response**
- **DataSet** (list) -
- **VIPSet** (list) - 见 **VIPSet** 模型定义
**Response Model**
**VIPSet**
- **VIP** (str) -
- **VIPId** (str) -
- **VPCId** (str) -
"""
# build request
d = {
"ProjectId": self.config.project_id,
"Region": self.config.region,
}
req and d.update(req)
d = apis.AllocateVIPRequestSchema().dumps(d)

# build options
kwargs["max_retries"] = 0 # ignore retry when api is not idempotent

resp = self.invoke("AllocateVIP", d, **kwargs)
return apis.AllocateVIPResponseSchema().loads(resp)

def associate_eip_with_share_bandwidth(
self, req: typing.Optional[dict] = None, **kwargs
) -> dict:
Expand Down Expand Up @@ -575,6 +620,53 @@ def describe_share_bandwidth(
resp = self.invoke("DescribeShareBandwidth", d, **kwargs)
return apis.DescribeShareBandwidthResponseSchema().loads(resp)

def describe_vip(self, req: typing.Optional[dict] = None, **kwargs) -> dict:
"""DescribeVIP -
**Request**
- **ProjectId** (str) - (Config)
- **Region** (str) - (Config)
- **BusinessId** (str) -
- **SubnetId** (str) -
- **Tag** (str) -
- **VPCId** (str) -
- **Zone** (str) -
**Response**
- **DataSet** (list) -
- **TotalCount** (int) -
- **VIPSet** (list) - 见 **VIPDetailSet** 模型定义
**Response Model**
**VIPDetailSet**
- **CreateTime** (int) -
- **Name** (str) -
- **RealIp** (str) -
- **SubnetId** (str) -
- **VIP** (str) -
- **VIPId** (str) -
- **VPCId** (str) -
- **Zone** (str) -
"""
# build request
d = {
"ProjectId": self.config.project_id,
"Region": self.config.region,
}
req and d.update(req)
d = apis.DescribeVIPRequestSchema().dumps(d)

# build options
kwargs["max_retries"] = 0 # ignore retry when api is not idempotent

resp = self.invoke("DescribeVIP", d, **kwargs)
return apis.DescribeVIPResponseSchema().loads(resp)

def disassociate_eip_with_share_bandwidth(
self, req: typing.Optional[dict] = None, **kwargs
) -> dict:
Expand Down Expand Up @@ -843,6 +935,34 @@ def release_share_bandwidth(
resp = self.invoke("ReleaseShareBandwidth", d, **kwargs)
return apis.ReleaseShareBandwidthResponseSchema().loads(resp)

def release_vip(self, req: typing.Optional[dict] = None, **kwargs) -> dict:
"""ReleaseVIP -
**Request**
- **ProjectId** (str) - (Config)
- **Region** (str) - (Config)
- **VIPId** (str) - (Required)
- **Zone** (str) -
**Response**
"""
# build request
d = {
"ProjectId": self.config.project_id,
"Region": self.config.region,
}
req and d.update(req)
d = apis.ReleaseVIPRequestSchema().dumps(d)

# build options
kwargs["max_retries"] = 0 # ignore retry when api is not idempotent

resp = self.invoke("ReleaseVIP", d, **kwargs)
return apis.ReleaseVIPResponseSchema().loads(resp)

def resize_share_bandwidth(
self, req: typing.Optional[dict] = None, **kwargs
) -> dict:
Expand Down
97 changes: 97 additions & 0 deletions ucloud/services/unet/schemas/apis.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,44 @@ class AllocateShareBandwidthResponseSchema(schema.ResponseSchema):
}


"""
API: AllocateVIP
"""


class AllocateVIPRequestSchema(schema.RequestSchema):
"""AllocateVIP -"""

fields = {
"BusinessId": fields.Str(required=False, dump_to="BusinessId"),
"Count": fields.Int(required=False, dump_to="Count"),
"Ip": fields.Str(required=False, dump_to="Ip"),
"Name": fields.Str(required=False, dump_to="Name"),
"ProjectId": fields.Str(required=False, dump_to="ProjectId"),
"Region": fields.Str(required=True, dump_to="Region"),
"Remark": fields.Str(required=False, dump_to="Remark"),
"SubnetId": fields.Str(required=True, dump_to="SubnetId"),
"Tag": fields.Str(required=False, dump_to="Tag"),
"VPCId": fields.Str(required=True, dump_to="VPCId"),
"Zone": fields.Str(required=False, dump_to="Zone"),
}


class AllocateVIPResponseSchema(schema.ResponseSchema):
"""AllocateVIP -"""

fields = {
"DataSet": fields.List(
fields.Str(), required=False, load_from="DataSet"
),
"VIPSet": fields.List(
models.VIPSetSchema(), required=False, load_from="VIPSet"
),
}


"""
API: AssociateEIPWithShareBandwidth
Expand Down Expand Up @@ -436,6 +474,41 @@ class DescribeShareBandwidthResponseSchema(schema.ResponseSchema):
}


"""
API: DescribeVIP
"""


class DescribeVIPRequestSchema(schema.RequestSchema):
"""DescribeVIP -"""

fields = {
"BusinessId": fields.Str(required=False, dump_to="BusinessId"),
"ProjectId": fields.Str(required=False, dump_to="ProjectId"),
"Region": fields.Str(required=True, dump_to="Region"),
"SubnetId": fields.Str(required=False, dump_to="SubnetId"),
"Tag": fields.Str(required=False, dump_to="Tag"),
"VPCId": fields.Str(required=False, dump_to="VPCId"),
"Zone": fields.Str(required=False, dump_to="Zone"),
}


class DescribeVIPResponseSchema(schema.ResponseSchema):
"""DescribeVIP -"""

fields = {
"DataSet": fields.List(
fields.Str(), required=False, load_from="DataSet"
),
"TotalCount": fields.Int(required=False, load_from="TotalCount"),
"VIPSet": fields.List(
models.VIPDetailSetSchema(), required=False, load_from="VIPSet"
),
}


"""
API: DisassociateEIPWithShareBandwidth
Expand Down Expand Up @@ -674,6 +747,30 @@ class ReleaseShareBandwidthResponseSchema(schema.ResponseSchema):
fields = {}


"""
API: ReleaseVIP
"""


class ReleaseVIPRequestSchema(schema.RequestSchema):
"""ReleaseVIP -"""

fields = {
"ProjectId": fields.Str(required=False, dump_to="ProjectId"),
"Region": fields.Str(required=True, dump_to="Region"),
"VIPId": fields.Str(required=True, dump_to="VIPId"),
"Zone": fields.Str(required=False, dump_to="Zone"),
}


class ReleaseVIPResponseSchema(schema.ResponseSchema):
"""ReleaseVIP -"""

fields = {}


"""
API: ResizeShareBandwidth
Expand Down
57 changes: 41 additions & 16 deletions ucloud/services/unet/schemas/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ class UnetAllocateEIPSetSchema(schema.ResponseSchema):
}


class VIPSetSchema(schema.ResponseSchema):
"""VIPSet -"""

fields = {
"VIP": fields.Str(required=False, load_from="VIP"),
"VIPId": fields.Str(required=False, load_from="VIPId"),
"VPCId": fields.Str(required=False, load_from="VPCId"),
}


class EIPAddrSetSchema(schema.ResponseSchema):
"""EIPAddrSet - DescribeBandwidthPackage"""

Expand Down Expand Up @@ -55,6 +65,22 @@ class UnetBandwidthUsageEIPSetSchema(schema.ResponseSchema):
}


class ShareBandwidthSetSchema(schema.ResponseSchema):
"""ShareBandwidthSet - DescribeEIP"""

fields = {
"ShareBandwidth": fields.Int(
required=False, load_from="ShareBandwidth"
),
"ShareBandwidthId": fields.Str(
required=False, load_from="ShareBandwidthId"
),
"ShareBandwidthName": fields.Str(
required=False, load_from="ShareBandwidthName"
),
}


class UnetEIPResourceSetSchema(schema.ResponseSchema):
"""UnetEIPResourceSet - DescribeEIP"""

Expand All @@ -76,22 +102,6 @@ class UnetEIPResourceSetSchema(schema.ResponseSchema):
}


class ShareBandwidthSetSchema(schema.ResponseSchema):
"""ShareBandwidthSet - DescribeEIP"""

fields = {
"ShareBandwidth": fields.Int(
required=False, load_from="ShareBandwidth"
),
"ShareBandwidthId": fields.Str(
required=False, load_from="ShareBandwidthId"
),
"ShareBandwidthName": fields.Str(
required=False, load_from="ShareBandwidthName"
),
}


class UnetEIPSetSchema(schema.ResponseSchema):
"""UnetEIPSet - DescribeEIP"""

Expand Down Expand Up @@ -194,6 +204,21 @@ class UnetShareBandwidthSetSchema(schema.ResponseSchema):
}


class VIPDetailSetSchema(schema.ResponseSchema):
"""VIPDetailSet -"""

fields = {
"CreateTime": fields.Int(required=False, load_from="CreateTime"),
"Name": fields.Str(required=False, load_from="Name"),
"RealIp": fields.Str(required=False, load_from="RealIp"),
"SubnetId": fields.Str(required=False, load_from="SubnetId"),
"VIP": fields.Str(required=False, load_from="VIP"),
"VIPId": fields.Str(required=False, load_from="VIPId"),
"VPCId": fields.Str(required=False, load_from="VPCId"),
"Zone": fields.Str(required=False, load_from="Zone"),
}


class EIPPayModeSetSchema(schema.ResponseSchema):
"""EIPPayModeSet - GetEIPPayModeEIP"""

Expand Down

0 comments on commit a985b7b

Please sign in to comment.