예제 #1
0
        /// <summary>
        /// Kick off asynchronous request.
        /// </summary>
        /// <param name="session">Client session</param>
        /// <param name="req">API command</param>
        /// <returns>Asynchronous task job id.</returns>
        public static string StartAsyncJob(Client session, APIRequest req)
        {
            XDocument resp = session.SendRequest(req);

            XElement jobid = resp.Descendants("jobid").FirstOrDefault();

            if (jobid == null || string.IsNullOrEmpty(jobid.Value))
            {
                throw new CloudStackException("Async command failed to return jobid", req.ToString(), resp);
            }
            return jobid.Value;
        }
예제 #2
0
 /// <summary>
 /// Polls AsyncJob, returns XDocument when job is done.
 /// </summary>
 /// <param name="session">Client connection to CloudStack API</param>
 /// <param name="jobid">Asynchronous job</param>
 /// <returns>Response from async operation.</returns>
 /// <remarks>
 /// Sample result in SampleResponses.QueryAsyncJobResponse
 /// </remarks>
 public static XDocument QueryAsyncJobResult(Client session, string jobid)
 {
     APIRequest req = new SDK.APIRequest("queryAsyncJobResult");
     req.Parameters["jobid"] = jobid;
     return session.SendRequest(req);
 }