/// <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);
        }
        protected override void ProcessRecord()
        {
            var queries = new Dictionary <string, string>();

            if (StartTime.HasValue)
            {
                queries.Add("startTimeUsecs", StartTime.ToString());
            }

            if (EndTime.HasValue)
            {
                queries.Add("endTimeUsecs", EndTime.ToString());
            }

            if (Search != null)
            {
                queries.Add("search", Search);
            }

            if (FolderOnly != null && FolderOnly.HasValue)
            {
                queries.Add("folderOnly", FolderOnly.ToString());
            }

            if (Environments != null && Environments.Any())
            {
                queries.Add("environments", string.Join(",", Environments));
            }

            if (JobIds != null && JobIds.Any())
            {
                queries.Add("jobIds", string.Join(",", JobIds));
            }

            if (SourceIds != null && SourceIds.Any())
            {
                queries.Add("sourceIds", string.Join(",", SourceIds));
            }

            if (RegisteredSourceIds != null && RegisteredSourceIds.Any())
            {
                queries.Add("registeredSourceIds", string.Join(",", RegisteredSourceIds));
            }

            if (StorageDomainIds != null && StorageDomainIds.Any())
            {
                queries.Add("viewBoxIds", string.Join(",", StorageDomainIds));
            }

            var queryString = string.Empty;

            if (queries.Any())
            {
                queryString = "?" + string.Join("&", queries.Select(q => $"{q.Key}={q.Value}"));
            }

            var url    = $"/public/restore/files{queryString}";
            var result = Session.ApiClient.Get <FileSearchResults>(url);

            WriteObject(result.Files, true);
        }
        protected override void ProcessRecord()
        {
            var queries = new Dictionary <string, string>();

            if (StartTime.HasValue)
            {
                if (false == IsValidTime(StartTime))
                {
                    WriteObject("Invalid start time : " + StartTime.ToString());
                    return;
                }
                queries.Add("startTimeUsecs", StartTime.ToString());
            }

            if (EndTime.HasValue)
            {
                if (false == IsValidTime(EndTime))
                {
                    WriteObject("Invalid end time : " + EndTime.ToString());
                    return;
                }
                queries.Add("endTimeUsecs", EndTime.ToString());
            }

            if (Search != null)
            {
                queries.Add("search", Search);
            }

            if (FolderOnly != null && FolderOnly.HasValue)
            {
                queries.Add("folderOnly", FolderOnly.ToString());
            }

            if (Environments != null && Environments.Any())
            {
                List <string> envs = Environments.ToList().ConvertAll <string>(x => x.ToString().First().ToString().ToLower() + x.ToString().Substring(1));
                queries.Add("environments", string.Join(",", envs));
            }

            if (JobIds != null && JobIds.Any())
            {
                queries.Add("jobIds", string.Join(",", JobIds));
            }

            if (SourceIds != null && SourceIds.Any())
            {
                queries.Add("sourceIds", string.Join(",", SourceIds));
            }

            if (RegisteredSourceIds != null && RegisteredSourceIds.Any())
            {
                queries.Add("registeredSourceIds", string.Join(",", RegisteredSourceIds));
            }

            if (StorageDomainIds != null && StorageDomainIds.Any())
            {
                queries.Add("viewBoxIds", string.Join(",", StorageDomainIds));
            }

            var queryString = string.Empty;

            if (queries.Any())
            {
                queryString = "?" + string.Join("&", queries.Select(q => $"{q.Key}={q.Value}"));
            }

            var url    = $"/public/restore/files{queryString}";
            var result = Session.ApiClient.Get <FileSearchResults>(url);

            WriteObject(result.Files, true);
        }