Update WireMock.Org.Abstractions and WireMock.Org.RestClient (#765)

* Update WireMock.Org.Abstractions and WireMock.Org.RestClient

* .

* rename
This commit is contained in:
Stef Heyenrath
2022-07-08 11:02:18 +02:00
committed by GitHub
parent 4d0f96eabe
commit b1032c9dcd
42 changed files with 862 additions and 6736 deletions

View File

@@ -8,7 +8,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="RestEase" Version="1.5.6" /> <PackageReference Include="RestEase" Version="1.5.7" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -204,8 +204,8 @@
<Reference Include="Owin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f0ebd12fd5e55cc5, processorArchitecture=MSIL"> <Reference Include="Owin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f0ebd12fd5e55cc5, processorArchitecture=MSIL">
<HintPath>..\..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath> <HintPath>..\..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
</Reference> </Reference>
<Reference Include="RestEase, Version=1.5.5.0, Culture=neutral, processorArchitecture=MSIL"> <Reference Include="RestEase, Version=1.5.7.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\..\packages\RestEase.1.5.5\lib\net45\RestEase.dll</HintPath> <HintPath>..\..\packages\RestEase.1.5.7\lib\net452\RestEase.dll</HintPath>
</Reference> </Reference>
<Reference Include="SimMetrics.Net, Version=1.0.5.0, Culture=neutral, PublicKeyToken=c58dc06d59f3391b, processorArchitecture=MSIL"> <Reference Include="SimMetrics.Net, Version=1.0.5.0, Culture=neutral, PublicKeyToken=c58dc06d59f3391b, processorArchitecture=MSIL">
<HintPath>..\..\packages\SimMetrics.Net.1.0.5\lib\net45\SimMetrics.Net.dll</HintPath> <HintPath>..\..\packages\SimMetrics.Net.1.0.5\lib\net45\SimMetrics.Net.dll</HintPath>

View File

@@ -59,7 +59,7 @@
<package id="MimeKitLite" version="2.0.7" targetFramework="net461" /> <package id="MimeKitLite" version="2.0.7" targetFramework="net461" />
<package id="Newtonsoft.Json" version="13.0.1" targetFramework="net461" /> <package id="Newtonsoft.Json" version="13.0.1" targetFramework="net461" />
<package id="Owin" version="1.0" targetFramework="net461" /> <package id="Owin" version="1.0" targetFramework="net461" />
<package id="RestEase" version="1.5.5" targetFramework="net461" /> <package id="RestEase" version="1.5.7" targetFramework="net461" />
<package id="SimMetrics.Net" version="1.0.5" targetFramework="net461" /> <package id="SimMetrics.Net" version="1.0.5" targetFramework="net461" />
<package id="System.Buffers" version="4.5.0" targetFramework="net461" /> <package id="System.Buffers" version="4.5.0" targetFramework="net461" />
<package id="System.Collections.Immutable" version="1.5.0" targetFramework="net461" /> <package id="System.Collections.Immutable" version="1.5.0" targetFramework="net461" />

View File

@@ -35,7 +35,7 @@
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" /> <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<!-- See also https://mstack.nl/blog/20210801-source-generators --> <!-- See also https://mstack.nl/blog/20210801-source-generators -->
<PackageReference Include="FluentBuilder" Version="0.4.4"> <PackageReference Include="FluentBuilder" Version="0.4.9">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference> </PackageReference>

View File

@@ -31,7 +31,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" /> <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="RestEase" Version="1.5.6" /> <PackageReference Include="RestEase" Version="1.5.7" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -1,41 +1,40 @@
using JetBrains.Annotations; using JetBrains.Annotations;
using System.Collections.Generic; using System.Collections.Generic;
using WireMock.Types; using WireMock.Types;
namespace WireMock.ResponseBuilders namespace WireMock.ResponseBuilders;
/// <summary>
/// The HeadersResponseBuilder interface.
/// </summary>
public interface IHeadersResponseBuilder : IBodyResponseBuilder
{ {
/// <summary> /// <summary>
/// The HeadersResponseBuilder interface. /// The with header.
/// </summary> /// </summary>
public interface IHeadersResponseBuilder : IBodyResponseBuilder /// <param name="name">The name.</param>
{ /// <param name="values">The values.</param>
/// <summary> /// <returns>The <see cref="IResponseBuilder"/>.</returns>
/// The with header. IResponseBuilder WithHeader(string name, params string[] values);
/// </summary>
/// <param name="name">The name.</param>
/// <param name="values">The values.</param>
/// <returns>The <see cref="IResponseBuilder"/>.</returns>
IResponseBuilder WithHeader([NotNull] string name, params string[] values);
/// <summary> /// <summary>
/// The with headers. /// The with headers.
/// </summary> /// </summary>
/// <param name="headers">The headers.</param> /// <param name="headers">The headers.</param>
/// <returns>The <see cref="IResponseBuilder"/>.</returns> /// <returns>The <see cref="IResponseBuilder"/>.</returns>
IResponseBuilder WithHeaders([NotNull] IDictionary<string, string> headers); IResponseBuilder WithHeaders(IDictionary<string, string> headers);
/// <summary> /// <summary>
/// The with headers. /// The with headers.
/// </summary> /// </summary>
/// <param name="headers">The headers.</param> /// <param name="headers">The headers.</param>
/// <returns>The <see cref="IResponseBuilder"/>.</returns> /// <returns>The <see cref="IResponseBuilder"/>.</returns>
IResponseBuilder WithHeaders([NotNull] IDictionary<string, string[]> headers); IResponseBuilder WithHeaders(IDictionary<string, string[]> headers);
/// <summary> /// <summary>
/// The with headers. /// The with headers.
/// </summary> /// </summary>
/// <param name="headers">The headers.</param> /// <param name="headers">The headers.</param>
/// <returns>The <see cref="IResponseBuilder"/>.</returns> /// <returns>The <see cref="IResponseBuilder"/>.</returns>
IResponseBuilder WithHeaders([NotNull] IDictionary<string, WireMockList<string>> headers); IResponseBuilder WithHeaders(IDictionary<string, WireMockList<string>> headers);
}
} }

View File

@@ -10,299 +10,302 @@ using WireMock.RequestBuilders;
using WireMock.ResponseBuilders; using WireMock.ResponseBuilders;
using WireMock.Util; using WireMock.Util;
using Stef.Validation; using Stef.Validation;
using OrgMapping = WireMock.Org.Abstractions.Mapping; using OrgMappings = WireMock.Org.Abstractions.Mappings;
namespace WireMock.Server namespace WireMock.Server;
public partial class WireMockServer
{ {
public partial class WireMockServer /// <summary>
/// Read WireMock.org mapping json file.
/// </summary>
/// <param name="path">The path to the WireMock.org mapping json file.</param>
[PublicAPI]
public void ReadStaticWireMockOrgMappingAndAddOrUpdate(string path)
{ {
/// <summary> Guard.NotNull(path, nameof(path));
/// Read WireMock.org mapping json file.
/// </summary> string filenameWithoutExtension = Path.GetFileNameWithoutExtension(path);
/// <param name="path">The path to the WireMock.org mapping json file.</param>
[PublicAPI] if (FileHelper.TryReadMappingFileWithRetryAndDelay(_settings.FileSystemHandler, path, out string value))
public void ReadStaticWireMockOrgMappingAndAddOrUpdate(string path)
{ {
Guard.NotNull(path, nameof(path)); var mappings = DeserializeJsonToArray<OrgMappings>(value);
foreach (var mapping in mappings)
string filenameWithoutExtension = Path.GetFileNameWithoutExtension(path);
if (FileHelper.TryReadMappingFileWithRetryAndDelay(_settings.FileSystemHandler, path, out string value))
{ {
var mappings = DeserializeJsonToArray<OrgMapping>(value); if (mappings.Length == 1 && Guid.TryParse(filenameWithoutExtension, out Guid guidFromFilename))
foreach (var mapping in mappings)
{ {
if (mappings.Length == 1 && Guid.TryParse(filenameWithoutExtension, out Guid guidFromFilename)) ConvertWireMockOrgMappingAndRegisterAsRespondProvider(mapping, guidFromFilename, path);
{ }
ConvertWireMockOrgMappingAndRegisterAsRespondProvider(mapping, guidFromFilename, path); else
} {
else ConvertWireMockOrgMappingAndRegisterAsRespondProvider(mapping, null, path);
{
ConvertWireMockOrgMappingAndRegisterAsRespondProvider(mapping, null, path);
}
} }
} }
} }
}
private IResponseMessage MappingsPostWireMockOrg(IRequestMessage requestMessage) private IResponseMessage MappingsPostWireMockOrg(IRequestMessage requestMessage)
{
try
{ {
try var mappingModels = DeserializeRequestMessageToArray<OrgMappings>(requestMessage);
if (mappingModels.Length == 1)
{ {
var mappingModels = DeserializeRequestMessageToArray<OrgMapping>(requestMessage); Guid? guid = ConvertWireMockOrgMappingAndRegisterAsRespondProvider(mappingModels[0]);
if (mappingModels.Length == 1) return ResponseMessageBuilder.Create("Mapping added", 201, guid);
{
Guid? guid = ConvertWireMockOrgMappingAndRegisterAsRespondProvider(mappingModels[0]);
return ResponseMessageBuilder.Create("Mapping added", 201, guid);
}
foreach (var mappingModel in mappingModels)
{
ConvertWireMockOrgMappingAndRegisterAsRespondProvider(mappingModel);
}
return ResponseMessageBuilder.Create("Mappings added", 201);
} }
catch (ArgumentException a)
foreach (var mappingModel in mappingModels)
{ {
_settings.Logger.Error("HttpStatusCode set to 400 {0}", a); ConvertWireMockOrgMappingAndRegisterAsRespondProvider(mappingModel);
return ResponseMessageBuilder.Create(a.Message, 400);
} }
catch (Exception e)
return ResponseMessageBuilder.Create("Mappings added", 201);
}
catch (ArgumentException a)
{
_settings.Logger.Error("HttpStatusCode set to 400 {0}", a);
return ResponseMessageBuilder.Create(a.Message, 400);
}
catch (Exception e)
{
_settings.Logger.Error("HttpStatusCode set to 500 {0}", e);
return ResponseMessageBuilder.Create(e.ToString(), 500);
}
}
private Guid? ConvertWireMockOrgMappingAndRegisterAsRespondProvider(OrgMappings mapping, Guid? guid = null, string? path = null)
{
var requestBuilder = Request.Create();
var request = mapping.Request;
if (request != null)
{
if (request.Url != null)
{ {
_settings.Logger.Error("HttpStatusCode set to 500 {0}", e); requestBuilder = requestBuilder.WithUrl(request.Url);
return ResponseMessageBuilder.Create(e.ToString(), 500); }
else if (request.UrlPattern != null)
{
requestBuilder = requestBuilder.WithUrl(new RegexMatcher(request.UrlPattern));
}
else if (request.UrlPath != null)
{
requestBuilder = requestBuilder.WithPath(request.UrlPath);
}
else if (request.UrlPathPattern != null)
{
requestBuilder = requestBuilder.WithPath(new RegexMatcher(request.UrlPathPattern));
}
if (request.Method != null)
{
requestBuilder = requestBuilder.UsingMethod(request.Method);
}
/*
"headers" : {
"Accept" : {
"contains" : "xml"
}
}
*/
if (request.Headers is JObject headers)
{
ProcessWireMockOrgJObjectAndUseStringMatcher(headers, (key, match) =>
{
requestBuilder = requestBuilder.WithHeader(key, match);
});
}
if (request.Cookies is JObject cookies)
{
ProcessWireMockOrgJObjectAndUseStringMatcher(cookies, (key, match) =>
{
requestBuilder = requestBuilder.WithCookie(key, match);
});
}
/*
"queryParameters" : {
"search_term" : {
"equalTo" : "WireMock"
}
}
*/
if (request.QueryParameters is JObject queryParameters)
{
ProcessWireMockOrgJObjectAndUseStringMatcher(queryParameters, (key, match) =>
{
requestBuilder = requestBuilder.WithParam(key, match);
});
}
/*
"bodyPatterns" : [ {
"equalToJson" : "{ "cityName": "São Paulo", "cityCode": 5001 },
"ignoreArrayOrder" : true,
"ignoreExtraElements" : true
} ]
*/
if (request.BodyPatterns?.Any() == true)
{
var jObjectArray = request.BodyPatterns.Cast<JObject>();
var bodyPattern = jObjectArray.First();
ProcessWireMockOrgJObjectAndUseIMatcher(bodyPattern, match =>
{
requestBuilder = requestBuilder.WithBody(match);
});
} }
} }
private Guid? ConvertWireMockOrgMappingAndRegisterAsRespondProvider(OrgMapping mapping, Guid? guid = null, string path = null) IResponseBuilder responseBuilder = Response.Create();
var response = mapping.Response;
if (response != null)
{ {
var requestBuilder = Request.Create(); responseBuilder = responseBuilder.WithStatusCode(response.Status);
var request = mapping.Request; if (response.Headers is JObject responseHeaders)
if (request != null)
{ {
if (request.Url != null) var rb = responseBuilder;
ProcessWireMockOrgJObjectAndConvertToIDictionary(responseHeaders, headers =>
{ {
requestBuilder = requestBuilder.WithUrl(request.Url); rb = rb.WithHeaders(headers);
} });
else if (request.UrlPattern != null)
{
requestBuilder = requestBuilder.WithUrl(new RegexMatcher(request.UrlPattern));
}
else if (request.UrlPath != null)
{
requestBuilder = requestBuilder.WithPath(request.Url);
}
else if (request.UrlPathPattern != null)
{
requestBuilder = requestBuilder.WithPath(new RegexMatcher(request.UrlPathPattern));
}
if (request.Method != null)
{
requestBuilder = requestBuilder.UsingMethod(request.Method);
}
/*
"headers" : {
"Accept" : {
"contains" : "xml"
}
}
*/
if (request.Headers is JObject headers)
{
ProcessWireMockOrgJObjectAndUseStringMatcher(headers, (key, match) =>
{
requestBuilder = requestBuilder.WithHeader(key, match);
});
}
if (request.Cookies is JObject cookies)
{
ProcessWireMockOrgJObjectAndUseStringMatcher(cookies, (key, match) =>
{
requestBuilder = requestBuilder.WithCookie(key, match);
});
}
/*
"queryParameters" : {
"search_term" : {
"equalTo" : "WireMock"
}
}
*/
if (request.QueryParameters is JObject queryParameters)
{
ProcessWireMockOrgJObjectAndUseStringMatcher(queryParameters, (key, match) =>
{
requestBuilder = requestBuilder.WithParam(key, match);
});
}
/*
"bodyPatterns" : [ {
"equalToJson" : "{ "cityName": "São Paulo", "cityCode": 5001 },
"ignoreArrayOrder" : true,
"ignoreExtraElements" : true
} ]
*/
if (request.BodyPatterns?.Any() == true)
{
var jObjectArray = request.BodyPatterns.Cast<JObject>();
var bodyPattern = jObjectArray.First();
ProcessWireMockOrgJObjectAndUseIMatcher(bodyPattern, (match) =>
{
requestBuilder = requestBuilder.WithBody(match);
});
}
} }
IResponseBuilder responseBuilder = Response.Create(); if (response.Transformers != null)
var response = mapping.Response;
if (response != null)
{ {
responseBuilder = responseBuilder.WithStatusCode(response.Status); responseBuilder = responseBuilder.WithTransformer();
if (response.Headers is JObject responseHeaders)
{
ProcessWireMockOrgJObjectAndConvertToIDictionary(responseHeaders, (headers) =>
{
responseBuilder = responseBuilder.WithHeaders(headers);
});
}
if (response.Transformers != null)
{
responseBuilder = responseBuilder.WithTransformer();
}
if (response.Body != null)
{
responseBuilder = responseBuilder.WithBody(response.Body);
}
if (response.JsonBody != null)
{
responseBuilder = responseBuilder.WithBodyAsJson(response.JsonBody);
}
if (response.Base64Body != null)
{
responseBuilder = responseBuilder.WithBody(Encoding.UTF8.GetString(Convert.FromBase64String(response.Base64Body)));
}
if (response.BodyFileName != null)
{
responseBuilder = responseBuilder.WithBodyFromFile(response.BodyFileName);
}
} }
var respondProvider = Given(requestBuilder); if (response.Body != null)
if (guid != null)
{ {
respondProvider = respondProvider.WithGuid(guid.Value); responseBuilder = responseBuilder.WithBody(response.Body);
}
else if (!string.IsNullOrEmpty(mapping.Uuid))
{
respondProvider = respondProvider.WithGuid(new Guid(mapping.Uuid));
} }
if (mapping.Name != null) if (response.JsonBody != null)
{ {
respondProvider = respondProvider.WithTitle(mapping.Name); responseBuilder = responseBuilder.WithBodyAsJson(response.JsonBody);
} }
if (path != null) if (response.Base64Body != null)
{ {
respondProvider = respondProvider.WithPath(path); responseBuilder = responseBuilder.WithBody(Encoding.UTF8.GetString(Convert.FromBase64String(response.Base64Body)));
} }
respondProvider.RespondWith(responseBuilder); if (response.BodyFileName != null)
return respondProvider.Guid;
}
private void ProcessWireMockOrgJObjectAndConvertToIDictionary(JObject items, Action<IDictionary<string, string>> action)
{
var dict = new Dictionary<string, string>();
foreach (var item in items)
{ {
var key = item.Key; responseBuilder = responseBuilder.WithBodyFromFile(response.BodyFileName);
var valueAsString = item.Value.Value<string>();
dict.Add(key, valueAsString);
}
action(dict);
}
private void ProcessWireMockOrgJObjectAndUseStringMatcher(JObject items, Action<string, IStringMatcher> action)
{
foreach (var item in items)
{
var key = item.Key;
var match = item.Value.First as JProperty;
var valueAsString = match?.Value.Value<string>();
if (string.IsNullOrEmpty(valueAsString))
{
continue;
}
var matcher = ProcessAsStringMatcher(match, valueAsString);
if (matcher != null)
{
action(key, matcher);
}
} }
} }
private void ProcessWireMockOrgJObjectAndUseIMatcher(JObject items, Action<IMatcher> action) var respondProvider = Given(requestBuilder);
if (guid != null)
{ {
if (!(items.First is JProperty firstItem)) respondProvider = respondProvider.WithGuid(guid.Value);
}
else if (!string.IsNullOrEmpty(mapping.Uuid))
{
respondProvider = respondProvider.WithGuid(new Guid(mapping.Uuid));
}
if (mapping.Name != null)
{
respondProvider = respondProvider.WithTitle(mapping.Name);
}
if (path != null)
{
respondProvider = respondProvider.WithPath(path);
}
respondProvider.RespondWith(responseBuilder);
return respondProvider.Guid;
}
private void ProcessWireMockOrgJObjectAndConvertToIDictionary(JObject items, Action<IDictionary<string, string>> action)
{
var dict = new Dictionary<string, string>();
foreach (var item in items)
{
var key = item.Key;
var valueAsString = item.Value?.Value<string>();
if (valueAsString == null)
{
// Skip if the item.Value is null or when the string value is null
continue;
}
dict.Add(key, valueAsString);
}
action(dict);
}
private void ProcessWireMockOrgJObjectAndUseStringMatcher(JObject items, Action<string, IStringMatcher> action)
{
foreach (var item in items)
{
var key = item.Key;
var match = item.Value?.First as JProperty;
if (match == null)
{
continue;
}
var valueAsString = match.Value.Value<string>();
if (string.IsNullOrEmpty(valueAsString))
{
continue;
}
var matcher = ProcessAsStringMatcher(match, valueAsString!);
if (matcher != null)
{
action(key, matcher);
}
}
}
private static void ProcessWireMockOrgJObjectAndUseIMatcher(JObject items, Action<IMatcher> action)
{
if (items.First is not JProperty firstItem)
{
return;
}
IMatcher? matcher;
if (firstItem.Name == "equalToJson")
{
matcher = new JsonMatcher(firstItem.Value);
}
else
{
if ((firstItem.Value as JValue)?.Value is not string valueAsString)
{ {
return; return;
} }
IMatcher matcher; matcher = ProcessAsStringMatcher(firstItem, valueAsString);
if (firstItem.Name == "equalToJson")
{
matcher = new JsonMatcher(firstItem.Value);
}
else
{
var valueAsString = (firstItem.Value as JValue)?.Value as string;
if (valueAsString == null)
{
return;
}
matcher = ProcessAsStringMatcher(firstItem, valueAsString);
}
if (matcher != null)
{
action(matcher);
}
} }
private static IStringMatcher ProcessAsStringMatcher(JProperty match, string valueAsString) if (matcher != null)
{ {
switch (match?.Name) action(matcher);
{
case "contains":
return new WildcardMatcher(valueAsString);
case "matches":
return new RegexMatcher(valueAsString);
case "equalTo":
return new ExactMatcher(valueAsString);
default:
return null;
}
} }
} }
private static IStringMatcher? ProcessAsStringMatcher(JProperty match, string valueAsString)
{
return match.Name switch
{
"contains" => new WildcardMatcher(valueAsString),
"matches" => new RegexMatcher(valueAsString),
"equalTo" => new ExactMatcher(valueAsString),
_ => null,
};
}
} }

View File

@@ -0,0 +1,59 @@
namespace WireMock.Org.Abstractions
{
public class GetAdminMappingsByStubMappingIdResult
{
/// <summary>
/// This stub mapping's unique identifier
/// </summary>
public string Id { get; set; }
/// <summary>
/// Alias for the id
/// </summary>
public string Uuid { get; set; }
/// <summary>
/// The stub mapping's name
/// </summary>
public string Name { get; set; }
public WireMockOrgRequest Request { get; set; }
public WireMockOrgResponse Response { get; set; }
/// <summary>
/// Indicates that the stub mapping should be persisted immediately on create/update/delete and survive resets to default.
/// </summary>
public bool Persistent { get; set; }
/// <summary>
/// This stub mapping's priority relative to others. 1 is highest.
/// </summary>
public int Priority { get; set; }
/// <summary>
/// The name of the scenario that this stub mapping is part of
/// </summary>
public string ScenarioName { get; set; }
/// <summary>
/// The required state of the scenario in order for this stub to be matched.
/// </summary>
public string RequiredScenarioState { get; set; }
/// <summary>
/// The new state for the scenario to be updated to after this stub is served.
/// </summary>
public string NewScenarioState { get; set; }
/// <summary>
/// A map of the names of post serve action extensions to trigger and their parameters.
/// </summary>
public object PostServeActions { get; set; }
/// <summary>
/// Arbitrary metadata to be used for e.g. tagging, documentation. Can also be used to find and remove stubs.
/// </summary>
public object Metadata { get; set; }
}
}

View File

@@ -1,9 +0,0 @@
namespace WireMock.Org.Abstractions
{
public class GetAdminMappingsResponse
{
public Mapping[] Mappings { get; set; }
public Meta Meta { get; set; }
}
}

View File

@@ -0,0 +1,9 @@
namespace WireMock.Org.Abstractions
{
public class GetAdminMappingsResult
{
public Mappings Mappings { get; set; }
public Meta Meta { get; set; }
}
}

View File

@@ -1,7 +1,7 @@
namespace WireMock.Org.Abstractions namespace WireMock.Org.Abstractions
{ {
public class GetAdminRecordingsStatusResponse public class GetAdminRecordingsStatusResult
{ {
public string Status { get; set; } public string Status { get; set; }
} }
} }

View File

@@ -1,7 +0,0 @@
namespace WireMock.Org.Abstractions
{
public class GetAdminRequestsUnmatchedNearMissesResponse
{
public NearMiss[] NearMisses { get; set; }
}
}

View File

@@ -0,0 +1,7 @@
namespace WireMock.Org.Abstractions
{
public class GetAdminRequestsUnmatchedNearMissesResult
{
public NearMisses NearMisses { get; set; }
}
}

View File

@@ -1,7 +0,0 @@
namespace WireMock.Org.Abstractions
{
public class GetAdminScenariosResponse
{
public Scenario[] Scenarios { get; set; }
}
}

View File

@@ -0,0 +1,7 @@
namespace WireMock.Org.Abstractions
{
public class GetAdminScenariosResult
{
public Scenarios Scenarios { get; set; }
}
}

View File

@@ -1,6 +1,6 @@
namespace WireMock.Org.Abstractions namespace WireMock.Org.Abstractions
{ {
public class Mapping public class Mappings
{ {
/// <summary> /// <summary>
/// This stub mapping's unique identifier /// This stub mapping's unique identifier
@@ -17,9 +17,9 @@ namespace WireMock.Org.Abstractions
/// </summary> /// </summary>
public string Name { get; set; } public string Name { get; set; }
public Request Request { get; set; } public MappingsRequest Request { get; set; }
public Response Response { get; set; } public MappingsResponse Response { get; set; }
/// <summary> /// <summary>
/// Indicates that the stub mapping should be persisted immediately on create/update/delete and survive resets to default. /// Indicates that the stub mapping should be persisted immediately on create/update/delete and survive resets to default.
@@ -56,4 +56,4 @@ namespace WireMock.Org.Abstractions
/// </summary> /// </summary>
public object Metadata { get; set; } public object Metadata { get; set; }
} }
} }

View File

@@ -0,0 +1,55 @@
namespace WireMock.Org.Abstractions
{
public class MappingsRequest
{
/// <summary>
/// The HTTP request method e.g. GET
/// </summary>
public string Method { get; set; }
/// <summary>
/// The path and query to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified.
/// </summary>
public string Url { get; set; }
/// <summary>
/// The path to match exactly against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified.
/// </summary>
public string UrlPath { get; set; }
/// <summary>
/// The path regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified.
/// </summary>
public string UrlPathPattern { get; set; }
/// <summary>
/// The path and query regex to match against. Only one of url, urlPattern, urlPath or urlPathPattern may be specified.
/// </summary>
public string UrlPattern { get; set; }
/// <summary>
/// Query parameter patterns to match against in the : { "": "" } form
/// </summary>
public object QueryParameters { get; set; }
/// <summary>
/// Header patterns to match against in the : { "": "" } form
/// </summary>
public object Headers { get; set; }
/// <summary>
/// Pre-emptive basic auth credentials to match against
/// </summary>
public MappingsRequestBasicAuthCredentials BasicAuthCredentials { get; set; }
/// <summary>
/// Cookie patterns to match against in the : { "": "" } form
/// </summary>
public object Cookies { get; set; }
/// <summary>
/// Request body patterns to match against in the : { "": "" } form
/// </summary>
public object[] BodyPatterns { get; set; }
}
}

View File

@@ -0,0 +1,12 @@
namespace WireMock.Org.Abstractions
{
/// <summary>
/// Pre-emptive basic auth credentials to match against
/// </summary>
public class MappingsRequestBasicAuthCredentials
{
public string Password { get; set; }
public string Username { get; set; }
}
}

View File

@@ -0,0 +1,80 @@
namespace WireMock.Org.Abstractions
{
public class MappingsResponse
{
/// <summary>
/// The HTTP status code to be returned
/// </summary>
public int Status { get; set; }
/// <summary>
/// The HTTP status message to be returned
/// </summary>
public string StatusMessage { get; set; }
/// <summary>
/// Map of response headers to send
/// </summary>
public object Headers { get; set; }
/// <summary>
/// Extra request headers to send when proxying to another host.
/// </summary>
public object AdditionalProxyRequestHeaders { get; set; }
/// <summary>
/// The response body as a string. Only one of body, base64Body, jsonBody or bodyFileName may be specified.
/// </summary>
public string Body { get; set; }
/// <summary>
/// The response body as a base64 encoded string (useful for binary content). Only one of body, base64Body, jsonBody or bodyFileName may be specified.
/// </summary>
public string Base64Body { get; set; }
/// <summary>
/// The response body as a JSON object. Only one of body, base64Body, jsonBody or bodyFileName may be specified.
/// </summary>
public object JsonBody { get; set; }
/// <summary>
/// The path to the file containing the response body, relative to the configured file root. Only one of body, base64Body, jsonBody or bodyFileName may be specified.
/// </summary>
public string BodyFileName { get; set; }
/// <summary>
/// The fault to apply (instead of a full, valid response).
/// </summary>
public string Fault { get; set; }
/// <summary>
/// Number of milliseconds to delay be before sending the response.
/// </summary>
public int FixedDelayMilliseconds { get; set; }
/// <summary>
/// The delay distribution. Valid property configuration is either median/sigma/type or lower/type/upper.
/// </summary>
public object DelayDistribution { get; set; }
/// <summary>
/// Read-only flag indicating false if this was the default, unmatched response. Not present otherwise.
/// </summary>
public bool FromConfiguredStub { get; set; }
/// <summary>
/// The base URL of the target to proxy matching requests to.
/// </summary>
public string ProxyBaseUrl { get; set; }
/// <summary>
/// Parameters to apply to response transformers.
/// </summary>
public object TransformerParameters { get; set; }
/// <summary>
/// List of names of transformers to apply to this response.
/// </summary>
public string[] Transformers { get; set; }
}
}

View File

@@ -0,0 +1,16 @@
namespace WireMock.Org.Abstractions
{
/// <summary>
/// The fault to apply (instead of a full, valid response).
/// </summary>
public static class MappingsResponseFaultConstants
{
public const string CONNECTIONRESETBYPEER = "CONNECTION_RESET_BY_PEER";
public const string EMPTYRESPONSE = "EMPTY_RESPONSE";
public const string MALFORMEDRESPONSECHUNK = "MALFORMED_RESPONSE_CHUNK";
public const string RANDOMDATATHENCLOSE = "RANDOM_DATA_THEN_CLOSE";
}
}

View File

@@ -4,4 +4,4 @@ namespace WireMock.Org.Abstractions
{ {
public int Total { get; set; } public int Total { get; set; }
} }
} }

