-
Notifications
You must be signed in to change notification settings - Fork 120
/
Copy pathDeploymentRepository.cs
60 lines (50 loc) · 2.92 KB
/
DeploymentRepository.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
using System;
using Octopus.Client.Model;
namespace Octopus.Client.Repositories
{
public interface IDeploymentRepository : IGet<DeploymentResource>, ICreate<DeploymentResource>, IPaginate<DeploymentResource>, IDelete<DeploymentResource>
{
TaskResource GetTask(DeploymentResource resource);
/// <summary>
///
/// </summary>
/// <param name="projects"></param>
/// <param name="environments"></param>
/// <param name="skip">Number of records to skip</param>
/// <param name="take">Number of records to take (First supported in Server 3.14.159)</param>
/// <returns></returns>
ResourceCollection<DeploymentResource> FindBy(string[] projects, string[] environments, int skip = 0, int? take = null);
[Obsolete("This method is not a find all, it still requires paging. So it has been renamed to `FindBy`")]
ResourceCollection<DeploymentResource> FindAll(string[] projects, string[] environments, int skip = 0, int? take = null);
void Paginate(string[] projects, string[] environments, Func<ResourceCollection<DeploymentResource>, bool> getNextPage);
void Paginate(string[] projects, string[] environments, string[] tenants, Func<ResourceCollection<DeploymentResource>, bool> getNextPage);
}
class DeploymentRepository : BasicRepository<DeploymentResource>, IDeploymentRepository
{
public DeploymentRepository(IOctopusRepository repository)
: base(repository, "Deployments")
{
}
public TaskResource GetTask(DeploymentResource resource)
{
return Client.Get<TaskResource>(resource.Link("Task"));
}
public ResourceCollection<DeploymentResource> FindBy(string[] projects, string[] environments, int skip = 0, int? take = null)
{
return Client.List<DeploymentResource>(Repository.Link("Deployments"), new { skip, take, projects = projects ?? new string[0], environments = environments ?? new string[0] });
}
[Obsolete("This method is not a find all, it still requires paging. So it has been renamed to `FindBy`")]
public ResourceCollection<DeploymentResource> FindAll(string[] projects, string[] environments, int skip = 0, int? take = null)
{
return FindBy(projects, environments, skip, take);
}
public void Paginate(string[] projects, string[] environments, Func<ResourceCollection<DeploymentResource>, bool> getNextPage)
{
Paginate(projects, environments, new string[0], getNextPage);
}
public void Paginate(string[] projects, string[] environments, string[] tenants, Func<ResourceCollection<DeploymentResource>, bool> getNextPage)
{
Client.Paginate(Repository.Link("Deployments"), new { projects = projects ?? new string[0], environments = environments ?? new string[0], tenants = tenants ?? new string[0] }, getNextPage);
}
}
}