using System; using System.Collections.Generic; using System.Net.Http.Headers; using System.Threading; using System.Threading.Tasks; using RestEase; using WireMock.Admin.Mappings; using WireMock.Admin.Requests; using WireMock.Admin.Scenarios; using WireMock.Admin.Settings; using WireMock.Types; namespace WireMock.Client; /// /// The RestEase interface which defines all admin commands. /// [BasePath("__admin")] public interface IWireMockAdminApi { /// /// Authentication header /// [Header("Authorization")] AuthenticationHeaderValue Authorization { get; set; } /// /// Get the settings. /// /// SettingsModel [Get("settings")] Task GetSettingsAsync(); /// /// Update the settings. /// /// SettingsModel /// The optional cancellationToken. [Put("settings")] [Header("Content-Type", "application/json")] Task PutSettingsAsync([Body] SettingsModel settings, CancellationToken cancellationToken = default); /// /// Update the settings /// /// SettingsModel /// The optional cancellationToken. [Post("settings")] [Header("Content-Type", "application/json")] Task PostSettingsAsync([Body] SettingsModel settings, CancellationToken cancellationToken = default); /// /// Get the mappings. /// /// MappingModels /// The optional cancellationToken. [Get("mappings")] Task> GetMappingsAsync(CancellationToken cancellationToken = default); /// /// Get the C# code from all mappings /// /// C# code /// The , default is Server. /// The optional cancellationToken. [Get("mappings/code")] Task GetMappingsCodeAsync([Query] MappingConverterType mappingConverterType = MappingConverterType.Server, CancellationToken cancellationToken = default); /// /// Add a new mapping. /// /// MappingModel /// The optional cancellationToken. [Post("mappings")] [Header("Content-Type", "application/json")] Task PostMappingAsync([Body] MappingModel mapping, CancellationToken cancellationToken = default); /// /// Add new mappings. /// /// MappingModels /// The optional cancellationToken. [Post("mappings")] [Header("Content-Type", "application/json")] Task PostMappingsAsync([Body] IList mappings, CancellationToken cancellationToken = default); /// /// Delete all mappings. /// /// The optional cancellationToken. [Delete("mappings")] Task DeleteMappingsAsync(CancellationToken cancellationToken = default); /// /// Delete mappings according to GUIDs /// /// MappingModels /// The optional cancellationToken. [Delete("mappings")] [Header("Content-Type", "application/json")] Task DeleteMappingsAsync([Body] IList mappings, CancellationToken cancellationToken = default); /// /// Delete (reset) all mappings. /// /// A value indicating whether to reload the static mappings after the reset. /// The optional cancellationToken. [Post("mappings/reset")] Task ResetMappingsAsync(bool? reloadStaticMappings = false, CancellationToken cancellationToken = default); /// /// Get a mapping based on the guid /// /// The Guid /// MappingModel /// The optional cancellationToken. [Get("mappings/{guid}")] Task GetMappingAsync([Path] Guid guid, CancellationToken cancellationToken = default); /// /// Get the C# code from a mapping based on the guid /// /// The Guid /// The optional mappingConverterType (can be Server or Builder) /// C# code /// The optional cancellationToken. [Get("mappings/code/{guid}")] Task GetMappingCodeAsync([Path] Guid guid, [Query] MappingConverterType mappingConverterType = MappingConverterType.Server, CancellationToken cancellationToken = default); /// /// Update a mapping based on the guid /// /// The Guid /// MappingModel /// The optional cancellationToken. [Put("mappings/{guid}")] [Header("Content-Type", "application/json")] Task PutMappingAsync([Path] Guid guid, [Body] MappingModel mapping, CancellationToken cancellationToken = default); /// /// Delete a mapping based on the guid /// /// The Guid /// The optional cancellationToken. [Delete("mappings/{guid}")] Task DeleteMappingAsync([Path] Guid guid, CancellationToken cancellationToken = default); /// /// Save the mappings /// /// The optional cancellationToken. [Post("mappings/save")] Task SaveMappingAsync(CancellationToken cancellationToken = default); /// /// Get the requests. /// /// LogRequestModels /// The optional cancellationToken. [Get("requests")] Task> GetRequestsAsync(CancellationToken cancellationToken = default); /// /// Delete all requests. /// /// The optional cancellationToken. [Delete("requests")] Task DeleteRequestsAsync(CancellationToken cancellationToken = default); /// /// Delete (reset) all requests. /// /// The optional cancellationToken. [Post("requests/reset")] Task ResetRequestsAsync(CancellationToken cancellationToken = default); /// /// Get a request based on the guid /// /// The Guid /// MappingModel /// The optional cancellationToken. [Get("requests/{guid}")] Task GetRequestAsync([Path] Guid guid, CancellationToken cancellationToken = default); /// /// Delete a request based on the guid /// /// The Guid /// The optional cancellationToken. [Delete("requests/{guid}")] Task DeleteRequestAsync([Path] Guid guid, CancellationToken cancellationToken = default); /// /// Find a request based on the criteria /// /// The RequestModel /// The optional cancellationToken. [Post("requests/find")] [Header("Content-Type", "application/json")] Task> FindRequestsAsync([Body] RequestModel model, CancellationToken cancellationToken = default); /// /// Get all scenarios /// /// The optional cancellationToken. [Get("scenarios")] Task> GetScenariosAsync(CancellationToken cancellationToken = default); /// /// Delete (reset) all scenarios /// /// The optional cancellationToken. [Delete("scenarios")] Task DeleteScenariosAsync(CancellationToken cancellationToken = default); /// /// Delete (reset) all scenarios /// /// The optional cancellationToken. [Post("scenarios")] Task ResetScenariosAsync(CancellationToken cancellationToken = default); /// /// Delete (reset) a specific scenario /// /// Scenario name. /// The optional cancellationToken. [Delete("scenarios/{name}")] [AllowAnyStatusCode] Task DeleteScenarioAsync([Path] string name, CancellationToken cancellationToken = default); /// /// Delete (reset) all scenarios /// /// Scenario name. /// The optional cancellationToken. [Post("scenarios/{name}/reset")] [AllowAnyStatusCode] Task ResetScenarioAsync([Path] string name, CancellationToken cancellationToken = default); /// /// Create a new File /// /// The filename /// The body /// The optional cancellationToken. [Post("files/{filename}")] Task PostFileAsync([Path] string filename, [Body] string body, CancellationToken cancellationToken = default); /// /// Update an existing File /// /// The filename /// The body /// The optional cancellationToken. [Put("files/{filename}")] Task PutFileAsync([Path] string filename, [Body] string body, CancellationToken cancellationToken = default); /// /// Get the content of an existing File /// /// The filename /// The optional cancellationToken. [Get("files/{filename}")] Task GetFileAsync([Path] string filename, CancellationToken cancellationToken = default); /// /// Delete an existing File /// /// The filename /// The optional cancellationToken. [Delete("files/{filename}")] Task DeleteFileAsync([Path] string filename, CancellationToken cancellationToken = default); /// /// Check if a file exists /// /// The filename /// The optional cancellationToken. [Head("files/{filename}")] Task FileExistsAsync([Path] string filename, CancellationToken cancellationToken = default); }