View File

@@ -1,6 +1,6 @@
namespace WireMock.Org.Abstractions namespace WireMock.Org.Abstractions
{ {
public class NearMiss public class NearMisses
{ {
/// <summary> /// <summary>
/// The HTTP request method /// The HTTP request method
@@ -18,12 +18,12 @@ namespace WireMock.Org.Abstractions
public string AbsoluteUrl { get; set; } public string AbsoluteUrl { get; set; }
/// <summary> /// <summary>
/// Header patterns to match against in the &lt;key&gt;: { "&lt;predicate&gt;": "&lt;value&gt;" } form /// Header patterns to match against in the : { "": "" } form
/// </summary> /// </summary>
public object Headers { get; set; } public object Headers { get; set; }
/// <summary> /// <summary>
/// Cookie patterns to match against in the &lt;key&gt;: { "&lt;predicate&gt;": "&lt;value&gt;" } form /// Cookie patterns to match against in the : { "": "" } form
/// </summary> /// </summary>
public object Cookies { get; set; } public object Cookies { get; set; }
@@ -32,4 +32,4 @@ namespace WireMock.Org.Abstractions
/// </summary> /// </summary>
public string Body { get; set; } public string Body { get; set; }
} }
} }

View File

@@ -0,0 +1,9 @@
namespace WireMock.Org.Abstractions
{
public class PostAdminMappingsFindByMetadataResult
{
public Mappings Mappings { get; set; }
public Meta Meta { get; set; }
}
}

