diff --git a/source/Octopus.Client.Tests/PublicSurfaceAreaFixture.ThePublicSurfaceAreaShouldNotRegress..NETCore.approved.txt b/source/Octopus.Client.Tests/PublicSurfaceAreaFixture.ThePublicSurfaceAreaShouldNotRegress..NETCore.approved.txt index bfb0cc9b..a1f79479 100644 --- a/source/Octopus.Client.Tests/PublicSurfaceAreaFixture.ThePublicSurfaceAreaShouldNotRegress..NETCore.approved.txt +++ b/source/Octopus.Client.Tests/PublicSurfaceAreaFixture.ThePublicSurfaceAreaShouldNotRegress..NETCore.approved.txt @@ -37,6 +37,7 @@ Octopus.Client Task Delete(String, Object, Object) Task Delete(String, CancellationToken) Task Delete(String, Object, Object, CancellationToken) + Task Delete(String, Octopus.Client.TCommand, CancellationToken) Task Do(Octopus.Server.MessageContracts.Base.ICommand, CancellationToken) Octopus.Client.IOctopusSpaceAsyncRepository ForSpace(Octopus.Client.Model.SpaceResource) Octopus.Client.IOctopusSystemAsyncRepository ForSystem() @@ -81,6 +82,7 @@ Octopus.Client Task Update(String, Octopus.Client.TResource, Object) Task Update(String, Octopus.Client.TResource, CancellationToken) Task Update(String, Octopus.Client.TResource, Object, CancellationToken) + Task Update(String, Octopus.Client.TCommand, Object, CancellationToken) } interface IOctopusAsyncRepository Octopus.Client.IOctopusSpaceAsyncRepository @@ -99,6 +101,7 @@ Octopus.Client Octopus.Client.TResource Create(String, Octopus.Client.TResource, Object) Octopus.Client.TResponse Create(String, Octopus.Client.TCommand, Object) void Delete(String, Object, Object) + Octopus.Client.TResponse Delete(String, Octopus.Client.TCommand, Object) Octopus.Client.TResponse Do(Octopus.Server.MessageContracts.Base.ICommand, CancellationToken) Octopus.Client.IOctopusSpaceRepository ForSpace(Octopus.Client.Model.SpaceResource) Octopus.Client.IOctopusSystemRepository ForSystem() @@ -120,6 +123,7 @@ Octopus.Client void SignIn(Octopus.Client.Model.LoginCommand) void SignOut() Octopus.Client.TResource Update(String, Octopus.Client.TResource, Object) + Octopus.Client.TResponse Update(String, Octopus.Client.TCommand, Object) } interface IOctopusClientFactory { @@ -315,6 +319,7 @@ Octopus.Client Task Delete(String, Object, Object) Task Delete(String, CancellationToken) Task Delete(String, Object, Object, CancellationToken) + Task Delete(String, Octopus.Client.TCommand, CancellationToken) void Dispose() Task Do(Octopus.Server.MessageContracts.Base.ICommand, CancellationToken) Octopus.Client.IOctopusSpaceAsyncRepository ForSpace(Octopus.Client.Model.SpaceResource) @@ -360,6 +365,7 @@ Octopus.Client Task Update(String, Octopus.Client.TResource, Object) Task Update(String, Octopus.Client.TResource, CancellationToken) Task Update(String, Octopus.Client.TResource, Object, CancellationToken) + Task Update(String, Octopus.Client.TCommand, Object, CancellationToken) } class OctopusAsyncRepository Octopus.Client.IOctopusAsyncRepository @@ -457,6 +463,7 @@ Octopus.Client Octopus.Client.TResource Create(String, Octopus.Client.TResource, Object) Octopus.Client.TResponse Create(String, Octopus.Client.TCommand, Object) void Delete(String, Object, Object) + Octopus.Client.TResponse Delete(String, Octopus.Client.TCommand, Object) void Dispose() Octopus.Client.TResponse Do(Octopus.Server.MessageContracts.Base.ICommand, CancellationToken) Octopus.Client.IOctopusSpaceRepository ForSpace(Octopus.Client.Model.SpaceResource) @@ -480,6 +487,7 @@ Octopus.Client void SignIn(Octopus.Client.Model.LoginCommand) void SignOut() Octopus.Client.TResource Update(String, Octopus.Client.TResource, Object) + Octopus.Client.TResponse Update(String, Octopus.Client.TCommand, Object) } class OctopusClientFactory Octopus.Client.IOctopusClientFactory @@ -4193,6 +4201,7 @@ Octopus.Client.Model static Octopus.Client.Model.Permission DefectResolve static Octopus.Client.Model.Permission DeploymentCreate static Octopus.Client.Model.Permission DeploymentDelete + static Octopus.Client.Model.Permission DeploymentFreezeAdminister static Octopus.Client.Model.Permission DeploymentView static Octopus.Client.Model.Permission EnvironmentCreate static Octopus.Client.Model.Permission EnvironmentDelete @@ -6393,10 +6402,37 @@ Octopus.Client.Model.DeploymentFreezes Dictionary ProjectEnvironmentScope { get; set; } DateTimeOffset Start { get; set; } } + class DeleteDeploymentFreezeCommand + { + .ctor() + String Id { get; set; } + } + class DeleteDeploymentFreezeResponse + { + .ctor() + } abstract class DeploymentFreezeClientExtensions { static Octopus.Client.Model.DeploymentFreezes.CreateDeploymentFreezeResponse Create(Octopus.Client.IOctopusClient, Octopus.Client.Model.DeploymentFreezes.CreateDeploymentFreezeCommand) } + class ModifyDeploymentFreezeCommand + { + .ctor() + DateTimeOffset End { get; set; } + String Id { get; set; } + String Name { get; set; } + Dictionary ProjectEnvironmentScope { get; set; } + DateTimeOffset Start { get; set; } + } + class ModifyDeploymentFreezeResponse + { + .ctor() + DateTimeOffset End { get; set; } + String Id { get; set; } + String Name { get; set; } + Dictionary ProjectEnvironmentScope { get; set; } + DateTimeOffset Start { get; set; } + } } Octopus.Client.Model.DeploymentProcess { @@ -7503,6 +7539,8 @@ Octopus.Client.Repositories { .ctor(Octopus.Client.IOctopusClient) Octopus.Client.Model.DeploymentFreezes.CreateDeploymentFreezeResponse Create(Octopus.Client.Model.DeploymentFreezes.CreateDeploymentFreezeCommand) + Octopus.Client.Model.DeploymentFreezes.DeleteDeploymentFreezeResponse Delete(Octopus.Client.Model.DeploymentFreezes.DeleteDeploymentFreezeCommand) + Octopus.Client.Model.DeploymentFreezes.ModifyDeploymentFreezeResponse Modify(Octopus.Client.Model.DeploymentFreezes.ModifyDeploymentFreezeCommand) } interface IAccountRepository Octopus.Client.Repositories.IResourceRepository @@ -7662,6 +7700,8 @@ Octopus.Client.Repositories interface IDeploymentFreezeRepository { Octopus.Client.Model.DeploymentFreezes.CreateDeploymentFreezeResponse Create(Octopus.Client.Model.DeploymentFreezes.CreateDeploymentFreezeCommand) + Octopus.Client.Model.DeploymentFreezes.DeleteDeploymentFreezeResponse Delete(Octopus.Client.Model.DeploymentFreezes.DeleteDeploymentFreezeCommand) + Octopus.Client.Model.DeploymentFreezes.ModifyDeploymentFreezeResponse Modify(Octopus.Client.Model.DeploymentFreezes.ModifyDeploymentFreezeCommand) } interface IDeploymentProcessRepository Octopus.Client.Repositories.IGet @@ -8239,6 +8279,8 @@ Octopus.Client.Repositories.Async { .ctor(Octopus.Client.IOctopusAsyncClient) Task Create(Octopus.Client.Model.DeploymentFreezes.CreateDeploymentFreezeCommand, CancellationToken) + Task Delete(Octopus.Client.Model.DeploymentFreezes.DeleteDeploymentFreezeCommand, CancellationToken) + Task Modify(Octopus.Client.Model.DeploymentFreezes.ModifyDeploymentFreezeCommand, CancellationToken) } interface IAccountRepository Octopus.Client.Repositories.Async.IResourceRepository @@ -8403,6 +8445,8 @@ Octopus.Client.Repositories.Async interface IDeploymentFreezeRepository { Task Create(Octopus.Client.Model.DeploymentFreezes.CreateDeploymentFreezeCommand, CancellationToken) + Task Delete(Octopus.Client.Model.DeploymentFreezes.DeleteDeploymentFreezeCommand, CancellationToken) + Task Modify(Octopus.Client.Model.DeploymentFreezes.ModifyDeploymentFreezeCommand, CancellationToken) } interface IDeploymentProcessRepository Octopus.Client.Repositories.Async.IGet diff --git a/source/Octopus.Client.Tests/PublicSurfaceAreaFixture.ThePublicSurfaceAreaShouldNotRegress..NETFramework.approved.txt b/source/Octopus.Client.Tests/PublicSurfaceAreaFixture.ThePublicSurfaceAreaShouldNotRegress..NETFramework.approved.txt index e73f0e44..6d52f3fe 100644 --- a/source/Octopus.Client.Tests/PublicSurfaceAreaFixture.ThePublicSurfaceAreaShouldNotRegress..NETFramework.approved.txt +++ b/source/Octopus.Client.Tests/PublicSurfaceAreaFixture.ThePublicSurfaceAreaShouldNotRegress..NETFramework.approved.txt @@ -37,6 +37,7 @@ Octopus.Client Task Delete(String, Object, Object) Task Delete(String, CancellationToken) Task Delete(String, Object, Object, CancellationToken) + Task Delete(String, Octopus.Client.TCommand, CancellationToken) Task Do(Octopus.Server.MessageContracts.Base.ICommand, CancellationToken) Octopus.Client.IOctopusSpaceAsyncRepository ForSpace(Octopus.Client.Model.SpaceResource) Octopus.Client.IOctopusSystemAsyncRepository ForSystem() @@ -81,6 +82,7 @@ Octopus.Client Task Update(String, Octopus.Client.TResource, Object) Task Update(String, Octopus.Client.TResource, CancellationToken) Task Update(String, Octopus.Client.TResource, Object, CancellationToken) + Task Update(String, Octopus.Client.TCommand, Object, CancellationToken) } interface IOctopusAsyncRepository Octopus.Client.IOctopusSpaceAsyncRepository @@ -99,6 +101,7 @@ Octopus.Client Octopus.Client.TResource Create(String, Octopus.Client.TResource, Object) Octopus.Client.TResponse Create(String, Octopus.Client.TCommand, Object) void Delete(String, Object, Object) + Octopus.Client.TResponse Delete(String, Octopus.Client.TCommand, Object) Octopus.Client.TResponse Do(Octopus.Server.MessageContracts.Base.ICommand, CancellationToken) Octopus.Client.IOctopusSpaceRepository ForSpace(Octopus.Client.Model.SpaceResource) Octopus.Client.IOctopusSystemRepository ForSystem() @@ -120,6 +123,7 @@ Octopus.Client void SignIn(Octopus.Client.Model.LoginCommand) void SignOut() Octopus.Client.TResource Update(String, Octopus.Client.TResource, Object) + Octopus.Client.TResponse Update(String, Octopus.Client.TCommand, Object) } interface IOctopusClientFactory { @@ -315,6 +319,7 @@ Octopus.Client Task Delete(String, Object, Object) Task Delete(String, CancellationToken) Task Delete(String, Object, Object, CancellationToken) + Task Delete(String, Octopus.Client.TCommand, CancellationToken) void Dispose() Task Do(Octopus.Server.MessageContracts.Base.ICommand, CancellationToken) Octopus.Client.IOctopusSpaceAsyncRepository ForSpace(Octopus.Client.Model.SpaceResource) @@ -360,6 +365,7 @@ Octopus.Client Task Update(String, Octopus.Client.TResource, Object) Task Update(String, Octopus.Client.TResource, CancellationToken) Task Update(String, Octopus.Client.TResource, Object, CancellationToken) + Task Update(String, Octopus.Client.TCommand, Object, CancellationToken) } class OctopusAsyncRepository Octopus.Client.IOctopusAsyncRepository @@ -457,6 +463,7 @@ Octopus.Client Octopus.Client.TResource Create(String, Octopus.Client.TResource, Object) Octopus.Client.TResponse Create(String, Octopus.Client.TCommand, Object) void Delete(String, Object, Object) + Octopus.Client.TResponse Delete(String, Octopus.Client.TCommand, Object) void Dispose() Octopus.Client.TResponse Do(Octopus.Server.MessageContracts.Base.ICommand, CancellationToken) Octopus.Client.IOctopusSpaceRepository ForSpace(Octopus.Client.Model.SpaceResource) @@ -480,6 +487,7 @@ Octopus.Client void SignIn(Octopus.Client.Model.LoginCommand) void SignOut() Octopus.Client.TResource Update(String, Octopus.Client.TResource, Object) + Octopus.Client.TResponse Update(String, Octopus.Client.TCommand, Object) } class OctopusClientFactory Octopus.Client.IOctopusClientFactory @@ -4213,6 +4221,7 @@ Octopus.Client.Model static Octopus.Client.Model.Permission DefectResolve static Octopus.Client.Model.Permission DeploymentCreate static Octopus.Client.Model.Permission DeploymentDelete + static Octopus.Client.Model.Permission DeploymentFreezeAdminister static Octopus.Client.Model.Permission DeploymentView static Octopus.Client.Model.Permission EnvironmentCreate static Octopus.Client.Model.Permission EnvironmentDelete @@ -6417,10 +6426,37 @@ Octopus.Client.Model.DeploymentFreezes Dictionary ProjectEnvironmentScope { get; set; } DateTimeOffset Start { get; set; } } + class DeleteDeploymentFreezeCommand + { + .ctor() + String Id { get; set; } + } + class DeleteDeploymentFreezeResponse + { + .ctor() + } abstract class DeploymentFreezeClientExtensions { static Octopus.Client.Model.DeploymentFreezes.CreateDeploymentFreezeResponse Create(Octopus.Client.IOctopusClient, Octopus.Client.Model.DeploymentFreezes.CreateDeploymentFreezeCommand) } + class ModifyDeploymentFreezeCommand + { + .ctor() + DateTimeOffset End { get; set; } + String Id { get; set; } + String Name { get; set; } + Dictionary ProjectEnvironmentScope { get; set; } + DateTimeOffset Start { get; set; } + } + class ModifyDeploymentFreezeResponse + { + .ctor() + DateTimeOffset End { get; set; } + String Id { get; set; } + String Name { get; set; } + Dictionary ProjectEnvironmentScope { get; set; } + DateTimeOffset Start { get; set; } + } } Octopus.Client.Model.DeploymentProcess { @@ -7528,6 +7564,8 @@ Octopus.Client.Repositories { .ctor(Octopus.Client.IOctopusClient) Octopus.Client.Model.DeploymentFreezes.CreateDeploymentFreezeResponse Create(Octopus.Client.Model.DeploymentFreezes.CreateDeploymentFreezeCommand) + Octopus.Client.Model.DeploymentFreezes.DeleteDeploymentFreezeResponse Delete(Octopus.Client.Model.DeploymentFreezes.DeleteDeploymentFreezeCommand) + Octopus.Client.Model.DeploymentFreezes.ModifyDeploymentFreezeResponse Modify(Octopus.Client.Model.DeploymentFreezes.ModifyDeploymentFreezeCommand) } interface IAccountRepository Octopus.Client.Repositories.IResourceRepository @@ -7687,6 +7725,8 @@ Octopus.Client.Repositories interface IDeploymentFreezeRepository { Octopus.Client.Model.DeploymentFreezes.CreateDeploymentFreezeResponse Create(Octopus.Client.Model.DeploymentFreezes.CreateDeploymentFreezeCommand) + Octopus.Client.Model.DeploymentFreezes.DeleteDeploymentFreezeResponse Delete(Octopus.Client.Model.DeploymentFreezes.DeleteDeploymentFreezeCommand) + Octopus.Client.Model.DeploymentFreezes.ModifyDeploymentFreezeResponse Modify(Octopus.Client.Model.DeploymentFreezes.ModifyDeploymentFreezeCommand) } interface IDeploymentProcessRepository Octopus.Client.Repositories.IGet @@ -8264,6 +8304,8 @@ Octopus.Client.Repositories.Async { .ctor(Octopus.Client.IOctopusAsyncClient) Task Create(Octopus.Client.Model.DeploymentFreezes.CreateDeploymentFreezeCommand, CancellationToken) + Task Delete(Octopus.Client.Model.DeploymentFreezes.DeleteDeploymentFreezeCommand, CancellationToken) + Task Modify(Octopus.Client.Model.DeploymentFreezes.ModifyDeploymentFreezeCommand, CancellationToken) } interface IAccountRepository Octopus.Client.Repositories.Async.IResourceRepository @@ -8428,6 +8470,8 @@ Octopus.Client.Repositories.Async interface IDeploymentFreezeRepository { Task Create(Octopus.Client.Model.DeploymentFreezes.CreateDeploymentFreezeCommand, CancellationToken) + Task Delete(Octopus.Client.Model.DeploymentFreezes.DeleteDeploymentFreezeCommand, CancellationToken) + Task Modify(Octopus.Client.Model.DeploymentFreezes.ModifyDeploymentFreezeCommand, CancellationToken) } interface IDeploymentProcessRepository Octopus.Client.Repositories.Async.IGet diff --git a/source/Octopus.Server.Client/IOctopusAsyncClient.cs b/source/Octopus.Server.Client/IOctopusAsyncClient.cs index c0cbf9cb..3a1d7e2c 100644 --- a/source/Octopus.Server.Client/IOctopusAsyncClient.cs +++ b/source/Octopus.Server.Client/IOctopusAsyncClient.cs @@ -688,6 +688,7 @@ Task Create(string path, TCommand command, objec [Obsolete("Please use the overload with cancellation token instead.", false)] Task Update(string path, TResource resource, object pathParameters = null); + /// /// Updates the resource at the given URI on the server using the PUT verb, then performs a fresh GET request to reload /// the data. @@ -728,7 +729,26 @@ Task Create(string path, TCommand command, objec /// The request cancellation token. /// The latest copy of the resource from the server. Task Update(string path, TResource resource, object pathParameters, CancellationToken cancellationToken); - + /// + /// Updates the resource at the given URI on the server using the PUT verb, then performs a fresh GET request to reload + /// the data. + /// + /// + /// HTTP 401 or 403: Thrown when the current user's API key was not valid, their + /// account is disabled, or they don't have permission to perform the specified action. + /// + /// + /// If any other error is successfully returned from the server (e.g., a 500 + /// server error). + /// + /// HTTP 400: If there was a problem with the request provided by the user. + /// HTTP 404: If the specified resource does not exist on the server. + /// The path to the resource to update. + /// The command to update the resource. + /// If the path is a URI template, parameters to use for substitution. + /// The request cancellation token. + /// The response from updating the resource. + Task Update(string path, TCommand command, object pathParameters, CancellationToken cancellationToken); /// /// Deletes the resource at the given URI from the server using a the DELETE verb. Deletes in Octopus happen /// asynchronously via a background task @@ -796,6 +816,28 @@ Task Create(string path, TCommand command, objec /// A task resource that provides details about the background task that deletes the specified resource. Task Delete(string path, object pathParameters, object resource, CancellationToken cancellationToken); + /// + /// Deletes the resource at the given URI from the server using a the DELETE verb. Deletes in Octopus happen + /// asynchronously via a background task + /// that is executed by the Octopus Server. The payload returned by delete will be the task that was created on the + /// server. + /// + /// + /// HTTP 401 or 403: Thrown when the current user's API key was not valid, their + /// account is disabled, or they don't have permission to perform the specified action. + /// + /// + /// If any other error is successfully returned from the server (e.g., a 500 + /// server error). + /// + /// HTTP 400: If there was a problem with the request provided by the user. + /// HTTP 404: If the specified resource does not exist on the server. + /// The path to the resource to delete. + /// The command to delete the resource. + /// The request cancellation token. + /// The response from deleting the resource. + Task Delete(string path, TCommand command, CancellationToken cancellationToken); + /// /// Fetches raw content from the resource at the specified path, using the GET verb. /// diff --git a/source/Octopus.Server.Client/IOctopusClient.cs b/source/Octopus.Server.Client/IOctopusClient.cs index 0aaf4f2f..dcdd222f 100644 --- a/source/Octopus.Server.Client/IOctopusClient.cs +++ b/source/Octopus.Server.Client/IOctopusClient.cs @@ -311,6 +311,26 @@ public interface IOctopusClient : IDisposable /// If the path is a URI template, parameters to use for substitution. /// The latest copy of the resource from the server. TResource Update(string path, TResource resource, object pathParameters = null); + + /// + /// Updates the resource at the given URI on the server using the PUT verb, then performs a fresh GET request to reload + /// the data. + /// + /// + /// HTTP 401 or 403: Thrown when the current user's API key was not valid, their + /// account is disabled, or they don't have permission to perform the specified action. + /// + /// + /// If any other error is successfully returned from the server (e.g., a 500 + /// server error). + /// + /// HTTP 400: If there was a problem with the request provided by the user. + /// HTTP 404: If the specified resource does not exist on the server. + /// The path to the resource to update. + /// The command to update the resource. + /// If the path is a URI template, parameters to use for substitution. + /// The response from updating the resource. + TResponse Update(string path, TCommand command, object pathParameters = null); /// /// Deletes the resource at the given URI from the server using a the DELETE verb. Deletes in Octopus happen @@ -333,6 +353,25 @@ public interface IOctopusClient : IDisposable /// An optional resource to pass as the body of the request. /// A task resource that provides details about the background task that deletes the specified resource. void Delete(string path, object pathParameters = null, object resource = null); + + /// + /// Deletes the resource at the given URI from the server using a the DELETE verb. + /// + /// + /// HTTP 401 or 403: Thrown when the current user's API key was not valid, their + /// account is disabled, or they don't have permission to perform the specified action. + /// + /// + /// If any other error is successfully returned from the server (e.g., a 500 + /// server error). + /// + /// HTTP 400: If there was a problem with the request provided by the user. + /// HTTP 404: If the specified resource does not exist on the server. + /// The path to the resource to delete. + /// If the path is a URI template, parameters to use for substitution. + /// The command to delete the resource. + /// The response from deleting the resource. + TResponse Delete(string path, TCommand command, object pathParameters = null); /// /// Fetches raw content from the resource at the specified path, using the GET verb. diff --git a/source/Octopus.Server.Client/Model/DeploymentFreezes/DeleteDeploymentFreezeCommand.cs b/source/Octopus.Server.Client/Model/DeploymentFreezes/DeleteDeploymentFreezeCommand.cs new file mode 100644 index 00000000..392d573c --- /dev/null +++ b/source/Octopus.Server.Client/Model/DeploymentFreezes/DeleteDeploymentFreezeCommand.cs @@ -0,0 +1,8 @@ +using System.ComponentModel.DataAnnotations; + +namespace Octopus.Client.Model.DeploymentFreezes; + +public class DeleteDeploymentFreezeCommand +{ + [Required] public string Id { get; set; } +} \ No newline at end of file diff --git a/source/Octopus.Server.Client/Model/DeploymentFreezes/DeleteDeploymentFreezeResponse.cs b/source/Octopus.Server.Client/Model/DeploymentFreezes/DeleteDeploymentFreezeResponse.cs new file mode 100644 index 00000000..7a82c8aa --- /dev/null +++ b/source/Octopus.Server.Client/Model/DeploymentFreezes/DeleteDeploymentFreezeResponse.cs @@ -0,0 +1,6 @@ +namespace Octopus.Client.Model.DeploymentFreezes; + +public class DeleteDeploymentFreezeResponse +{ + +} \ No newline at end of file diff --git a/source/Octopus.Server.Client/Model/DeploymentFreezes/ModifyDeploymentFreezeCommand.cs b/source/Octopus.Server.Client/Model/DeploymentFreezes/ModifyDeploymentFreezeCommand.cs new file mode 100644 index 00000000..d779678a --- /dev/null +++ b/source/Octopus.Server.Client/Model/DeploymentFreezes/ModifyDeploymentFreezeCommand.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; + +namespace Octopus.Client.Model.DeploymentFreezes; + +public class ModifyDeploymentFreezeCommand +{ + [Required] public string Id { get; set; } + + [Required(ErrorMessage = "Please provide a display name.")] + [MinLength(1)] + [MaxLength(200)] + public string Name { get; set; } + + [Required(ErrorMessage = "Please provide a start time.")] + public DateTimeOffset Start { get; set; } + + [Required(ErrorMessage = "Please provide an end time.")] + public DateTimeOffset End { get; set; } + + [Required] public Dictionary ProjectEnvironmentScope { get; set; } +} \ No newline at end of file diff --git a/source/Octopus.Server.Client/Model/DeploymentFreezes/ModifyDeploymentFreezeResponse.cs b/source/Octopus.Server.Client/Model/DeploymentFreezes/ModifyDeploymentFreezeResponse.cs new file mode 100644 index 00000000..38157598 --- /dev/null +++ b/source/Octopus.Server.Client/Model/DeploymentFreezes/ModifyDeploymentFreezeResponse.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; + +namespace Octopus.Client.Model.DeploymentFreezes; + +public class ModifyDeploymentFreezeResponse +{ + [Required] public string Id { get; set; } + + [Required] public string Name { get; set; } + + [Required] public DateTimeOffset Start { get; set; } + + [Required] public DateTimeOffset End { get; set; } + + [Required] public Dictionary ProjectEnvironmentScope { get; set; } +} \ No newline at end of file diff --git a/source/Octopus.Server.Client/Model/Permission.cs b/source/Octopus.Server.Client/Model/Permission.cs index c0194d5c..e4227e85 100644 --- a/source/Octopus.Server.Client/Model/Permission.cs +++ b/source/Octopus.Server.Client/Model/Permission.cs @@ -270,6 +270,7 @@ public class Permission : IEquatable [Description("Delete Insights reports")] public static readonly Permission InsightsReportDelete = new("InsightsReportDelete"); + [Description("Create, update, delete and override deployment freezes")] public static readonly Permission DeploymentFreezeAdminister = new("DeploymentFreezeAdminister"); public Permission(string id) { Id = id; diff --git a/source/Octopus.Server.Client/OctopusAsyncClient.cs b/source/Octopus.Server.Client/OctopusAsyncClient.cs index 2d453b11..64e2773f 100644 --- a/source/Octopus.Server.Client/OctopusAsyncClient.cs +++ b/source/Octopus.Server.Client/OctopusAsyncClient.cs @@ -525,6 +525,14 @@ public Task Delete(string path, object pathParameters, object resource, Cancella return DispatchRequest(new OctopusRequest("DELETE", uri, resource), true, cancellationToken); } + /// + public async Task Delete(string path, TCommand command, CancellationToken cancellationToken) + { + var uri = QualifyUri(path); + + var response = await DispatchRequest(new OctopusRequest("DELETE", uri, command), true, cancellationToken); + return response.ResponseResource; + } /// public async Task Update(string path, TResource resource, object pathParameters = null) { @@ -547,6 +555,14 @@ public async Task Update(string path, TResource resource, return result; } + + /// + public async Task Update(string path, TCommand resource, object pathParameters, CancellationToken cancellationToken) + { + var uri = QualifyUri(path, pathParameters); + var response = await DispatchRequest(new OctopusRequest("PUT", uri, requestResource: resource), true, cancellationToken).ConfigureAwait(false); + return response.ResponseResource; + } /// public async Task GetContent(string path, object pathParameters = null) diff --git a/source/Octopus.Server.Client/OctopusClient.cs b/source/Octopus.Server.Client/OctopusClient.cs index bf335629..8f61c82b 100644 --- a/source/Octopus.Server.Client/OctopusClient.cs +++ b/source/Octopus.Server.Client/OctopusClient.cs @@ -386,6 +386,15 @@ public void Delete(string path, object pathParameters = null, object resource = DispatchRequest(new OctopusRequest("DELETE", uri, resource), true); } + + /// + public TResponse Delete(string path, TCommand command, object pathParameters = null) + { + var uri = QualifyUri(path, pathParameters); + + var response = DispatchRequest(new OctopusRequest("DELETE", uri, command), true); + return response.ResponseResource; + } /// /// Updates the resource at the given URI on the server using the PUT verb, then performs a fresh GET request to reload @@ -407,6 +416,15 @@ public TResource Update(string path, TResource resource, object pathP var getUrl = resourceSelfLinkExtractor.GetSelfUrlOrNull(response.ResponseResource) ?? path; return Get(getUrl); } + + /// + public TResponse Update(string path, TCommand command, object pathParameters = null) + { + var uri = QualifyUri(path, pathParameters); + + var response = DispatchRequest(new OctopusRequest("PUT", uri, requestResource: command), readResponse: true); + return response.ResponseResource; + } /// /// Fetches raw content from the resource at the specified path, using the GET verb. diff --git a/source/Octopus.Server.Client/Repositories/Async/DeploymentFreezeRepository.cs b/source/Octopus.Server.Client/Repositories/Async/DeploymentFreezeRepository.cs index cdb20f6b..084ffc0e 100644 --- a/source/Octopus.Server.Client/Repositories/Async/DeploymentFreezeRepository.cs +++ b/source/Octopus.Server.Client/Repositories/Async/DeploymentFreezeRepository.cs @@ -7,6 +7,12 @@ namespace Octopus.Client.Repositories.Async; public interface IDeploymentFreezeRepository { Task Create(CreateDeploymentFreezeCommand command, CancellationToken cancellationToken); + + Task Modify(ModifyDeploymentFreezeCommand command, + CancellationToken cancellationToken); + + Task Delete(DeleteDeploymentFreezeCommand command, + CancellationToken cancellationToken); } public class DeploymentFreezeRepository(IOctopusAsyncClient client) : IDeploymentFreezeRepository @@ -18,4 +24,19 @@ public async Task Create(CreateDeploymentFreezeC var response = await client.Create(link, command, null, cancellationToken); return response; } + + public async Task Modify(ModifyDeploymentFreezeCommand command, CancellationToken cancellationToken) + { + var link = await client.Repository.Link("DeploymentFreezes"); + + return await client.Update(link, command, null, cancellationToken); + } + + public async Task Delete(DeleteDeploymentFreezeCommand command, CancellationToken cancellationToken) + { + var link = await client.Repository.Link("DeploymentFreezes"); + + return await client.Delete(link, command, + cancellationToken); + } } \ No newline at end of file diff --git a/source/Octopus.Server.Client/Repositories/DeploymentFreezeRepository.cs b/source/Octopus.Server.Client/Repositories/DeploymentFreezeRepository.cs index 5737b26e..b94de260 100644 --- a/source/Octopus.Server.Client/Repositories/DeploymentFreezeRepository.cs +++ b/source/Octopus.Server.Client/Repositories/DeploymentFreezeRepository.cs @@ -5,6 +5,8 @@ namespace Octopus.Client.Repositories; public interface IDeploymentFreezeRepository { CreateDeploymentFreezeResponse Create(CreateDeploymentFreezeCommand command); + ModifyDeploymentFreezeResponse Modify(ModifyDeploymentFreezeCommand command); + DeleteDeploymentFreezeResponse Delete(DeleteDeploymentFreezeCommand command); } public class DeploymentFreezeRepository(IOctopusClient client) : IDeploymentFreezeRepository @@ -15,4 +17,18 @@ public CreateDeploymentFreezeResponse Create(CreateDeploymentFreezeCommand comma return client.Create(link, command); } + + public ModifyDeploymentFreezeResponse Modify(ModifyDeploymentFreezeCommand command) + { + var link = client.Repository.Link("DeploymentFreezes"); + + return client.Update(link, command); + } + + public DeleteDeploymentFreezeResponse Delete(DeleteDeploymentFreezeCommand command) + { + var link = client.Repository.Link("DeploymentFreezes"); + + return client.Delete(link, command); + } } \ No newline at end of file