Skip to main content

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.

required parameters

context.Context
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.

required parameters

context.Context
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

required parameters

context.Context
redactcli.Unredact(ctx, &UnredactRequest{
	RedactedData: "redacted data",
	FPEContext:   "gAyHpblmIoUXKTiYY8xKiQ==",
})

Type Client

type Client interface

required parameters

func(ctx context.Context, req *TextRequest) (*pangea.PangeaResponse[TextResult], error)
context.Context
func(ctx context.Context, req *StructuredRequest) (*pangea.PangeaResponse[StructuredResult], error)
context.Context
pangea.BaseServicer

Base service methods

type 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 struct

required parameters

map[string]int `json:"summary_counts"`
type DebugReport struct {
	SummaryCounts		map[string]int		`json:"summary_counts"`
	RecognizerResults	[]RecognizerResult	`json:"recognizer_results"`
}

Type FPEAlphabet

type FPEAlphabet string
type FPEAlphabet string

Type MaskingType

type MaskingType string
type MaskingType string

Type Option

type Option func(*redact) error
type Option func(*redact) error

Type PartialMasking

type PartialMasking struct

required parameters

*MaskingType `json:"masking_type,omitempty"`
*int `json:"unmasked_from_left,omitempty"`
*int `json:"unmasked_from_right,omitempty"`
*int `json:"masked_from_left,omitempty"`
*int `json:"masked_from_right,omitempty"`
[]string `json:"chars_to_ignore,omitempty"`
[]string `json:"masking_char,omitempty"`
type 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 struct

required parameters

string `json:"field_type"`

FieldType is always populated on a successful response.

*float64 `json:"score"`

Score is always populated on a successful response.

string `json:"text"`

Text is always populated on a successful response.

int `json:"start"`

Start is always populated on a successful response.

int `json:"end"`

End is always populated on a successful response.

bool `json:"redacted"`

Redacted is always populated on a successful response.

string `json:"data_key"`

DataKey is always populated on a successful response.

type 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 string
type RedactType string

Type RedactionMethodOverrides

type RedactionMethodOverrides struct

required parameters

RedactType `json:"redaction_type"`
map[string]interface{} `json:"hash,omitempty"`
*string `json:"redaction_value,omitempty"`
type 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 struct

required parameters

pangea.BaseRequest

Base request has ConfigID for multi-config projects

map[string]any `json:"data"`

Structured data to redact Data is a required field.

[]*string `json:"jsonp,omitempty"`

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.

*string `json:"format,omitempty"`

The format of the structured data to redact.

*bool `json:"debug,omitempty"`

Setting this value to true will provide a detailed analysis of the redacted data and the rules that caused redaction.

[]string `json:"rules,omitempty"`

An array of redact rule short names

[]string `json:"rulesets,omitempty"`

An array of redact rulesets short names

*bool `json:"return_result,omitempty"`

Setting this value to false will omit the redacted result only returning count

A set of redaction method overrides for any enabled rule. These methods override the config declared methods

type 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 struct

required parameters

map[string]any `json:"redacted_data"`

RedactedData is always populated on a successful response.

int `json:"count"`

Number of redactions present in the response

type 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 struct

required parameters

pangea.BaseRequest

Base request has ConfigID for multi-config projects

*string `json:"text"`

The text to be redacted. Text is a required field.

*bool `json:"debug,omitempty"`

If the response should include some debug Info.

[]string `json:"rules,omitempty"`

An array of redact rule short names

[]string `json:"rulesets,omitempty"`

An array of redact rulesets short names

*bool `json:"return_result,omitempty"`

Setting this value to false will omit the redacted result only returning count

A set of redaction method overrides for any enabled rule. These methods override the config declared methods

type 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 struct

required parameters

*string `json:"redacted_text"`

The redacted text.

int `json:"count"`

Number of redactions present in the response

type 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 struct

required parameters

pangea.BaseRequest

Base request has ConfigID for multi-config projects

any `json:"redacted_data"`

Data to unredact

string `json:"fpe_context"`

FPE context used to decrypt and unredact data (in base64)

type 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 struct

required parameters

any `json:"data"`
type UnredactResult struct {
	Data any `json:"data"`
}

Type redact

type redact struct
type redact struct {
	pangea.BaseService
}