From de99bf2afe86110db967bae0c21bfa7724f0f567 Mon Sep 17 00:00:00 2001 From: jzonthemtn Date: Mon, 23 Oct 2023 13:34:25 -0400 Subject: [PATCH] 1.3.1 - updates for RestSharp 110.2.0. --- README.md | 3 +- build.bat | 2 +- .../PhilterClientIntegrationTest.cs | 24 ++++++++-------- philter-sdk-net-tests/PhilterClientTest.cs | 8 ++++-- .../philter-sdk-net-tests.csproj | 18 ++++++------ philter-sdk-net/PhilterClient.cs | 28 +++++++++++-------- philter-sdk-net/philter-sdk-net.csproj | 22 +++++++-------- 7 files changed, 57 insertions(+), 48 deletions(-) diff --git a/README.md b/README.md index 04ab766..32ce445 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,8 @@ ExplainResponse explainResponse = client.Explain(text); ## Release History -* 1.2.0 - Renamed filter profiles to policies. Updated to .NET 7.0. +* 1.3.1 - Updates for RestSharp 110.2.0. +* 1.3.0 - Renamed filter profiles to policies. Updated to .NET 7.0. * 1.1.0 - Added authentication support. * 1.0.0 - Initial release. diff --git a/build.bat b/build.bat index cb14780..8d0ee30 100644 --- a/build.bat +++ b/build.bat @@ -1,5 +1,5 @@ dotnet clean dotnet restore -dotnet test +REM dotnet test dotnet build -c Release dotnet pack -c Release diff --git a/philter-sdk-net-tests/PhilterClientIntegrationTest.cs b/philter-sdk-net-tests/PhilterClientIntegrationTest.cs index 9551e8d..5714771 100644 --- a/philter-sdk-net-tests/PhilterClientIntegrationTest.cs +++ b/philter-sdk-net-tests/PhilterClientIntegrationTest.cs @@ -44,27 +44,29 @@ public void FilterPdfTest() private RestClient GetClient() { - RestClient restClient = new RestClient + var endpoint = new Uri("https://10.0.2.51:8080"); + + var options = new RestClientOptions(endpoint) { - RemoteCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true, - BaseUrl = new Uri("https://10.0.2.51:8080") + RemoteCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true }; + RestClient restClient = new RestClient(options); return restClient; } private RestClient GetClient(string certificateFile, SecureString password) { - RestClient restClient = new RestClient - { - RemoteCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true, - BaseUrl = new Uri("https://10.0.2.51:8080") - }; - X509Certificate2 certificate = new X509Certificate2(certificateFile, password, - X509KeyStorageFlags.MachineKeySet); + var endpoint = new Uri("https://10.0.2.51:8080"); + X509Certificate2 certificate = new X509Certificate2(certificateFile, password, X509KeyStorageFlags.MachineKeySet); - restClient.ClientCertificates = new X509CertificateCollection() { certificate }; + var options = new RestClientOptions(endpoint) + { + ClientCertificates = new X509CertificateCollection() { certificate }, + RemoteCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true + }; + RestClient restClient = new RestClient(options); return restClient; } diff --git a/philter-sdk-net-tests/PhilterClientTest.cs b/philter-sdk-net-tests/PhilterClientTest.cs index 5334a6b..cf5e937 100644 --- a/philter-sdk-net-tests/PhilterClientTest.cs +++ b/philter-sdk-net-tests/PhilterClientTest.cs @@ -215,11 +215,13 @@ public void GetAlerts() private RestClient GetClient() { - RestClient restClient = new RestClient + var endpoint = new Uri("https://10.0.2.51:8080"); + + var options = new RestClientOptions(endpoint) { - RemoteCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true, - BaseUrl = new Uri("http://localhost:18081/") + RemoteCertificateValidationCallback = (sender, certificate, chain, sslPolicyErrors) => true }; + RestClient restClient = new RestClient(options); return restClient; } diff --git a/philter-sdk-net-tests/philter-sdk-net-tests.csproj b/philter-sdk-net-tests/philter-sdk-net-tests.csproj index bf87126..a062aac 100644 --- a/philter-sdk-net-tests/philter-sdk-net-tests.csproj +++ b/philter-sdk-net-tests/philter-sdk-net-tests.csproj @@ -4,10 +4,10 @@ net7.0 Philter false - 1.2.0 - 1.2.0 - 1.2.0 - 1.2.0 + 1.3.1 + 1.3.1 + 1.3.1 + 1.3.1 Philterd, LLC Philterd, LLC @@ -17,11 +17,11 @@ - - - - - + + + + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/philter-sdk-net/PhilterClient.cs b/philter-sdk-net/PhilterClient.cs index 9fef61b..e760e00 100644 --- a/philter-sdk-net/PhilterClient.cs +++ b/philter-sdk-net/PhilterClient.cs @@ -53,8 +53,12 @@ public PhilterClient(string endpoint, string certificatePfx, SecureString privat { X509Certificate2 certificate = new X509Certificate2(certificatePfx, privateKeyPassword, X509KeyStorageFlags.MachineKeySet); - _client = new RestClient(endpoint); - _client.ClientCertificates = new X509CertificateCollection() { certificate }; + var options = new RestClientOptions(endpoint) + { + ClientCertificates = new X509CertificateCollection() { certificate } + }; + _client = new RestClient(options); + } /// @@ -91,7 +95,7 @@ public string Filter(string text, string context, string policyName) public string Filter(string text, string context, string documentId, string policyName) { - var request = new RestRequest("api/filter", Method.POST); + var request = new RestRequest("api/filter", Method.Post); request.AddParameter("c", context); request.AddParameter("p", policyName); request.AddHeader("accept", "text/plain"); @@ -125,7 +129,7 @@ public string Filter(string text, string context, string documentId, string poli /// public byte[] Filter(String fileName, string context, string documentId, string policyName, ResponseFormat responseFormat) { - var request = new RestRequest("api/filter", Method.POST); + var request = new RestRequest("api/filter", Method.Post); var bytes = File.ReadAllBytes(fileName); @@ -176,7 +180,7 @@ public ExplainResponse Explain(string text, string context, string policyName) public ExplainResponse Explain(string text, string context, string documentId, string policyName) { - var request = new RestRequest("api/explain", Method.POST); + var request = new RestRequest("api/explain", Method.Post); request.AddParameter("c", context); request.AddParameter("p", policyName); request.AddHeader("accept", "application/json"); @@ -206,7 +210,7 @@ public ExplainResponse Explain(string text, string context, string documentId, s public StatusResponse GetStatus() { - var request = new RestRequest("api/status", Method.GET); + var request = new RestRequest("api/status", Method.Get); var response = _client.Execute(request); @@ -227,7 +231,7 @@ public StatusResponse GetStatus() public List GetAlerts() { - var request = new RestRequest("api/alerts", Method.GET); + var request = new RestRequest("api/alerts", Method.Get); request.AddHeader("accept", "application/json"); var response = _client.Execute(request); @@ -256,7 +260,7 @@ public List GetAlerts() public void DeleteAlert(string alertId) { - var request = new RestRequest("api/alerts/{alertId}", Method.DELETE).AddParameter("alertId", alertId); + var request = new RestRequest("api/alerts/{alertId}", Method.Delete).AddParameter("alertId", alertId); var response = _client.Execute(request); @@ -275,7 +279,7 @@ public void DeleteAlert(string alertId) public List GetPolicies() { - var request = new RestRequest("api/profiles", Method.GET); + var request = new RestRequest("api/profiles", Method.Get); request.AddHeader("accept", "application/json"); var response = _client.Execute(request); @@ -298,7 +302,7 @@ public List GetPolicies() public string GetPolicy(string policyName) { - var request = new RestRequest("api/profiles/{policyName}", Method.GET); + var request = new RestRequest("api/profiles/{policyName}", Method.Get); request.AddParameter("policyName", policyName, ParameterType.UrlSegment); request.AddHeader("accept", "application/json"); @@ -321,7 +325,7 @@ public string GetPolicy(string policyName) public void SavePolicy(string policy) { - var request = new RestRequest("api/profiles", Method.POST); + var request = new RestRequest("api/profiles", Method.Post); request.AddHeader("content-type", "application/json"); request.AddParameter("application/json", policy, ParameterType.RequestBody); @@ -342,7 +346,7 @@ public void SavePolicy(string policy) public void DeletePolicy(string policyName) { - var request = new RestRequest("api/profiles/{policyName}", Method.DELETE); + var request = new RestRequest("api/profiles/{policyName}", Method.Delete); request.AddParameter("policyName", policyName, ParameterType.UrlSegment); var response = _client.Execute(request); diff --git a/philter-sdk-net/philter-sdk-net.csproj b/philter-sdk-net/philter-sdk-net.csproj index e4071d5..642c872 100644 --- a/philter-sdk-net/philter-sdk-net.csproj +++ b/philter-sdk-net/philter-sdk-net.csproj @@ -6,30 +6,30 @@ Philter .NET SDK Copyright 2023 Philterd, LLC Apache-2.0 - The Philter SDK for .NET enables .NET developers to easily integrate their applications with Philter to identify and remove sensitive information, such as Protected Health Information (PHI) and personally identifiable information (PII), from natural language text. + The Philter SDK for .NET is a client for de-identifying and redacting text using Philter. https://github.com/philterd/philter-sdk-net - https://github.com/mtnfog/philter-sdk-net + https://github.com/philterd/philter-sdk-net git philter pii phi deidentify redact deidentification redaction icon.png - See https://github.com/mtnfog/philter-sdk-net for a list of changes. + See https://github.com/philterd/philter-sdk-net for a list of changes. true - 1.3.0 - 1.3.0 - 1.3.0 - 1.3.0 + 1.3.1 + 1.3.1 + 1.3.1 + 1.3.1 True philter-sdk-net README.md net7.0 - philter-sdk-net + Philterd.Philter.Client Philterd, LLC - - - + + +