Skip to content

Commit

Permalink
Added support for the bulk delete packages endpoint. Closes #214
Browse files Browse the repository at this point in the history
  • Loading branch information
droyad committed Dec 21, 2017
1 parent ce0a87a commit 0ccb4b2
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -3784,6 +3784,7 @@ Octopus.Client.Repositories.Async
interface IBuiltInPackageRepositoryRepository
{
Task DeletePackage(Octopus.Client.Model.PackageResource)
Task DeletePackages(IReadOnlyList<PackageResource>)
Task<ResourceCollection<PackageFromBuiltInFeedResource>> LatestPackages(Int32, Int32)
Task<ResourceCollection<PackageFromBuiltInFeedResource>> ListPackages(String, Int32, Int32)
Task<PackageFromBuiltInFeedResource> PushPackage(String, Stream, Boolean)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4197,6 +4197,7 @@ Octopus.Client.Repositories
interface IBuiltInPackageRepositoryRepository
{
void DeletePackage(Octopus.Client.Model.PackageResource)
void DeletePackages(IReadOnlyList<PackageResource>)
Octopus.Client.Model.ResourceCollection<PackageFromBuiltInFeedResource> LatestPackages(Int32, Int32)
Octopus.Client.Model.ResourceCollection<PackageFromBuiltInFeedResource> ListPackages(String, Int32, Int32)
Octopus.Client.Model.PackageFromBuiltInFeedResource PushPackage(String, Stream, Boolean)
Expand Down Expand Up @@ -4651,6 +4652,7 @@ Octopus.Client.Repositories.Async
interface IBuiltInPackageRepositoryRepository
{
Task DeletePackage(Octopus.Client.Model.PackageResource)
Task DeletePackages(IReadOnlyList<PackageResource>)
Task<ResourceCollection<PackageFromBuiltInFeedResource>> LatestPackages(Int32, Int32)
Task<ResourceCollection<PackageFromBuiltInFeedResource>> ListPackages(String, Int32, Int32)
Task<PackageFromBuiltInFeedResource> PushPackage(String, Stream, Boolean)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using Octopus.Client.Model;

Expand All @@ -11,6 +13,7 @@ public interface IBuiltInPackageRepositoryRepository
Task<ResourceCollection<PackageFromBuiltInFeedResource>> ListPackages(string packageId, int skip = 0, int take = 30);
Task<ResourceCollection<PackageFromBuiltInFeedResource>> LatestPackages(int skip = 0, int take = 30);
Task DeletePackage(PackageResource package);
Task DeletePackages(IReadOnlyList<PackageResource> packages);
}

class BuiltInPackageRepositoryRepository : IBuiltInPackageRepositoryRepository
Expand Down Expand Up @@ -44,5 +47,9 @@ public Task DeletePackage(PackageResource package)
{
return client.Delete(client.RootDocument.Link("Packages"), new { id = package.Id });
}

public Task DeletePackages(IReadOnlyList<PackageResource> packages)
=> client.Delete(client.RootDocument.Link("PackagesBulk"), new { ids = packages.Select(p => p.Id).ToArray() });

}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Octopus.Client.Model;

namespace Octopus.Client.Repositories
Expand All @@ -10,8 +12,9 @@ public interface IBuiltInPackageRepositoryRepository
ResourceCollection<PackageFromBuiltInFeedResource> ListPackages(string packageId, int skip = 0, int take = 30);
ResourceCollection<PackageFromBuiltInFeedResource> LatestPackages(int skip = 0, int take = 30);
void DeletePackage(PackageResource package);
void DeletePackages(IReadOnlyList<PackageResource> packages);
}

class BuiltInPackageRepositoryRepository : IBuiltInPackageRepositoryRepository
{
readonly IOctopusClient client;
Expand Down Expand Up @@ -43,5 +46,8 @@ public void DeletePackage(PackageResource package)
{
client.Delete(client.RootDocument.Link("Packages"), new { id = package.Id });
}

public void DeletePackages(IReadOnlyList<PackageResource> packages)
=> client.Delete(client.RootDocument.Link("PackagesBulk"), new { ids = packages.Select(p => p.Id).ToArray() });
}
}

0 comments on commit 0ccb4b2

Please sign in to comment.