Skip to content

Latest commit

 

History

History
185 lines (127 loc) · 7.04 KB

File metadata and controls

185 lines (127 loc) · 7.04 KB

cms_client.RedactionApi

All URIs are relative to http://localhost

Method HTTP request Description
get_redacted_text POST /redact Get Redacted Text
get_redacted_text_with_encryption POST /redact_with_encryption Get Redacted Text With Encryption

get_redacted_text

object get_redacted_text(body, concepts_to_keep=concepts_to_keep, warn_on_no_redaction=warn_on_no_redaction, mask=mask, hash=hash)

Get Redacted Text

Extract and redact NER entities from a single piece of plain text

Example

  • OAuth Authentication (OAuth2PasswordBearer):
  • Api Key Authentication (APIKeyCookie):
import cms_client
from cms_client.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to http://localhost
# See configuration.py for a list of all supported configuration parameters.
configuration = cms_client.Configuration(
    host = "http://localhost"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

configuration.access_token = os.environ["ACCESS_TOKEN"]

# Configure API key authorization: APIKeyCookie
configuration.api_key['APIKeyCookie'] = os.environ["API_KEY"]

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['APIKeyCookie'] = 'Bearer'

# Enter a context with an instance of the API client
with cms_client.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = cms_client.RedactionApi(api_client)
    body = 'body_example' # str | 
    concepts_to_keep = [] # List[Optional[str]] | List of concepts (Label IDs) that should not be removedd during the redaction process. List should be in the format ['label1','label2'...] (optional) (default to [])
    warn_on_no_redaction = True # bool | Return warning when no entities were detected for redaction to prevent potential info leaking (optional)
    mask = 'mask_example' # str | The custom symbols used for masking detected spans (optional)
    hash = True # bool | Whether or not to hash detected spans (optional)

    try:
        # Get Redacted Text
        api_response = api_instance.get_redacted_text(body, concepts_to_keep=concepts_to_keep, warn_on_no_redaction=warn_on_no_redaction, mask=mask, hash=hash)
        print("The response of RedactionApi->get_redacted_text:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling RedactionApi->get_redacted_text: %s\n" % e)

Parameters

Name Type Description Notes
body str
concepts_to_keep List[Optional[str]] List of concepts (Label IDs) that should not be removedd during the redaction process. List should be in the format ['label1','label2'...] [optional] [default to []]
warn_on_no_redaction bool Return warning when no entities were detected for redaction to prevent potential info leaking [optional]
mask str The custom symbols used for masking detected spans [optional]
hash bool Whether or not to hash detected spans [optional]

Return type

object

Authorization

OAuth2PasswordBearer, APIKeyCookie

HTTP request headers

  • Content-Type: text/plain
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 Successful Response -
422 Validation Error -

[Back to top] [Back to API list] [Back to Model list] [Back to README]

get_redacted_text_with_encryption

object get_redacted_text_with_encryption(text_with_public_key, warn_on_no_redaction=warn_on_no_redaction)

Get Redacted Text With Encryption

Redact and encrypt NER entities from a single piece of plain text

Example

  • OAuth Authentication (OAuth2PasswordBearer):
  • Api Key Authentication (APIKeyCookie):
import cms_client
from cms_client.models.text_with_public_key import TextWithPublicKey
from cms_client.rest import ApiException
from pprint import pprint

# Defining the host is optional and defaults to http://localhost
# See configuration.py for a list of all supported configuration parameters.
configuration = cms_client.Configuration(
    host = "http://localhost"
)

# The client must configure the authentication and authorization parameters
# in accordance with the API server security policy.
# Examples for each auth method are provided below, use the example that
# satisfies your auth use case.

configuration.access_token = os.environ["ACCESS_TOKEN"]

# Configure API key authorization: APIKeyCookie
configuration.api_key['APIKeyCookie'] = os.environ["API_KEY"]

# Uncomment below to setup prefix (e.g. Bearer) for API key, if needed
# configuration.api_key_prefix['APIKeyCookie'] = 'Bearer'

# Enter a context with an instance of the API client
with cms_client.ApiClient(configuration) as api_client:
    # Create an instance of the API class
    api_instance = cms_client.RedactionApi(api_client)
    text_with_public_key = cms_client.TextWithPublicKey() # TextWithPublicKey | 
    warn_on_no_redaction = True # bool | Return warning when no entities were detected for redaction to prevent potential info leaking (optional)

    try:
        # Get Redacted Text With Encryption
        api_response = api_instance.get_redacted_text_with_encryption(text_with_public_key, warn_on_no_redaction=warn_on_no_redaction)
        print("The response of RedactionApi->get_redacted_text_with_encryption:\n")
        pprint(api_response)
    except Exception as e:
        print("Exception when calling RedactionApi->get_redacted_text_with_encryption: %s\n" % e)

Parameters

Name Type Description Notes
text_with_public_key TextWithPublicKey
warn_on_no_redaction bool Return warning when no entities were detected for redaction to prevent potential info leaking [optional]

Return type

object

Authorization

OAuth2PasswordBearer, APIKeyCookie

HTTP request headers

  • Content-Type: application/json
  • Accept: application/json

HTTP response details

Status code Description Response headers
200 Successful Response -
422 Validation Error -

[Back to top] [Back to API list] [Back to Model list] [Back to README]