View File

@@ -0,0 +1,59 @@
namespace WireMock.Org.Abstractions
{
public class PostAdminMappingsResult
{
/// <summary>
/// This stub mapping's unique identifier
/// </summary>
public string Id { get; set; }
/// <summary>
/// Alias for the id
/// </summary>
public string Uuid { get; set; }
/// <summary>
/// The stub mapping's name
/// </summary>
public string Name { get; set; }
public WireMockOrgRequest Request { get; set; }
public WireMockOrgResponse Response { get; set; }
/// <summary>
/// Indicates that the stub mapping should be persisted immediately on create/update/delete and survive resets to default.
/// </summary>
public bool Persistent { get; set; }
/// <summary>
/// This stub mapping's priority relative to others. 1 is highest.
/// </summary>
public int Priority { get; set; }
/// <summary>
/// The name of the scenario that this stub mapping is part of
/// </summary>
public string ScenarioName { get; set; }
/// <summary>
/// The required state of the scenario in order for this stub to be matched.
/// </summary>
public string RequiredScenarioState { get; set; }
/// <summary>
/// The new state for the scenario to be updated to after this stub is served.
/// </summary>
public string NewScenarioState { get; set; }
/// <summary>
/// A map of the names of post serve action extensions to trigger and their parameters.
/// </summary>
public object PostServeActions { get; set; }
/// <summary>
/// Arbitrary metadata to be used for e.g. tagging, documentation. Can also be used to find and remove stubs.
/// </summary>
public object Metadata { get; set; }
}
}

