/// <summary> /// Process /// </summary> protected override void ProcessRecord() { if (!string.IsNullOrWhiteSpace(Name)) { var job = RestApiCommon.GetProtectionJobByName(Session.ApiClient, Name); Id = (long)job.Id; } var copyRunTargets = CopyRunTargets != null?CopyRunTargets.ToList() : null; var sourceIDs = SourceIds != null?SourceIds.ToList() : null; var content = new RunProtectionJobParam { CopyRunTargets = copyRunTargets, RunType = RunType, SourceIds = sourceIDs }; // POST public/protectionJobs/run/{id} var preparedUrl = $"/public/protectionJobs/run/{Id.ToString()}"; Session.ApiClient.Post(preparedUrl, content); WriteObject("Protection job was started successfully."); }
protected override void ProcessRecord() { if (string.IsNullOrWhiteSpace(Timezone)) { Timezone = TimeZoneInfoExtensions.GetOlsonTimeZone(); } if (!string.IsNullOrWhiteSpace(PolicyName)) { var policy = RestApiCommon.GetPolicyByName(Session.ApiClient, PolicyName); PolicyId = policy.Id; } if (!string.IsNullOrWhiteSpace(StorageDomainName)) { var domain = RestApiCommon.GetStorageDomainByName(Session.ApiClient, StorageDomainName); StorageDomainId = (long)domain.Id; } var newProtectionJob = new Model.ProtectionJob(name: Name, policyId: PolicyId, viewBoxId: StorageDomainId) { Timezone = Timezone, StartTime = new TimeOfDay(ScheduleStartTime.Hour, ScheduleStartTime.Minute) }; if (ParentSourceId.HasValue) { newProtectionJob.ParentSourceId = ParentSourceId; } if (SourceIds != null && SourceIds.Any()) { newProtectionJob.SourceIds = SourceIds.ToList(); } if (ExcludeSourceIds != null && ExcludeSourceIds.Any()) { newProtectionJob.ExcludeSourceIds = ExcludeSourceIds.ToList(); } if (VmTagIds != null && VmTagIds.Any()) { var vmTagIdsList = VmTagIds.ToList(); newProtectionJob.VmTagIds = new List <List <long> >(); foreach (var vmTagIds in vmTagIdsList) { newProtectionJob.VmTagIds.Add(new List <long> { vmTagIds }); } } if (ExcludeVmTagIds != null && ExcludeVmTagIds.Any()) { var excludeVmTagIdsList = ExcludeVmTagIds.ToList(); newProtectionJob.ExcludeVmTagIds = new List <List <long> >(); foreach (var excludeVmTagIds in excludeVmTagIdsList) { newProtectionJob.ExcludeVmTagIds.Add(new List <long> { excludeVmTagIds }); } } if (!string.IsNullOrWhiteSpace(ViewName)) { newProtectionJob.ViewName = ViewName; } newProtectionJob.Environment = Environment != null ? Environment : Model.ProtectionJob.EnvironmentEnum.KView; if (FullSLATimeInMinutes != null) { newProtectionJob.FullProtectionSlaTimeMins = FullSLATimeInMinutes; } if (IncrementalSLATimeInMinutes != null) { newProtectionJob.IncrementalProtectionSlaTimeMins = IncrementalSLATimeInMinutes; } if (SourceSpecialParameters != null && SourceSpecialParameters.Any()) { newProtectionJob.SourceSpecialParameters = SourceSpecialParameters.ToList(); } var preparedUrl = $"/public/protectionJobs"; var result = Session.ApiClient.Post <Model.ProtectionJob>(preparedUrl, newProtectionJob); WriteObject(result); }