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)
Unredact
func (r *redact) Unredact(ctx context.Context, input *UnredactRequest) (*pangea.PangeaResponse[UnredactResult], error)Decrypt or unredact fpe redactions
redactcli.Unredact(ctx, &UnredactRequest{
RedactedData: "redacted data",
FPEContext: "gAyHpblmIoUXKTiYY8xKiQ==",
})
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 FPEAlphabet
type FPEAlphabet stringtype FPEAlphabet string
Type MaskingType
type MaskingType stringtype MaskingType string
Type Option
type Option func(*redact) errortype Option func(*redact) error
Type PartialMasking
type PartialMasking structtype PartialMasking struct {
MaskingType *MaskingType `json:"masking_type,omitempty"`
UnmaskedFromLeft *int `json:"unmasked_from_left,omitempty"`
UnmaskedFromRight *int `json:"unmasked_from_right,omitempty"`
MaskedFromLeft *int `json:"masked_from_left,omitempty"`
MaskedFromRight *int `json:"masked_from_right,omitempty"`
CharsToIgnore []string `json:"chars_to_ignore,omitempty"`
MaskingChar []string `json:"masking_char,omitempty"`
}
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 RedactType
type RedactType stringtype RedactType string
Type RedactionMethodOverrides
type RedactionMethodOverrides structtype RedactionMethodOverrides struct {
RedactionType RedactType `json:"redaction_type"`
Hash map[string]interface{} `json:"hash,omitempty"`
FPEAlphabet *FPEAlphabet `json:"fpe_alphabet,omitempty"`
PartialMasking *PartialMasking `json:"partial_masking,omitempty"`
RedactionValue *string `json:"redaction_value,omitempty"`
}
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"`
// A set of redaction method overrides for any enabled rule. These methods override the config declared methods
RedactionMethodOverrides *RedactionMethodOverrides `json:"redaction_method_overrides,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"`
// A set of redaction method overrides for any enabled rule. These methods override the config declared methods
RedactionMethodOverrides *RedactionMethodOverrides `json:"redaction_method_overrides,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 UnredactRequest
type UnredactRequest structtype UnredactRequest struct {
// Base request has ConfigID for multi-config projects
pangea.BaseRequest
// Data to unredact
RedactedData any `json:"redacted_data"`
// FPE context used to decrypt and unredact data (in base64)
FPEContext string `json:"fpe_context"`
}
Type UnredactResult
type UnredactResult structtype UnredactResult struct {
Data any `json:"data"`
}
Type redact
type redact structtype redact struct {
pangea.BaseService
}