Skip to content

Commit

Permalink
Renaming filter profile to policy. All projects using .net 7.
Browse files Browse the repository at this point in the history
  • Loading branch information
jzonthemtn committed Oct 18, 2023
1 parent f7be27f commit de7180b
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 42 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- name: Setup .NET
uses: actions/setup-dotnet@v1
with:
dotnet-version: 6.0.x
dotnet-version: 7.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand Down
2 changes: 1 addition & 1 deletion philter-sdk-net-tests/PhilterClientTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public void GetAlerts()
Alert alert = new Alert
{
id = Guid.NewGuid().ToString(),
filterProfile = "default",
policy = "default",
strategyId = "1",
context = "context",
documentId = "documentId",
Expand Down
2 changes: 1 addition & 1 deletion philter-sdk-net-tests/philter-sdk-net-tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<RootNamespace>Philter</RootNamespace>

<IsPackable>false</IsPackable>
Expand Down
4 changes: 2 additions & 2 deletions philter-sdk-net/Model/Alert.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ public class Alert
[JsonProperty("id")]
public string id { get; set; }

[JsonProperty("filterProfile")]
public string filterProfile { get; set; }
[JsonProperty("policy")]
public string policy { get; set; }

[JsonProperty("strategyId")]
public string strategyId { get; set; }
Expand Down
72 changes: 36 additions & 36 deletions philter-sdk-net/PhilterClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@ public PhilterClient(RestClient restClient)
/// </summary>
/// <param name="text">The text to be filtered.</param>
/// <param name="context">The context.</param>
/// <param name="filterProfileName">The name of the filter profile to apply.</param>
/// <param name="policyName">The name of the policy to apply.</param>
/// <returns>The filtered text.</returns>
/// <exception cref="ClientException"></exception>
public string Filter(string text, string context, string filterProfileName)
public string Filter(string text, string context, string policyName)
{
return Filter(text, context, string.Empty, filterProfileName);
return Filter(text, context, string.Empty, policyName);
}

/// <summary>
Expand All @@ -85,15 +85,15 @@ public string Filter(string text, string context, string filterProfileName)
/// <param name="text">The text to be filtered.</param>
/// <param name="context">The context.</param>
/// <param name="documentId">The document ID.</param>
/// <param name="filterProfileName">The name of the filter profile to apply.</param>
/// <param name="policyName">The name of the policy to apply.</param>
/// <returns>The filtered text.</returns>
/// <exception cref="ClientException"></exception>
public string Filter(string text, string context, string documentId, string filterProfileName)
public string Filter(string text, string context, string documentId, string policyName)
{

var request = new RestRequest("api/filter", Method.POST);
request.AddParameter("c", context);
request.AddParameter("p", filterProfileName);
request.AddParameter("p", policyName);
request.AddHeader("accept", "text/plain");
request.AddParameter("text/plain", text, ParameterType.RequestBody);

Expand All @@ -119,19 +119,19 @@ public string Filter(string text, string context, string documentId, string filt
/// <param name="fileName">The filename of the PDF document.</param>
/// <param name="context">The context.</param>
/// <param name="documentId">The document ID.</param>
/// <param name="filterProfileName">The name of the filter profile to apply.</param>
/// <param name="policyName">The name of the policy to apply.</param>
/// <param name="responseFormat">The desired format of the returned filtered document.</param>
/// <returns>The filtered document.</returns>
/// <exception cref="ClientException"></exception>
public byte[] Filter(String fileName, string context, string documentId, string filterProfileName, ResponseFormat responseFormat)
public byte[] Filter(String fileName, string context, string documentId, string policyName, ResponseFormat responseFormat)
{
var request = new RestRequest("api/filter", Method.POST);

var bytes = File.ReadAllBytes(fileName);

request.AddParameter("application/pdf", bytes, ParameterType.RequestBody);
request.AddParameter("c", context);
request.AddParameter("p", filterProfileName);
request.AddParameter("p", policyName);

request.AddHeader("Accept", responseFormat == ResponseFormat.Pdf ? "application/pdf" : "image/jpeg");

Expand All @@ -156,12 +156,12 @@ public byte[] Filter(String fileName, string context, string documentId, string
/// </summary>
/// <param name="text">The text to be filtered.</param>
/// <param name="context">The context.</param>
/// <param name="filterProfileName">The name of the filter profile to apply.</param>
/// <param name="policyName">The name of the policy to apply.</param>
/// <returns>The filtered text with the filtering explanation.</returns>
/// <exception cref="ClientException"></exception>
public ExplainResponse Explain(string text, string context, string filterProfileName)
public ExplainResponse Explain(string text, string context, string policyName)
{
return Explain(text, context, String.Empty, filterProfileName);
return Explain(text, context, String.Empty, policyName);
}

/// <summary>
Expand All @@ -170,15 +170,15 @@ public ExplainResponse Explain(string text, string context, string filterProfile
/// <param name="text">The text to be filtered.</param>
/// <param name="context">The context.</param>
/// <param name="documentId">The document ID.</param>
/// <param name="filterProfileName">The name of the filter profile to apply.</param>
/// <param name="policyName">The name of the policy to apply.</param>
/// <returns>The filtered text with the filtering explanation.</returns>
/// <exception cref="ClientException"></exception>
public ExplainResponse Explain(string text, string context, string documentId, string filterProfileName)
public ExplainResponse Explain(string text, string context, string documentId, string policyName)
{

var request = new RestRequest("api/explain", Method.POST);
request.AddParameter("c", context);
request.AddParameter("p", filterProfileName);
request.AddParameter("p", policyName);
request.AddHeader("accept", "application/json");
request.AddParameter("text/plain", text, ParameterType.RequestBody);

Expand Down Expand Up @@ -268,9 +268,9 @@ public void DeleteAlert(string alertId)
}

/// <summary>
/// Get the names of available filter profiles.
/// Get the names of available policies.
/// </summary>
/// <returns>A list of filter profile names.</returns>
/// <returns>A list of policy names.</returns>
/// <exception cref="ClientException"></exception>
public List<string> GetFilterProfiles()
{
Expand All @@ -285,21 +285,21 @@ public List<string> GetFilterProfiles()
return JsonConvert.DeserializeObject<List<string>>(response.Content);
}

throw new ClientException("Unable to get filter profiles.", response.ErrorException);
throw new ClientException("Unable to get policies.", response.ErrorException);

}

/// <summary>
/// Get a filter profile.
/// Get a policy.
/// </summary>
/// <param name="filterProfileName">The name of a filter profile.</param>
/// <returns>The filter profile.</returns>
/// <param name="policyName">The name of a policy.</param>
/// <returns>The policy.</returns>
/// <exception cref="ClientException"></exception>
public string GetFilterProfile(string filterProfileName)
public string GetFilterProfile(string policyName)
{

var request = new RestRequest("api/profiles/{filterProfileName}", Method.GET);
request.AddParameter("filterProfileName", filterProfileName, ParameterType.UrlSegment);
var request = new RestRequest("api/profiles/{policyName}", Method.GET);
request.AddParameter("policyName", policyName, ParameterType.UrlSegment);
request.AddHeader("accept", "application/json");

var response = _client.Execute(request);
Expand All @@ -309,47 +309,47 @@ public string GetFilterProfile(string filterProfileName)
return response.Content;
}

throw new ClientException("Unable to get filter profile.", response.ErrorException);
throw new ClientException("Unable to get policy.", response.ErrorException);

}

/// <summary>
/// Upload a filter profile. If a filter profile with the same name already exists it will be overwritten.
/// Upload a policy. If a policy with the same name already exists it will be overwritten.
/// </summary>
/// <param name="filterProfile">The filter profile.</param>
/// <param name="policy">The policy.</param>
/// <exception cref="ClientException"></exception>
public void SaveFilterProfile(string filterProfile)
public void SaveFilterProfile(string policy)
{

var request = new RestRequest("api/profiles", Method.POST);
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", filterProfile, ParameterType.RequestBody);
request.AddParameter("application/json", policy, ParameterType.RequestBody);

var response = _client.Execute(request);

if (!response.IsSuccessful)
{
throw new ClientException("Unable to save filter profile.", response.ErrorException);
throw new ClientException("Unable to save policy.", response.ErrorException);
}

}

/// <summary>
/// Delete a filter profile.
/// Delete a policy.
/// </summary>
/// <param name="filterProfileName">The name of the filter profile to delete.</param>
/// <param name="policyName">The name of the policy to delete.</param>
/// <exception cref="ClientException"></exception>
public void DeleteFilterProfile(string filterProfileName)
public void DeleteFilterProfile(string policyName)
{

var request = new RestRequest("api/profiles/{filterProfileName}", Method.DELETE);
request.AddParameter("filterProfileName", filterProfileName, ParameterType.UrlSegment);
var request = new RestRequest("api/profiles/{policyName}", Method.DELETE);
request.AddParameter("policyName", policyName, ParameterType.UrlSegment);

var response = _client.Execute(request);

if (!response.IsSuccessful)
{
throw new ClientException("Unable to delete filter profile.", response.ErrorException);
throw new ClientException("Unable to delete policy.", response.ErrorException);
}

}
Expand Down
2 changes: 1 addition & 1 deletion philter-sdk-net/philter-sdk-net.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<Title>philter-sdk-net</Title>
<PackageReadmeFile>README.md</PackageReadmeFile>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>net7.0</TargetFramework>
<Company>Philterd, LLC</Company>
</PropertyGroup>

Expand Down

0 comments on commit de7180b

Please sign in to comment.