View File

@@ -0,0 +1,7 @@
namespace WireMock.Org.Abstractions
{
public class PostAdminNearMissesRequestPatternResult
{
public NearMisses NearMisses { get; set; }
}
}

View File

@@ -0,0 +1,7 @@
namespace WireMock.Org.Abstractions
{
public class PostAdminNearMissesRequestResult
{
public NearMisses NearMisses { get; set; }
}
}

View File

@@ -0,0 +1,9 @@
namespace WireMock.Org.Abstractions
{
public class PostAdminRecordingsSnapshotResult
{
public Mappings Mappings { get; set; }
public Meta Meta { get; set; }
}
}

View File

@@ -0,0 +1,9 @@
namespace WireMock.Org.Abstractions
{
public class PostAdminRecordingsStopResult
{
public Mappings Mappings { get; set; }
public Meta Meta { get; set; }
}
}

View File

@@ -1,7 +1,7 @@
namespace WireMock.Org.Abstractions namespace WireMock.Org.Abstractions
{ {
public class PostAdminRequestsCountResponse public class PostAdminRequestsCountResult
{ {
public int Count { get; set; } public int Count { get; set; }
} }
} }

View File

@@ -0,0 +1,59 @@
namespace WireMock.Org.Abstractions
{
public class PutAdminMappingsByStubMappingIdResult
{
/// <summary>
/// This stub mapping's unique identifier
/// </summary>
public string Id { get; set; }
/// <summary>
/// Alias for the id
/// </summary>
public string Uuid { get; set; }
/// <summary>
/// The stub mapping's name
/// </summary>
public string Name { get; set; }
public WireMockOrgRequest Request { get; set; }
public WireMockOrgResponse Response { get; set; }
/// <summary>
/// Indicates that the stub mapping should be persisted immediately on create/update/delete and survive resets to default.
/// </summary>
public bool Persistent { get; set; }
/// <summary>
/// This stub mapping's priority relative to others. 1 is highest.
/// </summary>
public int Priority { get; set; }
/// <summary>
/// The name of the scenario that this stub mapping is part of
/// </summary>
public string ScenarioName { get; set; }
/// <summary>
/// The required state of the scenario in order for this stub to be matched.
/// </summary>
public string RequiredScenarioState { get; set; }
/// <summary>
/// The new state for the scenario to be updated to after this stub is served.
/// </summary>
public string NewScenarioState { get; set; }
/// <summary>
/// A map of the names of post serve action extensions to trigger and their parameters.
/// </summary>
public object PostServeActions { get; set; }
/// <summary>
/// Arbitrary metadata to be used for e.g. tagging, documentation. Can also be used to find and remove stubs.
/// </summary>
public object Metadata { get; set; }
}
}

