bcc_model.py 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. # Copyright (c) 2011 X.commerce, a business unit of eBay Inc.
  2. # Copyright 2010 United States Government as represented by the
  3. # Administrator of the National Aeronautics and Space Administration.
  4. # Copyright 2011 Piston Cloud Computing, Inc.
  5. # All Rights Reserved.
  6. #
  7. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  8. # not use this file except in compliance with the License. You may obtain
  9. # a copy of the License at
  10. #
  11. # http://www.apache.org/licenses/LICENSE-2.0
  12. #
  13. # Unless required by applicable law or agreed to in writing, software
  14. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  15. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  16. # License for the specific language governing permissions and limitations
  17. # under the License.
  18. """
  19. This module provides models for BCC-SDK.
  20. """
  21. class Billing(object):
  22. """
  23. This class define billing.
  24. param: paymentTiming:
  25. The pay time of the payment,
  26. see more detail in https://bce.baidu.com/doc/BCC/API.html#Billing
  27. param: reservationLength:
  28. The duration to buy in specified time unit,
  29. available values are [1,2,3,4,5,6,7,8,9,12,24,36] now.
  30. param: reservationTimeUnit:
  31. The time unit to specify the duration ,only "Month" can be used now.
  32. """
  33. def __init__(self, paymentTiming=None, reservationLength=1, reservationTimeUnit='Month'):
  34. if paymentTiming:
  35. self.paymentTiming = paymentTiming
  36. self.reservation = {
  37. 'reservationLength': reservationLength,
  38. 'reservationTimeUnit': reservationTimeUnit
  39. }
  40. class EphemeralDisk(object):
  41. """
  42. This class define detail of creating ephemeral volume.
  43. param: sizeInGB:
  44. The size of volume in GB.
  45. param: storageType:
  46. The storage type of volume,
  47. see more detail in https://bce.baidu.com/doc/BCC/API.html#StorageType
  48. """
  49. def __init__(self, sizeInGB, storageType='sata'):
  50. self.sizeInGB = sizeInGB
  51. self.storageType = storageType
  52. class CreateCdsModel(object):
  53. """
  54. This class define detail of creating volume.
  55. param: cdsSizeInGB:
  56. The size of volume in GB.
  57. param: storageType:
  58. The storage type of volume,
  59. see more detail in https://bce.baidu.com/doc/BCC/API.html#StorageType
  60. param: snapshotId:
  61. The id of snapshot.
  62. param: encryptKey
  63. """
  64. def __init__(self, cdsSizeInGB=None, storageType='hp1', snapshotId=None, encryptKey=None, deleteWithInstance=None):
  65. self.cdsSizeInGB = cdsSizeInGB
  66. self.storageType = storageType
  67. self.snapshotId = snapshotId
  68. self.encryptKey = encryptKey
  69. self.deleteWithInstance = deleteWithInstance
  70. class SecurityGroupRuleModel(object):
  71. """
  72. This class define the rule of the securitygroup.
  73. param: remark:
  74. The remark for the rule.
  75. param: direction:
  76. The parameter to define the rule direction,available value are "ingress/egress".
  77. param: ethertype:
  78. The ethernet protocol.
  79. param: portRange:
  80. The port range to specify the port which the rule will work on.
  81. Available range is rang [0, 65535], the fault value is "" for all port.
  82. param: protocol:
  83. The parameter specify which protocol will the rule work on, the fault value is "" for all protocol.
  84. Available protocol are tcp, udp and icmp.
  85. param: sourceGroupId:
  86. The id of source securitygroup.
  87. Only works for direction = "ingress".
  88. param: sourceIp:
  89. The source ip range with CIDR formats. The default value 0.0.0.0/0 (allow all ip address),
  90. other supported formats such as {ip_addr}/12 or {ip_addr}. Only supports IPV4.
  91. Only works for direction = "ingress".
  92. param: destGroupId:
  93. The id of destination securitygroup.
  94. Only works for direction = "egress".
  95. param: destIp:
  96. The destination ip range with CIDR formats. The default value 0.0.0.0/0 (allow all ip address),
  97. other supported formats such as {ip_addr}/12 or {ip_addr}. Only supports IPV4.
  98. Only works for direction = "egress".
  99. param: securityGroupId:
  100. The id of the securitygroup for the rule.
  101. """
  102. def __init__(self, remark=None, direction=None, ethertype=None, portRange=None,
  103. protocol=None, sourceGroupId=None, sourceIp=None, destGroupId=None, destIp=None,
  104. securityGroupId=None):
  105. self.remark = remark
  106. self.direction = direction
  107. self.ethertype = ethertype
  108. self.portRange = portRange
  109. self.protocol = protocol
  110. self.sourceGroupId = sourceGroupId
  111. self.sourceIp = sourceIp
  112. self.destGroupId = destGroupId
  113. self.destIp = destIp
  114. self.securityGroupId = securityGroupId
  115. class TagModel(object):
  116. """
  117. TAGModel
  118. """
  119. def __init__(self, tagKey=None, tagValue=None):
  120. self.tagKey = tagKey
  121. self.tagValue = tagValue
  122. class PayTimingChangeReqModel(object):
  123. """
  124. This class define detail of change pay timing.
  125. """
  126. def __init__(self, instanceId, relationCds=False, cdsList=None, duration=None, autoPay=True,
  127. autoRenew=None, autoRenewPeriod=None, effectiveType=None):
  128. self.instanceId = instanceId
  129. self.relationCds = relationCds
  130. self.cdsList = cdsList
  131. self.effectiveType = effectiveType
  132. self.duration = duration
  133. self.autoPay = autoPay
  134. self.autoRenew = autoRenew
  135. self.autoRenewPeriod = autoRenewPeriod
  136. class DestRegionInfoModel(object):
  137. """
  138. This class define for snapshot remote copy.
  139. """
  140. def __init__(self, destRegion, name):
  141. self.destRegion = destRegion
  142. self.name = name
  143. class AutoSnapshotPolicyModel(object):
  144. """
  145. This class define auto snapshot policy.
  146. """
  147. def __init__(self, name, timePoints, repeatWeekdays, retentionDays=None):
  148. self.name = name
  149. self.timePoints = timePoints
  150. self.repeatWeekdays = repeatWeekdays
  151. self.retentionDays = retentionDays
  152. class ModifyReservedInstanceModel(object):
  153. """
  154. ModifyReservedInstanceModel
  155. """
  156. def __init__(self, reservedInstanceId=None, zoneName=None, reservedInstanceName=None, ehcClusterId=None):
  157. self.reservedInstanceId = reservedInstanceId
  158. self.zoneName = zoneName
  159. self.reservedInstanceName = reservedInstanceName
  160. self.ehcClusterId = ehcClusterId
  161. class CdsCustomPeriod(object):
  162. """
  163. This class define custom period.
  164. """
  165. def __init__(self, period=None, volume_id=None):
  166. self.period = period
  167. self.volumeId = volume_id
  168. class FileSystemModel(object):
  169. """
  170. This class define file system.
  171. """
  172. def __init__(self, fsId=None, mountAds=None, path=None, protocol=None):
  173. self.fsId = fsId
  174. self.mountAds = mountAds
  175. self.path = path
  176. self.protocol = protocol