From a5257309c70191ccd7ad7a23fd06b382790ae52b Mon Sep 17 00:00:00 2001 From: Stef Heyenrath Date: Sat, 27 May 2017 10:32:19 +0200 Subject: [PATCH] Added more RestEase interface calls (__admin/mapping) --- .../Client/IFluentMockServerAdmin.cs | 55 ++++++++++++++++++- .../Server/FluentMockServer.Admin.cs | 4 +- 2 files changed, 54 insertions(+), 5 deletions(-) diff --git a/src/WireMock.Net/Client/IFluentMockServerAdmin.cs b/src/WireMock.Net/Client/IFluentMockServerAdmin.cs index 4bb603b9..17135896 100644 --- a/src/WireMock.Net/Client/IFluentMockServerAdmin.cs +++ b/src/WireMock.Net/Client/IFluentMockServerAdmin.cs @@ -27,11 +27,20 @@ namespace WireMock.Client Task GetSettingsAsync(); /// - /// Post the settings + /// Update the settings. + /// + /// SettingsModel + [Put("__admin/settings")] + [Header("Content-Type", "application/json")] + Task PutSettingsAsync([Body] SettingsModel settings); + + /// + /// Update the settings /// /// SettingsModel [Post("__admin/settings")] - Task PostSettingsAsync([Body] SettingsModel settings); + [Header("Content-Type", "application/json")] + Task PostSettingsAsync([Body] SettingsModel settings); /// /// Get the mappings. @@ -41,11 +50,51 @@ namespace WireMock.Client Task> GetMappingsAsync(); /// - /// Get a mappings based on the guid + /// Add a new mapping. + /// + /// MappingModel + [Post("__admin/mappings")] + Task PostMappingAsync([Body] MappingModel mapping); + + /// + /// Delete all mappings. + /// + [Delete("__admin/mappings")] + Task DeleteMappingsAsync(); + + /// + /// Delete (reset) all mappings. + /// + [Post("__admin/mappings/reset")] + Task ResetMappingsAsync(); + + /// + /// Get a mapping based on the guid /// /// The Guid /// MappingModel [Get("__admin/mappings/{guid}")] Task GetMappingAsync([Path] Guid guid); + + /// + /// Update a mapping based on the guid + /// + /// The Guid + /// MappingModel + [Put("__admin/mappings/{guid}")] + Task PutMappingAsync([Path] Guid guid, [Body] MappingModel mapping); + + /// + /// Delete a mapping based on the guid + /// + /// The Guid + [Delete("__admin/mappings/{guid}")] + Task DeleteMappingAsync([Path] Guid guid); + + /// + /// Save the mappings + /// + [Post("__admin/mappings/save")] + Task SaveMappingAsync(); } } \ No newline at end of file diff --git a/src/WireMock.Net/Server/FluentMockServer.Admin.cs b/src/WireMock.Net/Server/FluentMockServer.Admin.cs index 4e5d62c1..1e8c94c6 100644 --- a/src/WireMock.Net/Server/FluentMockServer.Admin.cs +++ b/src/WireMock.Net/Server/FluentMockServer.Admin.cs @@ -86,12 +86,12 @@ namespace WireMock.Server { // __admin/settings Given(Request.Create().WithPath(AdminSettings).UsingGet()).RespondWith(new DynamicResponseProvider(SettingsGet)); - Given(Request.Create().WithPath(AdminSettings).UsingVerb("PUT", "POST")).RespondWith(new DynamicResponseProvider(SettingsUpdate)); + Given(Request.Create().WithPath(AdminSettings).UsingVerb("PUT", "POST").WithHeader("Content-Type", "application/json")).RespondWith(new DynamicResponseProvider(SettingsUpdate)); // __admin/mappings Given(Request.Create().WithPath(AdminMappings).UsingGet()).RespondWith(new DynamicResponseProvider(MappingsGet)); - Given(Request.Create().WithPath(AdminMappings).UsingPost()).RespondWith(new DynamicResponseProvider(MappingsPost)); + Given(Request.Create().WithPath(AdminMappings).UsingPost().WithHeader("Content-Type", "application/json")).RespondWith(new DynamicResponseProvider(MappingsPost)); Given(Request.Create().WithPath(AdminMappings).UsingDelete()).RespondWith(new DynamicResponseProvider(MappingsDelete)); // __admin/mappings/reset