View File

@@ -1,6 +1,6 @@
namespace WireMock.Org.Abstractions namespace WireMock.Org.Abstractions
{ {
public class Request public class WireMockOrgRequest
{ {
/// <summary> /// <summary>
/// The HTTP request method e.g. GET /// The HTTP request method e.g. GET
@@ -28,28 +28,28 @@ namespace WireMock.Org.Abstractions
public string UrlPattern { get; set; } public string UrlPattern { get; set; }
/// <summary> /// <summary>
/// Query parameter patterns to match against in the &lt;key&gt;: { "&lt;predicate&gt;": "&lt;value&gt;" } form /// Query parameter patterns to match against in the : { "": "" } form
/// </summary> /// </summary>
public object QueryParameters { get; set; } public object QueryParameters { get; set; }
/// <summary> /// <summary>
/// Header patterns to match against in the &lt;key&gt;: { "&lt;predicate&gt;": "&lt;value&gt;" } form /// Header patterns to match against in the : { "": "" } form
/// </summary> /// </summary>
public object Headers { get; set; } public object Headers { get; set; }
/// <summary> /// <summary>
/// Pre-emptive basic auth credentials to match against /// Pre-emptive basic auth credentials to match against
/// </summary> /// </summary>
public BasicAuthCredentials BasicAuthCredentials { get; set; } public RequestBasicAuthCredentials BasicAuthCredentials { get; set; }
/// <summary> /// <summary>
/// Cookie patterns to match against in the &lt;key&gt;: { "&lt;predicate&gt;": "&lt;value&gt;" } form /// Cookie patterns to match against in the : { "": "" } form
/// </summary> /// </summary>
public object Cookies { get; set; } public object Cookies { get; set; }
/// <summary> /// <summary>
/// Request body patterns to match against in the &lt;key&gt;: { "&lt;predicate&gt;": "&lt;value&gt;" } form /// Request body patterns to match against in the : { "": "" } form
/// </summary> /// </summary>
public object[] BodyPatterns { get; set; } public object[] BodyPatterns { get; set; }
} }
} }

