From 0f16d861030120b4d0311d885d5adedc981f95c6 Mon Sep 17 00:00:00 2001 From: jzonthemtn Date: Tue, 17 Oct 2023 14:48:35 -0400 Subject: [PATCH] Renaming filter profile to policy. --- .../ai/philterd/philter/PhilterClient.java | 56 +++++++++---------- .../java/ai/philterd/philter/model/Alert.java | 6 +- .../philter/model/BinaryFilterResponse.java | 2 +- .../philter/model/ExplainResponse.java | 2 +- .../philterd/philter/model/Explanation.java | 2 +- .../philter/model/FilterResponse.java | 2 +- .../philterd/philter/model/FilteredSpan.java | 2 +- .../java/ai/philterd/philter/model/Span.java | 2 +- .../philter/model/StatusResponse.java | 2 +- .../philter/services/PhilterService.java | 24 ++++---- .../test/philter/PhilterClientTest.java | 34 +++++------ 11 files changed, 67 insertions(+), 67 deletions(-) diff --git a/src/main/java/ai/philterd/philter/PhilterClient.java b/src/main/java/ai/philterd/philter/PhilterClient.java index 4d9fc97..aad8d0b 100644 --- a/src/main/java/ai/philterd/philter/PhilterClient.java +++ b/src/main/java/ai/philterd/philter/PhilterClient.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2020 Mountain Fog, Inc. + * Copyright 2023 Philterd, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy @@ -37,7 +37,7 @@ /** * Client class for Philter's API. Philter finds and manipulates sensitive information in text. - * For more information on Philter see https://www.mtnfog.com. + * For more information on Philter see https://www.philterd.ai. */ public class PhilterClient extends AbstractClient { @@ -146,14 +146,14 @@ private void configureSSL(final OkHttpClient.Builder okHttpClientBuilder, String * Send text to Philter to be filtered. * @param context The context. Contexts can be used to group text based on some arbitrary property. * @param documentId The document ID. Leave empty for Philter to assign a document ID to the request. - * @param filterProfileName The name of the filter profile to apply to the text. + * @param policyName The name of the policy to apply to the text. * @param text The text to be filtered. * @return The filtered text. * @throws IOException Thrown if the request can not be completed. */ - public FilterResponse filter(String context, String documentId, String filterProfileName, String text) throws IOException { + public FilterResponse filter(String context, String documentId, String policyName, String text) throws IOException { - final Response response = service.filter(context, documentId, filterProfileName, text).execute(); + final Response response = service.filter(context, documentId, policyName, text).execute(); if(response.isSuccessful()) { @@ -184,17 +184,17 @@ public FilterResponse filter(String context, String documentId, String filterPro * Send a PDF document to Philter to be filtered. * @param context The context. Contexts can be used to group text based on some arbitrary property. * @param documentId The document ID. Leave empty for Philter to assign a document ID to the request. - * @param filterProfileName The name of the filter profile to apply to the text. + * @param policyName The name of the policy to apply to the text. * @param file The PDF file to be filtered. * @return The filtered text. * @throws IOException Thrown if the request can not be completed. */ - public BinaryFilterResponse filter(String context, String documentId, String filterProfileName, File file) throws IOException { + public BinaryFilterResponse filter(String context, String documentId, String policyName, File file) throws IOException { final byte[] params = FileUtils.readFileToByteArray(file); final RequestBody body = RequestBody.create(MediaType.parse("application/pdf"), params); - final Response response = service.filter(context, documentId, filterProfileName, body).execute(); + final Response response = service.filter(context, documentId, policyName, body).execute(); if(response.isSuccessful()) { @@ -225,14 +225,14 @@ public BinaryFilterResponse filter(String context, String documentId, String fil * Send text to Philter to be filtered and get an explanation. * @param context The context. Contexts can be used to group text based on some arbitrary property. * @param documentId The document ID. Leave empty for Philter to assign a document ID to the request. - * @param filterProfileName The name of the filter profile to apply to the text. + * @param policyName The name of the policy to apply to the text. * @param text The text to be filtered. * @return The filter {@link ExplainResponse}. * @throws IOException Thrown if the request can not be completed. */ - public ExplainResponse explain(String context, String documentId, String filterProfileName, String text) throws IOException { + public ExplainResponse explain(String context, String documentId, String policyName, String text) throws IOException { - final Response response = service.explain(context, documentId, filterProfileName, text).execute(); + final Response response = service.explain(context, documentId, policyName, text).execute(); if(response.isSuccessful()) { @@ -323,13 +323,13 @@ public StatusResponse status() throws IOException { } /** - * Gets a list of filter profile names. - * @return A list of filter profile names. + * Gets a list of policy names. + * @return A list of policy names. * @throws IOException Thrown if the call not be executed. */ - public List getFilterProfiles() throws IOException { + public List getPolicies() throws IOException { - final Response> response = service.getFilterProfile().execute(); + final Response> response = service.Policy().execute(); if(response.isSuccessful()) { @@ -356,14 +356,14 @@ public List getFilterProfiles() throws IOException { } /** - * Gets the content of a filter profile. - * @param filterProfileName The name of the filter profile to get. - * @return The content of the filter profile. + * Gets the content of a policy. + * @param policyName The name of the policy to get. + * @return The content of the policy. * @throws IOException Thrown if the call not be executed. */ - public String getFilterProfile(String filterProfileName) throws IOException { + public String Policy(String policyName) throws IOException { - final Response response = service.getFilterProfile(filterProfileName).execute(); + final Response response = service.Policy(policyName).execute(); if(response.isSuccessful()) { @@ -390,13 +390,13 @@ public String getFilterProfile(String filterProfileName) throws IOException { } /** - * Saves (or overwrites) the filter profile. - * @param json The body of the filter profile. + * Saves (or overwrites) the policy. + * @param json The body of the policy. * @throws IOException Thrown if the call not be executed. */ - public void saveFilterProfile(String json) throws IOException { + public void savePolicy(String json) throws IOException { - final Response response = service.saveFilterProfile(json).execute(); + final Response response = service.savePolicy(json).execute(); if(!response.isSuccessful()) { @@ -419,13 +419,13 @@ public void saveFilterProfile(String json) throws IOException { } /** - * Deletes a filter profile. - * @param filterProfileName The name of the filter profile to delete. + * Deletes a policy. + * @param policyName The name of the policy to delete. * @throws IOException Thrown if the call not be executed. */ - public void deleteFilterProfile(String filterProfileName) throws IOException { + public void deletePolicy(String policyName) throws IOException { - final Response response = service.deleteFilterProfile(filterProfileName).execute(); + final Response response = service.deletePolicy(policyName).execute(); if(!response.isSuccessful()) { diff --git a/src/main/java/ai/philterd/philter/model/Alert.java b/src/main/java/ai/philterd/philter/model/Alert.java index b674b2f..b21286c 100644 --- a/src/main/java/ai/philterd/philter/model/Alert.java +++ b/src/main/java/ai/philterd/philter/model/Alert.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2020 Mountain Fog, Inc. + * Copyright 2023 Philterd, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy @@ -76,11 +76,11 @@ public void setId(String id) { this.id = id; } - public String getFilterProfile() { + public String Policy() { return this.filterProfile; } - public void setFilterProfile(String filterProfile) { + public void setPolicy(String filterProfile) { this.filterProfile = filterProfile; } diff --git a/src/main/java/ai/philterd/philter/model/BinaryFilterResponse.java b/src/main/java/ai/philterd/philter/model/BinaryFilterResponse.java index ee4327a..3554504 100644 --- a/src/main/java/ai/philterd/philter/model/BinaryFilterResponse.java +++ b/src/main/java/ai/philterd/philter/model/BinaryFilterResponse.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2020 Mountain Fog, Inc. + * Copyright 2023 Philterd, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy diff --git a/src/main/java/ai/philterd/philter/model/ExplainResponse.java b/src/main/java/ai/philterd/philter/model/ExplainResponse.java index 5c964f3..d78c089 100644 --- a/src/main/java/ai/philterd/philter/model/ExplainResponse.java +++ b/src/main/java/ai/philterd/philter/model/ExplainResponse.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2020 Mountain Fog, Inc. + * Copyright 2023 Philterd, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy diff --git a/src/main/java/ai/philterd/philter/model/Explanation.java b/src/main/java/ai/philterd/philter/model/Explanation.java index 33328d8..569d5fd 100644 --- a/src/main/java/ai/philterd/philter/model/Explanation.java +++ b/src/main/java/ai/philterd/philter/model/Explanation.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2020 Mountain Fog, Inc. + * Copyright 2023 Philterd, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy diff --git a/src/main/java/ai/philterd/philter/model/FilterResponse.java b/src/main/java/ai/philterd/philter/model/FilterResponse.java index 838c126..275fce4 100644 --- a/src/main/java/ai/philterd/philter/model/FilterResponse.java +++ b/src/main/java/ai/philterd/philter/model/FilterResponse.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2020 Mountain Fog, Inc. + * Copyright 2023 Philterd, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy diff --git a/src/main/java/ai/philterd/philter/model/FilteredSpan.java b/src/main/java/ai/philterd/philter/model/FilteredSpan.java index fbe7982..1ecf9d7 100644 --- a/src/main/java/ai/philterd/philter/model/FilteredSpan.java +++ b/src/main/java/ai/philterd/philter/model/FilteredSpan.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2020 Mountain Fog, Inc. + * Copyright 2023 Philterd, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy diff --git a/src/main/java/ai/philterd/philter/model/Span.java b/src/main/java/ai/philterd/philter/model/Span.java index ea3a8bb..14a4959 100644 --- a/src/main/java/ai/philterd/philter/model/Span.java +++ b/src/main/java/ai/philterd/philter/model/Span.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2020 Mountain Fog, Inc. + * Copyright 2023 Philterd, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy diff --git a/src/main/java/ai/philterd/philter/model/StatusResponse.java b/src/main/java/ai/philterd/philter/model/StatusResponse.java index 89e5713..5ee6570 100644 --- a/src/main/java/ai/philterd/philter/model/StatusResponse.java +++ b/src/main/java/ai/philterd/philter/model/StatusResponse.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2020 Mountain Fog, Inc. + * Copyright 2023 Philterd, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy diff --git a/src/main/java/ai/philterd/philter/services/PhilterService.java b/src/main/java/ai/philterd/philter/services/PhilterService.java index 89fe803..3d94b41 100644 --- a/src/main/java/ai/philterd/philter/services/PhilterService.java +++ b/src/main/java/ai/philterd/philter/services/PhilterService.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2020 Mountain Fog, Inc. + * Copyright 2023 Philterd, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy @@ -32,16 +32,16 @@ public interface PhilterService { @Headers({"Accept: text/plain", "Content-Type: text/plain"}) @POST("/api/filter") - Call filter(@Query("c") String context, @Query("d") String documentId, @Query("p") String filterProfileName, @Body String text); + Call filter(@Query("c") String context, @Query("d") String documentId, @Query("p") String policyName, @Body String text); @Streaming @Headers({"Accept: application/zip", "Content-Type: application/pdf"}) @POST("/api/filter") - Call filter(@Query("c") String context, @Query("d") String documentId, @Query("p") String filterProfileName, @Body RequestBody bytes); + Call filter(@Query("c") String context, @Query("d") String documentId, @Query("p") String policyName, @Body RequestBody bytes); @Headers({"Accept: application/json", "Content-Type: text/plain"}) @POST("/api/explain") - Call explain(@Query("c") String context, @Query("d") String documentId, @Query("p") String filterProfileName, @Body String text); + Call explain(@Query("c") String context, @Query("d") String documentId, @Query("p") String policyName, @Body String text); @GET("/api/replacements") Call> replacements(@Query("d") String documentId); @@ -54,19 +54,19 @@ public interface PhilterService { // Filter Profiles @Headers({"Accept: application/json"}) - @GET("/api/profiles") - Call> getFilterProfile(); + @GET("/api/policies") + Call> Policy(); @Headers({"Accept: text/plain"}) - @GET("/api/profiles/{name}") - Call getFilterProfile(@Path("name") String filterProfileName); + @GET("/api/policies/{name}") + Call Policy(@Path("name") String policyName); @Headers({"Content-Type: application/json"}) - @POST("/api/profiles") - Call saveFilterProfile(@Body String json); + @POST("/api/policies") + Call savePolicy(@Body String json); - @DELETE("/api/profiles/{name}") - Call deleteFilterProfile(@Path("name") String filterProfileName); + @DELETE("/api/policies/{name}") + Call deletePolicy(@Path("name") String policyName); // Alerts diff --git a/src/test/java/com/mtnfog/test/philter/PhilterClientTest.java b/src/test/java/com/mtnfog/test/philter/PhilterClientTest.java index 5a5a192..df9cdcd 100644 --- a/src/test/java/com/mtnfog/test/philter/PhilterClientTest.java +++ b/src/test/java/com/mtnfog/test/philter/PhilterClientTest.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright 2020 Mountain Fog, Inc. + * Copyright 2023 Philterd, LLC * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy @@ -66,32 +66,32 @@ public void filterPdf() throws Exception { } @Test - public void getFilterProfiles() throws Exception { + public void getPolicies() throws Exception { final PhilterClient client = new PhilterClient.PhilterClientBuilder() .withEndpoint(ENDPOINT) .withOkHttpClientBuilder(getUnsafeOkHttpClientBuilder()) .build(); - final List filterProfileNames = client.getFilterProfiles(); + final List policyNames = client.getPolicies(); - Assert.assertTrue(filterProfileNames != null); - Assert.assertFalse(filterProfileNames.isEmpty()); + Assert.assertTrue(policyNames != null); + Assert.assertFalse(policyNames.isEmpty()); - for(final String name : filterProfileNames) { - LOGGER.info("Filter profile: {}", name); + for(final String name : policyNames) { + LOGGER.info("Policy: {}", name); } } @Test(expected = SSLHandshakeException.class) - public void getFilterProfilesNoCertificate() throws Exception { + public void getPoliciesNoCertificate() throws Exception { final PhilterClient client = new PhilterClient.PhilterClientBuilder() .withEndpoint(ENDPOINT) .build(); - client.getFilterProfiles(); + client.getPolicies(); } @@ -104,13 +104,13 @@ public void get() throws Exception { "/tmp/keystore-server.jks", "changeit") .build(); - final List filterProfileNames = client.getFilterProfiles(); + final List policyNames = client.getPolicies(); - Assert.assertTrue(filterProfileNames != null); - Assert.assertFalse(filterProfileNames.isEmpty()); + Assert.assertTrue(policyNames != null); + Assert.assertFalse(policyNames.isEmpty()); - for(final String name : filterProfileNames) { - LOGGER.info("Filter profile: {}", name); + for(final String name : policyNames) { + LOGGER.info("Policy: {}", name); } } @@ -124,12 +124,12 @@ public void getByName() throws Exception { "/tmp/keystore-server.jks", "changeit") .build(); - final String filterProfile = client.getFilterProfile("default"); + final String filterProfile = client.Policy("default"); Assert.assertTrue(filterProfile != null); Assert.assertTrue(filterProfile.length() > 0); - LOGGER.info("Filter profile:\n{}", filterProfile); + LOGGER.info("Policy:\n{}", filterProfile); } @@ -144,7 +144,7 @@ public void save() throws Exception { final String json = IOUtils.toString(this.getClass().getResource("/default2.json"), Charset.defaultCharset()); - client.saveFilterProfile(json); + client.savePolicy(json); }