public void Paginate(Func <ResourceCollection <TResource>, bool> getNextPage, string path = null, object pathParameters = null) { var link = ResolveLink(); var parameters = ParameterHelper.CombineParameters(AdditionalQueryParameters, pathParameters); client.Paginate(path ?? link, parameters, getNextPage); }
public static List <ProjectTriggerResource> FindAllProjectTriggers(this IOctopusClient client, ProjectResource project) { var items = new List <ProjectTriggerResource>(); client.Paginate(project.Links["Triggers"], (ResourceCollection <ProjectTriggerResource> page) => { items.AddRange(page.Items); return(true); }); return(items); }
/// <summary> /// Gathers the Events tied to a resource for auditing. /// </summary> /// <param name="client">The Repository this is tacked on to.</param> /// <param name="resourceId">The resource id of the object for events returned.</param> /// <param name="eventCategory">The type of category of events returned [null returns all].</param> /// <returns>Enumerable of EventsResources.</returns> internal static IEnumerable <EventResource> GetResourceEvents(this IOctopusClient client, string resourceId, string eventCategory) { var events = new List <EventResource>(); client.Paginate <EventResource>(string.Format(ResourceStrings.EventRegardingLink, client.RootDocument.Link(ResourceStrings.EventLink), resourceId, eventCategory), new { }, page => { events.AddRange(page.Items); return(true); }); return(events); }
/// <summary> /// Gathers the Interruptions tied to a Task /// </summary> /// <param name="client">The Repository this is tacked on to.</param> /// <param name="resourceId">The resource id to returns interruptions for.</param> /// <param name="pendingOnly">Returns only pending interruptions.</param> /// <returns>Enumerable of InterruptionResources.</returns> internal static IEnumerable <InterruptionResource> GetResourceInterruptions(this IOctopusClient client, string resourceId, bool pendingOnly) { var interruptions = new List <InterruptionResource>(); client.Paginate <InterruptionResource>(string.Format(ResourceStrings.InterruptionRegardingLink, client.RootDocument.Link(ResourceStrings.InterruptionLink), resourceId, pendingOnly.ToString()), new { }, page => { interruptions.AddRange(page.Items); return(true); }); return(interruptions); }
/// <summary> /// Gathers deployments based on release /// </summary> /// <param name="client">The Repository this is tacked on to.</param> /// <param name="release">The release to get deployments of.</param> /// <returns>Enumerable of Deployment Resources.</returns> internal static IEnumerable <DeploymentResource> GetReleaseDeployments(this IOctopusClient client, ReleaseResource release) { List <DeploymentResource> deployments = new List <DeploymentResource>(); client.Paginate <DeploymentResource>(release.Link(ResourceStrings.DeploymentLink), new { }, page => { deployments.AddRange(page.Items); return(true); }); return(deployments); }
/// <summary> /// Gathers the releases Tied to a channel. /// </summary> /// <param name="client">The Repository this is tacked on to.</param> /// <param name="channel">The channel to gather</param> /// <returns>Enumerable of Release Resources.</returns> internal static IEnumerable <ReleaseResource> GetChannelReleases(this IOctopusClient client, ChannelResource channel) { List <ReleaseResource> releases = new List <ReleaseResource>(); client.Paginate <ReleaseResource>(channel.Link(ResourceStrings.ReleaseLink), new { }, page => { releases.AddRange(page.Items); return(true); }); return(releases); }
/// <summary> /// Gets the Channels of the passed Project /// </summary> /// <param name="client">The Repository this is tacked on to.</param> /// <param name="project">The Project to get Channels of</param> /// <returns></returns> internal static IEnumerable <ChannelResource> GetProjectChannels(this IOctopusClient client, ProjectResource project) { List <ChannelResource> channels = new List <ChannelResource>(); client.Paginate <ChannelResource>(project.Link(ResourceStrings.ChannelLink), new { }, page => { channels.AddRange(page.Items); return(true); }); return(channels); }
/// <summary> /// Gathers the List of /// </summary> /// <param name="client">The Repository this is tacked on to.</param> /// <param name="projectIdList">The Project Ids to gather Deployments from.</param> /// <param name="environmentIdList">The Environment Ids to gather Deployments from.</param> /// <returns>Enumerable of Deployment Resources.</returns> internal static IEnumerable <DeploymentResource> GetProjectEnvironmentDeployments(this IOctopusClient client, string[] projectIdList, string[] environmentIdList) { var deployments = new List <DeploymentResource>(); var projectIdStringList = string.Join(",", projectIdList); var environmentIdStringList = string.Join(",", environmentIdList); client.Paginate <DeploymentResource>(string.Format(ResourceStrings.DeploymentsLink, client.RootDocument.Link(ResourceStrings.DeploymentLink), projectIdStringList, environmentIdStringList), new { }, page => { deployments.AddRange(page.Items); return(true); }); return(deployments); }
public ActionTemplateResource FindByName(string name) { ActionTemplateResource template = null; name = (name ?? string.Empty).Trim(); client.Paginate <ActionTemplateResource>(templatesPath, page => { template = page.Items.FirstOrDefault(t => string.Equals((t.Name ?? string.Empty), name, StringComparison.OrdinalIgnoreCase)); // If no matching template was found, then we need to try the next page. return(template == null); }); return(template); }
public void Paginate(Func <ResourceCollection <TResource>, bool> getNextPage, string path = null, object pathParameters = null) { client.Paginate(path ?? client.RootDocument.Link(CollectionLinkName), pathParameters ?? new { }, getNextPage); }