View File

@@ -3,10 +3,10 @@ namespace WireMock.Org.Abstractions
/// <summary> /// <summary>
/// Pre-emptive basic auth credentials to match against /// Pre-emptive basic auth credentials to match against
/// </summary> /// </summary>
public class BasicAuthCredentials public class RequestBasicAuthCredentials
{ {
public string Password { get; set; } public string Password { get; set; }
public string Username { get; set; } public string Username { get; set; }
} }
} }

View File

@@ -1,6 +1,6 @@
namespace WireMock.Org.Abstractions namespace WireMock.Org.Abstractions
{ {
public class Response public class WireMockOrgResponse
{ {
/// <summary> /// <summary>
/// The HTTP status code to be returned /// The HTTP status code to be returned
@@ -52,6 +52,11 @@ namespace WireMock.Org.Abstractions
/// </summary> /// </summary>
public int FixedDelayMilliseconds { get; set; } public int FixedDelayMilliseconds { get; set; }
/// <summary>
/// The delay distribution. Valid property configuration is either median/sigma/type or lower/type/upper.
/// </summary>
public object DelayDistribution { get; set; }
/// <summary> /// <summary>
/// Read-only flag indicating false if this was the default, unmatched response. Not present otherwise. /// Read-only flag indicating false if this was the default, unmatched response. Not present otherwise.
/// </summary> /// </summary>
@@ -70,6 +75,6 @@ namespace WireMock.Org.Abstractions
/// <summary> /// <summary>
/// List of names of transformers to apply to this response. /// List of names of transformers to apply to this response.
/// </summary> /// </summary>
public string Transformers { get; set; } public string[] Transformers { get; set; }
} }
} }

View File

@@ -0,0 +1,16 @@
namespace WireMock.Org.Abstractions
{
/// <summary>
/// The fault to apply (instead of a full, valid response).
/// </summary>
public static class ResponseFaultConstants
{
public const string CONNECTIONRESETBYPEER = "CONNECTION_RESET_BY_PEER";
public const string EMPTYRESPONSE = "EMPTY_RESPONSE";
public const string MALFORMEDRESPONSECHUNK = "MALFORMED_RESPONSE_CHUNK";
public const string RANDOMDATATHENCLOSE = "RANDOM_DATA_THEN_CLOSE";
}
}

View File

@@ -1,14 +0,0 @@
namespace WireMock.Org.Abstractions
{
/// <summary>
/// Log normal randomly distributed response delay.
/// </summary>
public class ResponseLogNormal
{
public int Median { get; set; }
public double Sigma { get; set; }
public string Type { get; set; }
}
}

View File

@@ -1,14 +0,0 @@
namespace WireMock.Org.Abstractions
{
/// <summary>
/// Uniformly distributed random response delay.
/// </summary>
public class ResponseLogUniformlyDistributed
{
public int Lower { get; set; }
public string Type { get; set; }
public int Upper { get; set; }
}
}

View File

@@ -1,6 +1,6 @@
namespace WireMock.Org.Abstractions namespace WireMock.Org.Abstractions
{ {
public class Scenario public class Scenarios
{ {
/// <summary> /// <summary>
/// The scenario ID /// The scenario ID
@@ -12,11 +12,14 @@ namespace WireMock.Org.Abstractions
/// </summary> /// </summary>
public string Name { get; set; } public string Name { get; set; }
public string PossibleStates { get; set; } /// <summary>
/// All the states this scenario can be in
/// </summary>
public string[] PossibleStates { get; set; }
/// <summary> /// <summary>
/// The current state of this scenario /// The current state of this scenario
/// </summary> /// </summary>
public string State { get; set; } public string State { get; set; }
} }
} }

View File

