-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPOSH_RS_API_CBS.PSM1
More file actions
122 lines (92 loc) · 3.82 KB
/
POSH_RS_API_CBS.PSM1
File metadata and controls
122 lines (92 loc) · 3.82 KB
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
function Get-RSCBSQuota {
Param (
)
$product = "cloudBlockStorage"
write-verbose "Getting CBS Quota"
write-debug "Parameters:$($MyInvocation.BoundParameters | format-table -AutoSize | out-string)"
$uri = (GetEndpoint -product $product) + "/os-quota-sets/"+(Get-RSDDI)+"?usage=True"
(Invoke-RestMethod -Uri $uri -Method GET -Headers (GetAuthToken) -ContentType application/json).quota_set
}
function Get-RSCBSVolume{
param(
[Parameter()][string[]]$VolumeID,
[Parameter()][ValidateSet("SATA","SSD")][string]$VolumeType,
[Parameter()][ValidateRange(50,1024)][int]$MinSize,
[Parameter()][ValidateRange(50,1024)][int]$MaxSize,
[Parameter()][string]$name,
[Parameter()][string]$description,
[Parameter()][string]$SnapshotID,
[Parameter()][string]$SourceVolumeID,
[Parameter()][string]$ImageID
)
$product = "cloudBlockStorage"
$apiResult="volumes"
$uri = "/volumes"
$method = "GET"
write-verbose "Listing CBS Volumes"
write-debug "Parameters:$($MyInvocation.BoundParameters | format-table -AutoSize | out-string)"
(Invoke-RSAPICall -product $product -Uri $uri -Method $method -body $body).($apiResult)
}
function New-RSCBSVolume{
param(
[Parameter(Mandatory=$True)][ValidateSet("SATA","SSD")][string]$VolumeType,
[Parameter(Mandatory=$True)][ValidateRange(50,1024)][int]$Size,
[Parameter(Mandatory=$True)][string]$name,
[Parameter()][string]$description,
[Parameter()][string]$SnapshotID,
[Parameter()][string]$VolumeID,
[Parameter()][string]$ImageID
)
$product = "cloudBlockStorage"
$apiResult="volume"
$uri = "/volumes"
$method = "POST"
if ($volumeType -eq "SATA" -and $size -lt 75) { $size = 75}
$body = @{"volume" = @{"volume_type" = "$VolumeType";"size" = $size;"display_name" = "$name"}}
if ($description -ne "") { $body.volume.add("display_description", $Description) }
if ($SnapshotID -ne "") { $body.volume.add("snapshot_id", $SnapshotID) }
elseif ($VolumeID -ne "") { $body.volume.add("source_volid", $VolumeID) }
elseif ($ImageID -ne "") { $body.volume.add("imageRef", $ImageID) }
$body = $body | ConvertTo-Json -Compress -depth 10
write-verbose "Updating CBS Volume $VolumeID"
write-debug "Parameters:$($MyInvocation.BoundParameters | format-table -AutoSize | out-string)"
(Invoke-RSAPICall -product $product -Uri $uri -Method $method -body $body).($apiResult)
}
function Update-RSCBSVolume{
param(
[Parameter(Mandatory=$True)][string]$VolumeID,
[Parameter()][string]$name,
[Parameter()][string]$description
)
$product = "cloudBlockStorage"
$apiResult="volume"
$uri = "/volumes/$VolumeID"
$method = "PUT"
$body = @{"volume" = @{}}
if ($name -ne "") { $body.volume.add("display_name", $Name) }
if ($description -ne "") { $body.volume.add("display_description", $Description) }
$body = $body | ConvertTo-Json -Compress -depth 10
write-verbose "Updating CBS Volume $VolumeID"
write-debug "Parameters:$($MyInvocation.BoundParameters | format-table -AutoSize | out-string)"
(Invoke-RSAPICall -product $product -Uri $uri -Method $method -body $body).($apiResult)
}
function Delete-RSCBSVolume{
param(
[Parameter(Mandatory=$True)][string]$VolumeID
)
$product = "cloudBlockStorage"
$apiResult="volumes"
$uri = "/volumes/$VolumeID"
$method = "DELETE"
write-verbose "Deleting CBS Volume $VolumeID"
write-debug "Parameters:$($MyInvocation.BoundParameters | format-table -AutoSize | out-string)"
(Invoke-RSAPICall -product $product -Uri $uri -Method $method).($apiResult)
}
function Get-RSCBSSnapshot{
}
function New-RSCBSSnapshot{
}
function Update-RSCBSSnapshot{
}
function Delete-RSCBSSnapshot{
}