1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152
|
# frozen_string_literal: true
module Fog
module Compute
class Aliyun
class Real
# Describe disks.
#
# ==== Parameters
# * options<~hash>
# * :diskIds - arry of diskId, the length of arry should less than or equal to 100.
# * :instanceId - id of the instance
# * :diskType - Default 'all'.Can be set to all | system | data
# * :category - Default 'all'. Can be set to all | cloud | cloud_efficiency | cloud_ssd | ephemeral | ephemeral_ssd
# * :state - status of the disk. Default 'All'. Can be set to In_use | Available | Attaching | Detaching | Creating | ReIniting | All
# * :snapshotId - id of snapshot which used to create disk.
# * :name - name of disk
# * :portable - If ture, can exist dependently,which means it can be mount or umont in available zones.
# Else, it must be created or destroyed with a instance.
# The value for ocal disks and system disks on the cloud and cloud disks paid by month must be false.
# * :delWithIns - If ture, the disk will be released when the instance is released.
# * :delAutoSna - If ture, the auto created snapshot will be destroyed when the disk is destroyed
# * :enAutoSna - Whether the disk apply the auto snapshot strategy.
# * :diskChargeType - Prepaid | Postpaid
# ==== Returns
# * response<~Excon::Response>:
# * body<~Hash>:
# * 'RequestId'<~String> - Id of the request
# * 'Disks'<~Hash> - list of Disk,and the parameter of disk refer to the Volume model
#
# {Aliyun API Reference}[https://docs.aliyun.com/?spm=5176.100054.3.1.DGkmH7#/pub/ecs/open-api/disk&describedisks]
def list_disks(options = {})
action = 'DescribeDisks'
sigNonce = randonStr
time = Time.new.utc
parameters = defaultParameters(action, sigNonce, time)
pathUrl = defaultAliyunUri(action, sigNonce, time)
pageNumber = options[:pageNumber]
pageSize = options[:pageSize]
instanceId = options[:instanceId]
diskIds = options[:diskIds]
diskType = options[:diskType]
category = options[:category]
state = options[:state]
snapshotId = options[:snapshotId]
name = options[:name]
portable = options[:portable]
delWithIns = options[:deleteWithInstance]
delAutoSna = options[:deleteAutoSnapshot]
enAutoSna = options[:enableAutoSnapshot]
diskChargeType = options[:diskChargeType]
if diskChargeType
parameters['DiskChargeType'] = diskChargeType
pathUrl += '&DiskChargeType='
pathUrl += diskChargeType
end
if enAutoSna
parameters['EnableAutoSnapshot'] = enAutoSna
pathUrl += '&EnableAutoSnapshot='
pathUrl += enAutoSna
end
if delAutoSna
parameters['DeleteAutoSnapshot'] = delAutoSna
pathUrl += '&DeleteAutoSnapshot='
pathUrl += delAutoSna
end
if delWithIns
parameters['DeleteWithInstance'] = delWithIns
pathUrl += '&DeleteWithInstance='
pathUrl += delWithIns
end
if portable
parameters['Portable'] = portable
pathUrl += '&Portable='
pathUrl += portable
end
if name
parameters['DiskName'] = name
pathUrl += '&DiskName='
pathUrl += name
end
if snapshotId
parameters['SnapshotId'] = snapshotId
pathUrl += '&SnapshotId='
pathUrl += snapshotId
end
if state
parameters['Status'] = state
pathUrl += '&Status='
pathUrl += state
end
if category
parameters['DiskType'] = diskType
pathUrl += '&DiskType='
pathUrl += diskType
end
if category
parameters['Category'] = category
pathUrl += '&Category='
pathUrl += category
end
if instanceId
parameters['InstanceId'] = instanceId
pathUrl += '&InstanceId='
pathUrl += instanceId
end
if diskIds
parameters['DiskIds'] = Fog::JSON.encode(diskIds)
pathUrl += '&DiskIds='
pathUrl += Fog::JSON.encode(diskIds)
end
if pageNumber
parameters['PageNumber'] = pageNumber
pathUrl += '&PageNumber='
pathUrl += pageNumber
end
pageSize = options[:pageSize]
pageSize ||= '50'
parameters['PageSize'] = pageSize
pathUrl += '&PageSize='
pathUrl += pageSize
signature = sign(@aliyun_accesskey_secret, parameters)
pathUrl += '&Signature='
pathUrl += signature
request(
expects: [200, 203],
method: 'GET',
path: pathUrl
)
end
end
end
end
end
|