@@ -0,0 +1,11 @@
namespace WireMock.Org.Abstractions
{
public static class StatusConstants
{
public const string NeverStarted = "NeverStarted";
public const string Recording = "Recording";
public const string Stopped = "Stopped";
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,232 +1,299 @@
using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks; using System.Threading.Tasks;
using AnyOfTypes;
using RestEase; using RestEase;
using WireMock.Org.Abstractions; using WireMock.Org.Abstractions;
namespace WireMock.Org.RestClient namespace WireMock.Org.RestClient
{ {
/// <summary> /// <summary>
/// WireMockOrg /// Summary: WireMockOrg
///
/// Title : WireMock
/// Version: 2.33.2
/// </summary> /// </summary>
public interface IWireMockOrgApi public interface IWireMockOrgApi
{ {
/// <summary> /// <summary>
/// Get all stub mappings /// Get all stub mappings
///
/// GetAdminMappings (/__admin/mappings)
/// </summary> /// </summary>
/// <param name="limit">The maximum number of results to return</param> /// <param name="limit">The maximum number of results to return</param>
/// <param name="offset">The start index of the results to return</param> /// <param name="offset">The start index of the results to return</param>
[Get("/__admin/mappings")] [Get("/__admin/mappings")]
Task<GetAdminMappingsResponse> GetAdminMappingsAsync([Query] int? limit, [Query] int? offset); Task<GetAdminMappingsResult> GetAdminMappingsAsync([Query] int? limit, [Query] int? offset);
/// <summary> /// <summary>
/// Create a new stub mapping /// Create a new stub mapping
///
/// PostAdminMappings (/__admin/mappings)
/// </summary> /// </summary>
/// <param name="request"></param>
[Post("/__admin/mappings")] [Post("/__admin/mappings")]
[Header("Content-Type", "application/json")] [Header("Content-Type", "application/json")]
Task<Mapping> PostAdminMappingsAsync([Body] Mapping request); Task<PostAdminMappingsResult> PostAdminMappingsAsync();
/// <summary> /// <summary>
/// Delete all stub mappings /// Delete all stub mappings
///
/// DeleteAdminMappings (/__admin/mappings)
/// </summary> /// </summary>
[Delete("/__admin/mappings")] [Delete("/__admin/mappings")]
Task DeleteAdminMappingsAsync(); Task<object> DeleteAdminMappingsAsync();
/// <summary> /// <summary>
/// Reset stub mappings /// Reset stub mappings
///
/// PostAdminMappingsReset (/__admin/mappings/reset)
/// </summary> /// </summary>
[Post("/__admin/mappings/reset")] [Post("/__admin/mappings/reset")]
Task PostAdminMappingsResetAsync(); Task<object> PostAdminMappingsResetAsync();
/// <summary> /// <summary>
/// Persist stub mappings /// Persist stub mappings
///
/// PostAdminMappingsSave (/__admin/mappings/save)
/// </summary> /// </summary>
[Post("/__admin/mappings/save")] [Post("/__admin/mappings/save")]
Task PostAdminMappingsSaveAsync(); Task<object> PostAdminMappingsSaveAsync();
/// <summary> /// <summary>
/// Get stub mapping by ID /// Get stub mapping by ID
///
/// GetAdminMappingsByStubMappingId (/__admin/mappings/{stubMappingId})
/// </summary> /// </summary>
/// <param name="stubMappingId">The UUID of stub mapping</param>
[Get("/__admin/mappings/{stubMappingId}")] [Get("/__admin/mappings/{stubMappingId}")]
Task<Mapping> GetAdminMappingsByStubMappingIdAsync(); Task<Response<AnyOf<GetAdminMappingsByStubMappingIdResult, object>>> GetAdminMappingsByStubMappingIdAsync([Path] string stubMappingId);
/// <summary> /// <summary>
/// Update a stub mapping /// Update a stub mapping
///
/// PutAdminMappingsByStubMappingId (/__admin/mappings/{stubMappingId})
/// </summary> /// </summary>
/// <param name="request"></param> /// <param name="stubMappingId">The UUID of stub mapping</param>
[Put("/__admin/mappings/{stubMappingId}")] [Put("/__admin/mappings/{stubMappingId}")]
[Header("Content-Type", "application/json")] [Header("Content-Type", "application/json")]
Task<Mapping> PutAdminMappingsByStubMappingIdAsync([Body] Mapping request); Task<Response<AnyOf<PutAdminMappingsByStubMappingIdResult, object>>> PutAdminMappingsByStubMappingIdAsync([Path] string stubMappingId);
/// <summary> /// <summary>
/// Delete a stub mapping /// Delete a stub mapping
///
/// DeleteAdminMappingsByStubMappingId (/__admin/mappings/{stubMappingId})
/// </summary> /// </summary>
/// <param name="stubMappingId">The UUID of stub mapping</param>
[Delete("/__admin/mappings/{stubMappingId}")] [Delete("/__admin/mappings/{stubMappingId}")]
Task DeleteAdminMappingsByStubMappingIdAsync(); Task<object> DeleteAdminMappingsByStubMappingIdAsync([Path] string stubMappingId);
/// <summary> /// <summary>
/// Find stubs by matching on their metadata
///
/// PostAdminMappingsFindByMetadata (/__admin/mappings/find-by-metadata) /// PostAdminMappingsFindByMetadata (/__admin/mappings/find-by-metadata)
/// </summary> /// </summary>
[Post("/__admin/mappings/find-by-metadata")] [Post("/__admin/mappings/find-by-metadata")]
[Header("Content-Type", "application/json")] [Header("Content-Type", "application/json")]
Task<GetAdminMappingsResponse> PostAdminMappingsFindByMetadataAsync(); Task<PostAdminMappingsFindByMetadataResult> PostAdminMappingsFindByMetadataAsync();
/// <summary> /// <summary>
/// Delete stub mappings matching metadata /// Delete stub mappings matching metadata
///
/// PostAdminMappingsRemoveByMetadata (/__admin/mappings/remove-by-metadata)
/// </summary> /// </summary>
[Post("/__admin/mappings/remove-by-metadata")] [Post("/__admin/mappings/remove-by-metadata")]
[Header("Content-Type", "application/json")] [Header("Content-Type", "application/json")]
Task PostAdminMappingsRemoveByMetadataAsync(); Task<object> PostAdminMappingsRemoveByMetadataAsync();
/// <summary> /// <summary>
/// Get all requests in journal /// Get all requests in journal
///
/// GetAdminRequests (/__admin/requests)
/// </summary> /// </summary>
/// <param name="limit">The maximum number of results to return</param> /// <param name="limit">The maximum number of results to return</param>
/// <param name="since">Only return logged requests after this date</param> /// <param name="since">Only return logged requests after this date</param>
[Get("/__admin/requests")] [Get("/__admin/requests")]
Task GetAdminRequestsAsync([Query] string limit, [Query] string since); Task<object> GetAdminRequestsAsync([Query] string limit, [Query] string since);
/// <summary> /// <summary>
/// Delete all requests in journal /// Delete all requests in journal
///
/// DeleteAdminRequests (/__admin/requests)
/// </summary> /// </summary>
[Delete("/__admin/requests")] [Delete("/__admin/requests")]
Task DeleteAdminRequestsAsync(); Task<object> DeleteAdminRequestsAsync();
/// <summary> /// <summary>
/// Get request by ID /// Get request by ID
///
/// GetAdminRequestsByRequestId (/__admin/requests/{requestId})
/// </summary> /// </summary>
/// <param name="requestId">The UUID of the logged request</param> /// <param name="requestId">The UUID of the logged request</param>
[Get("/__admin/requests/{requestId}")] [Get("/__admin/requests/{requestId}")]
Task GetAdminRequestsByRequestIdAsync([Path] string requestId); Task<object> GetAdminRequestsByRequestIdAsync([Path] string requestId);
/// <summary> /// <summary>
/// Delete request by ID /// Delete request by ID
///
/// DeleteAdminRequestsByRequestId (/__admin/requests/{requestId})
/// </summary> /// </summary>
/// <param name="requestId">The UUID of the logged request</param> /// <param name="requestId">The UUID of the logged request</param>
[Delete("/__admin/requests/{requestId}")] [Delete("/__admin/requests/{requestId}")]
Task DeleteAdminRequestsByRequestIdAsync([Path] string requestId); Task<object> DeleteAdminRequestsByRequestIdAsync([Path] string requestId);
/// <summary> /// <summary>
/// Empty the request journal /// Empty the request journal
///
/// PostAdminRequestsReset (/__admin/requests/reset)
/// </summary> /// </summary>
[Post("/__admin/requests/reset")] [Post("/__admin/requests/reset")]
Task PostAdminRequestsResetAsync(); Task<object> PostAdminRequestsResetAsync();
/// <summary> /// <summary>
/// Count requests by criteria /// Count requests by criteria
///
/// PostAdminRequestsCount (/__admin/requests/count)
/// </summary> /// </summary>
/// <param name="request"></param>
[Post("/__admin/requests/count")] [Post("/__admin/requests/count")]
[Header("Content-Type", "application/json")] [Header("Content-Type", "application/json")]
Task<PostAdminRequestsCountResponse> PostAdminRequestsCountAsync([Body] Request request); Task<PostAdminRequestsCountResult> PostAdminRequestsCountAsync();
/// <summary> /// <summary>
/// Remove requests by criteria /// Remove requests by criteria
///
/// PostAdminRequestsRemove (/__admin/requests/remove)
/// </summary> /// </summary>
/// <param name="request"></param>
[Post("/__admin/requests/remove")] [Post("/__admin/requests/remove")]
[Header("Content-Type", "application/json")] [Header("Content-Type", "application/json")]
Task PostAdminRequestsRemoveAsync([Body] Request request); Task<object> PostAdminRequestsRemoveAsync();
/// <summary> /// <summary>
/// Delete requests mappings matching metadata /// Delete requests mappings matching metadata
///
/// PostAdminRequestsRemoveByMetadata (/__admin/requests/remove-by-metadata)
/// </summary> /// </summary>
[Post("/__admin/requests/remove-by-metadata")] [Post("/__admin/requests/remove-by-metadata")]
[Header("Content-Type", "application/json")] [Header("Content-Type", "application/json")]
Task PostAdminRequestsRemoveByMetadataAsync(); Task<object> PostAdminRequestsRemoveByMetadataAsync();
/// <summary> /// <summary>
/// Find requests by criteria /// Find requests by criteria
///
/// PostAdminRequestsFind (/__admin/requests/find)
/// </summary> /// </summary>
/// <param name="request"></param>
[Post("/__admin/requests/find")] [Post("/__admin/requests/find")]
[Header("Content-Type", "application/json")] [Header("Content-Type", "application/json")]
Task PostAdminRequestsFindAsync([Body] Request request); Task<object> PostAdminRequestsFindAsync();
/// <summary> /// <summary>
/// Find unmatched requests /// Find unmatched requests
///
/// GetAdminRequestsUnmatched (/__admin/requests/unmatched)
/// </summary> /// </summary>
[Get("/__admin/requests/unmatched")] [Get("/__admin/requests/unmatched")]
Task GetAdminRequestsUnmatchedAsync(); Task<object> GetAdminRequestsUnmatchedAsync();
/// <summary> /// <summary>
/// Retrieve near-misses for all unmatched requests
///
/// GetAdminRequestsUnmatchedNearMisses (/__admin/requests/unmatched/near-misses) /// GetAdminRequestsUnmatchedNearMisses (/__admin/requests/unmatched/near-misses)
/// </summary> /// </summary>
[Get("/__admin/requests/unmatched/near-misses")] [Get("/__admin/requests/unmatched/near-misses")]
Task<GetAdminRequestsUnmatchedNearMissesResponse> GetAdminRequestsUnmatchedNearMissesAsync(); Task<GetAdminRequestsUnmatchedNearMissesResult> GetAdminRequestsUnmatchedNearMissesAsync();
/// <summary> /// <summary>
/// Find near misses matching specific request /// Find near misses matching specific request
///
/// PostAdminNearMissesRequest (/__admin/near-misses/request)
/// </summary> /// </summary>
/// <param name="request"></param>
[Post("/__admin/near-misses/request")] [Post("/__admin/near-misses/request")]
[Header("Content-Type", "application/json")] [Header("Content-Type", "application/json")]
Task<GetAdminRequestsUnmatchedNearMissesResponse> PostAdminNearMissesRequestAsync([Body] NearMiss request); Task<PostAdminNearMissesRequestResult> PostAdminNearMissesRequestAsync();
/// <summary> /// <summary>
/// Find near misses matching request pattern /// Find near misses matching request pattern
///
/// PostAdminNearMissesRequestPattern (/__admin/near-misses/request-pattern)
/// </summary> /// </summary>
/// <param name="request"></param>
[Post("/__admin/near-misses/request-pattern")] [Post("/__admin/near-misses/request-pattern")]
[Header("Content-Type", "application/json")] [Header("Content-Type", "application/json")]
Task<GetAdminRequestsUnmatchedNearMissesResponse> PostAdminNearMissesRequestPatternAsync([Body] Request request); Task<PostAdminNearMissesRequestPatternResult> PostAdminNearMissesRequestPatternAsync();
/// <summary> /// <summary>
/// Start recording /// Start recording
///
/// PostAdminRecordingsStart (/__admin/recordings/start)
/// </summary> /// </summary>
[Post("/__admin/recordings/start")] [Post("/__admin/recordings/start")]
[Header("Content-Type", "application/json")] [Header("Content-Type", "application/json")]
Task PostAdminRecordingsStartAsync(); Task<object> PostAdminRecordingsStartAsync();
/// <summary> /// <summary>
/// Stop recording /// Stop recording
///
/// PostAdminRecordingsStop (/__admin/recordings/stop)
/// </summary> /// </summary>
[Post("/__admin/recordings/stop")] [Post("/__admin/recordings/stop")]
Task<GetAdminMappingsResponse> PostAdminRecordingsStopAsync(); Task<PostAdminRecordingsStopResult> PostAdminRecordingsStopAsync();
/// <summary> /// <summary>
/// Get recording status /// Get recording status
///
/// GetAdminRecordingsStatus (/__admin/recordings/status)
/// </summary> /// </summary>
[Get("/__admin/recordings/status")] [Get("/__admin/recordings/status")]
Task<GetAdminRecordingsStatusResponse> GetAdminRecordingsStatusAsync(); Task<GetAdminRecordingsStatusResult> GetAdminRecordingsStatusAsync();
/// <summary> /// <summary>
/// Take a snapshot recording /// Take a snapshot recording
///
/// PostAdminRecordingsSnapshot (/__admin/recordings/snapshot)
/// </summary> /// </summary>
/// <param name="request"></param>
[Post("/__admin/recordings/snapshot")] [Post("/__admin/recordings/snapshot")]
[Header("Content-Type", "application/json")] [Header("Content-Type", "application/json")]
Task<GetAdminMappingsResponse> PostAdminRecordingsSnapshotAsync([Body] object request); Task<PostAdminRecordingsSnapshotResult> PostAdminRecordingsSnapshotAsync();
/// <summary> /// <summary>
/// Get all scenarios /// Get all scenarios
///
/// GetAdminScenarios (/__admin/scenarios)
/// </summary> /// </summary>
[Get("/__admin/scenarios")] [Get("/__admin/scenarios")]
Task<GetAdminScenariosResponse> GetAdminScenariosAsync(); Task<GetAdminScenariosResult> GetAdminScenariosAsync();
/// <summary> /// <summary>
/// Reset the state of all scenarios /// Reset the state of all scenarios
///
/// PostAdminScenariosReset (/__admin/scenarios/reset)
/// </summary> /// </summary>
[Post("/__admin/scenarios/reset")] [Post("/__admin/scenarios/reset")]
Task PostAdminScenariosResetAsync(); Task<object> PostAdminScenariosResetAsync();
/// <summary> /// <summary>
/// Update global settings /// Update global settings
///
/// PostAdminSettings (/__admin/settings)
/// </summary> /// </summary>
[Post("/__admin/settings")] [Post("/__admin/settings")]
[Header("Content-Type", "application/json")] [Header("Content-Type", "application/json")]
Task PostAdminSettingsAsync(); Task<object> PostAdminSettingsAsync();
/// <summary> /// <summary>
/// Reset mappings and request journal /// Reset mappings and request journal
///
/// PostAdminReset (/__admin/reset)
/// </summary> /// </summary>
[Post("/__admin/reset")] [Post("/__admin/reset")]
Task PostAdminResetAsync(); Task<object> PostAdminResetAsync();
/// <summary> /// <summary>
/// Shutdown the WireMock server
///
/// PostAdminShutdown (/__admin/shutdown) /// PostAdminShutdown (/__admin/shutdown)
/// </summary> /// </summary>
[Post("/__admin/shutdown")] [Post("/__admin/shutdown")]
Task PostAdminShutdownAsync(); Task<object> PostAdminShutdownAsync();
} }
} }

View File

@@ -30,8 +30,9 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="AnyOf" Version="0.3.0" />
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" /> <PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All" />
<PackageReference Include="RestEase" Version="1.5.6" /> <PackageReference Include="RestEase" Version="1.5.7" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@@ -52,7 +52,7 @@
<PackageReference Include="Moq" Version="4.17.2" /> <PackageReference Include="Moq" Version="4.17.2" />
<PackageReference Include="System.Threading" Version="4.3.0" /> <PackageReference Include="System.Threading" Version="4.3.0" />
<PackageReference Include="RestEase" Version="1.5.6" /> <PackageReference Include="RestEase" Version="1.5.7" />
<!--<PackageReference Include="RandomDataGenerator.Net" Version="1.0.14" />--> <!--<PackageReference Include="RandomDataGenerator.Net" Version="1.0.14" />-->
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.1" />