Created
June 13, 2016 10:33
-
-
Save micmaher/0c1b6eb3d3b841acb2f735d58d3d2ae3 to your computer and use it in GitHub Desktop.
Move Rackspace Image to Cloud Files using the Pitchfork API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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