public static IEnumerable <ProtectionRunInstance> GetProtectionJobRunsByJobId(RestApiClient client, long jobId) { var qb = new QuerystringBuilder(); qb.Add("jobId", jobId); qb.Add("numRuns", 1000); var preparedUrl = $"/public/protectionRuns{qb.Build()}"; var jobRuns = client.Get <IEnumerable <ProtectionRunInstance> >(preparedUrl); if (jobRuns == null || !jobRuns.Any()) { throw new Exception("Protection job runs with matching job id not found."); } return(jobRuns); }
public static ProtectionJob GetProtectionJobById(RestApiClient client, long id) { var qb = new QuerystringBuilder(); qb.Add("ids", id); qb.Add("includeLastRunAndStats", true); var preparedUrl = $"/public/protectionJobs{qb.Build()}"; var jobs = client.Get <IEnumerable <ProtectionJob> >(preparedUrl); if (jobs == null || !jobs.Any()) { throw new Exception("Protection job with matching id not found."); } var job = jobs.FirstOrDefault(i => i.Id.Equals(id)); if (job == null) { throw new Exception("Protection job with matching id not found."); } return(job); }
public static View GetViewByName(RestApiClient client, string name) { var qb = new QuerystringBuilder(); qb.Add("includeInactive", true); var preparedUrl = $"/public/views{qb.Build()}"; var result = client.Get <GetViewsResult>(preparedUrl); if (result == null) { throw new Exception("View with matching name not found."); } var view = result.Views.FirstOrDefault(i => i.Name.Equals(name)); if (view == null) { throw new Exception("View with matching name not found."); } return(view); }