Note: Please go to docs.rightscale.com to access the current RightScale documentation set. Also, feel free to Chat with us!
Home > Guides > RightScale API 1.5 > Examples > Inputs > Bulk Modify Deployment Inputs

Bulk Modify Deployment Inputs

Modify several Inputs (e.g. "bulk modify") with a single API call for a specified deployment.

Note:  HTTP PUT method is used.  If a specified input does not exist, it gets created.  If it does exist, its value is set to the one provided.  This example modifies inputs at the Deployment level.  See the API online reference (for Inputs > multi_update) to construct the URL and modify at the ServerTemplate or server instance level.  If you accidentally set the input value twice on the same API call, the last setting takes precedence.

icon_curl_v1.png    icon_powershell_v1.png

Table of Contents

Curl

Prerequisite:  Example assumes you have previously authenticated, and your valid session cookie is in 'mycookie'.

Example Call

Modify the Timezone (text) input and the SVN User/Password (credential) input at the deployment level.   A single API call changes all three for all servers in the specified deployment. 

Note:  The following example uses bulk modify inputs "notation 1.0".  Its easy to read, but lengthier to specify.  See the Supplemental section below to see the newer "notation 2.0" format. 

Important!  Notation 1.0 will be deprecated in RightScale API 2.0 in favor of  "notation 2.0" format.

Curl on a single line:

#!/bin/sh -e
DEPLOYMENT="306795001"       # Set the deployment to change inputs for
curl -i -H X_API_VERSION:1.5 -b mycookie -d inputs[][name]="rightscale/timezone" -d inputs[][value]="text:US/Pacific"  -d inputs[][name]="repo/default/svn_username" -d inputs[][value]="cred:GD_SVN_USERNAME" -d inputs[][name]="repo/default/svn_password" -d inputs[][value]="cred:GD_SVN_PASSWORD" -X PUT https://my.rightscale.com/api/deployments/$DEPLOYMENT/inputs/multi_update

Same script but with curl split into multiple lines and basic in-line comments for readability sake:

#!/bin/sh -e
DEPLOYMENT="306795001"       # Set the deployment to change inputs for
curl -i -H X_API_VERSION:1.5 -b mycookie \
-d inputs[][name]="rightscale/timezone" \
-d inputs[][value]="text:US/Pacific" \              # Change TZ (text) input value
-d inputs[][name]="repo/default/svn_username" \
-d inputs[][value]="cred:GD_SVN_USERNAME" \         # Change SVN Username (credential) value
-d inputs[][name]="repo/default/svn_password" \
-d inputs[][value]="cred:GD_SVN_PASSWORD" \         # Change the SVN Password (credential) value
-X PUT https://my.rightscale.com/api/deployments/$DEPLOYMENT/inputs/multi_update

Sample Output

HTTP/1.1 204 No Content
Server: nginx/1.0.15
Date: Wed, 07 Nov 2012 16:53:34 GMT
Connection: keep-alive
Status: 204 No Content
X-Runtime: 62
X-Request-Uuid: 87119d96c03842869fcd36dc6b8131dd
Set-Cookie:
Cache-Control: no-cache

Note:  Navigate or refresh your browser from YourDeployment > Inputs tab.  Each input value should be changed, and painted "blue" designating the input was set at the deployment level.

Supplemental

The equivalent example using the more streamlined "notation 2.0" follows.

Important!  Notation 1.0 will be deprecated in RightScale API 2.0 in favor of the following "notation 2.0" format.

#!/bin/sh -e
DEPLOYMENT="306795001"       # Set the deployment to change inputs for
curl -i -H X_API_VERSION:1.5 -b mycookie \
-d inputs[rightscale/timezone]="text:US/Pacific", \
-d inputs[repo/default/svn_username]="cred:GD_SVN_USERNAME", \
-d inputs[repo/default/svn_password]="cred:GD_SVN_PASSWORD" \
-X PUT https://my.rightscale.com/api/deployments/$DEPLOYMENT/inputs/multi_update

 

PowerShell

Prerequisite:  Example assumes you have previously authenticated and your session cookie for subsequent requests is in 'cookieContainer'.

Example Call

The following example modifies several Inputs (APPLICATION_LISTENER_PORT, ZIP_FILE_NAME and OPT_APP_POOL_NAME) for Deployment with ID 306795001.

$deploymentID = "306795001"                                     # Set the actual ID of the deployment to be modified
$stringToPut = "inputs[][name]=APPLICATION_LISTENER_PORT&"      # One of several Inputs to be modified
$stringToPut += "inputs[][value]=text:80&"                      # Set to 80
$stringToPut += "inputs[][name]=ZIP_FILE_NAME&"
$stringToPut += "inputs[][value]=text:thisisazipfile.zip&"      # Set to a zip file name
$stringToPut += "inputs[][name]=OPT_APP_POOL_NAME&"
$stringToPut += "inputs[][value]=text:ASP.NET v4.0"             # Set to ASP.NET v4.0
$inputWebRequest = [System.Net.WebRequest]::Create("https://my.rightscale.com/api/deployments/$deploymentID/inputs/multi_update?$stringToPut")
$inputWebRequest.Method = "PUT"
$inputWebRequest.Headers.Add("X_API_VERSION","1.5")
$inputWebRequest.CookieContainer = $cookieContainer
$inputWebRequest.ServicePoint.Expect100Continue = $false
$inputRequestStream = $inputWebRequest.GetRequestStream()
$inputRequestStream.Close()
[System.Net.WebResponse]$inputResponse = $inputWebRequest.GetResponse()
$inputResponseStream = $inputResponse.GetResponseStream()
$inputResponseStreamReader = New-Object System.IO.StreamReader -ArgumentList $inputResponseStream
$inputResponse
#this is the cookie container for subsequent requests: $cookieContainer

Sample Output

See http/curl output.

See also

You must to post a comment.
Last modified
23:17, 16 May 2013

Tags

Classifications

This page has no classifications.

Announcements

None


© 2006-2014 RightScale, Inc. All rights reserved.
RightScale is a registered trademark of RightScale, Inc. All other products and services may be trademarks or servicemarks of their respective owners.