redact

package
v2.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 5, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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
	GetPendingRequestID() []string
	PollResultByError(ctx context.Context, e pangea.AcceptedError) (*pangea.PangeaResponse[any], error)
	PollResultByID(ctx context.Context, rid string, v any) (*pangea.PangeaResponse[any], error)
	PollResultRaw(ctx context.Context, requestID string) (*pangea.PangeaResponse[map[string]any], error)
}

func New

func New(cfg *pangea.Config) Client

type DebugReport

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

type RecognizerResult

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 {
	// 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 {
	// 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 {
	// 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 {
	// The redacted text.
	RedactedText *string `json:"redacted_text"`

	// Number of redactions present in the response
	Count int `json:"count"`

	Report *DebugReport `json:"report"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL