Skip to content

Commit

Permalink
Merge branch 'main' of github.com:philterd/philter-sdk-net
Browse files Browse the repository at this point in the history
  • Loading branch information
jzonthemtn committed Nov 17, 2023
2 parents e0923a1 + de99bf2 commit 9ab7aec
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 63 deletions.
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# Philter SDK for .NET

The **Philter SDK for .NET** enables .NET developers to easily work with [Philter](https://www.philterd.ai/philter/) to identify and redact PII, PHI, and other sensitive information from text and documents. This project is an API client to use Philter from .NET applications.

Refer to the [Philter API](https://docs.philterd.ai/philter/api/) documentation for details on the methods available.
The Philter SDK for .NET is a client for de-identifying and redacting text using Philter. Refer to the [Philter API](https://docs.philterd.ai/philter/api/) documentation for details on the methods available.

## Build

Expand All @@ -12,8 +10,6 @@ The project can be built using Visual Studio or other .NET IDE. It can be built

Install using [NuGet](https://www.nuget.org/packages/philter-sdk-net/).

[![nuget](https://img.shields.io/nuget/v/philter-sdk-net.svg)](https://www.nuget.org/packages/philter-sdk-net/)

Or, clone and import the project into your solution.

```
Expand All @@ -36,6 +32,8 @@ ExplainResponse explainResponse = client.Explain(text);

## Release History

* 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.

Expand Down
2 changes: 1 addition & 1 deletion build.bat
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
dotnet clean
dotnet restore
dotnet test
REM dotnet test
dotnet build -c Release
dotnet pack -c Release
24 changes: 13 additions & 11 deletions philter-sdk-net-tests/PhilterClientIntegrationTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
8 changes: 5 additions & 3 deletions philter-sdk-net-tests/PhilterClientTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,11 +204,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;
}
Expand Down
25 changes: 9 additions & 16 deletions philter-sdk-net-tests/philter-sdk-net-tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,12 @@
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<RootNamespace>Philter</RootNamespace>

<IsPackable>false</IsPackable>

<PackageVersion>1.1.0</PackageVersion>

<AssemblyVersion>1.1.0</AssemblyVersion>

<FileVersion>1.1.0</FileVersion>

<Version>1.3.0</Version>

<PackageVersion>1.3.1</PackageVersion>
<AssemblyVersion>1.3.1</AssemblyVersion>
<FileVersion>1.3.1</FileVersion>
<Version>1.3.1</Version>
<Authors>Philterd, LLC</Authors>

<Company>Philterd, LLC</Company>
</PropertyGroup>

Expand All @@ -24,11 +17,11 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FluentSimulator" Version="2.0.49" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
<PackageReference Include="MSTest.TestAdapter" Version="2.1.0" />
<PackageReference Include="MSTest.TestFramework" Version="2.1.0" />
<PackageReference Include="coverlet.collector" Version="1.2.0">
<PackageReference Include="FluentSimulator" Version="2.1.9" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.7.2" />
<PackageReference Include="MSTest.TestAdapter" Version="3.1.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.1.1" />
<PackageReference Include="coverlet.collector" Version="6.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
36 changes: 20 additions & 16 deletions philter-sdk-net/PhilterClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

}

/// <summary>
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -125,7 +129,7 @@ public string Filter(string text, string context, string documentId, string poli
/// <exception cref="ClientException"></exception>
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);

Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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);

Expand All @@ -227,7 +231,7 @@ public StatusResponse GetStatus()
public List<Alert> 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);
Expand Down Expand Up @@ -256,7 +260,7 @@ public List<Alert> 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);

Expand All @@ -272,10 +276,10 @@ public void DeleteAlert(string alertId)
/// </summary>
/// <returns>A list of policy names.</returns>
/// <exception cref="ClientException"></exception>
public List<string> GetFilterProfiles()
public List<string> 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);
Expand All @@ -295,10 +299,10 @@ public List<string> GetFilterProfiles()
/// <param name="policyName">The name of a policy.</param>
/// <returns>The policy.</returns>
/// <exception cref="ClientException"></exception>
public string GetFilterProfile(string policyName)
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");

Expand All @@ -318,10 +322,10 @@ public string GetFilterProfile(string policyName)
/// </summary>
/// <param name="policy">The policy.</param>
/// <exception cref="ClientException"></exception>
public void SaveFilterProfile(string policy)
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);

Expand All @@ -339,10 +343,10 @@ public void SaveFilterProfile(string policy)
/// </summary>
/// <param name="policyName">The name of the policy to delete.</param>
/// <exception cref="ClientException"></exception>
public void DeleteFilterProfile(string policyName)
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);
Expand Down
23 changes: 12 additions & 11 deletions philter-sdk-net/philter-sdk-net.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,30 @@
<Product>Philter .NET SDK</Product>
<Copyright>Copyright 2023 Philterd, LLC</Copyright>
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
<Description>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.</Description>
<Description>The Philter SDK for .NET is a client for de-identifying and redacting text using Philter.</Description>
<PackageProjectUrl>https://github.com/philterd/philter-sdk-net</PackageProjectUrl>
<RepositoryUrl>https://github.com/mtnfog/philter-sdk-net</RepositoryUrl>
<RepositoryUrl>https://github.com/philterd/philter-sdk-net</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>philter pii phi filtering</PackageTags>
<PackageTags>philter pii phi deidentify redact deidentification redaction</PackageTags>
<PackageIcon>icon.png</PackageIcon>
<PackageReleaseNotes>See https://github.com/mtnfog/philter-sdk-net for a list of changes.</PackageReleaseNotes>
<PackageReleaseNotes>See https://github.com/philterd/philter-sdk-net for a list of changes.</PackageReleaseNotes>
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
<PackageVersion>1.3.0</PackageVersion>
<AssemblyVersion>1.3.0</AssemblyVersion>
<FileVersion>1.3.0</FileVersion>
<Version>1.3.0</Version>
<PackageVersion>1.3.1</PackageVersion>
<AssemblyVersion>1.3.1</AssemblyVersion>
<FileVersion>1.3.1</FileVersion>
<Version>1.3.1</Version>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Title>philter-sdk-net</Title>
<PackageReadmeFile>README.md</PackageReadmeFile>
<TargetFramework>net7.0</TargetFramework>
<PackageId>Philterd.Philter.Client</PackageId>
<Company>Philterd, LLC</Company>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
<PackageReference Include="RestSharp" Version="106.12.0" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" PrivateAssets="All" Version="1.0.0" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="RestSharp" Version="110.2.0" />
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" PrivateAssets="All" Version="1.0.3" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 9ab7aec

Please sign in to comment.