Redact | Golang SDK
The Pangea Redact API helps developers limit the sprawl of sensitive information by performing redaction using defined rules.
Redact
func (r *redact) Redact(ctx context.Context, input *TextRequest) (*pangea.PangeaResponse[TextResult], error)Redacts the content of a single text string.
input := &redact.TextInput{
Text: pangea.String("my phone number is 123-456-7890"),
}
redactResponse, err := redactcli.Redact(ctx, input)
Redact structured
func (r *redact) RedactStructured(ctx context.Context, input *StructuredRequest) (*pangea.PangeaResponse[StructuredResult], error)Redacts text within a structured object.
data := yourCustomDataStruct{
Secret: "My social security number is 0303456",
}
input := &redact.StructuredInput{
Data: data,
}
redactResponse, err := redactcli.RedactStructured(ctx, input)
Type Client
type Client interfacetype Client interface {
Redact(ctx context.Context, req *TextRequest) (*pangea.PangeaResponse[TextResult], error)
RedactStructured(ctx context.Context, req *StructuredRequest) (*pangea.PangeaResponse[StructuredResult], error)
// Base service methods
pangea.BaseServicer
}
Type DebugReport
type DebugReport structtype DebugReport struct {
SummaryCounts map[string]int `json:"summary_counts"`
RecognizerResults []RecognizerResult `json:"recognizer_results"`
}
Type Option
type Option func(*redact) errortype Option func(*redact) error
Type RecognizerResult
type RecognizerResult structtype RecognizerResult struct {
// FieldType is always populated on a successful response.
FieldType string `json:"field_type"`
// Score is always populated on a successful response.
Score *float64 `json:"score"`
// Text is always populated on a successful response.
Text string `json:"text"`
// Start is always populated on a successful response.
Start int `json:"start"`
// End is always populated on a successful response.
End int `json:"end"`
// Redacted is always populated on a successful response.
Redacted bool `json:"redacted"`
// DataKey is always populated on a successful response.
DataKey string `json:"data_key"`
}
Type StructuredRequest
type StructuredRequest structtype StructuredRequest struct {
// Base request has ConfigID for multi-config projects
pangea.BaseRequest
// Structured data to redact
// Data is a required field.
Data map[string]any `json:"data"`
// JSON path(s) used to identify the specific JSON fields to redact in the structured data.
// Note: If jsonp parameter is used, the data parameter must be in JSON format.
JSONP []*string `json:"jsonp,omitempty"`
// The format of the structured data to redact.
Format *string `json:"format,omitempty"`
// Setting this value to true will provide a detailed analysis of the redacted data and the rules that caused redaction.
Debug *bool `json:"debug,omitempty"`
// An array of redact rule short names
Rules []string `json:"rules,omitempty"`
// An array of redact rulesets short names
Rulesets []string `json:"rulesets,omitempty"`
// Setting this value to false will omit the redacted result only returning count
ReturnResult *bool `json:"return_result,omitempty"`
}
Type StructuredResult
type StructuredResult structtype StructuredResult struct {
// RedactedData is always populated on a successful response.
RedactedData map[string]any `json:"redacted_data"`
// Number of redactions present in the response
Count int `json:"count"`
Report *DebugReport `json:"report"`
}
Type TextRequest
type TextRequest structtype TextRequest struct {
// Base request has ConfigID for multi-config projects
pangea.BaseRequest
// The text to be redacted.
// Text is a required field.
Text *string `json:"text"`
// If the response should include some debug Info.
Debug *bool `json:"debug,omitempty"`
// An array of redact rule short names
Rules []string `json:"rules,omitempty"`
// An array of redact rulesets short names
Rulesets []string `json:"rulesets,omitempty"`
// Setting this value to false will omit the redacted result only returning count
ReturnResult *bool `json:"return_result,omitempty"`
}
Type TextResult
type TextResult structtype TextResult struct {
// The redacted text.
RedactedText *string `json:"redacted_text"`
// Number of redactions present in the response
Count int `json:"count"`
Report *DebugReport `json:"report"`
}
Type redact
type redact structtype redact struct {
pangea.BaseService
}