/// <summary> /// Process Record /// </summary> protected override void ProcessRecord() { if (!string.IsNullOrWhiteSpace(Name)) { var job = RestApiCommon.GetProtectionJobByName(Session.ApiClient, Name); Id = (long)job.Id; } if (JobRunId == null) { var job = RestApiCommon.GetProtectionJobById(Session.ApiClient, Id); JobRunId = (long)job.LastRun.BackupRun.JobRunId; } var body = new CancelProtectionJobRunParam { //CopyTaskUid, JobRunId = JobRunId }; var url = $"/public/protectionRuns/cancel/{Id.ToString()}"; Session.ApiClient.Post(url, body); WriteObject("Protection Job Run cancelled."); }
/// <summary> /// Process Record /// </summary> protected override void ProcessRecord() { Model.ProtectionJob currentProtectionjob = null; if (!string.IsNullOrWhiteSpace(Name)) { var job = RestApiCommon.GetProtectionJobByName(Session.ApiClient, Name); Id = (long)job.Id; currentProtectionjob = job; } if (JobRunId == null) { var job = RestApiCommon.GetProtectionJobById(Session.ApiClient, Id); JobRunId = (long)job.LastRun.BackupRun.JobRunId; currentProtectionjob = job; } UniversalId copyTaskUid = null; CopyRun copyRun = null; if (StopArchivalJob) { copyRun = currentProtectionjob.LastRun.CopyRun.Find(x => x.Target.Type == SnapshotTargetSettings.TypeEnum.KArchival); if (null == copyRun) { WriteObject("Could not find the archival task."); return; } } if (StopCloudSpinJob) { copyRun = currentProtectionjob.LastRun.CopyRun.Find(x => x.Target.Type == SnapshotTargetSettings.TypeEnum.KCloudDeploy); if (null == copyRun) { WriteObject("Could not find the cloud deploy task."); return; } } if (StopReplicationJob) { copyRun = currentProtectionjob.LastRun.CopyRun.Find(x => x.Target.Type == SnapshotTargetSettings.TypeEnum.KRemote); if (null == copyRun) { WriteObject("Could not find the replication task."); return; } } object body; if (null != copyRun) { copyTaskUid = copyRun.TaskUid; // When the non-local job is being stopped body = new CancelProtectionJobRunParam { // The copy task uid and job id would be used for Archival, Cloud spin and Remote targets CopyTaskUid = copyTaskUid, }; } else { // When the local job is being stopped body = new CancelProtectionJobRunParam { JobRunId = this.JobRunId }; } var url = $"/public/protectionRuns/cancel/{Id.ToString()}"; Session.ApiClient.Post(url, body); WriteObject("Protection Job Run cancelled."); }