Skip to content

Instantly share code, notes, and snippets.

@micmaher
Created June 13, 2016 10:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save micmaher/0c1b6eb3d3b841acb2f735d58d3d2ae3 to your computer and use it in GitHub Desktop.
Save micmaher/0c1b6eb3d3b841acb2f735d58d3d2ae3 to your computer and use it in GitHub Desktop.
Move Rackspace Image to Cloud Files using the Pitchfork API
$DDI='YOUR ID HERE'
$Region = 'YOUR SITE HERE'
$AuthToken = "YOUR TOKEN HERE"
$URI="https://$region.images.api.rackspacecloud.com/v2/$DDI/tasks/"
# ImageID
$imageid = 'YOUR IMAGE ID HERE'
$container = "YOUR CONTAINER HERE"
# Request Headers
Set-Variable -Name "headers" -Value $(@{
"Content-Type" = "application/json"
"X-Auth-Token" = "$AuthToken"
})
# Data
$body = @{
input = @{image_uuid = $imageid; receiving_swift_container = $container}
type = "export"
} | ConvertTo-Json
# Set the URI Variable
Set-Variable -Name "uri" -Value $("$uri")
# Method to use for the Rest Call
$POST = "POST"
$GET = "GET"
$request = Invoke-RestMethod -Uri $uri -Method $POST -Headers $headers -Body $body
Start-Sleep 5
# Get Status
$request.status
$statusURI = $URI + $request.id
$update = Invoke-RestMethod -Uri $uri -Method $GET -Headers $headers
$update.tasks | where id -eq $request.id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment