Update (PUT/MERGE) RunbookVersions
Update using the HTTP PUT/MERGE operation.
Code Examples
Request
Method | Request URI | HTTP Version |
---|---|---|
MERGE |
HTTPS://<HOST>:<PORT>/00000000-0000-0000-0000-000000000000/ RunbookVersions(guid'<GUID>') |
HTTP/1.1 |
Request URI Parameters
URI Parameter | Description |
---|---|
NAME |
Required. The unique identifier value (RunbookID) for a RunbookVersion entity. |
Request URI Example
Example URI |
---|
POST https://sma-server:9090/00000000-0000-0000-0000-000000000000/Runbooks(guid'ba12b433-342e-4c15-88a1-942020c7a92e')/Edit HTTP/1.1 MERGE https://sma-server:9090/00000000-0000-0000-0000-000000000000/Runbooks(guid'ba12b433-342e-4c15-88a1-942020c7a92e') HTTP/1.1 |
Request Headers
For more information about the common request headers used by this operation, see Standard Service Management Automation POST/GET/PUT/DELETE Headers.
Request Body
The POST (Edit) request operation has no response body.
The MERGE request body.
<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://www.w3.org/2005/Atom" xmlns:d="https://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="https://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<id>https://sma-server:9090/00000000-0000-0000-0000-000000000000/Runbooks(guid'ba12b433-342e-4c15-88a1-942020c7a92e')</id>
<category term="Orchestrator.ResourceModel.Runbook" scheme="https://schemas.microsoft.com/ado/2007/08/dataservices/scheme" />
<title />
<updated>2014-04-21T16:16:15Z</updated>
<author>
<name />
</author>
<content type="application/xml">
<m:properties>
<d:CreationTime m:type="Edm.DateTime">2014-04-03T15:45:24.247</d:CreationTime>
<d:Description>Test runbook, long running to enable pause, stop, etc ...</d:Description>
<d:DraftRunbookVersionID m:type="Edm.Guid">3f769b5a-0164-4536-bd9a-ee15915f2877</d:DraftRunbookVersionID>
<d:IsApiOnly m:type="Edm.Boolean">false</d:IsApiOnly>
<d:IsGlobal m:type="Edm.Boolean">false</d:IsGlobal>
<d:LastModifiedBy m:null="true" />
<d:LastModifiedTime m:type="Edm.DateTime">2014-04-21T16:12:23.933</d:LastModifiedTime>
<d:LogDebug m:type="Edm.Boolean">false</d:LogDebug>
<d:LogProgress m:type="Edm.Boolean">false</d:LogProgress>
<d:LogVerbose m:type="Edm.Boolean">false</d:LogVerbose>
<d:PublishedRunbookVersionID m:type="Edm.Guid">29a0bb1d-9988-41e2-8715-9217ddf62a1e</d:PublishedRunbookVersionID>
<d:RunbookID m:type="Edm.Guid">ba12b433-342e-4c15-88a1-942020c7a92e</d:RunbookID>
<d:RunbookName>Test_Runbook</d:RunbookName>
<d:Tags></d:Tags>
<d:TenantID m:type="Edm.Guid">00000000-0000-0000-0000-000000000000</d:TenantID>
</m:properties>
</content>
</entry>
Response
Response Codes
Response Code | Description |
---|---|
HTTP/1.1 200 OK |
Success. |
HTTP/1.1 204 No Content |
Request fulfilled. |
Response Headers
For more information about the common response headers used by this operation, see Standard Service Management Automation POST/GET/PUT/DELETE Headers.
Response Body
The POST (Edit) operation.
<?xml version="1.0" encoding="utf-8"?>
<d:Edit xmlns:d="https://schemas.microsoft.com/ado/2007/08/dataservices" xmlns:m="https://schemas.microsoft.com/ado/2007/08/dataservices/metadata" m:type="Edm.Guid">3f769b5a-0164-4536-bd9a-ee15915f2877</d:Edit>
The PUT/MERGE operation has no response body.
Code Examples
The following example updates the RunbookVersion for a Runbook using the Edit operation. The DraftRunbookVersionID is updated using the return value of the Edit operation.
namespace CodeSample.Microsoft.SystemCenter.SMA
{
public class SMASamples
{
public static void Main()
{
// Replace this with the name of your SMA web service endpoint.
string serviceEndPoint = "https://sma-server:9090/00000000-0000-0000-0000-000000000000";
// Setup the connection to SMA
OrchestratorApi SMAService = new OrchestratorApi(new Uri(serviceEndPoint));
// Set credentials to the default or to a specific user.
((DataServiceContext)SMAService).Credentials = CredentialCache.DefaultCredentials;
//((DataServiceContext)SMAService).Credentials = new NetworkCredential("user", "pwd", "domain");
try
{
// Identify a specific activity instance to search for.
System.Guid runbookID = new Guid("ba12b433-342e-4c15-88a1-942020c7a92e");
// Query for the specific activity instance identified by runbookID.
var runbook = SMAService.Runbooks.Where(r => r.RunbookID == runbookID).FirstOrDefault();
// If the DraftRunbookVersionID property is NULL, the runbook is in a published state.
// If the DraftRunbookVersionID property contains a GUID, the runbook is in a draft state.
if (runbook.DraftRunbookVersionID == null)
{
// The Runbook is in a published state and can be edited.
// Call the Runbook Edit operation.
Uri editRunbookUri = new Uri(string.Concat(SMAService.Runbooks, string.Format("(guid'{0}')/{1}", runbookID, "Edit")), UriKind.Absolute);
var draftRunbookVersionId = SMAService.Execute<Guid>(editRunbookUri, "POST", true);
// Assign the new RunbookVersionID to the runbook.
runbook.DraftRunbookVersionID = draftRunbookVersionId.Single();
SMAService.UpdateObject(runbook);
SMAService.SaveChanges();
}
else
{
Console.WriteLine("The runbook is not published and can't be edited.");
Console.ReadKey();
};
} catch (Exception ex)
{
throw new ApplicationException("An error occurred during execution.", ex);
}
}
}
}