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)

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 Option

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

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

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"`
}

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

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"`
}

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 redact

type redact struct
type redact struct {
	pangea.BaseService
}