@@ -266,6 +266,189 @@ function Global:Get-S3AccountUsage {
266266 Write-Error " GET to $Uri failed with response:`n $responseBody "
267267 }
268268
269+ Write-Output $Result.data
270+ }
271+ }
272+ }
273+
274+ <#
275+ . SYNOPSIS
276+ Update an S3 Account
277+ . DESCRIPTION
278+ Update an S3 Account
279+ #>
280+ function Global :Update-S3Account {
281+ [CmdletBinding ()]
282+
283+ PARAM (
284+ [parameter (Mandatory = $True ,
285+ Position = 0 ,
286+ HelpMessage = " ID of S3 Account to update" ,
287+ ValueFromPipeline = $True ,
288+ ValueFromPipelineByPropertyName = $True )][String []]$id ,
289+ [parameter (Mandatory = $True ,
290+ Position = 1 ,
291+ HelpMessage = " New name for S3 Account" )][String []]$Name
292+
293+ )
294+
295+ Begin {
296+ $Result = $null
297+ }
298+
299+ Process {
300+ $id = @ ($id )
301+ foreach ($id in $id ) {
302+ $Uri = $CurrentS3MgmtServer.BaseURI + " /api/v1/service-provider/s3-accounts/$id "
303+
304+ try {
305+ $Result = Invoke-RestMethod - Method PATCH - Uri $Uri - Headers $CurrentS3MgmtServer.Headers - Body " {`" name`" :`" $Name `" }"
306+ }
307+ catch {
308+ $Response = $_.Exception.Response
309+ if ($Response ) {
310+ $Result = $Response.GetResponseStream ()
311+ $Reader = New-Object System.IO.StreamReader($Result )
312+ $responseBody = $reader.ReadToEnd ()
313+ }
314+ Write-Error " GET to $Uri failed with response:`n $responseBody "
315+ }
316+
317+ Write-Output $Result.data
318+ }
319+ }
320+ }
321+
322+ <#
323+ . SYNOPSIS
324+ Restore S3 Account Secret Key
325+ . DESCRIPTION
326+ Restore S3 Account Secret Key
327+ #>
328+ function Global :Restore-S3AccountSecretKey {
329+ [CmdletBinding ()]
330+
331+ PARAM (
332+ [parameter (Mandatory = $True ,
333+ Position = 0 ,
334+ HelpMessage = " ID of S3 Account to update" ,
335+ ValueFromPipeline = $True ,
336+ ValueFromPipelineByPropertyName = $True )][String []]$id
337+ )
338+
339+ Begin {
340+ $Result = $null
341+ }
342+
343+ Process {
344+ $id = @ ($id )
345+ foreach ($id in $id ) {
346+ $Uri = $CurrentS3MgmtServer.BaseURI + " /api/v1/service-provider/s3-accounts/$id /regenerate-keys"
347+
348+ try {
349+ $Result = Invoke-RestMethod - Method POST - Uri $Uri - Headers $CurrentS3MgmtServer.Headers
350+ }
351+ catch {
352+ $Response = $_.Exception.Response
353+ if ($Response ) {
354+ $Result = $Response.GetResponseStream ()
355+ $Reader = New-Object System.IO.StreamReader($Result )
356+ $responseBody = $reader.ReadToEnd ()
357+ }
358+ Write-Error " PATCH to $Uri failed with response:`n $responseBody "
359+ }
360+
361+ Write-Output $Result.data
362+ }
363+ }
364+ }
365+
366+ <#
367+ . SYNOPSIS
368+ Create an S3 Account
369+ . DESCRIPTION
370+ Create an S3 Account
371+ #>
372+ function Global :Create-S3Account {
373+ [CmdletBinding ()]
374+
375+ PARAM (
376+ [parameter (Mandatory = $True ,
377+ Position = 0 ,
378+ HelpMessage = " ID of S3 Account to update" ,
379+ ValueFromPipeline = $True ,
380+ ValueFromPipelineByPropertyName = $True )][String []]$Name
381+ )
382+
383+ Begin {
384+ $Result = $null
385+ }
386+
387+ Process {
388+ $Name = @ ($Name )
389+ foreach ($Name in $Name ) {
390+ $Uri = $CurrentS3MgmtServer.BaseURI + " /api/v1/service-provider/s3-accounts"
391+
392+ try {
393+ $Result = Invoke-RestMethod - Method POST - Uri $Uri - Headers $CurrentS3MgmtServer.Headers - Body " {`" name`" :`" $Name `" }"
394+ }
395+ catch {
396+ $Response = $_.Exception.Response
397+ if ($Response ) {
398+ $Result = $Response.GetResponseStream ()
399+ $Reader = New-Object System.IO.StreamReader($Result )
400+ $responseBody = $reader.ReadToEnd ()
401+ }
402+ Write-Error " POST to $Uri failed with response:`n $responseBody "
403+ }
404+
405+ Write-Output $Result.data
406+ }
407+ }
408+ }
409+
410+ <#
411+ . SYNOPSIS
412+ Delete an S3 Account
413+ . DESCRIPTION
414+ Delete an S3 Account
415+ #>
416+ function Global :Delete-S3Account {
417+ [CmdletBinding ()]
418+
419+ PARAM (
420+ [parameter (Mandatory = $True ,
421+ Position = 0 ,
422+ HelpMessage = " ID of S3 Account to delete" ,
423+ ValueFromPipeline = $True ,
424+ ValueFromPipelineByPropertyName = $True )][String []]$id
425+ )
426+
427+ Begin {
428+ if (! $CurrentS3MgmtServer ) {
429+ Write-Error " No S3 management server found. Please run Connect-S3MgtServer to continue."
430+ }
431+ $Result = $null
432+ }
433+
434+ Process {
435+ $id = @ ($id )
436+ foreach ($id in $id ) {
437+ $Uri = $CurrentS3MgmtServer.BaseURI + " /api/v1/service-provider/s3-accounts/$id "
438+
439+ try {
440+ $Result = Invoke-RestMethod - Method DELETE - Uri $Uri - Headers $CurrentS3MgmtServer.Headers
441+ }
442+ catch {
443+ $Response = $_.Exception.Response
444+ if ($Response ) {
445+ $Result = $Response.GetResponseStream ()
446+ $Reader = New-Object System.IO.StreamReader($Result )
447+ $responseBody = $reader.ReadToEnd ()
448+ }
449+ Write-Error " GET to $Uri failed with response:`n $responseBody "
450+ }
451+
269452 Write-Output $Result.data
270453 }
271454 }
0 commit comments